Skip to content

Commit 6464015

Browse files
committed
add hello solana steel example and add bankrun test
add hello solana steel example fix syntax issue in steel hello world example add backrun tests fix tests issue correct program and api name fixed typo in test.rs and updated steel version
1 parent 401366c commit 6464015

File tree

17 files changed

+363
-264
lines changed

17 files changed

+363
-264
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Steel
2+
3+
**Steel** is a ...
4+
5+
## API
6+
- [`Consts`](api/src/consts.rs) – Program constants.
7+
- [`Error`](api/src/error.rs) – Custom program errors.
8+
- [`Event`](api/src/event.rs) – Custom program events.
9+
- [`Instruction`](api/src/instruction.rs) – Declared instructions.
10+
11+
## Instructions
12+
- [`Hello`](program/src/hello.rs) – Hello ...
13+
14+
## State
15+
- [`User`](api/src/state/user.rs) – User ...
16+
17+
## Tests
18+
19+
To run the test suit, use the Solana toolchain:
20+
```
21+
cargo test-sbf
22+
```
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
[package]
2+
name = "hello-solana-api"
3+
version = "0.1.0"
4+
edition = "2021"
5+
6+
[dependencies]
7+
bytemuck.workspace = true
8+
num_enum.workspace = true
9+
solana-program.workspace = true
10+
steel.workspace = true
11+
thiserror.workspace = true
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
use steel::*;
2+
3+
#[derive(Debug, Error, Clone, Copy, PartialEq, Eq, IntoPrimitive)]
4+
#[repr(u32)]
5+
pub enum SteelError {
6+
#[error("This is a dummy error")]
7+
Dummy = 0,
8+
}
9+
10+
error!(SteelError);
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
use steel::*;
2+
3+
#[repr(u8)]
4+
#[derive(Clone, Copy, Debug, Eq, PartialEq, TryFromPrimitive)]
5+
pub enum SteelInstruction {
6+
HelloSolana = 0,
7+
}
8+
9+
#[repr(C)]
10+
#[derive(Clone, Copy, Debug, Pod, Zeroable)]
11+
pub struct HelloSolana {}
12+
13+
instruction!(SteelInstruction, HelloSolana);
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
pub mod error;
2+
pub mod instruction;
3+
pub mod sdk;
4+
5+
pub mod prelude {
6+
pub use crate::error::*;
7+
pub use crate::instruction::*;
8+
pub use crate::sdk::*;
9+
}
10+
11+
use steel::*;
12+
13+
// TODO Set program id
14+
declare_id!("z7msBPQHDJjTvdQRoEcKyENgXDhSRYeHieN1ZMTqo35");
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
use steel::*;
2+
3+
use crate::prelude::*;
4+
5+
pub fn hello(signer: Pubkey) -> Instruction {
6+
Instruction {
7+
program_id: crate::ID,
8+
accounts: vec![AccountMeta::new(signer, true)],
9+
data: HelloSolana {}.to_bytes(),
10+
}
11+
}
Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,22 @@
11
[workspace]
2-
members = [
3-
"program",
4-
]
52
resolver = "2"
3+
members = ["api", "program"]
64

7-
[profile.release]
8-
overflow-checks = true
5+
[workspace.package]
6+
version = "0.1.0"
7+
edition = "2021"
8+
license = "Apache-2.0"
9+
homepage = ""
10+
documentation = ""
11+
repository = ""
12+
readme = "./README.md"
13+
keywords = ["solana"]
14+
15+
[workspace.dependencies]
16+
hello-solana-api = { path = "./api", version = "0.1.0" }
17+
bytemuck = "1.14"
18+
num_enum = "0.7"
19+
solana-program = "1.18"
20+
steel = "2.0"
21+
thiserror = "1.0"
22+
solana-sdk = "1.18"

basics/hello-solana/steel/cicd.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/bin/bash
2+
3+
# This script is for quick building & deploying of the program.
4+
# It also serves as a reference for the commands used for building & deploying Solana programs.
5+
# Run this bad boy with "bash cicd.sh" or "./cicd.sh"
6+
7+
cargo build-sbf --manifest-path=./program/Cargo.toml --bpf-out-dir=./program/target/so
8+
solana program deploy ./program/target/so/program.so
Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,28 @@
11
{
2-
"name": "steel-hello-solana",
2+
"name": "hello-solana-program",
33
"version": "1.0.0",
4-
"description": "hello world with steel framework for solana",
4+
"description": "",
55
"scripts": {
6-
"test": "pnpm ts-mocha -p ./tsconfig.json -t 1000000 ./tests/test.ts",
6+
"test": "pnpm ts-mocha -p ./tsconfig.json -t 1000000 ./tests/*.test.ts",
77
"build-and-test": "cargo build-sbf --manifest-path=./program/Cargo.toml --sbf-out-dir=./tests/fixtures && pnpm test",
88
"build": "cargo build-sbf --manifest-path=./program/Cargo.toml --sbf-out-dir=./program/target/so",
9-
"deploy": "solana program deploy ./program/target/so/hello_solana_program.so"
9+
"deploy": "solana program deploy ./program/target/so/account_data_program.so"
1010
},
1111
"keywords": [],
12-
"author": "Ayush Chauhan",
12+
"author": "",
1313
"license": "ISC",
14+
"dependencies": {
15+
"@solana/web3.js": "^1.95.4"
16+
},
1417
"devDependencies": {
15-
"@types/bn.js": "^5.1.0",
16-
"@types/chai": "^4.3.1",
17-
"@types/mocha": "^9.1.1",
18+
"@types/chai": "^4.3.7",
19+
"@types/mocha": "10.0.9",
1820
"@types/node": "^22.7.4",
19-
"chai": "^4.3.4",
20-
"mocha": "^9.0.3",
21-
"solana-bankrun": "^0.3.0",
21+
"borsh": "^2.0.0",
22+
"chai": "^4.3.7",
23+
"mocha": "10.7.3",
24+
"solana-bankrun": "0.4.0",
2225
"ts-mocha": "^10.0.0",
23-
"typescript": "^4.3.5"
24-
},
25-
"dependencies": {
26-
"@solana/web3.js": "^1.95.3"
26+
"typescript": "5.6.3"
2727
}
2828
}

0 commit comments

Comments
 (0)