In that repo is an example ofresponse to your reply, I added an example showing explicitly how to spin up account data wholeclothclone and modify the USDC mint. Here's the relevant part below:
let test_mintusdc = LocalnetAccount::newnew_from_clone::<SplMintAccount, _>(
Pubkey&pubkey!("EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"),
&RpcClient::new_uniquenew("https://api.mainnet-beta.solana.com".to_string()),
"mint"usdc_mint.json".to_string(),
spl_mint_accountSome(&test_user|mint: SplMintAccount| {
let mut mint = mint.clone();
mint.mint_authority = COption::Some(test_user.address,.clone());
0, 9 SplMintAccount::from_spl_mint(mint),
})
).unwrap();
In this case, test_user.address
is the Pubkey
of the mint authority. Instead of creating entire test suites like in the example, you could write something simple that creates this newLocalnetAccount
constructor aboveobject, you'd useand just new_from_clone
, which allows one to modify the cloned data however you see fitcalls write_to_validator_json_file
on it. I will add an example showing explicitly how
You could also use this technique to clone and modify thejust create token accounts with arbitrary USDC balances instead of modifying the mint.
Note that the T: AccountSerialize + AccountDeserialize
that I am using in this example is not the Anchor SPL mint directly, but my own wrapper struct (it serializes all the same). This is because Anchor SPL types have an empty impl AccountSerialize
, which by default do nothing.