From e28bf55ebb53a3baabb8d4acba132d637bc5a8be Mon Sep 17 00:00:00 2001 From: Roman Khimov Date: Fri, 26 Aug 2022 23:12:22 +0300 Subject: [PATCH] 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). --- cli/wallet/nep17.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/cli/wallet/nep17.go b/cli/wallet/nep17.go index 54f81f379..5ebb80cc0 100644 --- a/cli/wallet/nep17.go +++ b/cli/wallet/nep17.go @@ -315,15 +315,15 @@ func getMatchingTokenRPC(ctx *cli.Context, c *rpcclient.Client, addr util.Uint16 } return getMatchingTokenAux(ctx, get, len(bs.Balances), name, standard) case manifest.NEP11StandardName: - tokenHash, err := flags.ParseAddress(name) + bs, err := c.GetNEP11Balances(addr) 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 { - t, _ := getTokenWithStandard(c, tokenHash, standard) + t, _ := getTokenWithStandard(c, bs.Balances[i].Asset, standard) return t } - return getMatchingTokenAux(ctx, get, 1, name, standard) + return getMatchingTokenAux(ctx, get, len(bs.Balances), name, standard) default: return nil, fmt.Errorf("unsupported %s token", standard) }