cli/wallet: search for NEP-11 token name in balances
In the same way we do for NEP-17 tokens. This code predates "getnep11balances" call, so this wasn't possible back then, but now we can improve the situation (allow specifying names/symbols instead of hashes only).
This commit is contained in:
parent
ed6ed61712
commit
e28bf55ebb
1 changed files with 4 additions and 4 deletions
|
@ -315,15 +315,15 @@ func getMatchingTokenRPC(ctx *cli.Context, c *rpcclient.Client, addr util.Uint16
|
||||||
}
|
}
|
||||||
return getMatchingTokenAux(ctx, get, len(bs.Balances), name, standard)
|
return getMatchingTokenAux(ctx, get, len(bs.Balances), name, standard)
|
||||||
case manifest.NEP11StandardName:
|
case manifest.NEP11StandardName:
|
||||||
tokenHash, err := flags.ParseAddress(name)
|
bs, err := c.GetNEP11Balances(addr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("valid token adress or hash in LE should be specified for %s RPC-node request: %s", standard, err.Error())
|
return nil, err
|
||||||
}
|
}
|
||||||
get := func(i int) *wallet.Token {
|
get := func(i int) *wallet.Token {
|
||||||
t, _ := getTokenWithStandard(c, tokenHash, standard)
|
t, _ := getTokenWithStandard(c, bs.Balances[i].Asset, standard)
|
||||||
return t
|
return t
|
||||||
}
|
}
|
||||||
return getMatchingTokenAux(ctx, get, 1, name, standard)
|
return getMatchingTokenAux(ctx, get, len(bs.Balances), name, standard)
|
||||||
default:
|
default:
|
||||||
return nil, fmt.Errorf("unsupported %s token", standard)
|
return nil, fmt.Errorf("unsupported %s token", standard)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue