-
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
lang: associated_token
constraints don't work when setting token_program
#2603
Conversation
@wjthieme is attempting to deploy a commit to the coral-xyz Team on Vercel. A member of the Team first needs to authorize it. |
Yes, please check #2541 (comment). This line also needs to change.
And a test case for this would be great #2447 (comment). |
Done! |
Hey, thank you so much for adding the tests but could you move them to |
Thanks @acheroncrypto! Must have overlooked those. I changed the already existing tests for associated token constraints that were supposed to catch this bug as I felt adding a new cases would be a little bit redundant |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I changed the already existing tests for associated token constraints that were supposed to catch this bug as I felt adding a new cases would be a little bit redundant
Those tests don't use the interface program so tests will fail with the current form. It would be better to add a new test case for this situation because we would also want to keep the tests for the standard token program.
Interesting as the tests were succeeding when I ran them locally. Let me investigate |
It succeeds because there is no functional change in tests(token program id is the same) but it will fail if you put the correct Token 2022 program id. |
Yep. Figured that out. I fixed the tests that uses a custom There are a couple of functions in
All tests should be passing now at least. @acheroncrypto lemme know what you think |
I'd still prefer not modifying existing program instructions since they are testing a different case(where you use
Token 2022 is a superset of the standard Token program which means anything that works with Token should also work with Token 2022.
They don't pass because |
Yep, but getting
Fixed |
@@ -1195,31 +1195,31 @@ const miscTest = ( | |||
|
|||
it("associated_token constraints (no init) - Can make with associated_token::token_program", async () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
associated_token::token_program
will still fail with Token 2022 on non-init accounts. I've modified this test to use Token 2022 to show the failure(#2603 (comment)).
Think this one is done now, right? Thanks for fixing that last issue @acheroncrypto! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
commit cec9946 Author: Jesserc <raymondjesse713@gmail.com> Date: Sun Sep 10 20:32:34 2023 +0100 docs: Fix typo and grammar in error documentation commit 4955a92 Author: acheron <98934430+acheroncrypto@users.noreply.github.com> Date: Fri Sep 8 10:01:51 2023 +0200 Add byte slice(`&[u8]`) support for `idl-build` (coral-xyz#2622) commit a1e4453 Author: acheron <98934430+acheroncrypto@users.noreply.github.com> Date: Tue Sep 5 17:30:53 2023 +0200 cli: Make conflicting account names a compile-time error (coral-xyz#2621) commit b9fa898 Author: acheron <98934430+acheroncrypto@users.noreply.github.com> Date: Fri Sep 1 22:42:06 2023 +0200 cli: Fix `anchor account` command panicking outside of workspace (coral-xyz#2620) commit dcf5928 Author: Will <82029448+wjthieme@users.noreply.github.com> Date: Wed Aug 30 19:28:51 2023 +0200 lang: `Box` the inner enums of `anchor_lang::error::Error` (coral-xyz#2600) Co-authored-by: acheron <acheroncrypto@gmail.com> commit 115679e Author: acheron <98934430+acheroncrypto@users.noreply.github.com> Date: Mon Aug 28 14:13:12 2023 +0200 bench: Add benchmarking for stack memory usage (coral-xyz#2617) commit a5e4c02 Author: acheron <98934430+acheroncrypto@users.noreply.github.com> Date: Sun Aug 27 10:21:17 2023 +0200 ts: Bump packages to `0.28.1-beta.2` (coral-xyz#2616) commit a7205af Author: Will <82029448+wjthieme@users.noreply.github.com> Date: Wed Aug 23 22:10:08 2023 +0200 lang: `associated_token` constraints don't work when setting `token_program` (coral-xyz#2603) Co-authored-by: acheron <acheroncrypto@gmail.com> commit 6f9f7d9 Author: acheron <98934430+acheroncrypto@users.noreply.github.com> Date: Sat Aug 19 13:09:09 2023 +0200 tests: Move IDL related tests in `misc` to `idl` (coral-xyz#2606) commit 6eacad4 Author: acheron <98934430+acheroncrypto@users.noreply.github.com> Date: Tue Aug 15 23:58:17 2023 +0200 cli: Add program template with multiple files (coral-xyz#2602) commit 454f1dd Author: acheron <98934430+acheroncrypto@users.noreply.github.com> Date: Sun Aug 13 16:50:28 2023 +0200 ts: Add support for unnamed(tuple) enum in accounts (coral-xyz#2601) commit b5cf67f Author: Jimii <30603522+jim4067@users.noreply.github.com> Date: Sat Aug 12 23:02:37 2023 +0300 spl: Add `TokenRecordAccount` for pNFTs (coral-xyz#2597) commit 58428f8 Author: Proph3t <metaproph3t@protonmail.com> Date: Fri Aug 11 19:48:28 2023 +0000 Add `setup_tests.sh` for setting up your local machine for tests (coral-xyz#2594) commit 4cf447a Author: acheron <98934430+acheroncrypto@users.noreply.github.com> Date: Tue Aug 8 22:03:31 2023 +0200 bench: Add benchmarking for program binary size (coral-xyz#2591) commit abfdc4e Author: acheron <98934430+acheroncrypto@users.noreply.github.com> Date: Sat Aug 5 23:47:06 2023 +0200 chore: Remove duplicate dependency and and alphabetize features (coral-xyz#2590) commit 2af9cc6 Author: acheron <98934430+acheroncrypto@users.noreply.github.com> Date: Wed Aug 2 23:01:05 2023 +0200 cli: Improve converting non-conflicting paths to names in IDL (coral-xyz#2588) commit be8764b Author: Proph3t <metaproph3t@protonmail.com> Date: Tue Aug 1 20:23:48 2023 +0000 Fix typo in account.rs docs (coral-xyz#2587) commit b7b8736 Author: acheron <98934430+acheroncrypto@users.noreply.github.com> Date: Mon Jul 31 23:41:12 2023 +0200 spl: Export `mpl-token-metadata` crate (coral-xyz#2583) commit cad868a Author: acheron <98934430+acheroncrypto@users.noreply.github.com> Date: Sat Jul 29 23:49:17 2023 +0200 Make the new IDL features explicit (coral-xyz#2582) commit 8f30f00 Author: acheron <98934430+acheroncrypto@users.noreply.github.com> Date: Thu Jul 27 23:29:26 2023 +0200 tests: Improve IDL comparison tests (coral-xyz#2581) commit df3e959 Author: Pierre <Arrowana@users.noreply.github.com> Date: Thu Jul 27 07:56:12 2023 +1000 chore: Use @noble/hashes/sha256 rather than obscure package (coral-xyz#2580) commit 5eb678a Author: acheron <98934430+acheroncrypto@users.noreply.github.com> Date: Tue Jul 25 23:52:26 2023 +0200 ts: Lazy load workspace programs and improve program name accessor (coral-xyz#2579) commit 4604fbe Author: acheron <98934430+acheroncrypto@users.noreply.github.com> Date: Sat Jul 22 16:39:05 2023 +0200 cli: Automatically decide IDL generation method (coral-xyz#2578) commit c548c85 Author: Jean Marchand (Exotic Markets) <jeanno11@orange.fr> Date: Sat Jul 22 12:43:56 2023 +0200 chore: Remove unused crates (coral-xyz#2577) commit 2bb3237 Author: Jean Marchand (Exotic Markets) <jeanno11@orange.fr> Date: Fri Jul 21 11:04:52 2023 +0200 chore: Fix clippy lints (coral-xyz#2576) commit 10eb698 Author: dromaz <92167972+dromaz@users.noreply.github.com> Date: Thu Jul 20 23:58:13 2023 +0200 avm: Add support for the `.anchorversion` file (coral-xyz#2553) Co-authored-by: acheron <acheroncrypto@gmail.com> commit 8309bb3 Author: acheron <98934430+acheroncrypto@users.noreply.github.com> Date: Wed Jul 19 18:28:38 2023 +0200 cli: Fix `anchor build --no-docs` (coral-xyz#2575) commit c306463 Author: acheron <98934430+acheroncrypto@users.noreply.github.com> Date: Mon Jul 17 22:47:55 2023 +0200 tests: Refactor IDL tests (coral-xyz#2573) commit cf057ac Author: acheron <98934430+acheroncrypto@users.noreply.github.com> Date: Sun Jul 16 17:08:25 2023 +0200 client: Fix compilation with Solana `1.14` (coral-xyz#2572) commit 4e5280b Author: acheron <98934430+acheroncrypto@users.noreply.github.com> Date: Fri Jul 14 23:17:23 2023 +0200 cli: Fix workspace inheritence (coral-xyz#2570) commit cfc6d29 Author: Lucas Steuernagel <38472950+LucasSte@users.noreply.github.com> Date: Fri Jul 14 16:29:16 2023 -0300 cli: Bump `solang-parser` version (coral-xyz#2569) commit 472279d Author: acheron <98934430+acheroncrypto@users.noreply.github.com> Date: Thu Jul 13 22:06:12 2023 +0200 cli: Add `--out` and `--out-ts` arguments for `idl build` command (coral-xyz#2566) commit b7e91d4 Author: acheron <98934430+acheroncrypto@users.noreply.github.com> Date: Tue Jul 11 19:05:14 2023 +0200 Remove IDL `path` field (coral-xyz#2564) commit 6ef6b79 Author: Krešimir Klas <kklas@users.noreply.github.com> Date: Sat Jul 8 19:59:30 2023 +0200 IDL generation through compilation (coral-xyz#2011) Co-authored-by: acheron <acheroncrypto@gmail.com> commit 0225b7c Author: Noah Prince <83885631+ChewingGlass@users.noreply.github.com> Date: Fri Jul 7 14:30:38 2023 -0700 lang: Allow polymorphic CPI calls matching an interface (coral-xyz#2559) commit 9ff7dfc Author: Jean Marchand (Exotic Markets) <jeanno11@orange.fr> Date: Wed Jul 5 10:05:37 2023 +0200 lang: Support for `const` in the `InitSpace` macro (coral-xyz#2555) commit 401d526 Author: chalda <chalda@marinade.finance> Date: Mon Jul 3 22:56:58 2023 +0200 client: Add `DynSigner` (coral-xyz#2550) commit e55cd3e Author: acheron <98934430+acheroncrypto@users.noreply.github.com> Date: Sat Jul 1 22:59:36 2023 +0200 lang: Add `Lamports` trait (coral-xyz#2552) commit 5624bfe Author: Jean Marchand (Exotic Markets) <jeanno11@orange.fr> Date: Thu Jun 29 13:35:38 2023 +0200 lang: Fix typo in the doc (coral-xyz#2551) commit 29b8a72 Author: acheron <98934430+acheroncrypto@users.noreply.github.com> Date: Tue Jun 27 20:03:51 2023 +0200 bench: Show change amount and add change note (coral-xyz#2549) commit 8bdc1b1 Author: Han Yang <dhy1996@live.com.sg> Date: Tue Jun 27 01:04:30 2023 +0800 spl: Only allow spl-token version above 1.1 (coral-xyz#2546)
commit cec9946 Author: Jesserc <raymondjesse713@gmail.com> Date: Sun Sep 10 20:32:34 2023 +0100 docs: Fix typo and grammar in error documentation commit 4955a92 Author: acheron <98934430+acheroncrypto@users.noreply.github.com> Date: Fri Sep 8 10:01:51 2023 +0200 Add byte slice(`&[u8]`) support for `idl-build` (coral-xyz#2622) commit a1e4453 Author: acheron <98934430+acheroncrypto@users.noreply.github.com> Date: Tue Sep 5 17:30:53 2023 +0200 cli: Make conflicting account names a compile-time error (coral-xyz#2621) commit b9fa898 Author: acheron <98934430+acheroncrypto@users.noreply.github.com> Date: Fri Sep 1 22:42:06 2023 +0200 cli: Fix `anchor account` command panicking outside of workspace (coral-xyz#2620) commit dcf5928 Author: Will <82029448+wjthieme@users.noreply.github.com> Date: Wed Aug 30 19:28:51 2023 +0200 lang: `Box` the inner enums of `anchor_lang::error::Error` (coral-xyz#2600) Co-authored-by: acheron <acheroncrypto@gmail.com> commit 115679e Author: acheron <98934430+acheroncrypto@users.noreply.github.com> Date: Mon Aug 28 14:13:12 2023 +0200 bench: Add benchmarking for stack memory usage (coral-xyz#2617) commit a5e4c02 Author: acheron <98934430+acheroncrypto@users.noreply.github.com> Date: Sun Aug 27 10:21:17 2023 +0200 ts: Bump packages to `0.28.1-beta.2` (coral-xyz#2616) commit a7205af Author: Will <82029448+wjthieme@users.noreply.github.com> Date: Wed Aug 23 22:10:08 2023 +0200 lang: `associated_token` constraints don't work when setting `token_program` (coral-xyz#2603) Co-authored-by: acheron <acheroncrypto@gmail.com> commit 6f9f7d9 Author: acheron <98934430+acheroncrypto@users.noreply.github.com> Date: Sat Aug 19 13:09:09 2023 +0200 tests: Move IDL related tests in `misc` to `idl` (coral-xyz#2606) commit 6eacad4 Author: acheron <98934430+acheroncrypto@users.noreply.github.com> Date: Tue Aug 15 23:58:17 2023 +0200 cli: Add program template with multiple files (coral-xyz#2602) commit 454f1dd Author: acheron <98934430+acheroncrypto@users.noreply.github.com> Date: Sun Aug 13 16:50:28 2023 +0200 ts: Add support for unnamed(tuple) enum in accounts (coral-xyz#2601) commit b5cf67f Author: Jimii <30603522+jim4067@users.noreply.github.com> Date: Sat Aug 12 23:02:37 2023 +0300 spl: Add `TokenRecordAccount` for pNFTs (coral-xyz#2597) commit 58428f8 Author: Proph3t <metaproph3t@protonmail.com> Date: Fri Aug 11 19:48:28 2023 +0000 Add `setup_tests.sh` for setting up your local machine for tests (coral-xyz#2594) commit 4cf447a Author: acheron <98934430+acheroncrypto@users.noreply.github.com> Date: Tue Aug 8 22:03:31 2023 +0200 bench: Add benchmarking for program binary size (coral-xyz#2591) commit abfdc4e Author: acheron <98934430+acheroncrypto@users.noreply.github.com> Date: Sat Aug 5 23:47:06 2023 +0200 chore: Remove duplicate dependency and and alphabetize features (coral-xyz#2590) commit 2af9cc6 Author: acheron <98934430+acheroncrypto@users.noreply.github.com> Date: Wed Aug 2 23:01:05 2023 +0200 cli: Improve converting non-conflicting paths to names in IDL (coral-xyz#2588) commit be8764b Author: Proph3t <metaproph3t@protonmail.com> Date: Tue Aug 1 20:23:48 2023 +0000 Fix typo in account.rs docs (coral-xyz#2587) commit b7b8736 Author: acheron <98934430+acheroncrypto@users.noreply.github.com> Date: Mon Jul 31 23:41:12 2023 +0200 spl: Export `mpl-token-metadata` crate (coral-xyz#2583) commit cad868a Author: acheron <98934430+acheroncrypto@users.noreply.github.com> Date: Sat Jul 29 23:49:17 2023 +0200 Make the new IDL features explicit (coral-xyz#2582) commit 8f30f00 Author: acheron <98934430+acheroncrypto@users.noreply.github.com> Date: Thu Jul 27 23:29:26 2023 +0200 tests: Improve IDL comparison tests (coral-xyz#2581) commit df3e959 Author: Pierre <Arrowana@users.noreply.github.com> Date: Thu Jul 27 07:56:12 2023 +1000 chore: Use @noble/hashes/sha256 rather than obscure package (coral-xyz#2580) commit 5eb678a Author: acheron <98934430+acheroncrypto@users.noreply.github.com> Date: Tue Jul 25 23:52:26 2023 +0200 ts: Lazy load workspace programs and improve program name accessor (coral-xyz#2579) commit 4604fbe Author: acheron <98934430+acheroncrypto@users.noreply.github.com> Date: Sat Jul 22 16:39:05 2023 +0200 cli: Automatically decide IDL generation method (coral-xyz#2578) commit c548c85 Author: Jean Marchand (Exotic Markets) <jeanno11@orange.fr> Date: Sat Jul 22 12:43:56 2023 +0200 chore: Remove unused crates (coral-xyz#2577) commit 2bb3237 Author: Jean Marchand (Exotic Markets) <jeanno11@orange.fr> Date: Fri Jul 21 11:04:52 2023 +0200 chore: Fix clippy lints (coral-xyz#2576) commit 10eb698 Author: dromaz <92167972+dromaz@users.noreply.github.com> Date: Thu Jul 20 23:58:13 2023 +0200 avm: Add support for the `.anchorversion` file (coral-xyz#2553) Co-authored-by: acheron <acheroncrypto@gmail.com> commit 8309bb3 Author: acheron <98934430+acheroncrypto@users.noreply.github.com> Date: Wed Jul 19 18:28:38 2023 +0200 cli: Fix `anchor build --no-docs` (coral-xyz#2575) commit c306463 Author: acheron <98934430+acheroncrypto@users.noreply.github.com> Date: Mon Jul 17 22:47:55 2023 +0200 tests: Refactor IDL tests (coral-xyz#2573) commit cf057ac Author: acheron <98934430+acheroncrypto@users.noreply.github.com> Date: Sun Jul 16 17:08:25 2023 +0200 client: Fix compilation with Solana `1.14` (coral-xyz#2572) commit 4e5280b Author: acheron <98934430+acheroncrypto@users.noreply.github.com> Date: Fri Jul 14 23:17:23 2023 +0200 cli: Fix workspace inheritence (coral-xyz#2570) commit cfc6d29 Author: Lucas Steuernagel <38472950+LucasSte@users.noreply.github.com> Date: Fri Jul 14 16:29:16 2023 -0300 cli: Bump `solang-parser` version (coral-xyz#2569) commit 472279d Author: acheron <98934430+acheroncrypto@users.noreply.github.com> Date: Thu Jul 13 22:06:12 2023 +0200 cli: Add `--out` and `--out-ts` arguments for `idl build` command (coral-xyz#2566) commit b7e91d4 Author: acheron <98934430+acheroncrypto@users.noreply.github.com> Date: Tue Jul 11 19:05:14 2023 +0200 Remove IDL `path` field (coral-xyz#2564) commit 6ef6b79 Author: Krešimir Klas <kklas@users.noreply.github.com> Date: Sat Jul 8 19:59:30 2023 +0200 IDL generation through compilation (coral-xyz#2011) Co-authored-by: acheron <acheroncrypto@gmail.com> commit 0225b7c Author: Noah Prince <83885631+ChewingGlass@users.noreply.github.com> Date: Fri Jul 7 14:30:38 2023 -0700 lang: Allow polymorphic CPI calls matching an interface (coral-xyz#2559) commit 9ff7dfc Author: Jean Marchand (Exotic Markets) <jeanno11@orange.fr> Date: Wed Jul 5 10:05:37 2023 +0200 lang: Support for `const` in the `InitSpace` macro (coral-xyz#2555) commit 401d526 Author: chalda <chalda@marinade.finance> Date: Mon Jul 3 22:56:58 2023 +0200 client: Add `DynSigner` (coral-xyz#2550) commit e55cd3e Author: acheron <98934430+acheroncrypto@users.noreply.github.com> Date: Sat Jul 1 22:59:36 2023 +0200 lang: Add `Lamports` trait (coral-xyz#2552) commit 5624bfe Author: Jean Marchand (Exotic Markets) <jeanno11@orange.fr> Date: Thu Jun 29 13:35:38 2023 +0200 lang: Fix typo in the doc (coral-xyz#2551) commit 29b8a72 Author: acheron <98934430+acheroncrypto@users.noreply.github.com> Date: Tue Jun 27 20:03:51 2023 +0200 bench: Show change amount and add change note (coral-xyz#2549) commit 8bdc1b1 Author: Han Yang <dhy1996@live.com.sg> Date: Tue Jun 27 01:04:30 2023 +0800 spl: Only allow spl-token version above 1.1 (coral-xyz#2546)
supersedes and resolves #2541
When setting
associated_token
constraints using a specifiedtoken_program
other than the standard token program. A constraint fails because it relies on a hardcoded version oftoken_program
instead of the user-specified one. This makes it impossible to useassociated_token
constraints that use the Token2022 token program.This PR fixes the check by using
get_associated_token_address_with_program_id
instead ofget_associated_token_address
which it was using previously.This PR also adds a new test program that uses the
associated_token
constraints both with and without specifying atoken_program
. This test would throw anAccountNotAssociatedTokenAccount
before the changes introduced in this PR.tl;dr: This PR fixes a bug that makes using a custom
token_program
impossible with theassociated_token
constraints.