Skip to content

Commit 2fc678c

Browse files
committed
chore: lint + fmt
1 parent 6fd9d4c commit 2fc678c

File tree

9 files changed

+55
-59
lines changed

9 files changed

+55
-59
lines changed

basics/counter/steel/api/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ pub mod prelude {
99
pub use crate::error::*;
1010
pub use crate::instruction::*;
1111
pub use crate::sdk::*;
12-
pub use crate::state::*;
12+
pub use crate::state::*;
1313
}
1414

1515
use steel::*;
1616

1717
// TODO Set program id
18-
declare_id!("11111111111111111111111111111112");
18+
declare_id!("11111111111111111111111111111112");

basics/counter/steel/api/src/sdk.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,6 @@ pub fn increment(signer: Pubkey) -> Instruction {
2121
AccountMeta::new(signer, true),
2222
AccountMeta::new(counter_pda().0, false),
2323
],
24-
data : Increment {}.to_bytes(),
24+
data: Increment {}.to_bytes(),
2525
}
2626
}

basics/counter/steel/api/src/state/counter.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use super::SteelAccount;
55
#[repr(C)]
66
#[derive(Clone, Copy, Debug, PartialEq, Pod, Zeroable)]
77
pub struct Counter {
8-
pub value: u64
8+
pub value: u64,
99
}
1010

1111
account!(SteelAccount, Counter);

basics/counter/steel/api/src/state/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ use crate::consts::*;
99
#[repr(u8)]
1010
#[derive(Clone, Copy, Debug, Eq, PartialEq, IntoPrimitive, TryFromPrimitive)]
1111
pub enum SteelAccount {
12-
Counter = 0
12+
Counter = 0,
1313
}
1414

1515
/// Fetch PDA of the counter account.
1616
pub fn counter_pda() -> (Pubkey, u8) {
17-
Pubkey::find_program_address(&[COUNTER], &crate::id())
17+
Pubkey::find_program_address(&[COUNTER], &crate::id())
1818
}

basics/counter/steel/package.json

Lines changed: 23 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,25 @@
11
{
2-
"name": "steel-counter-solana",
3-
"version": "1.0.0",
4-
"description": "Counter with steel framework for solana",
5-
"scripts": {
6-
"test": "pnpm ts-mocha -p ./tsconfig.json -t 1000000 ./tests/test.ts",
7-
"build-and-test": "cargo build-sbf --manifest-path=./program/Cargo.toml --sbf-out-dir=./tests/fixtures && pnpm test",
8-
"build": "cargo build-sbf --manifest-path=./program/Cargo.toml --sbf-out-dir=./program/target/so",
9-
"deploy": "solana program deploy ./program/target/so/counter_program.so"
10-
},
11-
"devDependencies": {
12-
"@types/bn.js": "^5.1.0",
13-
"@types/chai": "^4.3.1",
14-
"@types/mocha": "^9.1.1",
15-
"@types/node": "^22.7.4",
16-
"chai": "^4.3.4",
17-
"mocha": "^9.0.3",
18-
"solana-bankrun": "^0.3.0",
19-
"ts-mocha": "^10.0.0",
20-
"typescript": "^4.3.5"
21-
},
22-
"dependencies": {
23-
"@solana/web3.js": "^1.95.3"
24-
}
2+
"name": "steel-counter-solana",
3+
"version": "1.0.0",
4+
"description": "Counter with steel framework for solana",
5+
"scripts": {
6+
"test": "pnpm ts-mocha -p ./tsconfig.json -t 1000000 ./tests/test.ts",
7+
"build-and-test": "cargo build-sbf --manifest-path=./program/Cargo.toml --sbf-out-dir=./tests/fixtures && pnpm test",
8+
"build": "cargo build-sbf --manifest-path=./program/Cargo.toml --sbf-out-dir=./program/target/so",
9+
"deploy": "solana program deploy ./program/target/so/counter_program.so"
10+
},
11+
"devDependencies": {
12+
"@types/bn.js": "^5.1.0",
13+
"@types/chai": "^4.3.1",
14+
"@types/mocha": "^9.1.1",
15+
"@types/node": "^22.7.4",
16+
"chai": "^4.3.4",
17+
"mocha": "^9.0.3",
18+
"solana-bankrun": "^0.3.0",
19+
"ts-mocha": "^10.0.0",
20+
"typescript": "^4.3.5"
21+
},
22+
"dependencies": {
23+
"@solana/web3.js": "^1.95.3"
2524
}
26-
25+
}

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

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,19 @@
1-
use steel_api::prelude::*;
2-
use steel::*;
31
use solana_program::msg;
2+
use steel::*;
3+
use steel_api::prelude::*;
44

55
pub fn process_increment(accounts: &[AccountInfo<'_>]) -> ProgramResult {
6-
76
// Load accounts.
87
let [signer_info, counter_info] = accounts else {
9-
return Err(ProgramError::NotEnoughAccountKeys);
8+
return Err(ProgramError::NotEnoughAccountKeys);
109
};
1110
signer_info.is_signer()?;
12-
let counter = counter_info
13-
.to_account_mut::<Counter>(&steel_api::ID)?
14-
.check_mut(|c| c.value < 100)?;
11+
let counter = counter_info
12+
.to_account_mut::<Counter>(&steel_api::ID)?
13+
.check_mut(|c| c.value < 100)?;
1514

16-
// Update state
17-
counter.value += 1;
15+
// Update state
16+
counter.value += 1;
1817

1918
msg!("Increment");
2019
msg!("Counter Value {}", counter.value);

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

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,20 @@
1-
use steel_api::prelude::*;
2-
use steel::*;
31
use solana_program::msg;
2+
use steel::*;
3+
use steel_api::prelude::*;
44

55
pub fn process_initialize(accounts: &[AccountInfo<'_>]) -> ProgramResult {
66
// Get expected pda bump.
77
let counter_bump = counter_pda().1;
88

99
// Load accounts.
1010
let [signer_info, counter_info, system_program] = accounts else {
11-
return Err(ProgramError::NotEnoughAccountKeys);
11+
return Err(ProgramError::NotEnoughAccountKeys);
1212
};
1313
signer_info.is_signer()?;
14-
counter_info.is_empty()?.is_writable()?.has_seeds(
15-
&[COUNTER],
16-
counter_bump,
17-
&steel_api::ID
18-
)?;
14+
counter_info
15+
.is_empty()?
16+
.is_writable()?
17+
.has_seeds(&[COUNTER], counter_bump, &steel_api::ID)?;
1918
system_program.is_program(&system_program::ID)?;
2019

2120
// Initialize counter.

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ mod initialize;
33

44
use increment::*;
55
use initialize::*;
6-
7-
use steel_api::prelude::*;
6+
87
use steel::*;
8+
use steel_api::prelude::*;
99

1010
use solana_program::msg;
1111

@@ -14,7 +14,7 @@ pub fn process_instruction(
1414
accounts: &[AccountInfo],
1515
data: &[u8],
1616
) -> ProgramResult {
17-
let (ix, data) = parse_instruction(&steel_api::ID, program_id , data)?;
17+
let (ix, data) = parse_instruction(&steel_api::ID, program_id, data)?;
1818

1919
match ix {
2020
SteelInstruction::Initialize => process_initialize(accounts)?,

basics/counter/steel/tsconfig.json

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
{
2-
"compilerOptions": {
3-
"types": ["mocha", "chai", "node"],
4-
"typeRoots": ["./node_modules/@types"],
5-
"lib": ["es2015"],
6-
"module": "commonjs",
7-
"target": "es6",
8-
"esModuleInterop": true
9-
}
2+
"compilerOptions": {
3+
"types": ["mocha", "chai", "node"],
4+
"typeRoots": ["./node_modules/@types"],
5+
"lib": ["es2015"],
6+
"module": "commonjs",
7+
"target": "es6",
8+
"esModuleInterop": true
109
}
11-
10+
}

0 commit comments

Comments
 (0)