snarkOS icon indicating copy to clipboard operation
snarkOS copied to clipboard

[Feature] Add REST endpoint to get all items in a mapping

Open raychu86 opened this issue 1 year ago • 0 comments

Motivation

This PR adds a new GET get_mapping_values REST endpoint to read all the elements in a mapping.

GET /<network>/program/{programID}/mapping/{mappingName}?all={true}&metadata={true}

Example:

GET /<network>/program/credits.aleo/mapping/bonded?all=true&metadata=true will return the full bonded mapping of addresses + amounts staked on the network.

Notes:

  • The new GET endpoint currently requires a query parameters all to be set to true. In the future, this functionality can be expanded to get subsets of mapping data if required.
  • The endpoint is guarded behind the JSON Web Token auth because this call can be expensive for large mappings and may be a DOS vector for nodes. This JWT ensures that only authorized users can call this (potentially) expensive endpoint.

Related PRs

https://github.com/AleoNet/snarkOS/pull/3219

raychu86 avatar Jul 16 '24 19:07 raychu86