From fb8512db27616b88fb1365a82b941c6c417916fe Mon Sep 17 00:00:00 2001 From: Valentin Madrid Date: Tue, 4 Jul 2023 14:56:06 +0200 Subject: [PATCH] fix native create token errors --- tokens/create-token/native/program/Cargo.toml | 5 ++- tokens/create-token/native/program/src/lib.rs | 32 ++++++------------- 2 files changed, 14 insertions(+), 23 deletions(-) diff --git a/tokens/create-token/native/program/Cargo.toml b/tokens/create-token/native/program/Cargo.toml index 3efd12b7..7aa50c4a 100644 --- a/tokens/create-token/native/program/Cargo.toml +++ b/tokens/create-token/native/program/Cargo.toml @@ -6,10 +6,13 @@ edition = "2021" [dependencies] borsh = "0.9.3" borsh-derive = "0.9.1" -solana-program = "1.10.26" spl-token = { version="3.3.0", features = [ "no-entrypoint" ] } spl-associated-token-account = { version="1.0.5", features = [ "no-entrypoint" ] } mpl-token-metadata = { version="1.2.5", features = [ "no-entrypoint" ] } +winnow = "=0.4.1" +getrandom = { version = "0.2.9", features = ["custom"] } +solana-program = "=1.14.17" +toml_datetime="=0.6.1" [lib] crate-type = ["cdylib", "lib"] \ No newline at end of file diff --git a/tokens/create-token/native/program/src/lib.rs b/tokens/create-token/native/program/src/lib.rs index d82ee109..755acdda 100644 --- a/tokens/create-token/native/program/src/lib.rs +++ b/tokens/create-token/native/program/src/lib.rs @@ -1,13 +1,11 @@ use { - borsh::{ - BorshSerialize, - BorshDeserialize - }, + borsh::{BorshDeserialize, BorshSerialize}, + mpl_token_metadata::instruction as mpl_instruction, solana_program::{ - account_info::{next_account_info, AccountInfo}, + account_info::{next_account_info, AccountInfo}, entrypoint, - entrypoint::ProgramResult, - msg, + entrypoint::ProgramResult, + msg, program::invoke, program_pack::Pack, pubkey::Pubkey, @@ -15,16 +13,9 @@ use { system_instruction, sysvar::Sysvar, }, - spl_token::{ - instruction as token_instruction, - state::Mint, - }, - mpl_token_metadata::{ - instruction as mpl_instruction, - }, + spl_token::{instruction as token_instruction, state::Mint}, }; - #[derive(BorshSerialize, BorshDeserialize, Debug)] pub struct CreateTokenArgs { pub token_title: String, @@ -33,16 +24,13 @@ pub struct CreateTokenArgs { pub token_decimals: u8, } - entrypoint!(process_instruction); - fn process_instruction( _program_id: &Pubkey, accounts: &[AccountInfo], instruction_data: &[u8], ) -> ProgramResult { - let args = CreateTokenArgs::try_from_slice(instruction_data)?; let accounts_iter = &mut accounts.iter(); @@ -73,7 +61,7 @@ fn process_instruction( payer.clone(), system_program.clone(), token_program.clone(), - ] + ], )?; // Now initialize that account as a Mint (standard Mint) @@ -93,7 +81,7 @@ fn process_instruction( mint_authority.clone(), token_program.clone(), rent.clone(), - ] + ], )?; // Now create the account for that Mint's metadata @@ -126,10 +114,10 @@ fn process_instruction( payer.clone(), token_metadata_program.clone(), rent.clone(), - ] + ], )?; msg!("Token mint created successfully."); Ok(()) -} \ No newline at end of file +}