Skip to content

Commit a76dfc1

Browse files
update to steel 2.1
1 parent f6b9d79 commit a76dfc1

File tree

3 files changed

+13
-15
lines changed

3 files changed

+13
-15
lines changed

basics/counter/steel/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,5 @@ counter-api = { path = "./api", version = "0.1.0" }
1717
bytemuck = "1.14"
1818
num_enum = "0.7"
1919
solana-program = "1.18"
20-
steel = "1.3"
20+
steel = "2.1.0"
2121
thiserror = "1.0"

basics/counter/steel/program/src/increment.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ pub fn process_increment(accounts: &[AccountInfo<'_>], data: &[u8]) -> ProgramRe
1717
};
1818
signer_info.is_signer()?;
1919
let counter = counter_info
20-
.to_account_mut::<Counter>(&counter_api::ID)?
21-
.check_mut(|c| c.value < 100)?;
20+
.as_account_mut::<Counter>(&counter_api::ID)?
21+
.assert_mut(|c| c.value < 100)?;
2222

2323
// Update state
2424
counter.value += amount;

basics/counter/steel/program/src/initialize.rs

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,30 +2,28 @@ use counter_api::prelude::*;
22
use steel::*;
33

44
pub fn process_initialize(accounts: &[AccountInfo<'_>], _data: &[u8]) -> ProgramResult {
5-
// Get expected pda bump.
6-
let counter_bump = counter_pda().1;
7-
85
// Load accounts.
96
let [signer_info, counter_info, system_program] = accounts else {
10-
return Err(ProgramError::NotEnoughAccountKeys);
7+
return Err(ProgramError::NotEnoughAccountKeys);
118
};
9+
1210
signer_info.is_signer()?;
13-
counter_info.is_empty()?.is_writable()?.has_seeds(
14-
&[COUNTER_SEED],
15-
counter_bump,
16-
&counter_api::ID
17-
)?;
11+
counter_info
12+
.is_empty()?
13+
.is_writable()?
14+
.has_seeds(&[COUNTER_SEED], &counter_api::ID)?;
1815
system_program.is_program(&system_program::ID)?;
1916

2017
// Initialize counter.
2118
create_account::<Counter>(
2219
counter_info,
23-
&counter_api::ID,
24-
&[COUNTER_SEED, &[counter_bump]],
2520
system_program,
2621
signer_info,
22+
&counter_api::ID,
23+
&[COUNTER_SEED],
2724
)?;
28-
let counter = counter_info.to_account_mut::<Counter>(&counter_api::ID)?;
25+
26+
let counter = counter_info.as_account_mut::<Counter>(&counter_api::ID)?;
2927
counter.value = 0;
3028

3129
Ok(())

0 commit comments

Comments
 (0)