Skip to content

Commit

Permalink
transfer-tokens/steel - add api
Browse files Browse the repository at this point in the history
  • Loading branch information
thewuhxyz committed Nov 8, 2024
1 parent 8332368 commit 67540bc
Show file tree
Hide file tree
Showing 11 changed files with 43 additions and 16 deletions.
12 changes: 11 additions & 1 deletion tokens/transfer-tokens/steel/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
[workspace]
members = ["program"]
members = ["api","program"]
resolver = "2"

[workspace.dependencies]
solana-program = "1.18.17"
steel = {version = "2.1", features = ["spl"]}
bytemuck = "1.4"
num_enum = "0.7"
borsh = "1.5.1"
spl-token = { version = "4.0.0", features = [ "no-entrypoint" ] }
spl-associated-token-account = { version = "3.0.4", features = [ "no-entrypoint" ] }
mpl-token-metadata = { version = "4.1.2" }
17 changes: 17 additions & 0 deletions tokens/transfer-tokens/steel/api/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[package]
name = "transfer-tokens-steel-api"
version = "0.1.0"
edition = "2021"

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

[dependencies]
solana-program.workspace = true
steel.workspace = true
bytemuck.workspace = true
num_enum.workspace = true
borsh.workspace = true
spl-token.workspace = true
spl-associated-token-account.workspace = true
mpl-token-metadata.workspace = true
12 changes: 12 additions & 0 deletions tokens/transfer-tokens/steel/api/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
pub mod instruction;
pub mod macros;

use instruction::*;
use steel::*;

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

// TODO Set program id
declare_id!("z7msBPQHDJjTvdQRoEcKyENgXDhSRYeHieN1ZMTqo35");
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ macro_rules! borsh_instruction {
}
}

#[allow(dead_code)]
// adds discriminator to the instruction data, helpful with cpis etc.
impl $struct_name {
pub fn to_bytes(&self) -> Result<Vec<u8>, solana_program::program_error::ProgramError> {
Expand Down
8 changes: 1 addition & 7 deletions tokens/transfer-tokens/steel/program/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,5 @@ edition = "2021"
crate-type = ["cdylib", "lib"]

[dependencies]
solana-program = "1.18.17"
steel = {version = "2.1", features = ["spl"]}
bytemuck = "1.4"
num_enum = "0.7"
borsh = "1.5.1"
spl-token = { version = "4.0.0", features = [ "no-entrypoint" ] }
spl-associated-token-account = { version = "3.0.4", features = [ "no-entrypoint" ] }
mpl-token-metadata = { version = "4.1.2" }
transfer-tokens-steel-api = {path = "../api"}
9 changes: 2 additions & 7 deletions tokens/transfer-tokens/steel/program/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
mod borsh_instruction;
mod instructions;

use instructions::*;
use steel::*;

declare_id!("z7msBPQHDJjTvdQRoEcKyENgXDhSRYeHieN1ZMTqo35");
use transfer_tokens_steel_api::prelude::*;

entrypoint!(process_instruction);

Expand All @@ -13,7 +8,7 @@ pub fn process_instruction(
accounts: &[AccountInfo],
data: &[u8],
) -> ProgramResult {
let (ix, data) = parse_instruction(&crate::ID, program_id, data)?;
let (ix, data) = parse_instruction(&transfer_tokens_steel_api::ID, program_id, data)?;

match ix {
SteelInstruction::Create => Create::process(accounts, data)?,
Expand Down

0 comments on commit 67540bc

Please sign in to comment.