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

nft_tokens return empty array if there are no tokens not error #798

Merged
merged 4 commits into from
Apr 28, 2022

Conversation

kay404
Copy link
Contributor

@kay404 kay404 commented Apr 22, 2022

If there are no tokens are minted or from_index equal to, when I call commond:

near view NFT_CONTRACT_ID nft_tokens ''

It return error:

View call: NFT_CONTRACT_ID.nft_tokens()
An error occured
Error: Querying [object Object] failed: wasm execution failed with error: FunctionCallError(HostError(GuestPanic { panic_msg: "Out of bounds, please use a smaller from_index." })).
{
  "block_hash": "AUezwdpWhfrUh5XkDDLDMGSoEEUzhjsAgATdYUxLG9vY",
  "block_height": 88141968,
  "error": "wasm execution failed with error: FunctionCallError(HostError(GuestPanic { panic_msg: \"Out of bounds, please use a smaller from_index.\" }))",
  "logs": []
}
    at JsonRpcProvider.query (/root/.nvm/versions/node/v17.1.0/lib/node_modules/near-cli/node_modules/near-api-js/lib/providers/json-rpc-provider.js:123:19)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async Account.viewFunction (/root/.nvm/versions/node/v17.1.0/lib/node_modules/near-cli/node_modules/near-api-js/lib/account.js:366:24)
    at async exports.callViewFunction (/root/.nvm/versions/node/v17.1.0/lib/node_modules/near-cli/index.js:94:48)
    at async Object.handler (/root/.nvm/versions/node/v17.1.0/lib/node_modules/near-cli/utils/exit-on-error.js:52:9)
TypedError: Querying [object Object] failed: wasm execution failed with error: FunctionCallError(HostError(GuestPanic { panic_msg: "Out of bounds, please use a smaller from_index." })).
{
  "block_hash": "AUezwdpWhfrUh5XkDDLDMGSoEEUzhjsAgATdYUxLG9vY",
  "block_height": 88141968,
  "error": "wasm execution failed with error: FunctionCallError(HostError(GuestPanic { panic_msg: \"Out of bounds, please use a smaller from_index.\" }))",
  "logs": []
}
    at JsonRpcProvider.query (/root/.nvm/versions/node/v17.1.0/lib/node_modules/near-cli/node_modules/near-api-js/lib/providers/json-rpc-provider.js:123:19)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async Account.viewFunction (/root/.nvm/versions/node/v17.1.0/lib/node_modules/near-cli/node_modules/near-api-js/lib/account.js:366:24)
    at async exports.callViewFunction (/root/.nvm/versions/node/v17.1.0/lib/node_modules/near-cli/index.js:94:48)
    at async Object.handler (/root/.nvm/versions/node/v17.1.0/lib/node_modules/near-cli/utils/exit-on-error.js:52:9) {
  type: 'UntypedError',
  context: undefined
}

I think it's more reasonable to return an empty array not an error.

Copy link
Contributor

@austinabell austinabell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep! Not sure how this wouldn't have been found earlier

Also not really sure why there is this check anyway, since it seems it should just return an empty vec rather than panicking here... To fix another time

@austinabell austinabell merged commit a7e15f3 into near:master Apr 28, 2022
@austinabell
Copy link
Contributor

Thank you!

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

Successfully merging this pull request may close these issues.

2 participants