@@ -278,29 +278,29 @@ export default class VotingStore extends Store {
278278 chosenOption : string ;
279279 wallet : Wallet ;
280280 } ) => {
281- if ( wallet . isHardwareWallet ) {
282- let poolId : string ;
283-
284- if ( wallet . isDelegating ) {
285- const { lastDelegatedStakePoolId, delegatedStakePoolId } = wallet ;
286- const currentPoolId = lastDelegatedStakePoolId || delegatedStakePoolId ;
287- poolId = this . stores . staking . stakePools . find (
288- ( stakePool ) => stakePool . id !== currentPoolId
289- ) . id ;
290- } else {
291- const [ { id } ] = this . stores . staking . stakePools ;
292- poolId = id ;
293- }
281+ let poolId : string ;
282+
283+ if ( wallet . isDelegating ) {
284+ const { lastDelegatedStakePoolId, delegatedStakePoolId } = wallet ;
285+ const currentPoolId = lastDelegatedStakePoolId || delegatedStakePoolId ;
286+ poolId = this . stores . staking . stakePools . find (
287+ ( stakePool ) => stakePool . id !== currentPoolId
288+ ) . id ;
289+ } else {
290+ const [ { id } ] = this . stores . staking . stakePools ;
291+ poolId = id ;
292+ }
294293
295- try {
296- const initialCoinSelection = await this . stores . hardwareWallets . selectDelegationCoins (
297- {
298- walletId : wallet . id ,
299- delegationAction : 'join' ,
300- poolId,
301- }
302- ) ;
294+ try {
295+ let coinSelection = await this . stores . hardwareWallets . selectDelegationCoins (
296+ {
297+ walletId : wallet . id ,
298+ delegationAction : 'join' ,
299+ poolId,
300+ }
301+ ) ;
303302
303+ if ( wallet . isHardwareWallet ) {
304304 let certificates : object [ ] = [
305305 {
306306 certificateType : 'cast_vote' ,
@@ -309,7 +309,7 @@ export default class VotingStore extends Store {
309309 } ,
310310 ] ;
311311
312- const walletNeedsRegisteringRewardAccount = initialCoinSelection . certificates . some (
312+ const walletNeedsRegisteringRewardAccount = coinSelection . certificates . some (
313313 ( c ) => c . certificateType === 'register_reward_account'
314314 ) ;
315315 if ( walletNeedsRegisteringRewardAccount ) {
@@ -322,52 +322,28 @@ export default class VotingStore extends Store {
322322 ] ;
323323 }
324324
325- const coinSelection = {
326- ...initialCoinSelection ,
325+ coinSelection = {
326+ ...coinSelection ,
327327 certificates,
328328 } ;
329329
330330 this . stores . hardwareWallets . updateTxSignRequest ( coinSelection ) ;
331331 this . stores . hardwareWallets . initiateTransaction ( {
332332 walletId : wallet . id ,
333333 } ) ;
334-
335- return {
336- success : true ,
337- fees : coinSelection . fee ,
338- } ;
339- } catch ( error ) {
340- logger . error (
341- 'VotingStore: error while initializing VP delegation TX with HW' ,
342- {
343- error,
344- }
345- ) ;
346- return {
347- success : false ,
348- errorCode : parseApiCode (
349- expectedInitializeVPDelegationTxErrors ,
350- error
351- ) ,
352- } ;
353334 }
354- }
355-
356- this . constructTxRequest . reset ( ) ;
357- try {
358- const constructedTx = await this . constructTxRequest . execute ( {
359- walletId : wallet . id ,
360- data : { vote : chosenOption } ,
361- } ) . promise ;
362335
363336 return {
364337 success : true ,
365- fees : constructedTx . fee ,
338+ fees : coinSelection . fee ,
366339 } ;
367340 } catch ( error ) {
368- logger . error ( 'VotingStore: error while initializing VP delegation TX' , {
369- error,
370- } ) ;
341+ logger . error (
342+ 'VotingStore: error while initializing VP delegation TX with HW' ,
343+ {
344+ error,
345+ }
346+ ) ;
371347 return {
372348 success : false ,
373349 errorCode : parseApiCode ( expectedInitializeVPDelegationTxErrors , error ) ,
0 commit comments