stargate: Clarify pagination type in createPagination

This commit is contained in:
willclarktech 2021-02-04 11:32:33 +00:00
parent c33bd47648
commit 90246140f8
No known key found for this signature in database
GPG Key ID: 551A86E2E398ADF7
2 changed files with 12 additions and 23 deletions

View File

@ -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<Uint8Array>;
}

View File

@ -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 {