Skip to content

Commit 83e20c7

Browse files
committed
clean up and main pull
1 parent 09d1223 commit 83e20c7

File tree

9 files changed

+53
-44
lines changed

9 files changed

+53
-44
lines changed

basics/rent/steel/api/src/instruction.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@ pub struct CreateSystemAccount {
1313
pub address: [u8; 64],
1414
}
1515

16-
instruction!(RentInstruction, CreateSystemAccount);
16+
instruction!(RentInstruction, CreateSystemAccount);

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

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,21 @@
11
pub mod error;
22
pub mod instruction;
3-
pub mod state;
43
pub mod sdk;
4+
pub mod state;
55

66
pub mod prelude {
77
pub use crate::error::*;
88
pub use crate::instruction::*;
9-
pub use crate::state::*;
109
pub use crate::sdk::*;
10+
pub use crate::state::*;
1111
// Re-export common solana dependencies
1212
pub use solana_program::{
13-
account_info::AccountInfo,
14-
entrypoint::ProgramResult,
15-
msg,
16-
pubkey::Pubkey,
17-
rent::Rent,
13+
account_info::AccountInfo, entrypoint::ProgramResult, msg, pubkey::Pubkey, rent::Rent,
1814
system_program,
1915
};
2016
}
2117

2218
use steel::*;
2319

2420
// TODO Set program id
25-
declare_id!("z7msBPQHDJjTvdQRoEcKyENgXDhSRYeHieN1ZMTqo35");
21+
declare_id!("z7msBPQHDJjTvdQRoEcKyENgXDhSRYeHieN1ZMTqo35");

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
use steel::*;
21
use crate::prelude::*;
2+
use steel::*;
33

44
pub fn create_system_account(
55
payer: Pubkey,
@@ -9,7 +9,7 @@ pub fn create_system_account(
99
) -> Instruction {
1010
let mut name_bytes = [0u8; 32];
1111
let mut address_bytes = [0u8; 64];
12-
12+
1313
name_bytes[..name.len()].copy_from_slice(name.as_bytes());
1414
address_bytes[..address.len()].copy_from_slice(address.as_bytes());
1515

@@ -23,6 +23,7 @@ pub fn create_system_account(
2323
data: CreateSystemAccount {
2424
name: name_bytes,
2525
address: address_bytes,
26-
}.to_bytes(),
26+
}
27+
.to_bytes(),
2728
}
28-
}
29+
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
use steel::*;
21
use super::RentAccount;
2+
use steel::*;
33

44
#[repr(C)]
55
#[derive(Clone, Copy, Debug, PartialEq, Pod, Zeroable)]
@@ -8,4 +8,4 @@ pub struct Address {
88
pub address: [u8; 64],
99
}
1010

11-
account!(RentAccount, Address);
11+
account!(RentAccount, Address);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ use steel::*;
88
#[derive(Clone, Copy, Debug, Eq, PartialEq, IntoPrimitive, TryFromPrimitive)]
99
pub enum RentAccount {
1010
Address = 0,
11-
}
11+
}

basics/rent/steel/package.json

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
{
2-
"name": "rent-example",
3-
"version": "1.0.0",
4-
"description": "rent example with steel framework for solana",
5-
"scripts": {
6-
"test": "cargo test-sbf",
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/rent_example_program.so"
10-
},
11-
"keywords": [],
12-
"author": "Sabir Khan",
13-
"license": "ISC"
14-
}
2+
"name": "rent-example",
3+
"version": "1.0.0",
4+
"description": "rent example with steel framework for solana",
5+
"scripts": {
6+
"test": "cargo test-sbf",
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/rent_example_program.so"
10+
},
11+
"keywords": [],
12+
"author": "Sabir Khan",
13+
"license": "ISC"
14+
}

basics/rent/steel/program/src/create_account.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@ use steel::*;
44

55
pub fn process_create_account(accounts: &[AccountInfo<'_>], data: &[u8]) -> ProgramResult {
66
let args = CreateSystemAccount::try_from_bytes(data)?;
7-
7+
88
let [payer_info, new_account_info, system_program] = accounts else {
99
return Err(ProgramError::NotEnoughAccountKeys);
1010
};
1111

1212
payer_info.is_signer()?;
1313
new_account_info.is_signer()?;
14-
14+
1515
let account_size = std::mem::size_of::<Address>();
1616
let rent = Rent::get()?;
1717
let lamports_required = rent.minimum_balance(account_size);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@ pub fn process_instruction(
1818
Ok(())
1919
}
2020

21-
entrypoint!(process_instruction);
21+
entrypoint!(process_instruction);

basics/rent/steel/program/tests/test.rs

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ async fn test_create_system_account() {
2121

2222
// Generate a new keypair for the account we'll create
2323
let new_account = Keypair::new();
24-
24+
2525
// Test data
2626
let name = "John Doe";
2727
let address = "123 Blockchain Street";
@@ -44,7 +44,11 @@ async fn test_create_system_account() {
4444

4545
// Process transaction
4646
let result = banks_client.process_transaction(transaction).await;
47-
assert!(result.is_ok(), "Failed to process transaction: {:?}", result);
47+
assert!(
48+
result.is_ok(),
49+
"Failed to process transaction: {:?}",
50+
result
51+
);
4852

4953
// Fetch and verify the created account
5054
let account = banks_client
@@ -54,30 +58,38 @@ async fn test_create_system_account() {
5458
.expect("Account not found");
5559

5660
// Verify account owner
57-
assert_eq!(account.owner, rent_example_api::ID, "Incorrect account owner");
61+
assert_eq!(
62+
account.owner,
63+
rent_example_api::ID,
64+
"Incorrect account owner"
65+
);
5866

5967
// Deserialize and verify account data
60-
let address_account = Address::try_from_bytes(&account.data)
61-
.expect("Failed to deserialize account data");
68+
let address_account =
69+
Address::try_from_bytes(&account.data).expect("Failed to deserialize account data");
6270

6371
// Convert stored bytes back to strings for comparison
6472
let stored_name = String::from_utf8(
65-
address_account.name
73+
address_account
74+
.name
6675
.iter()
6776
.take_while(|&&b| b != 0)
6877
.cloned()
69-
.collect::<Vec<u8>>()
70-
).unwrap();
78+
.collect::<Vec<u8>>(),
79+
)
80+
.unwrap();
7181

7282
let stored_address = String::from_utf8(
73-
address_account.address
83+
address_account
84+
.address
7485
.iter()
7586
.take_while(|&&b| b != 0)
7687
.cloned()
77-
.collect::<Vec<u8>>()
78-
).unwrap();
88+
.collect::<Vec<u8>>(),
89+
)
90+
.unwrap();
7991

8092
// Verify the stored data matches what we sent
8193
assert_eq!(stored_name, name, "Stored name doesn't match");
8294
assert_eq!(stored_address, address, "Stored address doesn't match");
83-
}
95+
}

0 commit comments

Comments
 (0)