Skip to content

Commit

Permalink
chore: leaderboard api supports account param
Browse files Browse the repository at this point in the history
  • Loading branch information
shane-moore committed Sep 17, 2024
1 parent c0d362f commit 2ead287
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 11 deletions.
2 changes: 1 addition & 1 deletion packages/sdk-ts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,10 @@ describe('IndexerGrpcArchiverApi', () => {
test('fetchPnlLeaderboard', async () => {
try {
const response = await indexerGrpcArchiverApi.fetchPnlLeaderboard({
startDate,
endDate,
limit,
endDate,
account,
startDate,
})

expect(response).toBeDefined()
Expand All @@ -107,9 +108,10 @@ describe('IndexerGrpcArchiverApi', () => {
test('fetchVolLeaderboard', async () => {
try {
const response = await indexerGrpcArchiverApi.fetchVolLeaderboard({
startDate,
endDate,
limit,
endDate,
account,
startDate,
})

expect(response).toBeDefined()
Expand All @@ -131,8 +133,9 @@ describe('IndexerGrpcArchiverApi', () => {
try {
const response =
await indexerGrpcArchiverApi.fetchPnlLeaderboardFixedResolution({
resolution,
limit,
account,
resolution,
})

expect(response).toBeDefined()
Expand All @@ -155,8 +158,9 @@ describe('IndexerGrpcArchiverApi', () => {
try {
const response =
await indexerGrpcArchiverApi.fetchVolLeaderboardFixedResolution({
resolution,
limit,
account,
resolution,
})

expect(response).toBeDefined()
Expand Down
24 changes: 24 additions & 0 deletions packages/sdk-ts/src/client/indexer/grpc/IndexerGrpcArchiverApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand All @@ -152,6 +154,10 @@ export class IndexerGrpcArchiverApi extends BaseGrpcConsumer {
request.limit = limit
}

if (account) {
request.account = account
}

try {
const response =
await this.retry<InjectiveArchiverRpc.PnlLeaderboardResponse>(() =>
Expand Down Expand Up @@ -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()

Expand All @@ -196,6 +204,10 @@ export class IndexerGrpcArchiverApi extends BaseGrpcConsumer {
request.limit = limit
}

if (account) {
request.account = account
}

try {
const response =
await this.retry<InjectiveArchiverRpc.VolLeaderboardResponse>(() =>
Expand Down Expand Up @@ -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()
Expand All @@ -238,6 +252,10 @@ export class IndexerGrpcArchiverApi extends BaseGrpcConsumer {
request.limit = limit
}

if (account) {
request.account = account
}

try {
const response =
await this.retry<InjectiveArchiverRpc.PnlLeaderboardFixedResolutionResponse>(
Expand Down Expand Up @@ -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()
Expand All @@ -280,6 +300,10 @@ export class IndexerGrpcArchiverApi extends BaseGrpcConsumer {
request.limit = limit
}

if (account) {
request.account = account
}

try {
const response =
await this.retry<InjectiveArchiverRpc.VolLeaderboardFixedResolutionResponse>(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,11 @@ export class IndexerGrpcArchiverTransformer {
leaders: response.leaders.map(
IndexerGrpcArchiverTransformer.grpcLeaderboardRowToLeaderboardRow,
),
accountRow: response.accountRow
? IndexerGrpcArchiverTransformer.grpcLeaderboardRowToLeaderboardRow(
response.accountRow,
)
: undefined,
}
}

Expand All @@ -108,6 +113,11 @@ export class IndexerGrpcArchiverTransformer {
leaders: response.leaders.map(
IndexerGrpcArchiverTransformer.grpcLeaderboardRowToLeaderboardRow,
),
accountRow: response.accountRow
? IndexerGrpcArchiverTransformer.grpcLeaderboardRowToLeaderboardRow(
response.accountRow,
)
: undefined,
}
}

Expand All @@ -120,6 +130,11 @@ export class IndexerGrpcArchiverTransformer {
leaders: response.leaders.map(
IndexerGrpcArchiverTransformer.grpcLeaderboardRowToLeaderboardRow,
),
accountRow: response.accountRow
? IndexerGrpcArchiverTransformer.grpcLeaderboardRowToLeaderboardRow(
response.accountRow,
)
: undefined,
}
}

Expand All @@ -132,6 +147,11 @@ export class IndexerGrpcArchiverTransformer {
leaders: response.leaders.map(
IndexerGrpcArchiverTransformer.grpcLeaderboardRowToLeaderboardRow,
),
accountRow: response.accountRow
? IndexerGrpcArchiverTransformer.grpcLeaderboardRowToLeaderboardRow(
response.accountRow,
)
: undefined,
}
}

Expand Down
2 changes: 2 additions & 0 deletions packages/sdk-ts/src/client/indexer/types/archiver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2219,10 +2219,10 @@
dependencies:
browser-headers "^0.4.1"

"@injectivelabs/[email protected].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/[email protected].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"
Expand Down

0 comments on commit 2ead287

Please sign in to comment.