From 5f60fd711c71ead82c7c147b4ff8dd12eab02c43 Mon Sep 17 00:00:00 2001
From: jeff <113397187+cyberhorsey@users.noreply.github.com>
Date: Wed, 5 Apr 2023 17:50:50 -0700
Subject: [PATCH] fix(bridge-ui): fix relayer (#13548)
---
packages/bridge-ui/src/App.svelte | 9 +-------
.../src/components/ChainDropdown.svelte | 2 +-
.../Transactions/Transactions.svelte | 2 +-
.../src/components/form/SelectChain.svelte | 5 +++-
packages/bridge-ui/src/domain/relayerApi.ts | 8 +++----
.../src/relayer-api/RelayerAPIService.ts | 23 +++++++++++++++----
.../src/utils/switchChainAndSetSigner.ts | 5 +++-
.../src/components/ChainDropdown.svelte | 2 +-
8 files changed, 35 insertions(+), 21 deletions(-)
diff --git a/packages/bridge-ui/src/App.svelte b/packages/bridge-ui/src/App.svelte
index cfa1d1e26cd..c09373440af 100644
--- a/packages/bridge-ui/src/App.svelte
+++ b/packages/bridge-ui/src/App.svelte
@@ -96,6 +96,7 @@
const apiTxs = await $relayerApi.getAllBridgeTransactionByAddress(
userAddress,
);
+
const blockInfoMap = await $relayerApi.getBlockInfo();
relayerBlockInfoMap.set(blockInfoMap);
@@ -110,14 +111,6 @@
return !hashToApiTxsMap.has(tx.hash.toLowerCase());
});
- // const updatedStorageTxs: BridgeTransaction[] = txs.filter((tx) => {
- // const blockInfo = blockInfoMap.get(tx.fromChainId);
- // if (blockInfo?.latestProcessedBlock >= tx.receipt?.blockNumber) {
- // return false;
- // }
- // return true;
- // });
-
$transactioner.updateStorageByAddress(userAddress, updatedStorageTxs);
transactions.set([...updatedStorageTxs, ...apiTxs]);
diff --git a/packages/bridge-ui/src/components/ChainDropdown.svelte b/packages/bridge-ui/src/components/ChainDropdown.svelte
index 453e62a6421..0dc68cbaa35 100644
--- a/packages/bridge-ui/src/components/ChainDropdown.svelte
+++ b/packages/bridge-ui/src/components/ChainDropdown.svelte
@@ -11,7 +11,7 @@
await switchNetwork({
chainId: chain.id,
});
- const provider = new ethers.providers.Web3Provider(window.ethereum);
+ const provider = new ethers.providers.Web3Provider(window.ethereum, 'any');
await provider.send('eth_requestAccounts', []);
fromChain.set(chain);
diff --git a/packages/bridge-ui/src/components/Transactions/Transactions.svelte b/packages/bridge-ui/src/components/Transactions/Transactions.svelte
index f25e4d8d5aa..730c1d2b236 100644
--- a/packages/bridge-ui/src/components/Transactions/Transactions.svelte
+++ b/packages/bridge-ui/src/components/Transactions/Transactions.svelte
@@ -26,7 +26,7 @@
- {#each $transactions as transaction}
+ {#each $transactions as transaction (transaction.hash)}
noticeModal.open(detail)}
on:tooltipStatus={() => (showMessageStatusTooltip = true)}
diff --git a/packages/bridge-ui/src/components/form/SelectChain.svelte b/packages/bridge-ui/src/components/form/SelectChain.svelte
index bb6457ed690..ac7e45648b9 100644
--- a/packages/bridge-ui/src/components/form/SelectChain.svelte
+++ b/packages/bridge-ui/src/components/form/SelectChain.svelte
@@ -13,7 +13,10 @@
await switchNetwork({
chainId: chain.id,
});
- const provider = new ethers.providers.Web3Provider(window.ethereum);
+ const provider = new ethers.providers.Web3Provider(
+ window.ethereum,
+ 'any',
+ );
await provider.send('eth_requestAccounts', []);
fromChain.set(chain);
diff --git a/packages/bridge-ui/src/domain/relayerApi.ts b/packages/bridge-ui/src/domain/relayerApi.ts
index a7e64c35f00..8aa59975dc5 100644
--- a/packages/bridge-ui/src/domain/relayerApi.ts
+++ b/packages/bridge-ui/src/domain/relayerApi.ts
@@ -19,10 +19,10 @@ export type TransactionData = {
Memo: string;
Owner: Address;
Sender: Address;
- GasLimit: number;
- CallValue: number;
- DepositValue: number;
- ProcessingFee: number;
+ GasLimit: string;
+ CallValue: string;
+ DepositValue: string;
+ ProcessingFee: string;
RefundAddress: Address;
Data: string;
};
diff --git a/packages/bridge-ui/src/relayer-api/RelayerAPIService.ts b/packages/bridge-ui/src/relayer-api/RelayerAPIService.ts
index 0acbe50135c..e09811633dd 100644
--- a/packages/bridge-ui/src/relayer-api/RelayerAPIService.ts
+++ b/packages/bridge-ui/src/relayer-api/RelayerAPIService.ts
@@ -64,6 +64,17 @@ export class RelayerAPIService implements RelayerAPI {
return [];
}
+ apiTxs.items.map((t, i) => {
+ apiTxs.items.map((tx, j) => {
+ if (
+ tx.data.Raw.transactionHash === t.data.Raw.transactionHash &&
+ i !== j
+ ) {
+ apiTxs.items = apiTxs.items.filter((_, index) => index !== j);
+ }
+ });
+ });
+
const txs = apiTxs.items.map((tx: APIResponseTransaction) => {
let data = tx.data.Message.Data;
if (data === '') {
@@ -93,12 +104,16 @@ export class RelayerAPIService implements RelayerAPI {
memo: tx.data.Message.Memo,
owner: tx.data.Message.Owner,
sender: tx.data.Message.Sender,
- gasLimit: BigNumber.from(tx.data.Message.GasLimit),
- callValue: BigNumber.from(tx.data.Message.CallValue),
+ gasLimit: BigNumber.from(tx.data.Message.GasLimit.toString()),
+ callValue: BigNumber.from(tx.data.Message.CallValue.toString()),
srcChainId: tx.data.Message.SrcChainId,
destChainId: tx.data.Message.DestChainId,
- depositValue: BigNumber.from(`${tx.data.Message.DepositValue}`),
- processingFee: BigNumber.from(`${tx.data.Message.ProcessingFee}`),
+ depositValue: BigNumber.from(
+ `${tx.data.Message.DepositValue.toString()}`,
+ ),
+ processingFee: BigNumber.from(
+ `${tx.data.Message.ProcessingFee.toString()}`,
+ ),
refundAddress: tx.data.Message.RefundAddress,
},
};
diff --git a/packages/bridge-ui/src/utils/switchChainAndSetSigner.ts b/packages/bridge-ui/src/utils/switchChainAndSetSigner.ts
index 11ec1490706..09d87cdc5b7 100644
--- a/packages/bridge-ui/src/utils/switchChainAndSetSigner.ts
+++ b/packages/bridge-ui/src/utils/switchChainAndSetSigner.ts
@@ -10,7 +10,10 @@ export async function switchChainAndSetSigner(chain: Chain) {
await switchNetwork({ chainId });
- const provider = new ethers.providers.Web3Provider(globalThis.ethereum);
+ const provider = new ethers.providers.Web3Provider(
+ globalThis.ethereum,
+ 'any',
+ );
await provider.send('eth_requestAccounts', []);
fromChain.set(chain);
diff --git a/packages/starter-dapp/src/components/ChainDropdown.svelte b/packages/starter-dapp/src/components/ChainDropdown.svelte
index 3ae52d30e91..74219d1345b 100644
--- a/packages/starter-dapp/src/components/ChainDropdown.svelte
+++ b/packages/starter-dapp/src/components/ChainDropdown.svelte
@@ -11,7 +11,7 @@
await switchNetwork({
chainId: chain.id,
});
- const provider = new ethers.providers.Web3Provider(window.ethereum);
+ const provider = new ethers.providers.Web3Provider(window.ethereum, "any");
await provider.send("eth_requestAccounts", []);
fromChain.set(chain);