Not able to understand this error. function takes 4 arguments but 3 arguments were suppliedrustcClick for full compiler diagnostic
entrypoint.rs(132, 19): Actual error occurred here
entrypoint.rs(132, 39): an argument of type &whitelist::Tree
is missing
lib.rs(11, 4): function defined here
entrypoint.rs(132, 39): provide the argument: (&program_id, &accounts, &instruction_data, /* &whitelist::Tree */)
use instructions::{whitelist, Tree, WHITELIST_TREE};
use solana_program::{
account_info::AccountInfo, entrypoint, entrypoint::ProgramResult, pubkey::Pubkey,
};
pub mod instructions;
pub mod processor;
entrypoint!(process_instruction);
fn process_instruction(
program_id: &Pubkey,
accounts: &[AccountInfo],
instruction_data: &[u8],
whitelist_tree: &whitelist::Tree,
) -> ProgramResult {
processor::process_instruction(program_id, accounts, instruction_data, whitelist_tree)
}
Passing right arguments :-
use {
borsh::{BorshDeserialize, BorshSerialize},
solana_program::{account_info::AccountInfo, entrypoint::ProgramResult, pubkey::Pubkey},
};
use crate::instructions::{
create::{create_token, CreateTokenArgs},
mint::{mint_token, MintSplArgs},
transfer::{transfer_tokens, TransferTokensArgs},
whitelist::{whitelist_account, WhitelistArgs, Tree},
presale::{pre_sale, PreSaleArgs, BuyerArgs},
};
#[derive(BorshSerialize, BorshDeserialize, Debug)]
enum MyInstruction {
Create(CreateTokenArgs),
MintSpl(MintSplArgs),
TransferTokens(TransferTokensArgs),
WhiteListAccount(WhitelistArgs, String),
PreSale,
}
pub fn process_instruction(
_program_id: &Pubkey,
accounts: &[AccountInfo],
instruction_data: &[u8],
whitelist_tree : &Tree,
) -> ProgramResult {
let instruction = MyInstruction::try_from_slice(instruction_data)?;
match instruction {
MyInstruction::Create(args) => create_token(accounts, args),
MyInstruction::MintSpl(args) => mint_token(accounts, args),
MyInstruction::TransferTokens(args) => transfer_tokens(accounts, args),
MyInstruction::WhiteListAccount(args, admin_account) => {
match whitelist_account(args, admin_account) {
Ok(_) => Ok(()),
Err(err) => Err(err),
}
},
MyInstruction::PreSale => pre_sale(accounts, whitelist_tree),
}
}