3 releases (stable)

2.3.0 Oct 18, 2023
2.2.0 Jul 9, 2023
0.1.0 Jul 3, 2023

#1860 in Magic Beans

Download history 132/week @ 2024-01-08 39/week @ 2024-01-15 28/week @ 2024-01-22 74/week @ 2024-01-29 192/week @ 2024-02-05 83/week @ 2024-02-12 72/week @ 2024-02-19 110/week @ 2024-02-26 93/week @ 2024-03-04 181/week @ 2024-03-11 258/week @ 2024-03-18 326/week @ 2024-03-25 218/week @ 2024-04-01 113/week @ 2024-04-08 143/week @ 2024-04-15 168/week @ 2024-04-22

665 downloads per month
Used in 18 crates (9 directly)

BSD-3-Clause

20KB
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_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_binary(&paginate_map(
        deps,
        &ITEMS,
        start_after,
        limit,
        cosmwasm_std::Order::Descending,
    )?)
}

Dependencies

~3.5–5.5MB
~117K SLoC