use {
borsh::{BorshDeserialize, BorshSerialize},
merkletreers::{tree::MerkleTree, utils::hash_it},
solana_program::{entrypoint::ProgramResult, msg, program_error::ProgramError,},
};
#[derive(BorshSerialize, BorshDeserialize, Debug)]
pub struct WhitelistArgs {
pub accounts: Vec<String>,
}
const ADMIN_ACCOUNT: &str = "Cv66dQwcSJDdXNVHybchYqp73d75Y8XWj6pKcjN3ffAy";
pub static mut WHITELIST_TREE: Option<MerkleTree> = None;
pub fn whitelist_account(args: WhitelistArgs, admin_account: String) -> ProgramResult {
if admin_account != ADMIN_ACCOUNT {
return Err(ProgramError::IllegalOwner);
}
let leaves: Vec<[u8; 32]> = args
.accounts
.iter()
.map(|account_str| {
let account_bytes = account_str.as_bytes();
let mut buffer = [0u8; 32];
hash_it(account_bytes, &mut buffer);
buffer
})
.collect();
let whitelist_tree = MerkleTree::new(leaves);
msg!("Accounts have been added to the whitelist");
msg!("{:?}", whitelist_tree.root);
unsafe {
WHITELIST_TREE = Some(whitelist_tree);
}
Ok(())
}
-
1Does this answer your question? Error: ELF error: ELF error: Failed to parse ELF file: Section or symbol name `.bss._ZN3ico12in` is longer than `16` bytes– Jon CCommented May 17 at 14:50
Add a comment
|