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

create Map<K, T>::query_all #27

Open
0xForerunner opened this issue Jan 3, 2023 · 3 comments
Open

create Map<K, T>::query_all #27

0xForerunner opened this issue Jan 3, 2023 · 3 comments
Labels
enhancement New feature or request wontfix This will not be worked on

Comments

@0xForerunner
Copy link
Contributor

function signature should probably look something like:

impl<'a, K, T> Map<'a, K, T>
where
    T: Serialize + DeserializeOwned,
    K: PrimaryKey<'a>,
{
        pub fn query_all<Q: CustomQuery>(
        &self,
        querier: &QuerierWrapper<Q>,
        remote_contract: Addr,
        order: Order // Not sure this is required
    ) -> StdResult<Vec<T>> {
        ...
    }
}

The purpose of this function is to allow the querying of external contracts, and should function similarly to the existing Map::query.

@0xForerunner 0xForerunner changed the title create Map<K, V>::query_all create Map<K, T>::query_all Jan 3, 2023
@chipshort
Copy link
Collaborator

Nice idea.
I think a more generalized version with the semantics of range would be even more useful.

However, I don't think it is actually possible to implement this, since range internally depends on the range implementation provided by Storage and there is no equivalent for querying a range (WasmQuery::Raw only supports querying a single key)

@chipshort chipshort added the enhancement New feature or request label Jan 4, 2023
@0xForerunner
Copy link
Contributor Author

Yeah I don't think using range is possible, though I could be wrong. Either way being able to query the entire vec would be super useful as well!

@chipshort
Copy link
Collaborator

chipshort commented Jan 5, 2023

The problem is, there is no "entire vec" there. It's all saved individually in storage under the map's key concatenated with the key you put the values into (plus some length-prefixing). So, to my knowledge, the only way to get all the values out is using range or if you know all the keys and query them individually.

@chipshort chipshort added the wontfix This will not be worked on label Jan 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

2 participants