8 releases (stable)

2.6.0 Nov 7, 2024
2.5.0 Oct 31, 2024
2.4.2 Jul 22, 2024
2.3.0 Oct 18, 2023
0.1.0 Jul 3, 2023

#3 in #paginate

Download history 69/week @ 2024-08-24 98/week @ 2024-08-31 286/week @ 2024-09-07 182/week @ 2024-09-14 236/week @ 2024-09-21 115/week @ 2024-09-28 90/week @ 2024-10-05 480/week @ 2024-10-12 187/week @ 2024-10-19 602/week @ 2024-10-26 503/week @ 2024-11-02 171/week @ 2024-11-09 114/week @ 2024-11-16 142/week @ 2024-11-23 113/week @ 2024-11-30 181/week @ 2024-12-07

581 downloads per month
Used in 12 crates (5 directly)

BSD-3-Clause

21KB
437 lines

CosmWasm Map Pagination

This package provides generic convienence methods for paginating keys and values in a CosmWasm Map or SnapshotMap. If you use these methods to paginate the maps in your contract you may make larry0x happy.

Example

Given a map like:

use cw_storage_plus::Map;

pub const ITEMS: Map<String, String> = Map::new("items");

You can use this package to write a query to list it's contents like:

use cosmwasm_std::{Deps, Binary, to_json_binary, StdResult};
use cw_storage_plus::Map;
use cw_paginate_storage::paginate_map;                         

pub const ITEMS: Map<String, String> = Map::new("items");

pub fn query_list_items(
    deps: Deps,
    start_after: Option<String>,
    limit: Option<u32>,
) -> StdResult<Binary> {
    to_json_binary(&paginate_map(
        deps,
        &ITEMS,
        start_after,
        limit,
        cosmwasm_std::Order::Descending,
    )?)
}

Dependencies

~5–6.5MB
~143K SLoC