@@ -278,29 +278,29 @@ export default class VotingStore extends Store {
278
278
chosenOption : string ;
279
279
wallet : Wallet ;
280
280
} ) => {
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
+ }
294
293
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
+ ) ;
303
302
303
+ if ( wallet . isHardwareWallet ) {
304
304
let certificates : object [ ] = [
305
305
{
306
306
certificateType : 'cast_vote' ,
@@ -309,7 +309,7 @@ export default class VotingStore extends Store {
309
309
} ,
310
310
] ;
311
311
312
- const walletNeedsRegisteringRewardAccount = initialCoinSelection . certificates . some (
312
+ const walletNeedsRegisteringRewardAccount = coinSelection . certificates . some (
313
313
( c ) => c . certificateType === 'register_reward_account'
314
314
) ;
315
315
if ( walletNeedsRegisteringRewardAccount ) {
@@ -322,52 +322,28 @@ export default class VotingStore extends Store {
322
322
] ;
323
323
}
324
324
325
- const coinSelection = {
326
- ...initialCoinSelection ,
325
+ coinSelection = {
326
+ ...coinSelection ,
327
327
certificates,
328
328
} ;
329
329
330
330
this . stores . hardwareWallets . updateTxSignRequest ( coinSelection ) ;
331
331
this . stores . hardwareWallets . initiateTransaction ( {
332
332
walletId : wallet . id ,
333
333
} ) ;
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
- } ;
353
334
}
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 ;
362
335
363
336
return {
364
337
success : true ,
365
- fees : constructedTx . fee ,
338
+ fees : coinSelection . fee ,
366
339
} ;
367
340
} 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
+ ) ;
371
347
return {
372
348
success : false ,
373
349
errorCode : parseApiCode ( expectedInitializeVPDelegationTxErrors , error ) ,
0 commit comments