Skip to content

Conversation

@aarmoa
Copy link
Collaborator

@aarmoa aarmoa commented Jun 23, 2025

  • Added missing endpoints in AsyncClient v2
  • Fixed errors in the example scripts

Summary by CodeRabbit

  • New Features
    • Added support for querying individual and all market balances, as well as minimum notional values for denominations, in the exchange API.
  • Refactor
    • Simplified transaction broadcasting in example scripts by using a higher-level broadcaster abstraction, improving code readability and maintainability.
    • Enhanced output formatting in example scripts to display responses as pretty-printed JSON for improved readability.
  • Bug Fixes
    • Removed duplicate methods for fetching level 3 orderbooks in the exchange API.
  • Tests
    • Added new tests to verify market balance and denomination minimum notional query functionality in the exchange API.
  • Chores
    • Updated test utilities to support new query types for market balances and denomination minimum notionals.
    • Removed outdated example scripts for fetching level 3 orderbooks.

@aarmoa aarmoa requested a review from Copilot June 23, 2025 12:42
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jun 23, 2025

Walkthrough

This 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

Files / Groups Change Summary
pyinjective/client/chain/grpc/chain_grpc_exchange_v2_api.py Adds async methods for fetching market balances and denom min notionals; removes duplicate L3 orderbook methods.
tests/client/chain/grpc/configurable_exchange_v2_query_servicer.py Adds response queues and async handlers for new market balance and denom min notional query types.
tests/client/chain/grpc/test_chain_grpc_exchange_v2_api.py Adds async pytest test cases for new API methods: market balances and denom min notionals.
examples/chain_client/.../query/*.py Adds JSON pretty-printing for output in all query scripts.
examples/chain_client/.../1_Msg*.py, .../Msg*.py, .../Msg*.py Refactors transaction scripts to use MsgBroadcasterWithPk abstraction for broadcasting, removes manual logic.
examples/chain_client/.../new_using_gas_heuristics.py Changes broadcaster instantiation to use new_using_gas_heuristics where previously new_without_simulation.
examples/chain_client/exchange/query/59_L3DerivativeOrderBook.py
.../60_L3SpotOrderBook.py
Removes outdated example scripts for L3 orderbook queries.
examples/chain_client/exchange/query/59_MarketBalance.py
.../60_MarketBalances.py
Updates to fetch and pretty-print market balances, changes hardcoded IDs, updates docstrings.

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
Loading
sequenceDiagram
    participant API
    participant gRPCStub
    participant Servicer

    API->>gRPCStub: fetch_market_balances()
    gRPCStub->>Servicer: MarketBalances request
    Servicer-->>gRPCStub: MarketBalancesResponse
    gRPCStub-->>API: response dict
Loading

Poem

🐇✨
New queries bloom in gRPC land,
Market balances close at hand.
Scripts now print in JSON bright,
And broadcasters make the flow light.
Outdated examples hop away,
While tests ensure all’s okay—
A garden of code, neat and spry!

✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need 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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

Copilot AI left a 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"

Comment on lines +23 to +25
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)
Copy link

Copilot AI Jun 23, 2025

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.

Suggested change
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)

Copilot uses AI. Check for mistakes.
Copy link
Contributor

@coderabbitai coderabbitai bot left a 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 MarketBalance and QueryMarketBalancesResponse classes 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 use indent=2; here it’s indent=4. Consider standardizing on indent=2 for 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_heuristics is a good improvement consistent with the refactor pattern. However, the filename 5_MessageBroadcasterWithoutSimulation.py now 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.py
examples/chain_client/exchange/query/59_MarketBalance.py (1)

10-10: Fix docstring inconsistency

The 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 count

Static 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 MsgBroadcasterWithPk during 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 PrivateKey object is created from the hex string, but the MsgBroadcasterWithPk already 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

📥 Commits

Reviewing files that changed from the base of the PR and between fbe418c and 7fa372d.

📒 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.
Importing json enables use of json.dumps for formatting API responses.


29-29: Pretty-print grant authorizations response.
Using json.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.
Importing json is required to use json.dumps for formatted output.


12-12: Pretty-print community pool data.
Switching to json.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.
The json module is needed to serialize the validators list with indentation.


15-15: Pretty-print delegator validators response.
Using json.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.
Importing json allows formatting the account object with json.dumps.


13-13: Pretty-print account information.
Replacing the raw print with json.dumps(acc, indent=2) improves output readability.

examples/chain_client/distribution/query/5_DelegationRewards.py (2)

2-2: Add JSON import for serialization.
The json module is required to serialize the rewards object nicely.


16-16: Pretty-print delegation rewards data.
Using json.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 added import json is necessary for the subsequent json.dumps call.


13-13: Pretty-print JSON output
Using json.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 new import json enables pretty-printing of the grants response.


20-20: Pretty-print JSON output
Switching to json.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
Adding import json allows the use of json.dumps for transaction responses.


136-136: Pretty-print JSON broadcast response
Replacing raw print(res) with print(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
The json import is required for the formatted printing of bank balances.


13-13: Pretty-print JSON output
Using json.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 added import json supports the pretty-printing of slashes data.


17-17: Pretty-print JSON output
Applying json.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
Including import json ensures that the subsequent output formatting call to json.dumps will work correctly.


13-13: Pretty-print spendable balances as JSON
Switching from a raw print to json.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
The json module is required to format the metadata object in an indented JSON string.


13-13: Pretty-print denomination metadata as JSON
Using json.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
Ensure json is imported to support the formatted output of the denominations metadata.


15-15: Pretty-print denominations metadata as JSON
Replacing the raw print with json.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
Importing json is necessary for the upcoming formatted print call.


15-15: Pretty-print exchange balances as JSON
Switching to json.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
The json module is required to format the fetched rewards data.


15-15: Pretty-print delegation total rewards as JSON
Using json.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 of json.dumps to format output.


13-13: Format output as pretty-printed JSON
Using json.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 enable json.dumps for formatted output.


18-18: Pretty-print aggregate market volume
Switching to json.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
Using json.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 call json.dumps for output formatting.


15-15: Pretty-print total supply output
Using json.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 json import is required to format the output with json.dumps.


12-12: Pretty-print the supply_of result.

Replacing the raw print(supply_of) with print(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 json module enables formatting of the delegate withdraw address response.


15-15: Pretty-print the withdraw_address result.

Switching from print(withdraw_address) to print(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 json module is now needed to serialize the bank_balance response.


14-14: Pretty-print the bank_balance result.

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 json import supports formatted output of spendable balances.


14-14: Pretty-print the spendable_balances result.

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 json is necessary to serialize the aggregate volume data.


31-31: Pretty-print the volume result.

Replacing print(volume) with print(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.
The json import enables usage of json.dumps to pretty-print the fetched deposits.


31-31: Pretty-print subaccount deposits as JSON.
Using json.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.
Including json is required for the pretty-printed output of the send-enabled response.


17-17: Pretty-print send-enabled response as JSON.
Switching to json.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 use json.dumps for prettifying the deposit output.


31-31: Pretty-print single subaccount deposit as JSON.
Replacing the raw print with json.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.
The json import enables pretty-printing of the fetched market balances.


22-22: Pretty-print market balances as JSON.
Using json.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 of json.dumps to format the aggregate volume data.


30-30: Pretty-print aggregate volume (account) as JSON.
Switching to json.dumps(volume, indent=2) presents the first volume result in a structured format.


33-33: Pretty-print aggregate volume (subaccount) as JSON.
Applying json.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.dumps with 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_simulation to new_using_gas_heuristics represents 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_heuristics is 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 heuristics

The change from new_without_simulation to new_using_gas_heuristics aligns 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 formatting

Adding the json import enables pretty-printing of the response, improving readability.


20-24: LGTM: Clean API usage with improved output formatting

The 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 improvement

The change to new_using_gas_heuristics is 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 instantiation

The update to new_using_gas_heuristics follows 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 functionality

Adding json import for pretty-printing and MsgBroadcasterWithPk for standardized transaction broadcasting are both positive improvements.

Also applies to: 10-10


26-36: LGTM: Standardized transaction broadcasting

The 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 formatting

The 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 json for pretty-printing and MsgBroadcasterWithPk for 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 MsgBroadcasterWithPk with 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 MsgBroadcasterWithPk abstraction.

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 MsgBroadcasterWithPk successfully 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 MsgBroadcasterWithPk class is properly exported and available in the pyinjective.core.broadcaster module 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.py
examples/chain_client/insurance/1_MsgCreateInsuranceFund.py (2)

29-35: Successful systematic refactoring across examples.

The consistent adoption of MsgBroadcasterWithPk across 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 formatting

The json import is correctly added to support pretty-printed transaction responses.


8-8: LGTM: Broadcaster import added

The MsgBroadcasterWithPk import is correctly added to support the new transaction broadcasting approach.


24-34: LGTM: Gas price handling and broadcaster initialization

The 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 output

The 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 broadcasting

The 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 formatting

The json import is correctly added to support pretty-printed transaction responses.


10-10: LGTM: Broadcaster import added

The MsgBroadcasterWithPk import is correctly added to support the new transaction broadcasting approach.


26-36: LGTM: Gas price handling and broadcaster initialization

The gas price adjustment and broadcaster initialization are correctly implemented for derivative market orders.


62-65: LGTM: Simplified broadcasting with improved output

The broadcasting logic is correctly simplified using the broadcaster abstraction, and the JSON formatting improves readability.


70-70: LGTM: Gas price update after broadcasting

The 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 formatting

The json import is correctly added to support pretty-printed transaction responses.


8-8: LGTM: Broadcaster import added

The MsgBroadcasterWithPk import is correctly added to support the new transaction broadcasting approach.


24-34: LGTM: Gas price handling and broadcaster initialization

The gas price adjustment and broadcaster initialization are correctly implemented for external transfers.


51-54: LGTM: Simplified broadcasting with improved output

The broadcasting logic is correctly simplified using the broadcaster abstraction, and the JSON formatting improves readability.


59-59: LGTM: Gas price update after broadcasting

The 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 formatting

The json import is correctly added to support pretty-printed transaction responses.


8-8: LGTM: Broadcaster import added

The MsgBroadcasterWithPk import is correctly added to support the new transaction broadcasting approach.


24-34: LGTM: Gas price handling and broadcaster initialization

The gas price adjustment and broadcaster initialization are correctly implemented for oracle provider prices.


49-52: LGTM: Simplified broadcasting with improved output

The broadcasting logic is correctly simplified using the broadcaster abstraction, and the JSON formatting improves readability.


57-57: LGTM: Gas price update after broadcasting

The 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 formatting

The json import is correctly added to support pretty-printed transaction responses.


8-8: LGTM: Broadcaster import added

The MsgBroadcasterWithPk import is correctly added to support the new transaction broadcasting approach.


25-35: LGTM: Gas price handling and broadcaster initialization

The gas price adjustment and broadcaster initialization are correctly implemented for WASM contract execution.


58-61: LGTM: Simplified broadcasting with improved output

The broadcasting logic is correctly simplified using the broadcaster abstraction, and the JSON formatting improves readability.


66-66: LGTM: Gas price update after broadcasting

The 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 json import 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 MsgBroadcasterWithPk simplifies the code and makes it more maintainable.


53-56: I wasn’t able to locate the gas‐handling logic or update_gas_price definition 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 json import for pretty-printing aligns with the broader refactoring across example scripts.


28-35: Well-structured broadcaster initialization.

The MsgBroadcasterWithPk.new_using_gas_heuristics initialization 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 Decimal is 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_id and order_hash are 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 MsgBroadcasterWithPk pattern across all example types, creating a unified approach to transaction broadcasting.


41-41: Appropriately simple message composition.

The msg_rewards_opt_out message 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 MsgBroadcasterWithPk simplifies 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 MsgBroadcasterWithPk and 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_heuristics which 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 msg0 to message improves 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 MsgBroadcasterWithPk is 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 MsgBroadcasterWithPk pattern 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:

  • QueryMarketBalanceRequest
  • QueryMarketBalancesRequest
  • QueryDenomMinNotionalRequest
  • QueryDenomMinNotionalsRequest
#!/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 py
tests/client/chain/grpc/test_chain_grpc_exchange_v2_api.py (1)

2732-2759: ```shell
#!/bin/bash
set -e

Check if exchange_pb2.py exists

echo "🔍 Checking for exchange_pb2.py file:"
ls pyinjective/proto/injective/exchange/v2/exchange_pb2.py

Search 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")
Copy link
Contributor

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.

Suggested change
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")
Copy link
Contributor

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.

Suggested change
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")
Copy link
Contributor

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.

Suggested change
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")
Copy link
Contributor

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.

Suggested change
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")
Copy link
Contributor

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.

Suggested change
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.

Comment on lines +2712 to +2731
@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

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

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.

Comment on lines +2650 to +2677
@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

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

🧩 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.

Comment on lines +600 to +622
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

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

✅ Verification successful

Verify protobuf definitions exist for market balance and denomination methods.

The static analysis indicates that several protobuf request classes are missing:

  • QueryMarketBalanceRequest
  • QueryMarketBalancesRequest
  • QueryDenomMinNotionalRequest
  • QueryDenomMinNotionalsRequest

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:

  • QueryMarketBalanceRequest
  • QueryMarketBalancesRequest
  • QueryDenomMinNotionalRequest
  • QueryDenomMinNotionalsRequest

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.

Comment on lines +578 to +598
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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

❌ 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.

@aarmoa aarmoa merged commit afacb99 into dev Jun 23, 2025
33 of 58 checks passed
@aarmoa aarmoa deleted the chore/fix_example_scripts branch June 23, 2025 12:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants