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

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

Merged
merged 4 commits into from
Oct 22, 2024

Conversation

raychu86
Copy link
Contributor

@raychu86 raychu86 commented Jul 16, 2024

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

#3219

CI run is here.

node/rest/src/routes.rs Outdated Show resolved Hide resolved
node/rest/src/routes.rs Outdated Show resolved Hide resolved
ljedrz
ljedrz previously approved these changes Jul 17, 2024
Copy link
Collaborator

@ljedrz ljedrz left a comment

Choose a reason for hiding this comment

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

Left a few comments, LGTM otherwise 👍.

@zosorock zosorock merged commit dae2509 into AleoNet:staging Oct 22, 2024
22 of 24 checks passed
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.

5 participants