fix address range functions
@@ -11,32 +11,20 @@ pub fn maybe_addr(api: &dyn Api, human: Option<String>) -> StdResult<Option<Addr
}
// this will set the first key after the provided key, by appending a 0 byte
-pub fn calc_range_start_human(
- api: &dyn Api,
- start_after: Option<Addr>,
-) -> StdResult<Option<Vec<u8>>> {
- match start_after {
- Some(human) => {
- let mut v: Vec<u8> = api.addr_canonicalize(human.as_ref())?.0.into();
+pub fn calc_range_start(start_after: Option<Addr>) -> Option<Vec<u8>> {
+ start_after.map(|addr| {
+ let mut v: Vec<u8> = addr.as_ref().into();
v.push(0);
- Ok(Some(v))
- }
- None => Ok(None),
- }
+ v
+ })
}
// set the end to the canonicalized format (used for Order::Descending)
-pub fn calc_range_end_human(api: &dyn Api, end_before: Option<Addr>) -> StdResult<Option<Vec<u8>>> {
- match end_before {
- Some(human) => {
- let v: Vec<u8> = api.addr_canonicalize(human.as_ref())?.into();
- Ok(Some(v))
- }
- None => Ok(None),
- }
+pub fn calc_range_end(end_before: Option<Addr>) -> Option<Vec<u8>> {
+ end_before.map(|addr| addr.as_ref().into())
}
-// this will set the first key after the provided key, by appending a 1 byte
+// this will set the first key after the provided key, by appending a 0 byte
pub fn calc_range_start_string(start_after: Option<String>) -> Option<Vec<u8>> {
start_after.map(|token_id| {
let mut v: Vec<u8> = token_id.into_bytes();
