Skip to content

Commit

Permalink
Fix ui observations and ledger segwit sign
Browse files Browse the repository at this point in the history
  • Loading branch information
ronaldsg20 authored and alexjavabraz committed Apr 2, 2024
1 parent af55c26 commit 2726057
Show file tree
Hide file tree
Showing 8 changed files with 67 additions and 37 deletions.
40 changes: 20 additions & 20 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
"web3-eth-contract": "^1.10.0"
},
"devDependencies": {
"@ledgerhq/hw-transport-mocker": "^6.28.1",
"@ledgerhq/hw-transport-mocker": "^6.28.5",
"@mdi/font": "^7.2.96",
"@types/big.js": "^6.2.0",
"@types/chai": "^4.2.11",
Expand Down
1 change: 1 addition & 0 deletions src/common/services/LeatherService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ export default class LeatherService extends WalletService {
},
},
fee: true,
fullAmount: false,
},
];
}
Expand Down
10 changes: 7 additions & 3 deletions src/common/services/LedgerService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export default class LedgerService extends WalletService {
return [
{
title: 'Confirm your transaction',
subtitle: 'Please check your Trezor device',
subtitle: 'Please check your Ledger device',
outputsToshow: {
opReturn: {
value: true,
Expand All @@ -54,6 +54,7 @@ export default class LedgerService extends WalletService {
},
},
fee: false,
fullAmount: false,
},
{
title: 'Confirm funds transfer',
Expand All @@ -73,6 +74,7 @@ export default class LedgerService extends WalletService {
},
},
fee: false,
fullAmount: false,
},
{
title: 'Confirm change address',
Expand All @@ -92,10 +94,11 @@ export default class LedgerService extends WalletService {
},
},
fee: false,
fullAmount: false,
},
{
title: 'Confirm transaction fee',
subtitle: 'Really send',
subtitle: 'Confirm transaction',
outputsToshow: {
opReturn: {
value: false,
Expand All @@ -107,10 +110,11 @@ export default class LedgerService extends WalletService {
},
federation: {
address: false,
amount: true,
amount: false,
},
},
fee: true,
fullAmount: false,
},
];
}
Expand Down
1 change: 1 addition & 0 deletions src/common/services/LiqualityService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ export default class LiqualityService extends WalletService {
},
},
fee: true,
fullAmount: false,
},
];
}
Expand Down
6 changes: 5 additions & 1 deletion src/common/services/TrezorService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ export default class TrezorService extends WalletService {
},
},
fee: false,
fullAmount: false,
},
{
title: 'Confirm funds transfer',
Expand All @@ -104,6 +105,7 @@ export default class TrezorService extends WalletService {
},
},
fee: false,
fullAmount: false,
},
{
title: 'Confirm change address',
Expand All @@ -123,6 +125,7 @@ export default class TrezorService extends WalletService {
},
},
fee: false,
fullAmount: false,
},
{
title: 'Confirm transaction fee',
Expand All @@ -138,10 +141,11 @@ export default class TrezorService extends WalletService {
},
federation: {
address: false,
amount: true,
amount: false,
},
},
fee: true,
fullAmount: true,
},
];
}
Expand Down
1 change: 1 addition & 0 deletions src/common/types/Wallets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export interface Step {
amount: boolean,
},
},
fullAmount: boolean;
fee: boolean;
comment?: string;
}
43 changes: 31 additions & 12 deletions src/pegin/components/create/ConfirmTx.vue
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
<fieldset class="confirmation-box">
<legend lass="px-4">See on {{ walletService.name() }}</legend>
<v-row v-if="walletService.name() != 'leather'" class="ma-0 text-center">
<v-col>
<v-col class="pb-0">
<v-row justify="center" class="mt-3 mb-2">
<span>
{{ step.subtitle }}
Expand All @@ -60,7 +60,7 @@
</v-row>
<v-row v-if="step.outputsToshow.opReturn.amount"
justify="center" class="mt-5 mx-0 text-center">
Amount: 0
Amount: 0 {{ environmentContext.getBtcTicker() }}
</v-row>
<v-row v-if="step.outputsToshow.opReturn.value"
justify="center" class="mt-5 pa-0 d-none d-xl-block">
Expand All @@ -80,9 +80,9 @@
</v-row>
<v-divider
v-if="step.outputsToshow.opReturn.value || step.outputsToshow.opReturn.amount"
class="my-6"/>
class="mt-6 mb-3"/>
<v-row v-if="step.outputsToshow.federation.amount" justify="center">
Amount: {{computedFullAmount}}
Amount: {{computedAmountToTransfer}} {{ environmentContext.getBtcTicker() }}
</v-row>
<v-row v-if="step.outputsToshow.federation.address"
justify="center" class="mt-5 mx-0 d-none d-lg-block">
Expand All @@ -100,10 +100,17 @@
</v-row>
<v-divider
v-if="step.outputsToshow.federation.address || step.outputsToshow.federation.amount"
class="my-6"/>
class="mt-6 mb-3"/>
<v-row v-if="step.fullAmount"
justify="center" class="mt-5 mx-0 text-center">
Amount: {{computedFullAmount}} {{ environmentContext.getBtcTicker() }}
</v-row>
<v-divider
v-if="step.fullAmount"
class="mt-6 mb-3"/>
<v-row v-if="step.outputsToshow.change.amount && parseFloat(changeAmountComputed) > 0"
justify="center" class="mt-5 mx-0 text-center">
Amount: {{changeAmountComputed}}
Amount: {{changeAmountComputed}} {{ environmentContext.getBtcTicker() }}
</v-row>
<v-row v-if="step.outputsToshow.change.address"
justify="center" class="mt-5 mx-0 d-none d-lg-block">
Expand All @@ -121,11 +128,14 @@
</v-row>
<v-divider
v-if="step.outputsToshow.change.address || step.outputsToshow.change.amount"
class="my-6"/>
class="mt-6 mb-3"/>
<v-row v-if="step.fee"
justify="center" class="mt-5 mx-0 text-center">
Fee: {{safeFee.toBTCTrimmedString()}}
Fee: {{safeFee.toBTCTrimmedString()}} {{ environmentContext.getBtcTicker() }}
</v-row>
<v-divider
v-if="step.fee"
class="mt-6 mb-3"/>

</v-col>
</v-row>
Expand All @@ -138,15 +148,15 @@
</span>
</v-row>
<v-row v-if="step.outputsToshow.federation.amount" justify="center">
Bitcoin {{computedPlusFeeFullAmount}}
{{ environmentContext.getBtcText() }} {{computedPlusFeeFullAmount}}
</v-row>
<v-divider class="my-6"/>
<v-row v-if="step.outputsToshow.federation.amount" justify="center">
Transaction fee {{confirmTxSummary.fee}}
Transaction fee {{confirmTxSummary.fee}} {{environmentContext.getBtcTicker()}}
</v-row>
</v-col>
</v-row>
<v-row justify="center" class="mt-5 mb-3 mx-0">
<v-row justify="center" class="mt-2 mb-3 mx-0">
Confirm on your {{walletService.name()}} Wallet
</v-row>
</fieldset>
Expand Down Expand Up @@ -242,6 +252,11 @@ export default defineComponent({
});
const computedFullAmount = computed((): string => pegInTxState.value.amountToTransfer
.plus(new SatoshiBig(pegInTxState.value.normalizedTx.outputs[2]?.amount ?? 0, 'satoshi'))
.plus(safeFee.value)
.toBTCTrimmedString());
const computedAmountToTransfer = computed((): string => pegInTxState.value.amountToTransfer
.toBTCTrimmedString());
const computedPlusFeeFullAmount = computed((): string => pegInTxState.value.amountToTransfer
Expand Down Expand Up @@ -281,7 +296,10 @@ export default defineComponent({
let txError = '';
props.confirmTxState.send('loading');
await walletService.value.stopAskingForBalance()
.then(() => props.txBuilder.buildTx(pegInTxState.value.normalizedTx))
.then(() => props.txBuilder.buildTx(
pegInTxState.value.normalizedTx,
pegInTxState.value.selectedAccount,
))
.then((tx) => walletService.value.sign(tx))
.then(({ signedTx }) => ApiService
.broadcast(signedTx))
Expand Down Expand Up @@ -327,6 +345,7 @@ export default defineComponent({
environmentContext,
changeAmountComputed,
computedFullAmount,
computedAmountToTransfer,
computedPlusFeeFullAmount,
toPegInForm,
cropAddress,
Expand Down

0 comments on commit 2726057

Please sign in to comment.