Skip to content

Commit c978566

Browse files
committed
chore: get account status per auction endpoint
1 parent 5825feb commit c978566

File tree

5 files changed

+63
-1
lines changed

5 files changed

+63
-1
lines changed

packages/sdk-ts/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@
328328
"@injectivelabs/grpc-web": "^0.0.1",
329329
"@injectivelabs/grpc-web-node-http-transport": "^0.0.2",
330330
"@injectivelabs/grpc-web-react-native-transport": "^0.0.2",
331-
"@injectivelabs/indexer-proto-ts-v2": "1.17.5",
331+
"@injectivelabs/indexer-proto-ts-v2": "1.17.6",
332332
"@injectivelabs/mito-proto-ts-v2": "1.17.3",
333333
"@injectivelabs/networks": "workspace:*",
334334
"@injectivelabs/olp-proto-ts-v2": "1.17.3",

packages/sdk-ts/src/client/indexer/grpc/IndexerGrpcAuctionApi.spec.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,4 +138,26 @@ describe('IndexerGrpcAuctionApi', () => {
138138
)
139139
}
140140
})
141+
142+
test('fetchAccountAuctionStatus', async () => {
143+
try {
144+
const response = await indexerGrpcAuctionApi.fetchAccountAuctionStatus({
145+
address: 'inj17gkuet8f6pssxd8nycm3qr9d9y699rupv6397z',
146+
})
147+
148+
expect(response).toBeDefined()
149+
expect(response).toEqual(
150+
expect.objectContaining<
151+
ReturnType<
152+
typeof IndexerGrpcAuctionTransformer.auctionAccountStatusResponseToAuctionAccountStatus
153+
>
154+
>(response),
155+
)
156+
} catch (e) {
157+
console.error(
158+
'IndexerGrpcAuctionApi.fetchAccountAuctionStatus => ' +
159+
(e as any).message,
160+
)
161+
}
162+
})
141163
})

packages/sdk-ts/src/client/indexer/grpc/IndexerGrpcAuctionApi.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,4 +145,31 @@ export class IndexerGrpcAuctionApi extends BaseIndexerGrpcConsumer {
145145
response,
146146
)
147147
}
148+
149+
async fetchAccountAuctionStatus({
150+
address,
151+
round = -1,
152+
}: {
153+
address: string
154+
round?: string | number
155+
}) {
156+
const request = InjectiveAuctionRpcPb.AuctionAccountStatusRequest.create()
157+
158+
if (round) {
159+
request.round = BigInt(round)
160+
}
161+
162+
if (address) {
163+
request.address = address
164+
}
165+
166+
const response = await this.executeGrpcCall<
167+
InjectiveAuctionRpcPb.AuctionAccountStatusRequest,
168+
InjectiveAuctionRpcPb.AuctionAccountStatusResponse
169+
>(request, this.client.auctionAccountStatus.bind(this.client))
170+
171+
return IndexerGrpcAuctionTransformer.auctionAccountStatusResponseToAuctionAccountStatus(
172+
response,
173+
)
174+
}
148175
}

packages/sdk-ts/src/client/indexer/transformers/IndexerGrpcAuctionTransformer.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import type {
1111
AuctionCoinPrices,
1212
IndexerAuctionBid,
1313
GrpcAccountAuctionV2,
14+
AccountAuctionStatus,
1415
GrpcIndexerAuctionBid,
1516
GrpcAuctionCoinPrices,
1617
} from '../types/auction.js'
@@ -154,4 +155,12 @@ export class IndexerGrpcAuctionTransformer {
154155
totalBurntInUsd: response.totalUsdValue,
155156
}
156157
}
158+
159+
static auctionAccountStatusResponseToAuctionAccountStatus(
160+
response: InjectiveAuctionRpcPb.AuctionAccountStatusResponse,
161+
): AccountAuctionStatus {
162+
return {
163+
status: response.status,
164+
}
165+
}
157166
}

packages/sdk-ts/src/client/indexer/types/auction.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,10 @@ export interface AuctionsStats {
6868
totalBurntInUsd: string
6969
}
7070

71+
export interface AccountAuctionStatus {
72+
status: string
73+
}
74+
7175
export type GrpcAuction = InjectiveAuctionRpcPb.Auction
7276
export type GrpcAuctionCoin = InjectiveAuctionRpcPb.Coin
7377
export type GrpcIndexerAuctionBid = InjectiveAuctionRpcPb.Bid

0 commit comments

Comments
 (0)