-
Notifications
You must be signed in to change notification settings - Fork 204
Feat: rfq #615
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Feat: rfq #615
Changes from all commits
10bc944
f568ea6
cbd300f
4b25e10
3d4d418
bddf73c
10c6284
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,86 @@ | ||
| import { Network, getNetworkEndpoints } from '@injectivelabs/networks' | ||
| import { IndexerGrpcRFQApi } from './IndexerGrpcRfqApi.js' | ||
| import type { IndexerGrpcRfqTransformer } from '../transformers/index.js' | ||
|
|
||
| const endpoints = getNetworkEndpoints(Network.Mainnet) | ||
| const indexerGrpcRfqApi = new IndexerGrpcRFQApi(endpoints.indexer) | ||
|
|
||
| describe('IndexerGrpcRFQApi', () => { | ||
| test('submitRequest', async () => { | ||
| try { | ||
| const response = await indexerGrpcRfqApi.submitRequest({ | ||
| direction: 'LONG', | ||
| status: 'PENDING', | ||
| rfqId: BigInt(1717000000), | ||
| height: BigInt(1717000000), | ||
| expiry: BigInt(1717000000), | ||
| margin: '1000000000000000000', | ||
| updatedAt: BigInt(1717000000), | ||
| createdAt: BigInt(1717000000), | ||
| quantity: '1000000000000000000', | ||
| worstPrice: '1000000000000000000', | ||
| transactionTime: BigInt(1717000000), | ||
| marketId: 'inj1qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqe2hm49', | ||
| requestAddress: 'inj1qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqe2hm49', | ||
| }) | ||
|
|
||
| expect(response).toBeDefined() | ||
| expect(response).toEqual( | ||
| expect.objectContaining<{ status: string }>(response), | ||
| ) | ||
| } catch (e) { | ||
| console.error('IndexerGrpcRFQApi.submitRequest => ' + (e as any).message) | ||
| } | ||
| }) | ||
|
Comment on lines
+9
to
+34
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Tests silently pass on API failures due to try/catch pattern. Wrapping test logic in try/catch and only logging errors means tests will pass even when the API calls fail. This defeats the purpose of testing. Additionally, the assertion 🧪 Recommended test patternEither let exceptions propagate (remove try/catch) or explicitly fail: test('submitRequest', async () => {
const response = await indexerGrpcRfqApi.submitRequest({
// ... params
})
expect(response).toBeDefined()
expect(response).toHaveProperty('status')
expect(typeof response.status).toBe('string')
})If network failures are expected and tests should be skipped in CI, consider marking them as integration tests or using conditional skipping. 🤖 Prompt for AI Agents |
||
|
|
||
| test('submitQuote', async () => { | ||
| try { | ||
| const response = await indexerGrpcRfqApi.submitRequest({ | ||
| direction: 'LONG', | ||
| status: 'PENDING', | ||
| rfqId: BigInt(1717000000), | ||
| height: BigInt(1717000000), | ||
| expiry: BigInt(1717000000), | ||
| margin: '1000000000000000000', | ||
| updatedAt: BigInt(1717000000), | ||
| createdAt: BigInt(1717000000), | ||
| quantity: '1000000000000000000', | ||
| worstPrice: '1000000000000000000', | ||
| transactionTime: BigInt(1717000000), | ||
| marketId: 'inj1qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqe2hm49', | ||
| requestAddress: 'inj1qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqe2hm49', | ||
| }) | ||
|
|
||
| expect(response).toBeDefined() | ||
| expect(response).toEqual( | ||
| expect.objectContaining<{ status: string }>(response), | ||
| ) | ||
| } catch (e) { | ||
| console.error('IndexerGrpcRFQApi.submitRequest => ' + (e as any).message) | ||
| } | ||
| }) | ||
|
Comment on lines
+36
to
+61
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Copy-paste error: The test named 🐛 Proposed fix test('submitQuote', async () => {
try {
- const response = await indexerGrpcRfqApi.submitRequest({
- direction: 'LONG',
- status: 'PENDING',
- rfqId: BigInt(1717000000),
- height: BigInt(1717000000),
- expiry: BigInt(1717000000),
- margin: '1000000000000000000',
- updatedAt: BigInt(1717000000),
- createdAt: BigInt(1717000000),
- quantity: '1000000000000000000',
- worstPrice: '1000000000000000000',
- transactionTime: BigInt(1717000000),
- marketId: 'inj1qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqe2hm49',
- requestAddress: 'inj1qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqe2hm49',
+ const response = await indexerGrpcRfqApi.submitQuote({
+ // Use appropriate quote payload fields
})
expect(response).toBeDefined()
expect(response).toEqual(
expect.objectContaining<{ status: string }>(response),
)
} catch (e) {
- console.error('IndexerGrpcRFQApi.submitRequest => ' + (e as any).message)
+ console.error('IndexerGrpcRFQApi.submitQuote => ' + (e as any).message)
}
})🤖 Prompt for AI Agents |
||
| test('fetchSettlements', async () => { | ||
| try { | ||
| const response = await indexerGrpcRfqApi.fetchSettlements({ | ||
| addresses: ['inj1qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqe2hm49'], | ||
| pagination: { | ||
| skip: 0, | ||
| limit: 10, | ||
| }, | ||
| }) | ||
|
|
||
| expect(response).toBeDefined() | ||
| expect(response).toEqual( | ||
| expect.objectContaining< | ||
| ReturnType< | ||
| typeof IndexerGrpcRfqTransformer.listSettlementsResponseToSettlements | ||
| > | ||
| >(response), | ||
| ) | ||
| } catch (e) { | ||
| console.error( | ||
| 'IndexerGrpcRFQApi.fetchSettlements => ' + (e as any).message, | ||
| ) | ||
| } | ||
| }) | ||
| }) | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,264 @@ | ||
| import * as InjectiveRFQExchangeRpcPb from '@injectivelabs/indexer-proto-ts-v2/generated/injective_rfqrpc_pb' | ||
| import { InjectiveRFQRPCClient } from '@injectivelabs/indexer-proto-ts-v2/generated/injective_rfqrpc_pb.client' | ||
| import { IndexerModule } from '../types/index.js' | ||
| import { IndexerGrpcRfqTransformer } from '../transformers/index.js' | ||
| import BaseIndexerGrpcConsumer from '../../base/BaseIndexerGrpcConsumer.js' | ||
| import type { PaginationOption } from '../../../types/index.js' | ||
|
|
||
| /** | ||
| * @category Indexer Grpc API | ||
| */ | ||
| export class IndexerGrpcRFQApi extends BaseIndexerGrpcConsumer { | ||
| protected module: string = IndexerModule.RFQ | ||
|
|
||
| private get client() { | ||
| return this.initClient(InjectiveRFQRPCClient) | ||
| } | ||
|
Comment on lines
+11
to
+16
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: # First, let's check the actual file content
cat -n packages/sdk-ts/src/client/indexer/grpc/IndexerGrpcRfqApi.tsRepository: InjectiveLabs/injective-ts Length of output: 7465 🏁 Script executed: # Check for transformer methods
cat -n packages/sdk-ts/src/client/indexer/grpc/IndexerGrpcRfqTransformer.ts | head -100Repository: InjectiveLabs/injective-ts Length of output: 170 🏁 Script executed: # Search for any references to getOpenRequests and getPendingQuotes in the codebase
rg "getOpenRequests|getPendingQuotes" --type ts -A 2 -B 2Repository: InjectiveLabs/injective-ts Length of output: 52 🏁 Script executed: # Find all transformer files
fd -t f "*[Tt]ransformer*" packages/sdk-ts/src/client/indexer/Repository: InjectiveLabs/injective-ts Length of output: 365 🏁 Script executed: # Search for the transformer methods mentioned in the review
rg "openRequestsResponseToOpenRequests|pendingQuotesResponseToPendingQuotes" --type tsRepository: InjectiveLabs/injective-ts Length of output: 315 🏁 Script executed: # Search for any RFQ transformer imports or references
rg "RfqTransformer" --type ts -A 2 -B 2Repository: InjectiveLabs/injective-ts Length of output: 8975 🏁 Script executed: # Check what methods are available on the gRPC client by checking the proto definitions
rg "getOpenRequests|getPendingQuotes|openRequests|pendingQuotes" --type ts -iRepository: InjectiveLabs/injective-ts Length of output: 1175 🏁 Script executed: # View the transformer methods
cat -n packages/sdk-ts/src/client/indexer/transformers/IndexerGrpcRfqTransformer.ts | grep -A 10 "openRequestsResponseToOpenRequests\|pendingQuotesResponseToPendingQuotes"Repository: InjectiveLabs/injective-ts Length of output: 787 🏁 Script executed: # Check the InjectiveRFQRPCClient definition to see what methods are available
rg "InjectiveRFQRPCClient|getOpenRequests|getPendingQuotes" --type ts -i --max-count=50Repository: InjectiveLabs/injective-ts Length of output: 1427 🏁 Script executed: # Look for the proto client definition file
fd -name "*rfqrpc*client*" --type fRepository: InjectiveLabs/injective-ts Length of output: 300 🏁 Script executed: # Search for usages of this.client to see what methods are called on it
rg "this\.client\." packages/sdk-ts/src/client/indexer/grpc/IndexerGrpcRfqApi.tsRepository: InjectiveLabs/injective-ts Length of output: 248 🏁 Script executed: # Find all proto-related files that might have the client definition
find . -type f -name "*rfqrpc*" 2>/dev/null | head -20Repository: InjectiveLabs/injective-ts Length of output: 52 🏁 Script executed: # Check if getOpenRequests or getPendingQuotes methods are used anywhere in the codebase
rg "\.(getOpenRequests|getPendingQuotes)" --type tsRepository: InjectiveLabs/injective-ts Length of output: 52 🏁 Script executed: # Look at the IndexerGrpcRfqStreamV2 to see if it uses any open requests or pending quotes methods
cat -n packages/sdk-ts/src/client/indexer/grpc_stream/streamV2/IndexerGrpcRfqStreamV2.ts | head -150Repository: InjectiveLabs/injective-ts Length of output: 4940 🏁 Script executed: # Check the transformer file to see what it imports and all its methods
cat -n packages/sdk-ts/src/client/indexer/transformers/IndexerGrpcRfqTransformer.ts | head -120Repository: InjectiveLabs/injective-ts Length of output: 4167 🏁 Script executed: # Look for any tests or usage of openRequestsResponseToOpenRequests or pendingQuotesResponseToPendingQuotes
rg "openRequestsResponseToOpenRequests|pendingQuotesResponseToPendingQuotes" --type ts -B 3 -A 3Repository: InjectiveLabs/injective-ts Length of output: 1462 🏁 Script executed: # Check if there are any similar RFQ API classes or if this pattern exists elsewhere
rg "async fetch.*Response" packages/sdk-ts/src/client/indexer/grpc/ --type ts -A 5Repository: InjectiveLabs/injective-ts Length of output: 52 🏁 Script executed: # Check the types file to see if OpenRequestsResponse and PendingQuotesResponse are defined
cat -n packages/sdk-ts/src/client/indexer/types/rfq.tsRepository: InjectiveLabs/injective-ts Length of output: 1993 🏁 Script executed: # Look at other similar indexer grpc API files to understand the pattern
ls -la packages/sdk-ts/src/client/indexer/grpc/ | grep -i "IndexerGrpc.*Api"Repository: InjectiveLabs/injective-ts Length of output: 2873 🏁 Script executed: # Check if there's any documentation or interfaces that hint at these methods
rg "GetOpenRequestsRequest|GetPendingQuotesRequest" --type tsRepository: InjectiveLabs/injective-ts Length of output: 52 🏁 Script executed: # Check the spec file to see if there are any tests or hints about these methods
cat -n packages/sdk-ts/src/client/indexer/grpc/IndexerGrpcRfqApi.spec.tsRepository: InjectiveLabs/injective-ts Length of output: 3504 🏁 Script executed: # Check if GetOpenRequestsRequest and GetPendingQuotesRequest exist in the proto definitions
rg "GetOpenRequestsRequest|GetPendingQuotesRequest|getOpenRequests|getPendingQuotes" --type ts -iRepository: InjectiveLabs/injective-ts Length of output: 338 🏁 Script executed: # Check if the proto types are exported and available
rg "export.*GetOpenRequestsResponse|export.*GetPendingQuotesResponse" --type tsRepository: InjectiveLabs/injective-ts Length of output: 52 🏁 Script executed: # Look at what the InjectiveRFQRpcPb exports by checking imports
rg "InjectiveRFQRpcPb\." packages/sdk-ts/src/client/indexer/transformers/IndexerGrpcRfqTransformer.tsRepository: InjectiveLabs/injective-ts Length of output: 240 🏁 Script executed: # Search for any pattern showing these proto types being used
rg "GetOpenRequestsResponse|GetPendingQuotesResponse" --type ts -B 2 -A 2Repository: InjectiveLabs/injective-ts Length of output: 1134 🏁 Script executed: # Check if there's any documentation or PR history about these methods
rg "openRequests|pendingQuotes" --type ts -iRepository: InjectiveLabs/injective-ts Length of output: 1175 🏁 Script executed: # Look at similar API patterns to understand the structure better
cat -n packages/sdk-ts/src/client/indexer/grpc/IndexerGrpcSpotApi.ts | head -100Repository: InjectiveLabs/injective-ts Length of output: 3643 🏁 Script executed: # Let's check the complete IndexerGrpcRfqApi.ts to make sure there are no other methods
wc -l packages/sdk-ts/src/client/indexer/grpc/IndexerGrpcRfqApi.tsRepository: InjectiveLabs/injective-ts Length of output: 134 🏁 Script executed: # View the entire file to verify no other methods exist
tail -n 50 packages/sdk-ts/src/client/indexer/grpc/IndexerGrpcRfqApi.tsRepository: InjectiveLabs/injective-ts Length of output: 1378 🏁 Script executed: # Check if there are any imports or references to getOpenRequests or getPendingQuotes anywhere
rg "\.getOpenRequests|\.getPendingQuotes" --type tsRepository: InjectiveLabs/injective-ts Length of output: 52 Missing The Suggested implementationasync fetchOpenRequests() {
const request = InjectiveRFQExchangeRpcPb.GetOpenRequestsRequest.create()
const response = await this.executeGrpcCall<
InjectiveRFQExchangeRpcPb.GetOpenRequestsRequest,
InjectiveRFQExchangeRpcPb.GetOpenRequestsResponse
>(request, this.client.getOpenRequests.bind(this.client))
return IndexerGrpcRfqTransformer.openRequestsResponseToOpenRequests(response)
}
async fetchPendingQuotes() {
const request = InjectiveRFQExchangeRpcPb.GetPendingQuotesRequest.create()
const response = await this.executeGrpcCall<
InjectiveRFQExchangeRpcPb.GetPendingQuotesRequest,
InjectiveRFQExchangeRpcPb.GetPendingQuotesResponse
>(request, this.client.getPendingQuotes.bind(this.client))
return IndexerGrpcRfqTransformer.pendingQuotesResponseToPendingQuotes(response)
}🤖 Prompt for AI Agents |
||
|
|
||
| async submitRequest({ | ||
| rfqId, | ||
| margin, | ||
| expiry, | ||
| status, | ||
| height, | ||
| marketId, | ||
| quantity, | ||
| direction, | ||
| createdAt, | ||
| updatedAt, | ||
| worstPrice, | ||
| requestAddress, | ||
| transactionTime, | ||
| }: { | ||
| rfqId?: bigint | ||
| margin: string | ||
| expiry?: bigint | ||
| status?: string | ||
| height?: bigint | ||
| marketId: string | ||
| quantity: string | ||
| direction: string | ||
| worstPrice: string | ||
| createdAt?: bigint | ||
| updatedAt?: bigint | ||
| requestAddress?: string | ||
| transactionTime?: bigint | ||
| }) { | ||
| const request = InjectiveRFQExchangeRpcPb.RFQRequestType.create() | ||
|
|
||
| if (rfqId !== undefined) { | ||
| request.rfqId = rfqId | ||
| } | ||
|
|
||
| if (marketId) { | ||
| request.marketId = marketId | ||
| } | ||
|
|
||
| if (direction) { | ||
| request.direction = direction | ||
| } | ||
|
|
||
| if (margin) { | ||
| request.margin = margin | ||
| } | ||
|
|
||
| if (quantity) { | ||
| request.quantity = quantity | ||
| } | ||
|
|
||
| if (worstPrice) { | ||
| request.worstPrice = worstPrice | ||
| } | ||
|
|
||
| if (requestAddress) { | ||
| request.requestAddress = requestAddress | ||
| } | ||
|
|
||
| if (expiry) { | ||
| request.expiry = expiry | ||
| } | ||
|
|
||
| if (status) { | ||
| request.status = status | ||
| } | ||
|
|
||
| if (createdAt) { | ||
| request.createdAt = createdAt | ||
| } | ||
|
|
||
| if (updatedAt) { | ||
| request.updatedAt = updatedAt | ||
| } | ||
|
|
||
| if (transactionTime) { | ||
| request.transactionTime = transactionTime | ||
| } | ||
|
|
||
| if (height) { | ||
| request.height = height | ||
| } | ||
|
|
||
| const requestMessage = InjectiveRFQExchangeRpcPb.RequestRequest.create() | ||
| requestMessage.request = request | ||
|
|
||
| const response = await this.executeGrpcCall< | ||
| InjectiveRFQExchangeRpcPb.RequestRequest, | ||
| InjectiveRFQExchangeRpcPb.RequestResponse | ||
| >(requestMessage, this.client.request.bind(this.client)) | ||
|
|
||
| return { status: response.status } | ||
| } | ||
|
|
||
| async submitQuote({ | ||
| rfqId, | ||
| price, | ||
| maker, | ||
| taker, | ||
| margin, | ||
| expiry, | ||
| status, | ||
| height, | ||
| chainId, | ||
| marketId, | ||
| quantity, | ||
| signature, | ||
| createdAt, | ||
| updatedAt, | ||
| eventTime, | ||
| takerDirection, | ||
| contractAddress, | ||
| transactionTime, | ||
| }: { | ||
| rfqId?: bigint | ||
| price: string | ||
| maker: string | ||
| taker: string | ||
| margin: string | ||
| expiry?: bigint | ||
| status?: string | ||
| height?: bigint | ||
| chainId: string | ||
| marketId: string | ||
| quantity: string | ||
| signature: string | ||
| createdAt?: bigint | ||
| updatedAt?: bigint | ||
| eventTime?: bigint | ||
| takerDirection: string | ||
| contractAddress: string | ||
| transactionTime?: bigint | ||
| }): Promise<{ status: string }> { | ||
| const request = InjectiveRFQExchangeRpcPb.RFQQuoteType.create() | ||
|
|
||
| if (chainId) { | ||
| request.chainId = chainId | ||
| } | ||
|
|
||
| if (contractAddress) { | ||
| request.contractAddress = contractAddress | ||
| } | ||
|
|
||
| if (marketId) { | ||
| request.marketId = marketId | ||
| } | ||
|
|
||
| if (rfqId !== undefined) { | ||
| request.rfqId = rfqId | ||
| } | ||
|
|
||
| if (takerDirection) { | ||
| request.takerDirection = takerDirection | ||
| } | ||
|
|
||
| if (margin) { | ||
| request.margin = margin | ||
| } | ||
|
|
||
| if (quantity) { | ||
| request.quantity = quantity | ||
| } | ||
|
|
||
| if (price) { | ||
| request.price = price | ||
| } | ||
|
|
||
| if (expiry) { | ||
| request.expiry = expiry | ||
| } | ||
|
|
||
| if (maker) { | ||
| request.maker = maker | ||
| } | ||
|
|
||
| if (taker) { | ||
| request.taker = taker | ||
| } | ||
|
|
||
| if (signature) { | ||
| request.signature = signature | ||
| } | ||
|
|
||
| if (status) { | ||
| request.status = status | ||
| } | ||
|
|
||
| if (createdAt) { | ||
| request.createdAt = createdAt | ||
| } | ||
|
|
||
| if (updatedAt) { | ||
| request.updatedAt = updatedAt | ||
| } | ||
|
|
||
| if (height) { | ||
| request.height = height | ||
| } | ||
|
|
||
| if (eventTime) { | ||
| request.eventTime = eventTime | ||
| } | ||
|
|
||
| if (transactionTime) { | ||
| request.transactionTime = transactionTime | ||
| } | ||
|
|
||
| const quoteMessage = InjectiveRFQExchangeRpcPb.QuoteRequest.create() | ||
| quoteMessage.quote = request | ||
|
|
||
| const response = await this.executeGrpcCall< | ||
| InjectiveRFQExchangeRpcPb.QuoteRequest, | ||
| InjectiveRFQExchangeRpcPb.QuoteResponse | ||
| >(quoteMessage, this.client.quote.bind(this.client)) | ||
|
|
||
| return { status: response.status } | ||
| } | ||
|
|
||
| async fetchSettlements(params?: { | ||
| addresses?: string[] | ||
| pagination?: PaginationOption | ||
| }) { | ||
| const { addresses, pagination } = params || {} | ||
| const request = InjectiveRFQExchangeRpcPb.ListSettlementRequest.create() | ||
|
|
||
| if (addresses && addresses.length > 0) { | ||
| request.addresses = addresses | ||
| } | ||
|
|
||
| if (pagination?.skip) { | ||
| request.skip = BigInt(pagination.skip) | ||
| } | ||
|
|
||
| if (pagination?.limit) { | ||
| request.limit = BigInt(pagination.limit) | ||
| } | ||
|
|
||
| const response = await this.executeGrpcCall< | ||
| InjectiveRFQExchangeRpcPb.ListSettlementRequest, | ||
| InjectiveRFQExchangeRpcPb.ListSettlementResponse | ||
| >(request, this.client.listSettlement.bind(this.client)) | ||
|
|
||
| return IndexerGrpcRfqTransformer.listSettlementsResponseToSettlements( | ||
| response, | ||
| ) | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
Repository: InjectiveLabs/injective-ts
Length of output: 191
Verify alpha dependency before production release.
The dependency
@injectivelabs/indexer-proto-ts-v2is being upgraded to1.17.7-alpha.3. The latest stable version in this range is1.17.6. Since no stable1.17.7is available yet, the alpha version indicates this dependency is still under active development.Using alpha versions introduces risk of breaking changes. Ensure this is updated to a stable release before the SDK is released to production. Track this as a pre-release blocker.
🤖 Prompt for AI Agents