Skip to content

Commit d038a8a

Browse files
authored
Merge pull request #630 from InjectiveLabs/feat/tc-abacus-enhancements
feat/tc-abacus-enhancements
2 parents b5e0b2c + 81f1967 commit d038a8a

7 files changed

Lines changed: 2986 additions & 8480 deletions

File tree

packages/sdk-ts/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@
352352
"@injectivelabs/mito-proto-ts-v2": "1.17.3",
353353
"@injectivelabs/networks": "workspace:*",
354354
"@injectivelabs/olp-proto-ts-v2": "1.17.6",
355-
"@injectivelabs/tc-abacus-proto-ts-v2": "1.18.1",
355+
"@injectivelabs/tc-abacus-proto-ts-v2": "1.18.2",
356356
"@injectivelabs/ts-types": "workspace:*",
357357
"@injectivelabs/utils": "workspace:*",
358358
"@noble/curves": "catalog:",

packages/sdk-ts/src/client/tcAbacus/grpc/TcAbacusGrpcApi.spec.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,25 @@ const tcAbacusGrpcApi = new TcAbacusGrpcApi(
88
)
99

1010
describe('TcAbacusGrpcApi', () => {
11+
test('fetchCurrentEpoch', async () => {
12+
try {
13+
const response = await tcAbacusGrpcApi.fetchCurrentEpoch()
14+
15+
expect(response).toBeDefined()
16+
expect(response).toEqual(
17+
expect.objectContaining<
18+
ReturnType<
19+
typeof TcAbacusGrpcTransformer.grpcCurrentEpochToCurrentEpoch
20+
>
21+
>(response),
22+
)
23+
} catch (e) {
24+
console.error(
25+
'TcAbacusGrpcApi.fetchCurrentEpoch => ' + (e as any).message,
26+
)
27+
}
28+
})
29+
1130
test('fetchHealthCheck', async () => {
1231
try {
1332
const response = await tcAbacusGrpcApi.fetchHealthCheck()

packages/sdk-ts/src/client/tcAbacus/grpc/TcAbacusGrpcApi.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,17 @@ export class TcAbacusGrpcApi extends BaseGrpcConsumer {
1111
return this.initClient(InjectiveTCAbacusRPCClient)
1212
}
1313

14+
async fetchCurrentEpoch() {
15+
const request = TcAbacusPb.GetCurrentEpochRequest.create({})
16+
17+
const response = await this.executeGrpcCall<
18+
TcAbacusPb.GetCurrentEpochRequest,
19+
TcAbacusPb.GetCurrentEpochResponse
20+
>(request, this.client.getCurrentEpoch.bind(this.client))
21+
22+
return TcAbacusGrpcTransformer.grpcCurrentEpochToCurrentEpoch(response)
23+
}
24+
1425
async fetchHealthCheck() {
1526
const request = TcAbacusPb.HealthCheckRequest.create({})
1627

packages/sdk-ts/src/client/tcAbacus/grpc/transformers/index.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,23 @@ import type {
44
SnapshotPoints,
55
ReferrerInvitee,
66
HealthCheckResponse,
7+
CurrentEpochResponse,
78
AccountStatsResponse,
89
AccountPointsResponse,
910
ListReferrersResponse,
1011
AccountInviteesResponse,
1112
} from '../../types/index.js'
1213

1314
export class TcAbacusGrpcTransformer {
15+
static grpcCurrentEpochToCurrentEpoch(
16+
response: TcAbacusPb.GetCurrentEpochResponse,
17+
): CurrentEpochResponse {
18+
return {
19+
epochEnd: response.epochEnd,
20+
epochPoints: response.epochPoints,
21+
}
22+
}
23+
1424
static grpcHealthCheckToHealthCheck(
1525
response: TcAbacusPb.HealthCheckResponse,
1626
): HealthCheckResponse {
@@ -41,6 +51,7 @@ export class TcAbacusGrpcTransformer {
4151
updatedAt: response.updatedAt,
4252
nextCursor: response.nextCursor,
4353
totalPoints: response.totalPoints,
54+
totalReferralPoints: response.totalReferralPoints,
4455
snapshots: response.snapshots.map((snapshot) =>
4556
TcAbacusGrpcTransformer.grpcSnapshotPointsToSnapshotPoints(snapshot),
4657
),

packages/sdk-ts/src/client/tcAbacus/types/tcAbacus.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
export interface CurrentEpochResponse {
2+
epochEnd: string
3+
epochPoints: string
4+
}
5+
16
export interface HealthCheckResponse {
27
uptime: string
38
uptimeSeconds: number
@@ -17,6 +22,7 @@ export interface AccountPointsResponse {
1722
updatedAt: string
1823
totalPoints: string
1924
nextCursor?: string
25+
totalReferralPoints: string
2026
snapshots: SnapshotPoints[]
2127
}
2228

0 commit comments

Comments
 (0)