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

Can we autogenerate instruction creators and account decoders for an existing program? #30

Open
mikemaccana opened this issue Mar 20, 2024 · 6 comments

Comments

@mikemaccana
Copy link

The web3.js TP2 announment points to this repo with a 'here' link and the following text:

Instruction creators and account decoders can now be autogenerated for any program, including your own!

The README seems to imply generating clients for brand new projects, but can we use create-solana-program to generate clients for existing on-chain apps as the announcement states?

@mikemaccana mikemaccana changed the title Can we autogegnerate instruction creators and account decoders for an existing program? Can we autogenerate instruction creators and account decoders for an existing program? Mar 20, 2024
@lorisleiva
Copy link
Member

Hey Mike,

Yes that's the plan.

We're already doing this for the following programs:

And planning to add many more to the list.

@ronanyeah
Copy link

Is there a way to avoid copy pasting the scripts contents? Such as an API like this:

create-solana-program generate:clients ./idl.json --js --output ./codegen"

@lorisleiva
Copy link
Member

Hi @ronanyeah, sorry I'm not sure I understand the question. Are you saying you do not want the scripts folder to be present in the generated repository? If so, I'm not sure how the provided snippet of code helps with that.

@mikemaccana
Copy link
Author

Thanks for answering @loris but I realise I should have been clearer:

can we use create-solana-program to generate clients for existing on-chain apps as the announcement states?

I meant to say: how can we we use create-solana-program to generate clients for existing on-chain apps? Eg what docs or examples exist for using create-solana-program in this way?

@lorisleiva
Copy link
Member

Oh I see. No docs right now and it's on a case-by-case basis but we're using the following process:

  1. Run pnpm create solana-program my-existing-program --address MyExistingProgramAddress
  2. Follow the prompts and use these naming conventions.
  3. Replace the program folder with the existing program — or empty it and add idl.json inside for non-yet-migrated BPF programs.
  4. Make existing program use Shank if it's not already so we can generate an IDL from it.
  5. pnpm generate

@mikemaccana
Copy link
Author

Thanks! I'm in the middle of trying to get instructor notes together for something but will try on one of our demo apps as soon as I can.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants