-
Notifications
You must be signed in to change notification settings - Fork 306
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
- Loading branch information
1 parent
401366c
commit fb18f6d
Showing
17 changed files
with
363 additions
and
264 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# Steel | ||
|
||
**Steel** is a ... | ||
|
||
## API | ||
- [`Consts`](api/src/consts.rs) – Program constants. | ||
- [`Error`](api/src/error.rs) – Custom program errors. | ||
- [`Event`](api/src/event.rs) – Custom program events. | ||
- [`Instruction`](api/src/instruction.rs) – Declared instructions. | ||
|
||
## Instructions | ||
- [`Hello`](program/src/hello.rs) – Hello ... | ||
|
||
## State | ||
- [`User`](api/src/state/user.rs) – User ... | ||
|
||
## Tests | ||
|
||
To run the test suit, use the Solana toolchain: | ||
``` | ||
cargo test-sbf | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
[package] | ||
name = "steel-api" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
[dependencies] | ||
bytemuck.workspace = true | ||
num_enum.workspace = true | ||
solana-program.workspace = true | ||
steel.workspace = true | ||
thiserror.workspace = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
use steel::*; | ||
|
||
#[derive(Debug, Error, Clone, Copy, PartialEq, Eq, IntoPrimitive)] | ||
#[repr(u32)] | ||
pub enum SteelError { | ||
#[error("This is a dummy error")] | ||
Dummy = 0, | ||
} | ||
|
||
error!(SteelError); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
use steel::*; | ||
|
||
#[repr(u8)] | ||
#[derive(Clone, Copy, Debug, Eq, PartialEq, TryFromPrimitive)] | ||
pub enum SteelInstruction { | ||
HelloSolana = 0, | ||
} | ||
|
||
#[repr(C)] | ||
#[derive(Clone, Copy, Debug, Pod, Zeroable)] | ||
pub struct HelloSolana {} | ||
|
||
instruction!(SteelInstruction, HelloSolana); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
pub mod error; | ||
pub mod instruction; | ||
pub mod sdk; | ||
|
||
pub mod prelude { | ||
pub use crate::error::*; | ||
pub use crate::instruction::*; | ||
pub use crate::sdk::*; | ||
} | ||
|
||
use steel::*; | ||
|
||
// TODO Set program id | ||
declare_id!("z7msBPQHDJjTvdQRoEcKyENgXDhSRYeHieN1ZMTqo35"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
use steel::*; | ||
|
||
use crate::prelude::*; | ||
|
||
pub fn hello(signer: Pubkey) -> Instruction { | ||
Instruction { | ||
program_id: crate::ID, | ||
accounts: vec![AccountMeta::new(signer, true)], | ||
data: HelloSolana {}.to_bytes(), | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,22 @@ | ||
[workspace] | ||
members = [ | ||
"program", | ||
] | ||
resolver = "2" | ||
members = ["api", "program"] | ||
|
||
[profile.release] | ||
overflow-checks = true | ||
[workspace.package] | ||
version = "0.1.0" | ||
edition = "2021" | ||
license = "Apache-2.0" | ||
homepage = "" | ||
documentation = "" | ||
respository = "" | ||
readme = "./README.md" | ||
keywords = ["solana"] | ||
|
||
[workspace.dependencies] | ||
steel-api = { path = "./api", version = "0.1.0" } | ||
bytemuck = "1.14" | ||
num_enum = "0.7" | ||
solana-program = "1.18" | ||
steel = "1.3" | ||
thiserror = "1.0" | ||
solana-sdk = "1.18" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#!/bin/bash | ||
|
||
# This script is for quick building & deploying of the program. | ||
# It also serves as a reference for the commands used for building & deploying Solana programs. | ||
# Run this bad boy with "bash cicd.sh" or "./cicd.sh" | ||
|
||
cargo build-sbf --manifest-path=./program/Cargo.toml --bpf-out-dir=./program/target/so | ||
solana program deploy ./program/target/so/program.so |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,28 @@ | ||
{ | ||
"name": "steel-hello-solana", | ||
"name": "steel-program", | ||
"version": "1.0.0", | ||
"description": "hello world with steel framework for solana", | ||
"description": "", | ||
"scripts": { | ||
"test": "pnpm ts-mocha -p ./tsconfig.json -t 1000000 ./tests/test.ts", | ||
"test": "pnpm ts-mocha -p ./tsconfig.json -t 1000000 ./tests/*.test.ts", | ||
"build-and-test": "cargo build-sbf --manifest-path=./program/Cargo.toml --sbf-out-dir=./tests/fixtures && pnpm test", | ||
"build": "cargo build-sbf --manifest-path=./program/Cargo.toml --sbf-out-dir=./program/target/so", | ||
"deploy": "solana program deploy ./program/target/so/hello_solana_program.so" | ||
"deploy": "solana program deploy ./program/target/so/account_data_program.so" | ||
}, | ||
"keywords": [], | ||
"author": "Ayush Chauhan", | ||
"author": "", | ||
"license": "ISC", | ||
"dependencies": { | ||
"@solana/web3.js": "^1.95.4" | ||
}, | ||
"devDependencies": { | ||
"@types/bn.js": "^5.1.0", | ||
"@types/chai": "^4.3.1", | ||
"@types/mocha": "^9.1.1", | ||
"@types/chai": "^4.3.7", | ||
"@types/mocha": "10.0.9", | ||
"@types/node": "^22.7.4", | ||
"chai": "^4.3.4", | ||
"mocha": "^9.0.3", | ||
"solana-bankrun": "^0.3.0", | ||
"borsh": "^2.0.0", | ||
"chai": "^4.3.7", | ||
"mocha": "10.7.3", | ||
"solana-bankrun": "0.4.0", | ||
"ts-mocha": "^10.0.0", | ||
"typescript": "^4.3.5" | ||
}, | ||
"dependencies": { | ||
"@solana/web3.js": "^1.95.3" | ||
"typescript": "5.6.3" | ||
} | ||
} |
Oops, something went wrong.