Skip to content
This repository has been archived by the owner on Sep 14, 2023. It is now read-only.

feat: entry page retrieval #644

Merged
merged 4 commits into from
Feb 23, 2023
Merged

feat: entry page retrieval #644

merged 4 commits into from
Feb 23, 2023

Conversation

harrysolovay
Copy link
Contributor

@harrysolovay harrysolovay commented Feb 22, 2023

Resolves #643

Allows one to retrieve a list of entries as they do a list of keys.

import { Uniques } from "statemint/mod.ts"

const collections = Uniques.Class.entryPage(100)

const result = await collections.run()

console.log(result)

Will soon be complemented by #567.

Note: was confused by the name of the result, storage changeset. Doesn't represent a diff after all.

@harrysolovay harrysolovay marked this pull request as ready for review February 22, 2023 22:47
Copy link
Contributor

@tjjfvi tjjfvi left a comment

Choose a reason for hiding this comment

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

state_queryStorageAt isn't the right method. Looks like we'll either need to use mapArray or give up paging and use state_getPairs.

Note: was confused by the name of the result, storage changeset. Doesn't represent a diff after all.

The first entry doesn't, but subsequent entries do.

@harrysolovay
Copy link
Contributor Author

harrysolovay commented Feb 22, 2023

This is the same approach used by pjs apps.

Try reading statemine's uniques classes storage map. Same output.

getPairs is deprecated and calling it results in a server error.

This approach allows for retrieval with 2 round trips... that being said, yea: it's not the prettiest. Not sure if we have any better alternative though.

@harrysolovay
Copy link
Contributor Author

The first entry doesn't, but subsequent entries do.

This is interesting. Yea, even if we did go this route, we'd need to skip decoding the subsequent diffs.

Copy link
Contributor

@tjjfvi tjjfvi left a comment

Choose a reason for hiding this comment

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

Ah, I confused state_queryStorageAt with state_queryStorage. The former does a single block, the latter is the history-diffing one.

Eventually we should rename .entry to .get or .value, but for now I think we should leave it as-is.

@harrysolovay harrysolovay added this pull request to the merge queue Feb 23, 2023
Merged via the queue into main with commit 4a975ca Feb 23, 2023
@harrysolovay harrysolovay deleted the entry-pages branch February 23, 2023 14:12
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fetch all the items from a StorageMap
2 participants