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
21 changes: 21 additions & 0 deletions basics/create-account/steel/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]
create-account-api = { path = "./api", version = "0.1.0" }
bytemuck = "1.14"
num_enum = "0.7"
solana-program = "1.18"
steel = "2.0"
thiserror = "1.0"
43 changes: 43 additions & 0 deletions basics/create-account/steel/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# CreateAccount

**CreateAccount** is an example Solana program that demonstrates how to create a new account.

## API

- [`Instruction`](api/src/instruction.rs) – Declared instructions.

## Instructions

- [`CreateSystemAccount`](program/src/create_system_account.rs) – Create a new system account.

## How to?

Compile your program:

```sh
pnpm build
```

Run tests:

```sh
pnpm test
```

or

```sh
steel test
```

Run build and test

```sh
pnpm build-and-test
```

Deploy your program:

```sh
pnpm deploy
```
18 changes: 18 additions & 0 deletions basics/create-account/steel/api/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[package]
name = "create-account-api"
description = "API for interacting with the CreateAccount 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/create-account/steel/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 CreateAccountInstruction {
CreateSystemAccount = 0,
}

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

instruction!(CreateAccountInstruction, CreateSystemAccount);
13 changes: 13 additions & 0 deletions basics/create-account/steel/api/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
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");
15 changes: 15 additions & 0 deletions basics/create-account/steel/api/src/sdk.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
use steel::*;

use crate::prelude::*;

pub fn create_system_account(payer: Pubkey, new_account: Pubkey) -> Instruction {
Instruction {
program_id: crate::ID,
accounts: vec![
AccountMeta::new(payer, true),
AccountMeta::new(new_account, true),
AccountMeta::new_readonly(system_program::ID, false),
],
data: CreateSystemAccount {}.to_bytes(),
}
}
29 changes: 29 additions & 0 deletions basics/create-account/steel/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"name": "steel",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"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/account_data_program.so"
},
"keywords": [],
"author": "Leo Pham <hongthaipro@gmail.com>",
"license": "ISC",
"dependencies": {
"@solana/web3.js": "^1.95.4"
},
"devDependencies": {
"@types/mocha": "^10.0.9",
"@types/node": "^22.7.9",
"borsh": "^2.0.0",
"mocha": "^10.7.3",
"solana-bankrun": "^0.4.0",
"ts-mocha": "^10.0.0",
"typescript": "^5.6.3",
"chai": "^4.3.7",
"@types/chai": "^4.3.7"
}
}
Loading