From 6173edb3dfe987cefd1f712cd23fbde0ff13877f Mon Sep 17 00:00:00 2001 From: Memo Khoury Date: Fri, 13 Dec 2024 14:10:45 +0000 Subject: [PATCH] update with gas fees --- webapps/world-builder-dashboard/constants.ts | 2 +- .../src/components/bridge/bridge/ActionButton.tsx | 14 +++++++++----- .../src/components/bridge/history/Withdrawal.tsx | 1 - 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/webapps/world-builder-dashboard/constants.ts b/webapps/world-builder-dashboard/constants.ts index 0c69ebee..bf217458 100644 --- a/webapps/world-builder-dashboard/constants.ts +++ b/webapps/world-builder-dashboard/constants.ts @@ -40,7 +40,7 @@ export const L3_NETWORK: HighNetworkInterface = { chainId: 13746, name: 'game7Testnet', displayName: 'G7 Sepolia', - rpcs: ['https://testnet-rpc.game7.io'], + rpcs: ['https://x.game7-testnet.nodes.game7.build'], blockExplorerUrls: ['https://testnet.game7.io'], nativeCurrency: { decimals: 18, diff --git a/webapps/world-builder-dashboard/src/components/bridge/bridge/ActionButton.tsx b/webapps/world-builder-dashboard/src/components/bridge/bridge/ActionButton.tsx index 65060d7d1..f502ae73 100644 --- a/webapps/world-builder-dashboard/src/components/bridge/bridge/ActionButton.tsx +++ b/webapps/world-builder-dashboard/src/components/bridge/bridge/ActionButton.tsx @@ -72,13 +72,14 @@ const ActionButton: React.FC = ({ const checkAllowances = async () => { if (!bridger || !connectedAccount) return null; - + console.log('check allowances start') if (amount === '0.01') { setStartingTokenIndex(0); setShowApproval(true); return false; } + console.log('allowancesVerified', allowancesVerified) if (allowancesVerified) { console.log('Allowances already verified, skipping check') return true @@ -88,7 +89,9 @@ const ActionButton: React.FC = ({ const amountBN = ethers.utils.parseUnits(amount, decimals) if (bridgeAllowance === null) { - const needsNativeTokenApproval = nativeAllowance !== null && nativeAllowance?.lt(amountBN) + console.log('bridgeAllowance is null') + const gasFeesAmount = gasFees?.[1] ? ethers.utils.parseUnits(gasFees[1], 18) : amountBN + const needsNativeTokenApproval = nativeAllowance !== null ? nativeAllowance?.lt(gasFeesAmount) : false if (needsNativeTokenApproval) { setStartingTokenIndex(0) setShowApproval(true) @@ -96,8 +99,9 @@ const ActionButton: React.FC = ({ } } else { const needsBridgeTokenApproval = bridgeAllowance?.lt(amountBN) - const needsNativeTokenApproval = nativeAllowance !== null && nativeAllowance?.lt(amountBN) - + const gasFeesAmount = gasFees?.[1] ? ethers.utils.parseUnits(gasFees[1], 18) : amountBN + const needsNativeTokenApproval = nativeAllowance !== null ? nativeAllowance?.lt(gasFeesAmount) : false + if (needsBridgeTokenApproval || needsNativeTokenApproval) { setStartingTokenIndex(needsBridgeTokenApproval ? 0 : 1) setShowApproval(true) @@ -271,7 +275,7 @@ const ActionButton: React.FC = ({ if (nativeAllowance === null && bridgeAllowance !== null) { return [selectedBridgeToken]; } - + if (nativeAllowance === null && bridgeAllowance === null) { return []; } diff --git a/webapps/world-builder-dashboard/src/components/bridge/history/Withdrawal.tsx b/webapps/world-builder-dashboard/src/components/bridge/history/Withdrawal.tsx index 9b00d858..dd893bbf 100644 --- a/webapps/world-builder-dashboard/src/components/bridge/history/Withdrawal.tsx +++ b/webapps/world-builder-dashboard/src/components/bridge/history/Withdrawal.tsx @@ -63,7 +63,6 @@ const Withdrawal: React.FC = ({ withdrawal }) => { const status = getStatus(withdrawal, lowNetworks, highNetworks) const { data: transferStatus, isLoading } = returnTransferData({ txRecord: withdrawal }) const { data: transactionInputs } = getTransactionInputs({ txRecord: withdrawal }) - console.log(transferStatus?.status !== ChildToParentMessageStatus.EXECUTED && withdrawal) return ( <> {status?.isLoading && smallView ? (