Improve some pagination code
This commit is contained in:
@@ -85,10 +85,10 @@ export function setupWasmExtension(base: QueryClient): WasmExtension {
|
||||
return queryService.Code(request);
|
||||
},
|
||||
listContractsByCodeId: async (id: number, paginationKey?: Uint8Array) => {
|
||||
const pagination = {
|
||||
const request = {
|
||||
codeId: Long.fromNumber(id),
|
||||
pagination: createPagination(paginationKey),
|
||||
};
|
||||
const request = { ...pagination, codeId: Long.fromNumber(id) };
|
||||
return queryService.ContractsByCode(request);
|
||||
},
|
||||
getContractInfo: async (address: string) => {
|
||||
@@ -97,18 +97,18 @@ export function setupWasmExtension(base: QueryClient): WasmExtension {
|
||||
},
|
||||
|
||||
getContractCodeHistory: async (address: string, paginationKey?: Uint8Array) => {
|
||||
const pagination = {
|
||||
const request = {
|
||||
address: address,
|
||||
pagination: createPagination(paginationKey),
|
||||
};
|
||||
const request = { ...pagination, address: address };
|
||||
return queryService.ContractHistory(request);
|
||||
},
|
||||
|
||||
getAllContractState: async (address: string, paginationKey?: Uint8Array) => {
|
||||
const pagination = {
|
||||
const request = {
|
||||
address: address,
|
||||
pagination: createPagination(paginationKey),
|
||||
};
|
||||
const request = { ...pagination, address: address };
|
||||
return queryService.AllContractState(request);
|
||||
},
|
||||
|
||||
|
||||
@@ -14,6 +14,13 @@ export function toAccAddress(address: string): Uint8Array {
|
||||
return Bech32.decode(address).data;
|
||||
}
|
||||
|
||||
/**
|
||||
* If paginationKey is set, return a `PageRequest` with the given key.
|
||||
* If paginationKey is unset, return `undefined`.
|
||||
*
|
||||
* Use this with a query response's pagination next key to
|
||||
* request the next page.
|
||||
*/
|
||||
export function createPagination(paginationKey?: Uint8Array): PageRequest | undefined {
|
||||
return paginationKey
|
||||
? {
|
||||
|
||||
Reference in New Issue
Block a user