From 6f9a0427bf66b5be7c8727ba8729d60a339fd33e Mon Sep 17 00:00:00 2001 From: lserra-iov Date: Wed, 27 Nov 2024 09:27:26 -0300 Subject: [PATCH] Clear wallet service Avoids Enkrypt loading previous selected option --- .../exchange/SelectBitcoinWallet.vue | 3 +- src/common/utils/common.ts | 1 + src/pegin/store/PeginTx/actions.ts | 43 +++++++++++-------- 3 files changed, 26 insertions(+), 21 deletions(-) diff --git a/src/common/components/exchange/SelectBitcoinWallet.vue b/src/common/components/exchange/SelectBitcoinWallet.vue index 73803668..69ce12d4 100644 --- a/src/common/components/exchange/SelectBitcoinWallet.vue +++ b/src/common/components/exchange/SelectBitcoinWallet.vue @@ -113,8 +113,7 @@ export default { } function setBitcoinWallet(wallet: BtcWallet): void { - addBitcoinWallet(wallet); - toSendBitcoin(); + addBitcoinWallet(wallet).then(toSendBitcoin); } return { diff --git a/src/common/utils/common.ts b/src/common/utils/common.ts index 37946fdd..8bc22f43 100644 --- a/src/common/utils/common.ts +++ b/src/common/utils/common.ts @@ -66,6 +66,7 @@ export const getClearPeginTxState = (): PegInTxState => ({ safeFee: new SatoshiBig(0, 'btc'), }, peginType: constants.peginType.POWPEG, + walletService: undefined, }); export const getClearPegoutTxState = (): PegOutTxState => ({ diff --git a/src/pegin/store/PeginTx/actions.ts b/src/pegin/store/PeginTx/actions.ts index 5d745aef..51eb6085 100644 --- a/src/pegin/store/PeginTx/actions.ts +++ b/src/pegin/store/PeginTx/actions.ts @@ -38,25 +38,30 @@ export const actions: ActionTree = { }, [constants.PEGIN_TX_ADD_BITCOIN_WALLET]: ({ commit, state }, bitcoinWallet: BtcWallet) => { commit(constants.PEGIN_TX_SET_BITCOIN_WALLET, bitcoinWallet); - switch (bitcoinWallet) { - case constants.WALLET_NAMES.TREZOR.long_name: - commit(constants.PEGIN_TX_SET_WALLET_SERVICE, new TrezorService()); - break; - case constants.WALLET_NAMES.LEDGER.long_name: - commit(constants.PEGIN_TX_SET_WALLET_SERVICE, new LedgerService()); - break; - case constants.WALLET_NAMES.LEATHER.long_name: - commit(constants.PEGIN_TX_SET_WALLET_SERVICE, new LeatherService()); - break; - case constants.WALLET_NAMES.XVERSE.long_name: - commit(constants.PEGIN_TX_SET_WALLET_SERVICE, new XverseService()); - break; - case constants.WALLET_NAMES.ENKRYPT.long_name: - commit(constants.PEGIN_TX_SET_WALLET_SERVICE, new EnkryptService()); - break; - default: - commit(constants.PEGIN_TX_SET_WALLET_SERVICE, undefined); - break; + try { + switch (bitcoinWallet) { + case constants.WALLET_NAMES.TREZOR.long_name: + commit(constants.PEGIN_TX_SET_WALLET_SERVICE, new TrezorService()); + break; + case constants.WALLET_NAMES.LEDGER.long_name: + commit(constants.PEGIN_TX_SET_WALLET_SERVICE, new LedgerService()); + break; + case constants.WALLET_NAMES.LEATHER.long_name: + commit(constants.PEGIN_TX_SET_WALLET_SERVICE, new LeatherService()); + break; + case constants.WALLET_NAMES.XVERSE.long_name: + commit(constants.PEGIN_TX_SET_WALLET_SERVICE, new XverseService()); + break; + case constants.WALLET_NAMES.ENKRYPT.long_name: + commit(constants.PEGIN_TX_SET_WALLET_SERVICE, new EnkryptService()); + break; + default: + commit(constants.PEGIN_TX_SET_WALLET_SERVICE, undefined); + break; + } + } catch (e) { + commit(constants.PEGIN_TX_SET_WALLET_SERVICE, undefined); + return; } commit( constants.PEGIN_TX_WALLET_SERVICE_SUBSCRIBE,