@@ -256,31 +256,57 @@ impl crate::chains::bridge_contracts::BridgeContract<EthAddress> for EthClient {
256
256
hash_lock : HashLock ,
257
257
amount : Amount , // the ETH amount
258
258
) -> BridgeContractResult < ( ) > {
259
- let contract =
260
- AtomicBridgeInitiator :: new ( self . initiator_contract_address ( ) , & self . rpc_provider ) ;
261
259
let recipient_bytes: [ u8 ; 32 ] = recipient_address. 0 . try_into ( ) . map_err ( |e| {
262
260
BridgeContractError :: ConversionFailed ( format ! (
263
261
"Failed to convert in [u8; 32] recipient_address: {e:?}"
264
262
) )
265
263
} ) ?;
266
- let call = contract
267
- . initiateBridgeTransfer (
268
- U256 :: from ( amount. weth_value ( ) ) ,
269
- FixedBytes ( recipient_bytes) ,
270
- FixedBytes ( hash_lock. 0 ) ,
271
- )
272
- . value ( U256 :: from ( amount. eth_value ( ) ) )
273
- . from ( * initiator_address. 0 ) ;
274
- let _ = send_transaction (
275
- call,
276
- & send_transaction_rules ( ) ,
277
- self . config . transaction_send_retries ,
278
- self . config . gas_limit ,
279
- )
280
- . await
281
- . map_err ( |e| {
282
- BridgeContractError :: GenericError ( format ! ( "Failed to send transaction: {}" , e) )
283
- } ) ?;
264
+
265
+ // While these match arms may look the same, the underlying contract type
266
+ // is different as it's initalized with a different ABI. So therefor we must explicitly
267
+ // call the correct one
268
+ match & self . initiator_contract {
269
+ InitiatorContract :: Weth ( contract) => {
270
+ let call = contract
271
+ . initiateBridgeTransfer (
272
+ U256 :: from ( amount. weth_value ( ) ) ,
273
+ FixedBytes ( recipient_bytes) ,
274
+ FixedBytes ( hash_lock. 0 ) ,
275
+ )
276
+ . value ( U256 :: from ( amount. eth_value ( ) ) )
277
+ . from ( * initiator_address. 0 ) ;
278
+ let _ = send_transaction (
279
+ call,
280
+ & send_transaction_rules ( ) ,
281
+ self . config . transaction_send_retries ,
282
+ self . config . gas_limit ,
283
+ )
284
+ . await
285
+ . map_err ( |e| {
286
+ BridgeContractError :: GenericError ( format ! ( "Failed to send transaction: {}" , e) )
287
+ } ) ?;
288
+ }
289
+ InitiatorContract :: Move ( contract) => {
290
+ let call = contract
291
+ . initiateBridgeTransfer (
292
+ U256 :: from ( amount. weth_value ( ) ) ,
293
+ FixedBytes ( recipient_bytes) ,
294
+ FixedBytes ( hash_lock. 0 ) ,
295
+ )
296
+ . value ( U256 :: from ( amount. eth_value ( ) ) )
297
+ . from ( * initiator_address. 0 ) ;
298
+ let _ = send_transaction (
299
+ call,
300
+ & send_transaction_rules ( ) ,
301
+ self . config . transaction_send_retries ,
302
+ self . config . gas_limit ,
303
+ )
304
+ . await
305
+ . map_err ( |e| {
306
+ BridgeContractError :: GenericError ( format ! ( "Failed to send transaction: {}" , e) )
307
+ } ) ?;
308
+ }
309
+ }
284
310
Ok ( ( ) )
285
311
}
286
312
0 commit comments