Skip to content

Commit

Permalink
fix(bridge-ui): fix relayer (#13548)
Browse files Browse the repository at this point in the history
  • Loading branch information
cyberhorsey authored Apr 6, 2023
1 parent 728b8ad commit 5f60fd7
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 21 deletions.
9 changes: 1 addition & 8 deletions packages/bridge-ui/src/App.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@
const apiTxs = await $relayerApi.getAllBridgeTransactionByAddress(
userAddress,
);
const blockInfoMap = await $relayerApi.getBlockInfo();
relayerBlockInfoMap.set(blockInfoMap);
Expand All @@ -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]);
Expand Down
2 changes: 1 addition & 1 deletion packages/bridge-ui/src/components/ChainDropdown.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
</tr>
</thead>
<tbody class="text-sm md:text-base">
{#each $transactions as transaction}
{#each $transactions as transaction (transaction.hash)}
<Transaction
on:claimNotice={({ detail }) => noticeModal.open(detail)}
on:tooltipStatus={() => (showMessageStatusTooltip = true)}
Expand Down
5 changes: 4 additions & 1 deletion packages/bridge-ui/src/components/form/SelectChain.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
8 changes: 4 additions & 4 deletions packages/bridge-ui/src/domain/relayerApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
Expand Down
23 changes: 19 additions & 4 deletions packages/bridge-ui/src/relayer-api/RelayerAPIService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 === '') {
Expand Down Expand Up @@ -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,
},
};
Expand Down
5 changes: 4 additions & 1 deletion packages/bridge-ui/src/utils/switchChainAndSetSigner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion packages/starter-dapp/src/components/ChainDropdown.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 5f60fd7

Please sign in to comment.