From 90246140f814bc53294642cbaf3d03aa6e0a4ed5 Mon Sep 17 00:00:00 2001 From: willclarktech Date: Thu, 4 Feb 2021 11:32:33 +0000 Subject: [PATCH] stargate: Clarify pagination type in createPagination --- packages/stargate/build/queries/utils.d.ts | 11 ++-------- packages/stargate/src/queries/utils.ts | 24 +++++++++------------- 2 files changed, 12 insertions(+), 23 deletions(-) diff --git a/packages/stargate/build/queries/utils.d.ts b/packages/stargate/build/queries/utils.d.ts index 7f09886e..99ed6f34 100644 --- a/packages/stargate/build/queries/utils.d.ts +++ b/packages/stargate/build/queries/utils.d.ts @@ -1,4 +1,4 @@ -import Long from "long"; +import { PageRequest } from "../codec/cosmos/base/query/v1beta1/pagination"; import { QueryClient } from "./queryclient"; /** * Takes a bech32 encoded address and returns the data part. The prefix is ignored and discarded. @@ -6,14 +6,7 @@ import { QueryClient } from "./queryclient"; * The result is typically 20 bytes long but not restricted to that. */ export declare function toAccAddress(address: string): Uint8Array; -export declare function createPagination( - paginationKey?: Uint8Array, -): { - readonly key: Uint8Array; - readonly offset: Long; - readonly limit: Long; - readonly countTotal: boolean; -}; +export declare function createPagination(paginationKey?: Uint8Array): PageRequest | undefined; interface Rpc { request(service: string, method: string, data: Uint8Array): Promise; } diff --git a/packages/stargate/src/queries/utils.ts b/packages/stargate/src/queries/utils.ts index 0bb7115f..afba2275 100644 --- a/packages/stargate/src/queries/utils.ts +++ b/packages/stargate/src/queries/utils.ts @@ -1,6 +1,7 @@ import { Bech32 } from "@cosmjs/encoding"; import Long from "long"; +import { PageRequest } from "../codec/cosmos/base/query/v1beta1/pagination"; import { QueryClient } from "./queryclient"; /** @@ -12,20 +13,15 @@ export function toAccAddress(address: string): Uint8Array { return Bech32.decode(address).data; } -export function createPagination( - paginationKey?: Uint8Array, -): { - readonly key: Uint8Array; - readonly offset: Long; - readonly limit: Long; - readonly countTotal: boolean; -} { - return { - key: paginationKey ?? new Uint8Array(), - offset: Long.fromNumber(0, true), - limit: Long.fromNumber(0, true), - countTotal: false, - }; +export function createPagination(paginationKey?: Uint8Array): PageRequest | undefined { + return paginationKey + ? { + key: paginationKey, + offset: Long.fromNumber(0, true), + limit: Long.fromNumber(0, true), + countTotal: false, + } + : undefined; } interface Rpc {