diff --git a/packages/sdk-ts/package.json b/packages/sdk-ts/package.json index 83740bb8e..758594ad6 100644 --- a/packages/sdk-ts/package.json +++ b/packages/sdk-ts/package.json @@ -127,7 +127,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.13.3", + "@injectivelabs/indexer-proto-ts": "1.13.4", "@injectivelabs/mito-proto-ts": "1.13.2", "@injectivelabs/networks": "^1.14.34-beta.3", "@injectivelabs/olp-proto-ts": "1.13.1", diff --git a/packages/sdk-ts/src/client/indexer/grpc/IndexerGrpcAuctionApi.spec.ts b/packages/sdk-ts/src/client/indexer/grpc/IndexerGrpcAuctionApi.spec.ts index db8998dd0..0261233c1 100644 --- a/packages/sdk-ts/src/client/indexer/grpc/IndexerGrpcAuctionApi.spec.ts +++ b/packages/sdk-ts/src/client/indexer/grpc/IndexerGrpcAuctionApi.spec.ts @@ -47,4 +47,23 @@ describe('IndexerGrpcAuctionApi', () => { ) } }) + + test('fetchInjBurnt', async () => { + try { + const response = await indexerGrpcAuctionApi.fetchInjBurnt() + + expect(response).toBeDefined() + expect(response).toEqual( + expect.objectContaining< + ReturnType< + typeof IndexerGrpcAuctionTransformer.injBurntResponseToInjBurnt + > + >(response), + ) + } catch (e) { + console.error( + 'IndexerGrpcAuctionApi.fetchInjBurnt => ' + (e as any).message, + ) + } + }) }) diff --git a/packages/sdk-ts/src/client/indexer/grpc/IndexerGrpcAuctionApi.ts b/packages/sdk-ts/src/client/indexer/grpc/IndexerGrpcAuctionApi.ts index 20ea0539c..1fe00e779 100644 --- a/packages/sdk-ts/src/client/indexer/grpc/IndexerGrpcAuctionApi.ts +++ b/packages/sdk-ts/src/client/indexer/grpc/IndexerGrpcAuctionApi.ts @@ -83,4 +83,31 @@ export class IndexerGrpcAuctionApi extends BaseGrpcConsumer { }) } } + + async fetchInjBurnt() { + const request: InjectiveAuctionRpc.InjBurntEndpointRequest = {} + + try { + const response = + await this.retry(() => + this.client.InjBurntEndpoint(request), + ) + + return IndexerGrpcAuctionTransformer.injBurntResponseToInjBurnt(response) + } catch (e: unknown) { + if (e instanceof InjectiveAuctionRpc.GrpcWebError) { + throw new GrpcUnaryRequestException(new Error(e.toString()), { + code: e.code, + context: 'InjBurntEndpoint', + contextModule: this.module, + }) + } + + throw new GrpcUnaryRequestException(e as Error, { + code: UnspecifiedErrorCode, + context: 'InjBurntEndpoint', + contextModule: this.module, + }) + } + } } diff --git a/packages/sdk-ts/src/client/indexer/transformers/IndexerGrpcAuctionTransformer.ts b/packages/sdk-ts/src/client/indexer/transformers/IndexerGrpcAuctionTransformer.ts index bbb4c5d92..69fc7d159 100644 --- a/packages/sdk-ts/src/client/indexer/transformers/IndexerGrpcAuctionTransformer.ts +++ b/packages/sdk-ts/src/client/indexer/transformers/IndexerGrpcAuctionTransformer.ts @@ -1,10 +1,11 @@ import { InjectiveAuctionRpc } from '@injectivelabs/indexer-proto-ts' import { GrpcCoin } from '../../../types/index.js' import { - GrpcIndexerBid, - GrpcAuction, - IndexerBid, Auction, + IndexerBid, + GrpcAuction, + TotalInjBurnt, + GrpcIndexerBid, } from '../types/auction.js' import { Coin } from '@injectivelabs/ts-types' @@ -61,4 +62,10 @@ export class IndexerGrpcAuctionTransformer { updatedAt: parseInt(grpcAuction.updatedAt, 10), } } + + static injBurntResponseToInjBurnt( + response: InjectiveAuctionRpc.InjBurntEndpointResponse, + ): TotalInjBurnt { + return Number(response.totalInjBurnt) + } } diff --git a/packages/sdk-ts/src/client/indexer/types/auction.ts b/packages/sdk-ts/src/client/indexer/types/auction.ts index 18e8f63d8..f899be701 100644 --- a/packages/sdk-ts/src/client/indexer/types/auction.ts +++ b/packages/sdk-ts/src/client/indexer/types/auction.ts @@ -16,6 +16,8 @@ export interface Auction { updatedAt: number } +export type TotalInjBurnt = number + export type GrpcIndexerBid = InjectiveAuctionRpc.Bid export type GrpcAuction = InjectiveAuctionRpc.Auction export type StreamBidsResponse = InjectiveAuctionRpc.StreamBidsResponse diff --git a/yarn.lock b/yarn.lock index bb888aba9..d7a9a302b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2220,10 +2220,10 @@ dependencies: browser-headers "^0.4.1" -"@injectivelabs/indexer-proto-ts@1.13.3": - version "1.13.3" - resolved "https://registry.yarnpkg.com/@injectivelabs/indexer-proto-ts/-/indexer-proto-ts-1.13.3.tgz#9f1963a8bc87bd4d6f88262fb4a4552b2e6fa79e" - integrity sha512-rLesVPCARl+OC82vj063/pUawYu0ISty/2+xg6ya4Lwk6PDbXmtRvw8wpNP6K+pAsBOKaSkRnO4ThP5qbX+E6A== +"@injectivelabs/indexer-proto-ts@1.13.4": + version "1.13.4" + resolved "https://registry.yarnpkg.com/@injectivelabs/indexer-proto-ts/-/indexer-proto-ts-1.13.4.tgz#75f7d5caa23843b862fea6199975a88c5c88290e" + integrity sha512-4i7jc2LQd3KRziSUCjQOt2VfhRFlJVwuWDPjKnAJRYCnbaJeZRxtZOY+2kFNthXDV2dYJkoiu+mOUHuGvWUM7Q== dependencies: "@injectivelabs/grpc-web" "^0.0.1" google-protobuf "^3.14.0"