Skip to content

Commit be1c7ca

Browse files
authored
Merge pull request #611 from InjectiveLabs/chore/auction-whitelist-new-endpoint
chore/auction-whitelist-new-endpoint
2 parents d63d0f3 + c978566 commit be1c7ca

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
@@ -140,4 +140,31 @@ export class IndexerGrpcAuctionApi extends BaseIndexerGrpcConsumer {
140140
response,
141141
)
142142
}
143+
144+
async fetchAccountAuctionStatus({
145+
address,
146+
round = -1,
147+
}: {
148+
address: string
149+
round?: string | number
150+
}) {
151+
const request = InjectiveAuctionRpcPb.AuctionAccountStatusRequest.create()
152+
153+
if (round) {
154+
request.round = BigInt(round)
155+
}
156+
157+
if (address) {
158+
request.address = address
159+
}
160+
161+
const response = await this.executeGrpcCall<
162+
InjectiveAuctionRpcPb.AuctionAccountStatusRequest,
163+
InjectiveAuctionRpcPb.AuctionAccountStatusResponse
164+
>(request, this.client.auctionAccountStatus.bind(this.client))
165+
166+
return IndexerGrpcAuctionTransformer.auctionAccountStatusResponseToAuctionAccountStatus(
167+
response,
168+
)
169+
}
143170
}

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)