Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions basics/hello-solana/steel/cargo.toml

This file was deleted.

2 changes: 2 additions & 0 deletions basics/hello-solana/steel/hello_solana/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
target
test-ledger
21 changes: 21 additions & 0 deletions basics/hello-solana/steel/hello_solana/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
[workspace]
resolver = "2"
members = ["api", "program"]

[workspace.package]
version = "0.1.0"
edition = "2021"
license = "Apache-2.0"
homepage = ""
documentation = ""
repository = ""
readme = "./README.md"
keywords = ["solana"]

[workspace.dependencies]
hello_solana-api = { path = "./api", version = "0.1.0" }
bytemuck = "1.14"
num_enum = "0.7"
solana-program = "1.18"
steel = "2.0"
thiserror = "1.0"
28 changes: 28 additions & 0 deletions basics/hello-solana/steel/hello_solana/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# HelloSolana

**HelloSolana** 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
- [`Add`](program/src/add.rs) – Add ...
- [`Initialize`](program/src/initialize.rs) – Initialize ...

## State
- [`Counter`](api/src/state/counter.rs) – Counter ...

## Get started

Compile your program:
```sh
steel build
```

Run unit and integration tests:
```sh
steel test
```
18 changes: 18 additions & 0 deletions basics/hello-solana/steel/hello_solana/api/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[package]
name = "hello_solana-api"
description = "API for interacting with the HelloSolana program"
version.workspace = true
edition.workspace = true
license.workspace = true
homepage.workspace = true
documentation.workspace = true
repository.workspace = true
readme.workspace = true
keywords.workspace = true

[dependencies]
bytemuck.workspace = true
num_enum.workspace = true
solana-program.workspace = true
steel.workspace = true
thiserror.workspace = true
13 changes: 13 additions & 0 deletions basics/hello-solana/steel/hello_solana/api/src/instruction.rs
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 HelloSolanaInstruction {
Hello = 0
}

#[repr(C)]
#[derive(Clone, Copy, Debug, Pod, Zeroable)]
pub struct Hello {}

instruction!(HelloSolanaInstruction, Hello);
12 changes: 12 additions & 0 deletions basics/hello-solana/steel/hello_solana/api/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
pub mod instruction;
pub mod sdk;

pub mod prelude {
pub use crate::instruction::*;
pub use crate::sdk::*;
}

use steel::*;

// TODO Set program id
declare_id!("z7msBPQHDJjTvdQRoEcKyENgXDhSRYeHieN1ZMTqo35");
11 changes: 11 additions & 0 deletions basics/hello-solana/steel/hello_solana/api/src/sdk.rs
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: Hello {}.to_bytes(),
}
}
26 changes: 26 additions & 0 deletions basics/hello-solana/steel/hello_solana/program/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
[package]
name = "hello_solana-program"
description = ""
version.workspace = true
edition.workspace = true
license.workspace = true
homepage.workspace = true
documentation.workspace = true
repository.workspace = true
readme.workspace = true
keywords.workspace = true

[lib]
crate-type = ["cdylib", "lib"]

[dependencies]
hello_solana-api.workspace = true
solana-program.workspace = true
steel.workspace = true

[dev-dependencies]
bs64 = "0.1.2"
rand = "0.8.5"
solana-program-test = "1.18"
solana-sdk = "1.18"
tokio = { version = "1.35", features = ["full"] }
17 changes: 17 additions & 0 deletions basics/hello-solana/steel/hello_solana/program/src/hello.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
use hello_solana_api::prelude::*;
use steel::*;
use solana_program::{msg};

pub fn process_hello(accounts: &[AccountInfo<'_>]) -> ProgramResult {
let [signer_info] = accounts else {
return Err(ProgramError::NotEnoughAccountKeys);
};

signer_info.is_signer()?;

msg!("Hello, Solana!");

msg!("Our program's Program ID: {}", &hello_solana_api::ID);

Ok(())
}
22 changes: 22 additions & 0 deletions basics/hello-solana/steel/hello_solana/program/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
mod hello;

use hello::*;

use hello_solana_api::prelude::*;
use steel::*;

pub fn process_instruction(
program_id: &Pubkey,
accounts: &[AccountInfo],
data: &[u8],
) -> ProgramResult {
let (ix, _data) = parse_instruction(&hello_solana_api::ID, program_id, data)?;

match ix {
HelloSolanaInstruction::Hello => process_hello(accounts)?,
}

Ok(())
}

entrypoint!(process_instruction);
27 changes: 27 additions & 0 deletions basics/hello-solana/steel/hello_solana/program/tests/test.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
use hello_solana_api::prelude::*;
use solana_program::hash::Hash;
use solana_program_test::{processor, BanksClient, ProgramTest};
use solana_sdk::{signature::Keypair, signer::Signer, transaction::Transaction};
use steel::*;

async fn setup() -> (BanksClient, Keypair, Hash) {
let mut program_test = ProgramTest::new(
"hello_solana_program",
hello_solana_api::ID,
processor!(hello_solana_program::process_instruction),
);
program_test.prefer_bpf(true);
program_test.start().await
}

#[tokio::test]
async fn run_test() {
// Setup test
let (mut banks, payer, blockhash) = setup().await;

let ix = hello(payer.pubkey());
let tx = Transaction::new_signed_with_payer(&[ix], Some(&payer.pubkey()), &[&payer], blockhash);
let res = banks.process_transaction(tx).await;
assert!(res.is_ok());
}

28 changes: 0 additions & 28 deletions basics/hello-solana/steel/package.json

This file was deleted.

Loading