浏览代码

lang: Allow polymorphic CPI calls matching an interface (#2559)

Noah Prince 2 年之前
父节点
当前提交
0225b7c0fd
共有 2 个文件被更改,包括 2 次插入1 次删除
  1. 1 0
      CHANGELOG.md
  2. 1 1
      lang/syn/src/codegen/program/cpi.rs

+ 1 - 0
CHANGELOG.md

@@ -14,6 +14,7 @@ The minor version will be incremented upon a breaking change and the patch versi
 
 
 - lang: Add `get_lamports`, `add_lamports` and `sub_lamports` methods for all account types ([#2552](https://github.com/coral-xyz/anchor/pull/2552)).
 - lang: Add `get_lamports`, `add_lamports` and `sub_lamports` methods for all account types ([#2552](https://github.com/coral-xyz/anchor/pull/2552)).
 - client: Add a helper struct `DynSigner` to simplify use of `Client<C> where <C: Clone + Deref<Target = impl Signer>>` with Solana clap CLI utils that loads `Signer` as `Box<dyn Signer>` ([#2550](https://github.com/coral-xyz/anchor/pull/2550)).
 - client: Add a helper struct `DynSigner` to simplify use of `Client<C> where <C: Clone + Deref<Target = impl Signer>>` with Solana clap CLI utils that loads `Signer` as `Box<dyn Signer>` ([#2550](https://github.com/coral-xyz/anchor/pull/2550)).
+- lang: Allow CPI calls matching an interface without pinning program ID ([#2559](https://github.com/coral-xyz/anchor/pull/2559)).
 
 
 ### Fixes
 ### Fixes
 
 

+ 1 - 1
lang/syn/src/codegen/program/cpi.rs

@@ -40,7 +40,7 @@ pub fn generate(program: &Program) -> proc_macro2::TokenStream {
                             data.append(&mut ix_data);
                             data.append(&mut ix_data);
                             let accounts = ctx.to_account_metas(None);
                             let accounts = ctx.to_account_metas(None);
                             anchor_lang::solana_program::instruction::Instruction {
                             anchor_lang::solana_program::instruction::Instruction {
-                                program_id: crate::ID,
+                                program_id: ctx.program.key(),
                                 accounts,
                                 accounts,
                                 data,
                                 data,
                             }
                             }