Skip to content

Commit c3f9dc6

Browse files
committed
remove redundant uuid generation
1 parent df9b7fc commit c3f9dc6

File tree

24 files changed

+49
-60
lines changed

24 files changed

+49
-60
lines changed

packages/bridge-ui/src/components/Bridge/FungibleBridgeComponents/ImportStep/TokenInput/TokenInput.svelte

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434
import { debounce } from '$libs/util/debounce';
3535
import { getLogger } from '$libs/util/logger';
3636
import { truncateDecimal } from '$libs/util/truncateDecimal';
37-
import { uid } from '$libs/util/uid';
3837
import { account } from '$stores/account';
3938
import { ethBalance } from '$stores/balance';
4039
import { connectedSourceChain } from '$stores/network';
@@ -46,7 +45,7 @@
4645
export let hasEnoughEth: boolean = false;
4746
export let exceedsQuota: boolean = false;
4847
49-
let inputId = `input-${uid()}`;
48+
let inputId = `input-${crypto.randomUUID()}`;
5049
let inputBox: InputBox;
5150
5251
let value = '';

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

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,19 @@
66
import { chainConfig } from '$chainConfig';
77
import { Alert } from '$components/Alert';
88
import { ProcessingFee, Recipient } from '$components/Bridge/SharedBridgeComponents';
9-
import { destNetwork as destChain, enteredAmount, processingFee, selectedToken } from '$components/Bridge/state';
9+
import DestOwner from '$components/Bridge/SharedBridgeComponents/RecipientStep/DestOwner.svelte';
10+
import {
11+
destNetwork as destChain,
12+
destOwnerAddress,
13+
enteredAmount,
14+
processingFee,
15+
selectedToken,
16+
} from '$components/Bridge/state';
1017
import { PUBLIC_SLOW_L1_BRIDGING_WARNING } from '$env/static/public';
1118
import { LayerType } from '$libs/chain';
1219
import { isStablecoin, isSupported, isWrapped, type Token, TokenType } from '$libs/token';
1320
import { isToken } from '$libs/token/isToken';
21+
import { account } from '$stores/account';
1422
import { ethBalance } from '$stores/balance';
1523
import { connectedSourceChain } from '$stores/network';
1624
@@ -19,6 +27,7 @@
1927
export let hasEnoughFundsToContinue: boolean = true;
2028
2129
let recipientComponent: Recipient;
30+
let destOwnerComponent: DestOwner;
2231
let processingFeeComponent: ProcessingFee;
2332
let slowL1Warning = PUBLIC_SLOW_L1_BRIDGING_WARNING || false;
2433
@@ -106,6 +115,9 @@ Recipient & Processing Fee
106115
<button class="flex justify-start link" on:click={editTransactionDetails}> {$t('common.edit')} </button>
107116
</div>
108117
<Recipient bind:this={recipientComponent} small />
118+
{#if $destOwnerAddress !== $account?.address && $destOwnerAddress}
119+
<DestOwner bind:this={destOwnerComponent} small />
120+
{/if}
109121
<ProcessingFee bind:this={processingFeeComponent} small bind:hasEnoughEth />
110122
</div>
111123

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
55
import { Icon } from '$components/Icon';
66
import InputBox from '$components/InputBox/InputBox.svelte';
7-
import { uid } from '$libs/util/uid';
87
98
import { IDInputState as State } from './state';
109
@@ -24,7 +23,7 @@
2423
2524
const dispatch = createEventDispatcher();
2625
27-
let inputId = `input-${uid()}`;
26+
let inputId = `input-${crypto.randomUUID()}`;
2827
2928
function validateInput(idInput: EventTarget | number[] | null = null) {
3029
state = State.VALIDATING;

packages/bridge-ui/src/components/Bridge/NFTBridgeComponents/ImportStep/TokenAmountInput.svelte

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
import { ETHToken, fetchBalance, fetchBalance as getTokenBalance, TokenType } from '$libs/token';
1111
import { debounce } from '$libs/util/debounce';
1212
import { getLogger } from '$libs/util/logger';
13-
import { uid } from '$libs/util/uid';
1413
import { account } from '$stores/account';
1514
import { ethBalance } from '$stores/balance';
1615
import { connectedSourceChain } from '$stores/network';
@@ -30,7 +29,7 @@
3029
3130
const log = getLogger('component:Amount');
3231
33-
let inputId = `input-${uid()}`;
32+
let inputId = `input-${crypto.randomUUID()}`;
3433
let inputBox: InputBox;
3534
let computingMaxAmount = false;
3635
let invalidInput = false;

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

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@
88
import { Icon } from '$components/Icon';
99
import { withHoverAndFocusListener } from '$libs/customActions';
1010
import { classNames } from '$libs/util/classNames';
11-
import { uid } from '$libs/util/uid';
11+
import { account } from '$stores/account';
1212
1313
import { AddressInputState as State } from './state';
1414
1515
let inputElement: HTMLInputElement;
16-
let inputId = `input-${uid()}`;
16+
let inputId = `input-${crypto.randomUUID()}`;
1717
let isElementFocused = false;
1818
let isElementHovered = false;
1919
@@ -26,6 +26,7 @@
2626
export let isDisabled = false;
2727
export let quiet = false;
2828
export let state: State = State.DEFAULT;
29+
export let resettable = false;
2930
3031
export let onDialog = false;
3132
@@ -52,7 +53,12 @@
5253
if (inputElement) inputElement.value = '';
5354
ethereumAddress = '';
5455
state = State.DEFAULT;
55-
// dispatch('clearInput');
56+
};
57+
58+
const setToCurrentAddress = (): void => {
59+
clearAddress();
60+
ethereumAddress = $account?.address || '';
61+
validateAddress();
5662
};
5763
5864
export const focus = (): void => inputElement.focus();
@@ -79,6 +85,9 @@
7985
<!-- Input field and label -->
8086
<div class="f-between-center text-secondary-content">
8187
<label class="body-regular" for={inputId}>{labelText}</label>
88+
{#if resettable}
89+
<button class="link" on:click={setToCurrentAddress}>{$t('common.reset_to_wallet')}</button>
90+
{/if}
8291
</div>
8392
<div class="relative f-items-center">
8493
<input

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
import { closeOnEscapeOrOutsideClick } from '$libs/customActions';
1414
import { ProcessingFeeMethod } from '$libs/fee';
1515
import { parseToWei } from '$libs/util/parseToWei';
16-
import { uid } from '$libs/util/uid';
1716
1817
import NoneOption from './NoneOption.svelte';
1918
import RecommendedFee from './RecommendedFee.svelte';
@@ -23,7 +22,7 @@
2322
export let hasEnoughEth: boolean = false;
2423
export let disabled = false;
2524
26-
let dialogId = `dialog-${uid()}`;
25+
let dialogId = `dialog-${crypto.randomUUID()}`;
2726
2827
let recommendedAmount = BigInt(0);
2928
let errorCalculatingRecommendedAmount = false;

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@
44
import { Alert } from '$components/Alert';
55
import { ProcessingFee, Recipient } from '$components/Bridge/SharedBridgeComponents';
66
7+
import DestOwner from './DestOwner.svelte';
8+
79
let recipientComponent: Recipient;
10+
let destOwnerComponent: DestOwner;
811
let processingFeeComponent: ProcessingFee;
912
1013
export let hasEnoughEth: boolean = false;
@@ -18,6 +21,7 @@
1821

1922
<div class="mt-[30px] space-y-[16px]">
2023
<Recipient bind:this={recipientComponent} />
24+
<DestOwner bind:this={destOwnerComponent} />
2125
<ProcessingFee bind:this={processingFeeComponent} bind:hasEnoughEth />
2226
</div>
2327
<div class="h-sep my-[30px]" />

packages/bridge-ui/src/components/ChainSelectors/ChainPill/ChainPill.svelte

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
import { DesktopOrLarger } from '$components/DesktopOrLarger';
99
import { classNames } from '$libs/util/classNames';
1010
import { truncateString } from '$libs/util/truncateString';
11-
import { uid } from '$libs/util/uid';
1211
import { account } from '$stores';
1312
1413
export let value: Maybe<Chain> | null = null;
@@ -26,8 +25,8 @@
2625
2726
let iconSize = 'min-w-5 max-w-5 min-h-5 max-h-5';
2827
29-
let buttonId = `button-${uid()}`;
30-
let dialogId = `dialog-${uid()}`;
28+
let buttonId = `button-${crypto.randomUUID()}`;
29+
let dialogId = `dialog-${crypto.randomUUID()}`;
3130
let modalOpen = false;
3231
3332
const handlePillClick = () => {

packages/bridge-ui/src/components/ChainSelectors/SelectorDialogs/ChainsDialog.svelte

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,14 @@
99
import { ActionButton } from '$components/Button';
1010
import { chains } from '$libs/chain';
1111
import { closeOnEscapeOrOutsideClick } from '$libs/customActions';
12-
import { uid } from '$libs/util/uid';
1312
import { connectedSourceChain } from '$stores/network';
1413
1514
export let isOpen = false;
1615
export let value: Maybe<Chain> = null;
1716
export let switchWallet = false;
1817
1918
let modalOpen = false;
20-
const dialogId = `dialog-${uid()}`;
19+
const dialogId = `dialog-${crypto.randomUUID()}`;
2120
2221
const dispatch = createEventDispatcher();
2322

packages/bridge-ui/src/components/Dialogs/ClaimDialog/ClaimDialog.svelte

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
} from '$libs/error';
2525
import type { NFT } from '$libs/token';
2626
import { getLogger } from '$libs/util/logger';
27-
import { uid } from '$libs/util/uid';
2827
import { connectedSourceChain } from '$stores/network';
2928
import { pendingTransactions } from '$stores/pendingTransactions';
3029
@@ -37,7 +36,7 @@
3736
3837
const log = getLogger('ClaimDialog');
3938
40-
const dialogId = `dialog-${uid()}`;
39+
const dialogId = `dialog-${crypto.randomUUID()}`;
4140
const dispatch = createEventDispatcher();
4241
4342
export let dialogOpen = false;

0 commit comments

Comments
 (0)