Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/sdk-ts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@
"@injectivelabs/mito-proto-ts-v2": "1.17.3",
"@injectivelabs/networks": "workspace:*",
"@injectivelabs/olp-proto-ts-v2": "1.17.6",
"@injectivelabs/tc-abacus-proto-ts-v2": "1.18.1",
"@injectivelabs/tc-abacus-proto-ts-v2": "1.18.2",
"@injectivelabs/ts-types": "workspace:*",
"@injectivelabs/utils": "workspace:*",
"@noble/curves": "catalog:",
Expand Down
19 changes: 19 additions & 0 deletions packages/sdk-ts/src/client/tcAbacus/grpc/TcAbacusGrpcApi.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,25 @@ const tcAbacusGrpcApi = new TcAbacusGrpcApi(
)

describe('TcAbacusGrpcApi', () => {
test('fetchCurrentEpoch', async () => {
try {
const response = await tcAbacusGrpcApi.fetchCurrentEpoch()

expect(response).toBeDefined()
expect(response).toEqual(
expect.objectContaining<
ReturnType<
typeof TcAbacusGrpcTransformer.grpcCurrentEpochToCurrentEpoch
>
>(response),
)
} catch (e) {
console.error(
'TcAbacusGrpcApi.fetchCurrentEpoch => ' + (e as any).message,
)
}
})

test('fetchHealthCheck', async () => {
try {
const response = await tcAbacusGrpcApi.fetchHealthCheck()
Expand Down
11 changes: 11 additions & 0 deletions packages/sdk-ts/src/client/tcAbacus/grpc/TcAbacusGrpcApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,17 @@ export class TcAbacusGrpcApi extends BaseGrpcConsumer {
return this.initClient(InjectiveTCAbacusRPCClient)
}

async fetchCurrentEpoch() {
const request = TcAbacusPb.GetCurrentEpochRequest.create({})

const response = await this.executeGrpcCall<
TcAbacusPb.GetCurrentEpochRequest,
TcAbacusPb.GetCurrentEpochResponse
>(request, this.client.getCurrentEpoch.bind(this.client))

return TcAbacusGrpcTransformer.grpcCurrentEpochToCurrentEpoch(response)
}

async fetchHealthCheck() {
const request = TcAbacusPb.HealthCheckRequest.create({})

Expand Down
11 changes: 11 additions & 0 deletions packages/sdk-ts/src/client/tcAbacus/grpc/transformers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,23 @@ import type {
SnapshotPoints,
ReferrerInvitee,
HealthCheckResponse,
CurrentEpochResponse,
AccountStatsResponse,
AccountPointsResponse,
ListReferrersResponse,
AccountInviteesResponse,
} from '../../types/index.js'

export class TcAbacusGrpcTransformer {
static grpcCurrentEpochToCurrentEpoch(
response: TcAbacusPb.GetCurrentEpochResponse,
): CurrentEpochResponse {
return {
epochEnd: response.epochEnd,
epochPoints: response.epochPoints,
}
}

static grpcHealthCheckToHealthCheck(
response: TcAbacusPb.HealthCheckResponse,
): HealthCheckResponse {
Expand Down Expand Up @@ -41,6 +51,7 @@ export class TcAbacusGrpcTransformer {
updatedAt: response.updatedAt,
nextCursor: response.nextCursor,
totalPoints: response.totalPoints,
totalReferralPoints: response.totalReferralPoints,
snapshots: response.snapshots.map((snapshot) =>
TcAbacusGrpcTransformer.grpcSnapshotPointsToSnapshotPoints(snapshot),
),
Expand Down
6 changes: 6 additions & 0 deletions packages/sdk-ts/src/client/tcAbacus/types/tcAbacus.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
export interface CurrentEpochResponse {
epochEnd: string
epochPoints: string
}

export interface HealthCheckResponse {
uptime: string
uptimeSeconds: number
Expand All @@ -17,6 +22,7 @@ export interface AccountPointsResponse {
updatedAt: string
totalPoints: string
nextCursor?: string
totalReferralPoints: string
snapshots: SnapshotPoints[]
}

Expand Down
Loading