/
confirm_unbonded_candidate.go
47 lines (43 loc) · 1.22 KB
/
confirm_unbonded_candidate.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package ops
import (
"github.com/celer-network/goutils/log"
"github.com/celer-network/sgn/common"
"github.com/celer-network/sgn/mainchain"
"github.com/ethereum/go-ethereum/accounts/abi/bind"
ethtypes "github.com/ethereum/go-ethereum/core/types"
"github.com/spf13/cobra"
"github.com/spf13/viper"
)
func confirmUnbondedCandidate() error {
ethClient, err := common.NewEthClientFromConfig()
if err != nil {
return err
}
candidate := mainchain.Hex2Addr(viper.GetString(candidateFlag))
log.Infof(
"Confirming unbonded candidate %s",
candidate.Hex(),
)
_, err = ethClient.Transactor.TransactWaitMined(
"ConfirmUnbondedCandidate",
func(transactor bind.ContractTransactor, opts *bind.TransactOpts) (*ethtypes.Transaction, error) {
return ethClient.DPoS.ConfirmUnbondedCandidate(opts, candidate)
},
)
if err != nil {
return err
}
return nil
}
func ConfirmUnbondedCandidateCommand() *cobra.Command {
cmd := &cobra.Command{
Use: "confirm-unbonded-candidate",
Short: "Confirm an unbonded candidate",
RunE: func(cmd *cobra.Command, args []string) error {
return confirmUnbondedCandidate()
},
}
cmd.Flags().String(candidateFlag, "", "Candidate ETH address")
cmd.MarkFlagRequired(candidateFlag)
return cmd
}