crema-cli 0.1.0

Blockchain, Crema for Solana
Documentation
use borsh::{BorshDeserialize, BorshSerialize};
use solana_program::instruction::{AccountMeta, Instruction};
use solana_program::pubkey::Pubkey;

use crate::program::FARMING_MINT_WRAPPER_PROGRAM_ID;
use crate::utils::sighash;

#[derive(BorshSerialize, BorshDeserialize, PartialEq, Debug, Clone)]
pub struct NewWrapperV2 {
    pub hard_cap: u64,
}

pub fn new_wrapper_v2(
    base: Pubkey,
    mint: Pubkey,
    mint_wrapper_pubkey: Pubkey,
    payer: Pubkey,
    hardcap: u64,
) -> Instruction {
    let data = NewWrapperV2 {
        hard_cap: hardcap
    };

    let mut dsa = data.try_to_vec().unwrap();

    let mut distor = sighash::sighash("global", "new_wrapper_v2").to_vec();

    distor.append(&mut dsa);

    Instruction {
        program_id: FARMING_MINT_WRAPPER_PROGRAM_ID,
        accounts: vec![
            AccountMeta::new(base, true),
            AccountMeta::new(mint_wrapper_pubkey, false),
            AccountMeta::new(payer, true),
            AccountMeta::new_readonly(mint, false),
            AccountMeta::new_readonly(spl_token::id(), false),
            AccountMeta::new_readonly(payer, false),
            AccountMeta::new_readonly(solana_program::system_program::id(), false),
        ],
        data: distor,
    }
}