diff --git a/CHANGELOG.md b/CHANGELOG.md index 60850260..b43f205c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +# 0.22.10 + +- Move Ankr specific functionality to its own `eth_defi.provider.ankr` module + that will see more changes in the future + # 0.22.9 - Add `eth_defi.rpc.broken_provider` for workaround for the quirks and features of different JSON-RPC providers diff --git a/docs/source/api/provider/index.rst b/docs/source/api/provider/index.rst index 5438b7c6..e2ecfd45 100644 --- a/docs/source/api/provider/index.rst +++ b/docs/source/api/provider/index.rst @@ -19,6 +19,8 @@ This submodule offers functionality to connect and enhance robustness of various eth_defi.provider.multi_provider eth_defi.provider.mev_blocker eth_defi.provider.fallback + eth_defi.provider.broken_provider + eth_defi.provider.ankr eth_defi.provider.anvil eth_defi.provider.ganache eth_defi.provider.named diff --git a/eth_defi/provider/ankr.py b/eth_defi/provider/ankr.py new file mode 100644 index 00000000..9825f096 --- /dev/null +++ b/eth_defi/provider/ankr.py @@ -0,0 +1,19 @@ +"""Ankr specific Web3.py functionality. + +- Ankr has issues with some JSON-RPC access patterns. + See also :py:mod:`eth_defi.rpc.broken_provider`. + +""" +from web3 import Web3 + +from eth_defi.provider.named import get_provider_name + + +def is_ankr(web3: Web3) -> bool: + """Are we connected to Ankr as a provider. + + We use this function to detect and activate Ankr workarounds + for their bugs and features. + """ + name = get_provider_name(web3.provider) + return name == "rpc.ankr.com" diff --git a/eth_defi/provider/broken_provider.py b/eth_defi/provider/broken_provider.py index 22a9ad22..faad7b2c 100644 --- a/eth_defi/provider/broken_provider.py +++ b/eth_defi/provider/broken_provider.py @@ -1,16 +1,12 @@ """Fixes for Ankr and other broken JSON-RPC service providers. - Mainly to deal with unstable blockchain chain tip -""" - -from eth_defi.provider.named import get_provider_name -from web3 import Web3 +- See also :py:mod:`eth_defi.provider.ankr` -def is_ankr(web3: Web3) -> bool: - """Are we connected to Ankr as a provider.""" - name = get_provider_name(web3.provider) - return name == "rpc.ankr.com" +""" +from eth_defi.provider.ankr import is_ankr +from web3 import Web3 def get_default_block_tip_latency(web3: Web3) -> int: