Skip to content

Commit

Permalink
create-account/steel - cargo fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
thewuhxyz committed Nov 2, 2024
1 parent 7c22d8d commit 0f90aa4
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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"] }
Original file line number Diff line number Diff line change
Expand Up @@ -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
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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::<PowerStatus>(program_id)?;
let power = power_info.as_account_mut::<PowerStatus>(&crate::ID)?;

power.on = on;

Expand All @@ -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::<PowerStatus>(program_id)?;
let power = power_info.as_account_mut::<PowerStatus>(&crate::ID)?;

// switch power status
power.switch()?;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ pub use instructions::*;

use steel::*;

declare_id!("z7msBPQHDJjTvdQRoEcKyENgXDhSRYeHieN1ZMTqo35");
declare_id!("E64FVeubGC4NPNF2UBJYX4AkrVowf74fRJD9q6YhwstN");

#[cfg(not(feature = "no-entrypoint"))]
entrypoint!(process_instruction);
Expand All @@ -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),
}
}

Expand Down
4 changes: 2 additions & 2 deletions basics/cross-program-invocation/steel/tests/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit 0f90aa4

Please sign in to comment.