|
| 1 | +<template> |
| 2 | + <CommonCardWithLineButtons class="mt-4"> |
| 3 | + <DestinationItem |
| 4 | + v-if="enoughAllowance && setAllowanceReceipts?.length" |
| 5 | + as="div" |
| 6 | + :description="`You can now proceed to deposit`" |
| 7 | + > |
| 8 | + <template #label> |
| 9 | + {{ selectedToken?.symbol }} allowance approved |
| 10 | + <template v-for="allowanceReceipt in setAllowanceReceipts" :key="allowanceReceipt.transactionHash"> |
| 11 | + <a |
| 12 | + v-if="blockExplorerUrl" |
| 13 | + :href="`${blockExplorerUrl}/tx/${allowanceReceipt.transactionHash}`" |
| 14 | + target="_blank" |
| 15 | + class="inline-flex items-center gap-1 underline underline-offset-2" |
| 16 | + > |
| 17 | + View on Explorer |
| 18 | + <ArrowTopRightOnSquareIcon class="h-6 w-6" aria-hidden="true" /> |
| 19 | + </a> |
| 20 | + </template> |
| 21 | + </template> |
| 22 | + <template #image> |
| 23 | + <div class="aspect-square h-full w-full rounded-full bg-success-400 p-3 text-black"> |
| 24 | + <CheckIcon aria-hidden="true" /> |
| 25 | + </div> |
| 26 | + </template> |
| 27 | + </DestinationItem> |
| 28 | + <DestinationItem v-else as="div"> |
| 29 | + <template #label> |
| 30 | + Approve {{ selectedToken?.symbol }} allowance |
| 31 | + <template v-for="allowanceTransactionHash in setAllowanceTransactionHashes" :key="allowanceTransactionHash"> |
| 32 | + <a |
| 33 | + v-if="blockExplorerUrl && allowanceTransactionHash" |
| 34 | + :href="`${blockExplorerUrl}/tx/${allowanceTransactionHash}`" |
| 35 | + target="_blank" |
| 36 | + class="inline-flex items-center gap-1 underline underline-offset-2" |
| 37 | + > |
| 38 | + View on Explorer |
| 39 | + <ArrowTopRightOnSquareIcon class="h-6 w-6" aria-hidden="true" /> |
| 40 | + </a> |
| 41 | + </template> |
| 42 | + </template> |
| 43 | + <template #underline> |
| 44 | + Before depositing you need to give our bridge permission to spend specified amount of |
| 45 | + {{ selectedToken?.symbol }}. |
| 46 | + <span v-if="allowance && allowance !== 0n" |
| 47 | + >You can deposit up to |
| 48 | + <CommonButtonLabel variant="light" @click="setAmountToCurrentAllowance()"> |
| 49 | + {{ parseTokenAmount(allowance!, selectedToken!.decimals) }} |
| 50 | + </CommonButtonLabel> |
| 51 | + {{ selectedToken!.symbol }} without approving a new allowance. |
| 52 | + </span> |
| 53 | + <CommonButtonLabel variant="light" as="a" :href="TOKEN_ALLOWANCE" target="_blank"> |
| 54 | + Learn more |
| 55 | + </CommonButtonLabel> |
| 56 | + </template> |
| 57 | + <template #image> |
| 58 | + <div class="aspect-square h-full w-full rounded-full bg-warning-400 p-3 text-black"> |
| 59 | + <LockClosedIcon aria-hidden="true" /> |
| 60 | + </div> |
| 61 | + </template> |
| 62 | + </DestinationItem> |
| 63 | + </CommonCardWithLineButtons> |
| 64 | +</template> |
| 65 | + |
| 66 | +<script lang="ts" setup> |
| 67 | +import { LockClosedIcon, ArrowTopRightOnSquareIcon, CheckIcon } from "@heroicons/vue/24/outline"; |
| 68 | +
|
| 69 | +import type { Token } from "@/types"; |
| 70 | +import type { Hash } from "viem"; |
| 71 | +
|
| 72 | +const props = defineProps<{ |
| 73 | + tokenAddress: string; |
| 74 | + assetId: string; |
| 75 | + selectedToken: Token; |
| 76 | + enoughAllowance: boolean; |
| 77 | + blockExplorerUrl: string | undefined; |
| 78 | + allowance: bigint; |
| 79 | + setAllowanceReceipts: { transactionHash: Hash }[] | undefined; |
| 80 | + setAllowanceTransactionHashes: (Hash | undefined)[]; |
| 81 | +}>(); |
| 82 | +
|
| 83 | +const emit = defineEmits<{ |
| 84 | + (e: "setAmount", amount: bigint): void; |
| 85 | +}>(); |
| 86 | +
|
| 87 | +const setAmountToCurrentAllowance = () => { |
| 88 | + if (!props.allowance) { |
| 89 | + return; |
| 90 | + } |
| 91 | + emit("setAmount", props.allowance); |
| 92 | +}; |
| 93 | +</script> |
0 commit comments