Skip to content

Commit 441e993

Browse files
committed
fix: format of values for pegout native
1 parent 5a877ae commit 441e993

File tree

2 files changed

+21
-12
lines changed

2 files changed

+21
-12
lines changed

src/common/components/status/StatusSummary.vue

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,8 @@ export default defineComponent({
107107
108108
const btcSide = computed(() => {
109109
if (props.type === TxStatusType.PEGOUT || props.type === TxStatusType.FLYOVER_PEGOUT) {
110-
const fee = props.details.fee === 0 ? props.details.estimatedFee : props.details.fee;
110+
const fee = Number(props.details.fee) === 0
111+
? props.details.estimatedFee : props.details.fee;
111112
return [
112113
{
113114
title: 'You receive',
@@ -172,7 +173,7 @@ export default defineComponent({
172173
? 'Fee (includes provider and network fees)' : 'Fee',
173174
value: status.value.type === TxStatusType.FLYOVER_PEGOUT
174175
? props.details.fee
175-
: gasFee,
176+
: gasFee, // TODO: anni
176177
ticker: true,
177178
},
178179
{

src/common/components/status/TxPegout.vue

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,10 @@ import {
2424
import StatusProgressBar from '@/common/components/status/StatusProgressBar.vue';
2525
import { useStateAttribute } from '@/common/store/helper';
2626
import StatusSummary from '@/common/components/status/StatusSummary.vue';
27-
import { bigNumberToSatoshiBigIntString, toWeiBigIntString } from '@/common/utils';
27+
import {
28+
toWeiBigIntString,
29+
toSatoshiBigIntString,
30+
} from '@/common/utils';
2831
2932
export default defineComponent({
3033
name: 'TxPegout',
@@ -51,30 +54,35 @@ export default defineComponent({
5154
const amountToBeReceived = computed((): string => {
5255
const status = txDetails.value as PegoutStatusDataModel;
5356
if (isRejectedPegout.value) {
54-
return '';
57+
return '0';
5558
}
5659
if (status.valueInSatoshisToBeReceived) {
5760
return new SatoshiBig(status.valueInSatoshisToBeReceived, 'satoshi').toBTCTrimmedString();
5861
}
59-
const requestedAmount = new SatoshiBig(status.valueRequestedInSatoshis, 'satoshi');
60-
return requestedAmount.minus(pegOutEstimatedFee.value).toBTCTrimmedString();
62+
const requestedAmount = new WeiBig(status.valueRequestedInSatoshis, 'wei');
63+
const requestedAmountString = toWeiBigIntString(requestedAmount.toRBTCTrimmedString());
64+
const pegOutEstimatedString = toSatoshiBigIntString(pegOutEstimatedFee.value
65+
.toBTCTrimmedString());
66+
const amountToReceive = (new WeiBig(requestedAmountString, 'wei'))
67+
.minus(new WeiBig(pegOutEstimatedString, 'wei'));
68+
return amountToReceive.toRBTCTrimmedString();
6169
});
6270
6371
const txPegoutSummary = computed((): NormalizedSummary => {
6472
const status = txDetails.value as PegoutStatusDataModel;
65-
const valueRequested = bigNumberToSatoshiBigIntString(status.valueRequestedInSatoshis);
66-
const amountSent = new WeiBig(valueRequested, 'rbtc')
67-
.plus(calculatedGasFee.value).toRBTCTrimmedString();
73+
const valueRequested = new SatoshiBig(status.valueRequestedInSatoshis, 'satoshi');
74+
const amountSent = new WeiBig(valueRequested.toSatoshiBigIntUnsafe(), 'wei').plus(calculatedGasFee.value);
6875
const btcTxId = status.status === PegoutStatus.RELEASE_BTC ? status.btcTxId : '';
6976
return {
70-
amountFromString: amountSent,
77+
amountFromString: isRejectedPegout.value ? valueRequested.toBTCTrimmedString()
78+
: amountSent.toRBTCTrimmedString(),
7179
amountReceivedString: amountToBeReceived.value,
72-
gas: calculatedGasFee.value.toString(),
80+
gas: calculatedGasFee.value.toRBTCTrimmedString(),
7381
fee: status.feeInSatoshisToBePaid ?? '0',
7482
recipientAddress: status.btcRecipientAddress,
7583
senderAddress: status.rskSenderAddress,
7684
txId: status.rskTxHash ? status.rskTxHash : props.txId,
77-
estimatedFee: pegOutEstimatedFee.value.toString(),
85+
estimatedFee: pegOutEstimatedFee.value.toBTCTrimmedString(),
7886
status: status.status,
7987
btcTxId,
8088
};

0 commit comments

Comments
 (0)