Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix balance issues on add validator #2496

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion cmd/blockchaincmd/add_validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,14 @@ func addValidator(_ *cobra.Command, args []string) error {

sovereign := sc.Sovereign

availableBalance, err := utils.GetNetworkBalance(kc.Addresses().List(), network.Endpoint)
if err != nil {
return err
}
if availableBalance == 0 {
return fmt.Errorf("chosen key has zero balance")
}

if nodeEndpoint != "" {
nodeIDStr, publicKey, pop, err = node.GetNodeData(nodeEndpoint)
if err != nil {
Expand Down Expand Up @@ -512,7 +520,7 @@ func CallAddValidator(
if !pos {
ux.Logger.PrintToUser(" Weight: %d", weight)
}
ux.Logger.PrintToUser(" Balance: %d", balance/units.Avax)
ux.Logger.PrintToUser(" Balance: %f", float64(balance)/float64(units.Avax))
ux.Logger.GreenCheckmarkToUser("Validator successfully added to the L1")

return nil
Expand Down
Loading