pylon_utils/
range.rs

1use cosmwasm_std::CanonicalAddr;
2
3// this will set the first key after the provided key, by appending a 1 byte
4pub fn calc_range_start(start_after: Option<u64>) -> Option<Vec<u8>> {
5    start_after.map(|id| {
6        let mut v = id.to_be_bytes().to_vec();
7        v.push(1);
8        v
9    })
10}
11
12// this will set the first key after the provided key, by appending a 1 byte
13pub fn calc_range_end(start_after: Option<u64>) -> Option<Vec<u8>> {
14    start_after.map(|id| id.to_be_bytes().to_vec())
15}
16
17// this will set the first key after the provided key, by appending a 1 byte
18pub fn calc_range_start_addr(start_after: Option<CanonicalAddr>) -> Option<Vec<u8>> {
19    start_after.map(|address| {
20        let mut v = address.as_slice().to_vec();
21        v.push(1);
22        v
23    })
24}
25
26// this will set the first key after the provided key, by appending a 1 byte
27pub fn calc_range_end_addr(start_after: Option<CanonicalAddr>) -> Option<Vec<u8>> {
28    start_after.map(|address| address.as_slice().to_vec())
29}