Skip to content

Commit 742ced0

Browse files
authored
Merge pull request #1375 from crypto-com/fix/validator-api
Fix: New restriction on validator API
2 parents 38111df + 39bc6b9 commit 742ced0

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

src/service/rpc/ChainIndexingAPI.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ describe('Testing ChainIndexingApi', () => {
142142
it('should return estimated rewards for a user account, , apy = 10%, period = 12 Months', async () => {
143143
const nodeRpcService = ChainIndexingAPI.init('https://crypto.org/explorer/api/v1');
144144
moxios.wait(() => {
145-
const validatorListReq = moxios.requests.get('get', 'validators?limit=1000000');
145+
const validatorListReq = moxios.requests.get('get', 'validators?limit=1000');
146146
const accountInfoReq = moxios.requests.get(
147147
'get',
148148
'accounts/cro1gaf3jqqzvrxvgc4u4vr6x0tlf6kcm703zqa34a',
@@ -327,7 +327,7 @@ describe('Testing ChainIndexingApi', () => {
327327
it('should return estimated rewards for a user account, apy = 10%, period = 6 Months', async () => {
328328
const nodeRpcService = ChainIndexingAPI.init('https://crypto.org/explorer/api/v1');
329329
moxios.wait(() => {
330-
const validatorListReq = moxios.requests.get('get', 'validators?limit=1000000');
330+
const validatorListReq = moxios.requests.get('get', 'validators?limit=1000');
331331
const accountInfoReq = moxios.requests.get(
332332
'get',
333333
'accounts/cro1gaf3jqqzvrxvgc4u4vr6x0tlf6kcm703zqa34a',

src/service/rpc/ChainIndexingAPI.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ import { croNftApi, MintByCDCRequest } from './NftApi';
3535
import { splitToChunks } from '../../utils/utils';
3636
import { UserAsset } from '../../models/UserAsset';
3737

38+
const VALIDATOR_FETCH_LIMIT = 1000;
39+
3840
export interface IChainIndexingAPI {
3941
fetchAllTransferTransactions(
4042
baseAssetSymbol: string,
@@ -167,7 +169,7 @@ export class ChainIndexingAPI implements IChainIndexingAPI {
167169
const transferListResponse = await this.axiosClient.get<TransferListResponse>(
168170
`/accounts/${address}/messages?order=height.desc&filter.msgType=${msgType.join(
169171
',',
170-
)}&limit=1000`,
172+
)}&limit=${VALIDATOR_FETCH_LIMIT}`,
171173
);
172174

173175
function getStatus(transfer: TransferResult) {
@@ -459,7 +461,7 @@ export class ChainIndexingAPI implements IChainIndexingAPI {
459461

460462
private async getValidatorDetails(validatorAddr: string) {
461463
const validatorList = await this.axiosClient.get<ValidatorListResponse>(
462-
'validators?limit=1000000',
464+
`validators?limit=${VALIDATOR_FETCH_LIMIT}`,
463465
);
464466

465467
if (validatorList.data.pagination.total_page > 1) {
@@ -481,9 +483,8 @@ export class ChainIndexingAPI implements IChainIndexingAPI {
481483

482484
public async getValidatorsDetail(validatorAddrList: string[]) {
483485
const recentBlocks = '100';
484-
const limit = '10000';
485486
const validatorList = await this.axiosClient.get<ValidatorListResponse>(
486-
`validators?recentBlocks=${recentBlocks}&limit=${limit}`,
487+
`validators?recentBlocks=${recentBlocks}&limit=${VALIDATOR_FETCH_LIMIT}`,
487488
);
488489

489490
if (validatorList.data.pagination.total_page > 1) {
@@ -501,7 +502,7 @@ export class ChainIndexingAPI implements IChainIndexingAPI {
501502

502503
public async getValidatorsAverageApy(validatorAddrList: string[]) {
503504
const validatorList = await this.axiosClient.get<ValidatorListResponse>(
504-
'validators?limit=1000000',
505+
`validators?limit=${VALIDATOR_FETCH_LIMIT}`,
505506
);
506507

507508
if (validatorList.data.pagination.total_page > 1) {

0 commit comments

Comments
 (0)