From 74ee3c55ac2b1ba3c6c740d48d94c6aa53412e24 Mon Sep 17 00:00:00 2001 From: chizor iwuh Date: Fri, 8 Nov 2024 09:32:05 +0100 Subject: [PATCH] spl-token-minter/steel - add api --- tokens/spl-token-minter/steel/Cargo.toml | 12 +++++++++++- tokens/spl-token-minter/steel/api/Cargo.toml | 17 +++++++++++++++++ .../src/instruction}/create.rs | 3 ++- .../src/instruction}/mint.rs | 2 +- .../instructions => api/src/instruction}/mod.rs | 0 tokens/spl-token-minter/steel/api/src/lib.rs | 11 +++++++++++ .../borsh_instruction.rs => api/src/macros.rs} | 0 .../spl-token-minter/steel/program/Cargo.toml | 11 +++-------- .../spl-token-minter/steel/program/src/lib.rs | 10 ++-------- 9 files changed, 47 insertions(+), 19 deletions(-) create mode 100644 tokens/spl-token-minter/steel/api/Cargo.toml rename tokens/spl-token-minter/steel/{program/src/instructions => api/src/instruction}/create.rs (98%) rename tokens/spl-token-minter/steel/{program/src/instructions => api/src/instruction}/mint.rs (98%) rename tokens/spl-token-minter/steel/{program/src/instructions => api/src/instruction}/mod.rs (100%) create mode 100644 tokens/spl-token-minter/steel/api/src/lib.rs rename tokens/spl-token-minter/steel/{program/src/borsh_instruction.rs => api/src/macros.rs} (100%) diff --git a/tokens/spl-token-minter/steel/Cargo.toml b/tokens/spl-token-minter/steel/Cargo.toml index 39fc8ab6..d7c03a45 100644 --- a/tokens/spl-token-minter/steel/Cargo.toml +++ b/tokens/spl-token-minter/steel/Cargo.toml @@ -1,3 +1,13 @@ [workspace] -members = ["program"] +members = ["api","program"] resolver = "2" + +[workspace.dependencies] +solana-program = "=1.18.17" +steel = {version = "2.0", 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" } \ No newline at end of file diff --git a/tokens/spl-token-minter/steel/api/Cargo.toml b/tokens/spl-token-minter/steel/api/Cargo.toml new file mode 100644 index 00000000..f48c44ec --- /dev/null +++ b/tokens/spl-token-minter/steel/api/Cargo.toml @@ -0,0 +1,17 @@ +[package] +name = "spl-token-minter-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 diff --git a/tokens/spl-token-minter/steel/program/src/instructions/create.rs b/tokens/spl-token-minter/steel/api/src/instruction/create.rs similarity index 98% rename from tokens/spl-token-minter/steel/program/src/instructions/create.rs rename to tokens/spl-token-minter/steel/api/src/instruction/create.rs index f24e1641..92f08c6d 100644 --- a/tokens/spl-token-minter/steel/program/src/instructions/create.rs +++ b/tokens/spl-token-minter/steel/api/src/instruction/create.rs @@ -1,4 +1,5 @@ -use crate::{borsh_instruction, SteelInstruction}; +use super::SteelInstruction; +use crate::borsh_instruction; use borsh::{BorshDeserialize, BorshSerialize}; use mpl_token_metadata::{instructions as mpl_instruction, types::DataV2}; use solana_program::{msg, program::invoke, program_pack::Pack, rent::Rent, system_instruction}; diff --git a/tokens/spl-token-minter/steel/program/src/instructions/mint.rs b/tokens/spl-token-minter/steel/api/src/instruction/mint.rs similarity index 98% rename from tokens/spl-token-minter/steel/program/src/instructions/mint.rs rename to tokens/spl-token-minter/steel/api/src/instruction/mint.rs index 9897130e..fe363d03 100644 --- a/tokens/spl-token-minter/steel/program/src/instructions/mint.rs +++ b/tokens/spl-token-minter/steel/api/src/instruction/mint.rs @@ -1,4 +1,4 @@ -use crate::SteelInstruction; +use super::SteelInstruction; use solana_program::{msg, program::invoke}; use spl_token::instruction::{self as token_instruction}; use steel::*; diff --git a/tokens/spl-token-minter/steel/program/src/instructions/mod.rs b/tokens/spl-token-minter/steel/api/src/instruction/mod.rs similarity index 100% rename from tokens/spl-token-minter/steel/program/src/instructions/mod.rs rename to tokens/spl-token-minter/steel/api/src/instruction/mod.rs diff --git a/tokens/spl-token-minter/steel/api/src/lib.rs b/tokens/spl-token-minter/steel/api/src/lib.rs new file mode 100644 index 00000000..015a0914 --- /dev/null +++ b/tokens/spl-token-minter/steel/api/src/lib.rs @@ -0,0 +1,11 @@ +pub mod instruction; +pub mod macros; + +pub mod prelude { + pub use crate::instruction::*; +} + +use steel::*; + +// TODO Set program id +declare_id!("z7msBPQHDJjTvdQRoEcKyENgXDhSRYeHieN1ZMTqo35"); diff --git a/tokens/spl-token-minter/steel/program/src/borsh_instruction.rs b/tokens/spl-token-minter/steel/api/src/macros.rs similarity index 100% rename from tokens/spl-token-minter/steel/program/src/borsh_instruction.rs rename to tokens/spl-token-minter/steel/api/src/macros.rs diff --git a/tokens/spl-token-minter/steel/program/Cargo.toml b/tokens/spl-token-minter/steel/program/Cargo.toml index da553580..dd79d643 100644 --- a/tokens/spl-token-minter/steel/program/Cargo.toml +++ b/tokens/spl-token-minter/steel/program/Cargo.toml @@ -7,11 +7,6 @@ edition = "2021" crate-type = ["cdylib", "lib"] [dependencies] -solana-program = "=1.18.17" -steel = {version = "2.0", 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 = "2.0.3", features = [ "no-entrypoint" ] } -mpl-token-metadata = { version = "4.1.2" } +steel.workspace = true +spl-token-minter-steel-api = {path = "../api"} + diff --git a/tokens/spl-token-minter/steel/program/src/lib.rs b/tokens/spl-token-minter/steel/program/src/lib.rs index 97d9c16f..1472add0 100644 --- a/tokens/spl-token-minter/steel/program/src/lib.rs +++ b/tokens/spl-token-minter/steel/program/src/lib.rs @@ -1,11 +1,6 @@ -mod borsh_instruction; -mod instructions; - -use instructions::*; +use spl_token_minter_steel_api::prelude::*; use steel::*; -declare_id!("z7msBPQHDJjTvdQRoEcKyENgXDhSRYeHieN1ZMTqo35"); - entrypoint!(process_instruction); pub fn process_instruction( @@ -13,8 +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(&spl_token_minter_steel_api::ID, program_id, data)?; match ix { SteelInstruction::CreateToken => CreateToken::process(accounts, data)?, SteelInstruction::MintTo => MintTo::process(accounts, data)?,