mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2024-12-26 19:43:48 +00:00
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) {
|
||||
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
|
||||
}
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ func newNEP17Commands() []cli.Command {
|
|||
balanceFlags := []cli.Flag{
|
||||
walletPathFlag,
|
||||
tokenFlag,
|
||||
cli.StringFlag{
|
||||
flags.AddressFlag{
|
||||
Name: "address, a",
|
||||
Usage: "Address to use",
|
||||
},
|
||||
|
@ -135,15 +135,12 @@ func getNEP17Balance(ctx *cli.Context) error {
|
|||
}
|
||||
defer wall.Close()
|
||||
|
||||
addr := ctx.String("address")
|
||||
if addr != "" {
|
||||
addrHash, err := address.StringToUint160(addr)
|
||||
if err != nil {
|
||||
return cli.NewExitError(fmt.Errorf("invalid address: %w", err), 1)
|
||||
}
|
||||
addrFlag := ctx.Generic("address").(*flags.Address)
|
||||
if addrFlag.IsSet {
|
||||
addrHash := addrFlag.Uint160()
|
||||
acc := wall.GetAccount(addrHash)
|
||||
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)
|
||||
} else {
|
||||
|
|
Loading…
Reference in a new issue