|
| 1 | +use steel::*; |
| 2 | + |
| 3 | +use crate::prelude::*; |
| 4 | + |
| 5 | +pub fn create( |
| 6 | + payer: Pubkey, |
| 7 | + mint: Pubkey, |
| 8 | + token_name: [u8; 32], |
| 9 | + token_symbol: [u8; 8], |
| 10 | + token_uri: [u8; 64], |
| 11 | +) -> Instruction { |
| 12 | + let metadata_pda = Pubkey::find_program_address( |
| 13 | + &[METADATA, mpl_token_metadata::ID.as_ref(), mint.as_ref()], |
| 14 | + &mpl_token_metadata::ID, |
| 15 | + ); |
| 16 | + |
| 17 | + Instruction { |
| 18 | + program_id: crate::ID, |
| 19 | + accounts: vec![ |
| 20 | + AccountMeta::new(payer, true), |
| 21 | + AccountMeta::new(mint, true), |
| 22 | + AccountMeta::new(metadata_pda.0, false), |
| 23 | + AccountMeta::new_readonly(system_program::ID, false), |
| 24 | + AccountMeta::new_readonly(spl_token::ID, false), |
| 25 | + AccountMeta::new_readonly(mpl_token_metadata::ID, false), |
| 26 | + AccountMeta::new_readonly(sysvar::rent::ID, false), |
| 27 | + ], |
| 28 | + data: Create { |
| 29 | + token_name, |
| 30 | + token_symbol, |
| 31 | + token_uri, |
| 32 | + } |
| 33 | + .to_bytes(), |
| 34 | + } |
| 35 | +} |
| 36 | +pub fn mint( |
| 37 | + mint_authority: Pubkey, |
| 38 | + recipient: Pubkey, |
| 39 | + mint: Pubkey, |
| 40 | + associated_token_account: Pubkey, |
| 41 | + quantity: u64, |
| 42 | +) -> Instruction { |
| 43 | + Instruction { |
| 44 | + program_id: crate::ID, |
| 45 | + accounts: vec![ |
| 46 | + AccountMeta::new(mint_authority, true), |
| 47 | + AccountMeta::new(recipient, false), |
| 48 | + AccountMeta::new(mint, false), |
| 49 | + AccountMeta::new(associated_token_account, false), |
| 50 | + AccountMeta::new_readonly(spl_token::ID, false), |
| 51 | + AccountMeta::new_readonly(spl_associated_token_account::ID, false), |
| 52 | + AccountMeta::new_readonly(system_program::ID, false), |
| 53 | + ], |
| 54 | + data: Mint { |
| 55 | + quantity: quantity.to_le_bytes(), |
| 56 | + } |
| 57 | + .to_bytes(), |
| 58 | + } |
| 59 | +} |
0 commit comments