CosmWasm / cw-plus

Production Quality contracts under open source licenses

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

CW20 All accounts query sorting issue

haris8103 opened this issue · comments

Hi team,

Hope you are doing well, I am a beginner in rust and cosmwasm. I am facing an issue in querying all accounts they are not in sorted manner and also there are repeating accounts in query as i am using cw20-base-0.13.4 for this query to being called for cw20 token contract.
Kindly look into it and suggest. Your prompt response will be highly appreciated.

For the reference i have attached the code from cw20-base-0.13.4/src/enumerable.rs .

pub fn query_all_accounts(
    deps: Deps,
    start_after: Option<String>,
    limit: Option<u32>,
) -> StdResult<AllAccountsResponse> {
    let limit = limit.unwrap_or(DEFAULT_LIMIT).min(MAX_LIMIT) as usize;
    let start = start_after.map(|s| Bound::ExclusiveRaw(s.into()));

    let accounts = BALANCES
        .keys(deps.storage, start, None, Order::Ascending)
        .take(limit)
        .map(|item| item.map(Into::into))
        .collect::<StdResult<_>>()?;

    Ok(AllAccountsResponse { accounts })
}

Regards,
Haris.