diff --git a/CHANGELOG.md b/CHANGELOG.md index 029639d305..7fbf3260e3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,10 @@ # Changelog -## vNext +## 7.0.2 + +### Fixes + +- Changed Cardano Wallet endpoint used to initialize VP delegation transaction ([PR 3262](https://github.com/input-output-hk/daedalus/pull/3262)) ## 7.0.1 diff --git a/source/renderer/app/stores/VotingStore.ts b/source/renderer/app/stores/VotingStore.ts index bf1752dfc1..72ef02e9e6 100644 --- a/source/renderer/app/stores/VotingStore.ts +++ b/source/renderer/app/stores/VotingStore.ts @@ -278,29 +278,29 @@ export default class VotingStore extends Store { chosenOption: string; wallet: Wallet; }) => { - if (wallet.isHardwareWallet) { - let poolId: string; - - if (wallet.isDelegating) { - const { lastDelegatedStakePoolId, delegatedStakePoolId } = wallet; - const currentPoolId = lastDelegatedStakePoolId || delegatedStakePoolId; - poolId = this.stores.staking.stakePools.find( - (stakePool) => stakePool.id !== currentPoolId - ).id; - } else { - const [{ id }] = this.stores.staking.stakePools; - poolId = id; - } + let poolId: string; + + if (wallet.isDelegating) { + const { lastDelegatedStakePoolId, delegatedStakePoolId } = wallet; + const currentPoolId = lastDelegatedStakePoolId || delegatedStakePoolId; + poolId = this.stores.staking.stakePools.find( + (stakePool) => stakePool.id !== currentPoolId + ).id; + } else { + const [{ id }] = this.stores.staking.stakePools; + poolId = id; + } - try { - const initialCoinSelection = await this.stores.hardwareWallets.selectDelegationCoins( - { - walletId: wallet.id, - delegationAction: 'join', - poolId, - } - ); + try { + let coinSelection = await this.stores.hardwareWallets.selectDelegationCoins( + { + walletId: wallet.id, + delegationAction: 'join', + poolId, + } + ); + if (wallet.isHardwareWallet) { let certificates: object[] = [ { certificateType: 'cast_vote', @@ -309,7 +309,7 @@ export default class VotingStore extends Store { }, ]; - const walletNeedsRegisteringRewardAccount = initialCoinSelection.certificates.some( + const walletNeedsRegisteringRewardAccount = coinSelection.certificates.some( (c) => c.certificateType === 'register_reward_account' ); if (walletNeedsRegisteringRewardAccount) { @@ -322,8 +322,8 @@ export default class VotingStore extends Store { ]; } - const coinSelection = { - ...initialCoinSelection, + coinSelection = { + ...coinSelection, certificates, }; @@ -331,43 +331,19 @@ export default class VotingStore extends Store { this.stores.hardwareWallets.initiateTransaction({ walletId: wallet.id, }); - - return { - success: true, - fees: coinSelection.fee, - }; - } catch (error) { - logger.error( - 'VotingStore: error while initializing VP delegation TX with HW', - { - error, - } - ); - return { - success: false, - errorCode: parseApiCode( - expectedInitializeVPDelegationTxErrors, - error - ), - }; } - } - - this.constructTxRequest.reset(); - try { - const constructedTx = await this.constructTxRequest.execute({ - walletId: wallet.id, - data: { vote: chosenOption }, - }).promise; return { success: true, - fees: constructedTx.fee, + fees: coinSelection.fee, }; } catch (error) { - logger.error('VotingStore: error while initializing VP delegation TX', { - error, - }); + logger.error( + 'VotingStore: error while initializing VP delegation TX with HW', + { + error, + } + ); return { success: false, errorCode: parseApiCode(expectedInitializeVPDelegationTxErrors, error),