-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
interface: Support multiple programs with the same interface via token-2022 #2386
Conversation
@joncinque is attempting to deploy a commit to the coral-xyz Team on Vercel. A member of the Team first needs to authorize it. |
Love the naming of this @joncinque - far more succinct than my word salad! Keen to push for this to get merged - as well as the token_program constraint. |
This is great but I think it needs some tests around the Ability to use only the spl-token-2022 program would be useful too. i.e. pub token_program: Program<'info, anchor_spl:token_2022::Token2022>, This can be added separately though. |
I've added some init tests for mints, accounts, and associated accounts. Thanks for the feedback! |
636e3a0
to
58359e3
Compare
1769d60
to
4c84ae2
Compare
This looks pretty much ready to merge I think. @joncinque is there anything else you have left on your todo list? Do you think it's ready to merge. |
@Henry-E this is good to go from my side! Let me know if you want me to make any of the proposed changes we've discussed (renaming |
No that's ok, both the Great, I will probably do one more quick readthrough and then merge. |
Problem
Token-2022 is close to ready for mainnet adoption, but Anchor doesn't support it yet.
Solution
Support both programs, and take it a step further by adding support for "interface" programs and accounts.
As a coincidence, a lot of this work resembles the excellent work at #2363, so I hope that our efforts can be combined!
Overall, things are very similar, except for the implementation / naming for the interface account, which are called "multi-program" in the other PR. The main difference is relaxing type constraints in order to maximally reuse
Account
andProgram
implementations.#2363 also adds a token program constraint, which would be a very useful addition for dual-token-program support.
This also adds test support for two token programs in the escrow and token-proxy test programs, to show that this actually works. Each commit in this PR is deliberate, showing the succession of PRs that would require to get this in:
If this looks ok, I'm happy to work with @elliotkennedy on getting everything in!