This repository was archived by the owner on Mar 11, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +36
-10
lines changed Expand file tree Collapse file tree 1 file changed +36
-10
lines changed Original file line number Diff line number Diff line change @@ -979,6 +979,12 @@ where
979
979
let signing_pubkeys = signing_keypairs. pubkeys ( ) ;
980
980
let multisig_signers = self . get_multisig_signers ( authority, & signing_pubkeys) ;
981
981
982
+ let fetch_account_data_fn = |address| {
983
+ self . client
984
+ . get_account ( address)
985
+ . map_ok ( |opt| opt. map ( |acc| acc. data ) )
986
+ } ;
987
+
982
988
if * destination != self . get_associated_token_address ( destination_owner) {
983
989
return Err ( TokenError :: AccountInvalidAssociatedAddress ) ;
984
990
}
@@ -1006,16 +1012,36 @@ where
1006
1012
fee,
1007
1013
) ?) ;
1008
1014
} else if let Some ( decimals) = self . decimals {
1009
- instructions. push ( instruction:: transfer_checked (
1010
- & self . program_id ,
1011
- source,
1012
- & self . pubkey ,
1013
- destination,
1014
- authority,
1015
- & multisig_signers,
1016
- amount,
1017
- decimals,
1018
- ) ?) ;
1015
+ instructions. push (
1016
+ if let Some ( transfer_hook_accounts) = & self . transfer_hook_accounts {
1017
+ let mut instruction = instruction:: transfer_checked (
1018
+ & self . program_id ,
1019
+ source,
1020
+ self . get_address ( ) ,
1021
+ destination,
1022
+ authority,
1023
+ & multisig_signers,
1024
+ amount,
1025
+ decimals,
1026
+ ) ?;
1027
+ instruction. accounts . extend ( transfer_hook_accounts. clone ( ) ) ;
1028
+ instruction
1029
+ } else {
1030
+ offchain:: create_transfer_checked_instruction_with_extra_metas (
1031
+ & self . program_id ,
1032
+ source,
1033
+ self . get_address ( ) ,
1034
+ destination,
1035
+ authority,
1036
+ & multisig_signers,
1037
+ amount,
1038
+ decimals,
1039
+ fetch_account_data_fn,
1040
+ )
1041
+ . await
1042
+ . map_err ( |_| TokenError :: AccountNotFound ) ?
1043
+ } ,
1044
+ ) ;
1019
1045
} else {
1020
1046
#[ allow( deprecated) ]
1021
1047
instructions. push ( instruction:: transfer (
You can’t perform that action at this time.
0 commit comments