-
Notifications
You must be signed in to change notification settings - Fork 34
Feat/network refactoring from master to dev #320
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
Changes from all commits
601856e
6753d79
db9b6c0
d916599
5998b5e
7b4e0b2
c47c94e
105723b
79a4eb3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -2,14 +2,23 @@ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| All notable changes to this project will be documented in this file. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ## [1.5.0] - 9999-99-99 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ## [1.6.0] - 9999-99-99 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ### Added | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| - Added support for all queries in the chain 'tendermint' module | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| - Added support for all queries in the IBC Transfer module | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ### Changed | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| - Refactored cookies management logic to use all gRPC calls' responses to update the current cookies | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ## [1.5.0] - 2024-04-19 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ### Changed | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| - Refactoring in Network class to support mixed secure and insecure endpoints. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| - Marked the Network parameter `use_secure_connection` as deprecated. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ## [1.4.2] - 2024-03-19 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ### Changed | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| - Updated `aiohttp` dependency version to ">=3.9.2" to solve a security vulnerability detected by Dependabot | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+5
to
+21
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ensure consistency in list item markers. - * Synchronized markets and tokens config files to add KIRA/INJ, NINJA/INJ, KATANA/INJ, BRETT/INJ and nINJ/INJ spot markets
+ - Synchronized markets and tokens config files to add KIRA/INJ, NINJA/INJ, KATANA/INJ, BRETT/INJ and nINJ/INJ spot marketsThe use of asterisks (*) for list items is inconsistent with the use of dashes (-) in other parts of the document. Consider standardizing to dashes for all list items to maintain consistency. Committable suggestion
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ## [1.4.1] - 2024-03-12 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ### Changed | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| - Updates example scripts that were still using deprecated methods | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -95,7 +95,7 @@ def __init__( | |
| self, | ||
| network: Network, | ||
| insecure: Optional[bool] = None, | ||
| credentials=grpc.ssl_channel_credentials(), | ||
| credentials=None, | ||
| ): | ||
| # the `insecure` parameter is ignored and will be deprecated soon. The value is taken directly from `network` | ||
| if insecure is not None: | ||
|
|
@@ -104,6 +104,13 @@ def __init__( | |
| DeprecationWarning, | ||
| stacklevel=2, | ||
| ) | ||
| # the `credentials` parameter is ignored and will be deprecated soon. The value is taken directly from `network` | ||
| if credentials is not None: | ||
| warn( | ||
| "credentials parameter in AsyncClient is no longer used and will be deprecated", | ||
| DeprecationWarning, | ||
| stacklevel=2, | ||
| ) | ||
|
|
||
| self.addr = "" | ||
| self.number = 0 | ||
|
Comment on lines
104
to
116
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Tip Codebase Verification The output from the executed script reveals extensive usage of the However, the direct usage of the Given this information, it is clear that while the deprecation of the Conclusion:
Action Items:
Analysis chain
Deprecation of Ensure that all dependent code has been updated to use the new method of handling credentials through the Scripts ExecutedThe following scripts were executed for the analysis: Script: #!/bin/bash
# Search for any remaining direct uses of the `credentials` parameter in the codebase.
rg --type py 'credentials='
Length of output: 125138 |
||
|
|
@@ -112,11 +119,7 @@ def __init__( | |
| self.network = network | ||
|
|
||
| # chain stubs | ||
| self.chain_channel = ( | ||
| grpc.aio.secure_channel(network.grpc_endpoint, credentials) | ||
| if (network.use_secure_connection and credentials is not None) | ||
| else grpc.aio.insecure_channel(network.grpc_endpoint) | ||
| ) | ||
| self.chain_channel = self.network.create_chain_grpc_channel() | ||
|
|
||
| self.stubCosmosTendermint = tendermint_query_grpc.ServiceStub(self.chain_channel) | ||
| self.stubAuth = auth_query_grpc.QueryStub(self.chain_channel) | ||
|
|
@@ -128,11 +131,7 @@ def __init__( | |
| self.timeout_height = 1 | ||
|
|
||
| # exchange stubs | ||
| self.exchange_channel = ( | ||
| grpc.aio.secure_channel(network.grpc_exchange_endpoint, credentials) | ||
| if (network.use_secure_connection and credentials is not None) | ||
| else grpc.aio.insecure_channel(network.grpc_exchange_endpoint) | ||
| ) | ||
| self.exchange_channel = self.network.create_exchange_grpc_channel() | ||
| self.stubMeta = exchange_meta_rpc_grpc.InjectiveMetaRPCStub(self.exchange_channel) | ||
| self.stubExchangeAccount = exchange_accounts_rpc_grpc.InjectiveAccountsRPCStub(self.exchange_channel) | ||
| self.stubOracle = oracle_rpc_grpc.InjectiveOracleRPCStub(self.exchange_channel) | ||
|
|
@@ -145,18 +144,10 @@ def __init__( | |
| self.stubPortfolio = portfolio_rpc_grpc.InjectivePortfolioRPCStub(self.exchange_channel) | ||
|
|
||
| # explorer stubs | ||
| self.explorer_channel = ( | ||
| grpc.aio.secure_channel(network.grpc_explorer_endpoint, credentials) | ||
| if (network.use_secure_connection and credentials is not None) | ||
| else grpc.aio.insecure_channel(network.grpc_explorer_endpoint) | ||
| ) | ||
| self.explorer_channel = self.network.create_explorer_grpc_channel() | ||
| self.stubExplorer = explorer_rpc_grpc.InjectiveExplorerRPCStub(self.explorer_channel) | ||
|
|
||
| self.chain_stream_channel = ( | ||
| grpc.aio.secure_channel(network.chain_stream_endpoint, credentials) | ||
| if (network.use_secure_connection and credentials is not None) | ||
| else grpc.aio.insecure_channel(network.chain_stream_endpoint) | ||
| ) | ||
| self.chain_stream_channel = self.network.create_chain_stream_grpc_channel() | ||
| self.chain_stream_stub = stream_rpc_grpc.StreamStub(channel=self.chain_stream_channel) | ||
|
|
||
| self._timeout_height_sync_task = None | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,6 @@ | ||
| [tool.poetry] | ||
| name = "injective-py" | ||
| version = "1.5.0-pre" | ||
| version = "1.6.0-pre" | ||
| description = "Injective Python SDK, with Exchange API Client" | ||
| authors = ["Injective Labs <[email protected]>"] | ||
| license = "Apache-2.0" | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| from warnings import catch_warnings | ||
|
|
||
| from pyinjective.core.network import DisabledCookieAssistant, Network | ||
|
|
||
|
|
||
| class TestNetworkDeprecationWarnings: | ||
| def test_use_secure_connection_parameter_deprecation_warning(self): | ||
| with catch_warnings(record=True) as all_warnings: | ||
| Network( | ||
| lcd_endpoint="lcd_endpoint", | ||
| tm_websocket_endpoint="tm_websocket_endpoint", | ||
| grpc_endpoint="grpc_endpoint", | ||
| grpc_exchange_endpoint="grpc_exchange_endpoint", | ||
| grpc_explorer_endpoint="grpc_explorer_endpoint", | ||
| chain_stream_endpoint="chain_stream_endpoint", | ||
| chain_id="chain_id", | ||
| fee_denom="fee_denom", | ||
| env="env", | ||
| chain_cookie_assistant=DisabledCookieAssistant(), | ||
| exchange_cookie_assistant=DisabledCookieAssistant(), | ||
| explorer_cookie_assistant=DisabledCookieAssistant(), | ||
| use_secure_connection=True, | ||
| ) | ||
|
|
||
| deprecation_warnings = [warning for warning in all_warnings if issubclass(warning.category, DeprecationWarning)] | ||
| assert len(deprecation_warnings) == 1 | ||
| assert ( | ||
| str(deprecation_warnings[0].message) | ||
| == "use_secure_connection parameter in Network is no longer used and will be deprecated" | ||
| ) | ||
|
|
||
| def test_use_secure_connection_parameter_in_custom_network_deprecation_warning(self): | ||
| with catch_warnings(record=True) as all_warnings: | ||
| Network.custom( | ||
| lcd_endpoint="lcd_endpoint", | ||
| tm_websocket_endpoint="tm_websocket_endpoint", | ||
| grpc_endpoint="grpc_endpoint", | ||
| grpc_exchange_endpoint="grpc_exchange_endpoint", | ||
| grpc_explorer_endpoint="grpc_explorer_endpoint", | ||
| chain_stream_endpoint="chain_stream_endpoint", | ||
| chain_id="chain_id", | ||
| env="env", | ||
| chain_cookie_assistant=DisabledCookieAssistant(), | ||
| exchange_cookie_assistant=DisabledCookieAssistant(), | ||
| explorer_cookie_assistant=DisabledCookieAssistant(), | ||
| use_secure_connection=True, | ||
| ) | ||
|
|
||
| deprecation_warnings = [warning for warning in all_warnings if issubclass(warning.category, DeprecationWarning)] | ||
| assert len(deprecation_warnings) == 1 | ||
| assert ( | ||
| str(deprecation_warnings[0].message) | ||
| == "use_secure_connection parameter in Network is no longer used and will be deprecated" | ||
| ) |
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.
Add surrounding blank lines for headings.
Headings should be surrounded by blank lines to enhance the readability and structure of the document.
Committable suggestion