From 2ead28797d01c99f92e1f3625a551c2546dc3185 Mon Sep 17 00:00:00 2001 From: shane-moore Date: Tue, 17 Sep 2024 08:31:21 -0700 Subject: [PATCH] chore: leaderboard api supports account param --- packages/sdk-ts/package.json | 2 +- .../grpc/IndexerGrpcArchiverApi.spec.ts | 16 ++++++++----- .../indexer/grpc/IndexerGrpcArchiverApi.ts | 24 +++++++++++++++++++ .../IndexerGrpcArchiverTransformer.ts | 20 ++++++++++++++++ .../src/client/indexer/types/archiver.ts | 2 ++ yarn.lock | 8 +++---- 6 files changed, 61 insertions(+), 11 deletions(-) diff --git a/packages/sdk-ts/package.json b/packages/sdk-ts/package.json index 6b03fb880..c82a16ec2 100644 --- a/packages/sdk-ts/package.json +++ b/packages/sdk-ts/package.json @@ -44,7 +44,7 @@ "@injectivelabs/grpc-web": "^0.0.1", "@injectivelabs/grpc-web-node-http-transport": "^0.0.2", "@injectivelabs/grpc-web-react-native-transport": "^0.0.2", - "@injectivelabs/indexer-proto-ts": "1.11.53", + "@injectivelabs/indexer-proto-ts": "1.11.54", "@injectivelabs/mito-proto-ts": "1.0.65", "@injectivelabs/networks": "^1.14.14", "@injectivelabs/test-utils": "^1.14.14", diff --git a/packages/sdk-ts/src/client/indexer/grpc/IndexerGrpcArchiverApi.spec.ts b/packages/sdk-ts/src/client/indexer/grpc/IndexerGrpcArchiverApi.spec.ts index c1cdfa94f..2fd796060 100644 --- a/packages/sdk-ts/src/client/indexer/grpc/IndexerGrpcArchiverApi.spec.ts +++ b/packages/sdk-ts/src/client/indexer/grpc/IndexerGrpcArchiverApi.spec.ts @@ -84,9 +84,10 @@ describe('IndexerGrpcArchiverApi', () => { test('fetchPnlLeaderboard', async () => { try { const response = await indexerGrpcArchiverApi.fetchPnlLeaderboard({ - startDate, - endDate, limit, + endDate, + account, + startDate, }) expect(response).toBeDefined() @@ -107,9 +108,10 @@ describe('IndexerGrpcArchiverApi', () => { test('fetchVolLeaderboard', async () => { try { const response = await indexerGrpcArchiverApi.fetchVolLeaderboard({ - startDate, - endDate, limit, + endDate, + account, + startDate, }) expect(response).toBeDefined() @@ -131,8 +133,9 @@ describe('IndexerGrpcArchiverApi', () => { try { const response = await indexerGrpcArchiverApi.fetchPnlLeaderboardFixedResolution({ - resolution, limit, + account, + resolution, }) expect(response).toBeDefined() @@ -155,8 +158,9 @@ describe('IndexerGrpcArchiverApi', () => { try { const response = await indexerGrpcArchiverApi.fetchVolLeaderboardFixedResolution({ - resolution, limit, + account, + resolution, }) expect(response).toBeDefined() diff --git a/packages/sdk-ts/src/client/indexer/grpc/IndexerGrpcArchiverApi.ts b/packages/sdk-ts/src/client/indexer/grpc/IndexerGrpcArchiverApi.ts index a3d8aa156..f367d57e1 100644 --- a/packages/sdk-ts/src/client/indexer/grpc/IndexerGrpcArchiverApi.ts +++ b/packages/sdk-ts/src/client/indexer/grpc/IndexerGrpcArchiverApi.ts @@ -138,10 +138,12 @@ export class IndexerGrpcArchiverApi extends BaseGrpcConsumer { startDate, endDate, limit, + account, }: { startDate: string endDate: string limit?: number + account?: string }) { const request = InjectiveArchiverRpc.PnlLeaderboardRequest.create() @@ -152,6 +154,10 @@ export class IndexerGrpcArchiverApi extends BaseGrpcConsumer { request.limit = limit } + if (account) { + request.account = account + } + try { const response = await this.retry(() => @@ -182,10 +188,12 @@ export class IndexerGrpcArchiverApi extends BaseGrpcConsumer { startDate, endDate, limit, + account, }: { startDate: string endDate: string limit?: number + account?: string }) { const request = InjectiveArchiverRpc.VolLeaderboardRequest.create() @@ -196,6 +204,10 @@ export class IndexerGrpcArchiverApi extends BaseGrpcConsumer { request.limit = limit } + if (account) { + request.account = account + } + try { const response = await this.retry(() => @@ -225,9 +237,11 @@ export class IndexerGrpcArchiverApi extends BaseGrpcConsumer { async fetchPnlLeaderboardFixedResolution({ resolution, limit, + account, }: { resolution: string limit?: number + account?: string }) { const request = InjectiveArchiverRpc.PnlLeaderboardFixedResolutionRequest.create() @@ -238,6 +252,10 @@ export class IndexerGrpcArchiverApi extends BaseGrpcConsumer { request.limit = limit } + if (account) { + request.account = account + } + try { const response = await this.retry( @@ -267,9 +285,11 @@ export class IndexerGrpcArchiverApi extends BaseGrpcConsumer { async fetchVolLeaderboardFixedResolution({ resolution, limit, + account, }: { resolution: string limit?: number + account?: string }) { const request = InjectiveArchiverRpc.VolLeaderboardFixedResolutionRequest.create() @@ -280,6 +300,10 @@ export class IndexerGrpcArchiverApi extends BaseGrpcConsumer { request.limit = limit } + if (account) { + request.account = account + } + try { const response = await this.retry( diff --git a/packages/sdk-ts/src/client/indexer/transformers/IndexerGrpcArchiverTransformer.ts b/packages/sdk-ts/src/client/indexer/transformers/IndexerGrpcArchiverTransformer.ts index 04cdaf0b3..8644be981 100644 --- a/packages/sdk-ts/src/client/indexer/transformers/IndexerGrpcArchiverTransformer.ts +++ b/packages/sdk-ts/src/client/indexer/transformers/IndexerGrpcArchiverTransformer.ts @@ -96,6 +96,11 @@ export class IndexerGrpcArchiverTransformer { leaders: response.leaders.map( IndexerGrpcArchiverTransformer.grpcLeaderboardRowToLeaderboardRow, ), + accountRow: response.accountRow + ? IndexerGrpcArchiverTransformer.grpcLeaderboardRowToLeaderboardRow( + response.accountRow, + ) + : undefined, } } @@ -108,6 +113,11 @@ export class IndexerGrpcArchiverTransformer { leaders: response.leaders.map( IndexerGrpcArchiverTransformer.grpcLeaderboardRowToLeaderboardRow, ), + accountRow: response.accountRow + ? IndexerGrpcArchiverTransformer.grpcLeaderboardRowToLeaderboardRow( + response.accountRow, + ) + : undefined, } } @@ -120,6 +130,11 @@ export class IndexerGrpcArchiverTransformer { leaders: response.leaders.map( IndexerGrpcArchiverTransformer.grpcLeaderboardRowToLeaderboardRow, ), + accountRow: response.accountRow + ? IndexerGrpcArchiverTransformer.grpcLeaderboardRowToLeaderboardRow( + response.accountRow, + ) + : undefined, } } @@ -132,6 +147,11 @@ export class IndexerGrpcArchiverTransformer { leaders: response.leaders.map( IndexerGrpcArchiverTransformer.grpcLeaderboardRowToLeaderboardRow, ), + accountRow: response.accountRow + ? IndexerGrpcArchiverTransformer.grpcLeaderboardRowToLeaderboardRow( + response.accountRow, + ) + : undefined, } } diff --git a/packages/sdk-ts/src/client/indexer/types/archiver.ts b/packages/sdk-ts/src/client/indexer/types/archiver.ts index e29eb49d4..06b577684 100644 --- a/packages/sdk-ts/src/client/indexer/types/archiver.ts +++ b/packages/sdk-ts/src/client/indexer/types/archiver.ts @@ -26,12 +26,14 @@ export interface PnlLeaderboard { firstDate: string lastDate: string leaders: LeaderboardRow[] + accountRow: LeaderboardRow | undefined } export interface VolLeaderboard { firstDate: string lastDate: string leaders: LeaderboardRow[] + accountRow: LeaderboardRow | undefined } export interface Holder { diff --git a/yarn.lock b/yarn.lock index 93d281edf..50992a466 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2219,10 +2219,10 @@ dependencies: browser-headers "^0.4.1" -"@injectivelabs/indexer-proto-ts@1.11.53": - version "1.11.53" - resolved "https://registry.yarnpkg.com/@injectivelabs/indexer-proto-ts/-/indexer-proto-ts-1.11.53.tgz#9dba45c5af0c719505090b47cc4cdcd17da0cb8c" - integrity sha512-hc67sPi5Pr0iZO2SLgsk43f+n7f1ZGkx82ux4kXtE61lTuHPRWfweel1zHQfo+bmnD8wO3MKD2TZWTeoWbsyhQ== +"@injectivelabs/indexer-proto-ts@1.11.54": + version "1.11.54" + resolved "https://registry.yarnpkg.com/@injectivelabs/indexer-proto-ts/-/indexer-proto-ts-1.11.54.tgz#ae2063909bb998da7fbf97acc141e9f2a64487fd" + integrity sha512-G73Fel2ylP5EDSSEcVvWXPq0UrxL9+g7WvZst4tN5fGCTClvA7MYcl2fzcVg+G2pX+aE0zKsGWnNEol8ZkZdBw== dependencies: "@injectivelabs/grpc-web" "^0.0.1" google-protobuf "^3.14.0"