Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tokens/tokensOf implementation in PUPPET seems to be wrong #45

Open
roman-khimov opened this issue Sep 2, 2022 · 0 comments
Open

tokens/tokensOf implementation in PUPPET seems to be wrong #45

roman-khimov opened this issue Sep 2, 2022 · 0 comments

Comments

@roman-khimov
Copy link

Test invocation of tokensOf for some address returns two elements:

./bin/neo-go contract testinvokefunction -r https://rpc10.n3.nspcc.ru:10331 0x76a8f8a7a901b29a33013b469949f4b08db15756 tokensOf NTApChTbQbGwGbrpiAkZ6HsFEDBWcmRd1W
{
  "state": "HALT",
  "gasconsumed": "618444",
  "script": "DBRPl57jRYRr2hwYCrfRsIX8eR/GlhHAHwwIdG9rZW5zT2YMFFZXsY2w9EmZRjsBM5qyAamn+Kh2QWJ9W1I=",
  "stack": [
    {
      "type": "InteropInterface",
      "iterator": [
        {
          "type": "Struct",
          "value": [
            {
              "type": "ByteString",
              "value": "aYcBXzEwNzc="
            },
            {
              "type": "ByteString",
              "value": "MTA3Nw=="
            }
          ]
        },
        {
          "type": "Struct",
          "value": [
            {
              "type": "ByteString",
              "value": "aYcBXzYwMQ=="
            },
            {
              "type": "ByteString",
              "value": "NjAx"
            }
          ]
        }
      ]
    }
  ],
  "exception": null,
  "notifications": []
}

Each of them is a struct, while NEP-11 says:

Each of these IDs SHOULD be a ByteString with a length of no more than 64 bytes.

The same thing happens with the tokens call. Most likely this happens because of the default Storage.Find options. I'm not sure about the storage scheme used by the contract, but you probably need to use ValuesOnly (or KeysOnly with RemovePrefix).

For an example of well-behaving NEP-11 please check 0xcd10d9f697230b04d9ebb8594a1ffe18fa95d9ad:

$ ./bin/neo-go contract testinvokefunction -r https://rpc10.n3.nspcc.ru:10331 0xcd10d9f697230b04d9ebb8594a1ffe18fa95d9ad tokensOf NeteCycXF1o64QgJQwUKVAp5HaViZwjGnq
{
  "state": "HALT",
  "gasconsumed": "455667",
  "script": "DBTQKiGP1X8uBQeo5FgOveUii7ouFxHAHwwIdG9rZW5zT2YMFK3ZlfoY/h9KWbjr2QQLI5f22RDNQWJ9W1I=",
  "stack": [
    {
      "type": "InteropInterface",
      "iterator": [
        {
          "type": "ByteString",
          "value": "TyAjMTQxMiBTY2FsYWJpbGl0eQ=="
        }
      ]
    }
  ],
  "exception": null,
  "notifications": []
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant