I'd like to make custom token program which just proxies all transaction to TOKEN_PROGRAM. I've made custom TOKEN_PROGRAM and ASSOCIATIED_TOKEN_PROGRAM, and what I'm trying to achieve is to make that token_program to invoke existing TOKEN_PROGRAM.
For instance, When I try to invoke token program for transfer, It just simply invokes existing TOKEN_PROGRAM to transfer.
This is what I tried:
let account_info_iter = &mut accounts.iter();
let source_account_info = next_account_info(account_info_iter)?;
let test1 = source_account_info.clone();
let destination_account_info = next_account_info(account_info_iter)?;
let test2 = destination_account_info.clone();
let authority_info = next_account_info(account_info_iter)?;
let transfer_tokens_instruction = transfer(
&program_id,
&source_account_info.key,
&destination_account_info.key,
&authority_info.key,
&[&source_account_info.key],
amount,
)?;
let required_accounts_for_transfer = [
test1,
test2,
];
invoke(
&transfer_tokens_instruction,
&required_accounts_for_transfer,
)?;
But it just simply don't work. How do I invoke token program? is there any source I can see?