Skip to content

Commit

Permalink
Show error msg when pegout is rejected
Browse files Browse the repository at this point in the history
  • Loading branch information
lserra-iov committed Nov 4, 2024
1 parent 5ea3248 commit 52fc0aa
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 1 deletion.
6 changes: 6 additions & 0 deletions src/common/store/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
}
3 changes: 2 additions & 1 deletion src/common/types/store.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -73,6 +73,7 @@ export interface PegoutStatusDataModel {
fees: number;
estimatedFee: SatoshiBig;
btcTxId: string;
reason?: RejectedPegoutReasons;
}

export interface FlyoverStatusModel {
Expand Down
19 changes: 19 additions & 0 deletions src/status/views/Status.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
<v-row no-gutters v-if="showStatus && showTimeLeft" justify="center">
<span class="text-bw-400 text-body-1">Estimated time: {{ releaseTimeText }}</span>
</v-row>
<v-row no-gutters v-if="showStatus && isRejected" justify="center">
<p class="w-75 text-center text-body-1">{{ rejectionMsg }}</p>
</v-row>
<v-row no-gutters v-if="showStatus">
<tx-pegin v-if="isPegIn" :txId="txId" :isFlyover="isFlyover"
:txWithErrorType="txWithErrorType" :txWithError="txWithError" />
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -214,6 +232,7 @@ export default defineComponent({
rules,
txWithErrorType,
txWithError,
rejectionMsg,
};
},
});
Expand Down

0 comments on commit 52fc0aa

Please sign in to comment.