Skip to content

Commit 5781b33

Browse files
KorbinianKdantaik
andauthored
fix(bridge-ui): lock continue button when fee is calculating (#17548)
Co-authored-by: Daniel Wang <[email protected]>
1 parent 98beab8 commit 5781b33

File tree

6 files changed

+17
-21
lines changed

6 files changed

+17
-21
lines changed

packages/bridge-ui/src/components/Bridge/FungibleBridgeComponents/StepNavigation/StepNavigation.svelte

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<script lang="ts">
22
import { t } from 'svelte-i18n';
33
4-
import { importDone } from '$components/Bridge/state';
4+
import { calculatingProcessingFee, importDone } from '$components/Bridge/state';
55
import { BridgeSteps, BridgingStatus } from '$components/Bridge/types';
66
import { ActionButton } from '$components/Button';
77
import { Icon } from '$components/Icon';
@@ -66,7 +66,7 @@
6666
manuallyConfirmedRecipientStep = false;
6767
};
6868
69-
$: disabled = !$account || !$account.isConnected;
69+
$: disabled = !$account || !$account.isConnected || $calculatingProcessingFee;
7070
7171
$: nextStepButtonText = getStepText();
7272

packages/bridge-ui/src/components/Bridge/NFTBridgeComponents/StepNavigation/StepNavigation.svelte

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<script lang="ts">
22
import { t } from 'svelte-i18n';
33
4-
import { importDone } from '$components/Bridge/state';
4+
import { calculatingProcessingFee, importDone } from '$components/Bridge/state';
55
import { BridgeSteps, BridgingStatus, ImportMethod } from '$components/Bridge/types';
66
import { ActionButton } from '$components/Button';
77
import { StepBack } from '$components/Stepper';
@@ -69,7 +69,7 @@
6969
{/if}
7070
{/if}
7171
{#if activeStep === BridgeSteps.REVIEW}
72-
<ActionButton priority="primary" on:click={() => handleNextStep()}>
72+
<ActionButton priority="primary" disabled={$calculatingProcessingFee} on:click={() => handleNextStep()}>
7373
<span class="body-bold">{nextStepButtonText}</span>
7474
</ActionButton>
7575

packages/bridge-ui/src/components/Bridge/SharedBridgeComponents/ProcessingFee/ProcessingFee.svelte

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
66
import Alert from '$components/Alert/Alert.svelte';
77
import FlatAlert from '$components/Alert/FlatAlert.svelte';
8-
import { gasLimitZero, processingFee, processingFeeMethod } from '$components/Bridge/state';
8+
import { calculatingProcessingFee, gasLimitZero, processingFee, processingFeeMethod } from '$components/Bridge/state';
99
import { ActionButton, CloseButton } from '$components/Button';
1010
import { InputBox } from '$components/InputBox';
1111
import { LoadingText } from '$components/LoadingText';
@@ -26,7 +26,6 @@
2626
let dialogId = `dialog-${uid()}`;
2727
2828
let recommendedAmount = BigInt(0);
29-
let calculatingRecommendedAmount = false;
3029
let errorCalculatingRecommendedAmount = false;
3130
3231
let calculatingEnoughEth = false;
@@ -161,7 +160,7 @@
161160
<div class="f-between-center">
162161
<span class="text-secondary-content">{$t('processing_fee.title')}</span>
163162
<span class=" text-primary-content mt-[4px]">
164-
{#if calculatingRecommendedAmount}
163+
{#if $calculatingProcessingFee}
165164
<LoadingText mask="0.0017730224073" /> ETH
166165
{:else if errorCalculatingRecommendedAmount && $processingFeeMethod === ProcessingFeeMethod.RECOMMENDED}
167166
<FlatAlert type="warning" message={$t('processing_fee.recommended.error')} />
@@ -175,7 +174,7 @@
175174
</div>
176175
{:else if textOnly}
177176
<span class="text-primary-content mt-[4px] {$$props.class}">
178-
{#if calculatingRecommendedAmount}
177+
{#if $calculatingProcessingFee}
179178
<LoadingText mask="0.0017730224073" />
180179
{:else if errorCalculatingRecommendedAmount && $processingFeeMethod === ProcessingFeeMethod.RECOMMENDED}
181180
<span class="text-warning-sentiment">{$t('processing_fee.recommended.error')}</span>
@@ -201,7 +200,7 @@
201200
</div>
202201

203202
<span class="body-small-regular text-secondary-content mt-[4px]">
204-
{#if calculatingRecommendedAmount}
203+
{#if $calculatingProcessingFee}
205204
<LoadingText mask="0.0001" /> ETH
206205
{:else if errorCalculatingRecommendedAmount && $processingFeeMethod === ProcessingFeeMethod.RECOMMENDED}
207206
<FlatAlert type="warning" message={$t('processing_fee.recommended.error')} />
@@ -234,7 +233,7 @@
234233
</label>
235234
<span class="body-small-regular text-secondary-content">
236235
<!-- TODO: think about the UI for this part. Talk to Jane -->
237-
{#if calculatingRecommendedAmount}
236+
{#if $calculatingProcessingFee}
238237
<LoadingText mask="0.0001" /> ETH
239238
{:else if errorCalculatingRecommendedAmount}
240239
<FlatAlert type="warning" message={$t('processing_fee.recommended.error')} />
@@ -383,10 +382,7 @@
383382
</div>
384383
{/if}
385384

386-
<RecommendedFee
387-
bind:amount={recommendedAmount}
388-
bind:calculating={calculatingRecommendedAmount}
389-
bind:error={errorCalculatingRecommendedAmount} />
385+
<RecommendedFee bind:amount={recommendedAmount} bind:error={errorCalculatingRecommendedAmount} />
390386

391387
<NoneOption
392388
bind:enoughEth={hasEnoughEth}

packages/bridge-ui/src/components/Bridge/SharedBridgeComponents/ProcessingFee/RecommendedFee.svelte

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
<script lang="ts">
22
import { onDestroy, onMount } from 'svelte';
33
4-
import { destNetwork, selectedToken } from '$components/Bridge/state';
4+
import { calculatingProcessingFee, destNetwork, selectedToken } from '$components/Bridge/state';
55
import { processingFeeComponent } from '$config';
66
import { recommendProcessingFee } from '$libs/fee';
77
import type { NFT, Token } from '$libs/token';
88
import { connectedSourceChain } from '$stores/network';
99
1010
export let amount: bigint;
11-
export let calculating = false;
1211
export let error = false;
1312
1413
let interval: ReturnType<typeof setInterval>;
@@ -17,7 +16,7 @@
1716
// Without token nor destination chain we cannot compute this fee
1817
if (!token || !destChainId) return;
1918
20-
calculating = true;
19+
$calculatingProcessingFee = true;
2120
error = false;
2221
2322
try {
@@ -30,7 +29,7 @@
3029
console.error(err);
3130
error = true;
3231
} finally {
33-
calculating = false;
32+
$calculatingProcessingFee = false;
3433
}
3534
}
3635

packages/bridge-ui/src/components/Bridge/state.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ export const bridging = writable<boolean>(false);
3535
export const approving = writable<boolean>(false);
3636
export const computingBalance = writable<boolean>(false);
3737
export const validatingAmount = writable<boolean>(false);
38+
export const calculatingProcessingFee = writable<boolean>(false);
3839

3940
// Errors state
4041
export const errorComputingBalance = writable<boolean>(false);

packages/bridge-ui/src/i18n/en.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
"nft_scan_again": "Scan again"
4040
},
4141
"alerts": {
42-
"not_enough_funds": "You do not have enough ETH to cover the processing fee and transaction fee",
42+
"not_enough_funds": "You do not have enough ETH to cover the processing fee and transaction fee. Please add more ETH to your wallet (>= 0.0015 ETH).",
4343
"slow_bridging": "Please note: Bridging to L1 will take around 24hrs!",
4444
"smart_contract_wallet": "It seems you are using a smart contract wallet. Please double check that the recipient matches your wallet on the destination or change it accordingly.",
4545
"stable_coin": "You are bridging a stable coin. For USDC, we are currently partnering with <a target=\"_blank\" href=\"https://stargate.finance/transfer\" class=\"link\">Stargate Bridge</a> for liquidity. Consider using their bridge, as the ecosystem partners are likely using their bridged version",
@@ -291,7 +291,7 @@
291291
},
292292
"title": "Faucet",
293293
"warning": {
294-
"insufficient_balance": "You don't have enough ETH to complete the transaction. Please add some ETH to your wallet.",
294+
"insufficient_balance": "You don't have enough ETH to complete the transaction. Please add more ETH to your wallet (>= 0.0015 ETH)",
295295
"no_connected": "Please connect your wallet to mint tokens.",
296296
"not_mintable": "This token is not mintable on this network. Please switch to the correct network.",
297297
"token_minted": "You have already minted this token.",
@@ -503,7 +503,7 @@
503503
"title": "What is \"Connected to the correct chain\"?"
504504
},
505505
"funds": {
506-
"description": "In order to claim the transaction yourself, you need enough funds on the destination chain. If you've kept the default processing fee, the relayer will likely claim for you soon.",
506+
"description": "In order to claim the transaction yourself, you need enough funds on the destination chain (>= 0.0015 ETH). If you've kept the default processing fee, the relayer will likely claim for you soon.",
507507
"title": "What is \"Sufficient funds to claim\"?"
508508
},
509509
"quota": {

0 commit comments

Comments
 (0)