From 52fc0aa2883cb381aed696b7334c212185551660 Mon Sep 17 00:00:00 2001 From: lserra-iov Date: Mon, 4 Nov 2024 17:19:17 -0300 Subject: [PATCH] Show error msg when pegout is rejected --- src/common/store/constants.ts | 6 ++++++ src/common/types/store.ts | 3 ++- src/status/views/Status.vue | 19 +++++++++++++++++++ 3 files changed, 27 insertions(+), 1 deletion(-) diff --git a/src/common/store/constants.ts b/src/common/store/constants.ts index bf824c097..b52bd5d59 100644 --- a/src/common/store/constants.ts +++ b/src/common/store/constants.ts @@ -372,3 +372,9 @@ export enum FlyoverCallFunction { LPS = 'getLps', QUOTE = 'getQuote', } + +export enum RejectedPegoutReasons { + LOW_AMOUNT = 'LOW_AMOUNT', + CALLER_CONTRACT = 'CALLER_CONTRACT', + FEE_ABOVE_VALUE = 'FEE_ABOVE_VALUE', +} diff --git a/src/common/types/store.ts b/src/common/types/store.ts index fdf29bd3f..5a6f6f416 100644 --- a/src/common/types/store.ts +++ b/src/common/types/store.ts @@ -1,5 +1,5 @@ import { Duration } from 'moment/moment'; -import { PegStatus } from '@/common/store/constants'; +import { PegStatus, RejectedPegoutReasons } from '@/common/store/constants'; import SatoshiBig from '@/common/types/SatoshiBig'; import { PegInTxState } from '@/common/types/pegInTx'; import { SessionState } from '@/common/types/session'; @@ -73,6 +73,7 @@ export interface PegoutStatusDataModel { fees: number; estimatedFee: SatoshiBig; btcTxId: string; + reason?: RejectedPegoutReasons; } export interface FlyoverStatusModel { diff --git a/src/status/views/Status.vue b/src/status/views/Status.vue index b2c219bc2..e0e1a2fc4 100644 --- a/src/status/views/Status.vue +++ b/src/status/views/Status.vue @@ -18,6 +18,9 @@ Estimated time: {{ releaseTimeText }} + +

{{ rejectionMsg }}

+
@@ -90,6 +93,21 @@ export default defineComponent({ const isRejected = computed(() => status.value.txDetails?.status === 'REJECTED'); + const rejectionMsg = computed(() => { + const details = txDetails.value as PegoutStatusDataModel; + const { LOW_AMOUNT, CALLER_CONTRACT, FEE_ABOVE_VALUE } = constants.RejectedPegoutReasons; + switch (details.reason) { + case LOW_AMOUNT: + return 'The transaction was rejected because the amount is less than the minimum required.'; + case CALLER_CONTRACT: + return 'The transaction was rejected because the sender is a contract.'; + case FEE_ABOVE_VALUE: + return 'Due to high network fees, your transaction is cancelled. Please try again later when network fees are lower or you can bridge higher amounts.'; + default: + return ''; + } + }); + const isPegIn = computed((): boolean => status.value.type === TxStatusType.PEGIN || status.value.type === TxStatusType.FLYOVER_PEGIN); @@ -214,6 +232,7 @@ export default defineComponent({ rules, txWithErrorType, txWithError, + rejectionMsg, }; }, });