From 4e55b1a9ed60d004d900f20b9836cac4b06e27cb Mon Sep 17 00:00:00 2001 From: Anna Shaleva Date: Tue, 27 Apr 2021 17:55:01 +0300 Subject: [PATCH] cli: add `nep11 ownerOf` command --- cli/nep11_test.go | 17 ++++++++++++++++- cli/wallet/nep11.go | 43 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+), 1 deletion(-) diff --git a/cli/nep11_test.go b/cli/nep11_test.go index 55e32b4e9..b83969465 100644 --- a/cli/nep11_test.go +++ b/cli/nep11_test.go @@ -85,7 +85,7 @@ func TestNEP11Import(t *testing.T) { }) } -func TestNEP11_BalanceOf_Transfer(t *testing.T) { +func TestNEP11_OwnerOf_BalanceOf_Transfer(t *testing.T) { e := newExecutor(t, true) tmpDir, err := ioutil.TempDir(os.TempDir(), "neogo.test.nftwallet*") @@ -176,6 +176,21 @@ func TestNEP11_BalanceOf_Transfer(t *testing.T) { e.Run(t, "neo-go", "wallet", "nep11", "remove", "--wallet", wall, "--token", h.StringLE()) + // ownerOf: missing contract hash + cmdOwnerOf := []string{"neo-go", "wallet", "nep11", "ownerOf", + "--rpc-endpoint", "http://" + e.RPC.Addr, + } + e.RunWithError(t, cmdOwnerOf...) + cmdOwnerOf = append(cmdOwnerOf, "--token", h.StringLE()) + + // ownerOf: missing token ID + e.RunWithError(t, cmdOwnerOf...) + cmdOwnerOf = append(cmdOwnerOf, "--id", string(tokenID)) + + // ownerOf: good + e.Run(t, cmdOwnerOf...) + e.checkNextLine(t, nftOwnerAddr) + cmdTransfer := []string{ "neo-go", "wallet", "nep11", "transfer", "--rpc-endpoint", "http://" + e.RPC.Addr, diff --git a/cli/wallet/nep11.go b/cli/wallet/nep11.go index fdc496a75..0222e6c37 100644 --- a/cli/wallet/nep11.go +++ b/cli/wallet/nep11.go @@ -19,6 +19,10 @@ import ( ) func newNEP11Commands() []cli.Command { + tokenAddressFlag := flags.AddressFlag{ + Name: "token", + Usage: "Token contract address or hash in LE", + } tokenID := cli.StringFlag{ Name: "id", Usage: "Token ID", @@ -83,6 +87,16 @@ func newNEP11Commands() []cli.Command { signer. `, }, + { + Name: "ownerOf", + Usage: "print owner of non-divisible NEP11 token with the specified ID", + UsageText: "ownerOf --rpc-endpoint --timeout