diff --git a/README.md b/README.md index 25fac6e..769893d 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Many Abis -![Version](https://img.shields.io/badge/many--abis-v0.1.4-green) +![Version](https://img.shields.io/badge/many--abis-v0.1.4.1-green) ![Pypi](https://img.shields.io/pypi/dm/many-abis) ![GitHub Org's stars](https://img.shields.io/github/stars/ackness/many_abis?style=social) diff --git a/examples/example1.py b/examples/example1.py index 5bb2bbb..83e4c86 100644 --- a/examples/example1.py +++ b/examples/example1.py @@ -45,3 +45,6 @@ # print all support dex ma.print_all_dex() + +bsc = ma.from_id(chain_id=56) +print(bsc) \ No newline at end of file diff --git a/many_abis/chains/__init__.py b/many_abis/chains/__init__.py index 12cbb34..24e6c71 100644 --- a/many_abis/chains/__init__.py +++ b/many_abis/chains/__init__.py @@ -16,8 +16,14 @@ SUPPORT_CHAIN = ['BSC', 'ETH', 'AVAX', 'FANTOM', 'POLYGON', 'CRONOS', 'HECO', 'KCC', 'OKEX', 'MOONRIVER', 'ARBITRUM', 'BSC_TEST'] __all__ = ['SUPPORT_CHAIN', 'BSC', 'ETH', 'AVAX', 'FANTOM', 'CRONOS', - 'POLYGON', 'HECO', 'KCC', 'OKEX', 'MOONRIVER', 'BSC_TEST', 'ARBITRUM', 'CHAINS'] + 'POLYGON', 'HECO', 'KCC', 'OKEX', 'MOONRIVER', 'BSC_TEST', 'ARBITRUM', 'CHAINS', 'from_id'] CHAINS = AttributeDict( **{name: eval(name) for name in SUPPORT_CHAIN} ) + +def from_id(chain_id: int): + return next( + (chain[1] for chain in CHAINS.items() if chain[1].chain_id == chain_id), + None, + ) diff --git a/many_abis/chains/_assets.py b/many_abis/chains/_assets.py index 9f54f8c..ba272f3 100644 --- a/many_abis/chains/_assets.py +++ b/many_abis/chains/_assets.py @@ -3,7 +3,7 @@ __all__ = [ 'UNISWAP_V2_ROUTER_ABI', 'UNISWAP_V2_FACTORY_ABI', 'UNISWAP_V2_PAIR_ABI', 'UNISWAP_V3_ROUTER_ABI', 'UNISWAP_V3_FACTORY_ABI', 'UNISWAP_V3_POOL_ABI', - 'UNISWAP_V3_QUOTER_ABI', 'UNISWAP_V3_NFT_POSITION_MANAGER_ABI', 'UNISWAP_V3_NFT_POSITION_ABI', + 'UNISWAP_V3_QUOTER_ABI', 'UNISWAP_V3_NON_FUNGIBLE_POSITION_MANAGER_ABI', 'UNISWAP_V3_MULTICALL_ABI', 'WETH_ABI', 'STANDARD_ERC20_TOKEN_ABI', 'STANDARD_ERC721_TOKEN_ABI', 'STANDARD_ERC777_TOKEN_ABI', 'STANDARD_ERC1155_TOKEN_ABI', 'AVAX_JOE_ROUTER_ABI', 'AVAX_JOE_FACTORY_ABI', 'AVAX_JOE_PAIR_ABI' diff --git a/many_abis/chains/_base.py b/many_abis/chains/_base.py index 182150d..a93050e 100644 --- a/many_abis/chains/_base.py +++ b/many_abis/chains/_base.py @@ -100,4 +100,4 @@ def __init__( ) def __repr__(self): - return f'Chain Name: {self.name}, Explorer: {self.explorer}, DEX: {self.dex.keys()}' + return f'Chain Name: {self.name}, ID: {self.chain_id}, Explorer: {self.explorer}, DEX: {self.dex.keys()}' diff --git a/setup.py b/setup.py index 76560ee..b80c86f 100644 --- a/setup.py +++ b/setup.py @@ -6,7 +6,7 @@ setup( name='many_abis', packages=find_packages(), - version='0.1.4', + version='0.1.4.1', license='MIT', description='A simple way to get different DEXs abis for block chains.', long_description=long_description,