From eb2faf7a6f585e3423c2ffc054d757d84cd72aca Mon Sep 17 00:00:00 2001
From: shadab-taiko <108871478+shadab-taiko@users.noreply.github.com>
Date: Mon, 20 Mar 2023 16:43:45 +0530
Subject: [PATCH] fix(bridge-ui): ui fixes (#13366)
---
packages/bridge-ui/src/App.svelte | 2 +-
packages/bridge-ui/src/bridge/ERC20Bridge.ts | 20 +++++++++++--
packages/bridge-ui/src/bridge/ETHBridge.ts | 20 +++++++++++--
.../InsufficientBalanceTooltip.svelte | 14 ++++++++++
.../src/components/Transaction.svelte | 28 ++++++++++++++-----
.../src/components/Transactions.svelte | 13 +++++++--
packages/bridge-ui/src/domain/message.ts | 1 +
7 files changed, 83 insertions(+), 15 deletions(-)
create mode 100644 packages/bridge-ui/src/components/InsufficientBalanceTooltip.svelte
diff --git a/packages/bridge-ui/src/App.svelte b/packages/bridge-ui/src/App.svelte
index a6e8fe64ca2..efcacff5f57 100644
--- a/packages/bridge-ui/src/App.svelte
+++ b/packages/bridge-ui/src/App.svelte
@@ -159,7 +159,7 @@
const updatedStorageTxs: BridgeTransaction[] = txs.filter((tx) => {
const blockInfo = blockInfoMap.get(tx.fromChainId);
- if (blockInfo?.latestProcessedBlock >= tx.receipt.blockNumber) {
+ if (blockInfo?.latestProcessedBlock >= tx.receipt?.blockNumber) {
return false;
}
return true;
diff --git a/packages/bridge-ui/src/bridge/ERC20Bridge.ts b/packages/bridge-ui/src/bridge/ERC20Bridge.ts
index 71bb863da77..309e8a541df 100644
--- a/packages/bridge-ui/src/bridge/ERC20Bridge.ts
+++ b/packages/bridge-ui/src/bridge/ERC20Bridge.ts
@@ -1,4 +1,4 @@
-import { BigNumber, Contract, Signer } from 'ethers';
+import { BigNumber, Contract, ethers, Signer } from 'ethers';
import type { Transaction } from 'ethers';
import type {
ApproveOpts,
@@ -190,7 +190,23 @@ export class ERC20Bridge implements Bridge {
});
}
- return await contract.processMessage(opts.message, proof);
+ let processMessageTx;
+ try {
+ processMessageTx = await contract.processMessage(opts.message, proof);
+ } catch (error) {
+ if (error.code === ethers.errors.UNPREDICTABLE_GAS_LIMIT) {
+ processMessageTx = await contract.processMessage(
+ opts.message,
+ proof,
+ {
+ gasLimit: 1e6,
+ },
+ );
+ } else {
+ throw new Error(error);
+ }
+ }
+ return processMessageTx;
} else {
return await contract.retryMessage(opts.message, false);
}
diff --git a/packages/bridge-ui/src/bridge/ETHBridge.ts b/packages/bridge-ui/src/bridge/ETHBridge.ts
index 5b3ea01f2ba..74d4610ab62 100644
--- a/packages/bridge-ui/src/bridge/ETHBridge.ts
+++ b/packages/bridge-ui/src/bridge/ETHBridge.ts
@@ -1,4 +1,4 @@
-import { BigNumber, Contract } from 'ethers';
+import { BigNumber, Contract, ethers } from 'ethers';
import type { Transaction } from 'ethers';
import type {
ApproveOpts,
@@ -133,7 +133,23 @@ export class ETHBridge implements Bridge {
};
const proof = await this.prover.GenerateProof(proofOpts);
- return await contract.processMessage(opts.message, proof);
+ let processMessageTx;
+ try {
+ processMessageTx = await contract.processMessage(opts.message, proof);
+ } catch (error) {
+ if (error.code === ethers.errors.UNPREDICTABLE_GAS_LIMIT) {
+ processMessageTx = await contract.processMessage(
+ opts.message,
+ proof,
+ {
+ gasLimit: 1e6,
+ },
+ );
+ } else {
+ throw new Error(error);
+ }
+ }
+ return processMessageTx;
} else {
return await contract.retryMessage(opts.message, true);
}
diff --git a/packages/bridge-ui/src/components/InsufficientBalanceTooltip.svelte b/packages/bridge-ui/src/components/InsufficientBalanceTooltip.svelte
new file mode 100644
index 00000000000..1f1bc82d949
--- /dev/null
+++ b/packages/bridge-ui/src/components/InsufficientBalanceTooltip.svelte
@@ -0,0 +1,14 @@
+
+
+