Skip to content

[visitors] Add visitors that add more components inside a ProgramNode #83

Description

@lorisleiva

It would be useful to have visitors such as addAccountsVisitor, addInstructionsVisitor, addDefinedTypesVisitor, addErrorsVisitor, etc.

By default these visitors would add the provided nodes to the main program of the RootNode.

// Example.
codama.update(
  addDefinedTypesVisitor([
    definedTypeNode({ name: 'slot', type: numberTypeNode('u64') }),
    definedTypeNode({ name: 'hash', type: publicKeyTypeNode() })
  ])
);

However, we could also support an additional signature that would look for the correct ProgramNode using the provided program name.

// Example.
codama.update(
  addDefinedTypesVisitor('someAdditionalProgram', [
    definedTypeNode({ name: 'slot', type: numberTypeNode('u64') }),
    definedTypeNode({ name: 'hash', type: publicKeyTypeNode() })
  ])
);

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions