Skip to content

Commit e71d816

Browse files
committed
update: defaults and match arm calls
1 parent 9ef345a commit e71d816

File tree

2 files changed

+47
-21
lines changed
  • protocol-units/bridge

2 files changed

+47
-21
lines changed

protocol-units/bridge/config/src/common/eth.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ const DEFAULT_ETH_WS_CONNECTION_PORT: u16 = 8545; // same as RPC
1111
const DEFAULT_ETH_INITIATOR_CONTRACT: &str = "Oxeee";
1212
const DEFAULT_ETH_COUNTERPARTY_CONTRACT: &str = "0xccc";
1313
const DEFAULT_ETH_WETH_CONTRACT: &str = "0xe3e3";
14-
const DEFAULT_ASSET: &str = "0xe3e3";
14+
const DEFAULT_ASSET: &str = "MOVE";
1515

1616
#[derive(Clone, Debug, Serialize, Deserialize)]
1717
pub struct EthConfig {

protocol-units/bridge/service/src/chains/ethereum/client.rs

+46-20
Original file line numberDiff line numberDiff line change
@@ -256,31 +256,57 @@ impl crate::chains::bridge_contracts::BridgeContract<EthAddress> for EthClient {
256256
hash_lock: HashLock,
257257
amount: Amount, // the ETH amount
258258
) -> BridgeContractResult<()> {
259-
let contract =
260-
AtomicBridgeInitiator::new(self.initiator_contract_address(), &self.rpc_provider);
261259
let recipient_bytes: [u8; 32] = recipient_address.0.try_into().map_err(|e| {
262260
BridgeContractError::ConversionFailed(format!(
263261
"Failed to convert in [u8; 32] recipient_address: {e:?}"
264262
))
265263
})?;
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+
}
284310
Ok(())
285311
}
286312

0 commit comments

Comments
 (0)