-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
fix: Allow polymorphic CPI calls matching an interface #2559
fix: Allow polymorphic CPI calls matching an interface #2559
Conversation
@ChewingGlass is attempting to deploy a commit to the coral-xyz Team on Vercel. A member of the Team first needs to authorize it. |
Can't add reviewers. cc @Henry-E ? |
It's @acheroncrypto now |
Seems like - if I'm interpreting this correctly - you want to be able to write an Anchor crate that serves as an interface, and then deployed programs can implement it, and then you can CPI to those deployed programs with just the interface crate (which you're calling "base program") ? |
We can support this feature(looks more like a feature than a fix), could you add an entry to the CHANGELOG for this? |
@buffalojoec yeah, that's exactly it. Poor man's interfaces! |
Added a changelog entry |
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)
With the current implementation, CPIs can only call to the hardcoded crate program ID. With this change, you can create a base anchor program like this:
https://github.com/helium/modular-governance/blob/main/programs/vote_hook_interface/src/lib.rs
And then have a caller hit that interface with a context-dependent program ID