Integrate pagination in queryRecords
This commit is contained in:
parent
f14fb7d9bb
commit
0f972e48c9
@ -107,8 +107,8 @@ export class Registry {
|
|||||||
/**
|
/**
|
||||||
* Get records by attributes.
|
* Get records by attributes.
|
||||||
*/
|
*/
|
||||||
async queryRecords (attributes: { [key: string]: any }, all = false, refs = false) {
|
async queryRecords (attributes: { [key: string]: any }, all = false, refs = false, limit?: number, offset?: number) {
|
||||||
return this._client.queryRecords(attributes, all, refs);
|
return this._client.queryRecords(attributes, all, refs, limit, offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -11,7 +11,7 @@ import { Comet38Client } from '@cosmjs/tendermint-rpc';
|
|||||||
|
|
||||||
import { MsgCancelBondEncodeObject, MsgCreateBondEncodeObject, MsgRefillBondEncodeObject, MsgWithdrawBondEncodeObject, bondTypes, typeUrlMsgCancelBond, typeUrlMsgCreateBond, typeUrlMsgRefillBond, typeUrlMsgWithdrawBond } from './types/cerc/bond/message';
|
import { MsgCancelBondEncodeObject, MsgCreateBondEncodeObject, MsgRefillBondEncodeObject, MsgWithdrawBondEncodeObject, bondTypes, typeUrlMsgCancelBond, typeUrlMsgCreateBond, typeUrlMsgRefillBond, typeUrlMsgWithdrawBond } from './types/cerc/bond/message';
|
||||||
import { Coin } from './proto/cosmos/base/v1beta1/coin';
|
import { Coin } from './proto/cosmos/base/v1beta1/coin';
|
||||||
import { MsgAssociateBondEncodeObject, MsgDeleteNameEncodeObject, MsgDissociateBondEncodeObject, MsgDissociateRecordsEncodeObject, MsgReassociateRecordsEncodeObject, MsgReserveAuthorityEncodeObject, MsgSetAuthorityBondEncodeObject, MsgSetNameEncodeObject, MsgSetRecordEncodeObject, registryTypes, typeUrlMsgAssociateBond, typeUrlMsgDeleteName, typeUrlMsgDissociateBond, typeUrlMsgDissociateRecords, typeUrlMsgReassociateRecords, typeUrlMsgReserveAuthority, typeUrlMsgSetAuthorityBond, typeUrlMsgSetName, typeUrlMsgSetRecord, NAMESERVICE_ERRORS } from './types/cerc/registry/message';
|
import { MsgAssociateBondEncodeObject, MsgDeleteNameEncodeObject, MsgDissociateBondEncodeObject, MsgDissociateRecordsEncodeObject, MsgReassociateRecordsEncodeObject, MsgReserveAuthorityEncodeObject, MsgSetAuthorityBondEncodeObject, MsgSetNameEncodeObject, MsgSetRecordEncodeObject, registryTypes, typeUrlMsgAssociateBond, typeUrlMsgDeleteName, typeUrlMsgDissociateBond, typeUrlMsgDissociateRecords, typeUrlMsgReassociateRecords, typeUrlMsgReserveAuthority, typeUrlMsgSetAuthorityBond, typeUrlMsgSetName, typeUrlMsgSetRecord, NAMESERVICE_ERRORS, ONBOARDING_DISABLED_ERROR } from './types/cerc/registry/message';
|
||||||
import { MsgCommitBidEncodeObject, MsgRevealBidEncodeObject, auctionTypes, typeUrlMsgCommitBid, typeUrlMsgRevealBid } from './types/cerc/auction/message';
|
import { MsgCommitBidEncodeObject, MsgRevealBidEncodeObject, auctionTypes, typeUrlMsgCommitBid, typeUrlMsgRevealBid } from './types/cerc/auction/message';
|
||||||
import { MsgOnboardParticipantEncodeObject, onboardingTypes, typeUrlMsgOnboardParticipant } from './types/cerc/onboarding/message';
|
import { MsgOnboardParticipantEncodeObject, onboardingTypes, typeUrlMsgOnboardParticipant } from './types/cerc/onboarding/message';
|
||||||
import { MsgAssociateBondResponse, MsgDeleteNameResponse, MsgDissociateBondResponse, MsgDissociateRecordsResponse, MsgReassociateRecordsResponse, MsgReserveAuthorityResponse, MsgSetAuthorityBondResponse, MsgSetNameResponse, MsgSetRecordResponse, Payload } from './proto/cerc/registry/v1/tx';
|
import { MsgAssociateBondResponse, MsgDeleteNameResponse, MsgDissociateBondResponse, MsgDissociateRecordsResponse, MsgReassociateRecordsResponse, MsgReserveAuthorityResponse, MsgSetAuthorityBondResponse, MsgSetNameResponse, MsgSetRecordResponse, Payload } from './proto/cerc/registry/v1/tx';
|
||||||
@ -381,7 +381,7 @@ export class LaconicClient extends SigningStargateClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
processWriteError (error: string) {
|
processWriteError (error: string) {
|
||||||
const errorMessage = NAMESERVICE_ERRORS.find(message => error.includes(message));
|
const errorMessage = NAMESERVICE_ERRORS.find(message => error.includes(message) || ONBOARDING_DISABLED_ERROR);
|
||||||
|
|
||||||
if (!errorMessage) {
|
if (!errorMessage) {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
|
@ -241,13 +241,13 @@ export class RegistryClient {
|
|||||||
/**
|
/**
|
||||||
* Get records by attributes.
|
* Get records by attributes.
|
||||||
*/
|
*/
|
||||||
async queryRecords (attributes: { [key: string]: any }, all = false, refs = false) {
|
async queryRecords (attributes: { [key: string]: any }, all = false, refs = false, limit?: number, offset?: number) {
|
||||||
if (!attributes) {
|
if (!attributes) {
|
||||||
attributes = {};
|
attributes = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
const query = `query ($attributes: [KeyValueInput!], $all: Boolean) {
|
const query = `query ($attributes: [KeyValueInput!], $all: Boolean, $limit: Int, $offset: Int) {
|
||||||
queryRecords(attributes: $attributes, all: $all) {
|
queryRecords(attributes: $attributes, all: $all, limit: $limit, offset: $offset) {
|
||||||
id
|
id
|
||||||
names
|
names
|
||||||
owners
|
owners
|
||||||
@ -261,7 +261,9 @@ export class RegistryClient {
|
|||||||
|
|
||||||
const variables = {
|
const variables = {
|
||||||
attributes: Util.toGQLAttributes(attributes),
|
attributes: Util.toGQLAttributes(attributes),
|
||||||
all
|
all,
|
||||||
|
limit,
|
||||||
|
offset
|
||||||
};
|
};
|
||||||
|
|
||||||
let result = (await this._graph(query)(variables)).queryRecords;
|
let result = (await this._graph(query)(variables)).queryRecords;
|
||||||
|
@ -94,6 +94,8 @@ export const NAMESERVICE_ERRORS = [
|
|||||||
'Access denied.'
|
'Access denied.'
|
||||||
];
|
];
|
||||||
|
|
||||||
|
export const ONBOARDING_DISABLED_ERROR = 'Validator onboarding is disabled';
|
||||||
|
|
||||||
export interface MessageMsgReserveAuthority {
|
export interface MessageMsgReserveAuthority {
|
||||||
name: string
|
name: string
|
||||||
owner: string
|
owner: string
|
||||||
|
Loading…
Reference in New Issue
Block a user