Skip to content

Commit cb4b969

Browse files
authored
add tokens/create-token/steel (#299)
1 parent 136b6f2 commit cb4b969

File tree

13 files changed

+256
-0
lines changed

13 files changed

+256
-0
lines changed

tokens/create-token/steel/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
target
2+
test-ledger

tokens/create-token/steel/Cargo.toml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
[workspace]
2+
resolver = "2"
3+
members = ["api", "program"]
4+
5+
[workspace.package]
6+
version = "0.1.0"
7+
edition = "2021"
8+
license = "Apache-2.0"
9+
homepage = ""
10+
documentation = ""
11+
respository = ""
12+
readme = "./README.md"
13+
keywords = ["solana"]
14+
15+
[workspace.dependencies]
16+
steel-api = { path = "./api", version = "0.1.0" }
17+
bytemuck = "1.14"
18+
num_enum = "0.7"
19+
solana-program = "1.18"
20+
steel = "1.3"
21+
thiserror = "1.0"

tokens/create-token/steel/README.md

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: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
[package]
2+
name = "steel-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+
spl-token = "6.0.0"
11+
steel.workspace = true
12+
steel-program = { version = "0.1.0", path = "../program" }
13+
thiserror.workspace = true
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/// Seed of the counter account PDA.
2+
pub const MINT: &[u8] = b"mint";
3+
4+
pub const MINT_NOISE: [u8; 16] = [
5+
89, 157, 88, 232, 243, 249, 197, 132, 199, 49, 19, 234, 91, 94, 150, 41,
6+
];
7+
8+
pub const METADATA: &[u8] = b"metadata";
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: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
use steel::*;
2+
3+
#[repr(u8)]
4+
#[derive(Clone, Copy, Debug, Eq, PartialEq, TryFromPrimitive)]
5+
pub enum SteelInstruction {
6+
Create_Token = 0,
7+
}
8+
9+
#[repr(C)]
10+
#[derive(Clone, Copy, Debug, Pod, Zeroable)]
11+
pub struct Create_Token {
12+
pub token_name: [u8; 32],
13+
pub token_symbol: [u8; 8],
14+
pub token_uri: [u8; 64],
15+
}
16+
17+
instruction!(SteelInstruction, Create_Token);
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
pub mod consts;
2+
pub mod error;
3+
pub mod instruction;
4+
pub mod sdk;
5+
6+
pub mod prelude {
7+
pub use crate::consts::*;
8+
pub use crate::error::*;
9+
pub use crate::instruction::*;
10+
pub use crate::sdk::*;
11+
}
12+
13+
use steel::*;
14+
15+
// TODO Set program id
16+
declare_id!("z7msBPQHDJjTvdQRoEcKyENgXDhSRYeHieN1ZMTqo35");
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
use steel::*;
2+
3+
use crate::prelude::*;
4+
5+
pub fn create_token(
6+
payer: PubKey,
7+
mint_authority: PubKey,
8+
token_name: String,
9+
token_symbol: String,
10+
token_uri: String,
11+
) -> Instruction {
12+
let token_name: [u8; 32] = token_name
13+
.as_bytes()
14+
.try_into()
15+
.expect("token_name must be 32 bytes");
16+
let token_symbol: [u8; 8] = token_symbol
17+
.as_bytes()
18+
.try_into()
19+
.expect("token_symbol must be 32 bytes");
20+
let token_uri: [u8; 64] = token_uri
21+
.as_bytes()
22+
.try_into()
23+
.expect("token_uri must be 32 bytes");
24+
25+
let mint_pda = PubKey::find_program_address(&[b"mint"], &crate::ID);
26+
let metadata_pda = PubKey::find_program_address();
27+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
[package]
2+
name = "steel-program"
3+
version = "0.1.0"
4+
edition = "2021"
5+
6+
[lib]
7+
crate-type = ["cdylib", "lib"]
8+
9+
[dependencies]
10+
steel-api.workspace = true
11+
solana-program.workspace = true
12+
steel.workspace = true
13+
14+
[dev-dependencies]
15+
bs64 = "0.1.2"
16+
rand = "0.8.5"
17+
solana-program-test = "1.18"
18+
solana-sdk = "1.18"
19+
tokio = { version = "1.35", features = ["full"] }

0 commit comments

Comments
 (0)