diff --git a/basics/cross-program-invocation/steel/programs/hand/Cargo.toml b/basics/cross-program-invocation/steel/programs/hand/Cargo.toml index 56747a924..573b10d17 100644 --- a/basics/cross-program-invocation/steel/programs/hand/Cargo.toml +++ b/basics/cross-program-invocation/steel/programs/hand/Cargo.toml @@ -11,8 +11,8 @@ no-entrypoint = [] cpi = ["no-entrypoint"] [dependencies] -solana-program = "=1.18.17" -steel = "2.0" +solana-program = "1.18.17" +steel = "2.1" bytemuck = "1.14" num_enum = "0.7" cross-program-invocation-steel-lever = { path = "../lever", features = ["cpi"] } diff --git a/basics/cross-program-invocation/steel/programs/hand/src/lib.rs b/basics/cross-program-invocation/steel/programs/hand/src/lib.rs index eae73b0a9..cbc2b4336 100644 --- a/basics/cross-program-invocation/steel/programs/hand/src/lib.rs +++ b/basics/cross-program-invocation/steel/programs/hand/src/lib.rs @@ -18,8 +18,8 @@ pub fn process_instruction( let set_power_status_data = SetPowerStatus::try_from_bytes(data)?; let ix = Instruction::new_with_bytes( - *lever_program.key, // program id of the callee - &set_power_status_data.to_bytes(), // the instuction data, + *lever_program.key, // program id of the callee + &set_power_status_data.to_bytes(), // the instuction data, vec![AccountMeta::new(*power.key, false)], // accounts needed to execute the instruction ); diff --git a/basics/cross-program-invocation/steel/programs/lever/Cargo.toml b/basics/cross-program-invocation/steel/programs/lever/Cargo.toml index 9407a3fbc..f47abc54c 100644 --- a/basics/cross-program-invocation/steel/programs/lever/Cargo.toml +++ b/basics/cross-program-invocation/steel/programs/lever/Cargo.toml @@ -11,7 +11,7 @@ no-entrypoint = [] cpi = ["no-entrypoint"] [dependencies] -solana-program = "=1.18.17" -steel = "2.0" +solana-program = "1.18.17" +steel = "2.1" bytemuck = "1.14" num_enum = "0.7" diff --git a/basics/cross-program-invocation/steel/programs/lever/src/instructions.rs b/basics/cross-program-invocation/steel/programs/lever/src/instructions.rs index fc63600ca..210dcad18 100644 --- a/basics/cross-program-invocation/steel/programs/lever/src/instructions.rs +++ b/basics/cross-program-invocation/steel/programs/lever/src/instructions.rs @@ -20,7 +20,7 @@ pub struct InitializeLever { } impl InitializeLever { - pub fn process(program_id: &Pubkey, accounts: &[AccountInfo], data: &[u8]) -> ProgramResult { + pub fn process(accounts: &[AccountInfo], data: &[u8]) -> ProgramResult { let on = Self::try_from_bytes(data)?.on; let [power_info, user, system_program] = accounts else { @@ -37,12 +37,12 @@ impl InitializeLever { power_info.key, lamports_required, account_span as u64, - program_id, + &crate::ID, ), &[user.clone(), power_info.clone(), system_program.clone()], )?; - let power = power_info.as_account_mut::(program_id)?; + let power = power_info.as_account_mut::(&crate::ID)?; power.on = on; @@ -63,14 +63,14 @@ pub struct SetPowerStatus { } impl SetPowerStatus { - pub fn process(program_id: &Pubkey, accounts: &[AccountInfo], data: &[u8]) -> ProgramResult { + pub fn process(accounts: &[AccountInfo], data: &[u8]) -> ProgramResult { let name = SetPowerStatus::try_from_bytes(data)?.name; let [power_info] = accounts else { return Err(ProgramError::NotEnoughAccountKeys); }; - let power = power_info.as_account_mut::(program_id)?; + let power = power_info.as_account_mut::(&crate::ID)?; // switch power status power.switch()?; diff --git a/basics/cross-program-invocation/steel/programs/lever/src/lib.rs b/basics/cross-program-invocation/steel/programs/lever/src/lib.rs index 8bc12b50e..c8c0d2522 100644 --- a/basics/cross-program-invocation/steel/programs/lever/src/lib.rs +++ b/basics/cross-program-invocation/steel/programs/lever/src/lib.rs @@ -3,7 +3,7 @@ pub use instructions::*; use steel::*; -declare_id!("z7msBPQHDJjTvdQRoEcKyENgXDhSRYeHieN1ZMTqo35"); +declare_id!("E64FVeubGC4NPNF2UBJYX4AkrVowf74fRJD9q6YhwstN"); #[cfg(not(feature = "no-entrypoint"))] entrypoint!(process_instruction); @@ -13,11 +13,11 @@ pub fn process_instruction( accounts: &[AccountInfo], data: &[u8], ) -> ProgramResult { - let (ix, data) = parse_instruction(program_id, program_id, data)?; + let (ix, data) = parse_instruction(&crate::ID, program_id, data)?; match ix { - SteelInstruction::InitializeLever => InitializeLever::process(program_id, accounts, data), - SteelInstruction::SetPowerStatus => SetPowerStatus::process(program_id, accounts, data), + SteelInstruction::InitializeLever => InitializeLever::process(accounts, data), + SteelInstruction::SetPowerStatus => SetPowerStatus::process(accounts, data), } } diff --git a/basics/cross-program-invocation/steel/tests/test.ts b/basics/cross-program-invocation/steel/tests/test.ts index 5f857957c..777a86d28 100644 --- a/basics/cross-program-invocation/steel/tests/test.ts +++ b/basics/cross-program-invocation/steel/tests/test.ts @@ -5,8 +5,8 @@ import * as borsh from 'borsh'; import { start } from 'solana-bankrun'; describe('CPI Example', async () => { - const LEVER_PROGRAM_ID = PublicKey.unique(); - const HAND_PROGRAM_ID = PublicKey.unique(); + const LEVER_PROGRAM_ID = new PublicKey('E64FVeubGC4NPNF2UBJYX4AkrVowf74fRJD9q6YhwstN'); + const HAND_PROGRAM_ID = new PublicKey('z7msBPQHDJjTvdQRoEcKyENgXDhSRYeHieN1ZMTqo35'); const powerAccount = Keypair.generate(); const context = await start(