@@ -59,7 +59,6 @@ pub fn transfer_from_owner_to_vault_v2<'info>(
5959 ) ?;
6060
6161 let mut account_infos = vec ! [
62- token_program. to_account_info( ) ,
6362 // owner to vault
6463 token_owner_account. to_account_info( ) , // from (owner account)
6564 token_mint. to_account_info( ) , // mint
@@ -69,9 +68,9 @@ pub fn transfer_from_owner_to_vault_v2<'info>(
6968
7069 // TransferHook extension
7170 if let Some ( hook_program_id) = get_transfer_hook_program_id ( token_mint) ? {
72- if transfer_hook_accounts. is_none ( ) {
73- return Err ( ErrorCode :: NoExtraAccountsForTransferHook . into ( ) ) ;
74- }
71+ let transfer_hook_accounts = transfer_hook_accounts
72+ . as_deref ( )
73+ . ok_or ( ErrorCode :: NoExtraAccountsForTransferHook ) ? ;
7574
7675 spl_transfer_hook_interface:: onchain:: add_extra_accounts_for_execute_cpi (
7776 & mut instruction,
@@ -83,7 +82,7 @@ pub fn transfer_from_owner_to_vault_v2<'info>(
8382 token_vault. to_account_info ( ) , // to (vault account)
8483 authority. to_account_info ( ) , // authority (owner)
8584 amount,
86- transfer_hook_accounts. as_ref ( ) . unwrap ( ) ,
85+ transfer_hook_accounts,
8786 ) ?;
8887 }
8988
@@ -141,7 +140,6 @@ pub fn transfer_from_vault_to_owner_v2<'info>(
141140 ) ?;
142141
143142 let mut account_infos = vec ! [
144- token_program. to_account_info( ) ,
145143 // vault to owner
146144 token_vault. to_account_info( ) , // from (vault account)
147145 token_mint. to_account_info( ) , // mint
@@ -151,9 +149,9 @@ pub fn transfer_from_vault_to_owner_v2<'info>(
151149
152150 // TransferHook extension
153151 if let Some ( hook_program_id) = get_transfer_hook_program_id ( token_mint) ? {
154- if transfer_hook_accounts. is_none ( ) {
155- return Err ( ErrorCode :: NoExtraAccountsForTransferHook . into ( ) ) ;
156- }
152+ let transfer_hook_accounts = transfer_hook_accounts
153+ . as_deref ( )
154+ . ok_or ( ErrorCode :: NoExtraAccountsForTransferHook ) ? ;
157155
158156 spl_transfer_hook_interface:: onchain:: add_extra_accounts_for_execute_cpi (
159157 & mut instruction,
@@ -165,7 +163,7 @@ pub fn transfer_from_vault_to_owner_v2<'info>(
165163 token_owner_account. to_account_info ( ) , // to (owner account)
166164 whirlpool. to_account_info ( ) , // authority (pool)
167165 amount,
168- transfer_hook_accounts. as_ref ( ) . unwrap ( ) ,
166+ transfer_hook_accounts,
169167 ) ?;
170168 }
171169
0 commit comments