Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add visitors that add more components inside a ProgramNode #83

Open
lorisleiva opened this issue Jun 19, 2024 · 0 comments
Open

Add visitors that add more components inside a ProgramNode #83

lorisleiva opened this issue Jun 19, 2024 · 0 comments
Labels
proposal Suggesting a change / new feature

Comments

@lorisleiva
Copy link
Member

lorisleiva commented Jun 19, 2024

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() })
  ])
);
@lorisleiva lorisleiva added the proposal Suggesting a change / new feature label Jun 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
proposal Suggesting a change / new feature
Projects
None yet
Development

No branches or pull requests

1 participant