Skip to content

Commit

Permalink
updated to steel 2.1
Browse files Browse the repository at this point in the history
  • Loading branch information
robertohuertasm committed Dec 1, 2024
1 parent 39d1a7f commit 79496c1
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 9 deletions.
2 changes: 1 addition & 1 deletion basics/program-derived-addresses/steel/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ program-derived-addresses-api = { path = "./api", version = "0.1.0" }
bytemuck = "1.14"
num_enum = "0.7"
solana-program = "1.18"
steel = "1.3"
steel = "2.1"
thiserror = "1.0"
10 changes: 3 additions & 7 deletions basics/program-derived-addresses/steel/program/src/create.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,28 +14,24 @@ pub fn process_create(accounts: &[AccountInfo<'_>], data: &[u8]) -> ProgramResul
return Err(ProgramError::NotEnoughAccountKeys);
};

// get expected pda
let pda = page_visits_pda(user_info.key);

// validations
signer_info.is_signer()?;
pages_visit_info.is_empty()?.is_writable()?.has_seeds(
&[SEED, &user_info.key.as_ref()],
pda.1,
&program_derived_addresses_api::ID,
)?;
system_program.is_program(&system_program::ID)?;

// create account
create_account::<PageVisits>(
pages_visit_info,
&program_derived_addresses_api::ID,
&[SEED, user_info.key.as_ref(), &[pda.1]],
system_program,
signer_info,
&program_derived_addresses_api::ID,
&[SEED, user_info.key.as_ref()],
)?;

let info = pages_visit_info.to_account_mut::<PageVisits>(&program_derived_addresses_api::ID)?;
let info = pages_visit_info.as_account_mut::<PageVisits>(&program_derived_addresses_api::ID)?;
info.page_visits = page_visits.page_visits;
info.bump = page_visits.bump;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ pub fn process_increment(accounts: &[AccountInfo<'_>], _data: &[u8]) -> ProgramR
return Err(ProgramError::NotEnoughAccountKeys);
};

let info = page_visit_info.to_account_mut::<PageVisits>(&program_derived_addresses_api::ID)?;
let info = page_visit_info.as_account_mut::<PageVisits>(&program_derived_addresses_api::ID)?;

// increment page visits
info.increment_visits();
Expand Down

0 comments on commit 79496c1

Please sign in to comment.