diff --git a/integration/chain_orchestrator.test.ts b/integration/chain_orchestrator.test.ts
index 60e9a7e6..d173669a 100644
--- a/integration/chain_orchestrator.test.ts
+++ b/integration/chain_orchestrator.test.ts
@@ -13,19 +13,21 @@ describe('Chain abstraction orchestrator', () => {
const from_address_with_funds = "0x2aae531a81461f029cd55cb46703211c9227ba05";
const usdc_funds_on_base = 3_000_000;
const usdc_funds_on_optimism = 1_057_151;
+ const usdc_token_symbol = "USDC";
// Amount to send to Optimism
const amount_to_send = 3_000_000
// Amount bridging multiplier
const amount_multiplier = 5; // +5% topup
// How much needs to be topped up
- const amount_to_topup = (amount_to_send - usdc_funds_on_optimism) * (100 + amount_multiplier) / 100;
+ const amount_to_topup = Math.round((amount_to_send - usdc_funds_on_optimism) * (100 + amount_multiplier) / 100);
// Default gas esimation is default with 6x increase
const gas_estimate = "0xf9e82";
const receiver_address = "0x739ff389c8eBd9339E69611d46Eec6212179BB67";
const chain_id_optimism = "eip155:10";
- const chain_id_base = "eip155:8453";
const usdc_contract_optimism = "0x0b2c639c533813f4aa9d7837caf62653d097ff85";
+ const chain_id_base = "eip155:8453";
+ const usdc_contract_base = "0x833589fcd6edb6e08f4c7c32d4f71b54bda02913";
let orchestration_id = "";
@@ -195,7 +197,7 @@ describe('Chain abstraction orchestrator', () => {
expect(approvalTransaction.nonce).not.toBe("0x00")
expect(approvalTransaction.gas).toBe(gas_estimate)
const decodedData = erc20Interface.decodeFunctionData('approve', approvalTransaction.data);
- expect(decodedData.amount.toString()).toBe(amount_to_topup.toString().split('.')[0])
+ expect(decodedData.amount.toString()).toBe(amount_to_topup.toString())
// Second transaction expected to be the bridging to the Base
const bridgingTransaction = data.transactions[1]
@@ -207,6 +209,12 @@ describe('Chain abstraction orchestrator', () => {
const initialTransaction = data.transactions[2]
expect(initialTransaction.data).toBe(transactionObj.transaction.data)
+ // Check the metadata fundingFrom
+ const fundingFrom = data.metadata.fundingFrom[0]
+ expect(fundingFrom.chainId).toBe(chain_id_base)
+ expect(fundingFrom.symbol).toBe(usdc_token_symbol)
+ expect(fundingFrom.tokenContract).toBe(usdc_contract_base)
+ expect(fundingFrom.amount).toBe("0x" + amount_to_topup.toString(16))
// Set the Orchestration ID for the next test
orchestration_id = data.orchestrationId;
})
diff --git a/src/handlers/chain_agnostic/check.rs b/src/handlers/chain_agnostic/check.rs
index d90a8174..fb905557 100644
--- a/src/handlers/chain_agnostic/check.rs
+++ b/src/handlers/chain_agnostic/check.rs
@@ -145,7 +145,7 @@ async fn handler_internal(
+ (erc20_topup_value * U256::from(BRIDGING_AMOUNT_MULTIPLIER)) / U256::from(100);
// Check for possible bridging by iterating over supported assets
- if let Some((bridge_chain_id, bridge_contract)) =
+ if let Some((bridge_chain_id, _, bridge_contract)) =
check_bridging_for_erc20_transfer(query_params.project_id, erc20_topup_value, from_address)
.await?
{
diff --git a/src/handlers/chain_agnostic/mod.rs b/src/handlers/chain_agnostic/mod.rs
index a7c7fbbf..6821556c 100644
--- a/src/handlers/chain_agnostic/mod.rs
+++ b/src/handlers/chain_agnostic/mod.rs
@@ -71,23 +71,25 @@ pub async fn check_erc20_balances(
Ok(balances)
}
+/// Check available assets for bridging and return
+/// the chain_id, token symbol and contract_address
pub async fn check_bridging_for_erc20_transfer(
rpc_project_id: String,
value: U256,
sender: Address,
-) -> Result