Skip to content

Commit 66478e0

Browse files
koseoyoungYutong Pei
and
Yutong Pei
authored
support ioctl account balance command for staking and reward pool addr (iotexproject#2342)
Co-authored-by: Yutong Pei <[email protected]>
1 parent 29f2060 commit 66478e0

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

ioctl/cmd/account/accountbalance.go

+11-6
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import (
1212

1313
"github.com/spf13/cobra"
1414

15+
ioAddress "github.com/iotexproject/iotex-address/address"
1516
"github.com/iotexproject/iotex-core/ioctl/config"
1617
"github.com/iotexproject/iotex-core/ioctl/output"
1718
"github.com/iotexproject/iotex-core/ioctl/util"
@@ -52,11 +53,15 @@ type balanceMessage struct {
5253

5354
// balance gets balance of an IoTeX blockchain address
5455
func balance(arg string) error {
55-
address, err := util.GetAddress(arg)
56-
if err != nil {
57-
return output.NewError(output.AddressError, "", err)
58-
}
59-
accountMeta, err := GetAccountMeta(address)
56+
addr := arg
57+
if arg != ioAddress.StakingBucketPoolAddr && arg != ioAddress.RewardingPoolAddr {
58+
var err error
59+
addr, err = util.GetAddress(arg)
60+
if err != nil {
61+
return output.NewError(output.AddressError, "", err)
62+
}
63+
}
64+
accountMeta, err := GetAccountMeta(addr)
6065
if err != nil {
6166
return output.NewError(0, "", err) // TODO: undefined error
6267
}
@@ -65,7 +70,7 @@ func balance(arg string) error {
6570
return output.NewError(output.ConvertError, "", err)
6671
}
6772
message := balanceMessage{
68-
Address: address,
73+
Address: addr,
6974
Balance: util.RauToString(balance, util.IotxDecimalNum),
7075
}
7176
fmt.Println((message.String()))

0 commit comments

Comments
 (0)