Skip to content

Commit

Permalink
fix native create token errors
Browse files Browse the repository at this point in the history
  • Loading branch information
valentinmadrid committed Jul 4, 2023
1 parent 3f7abc9 commit fb8512d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 23 deletions.
5 changes: 4 additions & 1 deletion tokens/create-token/native/program/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
32 changes: 10 additions & 22 deletions tokens/create-token/native/program/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,30 +1,21 @@
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,
rent::Rent,
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,
Expand All @@ -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();
Expand Down Expand Up @@ -73,7 +61,7 @@ fn process_instruction(
payer.clone(),
system_program.clone(),
token_program.clone(),
]
],
)?;

// Now initialize that account as a Mint (standard Mint)
Expand All @@ -93,7 +81,7 @@ fn process_instruction(
mint_authority.clone(),
token_program.clone(),
rent.clone(),
]
],
)?;

// Now create the account for that Mint's metadata
Expand Down Expand Up @@ -126,10 +114,10 @@ fn process_instruction(
payer.clone(),
token_metadata_program.clone(),
rent.clone(),
]
],
)?;

msg!("Token mint created successfully.");

Ok(())
}
}

0 comments on commit fb8512d

Please sign in to comment.