diff --git a/src/index.ts b/src/index.ts index 17047ff..2ad56a1 100644 --- a/src/index.ts +++ b/src/index.ts @@ -107,8 +107,8 @@ export class Registry { /** * Get records by attributes. */ - async queryRecords (attributes: { [key: string]: any }, all = false, refs = false) { - return this._client.queryRecords(attributes, all, refs); + async queryRecords (attributes: { [key: string]: any }, all = false, refs = false, limit?: number, offset?: number) { + return this._client.queryRecords(attributes, all, refs, limit, offset); } /** diff --git a/src/laconic-client.ts b/src/laconic-client.ts index 551393d..cb94ed4 100644 --- a/src/laconic-client.ts +++ b/src/laconic-client.ts @@ -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 { 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 { 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'; @@ -381,7 +381,7 @@ export class LaconicClient extends SigningStargateClient { } 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) { console.error(error); diff --git a/src/registry-client.ts b/src/registry-client.ts index 23c7776..2b64bf1 100644 --- a/src/registry-client.ts +++ b/src/registry-client.ts @@ -241,13 +241,13 @@ export class RegistryClient { /** * 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) { attributes = {}; } - const query = `query ($attributes: [KeyValueInput!], $all: Boolean) { - queryRecords(attributes: $attributes, all: $all) { + const query = `query ($attributes: [KeyValueInput!], $all: Boolean, $limit: Int, $offset: Int) { + queryRecords(attributes: $attributes, all: $all, limit: $limit, offset: $offset) { id names owners @@ -261,7 +261,9 @@ export class RegistryClient { const variables = { attributes: Util.toGQLAttributes(attributes), - all + all, + limit, + offset }; let result = (await this._graph(query)(variables)).queryRecords; diff --git a/src/types/cerc/registry/message.ts b/src/types/cerc/registry/message.ts index 5ba88a0..b21fe75 100644 --- a/src/types/cerc/registry/message.ts +++ b/src/types/cerc/registry/message.ts @@ -94,6 +94,8 @@ export const NAMESERVICE_ERRORS = [ 'Access denied.' ]; +export const ONBOARDING_DISABLED_ERROR = 'Validator onboarding is disabled'; + export interface MessageMsgReserveAuthority { name: string owner: string