forked from TrueCloudLab/neoneo-go
cli: use AddressFlag for nep17-related commands
This commit is contained in:
parent
2dcc729c47
commit
ff2b051646
2 changed files with 5 additions and 11 deletions
|
@ -98,9 +98,6 @@ func TestNEP17Balance(t *testing.T) {
|
||||||
t.Run("Bad wallet", func(t *testing.T) {
|
t.Run("Bad wallet", func(t *testing.T) {
|
||||||
e.RunWithError(t, append(cmdbalance, "--wallet", "/dev/null")...)
|
e.RunWithError(t, append(cmdbalance, "--wallet", "/dev/null")...)
|
||||||
})
|
})
|
||||||
t.Run("Bad address", func(t *testing.T) {
|
|
||||||
e.RunWithError(t, append(cmdbalance, "--rpc-endpoint", "http://"+e.RPC.Addr, "--wallet", validatorWallet, "--address", "xxx")...)
|
|
||||||
})
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,7 @@ func newNEP17Commands() []cli.Command {
|
||||||
balanceFlags := []cli.Flag{
|
balanceFlags := []cli.Flag{
|
||||||
walletPathFlag,
|
walletPathFlag,
|
||||||
tokenFlag,
|
tokenFlag,
|
||||||
cli.StringFlag{
|
flags.AddressFlag{
|
||||||
Name: "address, a",
|
Name: "address, a",
|
||||||
Usage: "Address to use",
|
Usage: "Address to use",
|
||||||
},
|
},
|
||||||
|
@ -135,15 +135,12 @@ func getNEP17Balance(ctx *cli.Context) error {
|
||||||
}
|
}
|
||||||
defer wall.Close()
|
defer wall.Close()
|
||||||
|
|
||||||
addr := ctx.String("address")
|
addrFlag := ctx.Generic("address").(*flags.Address)
|
||||||
if addr != "" {
|
if addrFlag.IsSet {
|
||||||
addrHash, err := address.StringToUint160(addr)
|
addrHash := addrFlag.Uint160()
|
||||||
if err != nil {
|
|
||||||
return cli.NewExitError(fmt.Errorf("invalid address: %w", err), 1)
|
|
||||||
}
|
|
||||||
acc := wall.GetAccount(addrHash)
|
acc := wall.GetAccount(addrHash)
|
||||||
if acc == nil {
|
if acc == nil {
|
||||||
return cli.NewExitError(fmt.Errorf("can't find account for the address: %s", addr), 1)
|
return cli.NewExitError(fmt.Errorf("can't find account for the address: %s", address.Uint160ToString(addrHash)), 1)
|
||||||
}
|
}
|
||||||
accounts = append(accounts, acc)
|
accounts = append(accounts, acc)
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in a new issue