Skip to content

Commit

Permalink
chore: total inj burnt
Browse files Browse the repository at this point in the history
  • Loading branch information
shane-moore committed Dec 19, 2024
1 parent d2a01a5 commit 159f844
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 8 deletions.
2 changes: 1 addition & 1 deletion packages/sdk-ts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
}
})
})
27 changes: 27 additions & 0 deletions packages/sdk-ts/src/client/indexer/grpc/IndexerGrpcAuctionApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,31 @@ export class IndexerGrpcAuctionApi extends BaseGrpcConsumer {
})
}
}

async fetchInjBurnt() {
const request: InjectiveAuctionRpc.InjBurntEndpointRequest = {}

try {
const response =
await this.retry<InjectiveAuctionRpc.InjBurntEndpointResponse>(() =>
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,
})
}
}
}
Original file line number Diff line number Diff line change
@@ -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'

Expand Down Expand Up @@ -61,4 +62,10 @@ export class IndexerGrpcAuctionTransformer {
updatedAt: parseInt(grpcAuction.updatedAt, 10),
}
}

static injBurntResponseToInjBurnt(
response: InjectiveAuctionRpc.InjBurntEndpointResponse,
): TotalInjBurnt {
return Number(response.totalInjBurnt)
}
}
2 changes: 2 additions & 0 deletions packages/sdk-ts/src/client/indexer/types/auction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2220,10 +2220,10 @@
dependencies:
browser-headers "^0.4.1"

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

0 comments on commit 159f844

Please sign in to comment.