Skip to content

Commit

Permalink
fix(account): Fix delegate/undelegate ParaTime param
Browse files Browse the repository at this point in the history
  • Loading branch information
matevz committed May 29, 2023
1 parent 6a49b35 commit 794daa4
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 33 deletions.
26 changes: 10 additions & 16 deletions cmd/account/delegate.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,24 +43,18 @@ var delegateCmd = &cobra.Command{
acc := common.LoadAccount(cfg, npa.AccountName)

var sigTx interface{}
switch npa.ParaTime {
case nil:
// Consensus layer delegation.
amount, err := helpers.ParseConsensusDenomination(npa.Network, amount)
cobra.CheckErr(err)
// Consensus layer delegation.
amt, err := helpers.ParseConsensusDenomination(npa.Network, amount)
cobra.CheckErr(err)

// Prepare transaction.
tx := staking.NewAddEscrowTx(0, nil, &staking.Escrow{
Account: toAddr.ConsensusAddress(),
Amount: *amount,
})
// Prepare transaction.
tx := staking.NewAddEscrowTx(0, nil, &staking.Escrow{
Account: toAddr.ConsensusAddress(),
Amount: *amt,
})

sigTx, err = common.SignConsensusTransaction(ctx, npa, acc, conn, tx)
cobra.CheckErr(err)
default:
// ParaTime delegation.
cobra.CheckErr("delegations within ParaTimes are not supported; use --no-paratime")
}
sigTx, err = common.SignConsensusTransaction(ctx, npa, acc, conn, tx)
cobra.CheckErr(err)

common.BroadcastOrExportTransaction(ctx, npa.ParaTime, conn, sigTx, nil, nil)
},
Expand Down
28 changes: 11 additions & 17 deletions cmd/account/undelegate.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,25 +43,19 @@ var undelegateCmd = &cobra.Command{
acc := common.LoadAccount(cfg, npa.AccountName)

var sigTx interface{}
switch npa.ParaTime {
case nil:
// Consensus layer delegation.
var shares quantity.Quantity
err = shares.UnmarshalText([]byte(amount))
cobra.CheckErr(err)
// Consensus layer delegation.
var shares quantity.Quantity
err = shares.UnmarshalText([]byte(amount))
cobra.CheckErr(err)

// Prepare transaction.
tx := staking.NewReclaimEscrowTx(0, nil, &staking.ReclaimEscrow{
Account: fromAddr.ConsensusAddress(),
Shares: shares,
})
// Prepare transaction.
tx := staking.NewReclaimEscrowTx(0, nil, &staking.ReclaimEscrow{
Account: fromAddr.ConsensusAddress(),
Shares: shares,
})

sigTx, err = common.SignConsensusTransaction(ctx, npa, acc, conn, tx)
cobra.CheckErr(err)
default:
// ParaTime delegation.
cobra.CheckErr("delegations within ParaTimes are not supported; use --no-paratime")
}
sigTx, err = common.SignConsensusTransaction(ctx, npa, acc, conn, tx)
cobra.CheckErr(err)

common.BroadcastOrExportTransaction(ctx, npa.ParaTime, conn, sigTx, nil, nil)
},
Expand Down

0 comments on commit 794daa4

Please sign in to comment.