diff --git a/Cargo.lock b/Cargo.lock index f54b45b7..2b52a9a6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -15,7 +15,7 @@ version = "0.1.0" dependencies = [ "borsh 0.9.3", "borsh-derive 0.9.3", - "solana-program", + "solana-program 1.18.17", ] [[package]] @@ -219,7 +219,7 @@ dependencies = [ "borsh 0.10.3", "bytemuck", "getrandom 0.2.15", - "solana-program", + "solana-program 1.18.17", "thiserror", ] @@ -451,6 +451,12 @@ version = "0.21.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567" +[[package]] +name = "base64" +version = "0.22.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" + [[package]] name = "bincode" version = "1.3.3" @@ -738,7 +744,7 @@ dependencies = [ name = "checking-accounts-program" version = "0.1.0" dependencies = [ - "solana-program", + "solana-program 1.18.17", ] [[package]] @@ -765,7 +771,7 @@ version = "0.1.0" dependencies = [ "borsh 0.9.3", "borsh-derive 0.9.3", - "solana-program", + "solana-program 1.18.17", ] [[package]] @@ -807,7 +813,7 @@ version = "0.1.0" dependencies = [ "borsh 0.9.3", "shank", - "solana-program", + "solana-program 1.18.17", ] [[package]] @@ -815,7 +821,7 @@ name = "counter-solana-native" version = "0.1.0" dependencies = [ "borsh 0.9.3", - "solana-program", + "solana-program 1.18.17", ] [[package]] @@ -838,7 +844,7 @@ dependencies = [ name = "create-account-program" version = "0.1.0" dependencies = [ - "solana-program", + "solana-program 1.18.17", ] [[package]] @@ -1154,7 +1160,7 @@ dependencies = [ name = "hello-solana-program" version = "0.1.0" dependencies = [ - "solana-program", + "solana-program 1.18.17", ] [[package]] @@ -1571,7 +1577,7 @@ version = "0.1.0" dependencies = [ "borsh 0.9.3", "borsh-derive 0.9.3", - "solana-program", + "solana-program 1.18.17", ] [[package]] @@ -1674,7 +1680,7 @@ version = "0.1.0" dependencies = [ "borsh 0.9.3", "borsh-derive 0.9.3", - "solana-program", + "solana-program 1.18.17", ] [[package]] @@ -1683,7 +1689,7 @@ version = "0.1.0" dependencies = [ "borsh 0.9.3", "borsh-derive 0.9.3", - "solana-program", + "solana-program 1.18.17", ] [[package]] @@ -1692,7 +1698,7 @@ version = "0.1.0" dependencies = [ "borsh 0.9.3", "borsh-derive 0.9.3", - "solana-program", + "solana-program 1.18.17", ] [[package]] @@ -1830,7 +1836,7 @@ version = "0.1.0" dependencies = [ "borsh 0.9.3", "borsh-derive 0.9.3", - "solana-program", + "solana-program 1.18.17", ] [[package]] @@ -1884,7 +1890,7 @@ version = "0.1.0" dependencies = [ "borsh 0.9.3", "borsh-derive 0.9.3", - "solana-program", + "solana-program 1.18.17", ] [[package]] @@ -2202,13 +2208,59 @@ dependencies = [ "sha3 0.10.8", "solana-frozen-abi", "solana-frozen-abi-macro", - "solana-sdk-macro", + "solana-sdk-macro 1.18.17", "thiserror", "tiny-bip39", "wasm-bindgen", "zeroize", ] +[[package]] +name = "solana-program" +version = "2.0.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2625a23c3813b620141ee447819b08d1b9a5f1c69a309754834e3f35798a21fb" +dependencies = [ + "ark-bn254", + "ark-ec", + "ark-ff", + "ark-serialize", + "base64 0.22.1", + "bincode", + "bitflags", + "blake3", + "borsh 0.10.3", + "borsh 1.5.1", + "bs58 0.5.1", + "bv", + "bytemuck", + "bytemuck_derive", + "console_error_panic_hook", + "console_log", + "curve25519-dalek", + "getrandom 0.2.15", + "js-sys", + "lazy_static", + "libsecp256k1", + "log", + "memoffset", + "num-bigint", + "num-derive 0.4.2", + "num-traits", + "parking_lot", + "rand 0.8.5", + "rustc_version", + "rustversion", + "serde", + "serde_bytes", + "serde_derive", + "sha2 0.10.8", + "sha3 0.10.8", + "solana-sdk-macro 2.0.14", + "thiserror", + "wasm-bindgen", +] + [[package]] name = "solana-sdk" version = "1.18.17" @@ -2257,8 +2309,8 @@ dependencies = [ "solana-frozen-abi", "solana-frozen-abi-macro", "solana-logger", - "solana-program", - "solana-sdk-macro", + "solana-program 1.18.17", + "solana-sdk-macro 1.18.17", "thiserror", "uriparse", "wasm-bindgen", @@ -2277,6 +2329,19 @@ dependencies = [ "syn 2.0.72", ] +[[package]] +name = "solana-sdk-macro" +version = "2.0.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93a5a1eabc890415d326707afe62cd7a2009236e8d899c1519566fc8f7e3977b" +dependencies = [ + "bs58 0.5.1", + "proc-macro2", + "quote", + "rustversion", + "syn 2.0.72", +] + [[package]] name = "solana-security-txt" version = "1.1.1" @@ -2305,7 +2370,7 @@ dependencies = [ "serde", "serde_json", "sha3 0.9.1", - "solana-program", + "solana-program 1.18.17", "solana-sdk", "subtle", "thiserror", @@ -2322,7 +2387,7 @@ dependencies = [ "borsh 0.10.3", "num-derive 0.4.2", "num-traits", - "solana-program", + "solana-program 1.18.17", "spl-token", "spl-token-2022 1.0.0", "thiserror", @@ -2335,7 +2400,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cce5d563b58ef1bb2cdbbfe0dfb9ffdc24903b10ae6a4df2d8f425ece375033f" dependencies = [ "bytemuck", - "solana-program", + "solana-program 1.18.17", "spl-discriminator-derive", ] @@ -2369,7 +2434,7 @@ version = "3.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bd0dc6f70db6bacea7ff25870b016a65ba1d1b6013536f08e4fd79a8f9005325" dependencies = [ - "solana-program", + "solana-program 1.18.17", ] [[package]] @@ -2378,7 +2443,7 @@ version = "4.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a49f49f95f2d02111ded31696ab38a081fab623d4c76bd4cb074286db4560836" dependencies = [ - "solana-program", + "solana-program 1.18.17", ] [[package]] @@ -2389,7 +2454,7 @@ checksum = "2881dddfca792737c0706fa0175345ab282b1b0879c7d877bad129645737c079" dependencies = [ "borsh 0.10.3", "bytemuck", - "solana-program", + "solana-program 1.18.17", "solana-zk-token-sdk", "spl-program-error 0.3.0", ] @@ -2402,7 +2467,7 @@ checksum = "af92f74cd3b0fdfda59fef4b571a92123e4df0f67cc43f73163975d31118ef82" dependencies = [ "num-derive 0.3.3", "num-traits", - "solana-program", + "solana-program 1.18.17", "spl-program-error-derive 0.2.0", "thiserror", ] @@ -2415,7 +2480,7 @@ checksum = "249e0318493b6bcf27ae9902600566c689b7dfba9f1bdff5893e92253374e78c" dependencies = [ "num-derive 0.4.2", "num-traits", - "solana-program", + "solana-program 1.18.17", "spl-program-error-derive 0.3.2", "thiserror", ] @@ -2450,7 +2515,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "82149a5a06b5f158d03904066375eaf0c8a2422557cc3d5a25d277260d9a3b16" dependencies = [ "bytemuck", - "solana-program", + "solana-program 1.18.17", "spl-discriminator", "spl-program-error 0.2.0", "spl-type-length-value 0.2.0", @@ -2463,7 +2528,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "615d381f48ddd2bb3c57c7f7fb207591a2a05054639b18a62e785117dd7a8683" dependencies = [ "bytemuck", - "solana-program", + "solana-program 1.18.17", "spl-discriminator", "spl-pod", "spl-program-error 0.3.0", @@ -2481,7 +2546,7 @@ dependencies = [ "num-derive 0.4.2", "num-traits", "num_enum 0.7.3", - "solana-program", + "solana-program 1.18.17", "thiserror", ] @@ -2496,7 +2561,7 @@ dependencies = [ "num-derive 0.3.3", "num-traits", "num_enum 0.6.1", - "solana-program", + "solana-program 1.18.17", "solana-zk-token-sdk", "spl-memo 3.0.1", "spl-token", @@ -2515,7 +2580,7 @@ dependencies = [ "num-derive 0.4.2", "num-traits", "num_enum 0.7.3", - "solana-program", + "solana-program 1.18.17", "solana-security-txt", "solana-zk-token-sdk", "spl-memo 4.0.4", @@ -2535,7 +2600,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b889509d49fa74a4a033ca5dae6c2307e9e918122d97e58562f5c4ffa795c75d" dependencies = [ "bytemuck", - "solana-program", + "solana-program 1.18.17", "spl-discriminator", "spl-pod", "spl-program-error 0.3.0", @@ -2548,7 +2613,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4c16ce3ba6979645fb7627aa1e435576172dd63088dc7848cb09aa331fa1fe4f" dependencies = [ "borsh 0.10.3", - "solana-program", + "solana-program 1.18.17", "spl-discriminator", "spl-pod", "spl-program-error 0.3.0", @@ -2566,7 +2631,7 @@ dependencies = [ "num-derive 0.3.3", "num-traits", "num_enum 0.6.1", - "solana-program", + "solana-program 1.18.17", "spl-discriminator", "spl-tlv-account-resolution 0.2.0", "spl-type-length-value 0.2.0", @@ -2581,7 +2646,7 @@ checksum = "7aabdb7c471566f6ddcee724beb8618449ea24b399e58d464d6b5bc7db550259" dependencies = [ "arrayref", "bytemuck", - "solana-program", + "solana-program 1.18.17", "spl-discriminator", "spl-pod", "spl-program-error 0.3.0", @@ -2596,7 +2661,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f1d085f426b33b8365fb98383d1b8b3925e21bdfe579c851ceaa7f511dbec191" dependencies = [ "bytemuck", - "solana-program", + "solana-program 1.18.17", "spl-discriminator", "spl-program-error 0.2.0", ] @@ -2608,12 +2673,32 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a468e6f6371f9c69aae760186ea9f1a01c2908351b06a5e0026d21cfc4d7ecac" dependencies = [ "bytemuck", - "solana-program", + "solana-program 1.18.17", "spl-discriminator", "spl-pod", "spl-program-error 0.3.0", ] +[[package]] +name = "steel" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d88c610ca9fd5e4e51bdb6e9964114133a42f006713fe38aff37266fac91e1be" +dependencies = [ + "bytemuck", + "num_enum 0.7.3", + "solana-program 1.18.17", + "thiserror", +] + +[[package]] +name = "steel-hello-solana" +version = "0.1.0" +dependencies = [ + "solana-program 2.0.14", + "steel", +] + [[package]] name = "strsim" version = "0.11.1" @@ -2729,7 +2814,7 @@ version = "0.1.0" dependencies = [ "borsh 0.9.3", "borsh-derive 0.9.3", - "solana-program", + "solana-program 1.18.17", "spl-associated-token-account", "spl-token-2022 0.7.0", ] @@ -2740,7 +2825,7 @@ version = "0.1.0" dependencies = [ "borsh 0.9.3", "borsh-derive 0.9.3", - "solana-program", + "solana-program 1.18.17", "spl-associated-token-account", "spl-token-2022 0.7.0", ] @@ -2751,7 +2836,7 @@ version = "0.1.0" dependencies = [ "borsh 0.9.3", "borsh-derive 0.9.3", - "solana-program", + "solana-program 1.18.17", "spl-associated-token-account", "spl-token-2022 0.7.0", ] @@ -2762,7 +2847,7 @@ version = "0.1.0" dependencies = [ "borsh 0.9.3", "borsh-derive 0.9.3", - "solana-program", + "solana-program 1.18.17", "spl-associated-token-account", "spl-token-2022 0.7.0", ] @@ -2773,7 +2858,7 @@ version = "0.1.0" dependencies = [ "borsh 0.10.3", "borsh-derive 0.9.3", - "solana-program", + "solana-program 1.18.17", "spl-associated-token-account", "spl-token-2022 0.7.0", ] @@ -2856,7 +2941,7 @@ version = "0.1.0" dependencies = [ "borsh 0.9.3", "borsh-derive 0.9.3", - "solana-program", + "solana-program 1.18.17", ] [[package]] diff --git a/tokens/create-token/steel/api/src/consts.rs b/tokens/create-token/steel/api/src/consts.rs index 7e7b02db..29271aa6 100644 --- a/tokens/create-token/steel/api/src/consts.rs +++ b/tokens/create-token/steel/api/src/consts.rs @@ -1,10 +1,2 @@ -/// The seed of the mint account PDA. -pub const MINT: &[u8] = b"mint"; - -/// Noise for deriving the mint pda -pub const MINT_NOISE: [u8; 16] = [ - 89, 157, 88, 232, 243, 249, 197, 132, 199, 49, 19, 234, 91, 94, 150, 41, -]; - /// The seed of the metadata account PDA. pub const METADATA: &[u8] = b"metadata"; diff --git a/tokens/create-token/steel/program/build.rs b/tokens/create-token/steel/program/build.rs new file mode 100644 index 00000000..e4ff00ff --- /dev/null +++ b/tokens/create-token/steel/program/build.rs @@ -0,0 +1,24 @@ +// build.rs +use std::fs; +use std::process::Command; + +fn main() { + println!("cargo:rerun-if-changed=build.rs"); + + // Create the fixtures directory path + fs::create_dir_all("tests/fixtures").expect("Failed to create fixtures directory"); + + let status = Command::new("solana") + .args([ + "program", + "dump", + "metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s", + "tests/fixtures/token_metadata.so", + ]) + .status() + .expect("Failed to run solana program dump command"); + + if !status.success() { + panic!("Failed to dump Solana program"); + } +} diff --git a/tokens/create-token/steel/program/src/create.rs b/tokens/create-token/steel/program/src/create.rs index 2005ad4d..e512277e 100644 --- a/tokens/create-token/steel/program/src/create.rs +++ b/tokens/create-token/steel/program/src/create.rs @@ -24,6 +24,7 @@ pub fn process_create(accounts: &[AccountInfo<'_>], data: &[u8]) -> ProgramResul mint_info.is_empty()?.is_writable()?; system_program.is_program(&system_program::ID)?; token_program.is_program(&spl_token::ID)?; + metadata_program.is_program(&mpl_token_metadata::ID)?; rent_sysvar.is_sysvar(&sysvar::rent::ID)?; // First create the account for the Mint diff --git a/tokens/create-token/steel/tests/bankrun.test.ts b/tokens/create-token/steel/tests/bankrun.test.ts index e10dd613..759ba5d0 100644 --- a/tokens/create-token/steel/tests/bankrun.test.ts +++ b/tokens/create-token/steel/tests/bankrun.test.ts @@ -14,9 +14,8 @@ import { Transaction, TransactionInstruction, } from "@solana/web3.js"; -import { BN } from "bn.js"; import { start } from "solana-bankrun"; -import { CreateTokenArgs, SplMinterInstruction } from "./instructions"; +import { CreateTokenArgs } from "./instructions"; describe("Create Tokens!", async () => { const PROGRAM_ID = new PublicKey( @@ -51,7 +50,7 @@ describe("Create Tokens!", async () => { "Solana Gold", "GOLDSOL", "https://raw.githubusercontent.com/solana-developers/program-examples/new-examples/tokens/tokens/.assets/spl-token.json", - "9", + 9, ); const createTokenIx = new TransactionInstruction({ @@ -107,7 +106,7 @@ describe("Create Tokens!", async () => { "Homer NFT", "HOMR", "https://raw.githubusercontent.com/solana-developers/program-examples/new-examples/tokens/tokens/.assets/nft.json", - "0", + 0, ); const createTokenIx = new TransactionInstruction({ diff --git a/tokens/create-token/steel/tests/instructions.ts b/tokens/create-token/steel/tests/instructions.ts index b4acc9b7..1727cc94 100644 --- a/tokens/create-token/steel/tests/instructions.ts +++ b/tokens/create-token/steel/tests/instructions.ts @@ -1,6 +1,3 @@ -import * as borsh from "borsh"; -import { BN } from "bn.js"; - class Assignable { constructor(properties) { for (const [key, value] of Object.entries(properties)) { @@ -16,9 +13,8 @@ function strToBytes(str: string, length: number): Buffer { return buffer; } -export enum SplMinterInstruction { +export enum CreateTokenInstruction { Create = 0, - Mint = 1, } export class CreateTokenArgs { @@ -26,28 +22,39 @@ export class CreateTokenArgs { name: Buffer; symbol: Buffer; uri: Buffer; - decimals: Buffer; + decimals: number; - constructor(name: string, symbol: string, uri: string, decimals: string) { - this.instruction = SplMinterInstruction.Create; + constructor(name: string, symbol: string, uri: string, decimals: number) { + this.instruction = CreateTokenInstruction.Create; this.name = strToBytes(name, 32); this.symbol = strToBytes(symbol, 8); this.uri = strToBytes(uri, 64); - this.decimals = strToBytes(decimals, 8); + this.decimals = decimals; } toBuffer(): Buffer { - const buffer = Buffer.alloc(1 + 32 + 8 + 64); + // Added 1 byte for decimals to the total buffer size + const buffer = Buffer.alloc(1 + 32 + 8 + 64 + 1); let offset = 0; + // Write instruction buffer.writeUInt8(this.instruction, offset); offset += 1; + // Write name this.name.copy(buffer, offset); offset += 32; + + // Write symbol this.symbol.copy(buffer, offset); offset += 8; + + // Write uri this.uri.copy(buffer, offset); + offset += 64; + + // Write decimals + buffer.writeUInt8(this.decimals, offset); return buffer; }