From cd787d71374bcee9ca9d11d70b73f0a838b3541d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Szymon=20Mas=C5=82owski?= Date: Wed, 11 Dec 2024 16:00:41 +0100 Subject: [PATCH 1/2] feat: use pool delegation endpoint for constructing drep tx no matter the wallet type --- source/renderer/app/stores/VotingStore.ts | 86 ++++++++--------------- 1 file changed, 31 insertions(+), 55 deletions(-) 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), From 6cdd7bae4b4e032f256eeda7a3dba1544575a659 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Szymon=20Mas=C5=82owski?= Date: Thu, 12 Dec 2024 12:00:20 +0100 Subject: [PATCH 2/2] docs: add changelog entry --- CHANGELOG.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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