-
Notifications
You must be signed in to change notification settings - Fork 33
[chore] fix example scripts #383
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
Conversation
WalkthroughThis update introduces new gRPC API methods for querying market balances and denomination minimum notionals in the exchange v2 API, along with corresponding test coverage and mock servicer handlers. It also updates numerous example scripts to use a higher-level message broadcaster abstraction and to pretty-print JSON outputs. Two outdated example scripts for L3 orderbook queries are removed. Changes
Sequence Diagram(s)sequenceDiagram
participant UserScript
participant MsgBroadcasterWithPk
participant ChainClient
participant Composer
UserScript->>MsgBroadcasterWithPk: broadcast([message])
MsgBroadcasterWithPk->>ChainClient: prepare & send transaction
ChainClient->>Composer: compose message
ChainClient->>ChainClient: sign, estimate gas, set fees
ChainClient->>ChainClient: broadcast transaction
ChainClient-->>MsgBroadcasterWithPk: broadcast result
MsgBroadcasterWithPk-->>UserScript: formatted JSON response
sequenceDiagram
participant API
participant gRPCStub
participant Servicer
API->>gRPCStub: fetch_market_balances()
gRPCStub->>Servicer: MarketBalances request
Servicer-->>gRPCStub: MarketBalancesResponse
gRPCStub-->>API: response dict
Poem
✨ Finishing Touches
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
Documentation and Community
|
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.
Pull Request Overview
This pull request updates the AsyncClient v2 example scripts and tests by fixing errors, removing simulation‐based transaction building, and standardizing the output formatting (using json.dumps for pretty‐printed JSON responses).
- Replaces simulation code with direct broadcasting via MsgBroadcasterWithPk.new_using_gas_heuristics.
- Updates most examples and test files to output responses as formatted JSON.
- Adjusts how gas price is recalculated after transaction broadcast across multiple modules.
Reviewed Changes
Copilot reviewed 75 out of 79 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| tests/client/chain/grpc/test_chain_grpc_exchange_v2_api.py | Added tests for new endpoints (market balance, market balances, denom min notional, etc.). |
| tests/client/chain/grpc/configurable_exchange_v2_query_servicer.py | Added response deques for new endpoints in the servicer. |
| pyinjective/client/chain/grpc/chain_grpc_exchange_v2_api.py | Refactored API methods, now omitting duplicate simulation logic. |
| examples/chain_client/* | Across various example directories, replaced manual simulation and tx‐building code with direct broadcast calls and improved output as JSON. |
| examples/chain_client/distribution/, bank/, authz/, auction/ | All updated to follow the new gas price adjustments and broadcasting patterns. |
Comments suppressed due to low confidence (1)
examples/chain_client/wasmx/1_MsgExecuteContractCompat.py:44
- Since the simulation code is no longer used, remove the commented-out simulation code blocks to improve code clarity.
"1peggy0x87aB3B4C8661e07D6372361211B96ed4Dc36B1B5"
| gas_price = await client.current_chain_gas_price() | ||
| # adjust gas price to make it valid even if it changes between the time it is requested and the TX is broadcasted | ||
| gas_price = int(gas_price * 1.1) |
Copilot
AI
Jun 23, 2025
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.
The gas price adjustment logic (fetching and multiplying the gas price) is repeated in many examples; consider refactoring this into a helper function to reduce duplication and simplify future changes.
| gas_price = await client.current_chain_gas_price() | |
| # adjust gas price to make it valid even if it changes between the time it is requested and the TX is broadcasted | |
| gas_price = int(gas_price * 1.1) | |
| gas_price = await fetch_and_adjust_gas_price(client) |
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.
Actionable comments posted: 9
♻️ Duplicate comments (7)
examples/chain_client/exchange/2_MsgWithdraw.py (2)
24-27: Duplicate comment: Consider consolidating gas price management.Same issue as in other refactored examples - gas price is fetched and updated twice unnecessarily for single transaction examples.
Also applies to: 50-53
36-39: Duplicate comment: Consider removing redundant PrivateKey object creation.Same optimization opportunity as other examples - the PrivateKey creation can be streamlined since the broadcaster already handles the hex format.
examples/chain_client/bank/1_MsgSend.py (1)
24-27: Duplicate comment: Consider consolidating gas price management.The same gas price duplication pattern appears across all refactored examples, suggesting this could be addressed systematically.
Also applies to: 53-56
examples/chain_client/exchange/16_MsgCancelBinaryOptionsOrder.py (1)
24-27: Duplicate comment: Consider consolidating gas price management.This systematic issue appears across all refactored examples and should be addressed as a pattern.
Also applies to: 61-64
examples/chain_client/insurance/1_MsgCreateInsuranceFund.py (1)
25-27: Duplicate comment: Consider consolidating gas price management.The gas price duplication pattern is consistent across all insurance examples as well.
Also applies to: 57-60
examples/chain_client/authz/1_MsgGrant.py (1)
68-71: Same redundant gas price update pattern.As mentioned in the previous file, this gas price update appears unnecessary without subsequent transactions.
tests/client/chain/grpc/test_chain_grpc_exchange_v2_api.py (1)
2678-2711: Same protobuf class availability issue.This test has the same issue as the previous test method - it uses
MarketBalanceandQueryMarketBalancesResponseclasses that don't appear to exist according to static analysis.
🧹 Nitpick comments (23)
examples/chain_client/exchange/query/52_MarketVolatility.py (1)
27-27: Inconsistent indent level
Other scripts useindent=2; here it’sindent=4. Consider standardizing onindent=2for consistency.examples/chain_client/5_MessageBroadcasterWithoutSimulation.py (1)
30-36: LGTM with naming concern: Functional improvement but filename is now misleading.The switch to
new_using_gas_heuristicsis a good improvement consistent with the refactor pattern. However, the filename5_MessageBroadcasterWithoutSimulation.pynow misrepresents the example's behavior since gas heuristics typically involve simulation or estimation.Consider renaming this file to better reflect its current functionality, such as:
5_MessageBroadcasterWithGasHeuristics.pyexamples/chain_client/exchange/query/59_MarketBalance.py (1)
10-10: Fix docstring inconsistencyThe docstring mentions "balances" (plural) but the method being called is
fetch_market_balance(singular). Consider updating the docstring to match the actual API method being demonstrated.- Demonstrate fetching market balances using AsyncClient. + Demonstrate fetching market balance using AsyncClient.examples/chain_client/exchange/9_MsgBatchUpdateOrders.py (1)
15-15: Consider refactoring to reduce local variable countStatic analysis flagged 23 local variables (limit: 15). While most variables are necessary for demonstrating batch operations, consider extracting the order creation logic into helper functions to improve readability and reduce complexity.
For example, you could create helper functions like:
def create_derivative_orders_to_cancel(composer, subaccount_id): return [ composer.create_order_data_without_mask(...), # ... more orders ] def create_spot_orders_to_create(composer, subaccount_id, fee_recipient): return [ composer.spot_order(...), # ... more orders ]This would reduce the main function's variable count while maintaining the demonstration's clarity.
examples/chain_client/authz/3_MsgRevoke.py (1)
37-39: Suggest refactor: Remove redundant private key creation.The private key is already provided to
MsgBroadcasterWithPkduring initialization, making this explicit creation redundant since it's only used to derive the address.Consider simplifying by using the broadcaster's internal key handling:
-priv_key = PrivateKey.from_hex(private_key_in_hexa) -pub_key = priv_key.to_public_key() -address = pub_key.to_address() +# Get address directly from the private key for message composition +address = PrivateKey.from_hex(private_key_in_hexa).to_public_key().to_address()examples/chain_client/exchange/15_MsgCreateBinaryOptionsMarketOrder.py (1)
38-41: Suggest refactor: Consolidate private key usage.Similar to other files in this PR, the private key creation is redundant since it's already handled by the broadcaster.
Consider deriving the address more directly:
-priv_key = PrivateKey.from_hex(private_key_in_hexa) -pub_key = priv_key.to_public_key() -address = pub_key.to_address() +address = PrivateKey.from_hex(private_key_in_hexa).to_public_key().to_address()examples/chain_client/exchange/7_MsgCreateSpotMarketOrder.py (1)
38-41: Suggest refactor: Optimize private key handling.The private key derivation can be simplified since the broadcaster already manages the key internally.
-priv_key = PrivateKey.from_hex(private_key_in_hexa) -pub_key = priv_key.to_public_key() -address = pub_key.to_address() +address = PrivateKey.from_hex(private_key_in_hexa).to_public_key().to_address()examples/chain_client/exchange/19_MsgLiquidatePosition.py (2)
38-41: Suggest refactor: Simplify private key derivation.The private key handling can be optimized since the broadcaster already manages the key.
-priv_key = PrivateKey.from_hex(private_key_in_hexa) -pub_key = priv_key.to_public_key() -address = pub_key.to_address() +address = PrivateKey.from_hex(private_key_in_hexa).to_public_key().to_address()
15-77: Address static analysis warning: Consider extracting helper functions.The static analysis tool flagged too many local variables (16/15). While this is a minor issue, consider extracting some logic into helper functions for better code organization.
Consider extracting order preparation and configuration setup into separate functions:
def prepare_liquidation_order(composer, market_id, subaccount_id, fee_recipient, cid): return composer.derivative_order( market_id=market_id, subaccount_id=subaccount_id, fee_recipient=fee_recipient, price=Decimal(39.01), quantity=Decimal(0.147), margin=composer.calculate_margin( quantity=Decimal(0.147), price=Decimal(39.01), leverage=Decimal(1), is_reduce_only=False ), order_type="SELL", cid=cid, )examples/chain_client/insurance/2_MsgUnderwrite.py (1)
38-40: Suggest refactor: Final optimization for private key handling.Like the other files in this PR, the private key creation can be simplified.
-priv_key = PrivateKey.from_hex(private_key_in_hexa) -pub_key = priv_key.to_public_key() -address = pub_key.to_address() +address = PrivateKey.from_hex(private_key_in_hexa).to_public_key().to_address()examples/chain_client/exchange/12_MsgCancelDerivativeOrder.py (2)
24-27: Consider consolidating gas price management.The gas price is fetched and adjusted twice in the same function - once before creating the broadcaster and once after broadcasting. For a single transaction example, the second gas price update may be unnecessary unless this script is intended to be used for multiple transactions.
Consider removing the duplicate gas price handling:
- gas_price = await client.current_chain_gas_price() - # adjust gas price to make it valid even if it changes between the time it is requested and the TX is broadcasted - gas_price = int(gas_price * 1.1) - message_broadcaster.update_gas_price(gas_price=gas_price)Also applies to: 61-64
36-39: Consider removing redundant PrivateKey object creation.The
PrivateKeyobject is created from the hex string, but theMsgBroadcasterWithPkalready accepts the private key in hex format. The subsequent operations only need the public key and address, which could be derived more efficiently.Consider optimizing the key handling:
- priv_key = PrivateKey.from_hex(private_key_in_hexa) - pub_key = priv_key.to_public_key() - address = pub_key.to_address() + address = PrivateKey.from_hex(private_key_in_hexa).to_public_key().to_address()examples/chain_client/exchange/22_MsgAdminUpdateBinaryOptionsMarket.py (1)
63-66: Remove unnecessary gas price update after transaction broadcast.The gas price fetch and update after the transaction has been broadcast serves no purpose since no additional transactions are sent. This appears to be leftover code from the refactoring.
- gas_price = await client.current_chain_gas_price() - # adjust gas price to make it valid even if it changes between the time it is requested and the TX is broadcasted - gas_price = int(gas_price * 1.1) - message_broadcaster.update_gas_price(gas_price=gas_price)examples/chain_client/exchange/14_MsgCreateBinaryOptionsLimitOrder.py (1)
65-68: Remove unnecessary gas price update after transaction broadcast.The gas price fetch and update after the transaction has been broadcast serves no purpose since no additional transactions are sent. This appears to be leftover code from the refactoring.
- gas_price = await client.current_chain_gas_price() - # adjust gas price to make it valid even if it changes between the time it is requested and the TX is broadcasted - gas_price = int(gas_price * 1.1) - message_broadcaster.update_gas_price(gas_price=gas_price)examples/chain_client/auction/1_MsgBid.py (1)
48-51: Remove unnecessary gas price update after transaction broadcast.The gas price fetch and update after the transaction has been broadcast serves no purpose since no additional transactions are sent. This appears to be leftover code from the refactoring.
- gas_price = await client.current_chain_gas_price() - # adjust gas price to make it valid even if it changes between the time it is requested and the TX is broadcasted - gas_price = int(gas_price * 1.1) - message_broadcaster.update_gas_price(gas_price=gas_price)examples/chain_client/exchange/17_MsgSubaccountTransfer.py (1)
56-59: Remove unnecessary gas price update after transaction broadcast.The gas price fetch and update after the transaction has been broadcast serves no purpose since no additional transactions are sent. This appears to be leftover code from the refactoring.
- gas_price = await client.current_chain_gas_price() - # adjust gas price to make it valid even if it changes between the time it is requested and the TX is broadcasted - gas_price = int(gas_price * 1.1) - message_broadcaster.update_gas_price(gas_price=gas_price)examples/chain_client/wasmx/1_MsgExecuteContractCompat.py (1)
59-62: Remove unnecessary gas price update after transaction broadcast.The gas price fetch and update after the transaction has been broadcast serves no purpose since no additional transactions are sent. This appears to be leftover code from the refactoring.
- gas_price = await client.current_chain_gas_price() - # adjust gas price to make it valid even if it changes between the time it is requested and the TX is broadcasted - gas_price = int(gas_price * 1.1) - message_broadcaster.update_gas_price(gas_price=gas_price)examples/chain_client/staking/1_MsgDelegate.py (1)
24-27: Consider making the gas price adjustment configurable.The hardcoded 1.1 multiplier for gas price adjustment might not be suitable for all network conditions. Consider extracting this as a constant or making it configurable.
+ GAS_PRICE_ADJUSTMENT_FACTOR = 1.1 + gas_price = await client.current_chain_gas_price() # adjust gas price to make it valid even if it changes between the time it is requested and the TX is broadcasted - gas_price = int(gas_price * 1.1) + gas_price = int(gas_price * GAS_PRICE_ADJUSTMENT_FACTOR)examples/chain_client/exchange/1_MsgDeposit.py (1)
24-27: Same gas price adjustment pattern as other examples.This follows the same hardcoded 1.1 multiplier pattern. Consider implementing a consistent approach across all examples, potentially through a shared utility function.
examples/chain_client/exchange/20_MsgIncreasePositionMargin.py (1)
59-62: Consider consolidating gas price management.The pattern of fetching gas price twice appears across all examples. Consider if this could be simplified or if the broadcaster could handle gas price updates internally.
examples/chain_client/exchange/21_MsgRewardsOptOut.py (1)
48-51: Suggest creating a shared utility for gas price management.Since all examples follow the same gas price fetching and adjustment pattern, consider creating a shared utility function to reduce code duplication across examples.
# In a shared utility module async def get_adjusted_gas_price(client, adjustment_factor=1.1): gas_price = await client.current_chain_gas_price() return int(gas_price * adjustment_factor)This could be used across all examples to maintain consistency and reduce duplication.
examples/chain_client/peggy/1_MsgSendToEth.py (1)
65-68: Consider removing the redundant gas price update.The gas price update at the end of the script appears unnecessary since no additional transactions are broadcast afterward. If this is meant to demonstrate the update functionality, consider adding a comment to clarify its purpose.
- gas_price = await client.current_chain_gas_price() - # adjust gas price to make it valid even if it changes between the time it is requested and the TX is broadcasted - gas_price = int(gas_price * 1.1) - message_broadcaster.update_gas_price(gas_price=gas_price) + # Example of updating gas price for subsequent transactions (not needed in this script) + # gas_price = await client.current_chain_gas_price() + # gas_price = int(gas_price * 1.1) + # message_broadcaster.update_gas_price(gas_price=gas_price)examples/chain_client/authz/2_MsgExec.py (1)
15-71: Minor: Consider reducing local variables to address static analysis warning.The script has 16 local variables (limit is 15). While this is acceptable for an example script, you could reduce it by combining some operations if needed.
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (75)
examples/chain_client/1_LocalOrderHash.py(4 hunks)examples/chain_client/5_MessageBroadcasterWithoutSimulation.py(1 hunks)examples/chain_client/auction/1_MsgBid.py(1 hunks)examples/chain_client/auth/query/1_Account.py(2 hunks)examples/chain_client/authz/1_MsgGrant.py(3 hunks)examples/chain_client/authz/2_MsgExec.py(3 hunks)examples/chain_client/authz/3_MsgRevoke.py(3 hunks)examples/chain_client/authz/query/1_Grants.py(2 hunks)examples/chain_client/bank/1_MsgSend.py(2 hunks)examples/chain_client/bank/query/10_SendEnabled.py(2 hunks)examples/chain_client/bank/query/1_BankBalance.py(2 hunks)examples/chain_client/bank/query/2_BankBalances.py(2 hunks)examples/chain_client/bank/query/3_SpendableBalances.py(2 hunks)examples/chain_client/bank/query/4_SpendableBalancesByDenom.py(2 hunks)examples/chain_client/bank/query/5_TotalSupply.py(2 hunks)examples/chain_client/bank/query/6_SupplyOf.py(2 hunks)examples/chain_client/bank/query/7_DenomMetadata.py(2 hunks)examples/chain_client/bank/query/8_DenomsMetadata.py(2 hunks)examples/chain_client/bank/query/9_DenomOwners.py(2 hunks)examples/chain_client/distribution/1_SetWithdrawAddress.py(1 hunks)examples/chain_client/distribution/2_WithdrawDelegatorReward.py(1 hunks)examples/chain_client/distribution/3_WithdrawValidatorCommission.py(1 hunks)examples/chain_client/distribution/4_FundCommunityPool.py(1 hunks)examples/chain_client/distribution/query/1_ValidatorDistributionInfo.py(2 hunks)examples/chain_client/distribution/query/2_ValidatorOutstandingRewards.py(2 hunks)examples/chain_client/distribution/query/3_ValidatorCommission.py(2 hunks)examples/chain_client/distribution/query/4_ValidatorSlashes.py(2 hunks)examples/chain_client/distribution/query/5_DelegationRewards.py(2 hunks)examples/chain_client/distribution/query/6_DelegationTotalRewards.py(2 hunks)examples/chain_client/distribution/query/7_DelegatorValidators.py(2 hunks)examples/chain_client/distribution/query/8_DelegatorWithdrawAddress.py(2 hunks)examples/chain_client/distribution/query/9_CommunityPool.py(2 hunks)examples/chain_client/exchange/10_MsgCreateDerivativeLimitOrder.py(2 hunks)examples/chain_client/exchange/11_MsgCreateDerivativeMarketOrder.py(2 hunks)examples/chain_client/exchange/12_MsgCancelDerivativeOrder.py(2 hunks)examples/chain_client/exchange/14_MsgCreateBinaryOptionsLimitOrder.py(2 hunks)examples/chain_client/exchange/15_MsgCreateBinaryOptionsMarketOrder.py(2 hunks)examples/chain_client/exchange/16_MsgCancelBinaryOptionsOrder.py(2 hunks)examples/chain_client/exchange/17_MsgSubaccountTransfer.py(2 hunks)examples/chain_client/exchange/18_MsgExternalTransfer.py(2 hunks)examples/chain_client/exchange/19_MsgLiquidatePosition.py(2 hunks)examples/chain_client/exchange/1_MsgDeposit.py(1 hunks)examples/chain_client/exchange/20_MsgIncreasePositionMargin.py(2 hunks)examples/chain_client/exchange/21_MsgRewardsOptOut.py(1 hunks)examples/chain_client/exchange/22_MsgAdminUpdateBinaryOptionsMarket.py(2 hunks)examples/chain_client/exchange/2_MsgWithdraw.py(1 hunks)examples/chain_client/exchange/7_MsgCreateSpotMarketOrder.py(2 hunks)examples/chain_client/exchange/8_MsgCancelSpotOrder.py(2 hunks)examples/chain_client/exchange/9_MsgBatchUpdateOrders.py(2 hunks)examples/chain_client/exchange/query/1_SubaccountDeposits.py(2 hunks)examples/chain_client/exchange/query/2_SubaccountDeposit.py(2 hunks)examples/chain_client/exchange/query/3_ExchangeBalances.py(2 hunks)examples/chain_client/exchange/query/4_AggregateVolume.py(2 hunks)examples/chain_client/exchange/query/52_MarketVolatility.py(2 hunks)examples/chain_client/exchange/query/58_GrantAuthorizations.py(2 hunks)examples/chain_client/exchange/query/59_L3DerivativeOrderBook.py(0 hunks)examples/chain_client/exchange/query/59_MarketBalance.py(2 hunks)examples/chain_client/exchange/query/5_AggregateVolumes.py(2 hunks)examples/chain_client/exchange/query/60_L3SpotOrderBook.py(0 hunks)examples/chain_client/exchange/query/60_MarketBalances.py(2 hunks)examples/chain_client/exchange/query/6_AggregateMarketVolume.py(2 hunks)examples/chain_client/insurance/1_MsgCreateInsuranceFund.py(3 hunks)examples/chain_client/insurance/2_MsgUnderwrite.py(3 hunks)examples/chain_client/insurance/3_MsgRequestRedemption.py(3 hunks)examples/chain_client/oracle/1_MsgRelayPriceFeedPrice.py(2 hunks)examples/chain_client/oracle/2_MsgRelayProviderPrices.py(2 hunks)examples/chain_client/peggy/1_MsgSendToEth.py(2 hunks)examples/chain_client/staking/1_MsgDelegate.py(2 hunks)examples/chain_client/tokenfactory/4_MsgChangeAdmin.py(1 hunks)examples/chain_client/tokenfactory/5_MsgSetDenomMetadata.py(1 hunks)examples/chain_client/wasm/1_MsgExecuteContract.py(3 hunks)examples/chain_client/wasmx/1_MsgExecuteContractCompat.py(2 hunks)pyinjective/client/chain/grpc/chain_grpc_exchange_v2_api.py(1 hunks)tests/client/chain/grpc/configurable_exchange_v2_query_servicer.py(2 hunks)tests/client/chain/grpc/test_chain_grpc_exchange_v2_api.py(1 hunks)
💤 Files with no reviewable changes (2)
- examples/chain_client/exchange/query/59_L3DerivativeOrderBook.py
- examples/chain_client/exchange/query/60_L3SpotOrderBook.py
🧰 Additional context used
🪛 Pylint (3.3.7)
examples/chain_client/peggy/1_MsgSendToEth.py
[refactor] 15-15: Too many local variables (18/15)
(R0914)
examples/chain_client/exchange/19_MsgLiquidatePosition.py
[refactor] 15-15: Too many local variables (16/15)
(R0914)
examples/chain_client/exchange/22_MsgAdminUpdateBinaryOptionsMarket.py
[refactor] 14-14: Too many local variables (16/15)
(R0914)
examples/chain_client/authz/2_MsgExec.py
[refactor] 15-15: Too many local variables (16/15)
(R0914)
tests/client/chain/grpc/configurable_exchange_v2_query_servicer.py
[error] 367-367: Module 'pyinjective.proto.injective.exchange.v2.query_pb2' has no 'QueryMarketBalanceRequest' member
(E1101)
[error] 370-370: Module 'pyinjective.proto.injective.exchange.v2.query_pb2' has no 'QueryMarketBalancesRequest' member
(E1101)
[error] 374-374: Module 'pyinjective.proto.injective.exchange.v2.query_pb2' has no 'QueryDenomMinNotionalRequest' member
(E1101)
[error] 379-379: Module 'pyinjective.proto.injective.exchange.v2.query_pb2' has no 'QueryDenomMinNotionalsRequest' member
(E1101)
examples/chain_client/exchange/9_MsgBatchUpdateOrders.py
[refactor] 15-15: Too many local variables (23/15)
(R0914)
tests/client/chain/grpc/test_chain_grpc_exchange_v2_api.py
[error] 2655-2655: Module 'pyinjective.proto.injective.exchange.v2.query_pb2' has no 'MarketBalance' member
(E1101)
[error] 2659-2659: Module 'pyinjective.proto.injective.exchange.v2.query_pb2' has no 'QueryMarketBalanceResponse' member
(E1101)
[error] 2683-2683: Module 'pyinjective.proto.injective.exchange.v2.query_pb2' has no 'MarketBalance' member
(E1101)
[error] 2687-2687: Module 'pyinjective.proto.injective.exchange.v2.query_pb2' has no 'MarketBalance' member
(E1101)
[error] 2691-2691: Module 'pyinjective.proto.injective.exchange.v2.query_pb2' has no 'QueryMarketBalancesResponse' member
(E1101)
[error] 2718-2718: Module 'pyinjective.proto.injective.exchange.v2.query_pb2' has no 'QueryDenomMinNotionalResponse' member
(E1101)
[error] 2737-2737: Module 'pyinjective.proto.injective.exchange.v2.exchange_pb2' has no 'DenomMinNotional' member
(E1101)
[error] 2741-2741: Module 'pyinjective.proto.injective.exchange.v2.query_pb2' has no 'QueryDenomMinNotionalsResponse' member
(E1101)
pyinjective/client/chain/grpc/chain_grpc_exchange_v2_api.py
[error] 582-582: Module 'pyinjective.proto.injective.exchange.v2.query_pb2' has no 'QueryFullDerivativeOrderbookRequest' member
(E1101)
[error] 593-593: Module 'pyinjective.proto.injective.exchange.v2.query_pb2' has no 'QueryFullSpotOrderbookRequest' member
(E1101)
[error] 601-601: Module 'pyinjective.proto.injective.exchange.v2.query_pb2' has no 'QueryMarketBalanceRequest' member
(E1101)
[error] 607-607: Module 'pyinjective.proto.injective.exchange.v2.query_pb2' has no 'QueryMarketBalancesRequest' member
(E1101)
[error] 613-613: Module 'pyinjective.proto.injective.exchange.v2.query_pb2' has no 'QueryDenomMinNotionalRequest' member
(E1101)
[error] 619-619: Module 'pyinjective.proto.injective.exchange.v2.query_pb2' has no 'QueryDenomMinNotionalsRequest' member
(E1101)
🔇 Additional comments (141)
examples/chain_client/exchange/query/58_GrantAuthorizations.py (2)
2-2: Add JSON import for serialization.
Importingjsonenables use ofjson.dumpsfor formatting API responses.
29-29: Pretty-print grant authorizations response.
Usingjson.dumps(active_grant, indent=4)significantly improves readability of the output.examples/chain_client/distribution/query/9_CommunityPool.py (2)
2-2: Add JSON import for serialization.
Importingjsonis required to usejson.dumpsfor formatted output.
12-12: Pretty-print community pool data.
Switching tojson.dumps(community_pool, indent=2)makes the output more readable.examples/chain_client/distribution/query/7_DelegatorValidators.py (2)
2-2: Add JSON import for serialization.
Thejsonmodule is needed to serialize thevalidatorslist with indentation.
15-15: Pretty-print delegator validators response.
Usingjson.dumps(validators, indent=2)enhances clarity of the printed data.examples/chain_client/auth/query/1_Account.py (2)
2-2: Add JSON import for serialization.
Importingjsonallows formatting the account object withjson.dumps.
13-13: Pretty-print account information.
Replacing the raw print withjson.dumps(acc, indent=2)improves output readability.examples/chain_client/distribution/query/5_DelegationRewards.py (2)
2-2: Add JSON import for serialization.
Thejsonmodule is required to serialize therewardsobject nicely.
16-16: Pretty-print delegation rewards data.
Usingjson.dumps(rewards, indent=2)makes the output more structured and readable.examples/chain_client/distribution/query/3_ValidatorCommission.py (2)
2-2: Import JSON for pretty-printing
The addedimport jsonis necessary for the subsequentjson.dumpscall.
13-13: Pretty-print JSON output
Usingjson.dumps(commission, indent=2)improves readability of the validator commission data.examples/chain_client/authz/query/1_Grants.py (2)
2-2: Import JSON for formatted output
The newimport jsonenables pretty-printing of the grants response.
20-20: Pretty-print JSON output
Switching tojson.dumps(authorizations, indent=2)provides a clearer view of the fetched grants.examples/chain_client/1_LocalOrderHash.py (2)
2-2: Import JSON for consistent formatting
Addingimport jsonallows the use ofjson.dumpsfor transaction responses.
136-136: Pretty-print JSON broadcast response
Replacing rawprint(res)withprint(json.dumps(res, indent=2))makes the output more readable.examples/chain_client/bank/query/2_BankBalances.py (2)
2-2: Import JSON for output formatting
Thejsonimport is required for the formatted printing of bank balances.
13-13: Pretty-print JSON output
Usingjson.dumps(all_bank_balances, indent=2)enhances clarity of the balances response.examples/chain_client/distribution/query/4_ValidatorSlashes.py (2)
2-2: Import JSON for formatted display
The addedimport jsonsupports the pretty-printing of slashes data.
17-17: Pretty-print JSON output
Applyingjson.dumps(contracts, indent=2)improves the readability of validator slashes results.examples/chain_client/bank/query/3_SpendableBalances.py (2)
2-2: Add JSON import for pretty-printing
Includingimport jsonensures that the subsequent output formatting call tojson.dumpswill work correctly.
13-13: Pretty-print spendable balances as JSON
Switching from a raw print tojson.dumps(spendable_balances, indent=2)enhances readability of the output.examples/chain_client/bank/query/7_DenomMetadata.py (2)
2-2: Add JSON import for pretty-printing
Thejsonmodule is required to format the metadata object in an indented JSON string.
13-13: Pretty-print denomination metadata as JSON
Usingjson.dumps(metadata, indent=2)replaces the raw print for a cleaner, structured output.examples/chain_client/bank/query/8_DenomsMetadata.py (2)
2-2: Add JSON import for pretty-printing
Ensurejsonis imported to support the formatted output of the denominations metadata.
15-15: Pretty-print denominations metadata as JSON
Replacing the raw print withjson.dumps(denoms, indent=2)improves clarity of the displayed results.examples/chain_client/exchange/query/3_ExchangeBalances.py (2)
2-2: Add JSON import for pretty-printing
Importingjsonis necessary for the upcoming formatted print call.
15-15: Pretty-print exchange balances as JSON
Switching tojson.dumps(balances, indent=2)produces a well-structured output for easier inspection.examples/chain_client/distribution/query/6_DelegationTotalRewards.py (2)
2-2: Add JSON import for pretty-printing
Thejsonmodule is required to format the fetched rewards data.
15-15: Pretty-print delegation total rewards as JSON
Usingjson.dumps(rewards, indent=2)replaces the raw print to deliver a neatly formatted JSON output.examples/chain_client/distribution/query/2_ValidatorOutstandingRewards.py (2)
2-2: Add json import for pretty-printing
Enables the use ofjson.dumpsto format output.
13-13: Format output as pretty-printed JSON
Usingjson.dumps(rewards, indent=2)improves CLI readability.examples/chain_client/exchange/query/6_AggregateMarketVolume.py (2)
2-2: Add json import for pretty-printing
Required to enablejson.dumpsfor formatted output.
18-18: Pretty-print aggregate market volume
Switching tojson.dumps(volume, indent=2)enhances output clarity.examples/chain_client/bank/query/9_DenomOwners.py (2)
2-2: Add json import for pretty-printing
Necessary for JSON formatting of the response.
17-17: Format denom owners output as JSON
Usingjson.dumps(owners, indent=2)improves readability.examples/chain_client/exchange/query/52_MarketVolatility.py (1)
2-2: Add json import for pretty-printing
Enables formatted JSON output in the script.examples/chain_client/bank/query/5_TotalSupply.py (2)
2-2: Add json import for pretty-printing
Required to calljson.dumpsfor output formatting.
15-15: Pretty-print total supply output
Usingjson.dumps(total_supply, indent=2)enhances readability.examples/chain_client/bank/query/6_SupplyOf.py (2)
2-2: Add JSON import for pretty-printing.The new
jsonimport is required to format the output withjson.dumps.
12-12: Pretty-print thesupply_ofresult.Replacing the raw
print(supply_of)withprint(json.dumps(supply_of, indent=2))enhances readability of the output.examples/chain_client/distribution/query/8_DelegatorWithdrawAddress.py (2)
2-2: Add JSON import for pretty-printing.Importing the standard
jsonmodule enables formatting of the delegate withdraw address response.
15-15: Pretty-print thewithdraw_addressresult.Switching from
print(withdraw_address)toprint(json.dumps(withdraw_address, indent=2))makes the output more structured and human-readable.examples/chain_client/bank/query/1_BankBalance.py (2)
2-2: Add JSON import for pretty-printing.The
jsonmodule is now needed to serialize thebank_balanceresponse.
14-14: Pretty-print thebank_balanceresult.Using
json.dumps(bank_balance, indent=2)instead of a raw print improves clarity of the printed balance.examples/chain_client/bank/query/4_SpendableBalancesByDenom.py (2)
2-2: Add JSON import for pretty-printing.The added
jsonimport supports formatted output of spendable balances.
14-14: Pretty-print thespendable_balancesresult.Moving to
print(json.dumps(spendable_balances, indent=2))makes the spendable balances easier to read.examples/chain_client/exchange/query/5_AggregateVolumes.py (2)
2-2: Add JSON import for pretty-printing.Importing
jsonis necessary to serialize the aggregate volume data.
31-31: Pretty-print thevolumeresult.Replacing
print(volume)withprint(json.dumps(volume, indent=2))standardizes output formatting across example scripts.examples/chain_client/exchange/query/1_SubaccountDeposits.py (2)
2-2: Add JSON module import for formatted output.
Thejsonimport enables usage ofjson.dumpsto pretty-print the fetched deposits.
31-31: Pretty-print subaccount deposits as JSON.
Usingjson.dumps(deposits, indent=2)replaces the raw print and significantly improves readability.examples/chain_client/bank/query/10_SendEnabled.py (2)
2-2: Add JSON module import for formatted output.
Includingjsonis required for the pretty-printed output of the send-enabled response.
17-17: Pretty-print send-enabled response as JSON.
Switching tojson.dumps(enabled, indent=2)presents the data in a clean, structured format.examples/chain_client/exchange/query/2_SubaccountDeposit.py (2)
2-2: Add JSON module import for formatted output.
This import is necessary to usejson.dumpsfor prettifying the deposit output.
31-31: Pretty-print single subaccount deposit as JSON.
Replacing the raw print withjson.dumps(deposit, indent=2)enhances clarity of the printed data.examples/chain_client/exchange/query/60_MarketBalances.py (2)
2-2: Add JSON module import for formatted output.
Thejsonimport enables pretty-printing of the fetched market balances.
22-22: Pretty-print market balances as JSON.
Usingjson.dumps(market_balances, indent=4)formats the output neatly for improved readability.examples/chain_client/exchange/query/4_AggregateVolume.py (3)
2-2: Add JSON module import for formatted output.
This import supports the use ofjson.dumpsto format the aggregate volume data.
30-30: Pretty-print aggregate volume (account) as JSON.
Switching tojson.dumps(volume, indent=2)presents the first volume result in a structured format.
33-33: Pretty-print aggregate volume (subaccount) as JSON.
Applyingjson.dumps(volume, indent=2)for the second call also enhances output readability.examples/chain_client/distribution/query/1_ValidatorDistributionInfo.py (2)
2-2: LGTM: JSON import added for output formatting.The addition of the JSON module import supports the pretty-printing enhancement.
13-13: LGTM: Improved output readability with JSON formatting.The change from raw print to
json.dumpswith indentation makes the query results much more readable while preserving all the data.examples/chain_client/distribution/1_SetWithdrawAddress.py (1)
25-31: LGTM: Improved transaction broadcasting with gas heuristics.The switch from
new_without_simulationtonew_using_gas_heuristicsrepresents a good improvement by using a higher-level abstraction that automatically handles gas estimation, making the example more robust and easier to follow.examples/chain_client/distribution/3_WithdrawValidatorCommission.py (1)
26-32: LGTM: Consistent improvement with gas heuristics.The update to
new_using_gas_heuristicsis consistent with the broader refactor across example scripts and improves transaction handling by automating gas estimation.examples/chain_client/tokenfactory/5_MsgSetDenomMetadata.py (1)
27-33: LGTM: Improved broadcaster usage with gas heuristics.The change aligns with the systematic refactor across examples, improving transaction handling through automatic gas estimation.
examples/chain_client/distribution/2_WithdrawDelegatorReward.py (1)
26-32: LGTM: Improved transaction broadcasting with gas heuristicsThe change from
new_without_simulationtonew_using_gas_heuristicsaligns with the broader refactoring effort to standardize transaction broadcasting across example scripts. This should provide better gas estimation and transaction handling.examples/chain_client/exchange/query/59_MarketBalance.py (2)
2-2: Good addition for output formattingAdding the
jsonimport enables pretty-printing of the response, improving readability.
20-24: LGTM: Clean API usage with improved output formattingThe market balance fetching implementation looks correct, and the JSON pretty-printing significantly improves output readability.
examples/chain_client/tokenfactory/4_MsgChangeAdmin.py (1)
27-33: LGTM: Consistent broadcaster improvementThe change to
new_using_gas_heuristicsis consistent with the standardization effort across example scripts and should provide better gas estimation for token factory operations.examples/chain_client/distribution/4_FundCommunityPool.py (1)
26-32: LGTM: Standardized broadcaster instantiationThe update to
new_using_gas_heuristicsfollows the consistent refactoring pattern across example scripts, improving transaction handling for community pool funding operations.examples/chain_client/exchange/9_MsgBatchUpdateOrders.py (3)
2-2: Good additions for improved functionalityAdding
jsonimport for pretty-printing andMsgBroadcasterWithPkfor standardized transaction broadcasting are both positive improvements.Also applies to: 10-10
26-36: LGTM: Standardized transaction broadcastingThe broadcaster instantiation with gas heuristics follows the consistent pattern across example scripts and should provide more reliable transaction handling compared to manual simulation.
137-145: Excellent simplification and improved output formattingThe refactoring removes complex manual transaction handling and replaces it with clean broadcaster usage. The JSON formatting significantly improves output readability.
examples/chain_client/authz/3_MsgRevoke.py (3)
2-2: LGTM: Clean imports for the broadcaster refactoring.The addition of
jsonfor pretty-printing andMsgBroadcasterWithPkfor simplified transaction handling improves code readability and maintainability.Also applies to: 8-8
25-35: Excellent: Simplified transaction broadcasting with proper gas price handling.The use of
MsgBroadcasterWithPkwith gas heuristics significantly simplifies the transaction lifecycle management compared to manual construction, simulation, and broadcasting.
49-51: LGTM: Improved output formatting with JSON pretty-printing.The formatted JSON output significantly improves readability of transaction responses for debugging and monitoring.
examples/chain_client/exchange/15_MsgCreateBinaryOptionsMarketOrder.py (3)
2-2: LGTM: Consistent refactoring pattern with necessary imports.The addition of required imports aligns with the broader refactoring to use
MsgBroadcasterWithPkabstraction.Also applies to: 10-10
26-36: LGTM: Proper broadcaster initialization with gas heuristics.The broadcaster setup correctly handles gas price adjustment and provides a cleaner abstraction for transaction management.
62-64: LGTM: Enhanced output readability with formatted JSON.The pretty-printed JSON output improves the developer experience for transaction response analysis.
examples/chain_client/exchange/7_MsgCreateSpotMarketOrder.py (3)
2-2: LGTM: Consistent imports for broadcaster abstraction.The import additions support the systematic refactoring to simplify transaction handling across example scripts.
Also applies to: 10-10
26-36: LGTM: Well-implemented broadcaster pattern.The gas price adjustment and broadcaster initialization follows the established pattern for reliable transaction submission.
60-62: LGTM: Improved transaction response formatting.The JSON pretty-printing enhances readability and debugging capabilities for transaction responses.
examples/chain_client/exchange/19_MsgLiquidatePosition.py (3)
2-2: LGTM: Standard imports for broadcaster refactoring.The import additions are consistent with the systematic refactoring across example scripts.
Also applies to: 10-10
26-36: LGTM: Proper broadcaster configuration.The broadcaster setup with gas heuristics follows the established pattern for reliable transaction handling.
70-72: LGTM: Enhanced transaction response display.The formatted JSON output provides better visibility into transaction results for debugging and monitoring.
examples/chain_client/insurance/2_MsgUnderwrite.py (3)
2-2: LGTM: Final consistent import additions.The imports complete the systematic refactoring pattern applied across all example scripts in this PR.
Also applies to: 9-9
26-36: LGTM: Consistent broadcaster implementation.The broadcaster setup maintains the established pattern for simplified and reliable transaction management.
54-56: LGTM: Completed refactoring with improved output.The JSON formatting provides consistent, readable transaction response output across all example scripts.
examples/chain_client/exchange/12_MsgCancelDerivativeOrder.py (1)
56-59: Excellent improvement in output formatting.The switch to JSON pretty-printing significantly improves the readability of transaction responses compared to raw output.
examples/chain_client/exchange/2_MsgWithdraw.py (1)
45-48: Good refactoring to simplify transaction broadcasting.The migration to
MsgBroadcasterWithPksuccessfully removes the complexity of manual transaction construction, simulation, and broadcasting while maintaining the same functionality.examples/chain_client/bank/1_MsgSend.py (1)
28-34: Consistent adoption of MsgBroadcasterWithPk pattern.The refactoring successfully standardizes transaction broadcasting across different message types, which improves code maintainability and reduces boilerplate.
examples/chain_client/exchange/16_MsgCancelBinaryOptionsOrder.py (1)
8-8: Verify MsgBroadcasterWithPk import availability.Ensure that the
MsgBroadcasterWithPkclass is properly exported and available in thepyinjective.core.broadcastermodule across all supported versions.#!/bin/bash # Description: Verify MsgBroadcasterWithPk is properly exported in the broadcaster module # Expected: Should find the class definition and export ast-grep --pattern 'class MsgBroadcasterWithPk' ast-grep --pattern '__all__ = [$$$]' pyinjective/core/broadcaster.pyexamples/chain_client/insurance/1_MsgCreateInsuranceFund.py (2)
29-35: Successful systematic refactoring across examples.The consistent adoption of
MsgBroadcasterWithPkacross exchange, bank, and insurance examples demonstrates a well-executed systematic improvement that simplifies transaction handling while maintaining functionality.
52-55: Improved output formatting enhances usability.The standardization of JSON pretty-printing across all example scripts significantly improves the developer experience when using these examples.
examples/chain_client/oracle/1_MsgRelayPriceFeedPrice.py (5)
2-2: LGTM: Import added for JSON formattingThe json import is correctly added to support pretty-printed transaction responses.
8-8: LGTM: Broadcaster import addedThe MsgBroadcasterWithPk import is correctly added to support the new transaction broadcasting approach.
24-34: LGTM: Gas price handling and broadcaster initializationThe gas price adjustment (10% buffer) and broadcaster initialization are correctly implemented. The gas heuristics approach simplifies the transaction lifecycle management.
50-53: LGTM: Simplified broadcasting with improved outputThe broadcasting logic is correctly simplified using the broadcaster abstraction, and the JSON formatting improves readability of the transaction response.
58-58: LGTM: Gas price update after broadcastingThe gas price update ensures the broadcaster stays current with network conditions for subsequent transactions.
examples/chain_client/exchange/11_MsgCreateDerivativeMarketOrder.py (5)
2-2: LGTM: Import added for JSON formattingThe json import is correctly added to support pretty-printed transaction responses.
10-10: LGTM: Broadcaster import addedThe MsgBroadcasterWithPk import is correctly added to support the new transaction broadcasting approach.
26-36: LGTM: Gas price handling and broadcaster initializationThe gas price adjustment and broadcaster initialization are correctly implemented for derivative market orders.
62-65: LGTM: Simplified broadcasting with improved outputThe broadcasting logic is correctly simplified using the broadcaster abstraction, and the JSON formatting improves readability.
70-70: LGTM: Gas price update after broadcastingThe gas price update ensures the broadcaster stays current with network conditions.
examples/chain_client/exchange/18_MsgExternalTransfer.py (5)
2-2: LGTM: Import added for JSON formattingThe json import is correctly added to support pretty-printed transaction responses.
8-8: LGTM: Broadcaster import addedThe MsgBroadcasterWithPk import is correctly added to support the new transaction broadcasting approach.
24-34: LGTM: Gas price handling and broadcaster initializationThe gas price adjustment and broadcaster initialization are correctly implemented for external transfers.
51-54: LGTM: Simplified broadcasting with improved outputThe broadcasting logic is correctly simplified using the broadcaster abstraction, and the JSON formatting improves readability.
59-59: LGTM: Gas price update after broadcastingThe gas price update ensures the broadcaster stays current with network conditions.
examples/chain_client/oracle/2_MsgRelayProviderPrices.py (5)
2-2: LGTM: Import added for JSON formattingThe json import is correctly added to support pretty-printed transaction responses.
8-8: LGTM: Broadcaster import addedThe MsgBroadcasterWithPk import is correctly added to support the new transaction broadcasting approach.
24-34: LGTM: Gas price handling and broadcaster initializationThe gas price adjustment and broadcaster initialization are correctly implemented for oracle provider prices.
49-52: LGTM: Simplified broadcasting with improved outputThe broadcasting logic is correctly simplified using the broadcaster abstraction, and the JSON formatting improves readability.
57-57: LGTM: Gas price update after broadcastingThe gas price update ensures the broadcaster stays current with network conditions.
examples/chain_client/wasm/1_MsgExecuteContract.py (5)
2-2: LGTM: Import added for JSON formattingThe json import is correctly added to support pretty-printed transaction responses.
8-8: LGTM: Broadcaster import addedThe MsgBroadcasterWithPk import is correctly added to support the new transaction broadcasting approach.
25-35: LGTM: Gas price handling and broadcaster initializationThe gas price adjustment and broadcaster initialization are correctly implemented for WASM contract execution.
58-61: LGTM: Simplified broadcasting with improved outputThe broadcasting logic is correctly simplified using the broadcaster abstraction, and the JSON formatting improves readability.
66-66: LGTM: Gas price update after broadcastingThe gas price update ensures the broadcaster stays current with network conditions.
examples/chain_client/staking/1_MsgDelegate.py (3)
2-2: Good addition for improved output readability.Adding the
jsonimport enables pretty-printing of the transaction response, which significantly improves the readability of example outputs.
8-8: Excellent refactoring to use the broadcaster abstraction.Replacing manual transaction lifecycle management with
MsgBroadcasterWithPksimplifies the code and makes it more maintainable.
53-56: I wasn’t able to locate the gas‐handling logic orupdate_gas_pricedefinition using the previous patterns. Let’s gather more context by:#!/bin/bash # 1. Locate the example file example_file=$(fd --full-path 1_MsgDelegate.py) echo "Example script path: $example_file" sed -n '1,200p' "$example_file" # 2. Find all Broadcaster classes in Python files echo; echo "=== Broadcaster classes ===" rg -n 'class .*Broadcaster' -t py # 3. Inspect each broadcaster file for gas logic for f in $(rg -l 'class .*Broadcaster' -t py); do echo; echo "=== File: $f ===" sed -n '1,200p' "$f" done # 4. Find any update_gas_price definitions echo; echo "=== update_gas_price definitions ===" rg -n 'def update_gas_price' -t py || echo "No definitions found" # 5. Look for gas heuristic methods echo; echo "=== gas heuristic references ===" rg -n 'gas_heuristic' -t py || echo "No heuristics found"Please share the output so we can confirm whether the second gas price fetch is indeed redundant.
examples/chain_client/exchange/1_MsgDeposit.py (2)
2-2: Consistent improvement for output formatting.The addition of
jsonimport for pretty-printing aligns with the broader refactoring across example scripts.
28-35: Well-structured broadcaster initialization.The
MsgBroadcasterWithPk.new_using_gas_heuristicsinitialization is clean and follows the expected pattern for the exchange deposit operation.examples/chain_client/exchange/20_MsgIncreasePositionMargin.py (2)
4-4: Good use of Decimal for financial calculations.The import of
Decimalis appropriate for handling financial amounts with precision, which is crucial for position margin operations.
51-51: Proper use of Decimal for margin amount.Using
Decimal(2)for the margin amount ensures precise financial calculations, which is essential for exchange operations.examples/chain_client/exchange/8_MsgCancelSpotOrder.py (2)
42-43: Appropriate use of example values.The hardcoded
market_idandorder_hashare suitable for example scripts, providing concrete values that users can reference.
50-53: Consistent transaction broadcasting pattern.The broadcaster usage and JSON formatting follows the established pattern across all refactored examples, maintaining consistency.
examples/chain_client/exchange/21_MsgRewardsOptOut.py (2)
28-35: Consistent broadcaster pattern completion.The refactoring successfully applies the same
MsgBroadcasterWithPkpattern across all example types, creating a unified approach to transaction broadcasting.
41-41: Appropriately simple message composition.The
msg_rewards_opt_outmessage correctly requires only the sender address, making it the simplest example in the refactored set.examples/chain_client/peggy/1_MsgSendToEth.py (2)
2-2: LGTM! Good refactoring to use the higher-level broadcaster abstraction.The switch to
MsgBroadcasterWithPksimplifies the transaction handling significantly, and the 10% gas price buffer is a reasonable approach to handle potential fluctuations.Also applies to: 10-10, 17-17, 26-36
60-63: Clean implementation of transaction broadcasting.The simplified broadcasting with JSON-formatted output improves readability and maintainability.
examples/chain_client/authz/1_MsgGrant.py (1)
2-2: Consistent refactoring with the new broadcaster pattern.The implementation correctly uses
MsgBroadcasterWithPkand maintains consistency with other example scripts.Also applies to: 8-8, 15-15, 25-36, 63-66
examples/chain_client/authz/2_MsgExec.py (2)
17-17: Correct use of grantee-specific broadcaster for authz exec.The implementation properly uses
new_for_grantee_account_using_gas_heuristicswhich is the appropriate method for authz exec scenarios where the grantee executes messages on behalf of the granter.Also applies to: 31-37
49-63: Clean implementation with improved variable naming.The rename from
msg0tomessageimproves readability, and the message construction correctly uses the granter's address while the grantee signs the transaction.examples/chain_client/exchange/10_MsgCreateDerivativeLimitOrder.py (1)
2-70: Consistent implementation following the established pattern.The refactoring to use
MsgBroadcasterWithPkis correctly implemented for derivative limit orders, maintaining consistency with other example scripts in the PR.examples/chain_client/insurance/3_MsgRequestRedemption.py (1)
2-56: Well-implemented refactoring for insurance module.The changes correctly apply the
MsgBroadcasterWithPkpattern to the insurance redemption example, maintaining consistency across the codebase.tests/client/chain/grpc/configurable_exchange_v2_query_servicer.py (2)
73-76: LGTM! Response queues follow established patterns.The new response queues are correctly initialized following the same pattern as existing queues in the servicer.
367-381: Implementation follows established patterns, but verify protobuf request types.The new handler methods are correctly implemented following the same pattern as existing methods. However, static analysis indicates the protobuf request types may not exist.
Please verify that the following protobuf request types are defined in the exchange v2 query protobuf:
QueryMarketBalanceRequestQueryMarketBalancesRequestQueryDenomMinNotionalRequestQueryDenomMinNotionalsRequest#!/bin/bash # Search for the protobuf request type definitions to verify they exist echo "Searching for protobuf request type definitions..." # Search for the request types in protobuf files rg -A 3 "message Query(MarketBalance|MarketBalances|DenomMinNotional|DenomMinNotionals)Request" --type proto # Alternative search in Python protobuf files if they exist rg -A 3 "QueryMarketBalanceRequest|QueryMarketBalancesRequest|QueryDenomMinNotionalRequest|QueryDenomMinNotionalsRequest" --type pytests/client/chain/grpc/test_chain_grpc_exchange_v2_api.py (1)
2732-2759: ```shell
#!/bin/bash
set -eCheck if exchange_pb2.py exists
echo "🔍 Checking for exchange_pb2.py file:"
ls pyinjective/proto/injective/exchange/v2/exchange_pb2.pySearch for DenomMinNotional in exchange_pb2.py
echo -e "\n🔍 Searching for DenomMinNotional in exchange_pb2.py:"
rg -n "DenomMinNotional" pyinjective/proto/injective/exchange/v2/exchange_pb2.py || echo "No matches found"Search for QueryDenomMinNotionalsResponse in query_pb2.py explicitly
echo -e "\n🔍 Verifying QueryDenomMinNotionalsResponse in query_pb2.py:"
rg -n "class QueryDenomMinNotionalsResponse" pyinjective/proto/injective/exchange/v2/query_pb2.py || echo "No class definition found"</details> <details> <summary>pyinjective/client/chain/grpc/chain_grpc_exchange_v2_api.py (1)</summary> `578-622`: **Code structure and patterns look correct.** The new methods follow the established patterns in the class: - Proper async/await usage - Consistent method signatures - Appropriate use of the `_execute_call` helper method - Correct protobuf request construction pattern However, the critical issue is the missing protobuf definitions flagged by static analysis. </details> </blockquote></details> </details> <!-- This is an auto-generated comment by CodeRabbit for review status -->
| async def main() -> None: | ||
| dotenv.load_dotenv() | ||
| configured_private_key = os.getenv("INJECTIVE_PRIVATE_KEY") | ||
| private_key_in_hexa = os.getenv("INJECTIVE_PRIVATE_KEY") |
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.
🛠️ Refactor suggestion
Add error handling for missing private key
The private key is retrieved from environment variable but there's no validation if it's None, which could cause runtime errors.
- private_key_in_hexa = os.getenv("INJECTIVE_PRIVATE_KEY")
+ private_key_in_hexa = os.getenv("INJECTIVE_PRIVATE_KEY")
+ if not private_key_in_hexa:
+ raise ValueError("INJECTIVE_PRIVATE_KEY environment variable is required")📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| private_key_in_hexa = os.getenv("INJECTIVE_PRIVATE_KEY") | |
| private_key_in_hexa = os.getenv("INJECTIVE_PRIVATE_KEY") | |
| if not private_key_in_hexa: | |
| raise ValueError("INJECTIVE_PRIVATE_KEY environment variable is required") |
🤖 Prompt for AI Agents
In examples/chain_client/oracle/1_MsgRelayPriceFeedPrice.py at line 15, the
private key is fetched from the environment without checking if it is None. Add
a validation step after retrieving the private key to check if it is None or
empty, and if so, raise an appropriate error or exit with a clear message
indicating the missing environment variable to prevent runtime errors.
| async def main() -> None: | ||
| dotenv.load_dotenv() | ||
| configured_private_key = os.getenv("INJECTIVE_PRIVATE_KEY") | ||
| private_key_in_hexa = os.getenv("INJECTIVE_PRIVATE_KEY") |
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.
🛠️ Refactor suggestion
Add error handling for missing private key
The private key is retrieved from environment variable but there's no validation if it's None, which could cause runtime errors.
- private_key_in_hexa = os.getenv("INJECTIVE_PRIVATE_KEY")
+ private_key_in_hexa = os.getenv("INJECTIVE_PRIVATE_KEY")
+ if not private_key_in_hexa:
+ raise ValueError("INJECTIVE_PRIVATE_KEY environment variable is required")📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| private_key_in_hexa = os.getenv("INJECTIVE_PRIVATE_KEY") | |
| private_key_in_hexa = os.getenv("INJECTIVE_PRIVATE_KEY") | |
| if not private_key_in_hexa: | |
| raise ValueError("INJECTIVE_PRIVATE_KEY environment variable is required") |
🤖 Prompt for AI Agents
In examples/chain_client/exchange/11_MsgCreateDerivativeMarketOrder.py at line
17, the private key is fetched from the environment without checking if it is
None. Add validation immediately after retrieving the private key to check if it
is None or empty, and raise a clear exception or error message to prevent
runtime errors later in the code.
| async def main() -> None: | ||
| dotenv.load_dotenv() | ||
| configured_private_key = os.getenv("INJECTIVE_PRIVATE_KEY") | ||
| private_key_in_hexa = os.getenv("INJECTIVE_PRIVATE_KEY") |
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.
🛠️ Refactor suggestion
Add error handling for missing private key
The private key is retrieved from environment variable but there's no validation if it's None, which could cause runtime errors.
- private_key_in_hexa = os.getenv("INJECTIVE_PRIVATE_KEY")
+ private_key_in_hexa = os.getenv("INJECTIVE_PRIVATE_KEY")
+ if not private_key_in_hexa:
+ raise ValueError("INJECTIVE_PRIVATE_KEY environment variable is required")📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| private_key_in_hexa = os.getenv("INJECTIVE_PRIVATE_KEY") | |
| private_key_in_hexa = os.getenv("INJECTIVE_PRIVATE_KEY") | |
| if not private_key_in_hexa: | |
| raise ValueError("INJECTIVE_PRIVATE_KEY environment variable is required") |
🤖 Prompt for AI Agents
In examples/chain_client/exchange/18_MsgExternalTransfer.py at line 15, the
private key is fetched from the environment without checking if it is None. Add
a validation step after retrieving the private key to check if it is None or
empty, and if so, raise an appropriate error or exit the program with a clear
message indicating the missing environment variable to prevent runtime errors.
| async def main() -> None: | ||
| dotenv.load_dotenv() | ||
| configured_private_key = os.getenv("INJECTIVE_PRIVATE_KEY") | ||
| private_key_in_hexa = os.getenv("INJECTIVE_PRIVATE_KEY") |
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.
🛠️ Refactor suggestion
Add error handling for missing private key
The private key is retrieved from environment variable but there's no validation if it's None, which could cause runtime errors.
- private_key_in_hexa = os.getenv("INJECTIVE_PRIVATE_KEY")
+ private_key_in_hexa = os.getenv("INJECTIVE_PRIVATE_KEY")
+ if not private_key_in_hexa:
+ raise ValueError("INJECTIVE_PRIVATE_KEY environment variable is required")📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| private_key_in_hexa = os.getenv("INJECTIVE_PRIVATE_KEY") | |
| private_key_in_hexa = os.getenv("INJECTIVE_PRIVATE_KEY") | |
| if not private_key_in_hexa: | |
| raise ValueError("INJECTIVE_PRIVATE_KEY environment variable is required") |
🤖 Prompt for AI Agents
In examples/chain_client/oracle/2_MsgRelayProviderPrices.py at line 15, the
private key is fetched from the environment without checking if it is None. Add
a validation step after retrieving the private key to check if it is None or
empty, and if so, raise an appropriate error or exit with a clear message
indicating the missing environment variable to prevent runtime errors.
| async def main() -> None: | ||
| dotenv.load_dotenv() | ||
| configured_private_key = os.getenv("INJECTIVE_PRIVATE_KEY") | ||
| private_key_in_hexa = os.getenv("INJECTIVE_PRIVATE_KEY") |
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.
🛠️ Refactor suggestion
Add error handling for missing private key
The private key is retrieved from environment variable but there's no validation if it's None, which could cause runtime errors.
- private_key_in_hexa = os.getenv("INJECTIVE_PRIVATE_KEY")
+ private_key_in_hexa = os.getenv("INJECTIVE_PRIVATE_KEY")
+ if not private_key_in_hexa:
+ raise ValueError("INJECTIVE_PRIVATE_KEY environment variable is required")📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| private_key_in_hexa = os.getenv("INJECTIVE_PRIVATE_KEY") | |
| private_key_in_hexa = os.getenv("INJECTIVE_PRIVATE_KEY") | |
| if not private_key_in_hexa: | |
| raise ValueError("INJECTIVE_PRIVATE_KEY environment variable is required") |
🤖 Prompt for AI Agents
In examples/chain_client/wasm/1_MsgExecuteContract.py at line 15, the private
key is fetched from the environment without checking if it is None. Add a
validation step after retrieving the private key to check if it is None or
empty, and if so, raise an appropriate error or exit with a clear message
indicating the missing environment variable to prevent runtime errors.
| @pytest.mark.asyncio | ||
| async def test_fetch_denom_min_notional( | ||
| self, | ||
| exchange_servicer, | ||
| ): | ||
| amount = "1" # Decimal as a string | ||
| response = exchange_query_pb.QueryDenomMinNotionalResponse( | ||
| amount=amount, | ||
| ) | ||
| exchange_servicer.denom_min_notional_responses.append(response) | ||
|
|
||
| api = self._api_instance(servicer=exchange_servicer) | ||
|
|
||
| denom_min_notional_response = await api.fetch_denom_min_notional( | ||
| denom="peggy0xf9152067989BDc8783fF586624124C05A529A5D1" | ||
| ) | ||
| expected_denom_min_notional = {"amount": amount} | ||
|
|
||
| assert denom_min_notional_response == expected_denom_min_notional | ||
|
|
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.
Missing protobuf class: QueryDenomMinNotionalResponse.
Static analysis indicates that QueryDenomMinNotionalResponse doesn't exist in the exchange_query_pb module. This will likely cause a runtime error.
🧰 Tools
🪛 Pylint (3.3.7)
[error] 2718-2718: Module 'pyinjective.proto.injective.exchange.v2.query_pb2' has no 'QueryDenomMinNotionalResponse' member
(E1101)
🤖 Prompt for AI Agents
In tests/client/chain/grpc/test_chain_grpc_exchange_v2_api.py around lines 2712
to 2731, the test uses QueryDenomMinNotionalResponse from exchange_query_pb, but
this protobuf class does not exist, causing runtime errors. To fix this, verify
the correct protobuf response class name for the denom min notional query in the
exchange_query_pb module or related protobuf definitions, then replace
QueryDenomMinNotionalResponse with the correct class. If the class is missing,
regenerate the protobuf files to include it or adjust the test to use an
existing valid response class.
| @pytest.mark.asyncio | ||
| async def test_fetch_market_balance( | ||
| self, | ||
| exchange_servicer, | ||
| ): | ||
| market_balance = exchange_query_pb.MarketBalance( | ||
| market_id="0x0611780ba69656949525013d947713300f56c37b6175e02f26bffa495c3208fe", | ||
| balance="1000000000000000000", | ||
| ) | ||
| response = exchange_query_pb.QueryMarketBalanceResponse( | ||
| balance=market_balance, | ||
| ) | ||
| exchange_servicer.market_balance_responses.append(response) | ||
|
|
||
| api = self._api_instance(servicer=exchange_servicer) | ||
|
|
||
| market_balance_response = await api.fetch_market_balance( | ||
| market_id="0x17ef48032cb24375ba7c2e39f384e56433bcab20cbee9a7357e4cba2eb00abe6" | ||
| ) | ||
| expected_market_balance = { | ||
| "balance": { | ||
| "marketId": market_balance.market_id, | ||
| "balance": market_balance.balance, | ||
| } | ||
| } | ||
|
|
||
| assert market_balance_response == expected_market_balance | ||
|
|
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.
🧩 Verification correct
Verify protobuf message class availability.
The test uses MarketBalance and QueryMarketBalanceResponse from the protobuf modules, but static analysis indicates these classes don't exist. This could cause runtime errors when the tests are executed.
Please verify that the protobuf files have been properly generated and include these message types. Run the following script to check for the missing classes:
🏁 Script executed:
#!/bin/bash
# Description: Search for MarketBalance and QueryMarketBalanceResponse definitions in protobuf files
# Check if MarketBalance exists in the codebase
rg -A 5 "class MarketBalance|message MarketBalance"
# Check if QueryMarketBalanceResponse exists
rg -A 5 "class QueryMarketBalanceResponse|message QueryMarketBalanceResponse"
# Check the actual protobuf module imports
python -c "
try:
from pyinjective.proto.injective.exchange.v2 import query_pb2 as exchange_query_pb
print('Available classes in exchange_query_pb:', [attr for attr in dir(exchange_query_pb) if 'MarketBalance' in attr])
except Exception as e:
print('Import error:', e)
"Length of output: 472
Verify protobuf message class availability.
The test uses MarketBalance and QueryMarketBalanceResponse from the protobuf modules, but static analysis indicates these classes don't exist. This could cause runtime errors when the tests are executed.
Please verify that the protobuf files have been properly generated and include these message types. Run the following script to check for the missing classes:
#!/bin/bash
# Description: Search for MarketBalance and QueryMarketBalanceResponse definitions in protobuf files
# Check if MarketBalance exists in the codebase
rg -A 5 "class MarketBalance|message MarketBalance"
# Check if QueryMarketBalanceResponse exists
rg -A 5 "class QueryMarketBalanceResponse|message QueryMarketBalanceResponse"
# Check the actual protobuf module imports
python -c "
try:
from pyinjective.proto.injective.exchange.v2 import query_pb2 as exchange_query_pb
print('Available classes in exchange_query_pb:', [attr for attr in dir(exchange_query_pb) if 'MarketBalance' in attr])
except Exception as e:
print('Import error:', e)
"🧰 Tools
🪛 Pylint (3.3.7)
[error] 2655-2655: Module 'pyinjective.proto.injective.exchange.v2.query_pb2' has no 'MarketBalance' member
(E1101)
[error] 2659-2659: Module 'pyinjective.proto.injective.exchange.v2.query_pb2' has no 'QueryMarketBalanceResponse' member
(E1101)
🤖 Prompt for AI Agents
In tests/client/chain/grpc/test_chain_grpc_exchange_v2_api.py around lines 2650
to 2677, the test uses protobuf message classes MarketBalance and
QueryMarketBalanceResponse which static analysis indicates may not exist,
risking runtime errors. Verify that the protobuf files have been properly
generated and include these message types by running the suggested shell script
to search for their definitions and checking the actual protobuf module imports.
If the classes are missing, regenerate the protobuf files or update the test to
use the correct existing message classes.
| async def fetch_market_balance(self, market_id: str) -> Dict[str, Any]: | ||
| request = exchange_query_pb.QueryMarketBalanceRequest(market_id=market_id) | ||
| response = await self._execute_call(call=self._stub.MarketBalance, request=request) | ||
|
|
||
| return response | ||
|
|
||
| async def fetch_market_balances(self) -> Dict[str, Any]: | ||
| request = exchange_query_pb.QueryMarketBalancesRequest() | ||
| response = await self._execute_call(call=self._stub.MarketBalances, request=request) | ||
|
|
||
| return response | ||
|
|
||
| async def fetch_denom_min_notional(self, denom: str) -> Dict[str, Any]: | ||
| request = exchange_query_pb.QueryDenomMinNotionalRequest(denom=denom) | ||
| response = await self._execute_call(call=self._stub.DenomMinNotional, request=request) | ||
|
|
||
| return response | ||
|
|
||
| async def fetch_denom_min_notionals(self) -> Dict[str, Any]: | ||
| request = exchange_query_pb.QueryDenomMinNotionalsRequest() | ||
| response = await self._execute_call(call=self._stub.DenomMinNotionals, request=request) | ||
| return 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.
✅ Verification successful
Verify protobuf definitions exist for market balance and denomination methods.
The static analysis indicates that several protobuf request classes are missing:
QueryMarketBalanceRequestQueryMarketBalancesRequestQueryDenomMinNotionalRequestQueryDenomMinNotionalsRequest
These methods will fail at runtime if the protobuf definitions don't exist.
🏁 Script executed:
#!/bin/bash
# Description: Verify if the protobuf request classes exist for market balance and denomination methods
# Expected: Find the protobuf class definitions or identify the correct class names
echo "Searching for market balance request classes..."
rg -A 3 "QueryMarketBalanceRequest|QueryMarketBalancesRequest"
echo "Searching for denomination min notional request classes..."
rg -A 3 "QueryDenomMinNotionalRequest|QueryDenomMinNotionalsRequest"
# Search for similar market balance and denomination classes
echo "Searching for similar market balance classes..."
rg -i "market.*balance|balance.*market"
echo "Searching for similar denomination classes..."
rg -i "denom.*min.*notional|min.*notional.*denom"
# List all available Query request classes in the protobuf module
echo "Available Query request classes in exchange v2 protobuf:"
ast-grep --pattern 'class Query$_Request'Length of output: 65853
Verify protobuf definitions exist for market balance and denomination methods.
The static analysis indicates that several protobuf request classes are missing:
QueryMarketBalanceRequestQueryMarketBalancesRequestQueryDenomMinNotionalRequestQueryDenomMinNotionalsRequest
These methods will fail at runtime if the protobuf definitions don't exist.
#!/bin/bash
# Description: Verify if the protobuf request classes exist for market balance and denomination methods
# Expected: Find the protobuf class definitions or identify the correct class names
echo "Searching for market balance request classes..."
rg -A 3 "QueryMarketBalanceRequest|QueryMarketBalancesRequest"
echo "Searching for denomination min notional request classes..."
rg -A 3 "QueryDenomMinNotionalRequest|QueryDenomMinNotionalsRequest"
# Search for similar market balance and denomination classes
echo "Searching for similar market balance classes..."
rg -i "market.*balance|balance.*market"
echo "Searching for similar denomination classes..."
rg -i "denom.*min.*notional|min.*notional.*denom"
# List all available Query request classes in the protobuf module
echo "Available Query request classes in exchange v2 protobuf:"
ast-grep --pattern 'class Query$_Request'🧰 Tools
🪛 Pylint (3.3.7)
[error] 601-601: Module 'pyinjective.proto.injective.exchange.v2.query_pb2' has no 'QueryMarketBalanceRequest' member
(E1101)
[error] 607-607: Module 'pyinjective.proto.injective.exchange.v2.query_pb2' has no 'QueryMarketBalancesRequest' member
(E1101)
[error] 613-613: Module 'pyinjective.proto.injective.exchange.v2.query_pb2' has no 'QueryDenomMinNotionalRequest' member
(E1101)
[error] 619-619: Module 'pyinjective.proto.injective.exchange.v2.query_pb2' has no 'QueryDenomMinNotionalsRequest' member
(E1101)
🤖 Prompt for AI Agents
In pyinjective/client/chain/grpc/chain_grpc_exchange_v2_api.py around lines 600
to 622, the protobuf request classes used in fetch_market_balance,
fetch_market_balances, fetch_denom_min_notional, and fetch_denom_min_notionals
methods may not exist, which will cause runtime failures. Verify the existence
and correct names of these protobuf request classes in the exchange_query_pb
module by searching the protobuf definitions for QueryMarketBalanceRequest,
QueryMarketBalancesRequest, QueryDenomMinNotionalRequest, and
QueryDenomMinNotionalsRequest. If they do not exist or are named differently,
update the code to use the correct protobuf request classes accordingly.
| async def fetch_l3_derivative_orderbook( | ||
| self, | ||
| market_id: str, | ||
| ) -> Dict[str, Any]: | ||
| request = exchange_query_pb.QueryFullDerivativeOrderbookRequest( | ||
| market_id=market_id, | ||
| ) | ||
| response = await self._execute_call(call=self._stub.L3DerivativeOrderBook, request=request) | ||
|
|
||
| return response | ||
|
|
||
| async def fetch_l3_spot_orderbook( | ||
| self, | ||
| market_id: str, | ||
| ) -> Dict[str, Any]: | ||
| request = exchange_query_pb.QueryFullSpotOrderbookRequest( | ||
| market_id=market_id, | ||
| ) | ||
| response = await self._execute_call(call=self._stub.L3SpotOrderBook, request=request) | ||
|
|
||
| return 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.
❌ Incorrect review comment
Verify protobuf definitions exist for L3 orderbook methods.
The static analysis indicates that QueryFullDerivativeOrderbookRequest and QueryFullSpotOrderbookRequest classes don't exist in the protobuf module. These methods will fail at runtime if the protobuf definitions are missing.
🏁 Script executed:
#!/bin/bash
# Description: Verify if the protobuf request classes exist in the exchange v2 query module
# Expected: Find the protobuf class definitions or identify the correct class names
# Search for the protobuf request classes in the codebase
echo "Searching for QueryFullDerivativeOrderbookRequest..."
rg -A 5 "QueryFullDerivativeOrderbookRequest"
echo "Searching for QueryFullSpotOrderbookRequest..."
rg -A 5 "QueryFullSpotOrderbookRequest"
# Search for similar L3 orderbook related classes
echo "Searching for L3 orderbook related classes..."
rg -i "l3.*orderbook|orderbook.*l3"
# Check what's actually available in the protobuf module
echo "Checking available request classes in exchange v2 query protobuf..."
fd -t f -e py . | xargs rg "class Query.*Request" | grep -E "(exchange|query)"Length of output: 99171
Verify protobuf definitions exist for L3 orderbook methods.
The static analysis indicates that QueryFullDerivativeOrderbookRequest and QueryFullSpotOrderbookRequest classes don't exist in the protobuf module. These methods will fail at runtime if the protobuf definitions are missing.
#!/bin/bash
# Description: Verify if the protobuf request classes exist in the exchange v2 query module
# Expected: Find the protobuf class definitions or identify the correct class names
# Search for the protobuf request classes in the codebase
echo "Searching for QueryFullDerivativeOrderbookRequest..."
rg -A 5 "QueryFullDerivativeOrderbookRequest"
echo "Searching for QueryFullSpotOrderbookRequest..."
rg -A 5 "QueryFullSpotOrderbookRequest"
# Search for similar L3 orderbook related classes
echo "Searching for L3 orderbook related classes..."
rg -i "l3.*orderbook|orderbook.*l3"
# Check what's actually available in the protobuf module
echo "Checking available request classes in exchange v2 query protobuf..."
fd -t f -e py . | xargs rg "class Query.*Request" | grep -E "(exchange|query)"🧰 Tools
🪛 Pylint (3.3.7)
[error] 582-582: Module 'pyinjective.proto.injective.exchange.v2.query_pb2' has no 'QueryFullDerivativeOrderbookRequest' member
(E1101)
[error] 593-593: Module 'pyinjective.proto.injective.exchange.v2.query_pb2' has no 'QueryFullSpotOrderbookRequest' member
(E1101)
🤖 Prompt for AI Agents
In pyinjective/client/chain/grpc/chain_grpc_exchange_v2_api.py around lines 578
to 598, the protobuf request classes QueryFullDerivativeOrderbookRequest and
QueryFullSpotOrderbookRequest are used but may not exist in the protobuf module,
causing runtime failures. Verify the actual protobuf definitions by searching
the protobuf files for these classes or similar L3 orderbook request classes. If
they do not exist, replace these request classes with the correct existing
protobuf request classes or update the protobuf definitions accordingly to match
the intended functionality.
Summary by CodeRabbit