Skip to content

Commit d5af41a

Browse files
committed
feat: disable weth deposit and reformat the error message
1 parent 702da9f commit d5af41a

5 files changed

Lines changed: 71 additions & 6 deletions

File tree

components/common/ErrorBlock.vue

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,23 @@
11
<template>
22
<div class="error-block-container">
33
<FaceFrownIcon class="error-block-icon" aria-hidden="true" />
4-
<div class="error-block-text-container">
4+
<div :class="showCopyButton ? 'hidden' : 'error-block-text-container'">
55
<slot>Unexpected error</slot>
66
</div>
7-
<CommonButton v-if="retryButton" class="ml-3" variant="error" @click="emit('try-again')">Try again</CommonButton>
7+
<p :class="showCopyButton ? 'error-block-text-container' : 'hidden'">
8+
Transaction failed. Please try again or copy the details of the error text.
9+
</p>
10+
<span class="flex flex-col items-end justify-center gap-2">
11+
<CommonButton v-if="retryButton" class="ml-3" variant="error" @click="emit('try-again')">Try again</CommonButton>
12+
<CommonButton
13+
v-if="showCopyButton"
14+
class="ml-3 text-sm"
15+
size="sm"
16+
variant="error"
17+
@click="emit('copy-message')"
18+
>{{ copied ? "Copied!" : "Copy error text" }}</CommonButton
19+
>
20+
</span>
821
</div>
922
</template>
1023

@@ -16,10 +29,19 @@ defineProps({
1629
type: Boolean,
1730
default: true,
1831
},
32+
showCopyButton: {
33+
type: Boolean,
34+
default: false,
35+
},
36+
copied: {
37+
type: Boolean,
38+
default: false,
39+
},
1940
});
2041
2142
const emit = defineEmits<{
2243
(eventName: "try-again"): void;
44+
(eventName: "copy-message"): void;
2345
}>();
2446
</script>
2547

composables/useCopy.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ export default (text: Ref<string>, copiedDuring = 1000) => {
1616

1717
const copied = computed(() => isCopied.value || tooltipShownViaLegacyCopy.value);
1818

19-
async function copy() {
19+
async function copy(altText?: string) {
2020
try {
21-
await clipboardCopy();
21+
await clipboardCopy(altText as string);
2222
} catch (error) {
2323
legacyCopy();
2424
showLegacyCopyTooltip();

utils/constants.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
11
export const L2_BASE_TOKEN_ADDRESS = "0x000000000000000000000000000000000000800A";
2+
3+
export const WETH_L1_ADDRESS = "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2";

views/transactions/Deposit.vue

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,14 @@
160160
<template
161161
v-if="(!tokenCustomBridge || !tokenCustomBridge?.bridgingDisabled) && (step === 'form' || step === 'confirm')"
162162
>
163-
<CommonErrorBlock v-if="feeError" class="mt-2" @try-again="estimate">
163+
<CommonErrorBlock
164+
v-if="feeError"
165+
class="mt-2"
166+
:show-copy-button="true"
167+
:copied="copied"
168+
@try-again="estimate"
169+
@copy-message="copyMessage(`Fee estimation error: ${feeError.message}`)"
170+
>
164171
Fee estimation error: {{ feeError.message }}
165172
</CommonErrorBlock>
166173
<div class="mt-4 flex items-center gap-4">
@@ -210,6 +217,19 @@
210217
<NuxtLink :to="{ name: 'receive-methods' }" class="alert-link">Receive funds</NuxtLink>
211218
</CommonAlert>
212219
</transition>
220+
<transition v-bind="TransitionAlertScaleInOutTransition" mode="out-in">
221+
<CommonAlert
222+
v-if="selectedToken?.address?.toUpperCase() === WETH_L1_ADDRESS.toUpperCase()"
223+
class="mt-4"
224+
variant="error"
225+
:icon="ExclamationTriangleIcon"
226+
>
227+
<p>
228+
Currently, the <span class="font-medium">{{ selectedToken?.symbol }}</span> token is
229+
<span class="font-medium">disabled</span> for deposit.
230+
</p>
231+
</CommonAlert>
232+
</transition>
213233
<CommonErrorBlock v-if="allowanceRequestError" class="mt-2" @try-again="requestAllowance">
214234
Checking allowance error: {{ allowanceRequestError.message }}
215235
</CommonErrorBlock>
@@ -389,13 +409,15 @@ import useFee from "@/composables/zksync/deposit/useFee";
389409
import useTransaction from "@/composables/zksync/deposit/useTransaction";
390410
import { customBridgeTokens } from "@/data/customBridgeTokens";
391411
import { isCustomNode } from "@/data/networks";
412+
import { WETH_L1_ADDRESS } from "@/utils/constants";
392413
import DepositSubmitted from "@/views/transactions/DepositSubmitted.vue";
393414
394415
import type { Token, TokenAmount } from "@/types";
395416
import type { BigNumberish } from "ethers";
396417
397418
const route = useRoute();
398419
const router = useRouter();
420+
const { copy, copied } = useCopy();
399421
400422
const onboardStore = useOnboardStore();
401423
const tokensStore = useZkSyncTokensStore();
@@ -411,6 +433,10 @@ const { balance, balanceInProgress, balanceError } = storeToRefs(zkSyncEthereumB
411433
412434
const { captureException } = useSentryLogger();
413435
436+
const copyMessage = async (text: string) => {
437+
await copy(text);
438+
};
439+
414440
const toNetworkModalOpened = ref(false);
415441
const toNetworkSelected = (networkKey?: string) => {
416442
if (destinations.value.ethereum.key === networkKey) {
@@ -646,6 +672,9 @@ watch(
646672
);
647673
648674
const continueButtonDisabled = computed(() => {
675+
if (selectedToken.value?.address?.toUpperCase() === WETH_L1_ADDRESS.toUpperCase()) {
676+
return true;
677+
}
649678
if (
650679
!transaction.value ||
651680
!enoughBalanceToCoverFee.value ||

views/transactions/Transfer.vue

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,14 @@
191191
</template>
192192

193193
<template v-if="!tokenCustomBridge && (step === 'form' || step === 'confirm')">
194-
<CommonErrorBlock v-if="feeError" class="mt-2" @try-again="estimate">
194+
<CommonErrorBlock
195+
v-if="feeError"
196+
class="mt-2"
197+
:show-copy-button="true"
198+
:copied="copied"
199+
@try-again="estimate"
200+
@copy-message="copyMessage(`Fee estimation error: ${feeError.message}`)"
201+
>
195202
Fee estimation error: {{ feeError.message }}
196203
</CommonErrorBlock>
197204
<div class="mt-4 flex items-center gap-4">
@@ -304,6 +311,7 @@ const props = defineProps({
304311
305312
const route = useRoute();
306313
const router = useRouter();
314+
const { copy, copied } = useCopy();
307315
308316
const onboardStore = useOnboardStore();
309317
const walletStore = useZkSyncWalletStore();
@@ -315,6 +323,10 @@ const { destinations } = storeToRefs(useDestinationsStore());
315323
const { tokens, tokensRequestInProgress, tokensRequestError } = storeToRefs(tokensStore);
316324
const { balance, balanceInProgress, balanceError } = storeToRefs(walletStore);
317325
326+
const copyMessage = async (text: string) => {
327+
await copy(text);
328+
};
329+
318330
const { captureException } = useSentryLogger();
319331
320332
const toNetworkModalOpened = ref(false);

0 commit comments

Comments
 (0)