-
Notifications
You must be signed in to change notification settings - Fork 28
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
Release/release v140 to master #311
Conversation
Fix/sync dev with master 110
…alization_logic (feat) Cleaned up the markets initialization logic
…o fix/sync_dev_with_master_1_12_0
…_12_0 Fix/sync dev with master 1.12.0
…Added the use of `dotenv` to load private keys into environment variables. Removed `asyncio` package dependency
…o feat/use_dot_env_in_examples
Feat/use dot env in examples
…o new example scripts for all queries and unit tests
…the `distribution` module. Marked as deprecated old functions not following Python naming standards and created the replacements for them (with the correct name following standards)
…Added the use of `dotenv` to load private keys into environment variables. Removed `asyncio` package dependency
…o feat/sync_dev_with_master_130
Feat/sync dev with master 1.3.0
…o new example scripts for all queries and unit tests
…the `distribution` module. Marked as deprecated old functions not following Python naming standards and created the replacements for them (with the correct name following standards)
…//github.com/InjectiveLabs/sdk-python into feat/add_distribution_module_queries_support
…le_queries_support Feat/add distribution module queries support
…new example scripts for all the queries and unit tests.
…er. Added unit tests for new messages. Refactored example scripts to move them into separated subfolders for each module.
…dule_support Feat/add chain exchange module support
…Added the use of `dotenv` to load private keys into environment variables. Removed `asyncio` package dependency
…Added the use of `dotenv` to load private keys into environment variables. Removed `asyncio` package dependency
…o new example scripts for all queries and unit tests
…the `distribution` module. Marked as deprecated old functions not following Python naming standards and created the replacements for them (with the correct name following standards)
…new example scripts for all the queries and unit tests.
…er. Added unit tests for new messages. Refactored example scripts to move them into separated subfolders for each module.
…new example scripts for all the queries and unit tests.
…er. Added unit tests for new messages. Refactored example scripts to move them into separated subfolders for each module.
…ule: TradeRewardCampaign
…o feat/add_trade_reward_campaign_endpoint
…aign_endpoint Feat/add trade reward campaign endpoint
fix/fix_example_script_errors
WalkthroughThe update to version 1.4.0 introduces a significant overhaul aimed at enhancing security, flexibility, and functionality. Key improvements include the adoption of Changes
TipsChatThere are 3 ways to chat with CodeRabbit:
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 as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #311 +/- ##
==========================================
+ Coverage 72.81% 76.16% +3.34%
==========================================
Files 48 50 +2
Lines 3384 4111 +727
Branches 303 351 +48
==========================================
+ Hits 2464 3131 +667
- Misses 839 875 +36
- Partials 81 105 +24 ☔ View full report in Codecov by Sentry. |
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.
Review Status
Actionable comments generated: 40
Configuration used: .coderabbit.yaml
Files selected for processing (140)
- .coderabbit.yaml (1 hunks)
- CHANGELOG.md (1 hunks)
- examples/SendToInjective.py (1 hunks)
- examples/chain_client/1_LocalOrderHash.py (8 hunks)
- examples/chain_client/3_MessageBroadcaster.py (3 hunks)
- examples/chain_client/4_MessageBroadcasterWithGranteeAccount.py (4 hunks)
- examples/chain_client/5_MessageBroadcasterWithoutSimulation.py (3 hunks)
- examples/chain_client/6_MessageBroadcasterWithGranteeAccountWithoutSimulation.py (4 hunks)
- examples/chain_client/auction/1_MsgBid.py (4 hunks)
- examples/chain_client/authz/1_MsgGrant.py (5 hunks)
- examples/chain_client/authz/2_MsgExec.py (4 hunks)
- examples/chain_client/authz/3_MsgRevoke.py (4 hunks)
- examples/chain_client/authz/query/1_Grants.py (1 hunks)
- examples/chain_client/bank/1_MsgSend.py (4 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 (1 hunks)
- examples/chain_client/distribution/query/2_ValidatorOutstandingRewards.py (1 hunks)
- examples/chain_client/distribution/query/3_ValidatorCommission.py (1 hunks)
- examples/chain_client/distribution/query/4_ValidatorSlashes.py (1 hunks)
- examples/chain_client/distribution/query/5_DelegationRewards.py (1 hunks)
- examples/chain_client/distribution/query/6_DelegationTotalRewards.py (1 hunks)
- examples/chain_client/distribution/query/7_DelegatorValidators.py (1 hunks)
- examples/chain_client/distribution/query/8_DelegatorWithdrawAddress.py (1 hunks)
- examples/chain_client/distribution/query/9_CommunityPool.py (1 hunks)
- examples/chain_client/exchange/10_MsgCreateDerivativeLimitOrder.py (5 hunks)
- examples/chain_client/exchange/11_MsgCreateDerivativeMarketOrder.py (5 hunks)
- examples/chain_client/exchange/12_MsgCancelDerivativeOrder.py (5 hunks)
- examples/chain_client/exchange/13_MsgInstantBinaryOptionsMarketLaunch.py (1 hunks)
- examples/chain_client/exchange/14_MsgCreateBinaryOptionsLimitOrder.py (5 hunks)
- examples/chain_client/exchange/15_MsgCreateBinaryOptionsMarketOrder.py (5 hunks)
- examples/chain_client/exchange/16_MsgCancelBinaryOptionsOrder.py (5 hunks)
- examples/chain_client/exchange/17_MsgSubaccountTransfer.py (4 hunks)
- examples/chain_client/exchange/18_MsgExternalTransfer.py (4 hunks)
- examples/chain_client/exchange/19_MsgLiquidatePosition.py (5 hunks)
- examples/chain_client/exchange/1_MsgDeposit.py (3 hunks)
- examples/chain_client/exchange/20_MsgIncreasePositionMargin.py (5 hunks)
- examples/chain_client/exchange/21_MsgRewardsOptOut.py (4 hunks)
- examples/chain_client/exchange/22_MsgAdminUpdateBinaryOptionsMarket.py (4 hunks)
- examples/chain_client/exchange/2_MsgWithdraw.py (4 hunks)
- examples/chain_client/exchange/3_MsgInstantSpotMarketLaunch.py (1 hunks)
- examples/chain_client/exchange/4_MsgInstantPerpetualMarketLaunch.py (1 hunks)
- examples/chain_client/exchange/5_MsgInstantExpiryFuturesMarketLaunch.py (1 hunks)
- examples/chain_client/exchange/6_MsgCreateSpotLimitOrder.py (5 hunks)
- examples/chain_client/exchange/7_MsgCreateSpotMarketOrder.py (5 hunks)
- examples/chain_client/exchange/8_MsgCancelSpotOrder.py (4 hunks)
- examples/chain_client/exchange/9_MsgBatchUpdateOrders.py (5 hunks)
- examples/chain_client/exchange/query/10_SpotMarkets.py (1 hunks)
- examples/chain_client/exchange/query/11_SpotMarket.py (1 hunks)
- examples/chain_client/exchange/query/12_FullSpotMarkets.py (1 hunks)
- examples/chain_client/exchange/query/13_FullSpotMarket.py (1 hunks)
- examples/chain_client/exchange/query/14_SpotOrderbook.py (1 hunks)
- examples/chain_client/exchange/query/15_TraderSpotOrders.py (1 hunks)
- examples/chain_client/exchange/query/16_AccountAddressSpotOrders.py (1 hunks)
- examples/chain_client/exchange/query/17_SpotOrdersByHashes.py (1 hunks)
- examples/chain_client/exchange/query/18_SubaccountOrders.py (1 hunks)
- examples/chain_client/exchange/query/19_TraderSpotTransientOrders.py (1 hunks)
- examples/chain_client/exchange/query/1_SubaccountDeposits.py (1 hunks)
- examples/chain_client/exchange/query/20_SpotMidPriceAndTOB.py (1 hunks)
- examples/chain_client/exchange/query/21_DerivativeMidPriceAndTOB.py (1 hunks)
- examples/chain_client/exchange/query/22_DerivativeOrderbook.py (1 hunks)
- examples/chain_client/exchange/query/23_TraderDerivativeOrders.py (1 hunks)
- examples/chain_client/exchange/query/24_AccountAddressDerivativeOrders.py (1 hunks)
- examples/chain_client/exchange/query/25_DerivativeOrdersByHashes.py (1 hunks)
- examples/chain_client/exchange/query/26_TraderDerivativeTransientOrders.py (1 hunks)
- examples/chain_client/exchange/query/27_DerivativeMarkets.py (1 hunks)
- examples/chain_client/exchange/query/28_DerivativeMarket.py (1 hunks)
- examples/chain_client/exchange/query/29_DerivativeMarketAddress.py (1 hunks)
- examples/chain_client/exchange/query/2_SubaccountDeposit.py (1 hunks)
- examples/chain_client/exchange/query/30_SubaccountTradeNonce.py (1 hunks)
- examples/chain_client/exchange/query/31_Positions.py (1 hunks)
- examples/chain_client/exchange/query/32_SubaccountPositions.py (1 hunks)
- examples/chain_client/exchange/query/33_SubaccountPositionInMarket.py (1 hunks)
- examples/chain_client/exchange/query/34_SubaccountEffectivePositionInMarket.py (1 hunks)
- examples/chain_client/exchange/query/35_PerpetualMarketInfo.py (1 hunks)
- examples/chain_client/exchange/query/36_ExpiryFuturesMarketInfo.py (1 hunks)
- examples/chain_client/exchange/query/37_PerpetualMarketFunding.py (1 hunks)
- examples/chain_client/exchange/query/38_SubaccountOrderMetadata.py (1 hunks)
- examples/chain_client/exchange/query/39_TradeRewardPoints.py (1 hunks)
- examples/chain_client/exchange/query/3_ExchangeBalances.py (1 hunks)
- examples/chain_client/exchange/query/40_PendingTradeRewardPoints.py (1 hunks)
- examples/chain_client/exchange/query/41_TradeRewardCampaign.py (1 hunks)
- examples/chain_client/exchange/query/42_FeeDiscountAccountInfo.py (1 hunks)
- examples/chain_client/exchange/query/43_FeeDiscountSchedule.py (1 hunks)
- examples/chain_client/exchange/query/44_BalanceMismatches.py (1 hunks)
- examples/chain_client/exchange/query/45_BalanceWithBalanceHolds.py (1 hunks)
- examples/chain_client/exchange/query/46_FeeDiscountTierStatistics.py (1 hunks)
- examples/chain_client/exchange/query/47_MitoVaultInfos.py (1 hunks)
- examples/chain_client/exchange/query/48_QueryMarketIDFromVault.py (1 hunks)
- examples/chain_client/exchange/query/49_HistoricalTradeRecords.py (1 hunks)
- examples/chain_client/exchange/query/4_AggregateVolume.py (1 hunks)
- examples/chain_client/exchange/query/50_IsOptedOutOfRewards.py (1 hunks)
- examples/chain_client/exchange/query/51_OptedOutOfRewardsAccounts.py (1 hunks)
- examples/chain_client/exchange/query/52_MarketVolatility.py (1 hunks)
- examples/chain_client/exchange/query/53_BinaryOptionsMarkets.py (1 hunks)
- examples/chain_client/exchange/query/54_TraderDerivativeConditionalOrders.py (1 hunks)
- examples/chain_client/exchange/query/55_MarketAtomicExecutionFeeMultiplier.py (1 hunks)
- examples/chain_client/exchange/query/5_AggregateVolumes.py (1 hunks)
- examples/chain_client/exchange/query/6_AggregateMarketVolume.py (1 hunks)
- examples/chain_client/exchange/query/7_AggregateMarketVolumes.py (1 hunks)
- examples/chain_client/exchange/query/8_DenomDecimal.py (1 hunks)
- examples/chain_client/exchange/query/9_DenomDecimals.py (1 hunks)
- examples/chain_client/insurance/1_MsgCreateInsuranceFund.py (4 hunks)
- examples/chain_client/insurance/2_MsgUnderwrite.py (4 hunks)
- examples/chain_client/insurance/3_MsgRequestRedemption.py (4 hunks)
- examples/chain_client/oracle/1_MsgRelayPriceFeedPrice.py (4 hunks)
- examples/chain_client/oracle/2_MsgRelayProviderPrices.py (4 hunks)
- examples/chain_client/peggy/1_MsgSendToEth.py (4 hunks)
- examples/chain_client/staking/1_MsgDelegate.py (4 hunks)
- examples/chain_client/tokenfactory/1_CreateDenom.py (2 hunks)
- examples/chain_client/tokenfactory/2_MsgMint.py (3 hunks)
- examples/chain_client/tokenfactory/3_MsgBurn.py (3 hunks)
- examples/chain_client/tokenfactory/4_MsgChangeAdmin.py (2 hunks)
- examples/chain_client/tokenfactory/5_MsgSetDenomMetadata.py (2 hunks)
- examples/chain_client/wasm/1_MsgExecuteContract.py (4 hunks)
- examples/chain_client/wasmx/1_MsgExecuteContractCompat.py (4 hunks)
- poetry.lock (16 hunks)
- pyinjective/async_client.py (6 hunks)
- pyinjective/client/chain/grpc/chain_grpc_distribution_api.py (1 hunks)
- pyinjective/client/chain/grpc/chain_grpc_exchange_api.py (1 hunks)
- pyinjective/composer.py (24 hunks)
- pyinjective/core/broadcaster.py (2 hunks)
- pyinjective/core/market.py (1 hunks)
- pyinjective/denoms_devnet.ini (3 hunks)
- pyinjective/denoms_mainnet.ini (12 hunks)
- pyinjective/denoms_testnet.ini (5 hunks)
- pyproject.toml (2 hunks)
- tests/client/chain/grpc/configurable_distribution_query_servicer.py (1 hunks)
- tests/client/chain/grpc/configurable_exchange_query_servicer.py (1 hunks)
- tests/client/chain/grpc/test_chain_grpc_authz_api.py (1 hunks)
- tests/client/chain/grpc/test_chain_grpc_distribution_api.py (1 hunks)
- tests/core/test_gas_limit_estimator.py (12 hunks)
- tests/core/test_market.py (1 hunks)
- tests/core/test_message_based_transaction_fee_calculator.py (3 hunks)
- tests/test_async_client_deprecation_warnings.py (1 hunks)
- tests/test_composer.py (5 hunks)
- tests/test_composer_deprecation_warnings.py (1 hunks)
- tests/test_orderhash.py (2 hunks)
Files not summarized due to errors (3)
- poetry.lock: Error: Message exceeds token limit
- pyinjective/composer.py: Error: Message exceeds token limit
- tests/test_composer.py: Error: Message exceeds token limit
Files not reviewed due to errors (10)
- examples/chain_client/exchange/6_MsgCreateSpotLimitOrder.py (Error: unable to parse review)
- examples/chain_client/authz/1_MsgGrant.py (Error: unable to parse review)
- examples/chain_client/exchange/15_MsgCreateBinaryOptionsMarketOrder.py (Error: unable to parse review)
- examples/chain_client/exchange/10_MsgCreateDerivativeLimitOrder.py (Error: unable to parse review)
- examples/chain_client/exchange/11_MsgCreateDerivativeMarketOrder.py (Error: unable to parse review)
- examples/chain_client/exchange/14_MsgCreateBinaryOptionsLimitOrder.py (Error: unable to parse review)
- examples/chain_client/authz/2_MsgExec.py (Error: unable to parse review)
- examples/chain_client/exchange/19_MsgLiquidatePosition.py (Error: unable to parse review)
- pyinjective/client/chain/grpc/chain_grpc_distribution_api.py (Error: unable to parse review)
- examples/chain_client/exchange/9_MsgBatchUpdateOrders.py (Error: unable to parse review)
Additional comments: 321
.coderabbit.yaml (1)
- 1-8: The configuration for automated reviews and replies looks good and is a welcome addition to streamline the review process. However, please verify:
- The regex pattern
feat/.*
correctly matches the intended feature branch naming convention.- The auto-reply feature in chat is intended for all interactions, as it might not be suitable for all types of communications.
examples/chain_client/distribution/query/9_CommunityPool.py (1)
- 1-15: The script for querying the community pool looks well-implemented and aligns with the project's objectives for enhanced functionality. Please ensure that error handling in the
AsyncClient
andNetwork
classes is robust, especially for network-related errors, assuming this is managed upstream.examples/chain_client/exchange/query/47_MitoVaultInfos.py (1)
- 1-15: The script for querying Mito Vault information is well-structured and serves its purpose effectively. Consider adding documentation or comments on how to adapt this script for different network environments (e.g., mainnet), ensuring flexibility for various use cases.
examples/chain_client/exchange/query/3_ExchangeBalances.py (1)
- 1-14: The script for querying exchange balances is clear and aligns with the project's enhancement objectives. As with previous scripts, please ensure there's guidance on adapting the script for different network environments to maintain flexibility.
examples/chain_client/exchange/query/31_Positions.py (1)
- 1-15: The script for querying chain positions is effectively implemented and contributes to the project's objectives. Please continue to provide guidance on adapting the script for different network environments, ensuring it remains flexible for various use cases.
examples/chain_client/exchange/query/43_FeeDiscountSchedule.py (1)
- 1-15: The script for querying the fee discount schedule is well-structured and meets the project's enhancement goals. As with other scripts, guidance on adapting for different network environments would be beneficial to ensure flexibility.
examples/chain_client/exchange/query/45_BalanceWithBalanceHolds.py (1)
- 1-15: The script for querying balances with balance holds is effectively implemented and aligns with the project's objectives. Continuing the theme, please ensure there's guidance on adapting the script for different network environments.
examples/chain_client/exchange/query/51_OptedOutOfRewardsAccounts.py (1)
- 1-15: The script for querying accounts that have opted out of rewards is well-structured and contributes to the project's enhancement goals. Please continue to provide guidance on adapting the script for different network environments.
examples/chain_client/exchange/query/46_FeeDiscountTierStatistics.py (1)
- 1-15: The script for querying fee discount tier statistics is effectively implemented and aligns with the project's objectives. As with other scripts, guidance on adapting the script for different network environments would be beneficial.
examples/chain_client/exchange/query/44_BalanceMismatches.py (1)
- 1-15: The script for querying balance mismatches is well-structured and meets the project's enhancement goals. Continuing the theme, please ensure there's guidance on adapting the script for different network environments.
examples/chain_client/exchange/query/53_BinaryOptionsMarkets.py (1)
- 1-19: - The script is well-structured and follows good practices for asynchronous programming in Python.
- The use of
Network.testnet()
directly in the script limits its flexibility. Consider allowing the network type (local, testnet, mainnet) to be passed as an argument or read from a configuration file or environment variable for greater flexibility.- Ensure that the
AsyncClient
and thefetch_chain_binary_options_markets
method handle errors gracefully. It's important to catch exceptions that may arise from network issues or invalid responses and provide meaningful error messages to the user.- Adding a brief comment or documentation at the top of the script explaining its purpose and usage would enhance its maintainability and usability for new developers or users.
examples/chain_client/distribution/query/3_ValidatorCommission.py (1)
- 1-16: - The script is concise and follows good practices for asynchronous programming in Python.
- The hardcoded
validator_address
limits the script's flexibility. Consider allowing the validator address to be passed as an argument or read from a configuration file or environment variable to make the script more versatile.- Similar to the previous file, ensure that the
AsyncClient
and thefetch_validator_commission
method handle errors gracefully. Proper error handling is crucial for a robust script.- Adding a brief comment or documentation at the top of the script explaining its purpose, usage, and the expected format of the
validator_address
would improve its maintainability and usability.examples/chain_client/distribution/query/2_ValidatorOutstandingRewards.py (1)
- 1-16: - The script is consistent with the previous ones in terms of structure and coding practices.
- As with the previous scripts, consider enhancing flexibility by allowing the
validator_address
to be passed as an argument or read from a configuration file or environment variable.- Ensure robust error handling for the
AsyncClient
and thefetch_validator_outstanding_rewards
method to handle potential exceptions gracefully.- Adding documentation at the top of the script to explain its purpose, usage, and the expected format of the
validator_address
would be beneficial for maintainability and user guidance.examples/chain_client/distribution/query/6_DelegationTotalRewards.py (1)
- 1-18: - This script, similar to the previous ones, is well-structured and follows good asynchronous programming practices.
- The hardcoded
delegator_address
limits the script's flexibility. Allowing this address to be dynamically specified, either through command-line arguments or environment variables, would make the script more versatile.- Ensure that error handling is robust for both the
AsyncClient
initialization and thefetch_delegation_total_rewards
method to gracefully manage potential exceptions.- Adding documentation at the top of the script to explain its purpose, usage, and the expected format of the
delegator_address
would enhance its maintainability and provide valuable guidance to users.examples/chain_client/distribution/query/7_DelegatorValidators.py (1)
- 1-18: - The script is consistent with the previous ones in terms of structure and coding practices.
- The hardcoded
delegator_address
limits the script's flexibility. Consider allowing this address to be dynamically specified to enhance the script's usability.- Robust error handling for the
AsyncClient
and thefetch_delegator_validators
method is essential to ensure the script can handle potential exceptions gracefully.- Adding documentation at the top of the script to explain its purpose, usage, and the expected format of the
delegator_address
would be beneficial for both maintainability and user guidance.examples/chain_client/distribution/query/1_ValidatorDistributionInfo.py (1)
- 1-16: - This script follows the established pattern of good asynchronous programming practices seen in the previous scripts.
- The hardcoded
validator_address
limits the script's flexibility. Allowing this address to be dynamically specified would enhance the script's usability.- Ensure robust error handling for the
AsyncClient
and thefetch_validator_distribution_info
method to manage potential exceptions effectively.- Adding documentation at the top of the script to explain its purpose, usage, and the expected format of the
validator_address
would improve its maintainability and provide valuable guidance to users.examples/chain_client/exchange/query/8_DenomDecimal.py (1)
- 1-19: - The script is well-structured and follows good practices for asynchronous programming in Python.
- The hardcoded
denom
value limits the script's flexibility. Consider allowing the denom to be passed as an argument or read from a configuration file or environment variable for greater flexibility.- Ensure that the
AsyncClient
and thefetch_denom_decimal
method handle errors gracefully. It's important to catch exceptions that may arise from network issues or invalid responses and provide meaningful error messages to the user.- Adding a brief comment or documentation at the top of the script explaining its purpose and usage would enhance its maintainability and usability for new developers or users.
examples/chain_client/exchange/query/9_DenomDecimals.py (1)
- 1-19: - The script is consistent with the previous ones in terms of structure and coding practices.
- The hardcoded
denoms
list limits the script's flexibility. Consider allowing this list to be dynamically specified to enhance the script's usability.- Robust error handling for the
AsyncClient
and thefetch_denom_decimals
method is essential to ensure the script can handle potential exceptions gracefully.- Adding documentation at the top of the script to explain its purpose, usage, and how to specify the
denoms
would be beneficial for both maintainability and user guidance.examples/chain_client/distribution/query/8_DelegatorWithdrawAddress.py (1)
- 1-18: - This script follows the established pattern of good asynchronous programming practices seen in the previous scripts.
- The hardcoded
delegator_address
limits the script's flexibility. Allowing this address to be dynamically specified would enhance the script's usability.- Ensure robust error handling for the
AsyncClient
and thefetch_delegator_withdraw_address
method to manage potential exceptions effectively.- Adding documentation at the top of the script to explain its purpose, usage, and the expected format of the
delegator_address
would improve its maintainability and provide valuable guidance to users.examples/chain_client/exchange/query/48_QueryMarketIDFromVault.py (1)
- 1-19: - The script is well-structured and follows good practices for asynchronous programming in Python.
- The hardcoded
vault_address
limits the script's flexibility. Consider allowing the vault address to be passed as an argument or read from a configuration file or environment variable for greater flexibility.- Ensure that the
AsyncClient
and thefetch_market_id_from_vault
method handle errors gracefully. It's important to catch exceptions that may arise from network issues or invalid responses and provide meaningful error messages to the user.- Adding a brief comment or documentation at the top of the script explaining its purpose and usage would enhance its maintainability and usability for new developers or users.
examples/chain_client/exchange/query/28_DerivativeMarket.py (1)
- 1-21: - The script
28_DerivativeMarket.py
is well-structured and follows good practices for asynchronous programming in Python. It correctly initializes theAsyncClient
and uses it to fetch a derivative market by its ID.
- It's important to ensure that the
market_id
used in the script is valid and corresponds to an existing market in the Injective Protocol. If this ID is just for example purposes, consider adding a comment to clarify that users should replace it with a valid market ID.- Consider adding error handling around the
await client.fetch_chain_derivative_market
call to gracefully handle any potential issues that might arise during the API call, such as network issues or invalid market IDs.examples/chain_client/exchange/query/55_MarketAtomicExecutionFeeMultiplier.py (1)
- 1-21: - The script
55_MarketAtomicExecutionFeeMultiplier.py
is well-structured and follows good practices for asynchronous programming in Python. It correctly initializes theAsyncClient
and uses it to fetch the atomic execution fee multiplier for a specific market by its ID.
- Similar to the previous script, ensure that the
market_id
used is valid and corresponds to an existing market. If this ID is for example purposes, adding a comment for clarification would be beneficial.- Adding error handling around the
await client.fetch_market_atomic_execution_fee_multiplier
call would improve the robustness of the script by gracefully handling potential issues during the API call.examples/chain_client/exchange/query/10_SpotMarkets.py (1)
- 1-22: - The script
10_SpotMarkets.py
effectively demonstrates how to query spot markets based on specific criteria (e.g., status and market IDs) using theAsyncClient
.
- Ensure the
market_ids
array contains valid market IDs. If these IDs are placeholders, it would be helpful to add a comment indicating that users should replace them with actual market IDs.- Adding error handling for the
await client.fetch_chain_spot_markets
call would enhance the script's reliability by addressing potential issues such as network errors or invalid parameters.examples/chain_client/distribution/query/5_DelegationRewards.py (1)
- 1-19: - The script
5_DelegationRewards.py
is well-structured and demonstrates how to query delegation rewards using theAsyncClient
. It correctly initializes the client and fetches rewards for a specified delegator and validator.
- It's crucial to ensure that the
delegator_address
andvalidator_address
are valid. If these addresses are placeholders for demonstration purposes, adding a comment to clarify that users should replace them with actual addresses would be beneficial.- Consider adding error handling around the
await client.fetch_delegation_rewards
call to improve the script's robustness by handling potential issues such as invalid addresses or network errors.examples/chain_client/exchange/query/13_FullSpotMarket.py (1)
- 1-22: - The script
13_FullSpotMarket.py
effectively demonstrates querying detailed information about a specific spot market, including mid-price and top of the book (TOB), using theAsyncClient
.
- As with previous scripts, ensure the
market_id
is valid and corresponds to an existing market. If this ID is for example purposes, adding a comment for clarification would be helpful.- Adding error handling for the
await client.fetch_chain_full_spot_market
call would enhance the script's reliability by addressing potential issues such as network errors or invalid market IDs.examples/chain_client/exchange/query/27_DerivativeMarkets.py (1)
- 1-22: - The script
27_DerivativeMarkets.py
is well-structured and demonstrates how to query multiple derivative markets based on specific criteria (e.g., status and market IDs) using theAsyncClient
.
- Ensure the
market_ids
array contains valid market IDs. If these IDs are placeholders, it would be helpful to add a comment indicating that users should replace them with actual market IDs.- Adding error handling for the
await client.fetch_chain_derivative_markets
call would enhance the script's reliability by addressing potential issues such as network errors or invalid parameters.examples/chain_client/exchange/query/12_FullSpotMarkets.py (1)
- 1-23: - The script
12_FullSpotMarkets.py
effectively demonstrates querying detailed information about multiple spot markets, including mid-price and top of the book (TOB), based on specific criteria using theAsyncClient
.
- As with previous scripts, ensure the
market_ids
array contains valid market IDs. If these IDs are placeholders, adding a comment for clarification would be beneficial.- Adding error handling for the
await client.fetch_chain_full_spot_markets
call would improve the script's robustness by addressing potential issues such as network errors or invalid parameters.examples/chain_client/authz/query/1_Grants.py (1)
- 1-11: - The update to
1_Grants.py
to use environment variables forgranter
andgrantee
public addresses enhances security by avoiding hardcoded values. This change aligns with best practices for sensitive information management.
- Ensure that the
.env
file or the environment variables are correctly set up with valid public addresses before running the script. It might be helpful to include a sample.env
file or documentation comments in the script to guide users on setting up these environment variables.- Consider adding error handling for scenarios where environment variables are not set or invalid, to provide clear feedback to the user.
examples/chain_client/distribution/query/4_ValidatorSlashes.py (1)
- 1-20: - The script
4_ValidatorSlashes.py
is well-structured and demonstrates how to query validator slashes using theAsyncClient
. It correctly initializes the client and uses pagination to limit the number of results.
- Ensure the
validator_address
is valid and corresponds to an existing validator. If this address is a placeholder for demonstration purposes, adding a comment for clarification would be helpful.- Adding error handling for the
await client.fetch_validator_slashes
call would enhance the script's reliability by addressing potential issues such as invalid addresses or network errors.examples/chain_client/exchange/query/22_DerivativeOrderbook.py (1)
- 1-25: - The script
22_DerivativeOrderbook.py
effectively demonstrates querying the derivative order book for a specific market using theAsyncClient
. It correctly initializes the client and uses pagination to limit the number of results.
- As with previous scripts, ensure the
market_id
is valid and corresponds to an existing market. If this ID is for example purposes, adding a comment for clarification would be beneficial.- Adding error handling for the
await client.fetch_chain_derivative_orderbook
call would improve the script's robustness by addressing potential issues such as network errors or invalid market IDs.examples/chain_client/exchange/query/14_SpotOrderbook.py (1)
- 1-26: - The script is well-structured and follows good practices for asynchronous programming in Python.
- The use of
PaginationOption
with a limit of 2 is a good practice for managing large datasets and preventing performance issues.- Hardcoding the
market_id
andorder_side
in the script limits its flexibility. Consider making these parameters configurable through command-line arguments or environment variables to enhance the script's usability in different scenarios.- Ensure that the
market_id
used in the script is valid and corresponds to an existing market on the Injective Protocol.examples/chain_client/exchange/query/41_TradeRewardCampaign.py (1)
- 1-32: - The use of
dotenv
for loading environment variables is a good practice for managing sensitive information, such as private keys, securely.
- It's important to validate the existence and correctness of the
INJECTIVE_PRIVATE_KEY
environment variable before proceeding with its use. Consider adding error handling to provide clear feedback if the environment variable is not set or invalid.- The script demonstrates good practices in asynchronous programming and secure handling of private keys by loading them from environment variables instead of hardcoding them in the script.
examples/chain_client/exchange/query/52_MarketVolatility.py (1)
- 1-30: - The script is well-structured and follows good practices for asynchronous programming in Python.
- Hardcoding the
market_id
,trade_grouping_sec
,max_age
,include_raw_history
, andinclude_metadata
in the script limits its flexibility. Consider making these parameters configurable through command-line arguments or environment variables to enhance the script's usability in different scenarios.- Ensure that the
market_id
used in the script is valid and corresponds to an existing market on the Injective Protocol.examples/chain_client/exchange/query/39_TradeRewardPoints.py (1)
- 1-34: - The use of
dotenv
for loading environment variables is a good practice for managing sensitive information, such as private keys, securely.
- It's important to validate the existence and correctness of the
INJECTIVE_PRIVATE_KEY
environment variable before proceeding with its use. Consider adding error handling to provide clear feedback if the environment variable is not set or invalid.- The script demonstrates good practices in asynchronous programming and secure handling of private keys by loading them from environment variables instead of hardcoding them in the script.
examples/chain_client/exchange/query/40_PendingTradeRewardPoints.py (1)
- 1-34: - The use of
dotenv
for loading environment variables is a good practice for managing sensitive information, such as private keys, securely.
- It's important to validate the existence and correctness of the
INJECTIVE_PRIVATE_KEY
environment variable before proceeding with its use. Consider adding error handling to provide clear feedback if the environment variable is not set or invalid.- The script demonstrates good practices in asynchronous programming and secure handling of private keys by loading them from environment variables instead of hardcoding them in the script.
examples/chain_client/exchange/query/50_IsOptedOutOfRewards.py (1)
- 1-34: - The use of
dotenv
for loading environment variables is a good practice for managing sensitive information, such as private keys, securely.
- It's important to validate the existence and correctness of the
INJECTIVE_PRIVATE_KEY
environment variable before proceeding with its use. Consider adding error handling to provide clear feedback if the environment variable is not set or invalid.- The script demonstrates good practices in asynchronous programming and secure handling of private keys by loading them from environment variables instead of hardcoding them in the script.
examples/chain_client/exchange/query/42_FeeDiscountAccountInfo.py (1)
- 1-34: - The use of
dotenv
for loading environment variables is a good practice for managing sensitive information, such as private keys, securely.
- It's important to validate the existence and correctness of the
INJECTIVE_PRIVATE_KEY
environment variable before proceeding with its use. Consider adding error handling to provide clear feedback if the environment variable is not set or invalid.- The script demonstrates good practices in asynchronous programming and secure handling of private keys by loading them from environment variables instead of hardcoding them in the script.
examples/chain_client/exchange/query/5_AggregateVolumes.py (1)
- 1-34: - The use of
dotenv
for loading environment variables is a good practice for managing sensitive information, such as private keys, securely.
- It's important to validate the existence and correctness of the
INJECTIVE_PRIVATE_KEY
environment variable before proceeding with its use. Consider adding error handling to provide clear feedback if the environment variable is not set or invalid.- The script demonstrates good practices in asynchronous programming and secure handling of private keys by loading them from environment variables instead of hardcoding them in the script.
examples/chain_client/exchange/query/1_SubaccountDeposits.py (1)
- 1-34: - The use of
dotenv
for loading environment variables is a good practice for managing sensitive information, such as private keys, securely.
- It's important to validate the existence and correctness of the
INJECTIVE_PRIVATE_KEY
environment variable before proceeding with its use. Consider adding error handling to provide clear feedback if the environment variable is not set or invalid.- The script demonstrates good practices in asynchronous programming and secure handling of private keys by loading them from environment variables instead of hardcoding them in the script.
examples/chain_client/exchange/query/2_SubaccountDeposit.py (1)
- 1-34: - The use of
dotenv
for loading environment variables is a good practice for managing sensitive information, such as private keys, securely.
- It's important to validate the existence and correctness of the
INJECTIVE_PRIVATE_KEY
environment variable before proceeding with its use. Consider adding error handling to provide clear feedback if the environment variable is not set or invalid.- The script demonstrates good practices in asynchronous programming and secure handling of private keys by loading them from environment variables instead of hardcoding them in the script.
examples/chain_client/exchange/query/30_SubaccountTradeNonce.py (3)
- 12-12: Loading environment variables at the start of the script is a good practice for managing sensitive information like private keys. This change enhances security by avoiding hard-coded credentials.
- 22-22: Converting the private key from hex to a
PrivateKey
object is a secure way to handle sensitive information. Ensure that the environment variableINJECTIVE_PRIVATE_KEY
is properly set in all deployment environments.- 29-31: Fetching the subaccount trade nonce is a critical operation for ensuring that transactions are processed in the correct order. This change appears to be correctly implemented.
examples/chain_client/exchange/query/38_SubaccountOrderMetadata.py (1)
- 29-31: Querying for subaccount order metadata is essential for tracking and managing orders. This functionality is correctly implemented, following the same secure practices as seen in the previous file.
examples/chain_client/exchange/query/32_SubaccountPositions.py (1)
- 29-31: Fetching subaccount positions is crucial for understanding the current state of an account's investments. The implementation here is consistent with best practices observed in previous files.
examples/chain_client/exchange/query/4_AggregateVolume.py (1)
- 28-32: The script fetches aggregate volume twice, once using the account address and then using the subaccount ID. This demonstrates flexibility in querying based on different identifiers. Ensure that both calls are necessary for the intended use case to avoid redundant network requests.
examples/chain_client/exchange/query/16_AccountAddressSpotOrders.py (1)
- 27-30: Querying spot orders by account address and market ID is a key operation. However, the market ID is hardcoded, which might limit the script's flexibility. Consider making the market ID a configurable parameter or environment variable for greater versatility.
examples/chain_client/exchange/query/24_AccountAddressDerivativeOrders.py (1)
- 27-30: Fetching derivative orders by account address and market ID is implemented correctly. As with the spot orders script, consider enhancing flexibility by not hardcoding the market ID.
examples/chain_client/exchange/query/18_SubaccountOrders.py (1)
- 29-31: Querying subaccount orders with a specific market ID is a crucial functionality. The implementation is consistent with best practices, but again, consider making the market ID configurable for enhanced script flexibility.
examples/chain_client/exchange/query/15_TraderSpotOrders.py (1)
- 29-31: Fetching trader spot orders by market ID and subaccount ID is well-implemented. As with other scripts, the hardcoded market ID could be made configurable to improve the script's usability in different scenarios.
examples/chain_client/exchange/query/23_TraderDerivativeOrders.py (1)
- 29-31: The script correctly implements fetching trader derivative orders. The hardcoded market ID issue is consistent across similar scripts; consider making it configurable for better flexibility.
examples/chain_client/exchange/query/19_TraderSpotTransientOrders.py (1)
- 29-31: Querying for trader spot transient orders is a unique functionality that complements the suite of query scripts. The implementation is correct, but the hardcoded market ID should be addressed as previously mentioned.
examples/chain_client/exchange/query/54_TraderDerivativeConditionalOrders.py (2)
- 1-4: The addition of
dotenv
for loading environment variables is a positive change for security, as it moves away from hardcoding sensitive information like private keys. Ensure that the.env
file is properly secured and not included in version control.- 29-32: Querying trader derivative conditional orders with a hardcoded
market_id
limits the script's flexibility. Consider makingmarket_id
a parameter or an environment variable to enhance the script's usability across different markets.examples/chain_client/exchange/query/33_SubaccountPositionInMarket.py (2)
- 1-4: The use of
dotenv
for loading environment variables is consistent across the example scripts, which is good for maintaining a uniform approach to handling sensitive information like private keys.- 29-31: Similar to the previous file, consider enhancing the script's flexibility by making
market_id
configurable through parameters or environment variables. This would allow the script to be more versatile across different markets.examples/chain_client/exchange/query/26_TraderDerivativeTransientOrders.py (2)
- 1-4: The consistent use of
dotenv
for loading environment variables across example scripts is a good practice, ensuring uniform handling of sensitive information like private keys.- 29-31: Encourage making
market_id
configurable to enhance the script's usability across different markets. This aligns with the PR's objectives of improving flexibility and functionality.examples/chain_client/exchange/query/34_SubaccountEffectivePositionInMarket.py (2)
- 1-4: The use of
dotenv
for loading environment variables continues to be a positive and consistent change across the example scripts, enhancing security by avoiding hardcoded sensitive information.- 29-31: Encourage making
market_id
configurable through parameters or environment variables to improve the script's flexibility and usability across different markets.examples/chain_client/tokenfactory/1_CreateDenom.py (1)
- 2-4: The addition of
os
anddotenv
imports for loading environment variables is a significant improvement in handling sensitive information securely by moving away from hardcoded private keys.examples/chain_client/exchange/query/17_SpotOrdersByHashes.py (2)
- 1-4: The consistent use of
dotenv
for loading environment variables across example scripts is a good practice, ensuring uniform handling of sensitive information like private keys.- 29-32: Encourage making
market_id
andorder_hashes
configurable through parameters or environment variables to improve the script's flexibility and usability across different markets and orders.examples/chain_client/exchange/query/25_DerivativeOrdersByHashes.py (2)
- 1-4: The use of
dotenv
for loading environment variables continues to be a positive and consistent change across the example scripts, enhancing security by avoiding hardcoded sensitive information.- 29-32: Encourage making
market_id
andorder_hashes
configurable through parameters or environment variables to improve the script's flexibility and usability across different markets and orders.examples/chain_client/tokenfactory/3_MsgBurn.py (2)
- 2-4: The addition of
os
anddotenv
imports for loading environment variables is a significant improvement in handling sensitive information securely by moving away from hardcoded private keys.- 29-29: The change to use
composer.coin
for creating theamount
is a good practice, as it likely aligns with updated library conventions or best practices. Ensure that this change is consistently applied across all relevant scripts.examples/chain_client/distribution/1_SetWithdrawAddress.py (1)
- 1-6: The use of
dotenv
to load environment variables andos
to fetch the private key (INJECTIVE_PRIVATE_KEY
) from the environment is a good practice for enhancing security by avoiding hardcoded sensitive information.examples/chain_client/distribution/3_WithdrawValidatorCommission.py (1)
- 1-6: The use of
dotenv
for loading environment variables andos
for fetching the private key (INJECTIVE_PRIVATE_KEY
) is correctly implemented, enhancing security by avoiding hardcoded sensitive information.examples/chain_client/distribution/4_FundCommunityPool.py (1)
- 1-6: The introduction of
dotenv
for loading environment variables andos
for fetching the private key (INJECTIVE_PRIVATE_KEY
) is correctly implemented. Additionally, the use ofDecimal
for precise calculations is a good practice for financial transactions.examples/chain_client/distribution/2_WithdrawDelegatorReward.py (1)
- 1-6: The use of
dotenv
for loading environment variables andos
for fetching the private key (INJECTIVE_PRIVATE_KEY
) is correctly implemented, enhancing security by avoiding hardcoded sensitive information.examples/SendToInjective.py (2)
- 1-5: The introduction of
dotenv
for loading environment variables andos
for fetching the private key (INJECTIVE_PRIVATE_KEY
) is correctly implemented, enhancing security by avoiding hardcoded sensitive information.- 12-13: Loading the private key from environment variables is a significant improvement in terms of security. This change ensures that sensitive information is not hardcoded into the script.
examples/chain_client/tokenfactory/5_MsgSetDenomMetadata.py (2)
- 1-4: The use of
dotenv
for loading environment variables andos
for fetching the private key (INJECTIVE_PRIVATE_KEY
) is correctly implemented, enhancing security by avoiding hardcoded sensitive information.- 13-14: Loading the private key from environment variables is a significant improvement in terms of security. This change ensures that sensitive information is not hardcoded into the script.
examples/chain_client/exchange/3_MsgInstantSpotMarketLaunch.py (1)
- 1-6: The use of
dotenv
for loading environment variables andos
for fetching the private key (INJECTIVE_PRIVATE_KEY
) is correctly implemented, enhancing security by avoiding hardcoded sensitive information.examples/chain_client/6_MessageBroadcasterWithGranteeAccountWithoutSimulation.py (1)
- 1-6: The introduction of
dotenv
for loading environment variables andos
for fetching the private key (INJECTIVE_GRANTEE_PRIVATE_KEY
) and public address (INJECTIVE_GRANTER_PUBLIC_ADDRESS
) is correctly implemented, enhancing security by avoiding hardcoded sensitive information.examples/chain_client/4_MessageBroadcasterWithGranteeAccount.py (1)
- 1-6: The use of
dotenv
for loading environment variables andos
for fetching the private key (INJECTIVE_GRANTEE_PRIVATE_KEY
) and public address (INJECTIVE_GRANTER_PUBLIC_ADDRESS
) is correctly implemented, enhancing security by avoiding hardcoded sensitive information.examples/chain_client/exchange/13_MsgInstantBinaryOptionsMarketLaunch.py (1)
- 1-6: The use of
dotenv
for loading environment variables andos
for fetching the private key (INJECTIVE_PRIVATE_KEY
) is correctly implemented, enhancing security by avoiding hardcoded sensitive information.examples/chain_client/exchange/4_MsgInstantPerpetualMarketLaunch.py (1)
- 1-61: - The script correctly imports necessary modules, loads environment variables using
dotenv
, and utilizesDecimal
for precise financial calculations. This enhances security by avoiding hardcoded private keys and improves accuracy in financial computations.
- Ensure that the environment variable
INJECTIVE_PRIVATE_KEY
is securely managed and not exposed in any logs or error messages.- Consider adding error handling for
os.getenv("INJECTIVE_PRIVATE_KEY")
to gracefully handle cases where the environment variable is not set.examples/chain_client/exchange/5_MsgInstantExpiryFuturesMarketLaunch.py (1)
- 1-62: - The script for launching an instant expiry futures market correctly uses environment variables and
Decimal
for precise calculations, following best practices for security and accuracy.
- Confirm that the
INJECTIVE_PRIVATE_KEY
environment variable is handled securely throughout the application.- Suggest adding error handling for missing or invalid environment variables to improve the script's robustness.
examples/chain_client/5_MessageBroadcasterWithoutSimulation.py (1)
- 35-56: > 📝 NOTE
This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [1-59]
- The script for broadcasting messages without simulation has been updated to use
Decimal
for financial values and string literals for order types, which enhances clarity and precision.- Ensure that the environment variable
INJECTIVE_PRIVATE_KEY
is securely managed and not exposed in any logs or error messages.- Recommend adding error handling for the retrieval of the environment variable to gracefully handle cases where it might not be set.
examples/chain_client/3_MessageBroadcaster.py (1)
- 35-56: > 📝 NOTE
This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [1-59]
- The script for message broadcasting with simulation correctly uses
Decimal
for financial values and string literals for order types, aligning with best practices for precision and clarity.- Confirm that the
INJECTIVE_PRIVATE_KEY
environment variable is handled securely throughout the application.- Suggest adding error handling for missing or invalid environment variables to improve the script's robustness.
tests/test_orderhash.py (1)
- 24-44: > 📝 NOTE
This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [1-41]
- The updates to the test file for order hash computation correctly use
Decimal
for financial values, enhancing the precision and reliability of the tests.- Consider adding more test cases to cover edge cases and potential error scenarios, ensuring comprehensive test coverage.
pyproject.toml (1)
- 1-6: > 📝 NOTE
This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [1-54]
- The update to the project version and the addition of
python-dotenv
as a dependency inpyproject.toml
are correctly implemented, aligning with the PR's objectives to enhance security and flexibility.- Ensure that all dependencies are kept up to date and that any new dependencies are evaluated for security and compatibility with the project.
examples/chain_client/exchange/21_MsgRewardsOptOut.py (1)
- 24-36: > 📝 NOTE
This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [1-59]
- The script for opting out of rewards correctly uses environment variables for private keys and follows best practices for secure and precise transactions.
- Confirm that the
INJECTIVE_PRIVATE_KEY
environment variable is handled securely throughout the application.- Recommend adding error handling for missing or invalid environment variables to improve the script's robustness.
examples/chain_client/auction/1_MsgBid.py (1)
- 12-20: > 📝 NOTE
This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [1-59]
- The script for bidding in auctions correctly uses environment variables for private keys and follows best practices for secure and precise transactions.
- Ensure that the
INJECTIVE_PRIVATE_KEY
environment variable is securely managed and not exposed in any logs or error messages.- Suggest adding error handling for missing or invalid environment variables to improve the script's robustness.
examples/chain_client/exchange/2_MsgWithdraw.py (1)
- 24-37: > 📝 NOTE
This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [1-60]
- The script for withdrawing funds correctly uses environment variables for private keys and follows best practices for secure and precise transactions.
- Confirm that the
INJECTIVE_PRIVATE_KEY
environment variable is handled securely throughout the application.- Recommend adding error handling for missing or invalid environment variables to improve the script's robustness.
examples/chain_client/bank/1_MsgSend.py (1)
- 12-20: > 📝 NOTE
This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [1-64]
- The script for sending funds correctly uses environment variables for private keys and follows best practices for secure and precise transactions.
- Ensure that the
INJECTIVE_PRIVATE_KEY
environment variable is securely managed and not exposed in any logs or error messages.- Suggest adding error handling for missing or invalid environment variables to improve the script's robustness.
examples/chain_client/exchange/1_MsgDeposit.py (6)
- 2-4: Importing
os
anddotenv
modules and loading environment variables usingdotenv.load_dotenv()
are good practices for enhancing security by avoiding hardcoded sensitive information like private keys. This change aligns with the PR's objective to improve security and flexibility.- 15-17: Successfully loading environment variables and retrieving the private key using
os.getenv("INJECTIVE_PRIVATE_KEY")
is a secure way to handle sensitive information. Ensure that the environment variableINJECTIVE_PRIVATE_KEY
is properly set in the deployment environment to avoid runtime errors.- 19-19: Switching to
Network.testnet()
for selecting the network is a straightforward change. It's important to ensure that this aligns with the intended use case and that any necessary adjustments are made for different environments (e.g., mainnet).- 27-27: Converting the private key from hexadecimal to a
PrivateKey
object usingPrivateKey.from_hex(configured_private_key)
is correct and secure, assuming the private key is properly managed and stored.- 34-36: The update to the
msg_deposit
method call, including the dynamic setting of the sender, subaccount ID, amount, and denom, is correctly implemented. It's crucial to validate the input values, especially the amount and denom, to prevent unintended transactions.- 62-62: The change to use
composer.coin
for creating a coin object with dynamic gas price and limit calculation is appropriate. This approach ensures that transaction fees are calculated based on the actual gas used, plus a buffer, enhancing efficiency and preventing overpayment.examples/chain_client/oracle/1_MsgRelayPriceFeedPrice.py (4)
- 2-4: The addition of
os
anddotenv
modules and the use ofdotenv.load_dotenv()
to load environment variables are consistent with best practices for handling sensitive information securely. This approach is crucial for maintaining the security of the private key.- 15-17: Retrieving the private key from an environment variable using
os.getenv("INJECTIVE_PRIVATE_KEY")
is a secure and flexible method. It's important to ensure the environment variable is set up correctly in the deployment environment.- 27-27: The conversion of the private key from hexadecimal to a
PrivateKey
object usingPrivateKey.from_hex(configured_private_key)
is correctly implemented. This ensures that the private key is handled securely throughout the script.- 64-64: Updating the method call to
composer.coin
for fee calculation with dynamic gas price and limit is appropriate. This change ensures that fees are calculated accurately based on the actual gas used, which is a good practice for efficiency and cost management.examples/chain_client/staking/1_MsgDelegate.py (4)
- 2-4: The addition of
os
anddotenv
modules and the use ofdotenv.load_dotenv()
to load environment variables are consistent with best practices for handling sensitive information securely. This approach is crucial for maintaining the security of the private key.- 15-17: Retrieving the private key from an environment variable using
os.getenv("INJECTIVE_PRIVATE_KEY")
is a secure and flexible method. It's important to ensure the environment variable is set up correctly in the deployment environment.- 27-27: The conversion of the private key from hexadecimal to a
PrivateKey
object usingPrivateKey.from_hex(configured_private_key)
is correctly implemented. This ensures that the private key is handled securely throughout the script.- 64-64: Updating the method call to
composer.coin
for fee calculation with dynamic gas price and limit is appropriate. This change ensures that fees are calculated accurately based on the actual gas used, which is a good practice for efficiency and cost management.examples/chain_client/insurance/2_MsgUnderwrite.py (4)
- 2-4: The addition of
os
anddotenv
modules and the use ofdotenv.load_dotenv()
to load environment variables are consistent with best practices for handling sensitive information securely. This approach is crucial for maintaining the security of the private key.- 15-17: Retrieving the private key from an environment variable using
os.getenv("INJECTIVE_PRIVATE_KEY")
is a secure and flexible method. It's important to ensure the environment variable is set up correctly in the deployment environment.- 28-28: The conversion of the private key from hexadecimal to a
PrivateKey
object usingPrivateKey.from_hex(configured_private_key)
is correctly implemented. This ensures that the private key is handled securely throughout the script.- 64-64: Updating the method call to
composer.coin
for fee calculation with dynamic gas price and limit is appropriate. This change ensures that fees are calculated accurately based on the actual gas used, which is a good practice for efficiency and cost management.examples/chain_client/authz/3_MsgRevoke.py (5)
- 2-4: The addition of
os
anddotenv
modules and the use ofdotenv.load_dotenv()
to load environment variables are consistent with best practices for handling sensitive information securely. This approach is crucial for maintaining the security of the private key.- 15-18: Retrieving the private key and grantee public address from environment variables using
os.getenv()
is a secure and flexible method. It's important to ensure the environment variables are set up correctly in the deployment environment. This approach enhances the script's flexibility by allowing dynamic configuration.- 28-28: The conversion of the private key from hexadecimal to a
PrivateKey
object usingPrivateKey.from_hex(configured_private_key)
is correctly implemented. This ensures that the private key is handled securely throughout the script.- 35-36: The update to the
MsgRevoke
instantiation with dynamicgranter
andgrantee
values is correctly implemented. It's crucial to validate the input values, especially thegrantee
public address, to prevent unintended revocations.- 64-64: Updating the method call to
composer.coin
for fee calculation with dynamic gas price and limit is appropriate. This change ensures that fees are calculated accurately based on the actual gas used, which is a good practice for efficiency and cost management.examples/chain_client/insurance/3_MsgRequestRedemption.py (4)
- 2-4: The addition of
os
anddotenv
modules and the use ofdotenv.load_dotenv()
to load environment variables are consistent with best practices for handling sensitive information securely. This approach is crucial for maintaining the security of the private key.- 15-17: Retrieving the private key from an environment variable using
os.getenv("INJECTIVE_PRIVATE_KEY")
is a secure and flexible method. It's important to ensure the environment variable is set up correctly in the deployment environment.- 28-28: The conversion of the private key from hexadecimal to a
PrivateKey
object usingPrivateKey.from_hex(configured_private_key)
is correctly implemented. This ensures that the private key is handled securely throughout the script.- 64-64: Updating the method call to
composer.coin
for fee calculation with dynamic gas price and limit is appropriate. This change ensures that fees are calculated accurately based on the actual gas used, which is a good practice for efficiency and cost management.examples/chain_client/insurance/1_MsgCreateInsuranceFund.py (4)
- 2-4: The addition of
os
anddotenv
modules and the use ofdotenv.load_dotenv()
to load environment variables are consistent with best practices for handling sensitive information securely. This approach is crucial for maintaining the security of the private key.- 15-17: Retrieving the private key from an environment variable using
os.getenv("INJECTIVE_PRIVATE_KEY")
is a secure and flexible method. It's important to ensure the environment variable is set up correctly in the deployment environment.- 28-28: The conversion of the private key from hexadecimal to a
PrivateKey
object usingPrivateKey.from_hex(configured_private_key)
is correctly implemented. This ensures that the private key is handled securely throughout the script.- 68-68: Updating the method call to
composer.coin
for fee calculation with dynamic gas price and limit is appropriate. This change ensures that fees are calculated accurately based on the actual gas used, which is a good practice for efficiency and cost management.examples/chain_client/exchange/17_MsgSubaccountTransfer.py (3)
- 2-5: The addition of
os
,dotenv
, andDecimal
from thedecimal
module, along with the use ofdotenv.load_dotenv()
to load environment variables, are consistent with best practices for handling sensitive information securely and performing precise calculations. This approach is crucial for maintaining the security of the private key and ensuring accurate financial transactions.- 16-18: Retrieving the private key from an environment variable using
os.getenv("INJECTIVE_PRIVATE_KEY")
is a secure and flexible method. It's important to ensure the environment variable is set up correctly in the deployment environment. Additionally, the use ofDecimal
for the amount ensures precise financial calculations, which is critical in financial applications.- 28-28: The conversion of the private key from hexadecimal to a
PrivateKey
object usingPrivateKey.from_hex(configured_private_key)
is correctly implemented. This ensures that the private key is handled securely throughout the script.examples/chain_client/exchange/12_MsgCancelDerivativeOrder.py (5)
- 2-4: - The addition of
os
anddotenv
imports is appropriate for loading environment variables, enhancing the script's security by avoiding hardcoded sensitive information.- 15-16: - Using
dotenv.load_dotenv()
to load environment variables and fetching the private key usingos.getenv("INJECTIVE_PRIVATE_KEY")
is a secure practice, ensuring that sensitive information is not hardcoded.- 27-27: - The conversion of the private key from hexadecimal to a
PrivateKey
object usingPrivateKey.from_hex(configured_private_key)
is correct and ensures that the private key is properly handled.- 38-38: - The change from
composer.MsgCancelDerivativeOrder
tocomposer.msg_cancel_derivative_order
follows Python's naming conventions and improves code readability.- 66-66: - The modification from
composer.Coin
tocomposer.coin
for gas fee calculation aligns with Python's naming conventions and ensures consistency across the project.examples/chain_client/exchange/18_MsgExternalTransfer.py (5)
- 2-5: - Importing
os
,Decimal
, anddotenv
modules is correctly done to support environment variable loading and precise calculations.- 16-17: - Loading environment variables and retrieving the private key securely using
dotenv.load_dotenv()
andos.getenv()
is a good practice.- 28-28: - Correctly converting the private key from hexadecimal format ensures secure and proper handling of sensitive information.
- 36-40: - The update to
msg_external_transfer
for message creation and the use ofDecimal
for the amount ensure accurate financial transactions and align with best practices.- 68-68: - Adjusting the gas fee calculation to use
composer.coin
is consistent with the project's coding standards and improves readability.examples/chain_client/exchange/20_MsgIncreasePositionMargin.py (5)
- 2-5: - The imports of
os
,Decimal
, anddotenv
are correctly implemented to support the script's functionality and security.- 16-17: - Securely loading the private key from environment variables using
dotenv.load_dotenv()
andos.getenv()
is a best practice for handling sensitive information.- 28-28: - The conversion of the private key from a hexadecimal string to a
PrivateKey
object is correctly implemented, ensuring secure handling of the key.- 38-43: - Updating the
msg_increase_position_margin
function call and usingDecimal
for the amount parameter ensures precise financial calculations.- 70-70: - The modification to use
composer.coin
for gas fee calculation aligns with the project's coding standards and improves code readability.examples/chain_client/wasmx/1_MsgExecuteContractCompat.py (4)
- 3-5: - The addition of
os
anddotenv
imports is correctly done to support environment variable loading, enhancing the script's security.- 16-17: - Securely loading the private key from environment variables using
dotenv.load_dotenv()
andos.getenv()
is a good practice.- 27-27: - The conversion of the private key from hexadecimal to a
PrivateKey
object is correctly implemented, ensuring secure handling of the key.- 71-71: - The change to use
composer.coin
for gas fee calculation is consistent with the project's coding standards and improves code readability.examples/chain_client/peggy/1_MsgSendToEth.py (4)
- 2-4: - Importing
os
anddotenv
is correctly done to support environment variable loading, enhancing the script's security by avoiding hardcoded sensitive information.- 16-17: - Using
dotenv.load_dotenv()
to load environment variables and fetching the private key usingos.getenv("INJECTIVE_PRIVATE_KEY")
is a secure practice.- 28-28: - The conversion of the private key from hexadecimal to a
PrivateKey
object usingPrivateKey.from_hex(configured_private_key)
is correct and ensures that the private key is properly handled.- 73-73: - The modification from
composer.Coin
tocomposer.coin
for gas fee calculation aligns with Python's naming conventions and ensures consistency across the project.examples/chain_client/exchange/16_MsgCancelBinaryOptionsOrder.py (5)
- 2-4: - The addition of
os
anddotenv
imports is appropriate for loading environment variables, enhancing the script's security by avoiding hardcoded sensitive information.- 15-16: - Using
dotenv.load_dotenv()
to load environment variables and fetching the private key usingos.getenv("INJECTIVE_PRIVATE_KEY")
is a secure practice.- 27-27: - The conversion of the private key from hexadecimal to a
PrivateKey
object usingPrivateKey.from_hex(configured_private_key)
is correct and ensures that the private key is properly handled.- 38-38: - The change from a previous method call to
composer.msg_cancel_binary_options_order
follows Python's naming conventions and improves code readability.- 69-69: - The modification from
composer.Coin
tocomposer.coin
for gas fee calculation aligns with Python's naming conventions and ensures consistency across the project.examples/chain_client/wasm/1_MsgExecuteContract.py (5)
- 2-4: - Importing
os
anddotenv
is correctly done to support environment variable loading, enhancing the script's security by avoiding hardcoded sensitive information.- 15-16: - Securely loading the private key from environment variables using
dotenv.load_dotenv()
andos.getenv()
is a good practice.- 28-28: - The conversion of the private key from hexadecimal to a
PrivateKey
object is correctly implemented, ensuring secure handling of the key.- 36-41: - The update to use
composer.coin
for creating coin amounts in the funds array is consistent with the project's coding standards and improves code readability.- 74-74: - The change to use
composer.coin
for gas fee calculation is consistent with the project's coding standards and improves code readability.examples/chain_client/exchange/22_MsgAdminUpdateBinaryOptionsMarket.py (5)
- 2-5: - Importing
os
,Decimal
, anddotenv
modules is correctly done to support environment variable loading and precise calculations.- 16-17: - Loading environment variables and retrieving the private key securely using
dotenv.load_dotenv()
andos.getenv()
is a good practice for handling sensitive information.- 28-28: - Correctly converting the private key from hexadecimal format ensures secure and proper handling of sensitive information.
- 41-41: - The update to
msg_admin_update_binary_options_market
for message creation and the use ofDecimal
for the settlement price ensure accurate financial transactions and align with best practices.- 78-78: - Adjusting the gas fee calculation to use
composer.coin
is consistent with the project's coding standards and improves readability.examples/chain_client/exchange/7_MsgCreateSpotMarketOrder.py (5)
- 2-6: - Importing
os
,Decimal
, anddotenv
modules is correctly done to support environment variable loading and precise calculations.- 17-18: - Loading environment variables and retrieving the private key securely using
dotenv.load_dotenv()
andos.getenv()
is a good practice for handling sensitive information.- 29-29: - Correctly converting the private key from hexadecimal format ensures secure and proper handling of sensitive information.
- 40-47: - The update to
composer.msg_create_spot_market_order
for message creation and the use ofDecimal
for price and quantity values ensure accurate financial transactions and align with best practices.- 79-79: - Adjusting the gas fee calculation to use
composer.coin
is consistent with the project's coding standards and improves readability.tests/client/chain/grpc/configurable_distribution_query_servicer.py (1)
- 1-69: - The implementation of
ConfigurableDistributionQueryServicer
is well-structured, using deques to simulate responses for distribution-related queries. This approach allows for flexible and controlled testing of the gRPC servicer methods.tests/client/chain/grpc/test_chain_grpc_authz_api.py (1)
- 10-10: The correction of the typo in the import statement from
configurable_autz_query_servicer
toconfigurable_authz_query_servicer
is crucial for ensuring the correctness of the test suite. This change allows the test suite to correctly import and utilize theConfigurableAuthZQueryServicer
class, which is essential for testing theChainGrpcAuthZApi
functionalities.tests/core/test_message_based_transaction_fee_calculator.py (2)
- 120-127: The changes made to use
Decimal
forprice
andquantity
fields, and the replacement of boolean flags with anorder_type
field set to "BUY", significantly improve the precision of financial calculations and the clarity of the code. UsingDecimal
is crucial for financial applications to avoid rounding errors, and theorder_type
field enhances readability and maintainability by clearly specifying the type of order.- 120-127: The refactoring of message creation in test functions, including the use of lowercase function names and adjustments in message parameters, enhances the consistency and readability of the codebase. This approach aligns with Python's naming conventions and improves the maintainability of the test suite by making the code more intuitive and easier to follow.
Also applies to: 150-157, 185-192
CHANGELOG.md (1)
- 5-9: The changelog entries for version 1.4.0 are clear and concise, effectively summarizing the significant additions and improvements made in this release. However, there's a minor typographical issue to address:
- The term "python-dotenv" is correctly spelled, but the static analysis tool suggested "python-dot env" as a replacement. This suggestion is incorrect, and the original spelling should be retained.
Overall, the changelog update for version 1.4.0 is well-documented and adheres to best practices for changelog entries.
examples/chain_client/1_LocalOrderHash.py (4)
- 2-6: The addition of
os
,Decimal
, anddotenv
imports aligns with the PR's objectives to enhance security and flexibility by moving away from hardcoded private keys to environment variables and usingDecimal
for precise calculations. Ensure that these modules are used consistently throughout the script.- 17-18: Loading environment variables at the beginning of the
main
function is a good practice for managing sensitive information such as private keys. This change enhances security by not hardcoding sensitive data within the script.- 48-50: The use of
Decimal
for specifyingprice
,quantity
, andmargin
ensures precise calculations, which is crucial for financial transactions. Additionally, changing order types to strings ("BUY", "SELL", "BUY_PO", "SELL_PO") improves readability and maintainability of the code.Also applies to: 57-59, 69-73, 81-85, 177-179, 186-188, 198-202, 210-214
- 92-96: The adjustments in function calls to
composer.msg_batch_create_spot_limit_orders
andcomposer.msg_batch_create_derivative_limit_orders
reflect the new naming conventions and enhance the clarity of the code. It's important to verify that these changes are consistently applied across all relevant parts of the project to avoid any integration issues.Also applies to: 221-225
Verification successful
The search results indicate that the changes to the function names
composer.msg_batch_create_spot_limit_orders
andcomposer.msg_batch_create_derivative_limit_orders
are consistently applied across the project. This includes their usage in examples, tests, and within thepyinjective
module itself, with appropriate deprecation warnings and test cases in place to handle the transition. Therefore, the adjustments reflect the new naming conventions and enhance the clarity of the code as intended.Scripts Executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Search for old function names to ensure they've been updated everywhere. rg --type py 'msg_batch_create_spot_limit_orders|msg_batch_create_derivative_limit_orders'Length of output: 2400
pyinjective/denoms_devnet.ini (2)
- 167-170: The adjustments to
min_price_tick_size
,min_display_price_tick_size
,min_quantity_tick_size
, andmin_display_quantity_tick_size
for various trading pairs are crucial for reflecting accurate trading conditions on the devnet. It's important to ensure these values are consistent with the intended trading parameters and that similar adjustments are made across all relevant configurations.Also applies to: 176-179, 185-188, 194-197
- 317-319: Updates to peggy denominations and decimals for tokens like HDRO, KIRA, and QUNT are necessary for accurate representation and handling of these tokens within the system. Verify that these updates align with the latest token specifications and that all references to these tokens in the project are updated accordingly.
Also applies to: 325-327, 341-343
Verification successful
The script output confirms that references to the tokens HDRO, KIRA, and QUNT are consistently found across different .ini files (
denoms_testnet.ini
,denoms_mainnet.ini
, anddenoms_devnet.ini
) within the project. This indicates that the updates to peggy denominations and decimals for these tokens are applied across various network configurations (testnet, mainnet, devnet), aligning with the necessity for accurate representation and handling within the system as mentioned in the review comment.However, verifying the alignment of these updates with the latest token specifications requires external data, which is beyond the scope of this verification process. Therefore, based on the provided context and the script output, the consistency of token references across the project's configuration files is confirmed.
Scripts Executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Search for references to the updated tokens to ensure consistency. rg --type ini 'HDRO|KIRA|QUNT'Length of output: 60
Script:
#!/bin/bash # Search for references to the updated tokens to ensure consistency, specifically targeting .ini files. rg -g '*.ini' 'HDRO|KIRA|QUNT'Length of output: 973
pyinjective/core/broadcaster.py (1)
- 267-267: The conversion of method calls from
self._composer.Coin
toself._composer.coin
for configuring gas fees aligns with Python's convention of using lowercase for method names. This change improves consistency and readability. Ensure that this naming convention is consistently applied throughout the project.Also applies to: 295-295
pyinjective/core/market.py (1)
- 172-181: The implementation of
margin_to_chain_format
in theBinaryOptionMarket
class correctly converts human-readable margin values to chain-formatted values, considering special denominations if provided. This addition follows the established pattern of similar conversion methods in the file, usingDecimal
for precise calculations and supporting optionalspecial_denom
for flexibility. The method is consistent with best practices for financial calculations.tests/client/chain/grpc/test_chain_grpc_distribution_api.py (3)
- 18-54: The test case
test_fetch_module_params
is well-structured and effectively tests the functionality of fetching module params from the distribution API. It uses a fixture for the distribution servicer and mocks the API's stub to use this servicer, with clear assertions comparing the expected dictionary with the result from the API call.- 56-84: The test case
test_fetch_validator_distribution_info
effectively tests the API's functionality to fetch validator distribution info. It follows a consistent structure and approach, effectively mocking the necessary responses and validating the API's functionality with clear assertions.- 86-110: The test case
test_fetch_validator_outstanding_rewards
effectively tests the API's functionality to fetch validator outstanding rewards. It follows a consistent pattern with well-structured mocks and clear assertions, demonstrating the effectiveness of the test.pyinjective/denoms_testnet.ini (3)
- 145-152: The configuration for
Testnet Spot TEST2/INJ
andTestnet Spot TEST2/USDT
introduces a significant change inmin_price_tick_size
forTEST2/INJ
compared to other configurations. This could potentially be an error or a very specific requirement. Please verify the correctness of themin_price_tick_size
forTEST2/INJ
being set to100000000
, which is significantly higher than typical values seen in other configurations.- 468-470: The addition of the
HDRO
token configuration introduces a new peggy_denom and specifies its decimals. It's important to ensure that the peggy_denom address and decimals are correctly configured to match the token's specifications on the blockchain. Any discrepancy here could lead to incorrect handling of token amounts in the application.- 492-498: The addition of
TEST1
andTEST2
tokens with their respective peggy_denom configurations is noted. It's crucial to verify that these tokens and their peggy_denom addresses are correctly set up in the blockchain environment the application interacts with. Misconfiguration could lead to issues with token transfers or balance queries.tests/core/test_gas_limit_estimator.py (16)
- 27-33: - The use of
Decimal
forprice
andquantity
incomposer.spot_order
is a good practice for financial calculations, ensuring precision.
- The introduction of
order_type
instead of boolean flags likeis_buy
improves readability and flexibility.
- 44-44: - The method
msg_batch_create_spot_limit_orders
correctly aggregates the orders. Ensure that thesender
parameter is properly validated upstream to prevent misuse.- 56-66: - The use of
composer.order_data
for canceling spot orders is correctly implemented. It's important to ensure thatorder_hash
values are validated and sanitized to prevent any injection attacks.- 72-72: - The method
msg_batch_cancel_spot_orders
is correctly used for batch canceling spot orders. Similar to the creation of orders, ensure that thesender
parameter is validated.- 84-100: - The use of
Decimal
forprice
,quantity
, andmargin
incomposer.derivative_order
is correctly applied, ensuring accurate financial calculations.
- The distinction between
BUY
andSELL
order types is clear and enhances the code's readability.
- 103-103: - The method
msg_batch_create_derivative_limit_orders
is used appropriately for creating derivative limit orders. As with other methods, ensure thesender
parameter is validated to prevent unauthorized use.- 115-125: - The use of
composer.order_data
for canceling derivative orders follows the same pattern as for spot orders. Ensure thatorder_hash
values are properly validated to prevent any potential security issues.- 131-131: - The method
msg_batch_cancel_derivative_orders
correctly implements the batch canceling of derivative orders. Validate thesender
parameter as a security measure.- 143-157: - The test case for updating orders to create spot orders demonstrates the flexibility of the system to handle various order types. The use of
Decimal
for precise calculations is consistent and appropriate.- 178-194: - The test case for updating orders to create derivative orders is well-implemented, showcasing the system's ability to handle complex order types with precision using
Decimal
.- 233-249: - The test case for updating orders to create binary options orders is correctly implemented, using
Decimal
for financial calculations and clearly distinguishing betweenBUY
andSELL
order types.- 271-281: - The test case for batch updating orders to cancel spot orders is implemented correctly. It's important to ensure that
order_hash
values are validated to prevent any potential security issues.- 305-315: - The test case for batch updating orders to cancel derivative orders follows the established pattern and is correctly implemented. Validate
order_hash
values for security.- 339-349: - The test case for batch updating orders to cancel binary options orders is correctly implemented. As with other order types, ensure that
order_hash
values are validated.- 434-440: - The test case for executing a message within another message (
MsgExec
) is correctly implemented, showcasing advanced use cases. Ensure that nested messages are validated and sanitized appropriately.- 502-509: - The method
msg_create_spot_limit_order
is used correctly for creating a spot limit order. The use ofDecimal
forprice
andquantity
ensures precision in financial calculations.tests/core/test_market.py (2)
- 251-272: - The method
test_convert_margin_to_chain_format_with_fixed_denom
correctly tests the conversion of margin values to chain format using a fixed denomination. This test ensures that margin values are accurately converted, taking into account the fixed denomination's specifics.- 274-285: - The method
test_convert_margin_to_chain_format_without_fixed_denom
tests the conversion of margin values to chain format without a fixed denomination. This test verifies the flexibility of the conversion functionality to handle different market configurations.pyinjective/client/chain/grpc/chain_grpc_exchange_api.py (3)
- 13-16: The class initialization is well-implemented, correctly setting up the necessary components for making gRPC calls. It's good practice to separate the creation of the stub and the request assistant, as it enhances modularity and testability.
- 18-578: All async methods in the
ChainGrpcExchangeApi
class follow a consistent and clear pattern for making gRPC calls. This consistency is beneficial for maintainability and readability. It's also good to see the use of type hints for method return types, enhancing code clarity and developer experience.- 577-578: The
_execute_call
helper method is well-designed, abstracting the execution of gRPC calls and centralizing error handling and metadata management. This design choice simplifies the public method implementations and enhances code maintainability.pyinjective/denoms_mainnet.ini (19)
- 685-692: The addition of the
DOJO/INJ
spot trading pair with its corresponding tick sizes and quantities is noted. Ensure that these values have been validated against the current market requirements and Injective Protocol's standards for precision and minimum quantities.- 694-701: The addition of the
GYEN/USDT
spot trading pair introduces a fiat-pegged stablecoin pair. It's crucial to verify the demand for this trading pair within the Injective Protocol ecosystem and ensure that the peggy_denom value for GYEN is correctly set up in the system to facilitate seamless transactions.- 703-710: The addition of the
USDCnb/USDT
spot trading pair is observed. Given the naming convention, it appears to be a specific version or network bridge of USDC. Confirm that the peggy_denom and decimals forUSDCnb
are correctly configured and that there's clear documentation for users regarding this specific token variant.- 713-719: The
ANDR/INJ
spot trading pair has been added with a significant minimum price tick size of 10,000,000 and a display tick size of 0.00001. This configuration suggests a high-value asset or a specific use case. Ensure that this configuration aligns with the asset's market characteristics and the platform's trading strategy.- 721-728: The addition of the
hINJ/INJ
spot trading pair is noted. Given the naming, this might represent a wrapped or staked version of INJ. Confirm that the community and stakeholders are aware of this new trading pair and that the necessary infrastructure (e.g., smart contracts for wrapping/unwrapping) is in place and has been audited for security.- 739-746: The addition of the
PHUC/INJ
spot trading pair with its specific tick sizes and quantities is observed. Given the unique naming, ensure that there's adequate information available about this asset, including its utility and how it integrates with the Injective Protocol ecosystem.- 748-755: The addition of the
QUNT/INJ
spot trading pair is noted. It's important to verify the demand for this trading pair within the Injective Protocol ecosystem and ensure that the peggy_denom value for QUNT is correctly set up in the system to facilitate seamless transactions.- 757-764: The addition of the
WHALE/INJ
spot trading pair introduces a potentially high-value asset pair. Confirm that the peggy_denom for WHALE is correctly configured and that there's clear documentation for users regarding this asset, including its origins and utility within the ecosystem.- 766-773: The addition of the
HDRO/INJ
spot trading pair is observed. Given the specific configuration, ensure that this trading pair aligns with the market demand and that the HDRO asset is well-documented within the Injective Protocol ecosystem.- 776-782: The addition of the
PYTH/INJ
spot trading pair with a significant minimum price tick size of 10,000,000 suggests a high-value or high-precision asset. Verify that this configuration aligns with PYTH's market characteristics and that there's clear communication to users about this trading pair.- 838-845: The addition of the
OSMO/USDT PERP
derivative trading pair with specific tick sizes and quantities is noted. Ensure that these values have been validated against current market requirements and Injective Protocol's standards for precision and minimum quantities in derivative markets.- 857-863: The
BONK/USDT PERP
derivative trading pair introduces a unique configuration with a minimum price tick size of 0.01 and a display tick size of 0.00000001. This configuration suggests a high-precision or high-volatility asset. Confirm that this aligns with BONK's market characteristics and the platform's trading strategy for derivatives.- 937-944: The addition of the
AVAX/USDT PERP
derivative trading pair is observed. Given AVAX's prominence in the cryptocurrency market, ensure that the derivative contract specifications, including tick sizes and quantities, are aligned with market expectations and Injective Protocol's risk management practices.- 946-953: The addition of the
SUI/USDT PERP
derivative trading pair introduces a newer asset to the derivatives market. Verify the demand for this trading pair within the Injective Protocol ecosystem and ensure that the contract specifications are clearly communicated to users.- 955-962: The
WIF/USDT PERP
derivative trading pair is added with specific tick sizes and quantities. Given the unique naming, confirm that there's adequate information available about this asset, including its utility and how it integrates with the Injective Protocol's derivatives market.- 973-980: The addition of the
ARB/USDT PERP
derivative trading pair is noted. Ensure that these values have been validated against current market requirements and Injective Protocol's standards for precision and minimum quantities in derivative markets, especially considering ARB's potential market dynamics.- 982-989: The
W/USDT PERP
derivative trading pair introduces a potentially high-value asset pair. Confirm that the peggy_denom for W is correctly configured and that there's clear documentation for users regarding this asset, including its origins and utility within the derivatives market.- 991-998: The addition of the
LINK/USDT PERP
derivative trading pair with specific tick sizes and quantities is observed. Given LINK's prominence in the cryptocurrency market, ensure that the derivative contract specifications are aligned with market expectations and Injective Protocol's risk management practices.- 1000-1007: The addition of the
DOGE/USDT PERP
derivative trading pair introduces a popular meme coin to the derivatives market. Confirm that the contract specifications, including tick sizes and quantities, are clearly communicated to users and align with DOGE's market characteristics and volatility.tests/test_composer.py (31)
- 79-79: The use of a large literal number (
1_000_000
) for theamount
parameter intest_msg_mint
is clear and improves readability. However, it's important to ensure that such large numbers are handled correctly in the context of the application, especially when dealing with financial transactions.- 178-208: In
test_msg_deposit
, the conversion ofamount
to a chain-formatted value usingexpected_amount = token.chain_formatted_value(human_readable_value=Decimal(amount))
is a good practice for ensuring consistency in how amounts are represented and processed. It's crucial to verify that thechain_formatted_value
method accurately handles the conversion, especially with respect to rounding and precision.Verification successful
The implementation of
chain_formatted_value
inpyinjective/core/token.py
correctly handles rounding and precision by using theDecimal
class for arithmetic operations and scaling thehuman_readable_value
by10^decimals
. This approach is consistent with best practices for converting between human-readable and chain-formatted values in cryptocurrency applications. The review comment's concern about ensuring consistency in how amounts are represented and processed is addressed by this implementation.* 209-238: The test `test_msg_withdraw` follows a similar pattern to `test_msg_deposit`, including the conversion of amounts for consistency. It's equally important here to ensure that the conversion logic is robust and tested, especially given the financial implications of withdrawal operations.Scripts Executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Verify the implementation of chain_formatted_value to ensure it handles rounding and precision correctly. cat tests/test_composer.py | grep -A 10 "def chain_formatted_value"Length of output: 69
Script:
#!/bin/bash # Search for the implementation of chain_formatted_value across the entire codebase rg "def chain_formatted_value" --files-with-matchesLength of output: 79
Script:
#!/bin/bash # Display the implementation of chain_formatted_value from pyinjective/core/token.py cat pyinjective/core/token.py | grep -A 20 "def chain_formatted_value"Length of output: 219
Verification successful
The implementation of
chain_formatted_value
inpyinjective/core/token.py
correctly converts human-readable values to the chain's format by adjusting for the token's decimal places. This method is appropriately used in thetest_msg_withdraw
to ensure that withdrawal amounts are correctly formatted for blockchain transactions. The review comment's concern about the importance of robust conversion logic, especially for financial operations, is addressed by this implementation.* 240-279: In `test_msg_instant_spot_market_launch`, the calculation of `expected_min_price_tick_size` and `expected_min_quantity_tick_size` involves adjusting for token decimals and additional chain format decimals. This approach is commendable for its attention to detail in ensuring that tick sizes are accurately represented on-chain. It's important to validate these calculations against expected outcomes to prevent any unintended market behavior. * 281-342: The `test_msg_instant_perpetual_market_launch` method includes comprehensive testing of various market parameters, including fee rates and margin ratios, converted for chain compatibility. This thorough testing is crucial for ensuring that market launches behave as expected, particularly in terms of financial risk management. Continuous validation of these parameters against real-world scenarios is recommended.Scripts Executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Reuse the previous script to verify the implementation of chain_formatted_value for withdrawal amounts. cat tests/test_composer.py | grep -A 10 "def chain_formatted_value"Length of output: 69
Script:
#!/bin/bash # Search for the definition of chain_formatted_value across the entire codebase rg "def chain_formatted_value" --context 10Length of output: 662
Verification successful
The review comment regarding the
test_msg_instant_perpetual_market_launch
method is justified. The method indeed includes comprehensive testing of various market parameters, such as fee rates and margin ratios, converted for chain compatibility. This testing is crucial for ensuring that market launches behave as expected, particularly in terms of financial risk management. The recommendation for continuous validation of these parameters against real-world scenarios is well-founded, emphasizing the importance of maintaining robustness under various market conditions.* 344-408: The `test_msg_instant_expiry_futures_market_launch` function tests the launching of an expiry futures market with various parameters, including oracle settings and fee rates. Given the complexity of futures markets, it's essential to ensure that all parameters are correctly set and that the market behaves as expected under various conditions. * 410-451: The `test_spot_order` function demonstrates the creation of a spot order with detailed assertions on the expected order structure. This level of detail is crucial for ensuring that orders are correctly formatted and processed by the system. It's recommended to also include negative test cases to ensure robust error handling.Scripts Executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Suggest manual review for validating market parameters in test_msg_instant_perpetual_market_launch. echo "Manual review recommended for validating market parameters in test_msg_instant_perpetual_market_launch."Length of output: 216
Consider adding negative test cases to ensure the system gracefully handles invalid or malformed orders.
- 453-497: In
test_derivative_order
, similar to the spot order test, the creation and validation of a derivative order are thoroughly tested. Including tests for edge cases, such as orders with zero quantity or invalid market IDs, would further strengthen the test suite's coverage and robustness.Enhance the test suite by including edge cases and negative scenarios for derivative orders to ensure comprehensive coverage.
- 499-547: The
test_msg_create_spot_limit_order
method correctly tests the creation of a spot limit order, ensuring that all fields are properly set. It's important to verify that the system's order matching logic correctly interprets and executes these orders as intended, especially in edge cases.- 549-584: The
test_msg_batch_create_spot_limit_orders
function tests the batch creation of spot limit orders, an important feature for users who need to execute multiple orders efficiently. Ensuring that the batch processing logic maintains order integrity and correctly handles partial failures is critical.- 586-633: The
test_msg_create_spot_market_order
method tests the creation of a spot market order. It's crucial to ensure that market orders are executed according to current market conditions and that the test reflects realistic scenarios, including liquidity considerations.- 635-661: In
test_msg_cancel_spot_order
, the cancellation of a spot order is tested. It's important to verify that the cancellation process correctly identifies and nullifies the specified order without affecting other orders, especially in high-frequency trading environments.- 663-688: The
test_msg_batch_cancel_spot_orders
function tests the batch cancellation of spot orders. This feature is critical for users needing to quickly adjust their positions. Ensuring that the batch cancellation process is atomic and either fully succeeds or reverts in case of failure is essential for maintaining market integrity.- 690-787: The
test_msg_batch_update_orders
method tests a complex scenario involving the creation and cancellation of multiple order types across different markets. This comprehensive test is crucial for ensuring that the system can handle complex order management operations. It's recommended to also test the resilience of this feature under high load or failure conditions.Consider stress testing the batch update orders feature to ensure its resilience and reliability under high load or partial failure conditions.
- 789-812: In
test_msg_privileged_execute_contract
, the execution of a contract with privileged access is tested. Given the potential security implications, it's vital to ensure that only authorized entities can invoke this functionality and that all security checks are robust and comprehensive.- 814-863: The
test_msg_create_derivative_limit_order
function tests the creation of a derivative limit order, which is essential for derivative market participants. Ensuring that these orders are accurately represented and processed in the matching engine, especially under various market conditions, is crucial.- 866-901: In
test_msg_batch_create_derivative_limit_orders
, the batch creation of derivative limit orders is tested. This functionality is important for traders managing large portfolios. Verifying that the system can efficiently process and match these orders in batch mode without performance degradation is essential.- 904-953: The
test_msg_create_derivative_market_order
method tests the creation of a derivative market order. It's important to ensure that these orders are executed with respect to current market liquidity and that slippage is handled appropriately. Testing against various liquidity scenarios would enhance the robustness of this test.Enhance testing of derivative market orders by including various liquidity scenarios to assess slippage handling and execution accuracy.
- 956-995: In
test_msg_cancel_derivative_order
, the cancellation of a derivative order is tested. Ensuring that the cancellation logic correctly identifies the target order without impacting other market participants is crucial. Additionally, testing the system's ability to handle rapid order cancellations in volatile markets is recommended.Consider testing the derivative order cancellation feature under scenarios of high market volatility and rapid order submissions/cancellations to ensure system stability and correctness.
- 997-1021: The
test_msg_batch_cancel_derivative_orders
function tests the batch cancellation of derivative orders. Similar to spot order batch cancellations, verifying the atomicity and reliability of this process is essential, especially in fast-moving derivative markets where timing is critical.- 1023-1085: The
test_msg_instant_binary_options_market_launch
method tests the launching of a binary options market with various parameters. Given the unique characteristics of binary options markets, ensuring that all parameters are correctly set and that the market behaves as expected under different scenarios is critical.- 1087-1136: In
test_msg_create_binary_options_limit_order
, the creation of a binary options limit order is tested. This test is important for ensuring that binary options orders are correctly processed and matched. Including tests for scenarios where the market moves significantly before order execution could provide additional insights into system behavior.Include scenarios in testing where the market moves significantly before the execution of binary options limit orders to assess system behavior under such conditions.
- 1139-1188: The
test_msg_create_binary_options_market_order
function tests the creation of a binary options market order. It's crucial to verify that these orders are executed promptly and accurately, taking into account the unique payout structures of binary options. Testing against a range of market conditions would be beneficial.Expand testing of binary options market orders to include a wider range of market conditions, focusing on execution speed and accuracy.
- 1191-1230: In
test_msg_cancel_derivative_order
for binary options, the cancellation logic is tested. Ensuring that binary options orders can be canceled efficiently and without unintended consequences is important for market integrity. Testing the cancellation process under high-frequency trading conditions could highlight potential areas for improvement.Test the cancellation process for binary options orders under high-frequency trading conditions to ensure efficiency and market integrity.
- 1232-1264: The
test_msg_subaccount_transfer
method tests the transfer of funds between subaccounts. This functionality is critical for managing funds within the platform. Ensuring that transfers are atomic and that the system correctly handles edge cases, such as insufficient funds, is essential.- 1266-1298: In
test_msg_external_transfer
, the transfer of funds to an external subaccount is tested. Given the potential for funds to leave the platform, it's crucial to ensure that these transfers are secure and that all necessary validations are in place to prevent unauthorized or fraudulent transfers.- 1300-1331: The
test_msg_liquidate_position
function tests the liquidation of a position in a derivative market. This critical functionality must be thoroughly tested to ensure that liquidations are executed fairly and accurately, especially under extreme market conditions.Enhance testing of position liquidation to include scenarios of extreme market volatility and stress conditions to ensure fair and accurate execution.
- 1333-1352: In
test_msg_emergency_settle_market
, the emergency settlement of a market is tested. This functionality is a critical safety mechanism and must be tested extensively to ensure that it can be executed reliably and without unintended consequences in real emergency situations.Conduct comprehensive testing of the emergency market settlement feature, including simulations of real emergency scenarios, to validate its reliability and effectiveness.
- 1355-1382: The
test_msg_external_transfer
method for increasing position margin in a derivative market is tested. Ensuring that margin increases are processed correctly and in a timely manner is crucial for maintaining the necessary collateral levels and preventing unintended liquidations.- 1385-1398: The
test_msg_rewards_opt_out
function tests the opt-out functionality for rewards. This feature allows users to decline participation in reward programs, and it's important to ensure that the opt-out process is straightforward and irreversible, as desired by the user.- 1401-1431: In
test_msg_admin_update_binary_options_market
, the administrative update of a binary options market is tested. Given the potential impact of administrative actions on market participants, it's crucial to ensure that these updates are authorized, logged, and transparent to all affected parties.tests/test_async_client_deprecation_warnings.py (1)
- 24-24: The correction in the import statement from
configurable_autz_query_servicer
toconfigurable_authz_query_servicer
is accurate and resolves a typo, ensuring the correct module is imported.pyinjective/composer.py (43)
- 140-143: The method
Coin
is marked as deprecated with a warning to usecoin
instead. This is a good practice for maintaining backward compatibility while guiding users towards the new method.- 164-167: The method
OrderData
is marked as deprecated with a warning to useorder_data
instead. Proper deprecation warnings are essential for a smooth transition to new methods.- 212-215: The method
SpotOrder
is marked as deprecated with a warning to usespot_order
instead. This consistent approach to deprecation across the file helps maintain code clarity and guides users effectively.- 304-307: The method
DerivativeOrder
is marked as deprecated with a warning to usederivative_order
instead. It's good to see a consistent pattern in handling deprecated methods across the file.- 489-493: The method
MsgDeposit
is marked as deprecated with a warning to usemsg_deposit
instead. This deprecation notice is crucial for guiding users towards the updated method.- 511-515: The method
MsgWithdraw
is marked as deprecated with a warning to usemsg_withdraw
instead. Consistent deprecation warnings across different methods help in maintaining backward compatibility while encouraging the use of updated methods.- 660-663: The method
MsgCreateSpotLimitOrder
is marked as deprecated with a warning to usemsg_create_spot_limit_order
instead. This approach ensures users are aware of the newer, preferred methods.- 717-721: The method
MsgBatchCreateSpotLimitOrders
is marked as deprecated with a warning to usemsg_batch_create_spot_limit_orders
instead. This consistent approach to deprecation is beneficial for users transitioning to new methods.- 733-747: The method
MsgCreateSpotMarketOrder
is marked as deprecated with a warning to usemsg_create_spot_market_order
instead. Properly deprecating methods and guiding users to the new implementations is crucial for a smooth transition.- 792-803: The method
MsgCancelSpotOrder
is marked as deprecated with a warning to usemsg_cancel_spot_order
instead. This consistent deprecation strategy across the file helps users navigate the changes effectively.- 829-832: The method
MsgBatchCancelSpotOrders
is marked as deprecated with a warning to usemsg_batch_cancel_spot_orders
instead. This approach ensures that users are informed about the newer, preferred methods.- 840-844: The method
MsgBatchUpdateOrders
is marked as deprecated with a warning to usemsg_batch_update_orders
instead. Consistent deprecation warnings across different methods help in maintaining backward compatibility while encouraging the use of updated methods.- 887-893: The method
MsgPrivilegedExecuteContract
is marked as deprecated with a warning to usemsg_privileged_execute_contract
instead. This deprecation notice is crucial for guiding users towards the updated method.- 929-932: The method
MsgCreateDerivativeLimitOrder
is marked as deprecated with a warning to usemsg_create_derivative_limit_order
instead. This approach ensures users are aware of the newer, preferred methods.- 1008-1013: The method
MsgBatchCreateDerivativeLimitOrders
is marked as deprecated with a warning to usemsg_batch_create_derivative_limit_orders
instead. This consistent approach to deprecation is beneficial for users transitioning to new methods.- 1038-1041: The method
MsgCreateDerivativeMarketOrder
is marked as deprecated with a warning to usemsg_create_derivative_market_order
instead. Properly deprecating methods and guiding users to the new implementations is crucial for a smooth transition.- 1119-1129: The method
MsgCancelDerivativeOrder
is marked as deprecated with a warning to usemsg_cancel_derivative_order
instead. This consistent deprecation strategy across the file helps users navigate the changes effectively.- 1173-1177: The method
MsgBatchCancelDerivativeOrders
is marked as deprecated with a warning to usemsg_batch_cancel_derivative_orders
instead. This approach ensures that users are informed about the newer, preferred methods.- 1207-1211: The method
MsgInstantBinaryOptionsMarketLaunch
is marked as deprecated with a warning to usemsg_instant_binary_options_market_launch
instead. Consistent deprecation warnings across different methods help in maintaining backward compatibility while encouraging the use of updated methods.- 1299-1302: The method
MsgCreateBinaryOptionsLimitOrder
is marked as deprecated with a warning to usemsg_create_binary_options_limit_order
instead. This deprecation notice is crucial for guiding users towards the updated method.- 1393-1396: The method
MsgCreateBinaryOptionsMarketOrder
is marked as deprecated with a warning to usemsg_create_binary_options_market_order
instead. This approach ensures users are aware of the newer, preferred methods.- 1484-1487: The method
MsgCancelBinaryOptionsOrder
is marked as deprecated with a warning to usemsg_cancel_binary_options_order
instead. This consistent approach to deprecation is beneficial for users transitioning to new methods.- 1530-1533: The method
MsgSubaccountTransfer
is marked as deprecated with a warning to usemsg_subaccount_transfer
instead. Properly deprecating methods and guiding users to the new implementations is crucial for a smooth transition.- 1572-1575: The method
MsgExternalTransfer
is marked as deprecated with a warning to usemsg_external_transfer
instead. This consistent deprecation strategy across the file helps users navigate the changes effectively.- 1613-1616: The method
MsgLiquidatePosition
is marked as deprecated with a warning to usemsg_liquidate_position
instead. This approach ensures that users are informed about the newer, preferred methods.- 1654-1657: The method
MsgIncreasePositionMargin
is marked as deprecated with a warning to usemsg_increase_position_margin
instead. Consistent deprecation warnings across different methods help in maintaining backward compatibility while encouraging the use of updated methods.- 1692-1696: The method
MsgRewardsOptOut
is marked as deprecated with a warning to usemsg_rewards_opt_out
instead. This deprecation notice is crucial for guiding users towards the updated method.- 1713-1716: The method
MsgAdminUpdateBinaryOptionsMarket
is marked as deprecated with a warning to usemsg_admin_update_binary_options_market
instead. This approach ensures users are aware of the newer, preferred methods.- 2107-2110: The method
MsgWithdrawDelegatorReward
is marked as deprecated with a warning to usemsg_withdraw_delegator_reward
instead. This consistent approach to deprecation is beneficial for users transitioning to new methods.- 2121-2124: The method
MsgWithdrawValidatorCommission
is marked as deprecated with a warning to usemsg_withdraw_validator_commission
instead. Properly deprecating methods and guiding users to the new implementations is crucial for a smooth transition.- 146-151: The new
coin
method correctly creates an instance of theCoin
gRPC type, considering the amount is already expressed in chain format. This method simplifies the creation ofCoin
objects and is a good addition for better code readability and maintainability.- 153-159: The
create_coin_amount
method is a valuable addition, allowing for the creation ofCoin
gRPC types with precise calculations using theDecimal
type. This method enhances the flexibility and accuracy of handling token amounts.- 182-192: The
order_data
method introduces a more flexible way to createOrderData
objects by allowing optional parameters for conditional, buy, and market order types. This method improves the modularity and usability of order creation within the SDK.- 249-281: The
spot_order
method is a significant improvement over its deprecated counterpart, offering more precise handling of quantities and prices using theDecimal
type and allowing for a clearer definition of order types. This method enhances the SDK's functionality for creating spot orders.- 362-393: The
derivative_order
method is a comprehensive addition that allows for the creation of derivative orders with detailed parameters, including margin and trigger price. This method significantly enhances the SDK's capabilities for handling derivative orders.- 395-427: The
binary_options_order
method is a new functionality that extends the SDK's capabilities to handle binary options orders. It introduces additional parameters likedenom
for special handling of quantities and prices, which is a valuable addition for users dealing with binary options.- 502-509: The
msg_deposit
method is a new addition that replaces the deprecatedMsgDeposit
method. It correctly uses theDecimal
type for the amount, enhancing the precision and flexibility of deposit operations within the SDK.- 524-531: The
msg_withdraw
method is a new addition that replaces the deprecatedMsgWithdraw
method. It correctly uses theDecimal
type for the amount, enhancing the precision and flexibility of withdrawal operations within the SDK.- 691-713: The
msg_create_spot_limit_order
method is a significant improvement over its deprecated counterpart, offering more precise handling of quantities and prices using theDecimal
type and allowing for a clearer definition of order types. This method enhances the SDK's functionality for creating spot limit orders.- 728-731: The
msg_batch_create_spot_limit_orders
method is a new addition that replaces the deprecatedMsgBatchCreateSpotLimitOrders
method. It correctly handles a list ofSpotOrder
objects, enhancing the SDK's batch processing capabilities for spot limit orders.- 766-790: The
msg_create_spot_market_order
method is a new addition that replaces the deprecatedMsgCreateSpotMarketOrder
method. It introduces more precise handling of quantities and prices using theDecimal
type and allows for a clearer definition of order types, enhancing the SDK's functionality for creating spot market orders.- 812-826: The
msg_cancel_spot_order
method is a new addition that replaces the deprecatedMsgCancelSpotOrder
method. It correctly handles optional parameters for conditional, buy, and market order types, enhancing the SDK's functionality for canceling spot orders.- 835-838: The
msg_batch_cancel_spot_orders
method is a new addition that replaces the deprecatedMsgBatchCancelSpotOrders
method. It correctly handles a list ofOrderData
objects, enhancing the SDK's batch processing capabilities for canceling spot orders.pyinjective/async_client.py (5)
- 15-16: The addition of imports for
ChainGrpcDistributionApi
andChainGrpcExchangeApi
is aligned with the PR objectives to enhance theasync_client.py
with new functionalities for interacting with the Injective Protocol's distribution and exchange modules. This change is necessary for the subsequent use of these APIs within theAsyncClient
class.- 183-194: The initialization of
distribution_api
andchain_exchange_api
within theAsyncClient
constructor is correctly implemented. The use ofself.chain_channel
as the channel and the lambda function formetadata_provider
ensures that these APIs can utilize the established gRPC channel and metadata for requests. This setup is essential for enabling the new functionalities related to the Injective Protocol's distribution and exchange modules as mentioned in the PR objectives.- 589-648: The methods added for fetching distribution information, such as
fetch_validator_distribution_info
,fetch_validator_outstanding_rewards
,fetch_validator_commission
,fetch_validator_slashes
,fetch_delegation_rewards
,fetch_delegation_total_rewards
,fetch_delegator_validators
,fetch_delegator_withdraw_address
, andfetch_community_pool
, are correctly implemented. They utilize thedistribution_api
to make the respective gRPC calls. This addition aligns with the PR objectives to enhance the client's capabilities in interacting with the distribution module of the Injective Protocol. It's important to ensure that these methods are accompanied by appropriate error handling and validation where necessary, although the specifics of such validations are not visible in the provided context.- 651-1037: The methods added for interacting with the Injective Protocol's exchange module, such as
fetch_subaccount_deposits
,fetch_subaccount_deposit
,fetch_exchange_balances
,fetch_aggregate_volume
,fetch_aggregate_volumes
,fetch_aggregate_market_volume
,fetch_aggregate_market_volumes
,fetch_denom_decimal
,fetch_denom_decimals
,fetch_chain_spot_markets
,fetch_chain_spot_market
,fetch_chain_full_spot_markets
,fetch_chain_full_spot_market
,fetch_chain_spot_orderbook
,fetch_chain_trader_spot_orders
,fetch_chain_account_address_spot_orders
,fetch_chain_spot_orders_by_hashes
,fetch_chain_subaccount_orders
,fetch_chain_trader_spot_transient_orders
,fetch_spot_mid_price_and_tob
,fetch_derivative_mid_price_and_tob
,fetch_chain_derivative_orderbook
,fetch_chain_trader_derivative_orders
,fetch_chain_account_address_derivative_orders
,fetch_chain_derivative_orders_by_hashes
,fetch_chain_trader_derivative_transient_orders
,fetch_chain_derivative_markets
,fetch_chain_derivative_market
,fetch_derivative_market_address
,fetch_subaccount_trade_nonce
,fetch_chain_positions
,fetch_chain_subaccount_positions
,fetch_chain_subaccount_position_in_market
,fetch_chain_subaccount_effective_position_in_market
,fetch_chain_perpetual_market_info
,fetch_chain_expiry_futures_market_info
,fetch_chain_perpetual_market_funding
,fetch_subaccount_order_metadata
,fetch_trade_reward_points
,fetch_pending_trade_reward_points
,fetch_trade_reward_campaign
,fetch_fee_discount_account_info
,fetch_fee_discount_schedule
,fetch_balance_mismatches
,fetch_balance_with_balance_holds
,fetch_fee_discount_tier_statistics
,fetch_mito_vault_infos
,fetch_market_id_from_vault
,fetch_historical_trade_records
,fetch_is_opted_out_of_rewards
,fetch_opted_out_of_rewards_accounts
,fetch_market_volatility
,fetch_chain_binary_options_markets
,fetch_trader_derivative_conditional_orders
, andfetch_market_atomic_execution_fee_multiplier
are correctly implemented. These methods significantly expand the client's functionality, allowing for comprehensive interaction with various aspects of the exchange module. It's crucial that these methods are tested thoroughly to ensure they handle all possible edge cases and errors gracefully. Additionally, considering the extensive list of new functionalities, documentation should be updated accordingly to help users understand how to use these new methods effectively.- 3229-3236: The refactoring of the token representation logic within the
_token_representation
method is a positive change that improves the maintainability and readability of the code. By extracting the logic for determining a unique symbol and creating aToken
instance into a separate method, the code becomes more modular and easier to understand. This refactoring aligns with best practices for code organization and modularity. However, it's important to ensure that this method is called correctly throughout the class and that any changes to theToken
model or its usage are consistently applied.poetry.lock (16)
- 638-694: The update to "coverage" version "7.4.3" includes new wheel files for various Python versions and platforms, each with a corresponding SHA256 hash. Ensure that this version is compatible with the project's requirements and that the hashes match those from a trusted source, such as PyPI.
- 902-908: The update to "eth-abi" version "5.0.1" includes a wheel file and a source distribution, each with a SHA256 hash. Verify that this version is compatible with the project's requirements and confirm the hashes with a trusted source.
- 917-919: The extras for "eth-abi" have been updated to specify dependencies for development, documentation, testing, and tools. Review these extras to ensure they align with the project's development and deployment needs.
- 951-957: The update to "eth-hash" version "0.7.0" includes a wheel file and a source distribution, each with a SHA256 hash. Ensure this version is compatible with the project's requirements and verify the hashes with a trusted source.
- 972-978: The update to "eth-keyfile" version "0.8.0" includes a wheel file and a source distribution, each with a SHA256 hash. Verify that this version is compatible with the project's requirements and confirm the hashes with a trusted source.
- 1233-1361: The updates to "grpcio" and "grpcio-tools" version "1.62.0" include numerous wheel files for various Python versions and platforms, each with a SHA256 hash. Additionally, there's an update to the "grpcio-tools" package dependencies. Ensure these versions are compatible with the project's requirements, verify the hashes with a trusted source, and review the updated dependencies for "grpcio-tools".
- 1398-1404: The update to "identify" version "2.5.35" includes a wheel file and a source distribution, each with a SHA256 hash. Verify that this version is compatible with the project's requirements and confirm the hashes with a trusted source.
- 1788-1794: The update to "pre-commit" version "3.6.2" includes a wheel file and a source distribution, each with a SHA256 hash. Ensure this version is compatible with the project's requirements and verify the hashes with a trusted source.
- 1806-1821: The update to "protobuf" version "4.25.3" includes numerous wheel files for various Python versions and platforms, each with a SHA256 hash. Verify that this version is compatible with the project's requirements and confirm the hashes with a trusted source.
- 1915-1921: The update to "pytest" version "8.0.2" includes a wheel file and a source distribution, each with a SHA256 hash. Ensure this version is compatible with the project's requirements and verify the hashes with a trusted source.
- 1985-1998: The update to "python-dotenv" version "1.0.1" includes a wheel file and a source distribution, each with a SHA256 hash, and an update to the package extras specifying a dependency for the CLI. Verify that this version is compatible with the project's requirements, confirm the hashes with a trusted source, and review the updated extras for relevance.
- 2270-2373: The update to "rpds-py" version "0.18.0" includes numerous wheel files for various Python versions and platforms, each with a SHA256 hash. Ensure this version is compatible with the project's requirements and verify the hashes with a trusted source.
- 2388-2400: The update to "setuptools" version "69.1.1" includes a wheel file and a source distribution, each with a SHA256 hash, and an update to the package extras specifying dependencies for documentation and testing. Verify that this version is compatible with the project's requirements, confirm the hashes with a trusted source, and review the updated extras for relevance.
- 2448-2454: The update to "typing-extensions" version "4.10.0" includes a wheel file and a source distribution, each with a SHA256 hash. Ensure this version is compatible with the project's requirements and verify the hashes with a trusted source.
- 2475-2481: The update to "virtualenv" version "20.25.1" includes a wheel file and a source distribution, each with a SHA256 hash. Verify that this version is compatible with the project's requirements and confirm the hashes with a trusted source.
- 2715-2715: The metadata section has been updated with a new content-hash. This is a standard practice to ensure the integrity of the
poetry.lock
file after modifications.
class ConfigurableExchangeQueryServicer(exchange_query_grpc.QueryServicer): | ||
def __init__(self): | ||
super().__init__() | ||
self.exchange_params = deque() | ||
self.subaccount_deposits_responses = deque() | ||
self.subaccount_deposit_responses = deque() | ||
self.exchange_balances_responses = deque() | ||
self.aggregate_volume_responses = deque() | ||
self.aggregate_volumes_responses = deque() | ||
self.aggregate_market_volume_responses = deque() | ||
self.aggregate_market_volumes_responses = deque() | ||
self.denom_decimal_responses = deque() | ||
self.denom_decimals_responses = deque() | ||
self.spot_markets_responses = deque() | ||
self.spot_market_responses = deque() | ||
self.full_spot_markets_responses = deque() | ||
self.full_spot_market_responses = deque() | ||
self.spot_orderbook_responses = deque() | ||
self.trader_spot_orders_responses = deque() | ||
self.account_address_spot_orders_responses = deque() | ||
self.spot_orders_by_hashes_responses = deque() | ||
self.subaccount_orders_responses = deque() | ||
self.trader_spot_transient_orders_responses = deque() | ||
self.spot_mid_price_and_tob_responses = deque() | ||
self.derivative_mid_price_and_tob_responses = deque() | ||
self.derivative_orderbook_responses = deque() | ||
self.trader_derivative_orders_responses = deque() | ||
self.account_address_derivative_orders_responses = deque() | ||
self.derivative_orders_by_hashes_responses = deque() | ||
self.trader_derivative_transient_orders_responses = deque() | ||
self.derivative_markets_responses = deque() | ||
self.derivative_market_responses = deque() | ||
self.derivative_market_address_responses = deque() | ||
self.subaccount_trade_nonce_responses = deque() | ||
self.positions_responses = deque() | ||
self.subaccount_positions_responses = deque() | ||
self.subaccount_position_in_market_responses = deque() | ||
self.subaccount_effective_position_in_market_responses = deque() | ||
self.perpetual_market_info_responses = deque() | ||
self.expiry_futures_market_info_responses = deque() | ||
self.perpetual_market_funding_responses = deque() | ||
self.subaccount_order_metadata_responses = deque() | ||
self.trade_reward_points_responses = deque() | ||
self.pending_trade_reward_points_responses = deque() | ||
self.trade_reward_campaign_responses = deque() | ||
self.fee_discount_account_info_responses = deque() | ||
self.fee_discount_schedule_responses = deque() | ||
self.balance_mismatches_responses = deque() | ||
self.balance_with_balance_holds_responses = deque() | ||
self.fee_discount_tier_statistics_responses = deque() | ||
self.mito_vault_infos_responses = deque() | ||
self.market_id_from_vault_responses = deque() | ||
self.historical_trade_records_responses = deque() | ||
self.is_opted_out_of_rewards_responses = deque() | ||
self.opted_out_of_rewards_accounts_responses = deque() | ||
self.market_volatility_responses = deque() | ||
self.binary_options_markets_responses = deque() | ||
self.trader_derivative_conditional_orders_responses = deque() | ||
self.market_atomic_execution_fee_multiplier_responses = deque() | ||
|
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 ConfigurableExchangeQueryServicer
class is well-structured for mocking exchange query services. Using deque
for mock responses is a good choice for FIFO behavior, which is typical in mock scenarios. However, ensure that there is a mechanism in place to handle cases where a pop()
operation is called on an empty deque
, as this will raise an IndexError
. Consider adding checks or default responses to prevent potential runtime errors during testing.
): | ||
return self.perpetual_market_info_responses.pop() | ||
|
||
async def ExpiryFuturesMarketInfo( | ||
self, request: exchange_query_pb.QueryExpiryFuturesMarketInfoRequest, context=None, metadata=None | ||
): | ||
return self.expiry_futures_market_info_responses.pop() | ||
|
||
async def PerpetualMarketFunding( | ||
self, request: exchange_query_pb.QueryPerpetualMarketFundingRequest, context=None, metadata=None | ||
): | ||
return self.perpetual_market_funding_responses.pop() | ||
|
||
async def SubaccountOrderMetadata( | ||
self, request: exchange_query_pb.QuerySubaccountOrderMetadataRequest, context=None, metadata=None | ||
): | ||
return self.subaccount_order_metadata_responses.pop() | ||
|
||
async def TradeRewardPoints( | ||
self, request: exchange_query_pb.QueryTradeRewardPointsRequest, context=None, metadata=None | ||
): | ||
return self.trade_reward_points_responses.pop() | ||
|
||
async def PendingTradeRewardPoints( | ||
self, request: exchange_query_pb.QueryTradeRewardPointsRequest, context=None, metadata=None | ||
): | ||
return self.pending_trade_reward_points_responses.pop() | ||
|
||
async def TradeRewardCampaign( | ||
self, request: exchange_query_pb.QueryTradeRewardCampaignRequest, context=None, metadata=None | ||
): | ||
return self.trade_reward_campaign_responses.pop() | ||
|
||
async def FeeDiscountAccountInfo( | ||
self, request: exchange_query_pb.QueryFeeDiscountAccountInfoRequest, context=None, metadata=None | ||
): | ||
return self.fee_discount_account_info_responses.pop() | ||
|
||
async def FeeDiscountSchedule( | ||
self, request: exchange_query_pb.QueryFeeDiscountScheduleRequest, context=None, metadata=None | ||
): | ||
return self.fee_discount_schedule_responses.pop() | ||
|
||
async def BalanceMismatches( | ||
self, request: exchange_query_pb.QueryBalanceMismatchesRequest, context=None, metadata=None | ||
): | ||
return self.balance_mismatches_responses.pop() | ||
|
||
async def BalanceWithBalanceHolds( | ||
self, request: exchange_query_pb.QueryBalanceWithBalanceHoldsRequest, context=None, metadata=None | ||
): | ||
return self.balance_with_balance_holds_responses.pop() | ||
|
||
async def FeeDiscountTierStatistics( | ||
self, request: exchange_query_pb.QueryFeeDiscountTierStatisticsRequest, context=None, metadata=None | ||
): | ||
return self.fee_discount_tier_statistics_responses.pop() | ||
|
||
async def MitoVaultInfos(self, request: exchange_query_pb.MitoVaultInfosRequest, context=None, metadata=None): | ||
return self.mito_vault_infos_responses.pop() | ||
|
||
async def QueryMarketIDFromVault( | ||
self, request: exchange_query_pb.QueryMarketIDFromVaultRequest, context=None, metadata=None | ||
): | ||
return self.market_id_from_vault_responses.pop() | ||
|
||
async def HistoricalTradeRecords( | ||
self, request: exchange_query_pb.QueryHistoricalTradeRecordsRequest, context=None, metadata=None | ||
): | ||
return self.historical_trade_records_responses.pop() | ||
|
||
async def IsOptedOutOfRewards( | ||
self, request: exchange_query_pb.QueryIsOptedOutOfRewardsRequest, context=None, metadata=None | ||
): | ||
return self.is_opted_out_of_rewards_responses.pop() | ||
|
||
async def OptedOutOfRewardsAccounts( | ||
self, request: exchange_query_pb.QueryOptedOutOfRewardsAccountsRequest, context=None, metadata=None | ||
): | ||
return self.opted_out_of_rewards_accounts_responses.pop() | ||
|
||
async def MarketVolatility( | ||
self, request: exchange_query_pb.QueryMarketVolatilityRequest, context=None, metadata=None | ||
): | ||
return self.market_volatility_responses.pop() | ||
|
||
async def BinaryOptionsMarkets( | ||
self, request: exchange_query_pb.QueryBinaryMarketsRequest, context=None, metadata=None | ||
): | ||
return self.binary_options_markets_responses.pop() | ||
|
||
async def TraderDerivativeConditionalOrders( | ||
self, request: exchange_query_pb.QueryTraderDerivativeConditionalOrdersRequest, context=None, metadata=None | ||
): | ||
return self.trader_derivative_conditional_orders_responses.pop() | ||
|
||
async def MarketAtomicExecutionFeeMultiplier( | ||
self, request: exchange_query_pb.QueryMarketAtomicExecutionFeeMultiplierRequest, context=None, metadata=None | ||
): | ||
return self.market_atomic_execution_fee_multiplier_responses.pop() |
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.
Each async method in ConfigurableExchangeQueryServicer
correctly pops a response from its respective deque
. This setup is crucial for testing different scenarios by preloading the deque
with expected responses. However, it's important to ensure that all methods have corresponding test cases that cover various scenarios, including empty responses and error cases. This will help in validating the robustness of the application's error handling and response parsing logic.
Would you like me to help generate some test cases covering various scenarios for these methods?
assert len(deprecation_warnings) == 1 | ||
assert str(deprecation_warnings[0].message) == "This method is deprecated. Use msg_withdraw instead" | ||
|
||
def teste_order_data_deprecation_warning(self): |
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.
There's a typo in the method name teste_order_data_deprecation_warning
. It should be test_order_data_deprecation_warning
.
- def teste_order_data_deprecation_warning(self):
+ def test_order_data_deprecation_warning(self):
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.
def teste_order_data_deprecation_warning(self): | |
def test_order_data_deprecation_warning(self): |
return response | ||
|
||
async def fetch_balance_with_balance_holds(self) -> Dict[str, Any]: | ||
request = exchange_query_pb.QueryBalanceWithBalanceHoldsRequest() | ||
response = await self._execute_call(call=self._stub.BalanceWithBalanceHolds, request=request) | ||
|
||
return response | ||
|
||
async def fetch_fee_discount_tier_statistics(self) -> Dict[str, Any]: | ||
request = exchange_query_pb.QueryFeeDiscountTierStatisticsRequest() | ||
response = await self._execute_call(call=self._stub.FeeDiscountTierStatistics, request=request) | ||
|
||
return response | ||
|
||
async def fetch_mito_vault_infos(self) -> Dict[str, Any]: | ||
request = exchange_query_pb.MitoVaultInfosRequest() | ||
response = await self._execute_call(call=self._stub.MitoVaultInfos, request=request) | ||
|
||
return response | ||
|
||
async def fetch_market_id_from_vault(self, vault_address: str) -> Dict[str, Any]: | ||
request = exchange_query_pb.QueryMarketIDFromVaultRequest(vault_address=vault_address) | ||
response = await self._execute_call(call=self._stub.QueryMarketIDFromVault, request=request) | ||
|
||
return response | ||
|
||
async def fetch_historical_trade_records(self, market_id: str) -> Dict[str, Any]: | ||
request = exchange_query_pb.QueryHistoricalTradeRecordsRequest(market_id=market_id) | ||
response = await self._execute_call(call=self._stub.HistoricalTradeRecords, request=request) | ||
|
||
return response | ||
|
||
async def fetch_is_opted_out_of_rewards(self, account: str) -> Dict[str, Any]: | ||
request = exchange_query_pb.QueryIsOptedOutOfRewardsRequest(account=account) | ||
response = await self._execute_call(call=self._stub.IsOptedOutOfRewards, request=request) | ||
|
||
return response | ||
|
||
async def fetch_opted_out_of_rewards_accounts(self) -> Dict[str, Any]: | ||
request = exchange_query_pb.QueryOptedOutOfRewardsAccountsRequest() | ||
response = await self._execute_call(call=self._stub.OptedOutOfRewardsAccounts, request=request) | ||
|
||
return response | ||
|
||
async def fetch_market_volatility( | ||
self, | ||
market_id: str, | ||
trade_grouping_sec: Optional[int] = None, | ||
max_age: Optional[int] = None, | ||
include_raw_history: Optional[bool] = None, | ||
include_metadata: Optional[bool] = None, | ||
) -> Dict[str, Any]: | ||
trade_history_options = exchange_query_pb.TradeHistoryOptions() | ||
if trade_grouping_sec is not None: | ||
trade_history_options.trade_grouping_sec = trade_grouping_sec | ||
if max_age is not None: | ||
trade_history_options.max_age = max_age | ||
if include_raw_history is not None: | ||
trade_history_options.include_raw_history = include_raw_history | ||
if include_metadata is not None: | ||
trade_history_options.include_metadata = include_metadata | ||
request = exchange_query_pb.QueryMarketVolatilityRequest( | ||
market_id=market_id, trade_history_options=trade_history_options | ||
) | ||
response = await self._execute_call(call=self._stub.MarketVolatility, request=request) | ||
|
||
return response | ||
|
||
async def fetch_binary_options_markets(self, status: Optional[str] = None) -> Dict[str, Any]: | ||
request = exchange_query_pb.QueryBinaryMarketsRequest(status=status) | ||
response = await self._execute_call(call=self._stub.BinaryOptionsMarkets, request=request) | ||
|
||
return response | ||
|
||
async def fetch_trader_derivative_conditional_orders( | ||
self, | ||
subaccount_id: Optional[str] = None, | ||
market_id: Optional[str] = None, | ||
) -> Dict[str, Any]: | ||
request = exchange_query_pb.QueryTraderDerivativeConditionalOrdersRequest( | ||
subaccount_id=subaccount_id, | ||
market_id=market_id, | ||
) | ||
response = await self._execute_call(call=self._stub.TraderDerivativeConditionalOrders, request=request) | ||
|
||
return response | ||
|
||
async def fetch_market_atomic_execution_fee_multiplier( | ||
self, | ||
market_id: str, | ||
) -> Dict[str, Any]: | ||
request = exchange_query_pb.QueryMarketAtomicExecutionFeeMultiplierRequest( | ||
market_id=market_id, | ||
) | ||
response = await self._execute_call(call=self._stub.MarketAtomicExecutionFeeMultiplier, request=request) | ||
|
||
return response | ||
|
||
async def _execute_call(self, call: Callable, request) -> Dict[str, Any]: | ||
return await self._assistant.execute_call(call=call, request=request) |
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.
Ensure comprehensive test coverage for all methods in the ChainGrpcExchangeApi
class. Given the complexity of interacting with a blockchain protocol, it's crucial to validate the correctness and resilience of these methods under various conditions.
Would you like assistance in generating tests or enhancing existing ones to cover these functionalities?
import asyncio | ||
import os | ||
|
||
import dotenv |
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 import statement for dotenv
is correct, but it's more conventional to use from dotenv import load_dotenv
and then simply call load_dotenv()
without the module prefix.
- import dotenv
+ from dotenv import load_dotenv
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.
import dotenv | |
from dotenv import load_dotenv |
message = composer.msg_instant_binary_options_market_launch( | ||
sender=address.to_acc_bech32(), | ||
ticker="UFC-KHABIB-TKO-05/30/2023", | ||
oracle_symbol="UFC-KHABIB-TKO-05/30/2023", | ||
oracle_provider="UFC", | ||
oracle_type="Provider", | ||
oracle_scale_factor=6, | ||
maker_fee_rate=0.0005, # 0.05% | ||
taker_fee_rate=0.0010, # 0.10% | ||
expiration_timestamp=1680730982, | ||
settlement_timestamp=1690730982, | ||
admin=address.to_acc_bech32(), | ||
quote_denom="peggy0xdAC17F958D2ee523a2206206994597C13D831ec7", | ||
min_price_tick_size=0.01, | ||
min_quantity_tick_size=0.01, | ||
) |
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 parameters for launching the binary options market, such as ticker
, oracle_symbol
, oracle_provider
, oracle_type
, maker_fee_rate
, taker_fee_rate
, expiration_timestamp
, settlement_timestamp
, quote_denom
, min_price_tick_size
, and min_quantity_tick_size
are hardcoded. While this might be suitable for example purposes, consider fetching these values from an environment variable or a configuration file to enhance flexibility and usability in real-world scenarios.
if __name__ == "__main__": | ||
asyncio.get_event_loop().run_until_complete(main()) |
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.
Recommend updating the method for running the async main function to asyncio.run(main())
for Python 3.7 and newer, which simplifies the entry point and ensures proper event loop management.
- asyncio.get_event_loop().run_until_complete(main())
+ asyncio.run(main())
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.
if __name__ == "__main__": | |
asyncio.get_event_loop().run_until_complete(main()) | |
if __name__ == "__main__": | |
asyncio.run(main()) |
dotenv.load_dotenv() | ||
configured_private_key = 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.
Include error handling for the scenario where the INJECTIVE_PRIVATE_KEY
environment variable is not set, to prevent runtime errors and improve the script's robustness, as done in previous files.
- configured_private_key = os.getenv("INJECTIVE_PRIVATE_KEY")
+ configured_private_key = os.getenv("INJECTIVE_PRIVATE_KEY", "")
+ if not configured_private_key:
+ raise ValueError("INJECTIVE_PRIVATE_KEY environment variable is not set.")
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.
dotenv.load_dotenv() | |
configured_private_key = os.getenv("INJECTIVE_PRIVATE_KEY") | |
dotenv.load_dotenv() | |
configured_private_key = os.getenv("INJECTIVE_PRIVATE_KEY", "") | |
if not configured_private_key: | |
raise ValueError("INJECTIVE_PRIVATE_KEY environment variable is not set.") |
if __name__ == "__main__": | ||
asyncio.get_event_loop().run_until_complete(main()) |
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.
Recommend updating the method for running the async main function to asyncio.run(main())
for Python 3.7 and newer, which simplifies the entry point and ensures proper event loop management.
- asyncio.get_event_loop().run_until_complete(main())
+ asyncio.run(main())
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.
if __name__ == "__main__": | |
asyncio.get_event_loop().run_until_complete(main()) | |
if __name__ == "__main__": | |
asyncio.run(main()) |
dotenv.load_dotenv() | ||
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.
Ensure that there's error handling for the case where the INJECTIVE_PRIVATE_KEY
environment variable might not be set. This is crucial for avoiding runtime errors and improving the script's robustness.
- 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 not set.")
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.
dotenv.load_dotenv() | |
private_key_in_hexa = os.getenv("INJECTIVE_PRIVATE_KEY") | |
dotenv.load_dotenv() | |
private_key_in_hexa = os.getenv("INJECTIVE_PRIVATE_KEY", "") | |
if not private_key_in_hexa: | |
raise ValueError("INJECTIVE_PRIVATE_KEY environment variable is not set.") |
dev
branch (v1.4.0) tomaster
Summary by CodeRabbit
.coderabbit.yaml
configuration.dotenv
in example scripts.ChainGrpcDistributionApi
andChainGrpcExchangeApi
for distribution and exchange operations.python-dotenv
dependency for environment variable management.