diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 0000000..bb12031 --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1,12 @@ +# These are supported funding model platforms + +github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] +patreon: # Replace with a single Patreon username +open_collective: # Replace with a single Open Collective username +ko_fi: # Replace with a single Ko-fi username +tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel +community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry +liberapay: # Replace with a single Liberapay username +issuehunt: # Replace with a single IssueHunt username +otechie: # Replace with a single Otechie username +custom: ['0xD9D6E8C16686536E3C81124639e975AdF2468197'] diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..3bb4e73 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,32 @@ +name: build + +on: [push] + +jobs: + build: + + runs-on: ubuntu-latest + strategy: + matrix: + python-version: [3.8] + + steps: + - uses: actions/checkout@v2 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install git+https://github.com/pcko1/etherscan-python.git coverage flake8 + - name: Lint with flake8 + run: | + # stop the build if there are Python syntax errors or undefined names + flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics + # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide + flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics + - name: Test with unittest + run: | + bash run_tests.sh ${{ secrets.ETHERSCAN_API_KEY }} + bash <(curl -s https://codecov.io/bash) \ No newline at end of file diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index e17a763..0000000 --- a/.travis.yml +++ /dev/null @@ -1,20 +0,0 @@ -language: python -python: -- '3.8' -before_install: -- wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh -- bash miniconda.sh -b -p $HOME/miniconda -- source "$HOME/miniconda/etc/profile.d/conda.sh" -- export PATH=/home/travis/miniconda/bin:$PATH -- conda update -q conda -y -- conda info -a -install: -- conda env create -f env.yml -- conda activate etherscan-python -- pip install . -script: -- coverage run -m unittest discover && coverage report -m -- bash <(curl -s https://codecov.io/bash) -env: - global: - - secure: ozKF63ysgAWWsr5R47T/B+u94L6pq89onaSfmqnmzmup8gS6WVnAE5yviuM3y9Il3BihXbxw5VUBx5lIwLg6MV4fCubxcNH+4qVjxGe1kxsjoT4wW8luJkkWGbvT+afGWaWU8AGWLTgqjYZrfkgTPxmNC/ulwoAHJra297ZvoGZEAcAZ/Y2vQ4u9JP2H3C3AJMhIdH/fuPf7DwKCvU4ufAhszJNbosSsaAxSndrecgHeQCxz+4RhX+a8XqIMTjys+DahSc4b5NRc/xJ/D1KMoNgtzj0yKldkcXhL1ykKW7S541ATKOrZLUqL924tlNdtm/IOvQ1Xy8xoR47rg+xAanj5SjiW0dsI+BIw94D4mIKVpKSB4wa3/ZxRKyw5fG5NUEFT/kdqp9vVz3n+x8nSNxV9x7yS0N/2fyACT2j+75aQhXvXI55WTleX9znsLRXFuTb0g0p7s3G/Bk+GS1gfJGdp/mRzdF80A0aMI5L+CY9e2G8VerQt93Is9w7+Ny3+XA4kSt+s0w/TzUSvv9y/BobSC2ZBiLltEaLups9VW5lCaWSgQLCr42rtHgMrduwzyagDGUlKUp5F8+Q1dMn0IpHEsjzwAl5SNuw8EoT9amBbWcR4d/Q+eqQ0JiHTbR2pwNs8bjYjIq4cXlze2BgYOZGStB1oMlfH9XSA7SrH7ns= diff --git a/MANIFEST.in b/MANIFEST.in new file mode 100644 index 0000000..952e599 --- /dev/null +++ b/MANIFEST.in @@ -0,0 +1,5 @@ +include etherscan/configs/MAIN-stable.json +include etherscan/configs/GOERLI-stable.json +include etherscan/configs/KOVAN-stable.json +include etherscan/configs/RINKEBY-stable.json +include etherscan/configs/ROPSTEN-stable.json diff --git a/README.md b/README.md index edd4118..3a415f6 100644 --- a/README.md +++ b/README.md @@ -1,16 +1,26 @@ # etherscan-python -[![Build Status](https://travis-ci.com/pcko1/etherscan-python.svg?branch=master)](https://travis-ci.com/pcko1/etherscan-python) +[![Build Status](https://github.com/pcko1/etherscan-python/workflows/build/badge.svg)](https://github.com/pcko1/etherscan-python) [![codecov](https://codecov.io/gh/pcko1/etherscan-python/branch/master/graph/badge.svg)](https://codecov.io/gh/pcko1/etherscan-python) -[![Python 3.8](https://img.shields.io/badge/python-3.8-blue.svg)](https://www.python.org/downloads/release/python-385/) +[![Codacy Badge](https://api.codacy.com/project/badge/Grade/6db2e36886ee46f58720c6131ef58dd6)](https://app.codacy.com/gh/pcko1/etherscan-python?utm_source=github.com&utm_medium=referral&utm_content=pcko1/etherscan-python&utm_campaign=Badge_Grade) +[![](https://img.shields.io/codeclimate/tech-debt/pcko1/etherscan-python)](https://codeclimate.com/github/pcko1/etherscan-python) +[![Maintainability](https://api.codeclimate.com/v1/badges/94c15c6d8b1ec869a7fd/maintainability)](https://codeclimate.com/github/pcko1/etherscan-python/maintainability) +[![CodeFactor](https://www.codefactor.io/repository/github/pcko1/etherscan-python/badge)](https://www.codefactor.io/repository/github/pcko1/etherscan-python) + +[![PyPI](https://badge.fury.io/py/etherscan-python.svg)](https://badge.fury.io/py/etherscan-python) +![PyPI - Downloads](https://img.shields.io/pypi/dm/etherscan-python) ![GitHub](https://img.shields.io/github/license/pcko1/etherscan-python) +[![Python 3.8](https://img.shields.io/badge/python-3.8-blue.svg)](https://www.python.org/downloads/release/python-385/) [![DOI](https://zenodo.org/badge/298646404.svg)](https://zenodo.org/badge/latestdoi/298646404) -A minimal, yet complete, python API for [Etherscan.io](https://etherscan.io/). Available on [PyPI](https://pypi.org/project/etherscan-python/). -All FREE and PRO endpoints are provided. +A minimal, yet complete, Python API for [Etherscan.io](https://etherscan.io/). + +All standard and pro endpoints are provided. Kovan, Rinkeby and Ropsten testnets are also supported. + +Available on [PyPI](https://pypi.org/project/etherscan-python/). Powered by [Etherscan.io APIs](https://etherscan.io/apis#misc). + -Powered by [Etherscan.io APIs](https://etherscan.io/apis). ___ @@ -145,25 +155,13 @@ Before proceeding, you should register an account on [Etherscan.io](https://ethe If you wish to have access to the PRO endpoints, you should obtain elevated privileges via Etherscan's subscription service. -Assuming [conda](https://docs.conda.io/en/latest/miniconda.html) is already installed on your system, first create the environment: - -``` bash -conda env create -f env.yml -``` - -Activate the environment: +Install from source: ``` bash -conda activate etherscan-python +pip install git+https://github.com/pcko1/etherscan-python.git ``` -Then, install the package: - -``` bash -pip install . -``` - -Alternatively, you can install it from [PyPI](https://pypi.org/project/etherscan-python/): +Alternatively, install from [PyPI](https://pypi.org/project/etherscan-python/): ```bash pip install etherscan-python @@ -179,17 +177,15 @@ bash run_tests.sh YOUR_API_KEY This will regenerate the logs under `logs/` with the most recent results and the timestamp of the execution. +The tests also include the PRO endpoints so if your key is not PRO, the correspondings tests are expected to fail. + ## Usage In `python`, create a client with your personal [Etherscan.io](https://etherscan.io/) API key: ``` python from etherscan import Etherscan - -api_key = YOUR_API_KEY # use quotation marks because it is a Python string -config_path = "configs/stable.json" - -eth = Etherscan.from_config(config_path, api_key) +eth = Etherscan(YOUR_API_KEY) # key in quotation marks ``` Then you can call all available methods, e.g.: @@ -199,6 +195,10 @@ eth.get_eth_balance(address="0xddbd2b932c763ba5b1b7ae3b362eac3e8d40121a") > '40891631566070000000000' ``` +You can also choose one of the other testnets: +``` python +eth = Etherscan(YOUR_API_KEY, net="ropsten") # net name is case-insensitive, default is main +``` ## Examples @@ -233,19 +233,18 @@ For problems regarding installing or using the package please open an [issue](ht ## Cite -Kotsias, P. C., A Python API for Etherscan.io. *https://github.com/pcko1/etherscan-python (2020)*. doi:10.5281/zenodo.4088586 +Kotsias, P. C., pcko1/etherscan-python. *https://github.com/pcko1/etherscan-python (2020)*. doi:10.5281/zenodo.4306855 or in ```bibtex```: ```bibtex @misc{Kotsias2020, author = {Kotsias, P.C.}, - title = {A Python API for Etherscan.io}, + title = {pcko1/etherscan-python}, year = {2020}, - publisher = {GitHub}, - journal = {GitHub repository}, + publisher = {Zenodo}, url = {https://github.com/pcko1/etherscan-python}, - doi = {10.5281/zenodo.4088586} + doi = {10.5281/zenodo.4306855} } ``` diff --git a/build/lib/etherscan/__init__.py b/build/lib/etherscan/__init__.py deleted file mode 100644 index d73dff9..0000000 --- a/build/lib/etherscan/__init__.py +++ /dev/null @@ -1,9 +0,0 @@ -from .modules.accounts import Accounts as accounts -from .modules.blocks import Blocks as blocks -from .modules.contracts import Contracts as contracts -from .modules.gastracker import GasTracker as gastracker -from .modules.proxy import Proxy as proxy -from .modules.stats import Stats as stats -from .modules.tokens import Tokens as tokens -from .modules.transactions import Transactions as transactions -from .etherscan import Etherscan diff --git a/build/lib/etherscan/enums/__init__.py b/build/lib/etherscan/enums/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/build/lib/etherscan/enums/actions_enum.py b/build/lib/etherscan/enums/actions_enum.py deleted file mode 100644 index 2ca5d53..0000000 --- a/build/lib/etherscan/enums/actions_enum.py +++ /dev/null @@ -1,41 +0,0 @@ -from dataclasses import dataclass - - -@dataclass(frozen=True) -class ActionsEnum: - BALANCE_HISTORY: str = "balancehistory" - BALANCE_MULTI: str = "balancemulti" - BALANCE: str = "balance" - CHAIN_SIZE: str = "chainsize" - ETH_BLOCK_NUMBER: str = "eth_blockNumber" - ETH_CALL: str = "eth_call" - ETH_ESTIMATE_GAS: str = "eth_estimateGas" - ETH_GAS_PRICE: str = "eth_gasPrice" - ETH_GET_BLOCK_BY_NUMBER: str = "eth_getBlockByNumber" - ETH_GET_BLOCK_TRANSACTION_COUNT_BY_NUMBER: str = "eth_getBlockTransactionCountByNumber" - ETH_GET_TRANSACTION_BY_BLOCK_NUMBER_AND_INDEX: str = "eth_getTransactionByBlockNumberAndIndex" - ETH_GET_CODE: str = "eth_getCode" - ETH_GET_STORAGE_AT: str = "eth_getStorageAt" - ETH_GET_TRANSACTION_BY_HASH: str = "eth_getTransactionByHash" - ETH_GET_TRANSACTION_COUNT: str = "eth_getTransactionCount" - ETH_GET_TRANSACTION_RECEIPT: str = "eth_getTransactionReceipt" - ETH_GET_UNCLE_BY_BLOCK_NUMBER_AND_INDEX: str = "eth_getUncleByBlockNumberAndIndex" - ETH_PRICE: str = "ethprice" - ETH_SUPPLY: str = "ethsupply" - GAS_ESTIMATE: str = "gasestimate" - GAS_ORACLE: str = "gasoracle" - GET_ABI: str = "getabi" - GET_BLOCK_COUNTDOWN: str = "getblockcountdown" - GET_BLOCK_NUMBER_BY_TIME: str = "getblocknobytime" - GET_BLOCK_REWARD: str = "getblockreward" - GET_MINED_BLOCKS: str = "getminedblocks" - GET_SOURCE_CODE: str = "getsourcecode" - GET_STATUS: str = "getstatus" - GET_TX_RECEIPT_STATUS: str = "gettxreceiptstatus" - TOKEN_BALANCE: str = "tokenbalance" - TOKEN_SUPPLY: str = "tokensupply" - TOKENNFTTX: str = "tokennfttx" - TOKENTX: str = "tokentx" - TXLIST_INTERNAL: str = "txlistinternal" - TXLIST: str = "txlist" - diff --git a/build/lib/etherscan/enums/fields_enum.py b/build/lib/etherscan/enums/fields_enum.py deleted file mode 100644 index a85fb77..0000000 --- a/build/lib/etherscan/enums/fields_enum.py +++ /dev/null @@ -1,35 +0,0 @@ -from dataclasses import dataclass - - -@dataclass(frozen=True) -class FieldsEnum: - ACTION: str = "&action=" - ADDRESS: str = "&address=" - API_KEY: str = "&apikey=" - BLOCK_TYPE: str = "&blocktype=" - BLOCKNO: str = "&blockno=" - BOOLEAN: str = "&boolean=" - CLIENT_TYPE: str = "&clienttype=" - CLOSEST: str = "&closest=" - CONTRACT_ADDRESS: str = "&contractaddress=" - DATA: str = "&data=" - END_BLOCK: str = "&endblock=" - END_DATE: str = "&enddate=" - GAS_PRICE: str = "&gasPrice=" - GAS: str = "&gas=" - HEX: str = "&hex=" - INDEX: str = "&index=" - MODULE: str = "module=" - OFFSET: str = "&offset=" - PAGE: str = "&page=" - POSITION: str = "&position=" - PREFIX: str = "https://api.etherscan.io/api?" - SORT: str = "&sort=" - START_BLOCK: str = "&startblock=" - START_DATE: str = "&startdate=" - SYNC_MODE: str = "&syncmode=" - TAG: str = "&tag=" - TIMESTAMP: str = "×tamp=" - TO: str = "&to=" - TXHASH: str = "&txhash=" - VALUE: str = "&value=" diff --git a/build/lib/etherscan/enums/modules_enum.py b/build/lib/etherscan/enums/modules_enum.py deleted file mode 100644 index e02e11c..0000000 --- a/build/lib/etherscan/enums/modules_enum.py +++ /dev/null @@ -1,14 +0,0 @@ -from dataclasses import dataclass - - -@dataclass(frozen=True) -class ModulesEnum: - ACCOUNT: str = "account" - BLOCK: str = "block" - CONTRACT: str = "contract" - GASTRACKER: str = "gastracker" - PROXY: str = "proxy" - STATS: str = "stats" - TOKEN: str = "token" - TRANSACTION: str = "transaction" - diff --git a/build/lib/etherscan/enums/tags_enum.py b/build/lib/etherscan/enums/tags_enum.py deleted file mode 100644 index 03520fb..0000000 --- a/build/lib/etherscan/enums/tags_enum.py +++ /dev/null @@ -1,7 +0,0 @@ -from dataclasses import dataclass - - -@dataclass(frozen=True) -class TagsEnum: - ACCOUNT: str = "account" - LATEST: str = "latest" diff --git a/build/lib/etherscan/etherscan.py b/build/lib/etherscan/etherscan.py deleted file mode 100644 index 0b8b8f6..0000000 --- a/build/lib/etherscan/etherscan.py +++ /dev/null @@ -1,37 +0,0 @@ -import json - -import requests - -import etherscan -from etherscan.enums.fields_enum import FieldsEnum as fields -from etherscan.utils.parsing import ResponseParser as parser - - -class Etherscan: - @staticmethod - def __load_config(config_path: str) -> dict: - with open(config_path, "r") as f: - return json.load(f) - - @staticmethod - def __run(func, api_key): - def wrapper(*args, **kwargs): - url = ( - f"{fields.PREFIX}" - f"{func(*args, **kwargs)}" - f"{fields.API_KEY}" - f"{api_key}" - ) - r = requests.get(url) - return parser.parse(r) - - return wrapper - - @classmethod - def from_config(cls, config_path: str, api_key: str): - config = cls.__load_config(config_path) - for func, v in config.items(): - if not func.startswith("_"): # disabled if _ - attr = getattr(getattr(etherscan, v["module"]), func) - setattr(cls, func, cls.__run(attr, api_key)) - return cls diff --git a/build/lib/etherscan/modules/__init__.py b/build/lib/etherscan/modules/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/build/lib/etherscan/modules/accounts.py b/build/lib/etherscan/modules/accounts.py deleted file mode 100644 index 831b90d..0000000 --- a/build/lib/etherscan/modules/accounts.py +++ /dev/null @@ -1,330 +0,0 @@ -from functools import reduce -from typing import List - -from etherscan.enums.actions_enum import ActionsEnum as actions -from etherscan.enums.fields_enum import FieldsEnum as fields -from etherscan.enums.modules_enum import ModulesEnum as modules -from etherscan.enums.tags_enum import TagsEnum as tags - - -class Accounts: - @staticmethod - def get_eth_balance(address: str) -> str: - url = ( - f"{fields.MODULE}" - f"{modules.ACCOUNT}" - f"{fields.ACTION}" - f"{actions.BALANCE}" - f"{fields.ADDRESS}" - f"{address}" - f"{fields.TAG}" - f"{tags.LATEST}" - ) - return url - # r = requests.get(url) - # return conversions.to_ticker_unit(parser.get_result(r)) - - @staticmethod - def get_eth_balance_multiple(addresses: List[str]) -> str: - # NOTE: Max 20 wallets at a time - address_list = reduce(lambda w1, w2: str(w1) + "," + str(w2), addresses) - url = ( - f"{fields.MODULE}" - f"{modules.ACCOUNT}" - f"{fields.ACTION}" - f"{actions.BALANCE_MULTI}" - f"{fields.ADDRESS}" - f"{address_list}" - f"{fields.TAG}" - f"{tags.LATEST}" - ) - return url - # r = requests.get(url) - # return [conversions.to_ticker_unit(r["balance"]) for r in parser.get_result(r)] - - @staticmethod - def get_normal_txs_by_address( - address: str, startblock: int, endblock: int, sort: str, - ) -> str: - # NOTE: Returns the last 10k events - url = ( - f"{fields.MODULE}" - f"{modules.ACCOUNT}" - f"{fields.ACTION}" - f"{actions.TXLIST}" - f"{fields.ADDRESS}" - f"{address}" - f"{fields.START_BLOCK}" - f"{str(startblock)}" - f"{fields.END_BLOCK}" - f"{str(endblock)}" - f"{fields.SORT}" - f"{sort}" - ) - return url - - @staticmethod - def get_normal_txs_by_address_paginated( - address: str, page: int, offset: int, startblock: int, endblock: int, sort: str, - ) -> str: - url = ( - f"{fields.MODULE}" - f"{modules.ACCOUNT}" - f"{fields.ACTION}" - f"{actions.TXLIST}" - f"{fields.ADDRESS}" - f"{address}" - f"{fields.START_BLOCK}" - f"{str(startblock)}" - f"{fields.END_BLOCK}" - f"{str(endblock)}" - f"{fields.SORT}" - f"{sort}" - f"{fields.PAGE}" - f"{str(page)}" - f"{fields.OFFSET}" - f"{str(offset)}" - ) - return url - - @staticmethod - def get_internal_txs_by_address( - address: str, startblock: int, endblock: int, sort: str, - ) -> str: - # NOTE: Returns the last 10k events - url = ( - f"{fields.MODULE}" - f"{modules.ACCOUNT}" - f"{fields.ACTION}" - f"{actions.TXLIST_INTERNAL}" - f"{fields.ADDRESS}" - f"{address}" - f"{fields.START_BLOCK}" - f"{str(startblock)}" - f"{fields.END_BLOCK}" - f"{str(endblock)}" - f"{fields.SORT}" - f"{sort}" - ) - return url - - @staticmethod - def get_internal_txs_by_address_paginated( - address: str, page: int, offset: int, startblock: int, endblock: int, sort: str, - ) -> str: - url = ( - f"{fields.MODULE}" - f"{modules.ACCOUNT}" - f"{fields.ACTION}" - f"{actions.TXLIST_INTERNAL}" - f"{fields.ADDRESS}" - f"{address}" - f"{fields.START_BLOCK}" - f"{str(startblock)}" - f"{fields.END_BLOCK}" - f"{str(endblock)}" - f"{fields.SORT}" - f"{sort}" - f"{fields.PAGE}" - f"{str(page)}" - f"{fields.OFFSET}" - f"{str(offset)}" - ) - return url - - @staticmethod - def get_internal_txs_by_txhash(txhash: str) -> str: - # NOTE: Returns the last 10k events - url = ( - f"{fields.MODULE}" - f"{modules.ACCOUNT}" - f"{fields.ACTION}" - f"{actions.TXLIST_INTERNAL}" - f"{fields.TXHASH}" - f"{txhash}" - ) - return url - - @staticmethod - def get_internal_txs_by_block_range_paginated( - startblock: int, endblock: int, page: int, offset: int, sort: str, - ) -> str: - # NOTE: Returns the last 10k events - url = ( - f"{fields.MODULE}" - f"{modules.ACCOUNT}" - f"{fields.ACTION}" - f"{actions.TXLIST_INTERNAL}" - f"{fields.START_BLOCK}" - f"{str(startblock)}" - f"{fields.END_BLOCK}" - f"{str(endblock)}" - f"{fields.SORT}" - f"{sort}" - f"{fields.PAGE}" - f"{str(page)}" - f"{fields.OFFSET}" - f"{str(offset)}" - ) - return url - - @staticmethod - def get_erc20_token_transfer_events_by_address( - address: str, startblock: int, endblock: int, sort: str, - ) -> str: - # NOTE: Returns the last 10k events - url = ( - f"{fields.MODULE}" - f"{modules.ACCOUNT}" - f"{fields.ACTION}" - f"{actions.TOKENTX}" - f"{fields.ADDRESS}" - f"{address}" - f"{fields.START_BLOCK}" - f"{str(startblock)}" - f"{fields.END_BLOCK}" - f"{str(endblock)}" - f"{fields.SORT}" - f"{sort}" - ) - return url - - @staticmethod - def get_erc20_token_transfer_events_by_contract_address_paginated( - contract_address: str, page: int, offset: int, sort: str - ) -> str: - - url = ( - f"{fields.MODULE}" - f"{modules.ACCOUNT}" - f"{fields.ACTION}" - f"{actions.TOKENTX}" - f"{fields.CONTRACT_ADDRESS}" - f"{contract_address}" - f"{fields.SORT}" - f"{sort}" - f"{fields.PAGE}" - f"{str(page)}" - f"{fields.OFFSET}" - f"{str(offset)}" - ) - return url - - @staticmethod - def get_erc20_token_transfer_events_by_address_and_contract_paginated( - contract_address: str, address: str, page: int, offset: int, sort: str - ) -> str: - - url = ( - f"{fields.MODULE}" - f"{modules.ACCOUNT}" - f"{fields.ACTION}" - f"{actions.TOKENTX}" - f"{fields.CONTRACT_ADDRESS}" - f"{contract_address}" - f"{fields.ADDRESS}" - f"{address}" - f"{fields.SORT}" - f"{sort}" - f"{fields.PAGE}" - f"{str(page)}" - f"{fields.OFFSET}" - f"{str(offset)}" - ) - return url - - @staticmethod - def get_erc721_token_transfer_events_by_address( - address: str, startblock: int, endblock: int, sort: str, - ) -> str: - url = ( - f"{fields.MODULE}" - f"{modules.ACCOUNT}" - f"{fields.ACTION}" - f"{actions.TOKENNFTTX}" - f"{fields.ADDRESS}" - f"{address}" - f"{fields.START_BLOCK}" - f"{str(startblock)}" - f"{fields.END_BLOCK}" - f"{str(endblock)}" - f"{fields.SORT}" - f"{sort}" - ) - return url - - @staticmethod - def get_erc721_token_transfer_events_by_contract_address_paginated( - contract_address: str, page: int, offset: int, sort: str - ) -> str: - url = ( - f"{fields.MODULE}" - f"{modules.ACCOUNT}" - f"{fields.ACTION}" - f"{actions.TOKENNFTTX}" - f"{fields.CONTRACT_ADDRESS}" - f"{contract_address}" - f"{fields.SORT}" - f"{sort}" - f"{fields.PAGE}" - f"{str(page)}" - f"{fields.OFFSET}" - f"{str(offset)}" - ) - return url - - @staticmethod - def get_erc721_token_transfer_events_by_address_and_contract_paginated( - contract_address: str, address: str, page: int, offset: int, sort: str - ) -> str: - url = ( - f"{fields.MODULE}" - f"{modules.ACCOUNT}" - f"{fields.ACTION}" - f"{actions.TOKENNFTTX}" - f"{fields.CONTRACT_ADDRESS}" - f"{contract_address}" - f"{fields.ADDRESS}" - f"{address}" - f"{fields.SORT}" - f"{sort}" - f"{fields.PAGE}" - f"{str(page)}" - f"{fields.OFFSET}" - f"{str(offset)}" - ) - return url - - @staticmethod - def get_mined_blocks_by_address(address: str) -> str: - url = ( - f"{fields.MODULE}" - f"{modules.ACCOUNT}" - f"{fields.ACTION}" - f"{actions.GET_MINED_BLOCKS}" - f"{fields.ADDRESS}" - f"{address}" - f"{fields.BLOCK_TYPE}" - f"blocks" - ) - return url - - @staticmethod - def get_mined_blocks_by_address_paginated( - address: str, page: int, offset: int - ) -> str: - url = ( - f"{fields.MODULE}" - f"{modules.ACCOUNT}" - f"{fields.ACTION}" - f"{actions.GET_MINED_BLOCKS}" - f"{fields.ADDRESS}" - f"{address}" - f"{fields.BLOCK_TYPE}" - f"blocks" - f"{fields.PAGE}" - f"{str(page)}" - f"{fields.OFFSET}" - f"{str(offset)}" - ) - return url diff --git a/build/lib/etherscan/modules/blocks.py b/build/lib/etherscan/modules/blocks.py deleted file mode 100644 index c74b6e1..0000000 --- a/build/lib/etherscan/modules/blocks.py +++ /dev/null @@ -1,44 +0,0 @@ -from etherscan.enums.actions_enum import ActionsEnum as actions -from etherscan.enums.fields_enum import FieldsEnum as fields -from etherscan.enums.modules_enum import ModulesEnum as modules - - -class Blocks: - @staticmethod - def get_block_reward_by_block_number(block_no: str) -> str: - url = ( - f"{fields.MODULE}" - f"{modules.BLOCK}" - f"{fields.ACTION}" - f"{actions.GET_BLOCK_REWARD}" - f"{fields.BLOCKNO}" - f"{block_no}" - ) - return url - - @staticmethod - def get_est_block_countdown_time_by_block_number(block_no: str) -> str: - url = ( - f"{fields.MODULE}" - f"{modules.BLOCK}" - f"{fields.ACTION}" - f"{actions.GET_BLOCK_COUNTDOWN}" - f"{fields.BLOCKNO}" - f"{block_no}" - ) - return url - - @staticmethod - def get_block_number_by_timestamp(timestamp: int, closest: str) -> str: - # NOTE: Supports UNIX timestamps in seconds - url = ( - f"{fields.MODULE}" - f"{modules.BLOCK}" - f"{fields.ACTION}" - f"{actions.GET_BLOCK_NUMBER_BY_TIME}" - f"{fields.TIMESTAMP}" - f"{timestamp}" - f"{fields.CLOSEST}" - f"{closest}" - ) - return url diff --git a/build/lib/etherscan/modules/contracts.py b/build/lib/etherscan/modules/contracts.py deleted file mode 100644 index 6e8b85a..0000000 --- a/build/lib/etherscan/modules/contracts.py +++ /dev/null @@ -1,29 +0,0 @@ -from etherscan.enums.actions_enum import ActionsEnum as actions -from etherscan.enums.fields_enum import FieldsEnum as fields -from etherscan.enums.modules_enum import ModulesEnum as modules - - -class Contracts: - @staticmethod - def get_contract_abi(address: str) -> str: - url = ( - f"{fields.MODULE}" - f"{modules.CONTRACT}" - f"{fields.ACTION}" - f"{actions.GET_ABI}" - f"{fields.ADDRESS}" - f"{address}" - ) - return url - - @staticmethod - def get_contract_source_code(address: str) -> str: - url = ( - f"{fields.MODULE}" - f"{modules.CONTRACT}" - f"{fields.ACTION}" - f"{actions.GET_SOURCE_CODE}" - f"{fields.ADDRESS}" - f"{address}" - ) - return url diff --git a/build/lib/etherscan/modules/gastracker.py b/build/lib/etherscan/modules/gastracker.py deleted file mode 100644 index 191a8c3..0000000 --- a/build/lib/etherscan/modules/gastracker.py +++ /dev/null @@ -1,29 +0,0 @@ -from etherscan.enums.actions_enum import ActionsEnum as actions -from etherscan.enums.fields_enum import FieldsEnum as fields -from etherscan.enums.modules_enum import ModulesEnum as modules - - -class GasTracker: - @staticmethod - def get_est_confirmation_time(gas_price: int) -> str: - # NOTE: gas_price in wei, result in seconds - url = ( - f"{fields.MODULE}" - f"{modules.GASTRACKER}" - f"{fields.ACTION}" - f"{actions.GAS_ESTIMATE}" - f"{fields.GAS_PRICE}" - f"{gas_price}" - ) - return url - - @staticmethod - def get_gas_oracle() -> str: - # NOTE: gas_price in wei, result in seconds - url = ( - f"{fields.MODULE}" - f"{modules.GASTRACKER}" - f"{fields.ACTION}" - f"{actions.GAS_ORACLE}" - ) - return url diff --git a/build/lib/etherscan/modules/proxy.py b/build/lib/etherscan/modules/proxy.py deleted file mode 100644 index 3c5ffac..0000000 --- a/build/lib/etherscan/modules/proxy.py +++ /dev/null @@ -1,187 +0,0 @@ -from etherscan.enums.actions_enum import ActionsEnum as actions -from etherscan.enums.fields_enum import FieldsEnum as fields -from etherscan.enums.modules_enum import ModulesEnum as modules -from etherscan.enums.tags_enum import TagsEnum as tags - - -class Proxy: - @staticmethod - def get_proxy_block_number() -> str: - url = ( - f"{fields.MODULE}" - f"{modules.PROXY}" - f"{fields.ACTION}" - f"{actions.ETH_BLOCK_NUMBER}" - ) - return url - - @staticmethod - def get_proxy_block_by_number(tag: str) -> str: - url = ( - f"{fields.MODULE}" - f"{modules.PROXY}" - f"{fields.ACTION}" - f"{actions.ETH_GET_BLOCK_BY_NUMBER}" - f"{fields.TAG}" - f"{tag}" - f"{fields.BOOLEAN}" - f"true" - ) - return url - - @staticmethod - def get_proxy_uncle_by_block_number_and_index(tag: str, index: str) -> str: - url = ( - f"{fields.MODULE}" - f"{modules.PROXY}" - f"{fields.ACTION}" - f"{actions.ETH_GET_UNCLE_BY_BLOCK_NUMBER_AND_INDEX}" - f"{fields.TAG}" - f"{tag}" - f"{fields.INDEX}" - f"{index}" - ) - return url - - @staticmethod - def get_proxy_block_transaction_count_by_number(tag: str) -> str: - url = ( - f"{fields.MODULE}" - f"{modules.PROXY}" - f"{fields.ACTION}" - f"{actions.ETH_GET_BLOCK_TRANSACTION_COUNT_BY_NUMBER}" - f"{fields.TAG}" - f"{tag}" - ) - return url - - @staticmethod - def get_proxy_transaction_by_hash(txhash: str) -> str: - url = ( - f"{fields.MODULE}" - f"{modules.PROXY}" - f"{fields.ACTION}" - f"{actions.ETH_GET_TRANSACTION_BY_HASH}" - f"{fields.TXHASH}" - f"{txhash}" - ) - return url - - @staticmethod - def get_proxy_transaction_by_block_number_and_index(tag: str, index: str) -> str: - url = ( - f"{fields.MODULE}" - f"{modules.PROXY}" - f"{fields.ACTION}" - f"{actions.ETH_GET_TRANSACTION_BY_BLOCK_NUMBER_AND_INDEX}" - f"{fields.TAG}" - f"{tag}" - f"{fields.INDEX}" - f"{index}" - ) - return url - - @staticmethod - def get_proxy_transaction_count(address: str) -> str: - url = ( - f"{fields.MODULE}" - f"{modules.PROXY}" - f"{fields.ACTION}" - f"{actions.ETH_GET_TRANSACTION_COUNT}" - f"{fields.ADDRESS}" - f"{address}" - f"{fields.TAG}" - f"{tags.LATEST}" - ) - return url - - @staticmethod - def get_proxy_transaction_receipt(txhash: str) -> str: - url = ( - f"{fields.MODULE}" - f"{modules.PROXY}" - f"{fields.ACTION}" - f"{actions.ETH_GET_TRANSACTION_RECEIPT}" - f"{fields.TXHASH}" - f"{txhash}" - ) - return url - - @staticmethod - def get_proxy_call(to: str, data: str) -> str: - url = ( - f"{fields.MODULE}" - f"{modules.PROXY}" - f"{fields.ACTION}" - f"{actions.ETH_CALL}" - f"{fields.TO}" - f"{to}" - f"{fields.DATA}" - f"{data}" - f"{fields.TAG}" - f"{tags.LATEST}" - ) - return url - - @staticmethod - def get_proxy_code_at(address: str) -> str: - url = ( - f"{fields.MODULE}" - f"{modules.PROXY}" - f"{fields.ACTION}" - f"{actions.ETH_GET_CODE}" - f"{fields.ADDRESS}" - f"{address}" - f"{fields.TAG}" - f"{tags.LATEST}" - ) - return url - - @staticmethod - def get_proxy_storage_position_at(position: str, address: str) -> str: - url = ( - f"{fields.MODULE}" - f"{modules.PROXY}" - f"{fields.ACTION}" - f"{actions.ETH_GET_STORAGE_AT}" - f"{fields.ADDRESS}" - f"{address}" - f"{fields.POSITION}" - f"{position}" - f"{fields.TAG}" - f"{tags.LATEST}" - ) - return url - - @staticmethod - def get_proxy_gas_price() -> str: - # NOTE: Results are in WEI - url = ( - f"{fields.MODULE}" - f"{modules.PROXY}" - f"{fields.ACTION}" - f"{actions.ETH_GAS_PRICE}" - ) - return url - - @staticmethod - def get_proxy_est_gas( - to: str, data: str, value: str, gas_price: str, gas: str - ) -> str: - url = ( - f"{fields.MODULE}" - f"{modules.PROXY}" - f"{fields.ACTION}" - f"{actions.ETH_ESTIMATE_GAS}" - f"{fields.DATA}" - f"{data}" - f"{fields.TO}" - f"{to}" - f"{fields.VALUE}" - f"{value}" - f"{fields.GAS_PRICE}" - f"{gas_price}" - f"{fields.GAS}" - f"{gas}" - ) - return url diff --git a/build/lib/etherscan/modules/stats.py b/build/lib/etherscan/modules/stats.py deleted file mode 100644 index 816f46c..0000000 --- a/build/lib/etherscan/modules/stats.py +++ /dev/null @@ -1,47 +0,0 @@ -from etherscan.enums.actions_enum import ActionsEnum as actions -from etherscan.enums.fields_enum import FieldsEnum as fields -from etherscan.enums.modules_enum import ModulesEnum as modules - - -class Stats: - @staticmethod - def get_total_eth_supply() -> str: - url = ( - f"{fields.MODULE}" - f"{modules.STATS}" - f"{fields.ACTION}" - f"{actions.ETH_SUPPLY}" - ) - return url - - @staticmethod - def get_eth_last_price() -> str: - url = ( - f"{fields.MODULE}" - f"{modules.STATS}" - f"{fields.ACTION}" - f"{actions.ETH_PRICE}" - ) - return url - - @staticmethod - def get_eth_nodes_size( - start_date: str, end_date: str, client_type: str, sync_mode: str, sort: str - ) -> str: - url = ( - f"{fields.MODULE}" - f"{modules.STATS}" - f"{fields.ACTION}" - f"{actions.CHAIN_SIZE}" - f"{fields.START_DATE}" - f"{start_date}" - f"{fields.END_DATE}" - f"{end_date}" - f"{fields.CLIENT_TYPE}" - f"{client_type}" - f"{fields.SYNC_MODE}" - f"{sync_mode}" - f"{fields.SORT}" - f"{sort}" - ) - return url diff --git a/build/lib/etherscan/modules/tokens.py b/build/lib/etherscan/modules/tokens.py deleted file mode 100644 index 1c90745..0000000 --- a/build/lib/etherscan/modules/tokens.py +++ /dev/null @@ -1,36 +0,0 @@ -from etherscan.enums.actions_enum import ActionsEnum as actions -from etherscan.enums.fields_enum import FieldsEnum as fields -from etherscan.enums.modules_enum import ModulesEnum as modules -from etherscan.enums.tags_enum import TagsEnum as tags - - -class Tokens: - @staticmethod - def get_total_supply_by_contract_address(contract_address: str) -> str: - url = ( - f"{fields.MODULE}" - f"{modules.STATS}" - f"{fields.ACTION}" - f"{actions.TOKEN_SUPPLY}" - f"{fields.CONTRACT_ADDRESS}" - f"{contract_address}" - ) - return url - - @staticmethod - def get_acc_balance_by_token_and_contract_address( - contract_address: str, address: str - ) -> str: - url = ( - f"{fields.MODULE}" - f"{modules.ACCOUNT}" - f"{fields.ACTION}" - f"{actions.TOKEN_BALANCE}" - f"{fields.CONTRACT_ADDRESS}" - f"{contract_address}" - f"{fields.ADDRESS}" - f"{address}" - f"{fields.TAG}" - f"{tags.LATEST}" - ) - return url diff --git a/build/lib/etherscan/modules/transactions.py b/build/lib/etherscan/modules/transactions.py deleted file mode 100644 index 693089b..0000000 --- a/build/lib/etherscan/modules/transactions.py +++ /dev/null @@ -1,29 +0,0 @@ -from etherscan.enums.actions_enum import ActionsEnum as actions -from etherscan.enums.fields_enum import FieldsEnum as fields -from etherscan.enums.modules_enum import ModulesEnum as modules - - -class Transactions: - @staticmethod - def get_contract_execution_status(txhash: str) -> str: - url = ( - f"{fields.MODULE}" - f"{modules.TRANSACTION}" - f"{fields.ACTION}" - f"{actions.GET_STATUS}" - f"{fields.TXHASH}" - f"{txhash}" - ) - return url - - @staticmethod - def get_tx_receipt_status(txhash: str) -> str: - url = ( - f"{fields.MODULE}" - f"{modules.TRANSACTION}" - f"{fields.ACTION}" - f"{actions.GET_TX_RECEIPT_STATUS}" - f"{fields.TXHASH}" - f"{txhash}" - ) - return url diff --git a/build/lib/etherscan/utils/__init__.py b/build/lib/etherscan/utils/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/build/lib/etherscan/utils/conversions.py b/build/lib/etherscan/utils/conversions.py deleted file mode 100644 index 26fd503..0000000 --- a/build/lib/etherscan/utils/conversions.py +++ /dev/null @@ -1,13 +0,0 @@ -from decimal import Decimal - - -class Conversions: - @staticmethod - def to_ticker_unit(val: int, decimals: int = 18) -> Decimal: - factor = Decimal("10") ** Decimal("-{}".format(decimals)) - return Decimal(val) * factor - - @staticmethod - def to_smallest_unit(val: int, decimals: int = 18) -> Decimal: - factor = Decimal("10") ** Decimal("+{}".format(decimals)) - return Decimal(val) * factor diff --git a/build/lib/etherscan/utils/parsing.py b/build/lib/etherscan/utils/parsing.py deleted file mode 100644 index 3166fe2..0000000 --- a/build/lib/etherscan/utils/parsing.py +++ /dev/null @@ -1,18 +0,0 @@ -import requests - - -class ResponseParser: - @staticmethod - def parse(response: requests.Response): - content = response.json() - result = content["result"] - if "status" in content.keys(): - status = bool(int(content["status"])) - message = content["message"] - assert status, f"{result} -- {message}" - else: - # GETH or Parity proxy msg format - # TODO: see if we need those values - jsonrpc = content["jsonrpc"] - cid = int(content["id"]) - return result diff --git a/configs/__init__.py b/configs/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/dist/etherscan-python-1.0.3.tar.gz b/dist/etherscan-python-1.0.3.tar.gz deleted file mode 100644 index 38798f9..0000000 Binary files a/dist/etherscan-python-1.0.3.tar.gz and /dev/null differ diff --git a/dist/etherscan_python-1.0.3-py3-none-any.whl b/dist/etherscan_python-1.0.3-py3-none-any.whl deleted file mode 100644 index 3784ba6..0000000 Binary files a/dist/etherscan_python-1.0.3-py3-none-any.whl and /dev/null differ diff --git a/env.yml b/env.yml deleted file mode 100644 index 91d443f..0000000 --- a/env.yml +++ /dev/null @@ -1,34 +0,0 @@ -name: etherscan-python -channels: - - conda-forge - - defaults -dependencies: - - _libgcc_mutex=0.1=conda_forge - - _openmp_mutex=4.5=1_gnu - - ca-certificates=2020.6.20=hecda079_0 - - certifi=2020.6.20=py38h32f6830_0 - - ld_impl_linux-64=2.35=h769bd43_9 - - libffi=3.2.1=he1b5a44_1007 - - libgcc-ng=9.3.0=h24d8f2e_16 - - libgomp=9.3.0=h24d8f2e_16 - - libstdcxx-ng=9.3.0=hdf63c60_16 - - ncurses=6.2=he1b5a44_1 - - openssl=1.1.1h=h516909a_0 - - pip=20.2.3=py_0 - - python=3.8.5=h1103e12_9_cpython - - python_abi=3.8=1_cp38 - - readline=8.0=he28a2e2_2 - - setuptools=49.6.0=py38h32f6830_1 - - sqlite=3.33.0=h4cf870e_0 - - tk=8.6.10=hed695b0_0 - - wheel=0.35.1=pyh9f0ad1d_0 - - xz=5.2.5=h516909a_1 - - zlib=1.2.11=h516909a_1009 - - pip: - - chardet==3.0.4 - - coverage==5.3 - - idna==2.10 - - requests==2.24.0 - - urllib3==1.25.10 -prefix: /projects/mai/kjmv588/miniconda3/envs/etherscan-python - diff --git a/etherscan/configs/GOERLI-stable.json b/etherscan/configs/GOERLI-stable.json new file mode 100644 index 0000000..4dbe408 --- /dev/null +++ b/etherscan/configs/GOERLI-stable.json @@ -0,0 +1,310 @@ +{ + "get_proxy_block_number": { + "module": "proxy", + "kwargs": {} + }, + "get_proxy_block_by_number": { + "module": "proxy", + "kwargs": { + "tag": "0x10d4f" + } + }, + "_get_proxy_uncle_by_block_number_and_index": { + "module": "proxy", + "kwargs": { + "tag": "0x210A9B", + "index": "0x0" + } + }, + "get_proxy_block_transaction_count_by_number": { + "module": "proxy", + "kwargs": { + "tag": "0x10FB78" + } + }, + "get_proxy_transaction_by_hash": { + "module": "proxy", + "kwargs": { + "txhash": "0x1e2910a262b1008d0616a0beb24c1a491d78771baa54a33e66065e03b1f46bc1" + } + }, + "get_proxy_transaction_by_block_number_and_index": { + "module": "proxy", + "kwargs": { + "tag": "0x210A9B", + "index": "0x0" + } + }, + "get_proxy_transaction_count": { + "module": "proxy", + "kwargs": { + "address": "0x2910543af39aba0cd09dbb2d50200b3e800a63d2" + } + }, + "get_proxy_transaction_receipt": { + "module": "proxy", + "kwargs": { + "txhash": "0x1e2910a262b1008d0616a0beb24c1a491d78771baa54a33e66065e03b1f46bc1" + } + }, + "get_proxy_call": { + "module": "proxy", + "kwargs": { + "to": "0xAEEF46DB4855E25702F8237E8f403FddcaF931C0", + "data": "0x70a08231000000000000000000000000e16359506c028e51f16be38986ec5746251e9724" + } + }, + "get_proxy_code_at": { + "module": "proxy", + "kwargs": { + "address": "0xf75e354c5edc8efed9b59ee9f67a80845ade7d0c" + } + }, + "get_proxy_storage_position_at": { + "module": "proxy", + "kwargs": { + "position": "0x0", + "address": "0x6e03d9cce9d60f3e9f2597e13cd4c54c55330cfd" + } + }, + "get_proxy_gas_price": { + "module": "proxy", + "kwargs": {} + }, + "get_proxy_est_gas": { + "module": "proxy", + "kwargs": { + "data": "0x4e71d92d", + "to": "0xf0160428a8552ac9bb7e050d90eeade4ddd52843", + "value": "0xff22", + "gas_price": "0x51da038cc", + "gas": "0x5f5e0ff" + } + }, + "get_est_confirmation_time": { + "module": "gastracker", + "kwargs": { + "gas_price": "2000000000" + } + }, + "get_gas_oracle": { + "module": "gastracker", + "kwargs": {} + }, + "get_block_reward_by_block_number": { + "module": "blocks", + "kwargs": { + "block_no": "2165403" + } + }, + "get_est_block_countdown_time_by_block_number": { + "module": "blocks", + "kwargs": { + "block_no": "99999999" + } + }, + "get_block_number_by_timestamp": { + "module": "blocks", + "kwargs": { + "timestamp": "1578638524", + "closest": "before" + } + }, + "get_total_eth_supply": { + "module": "stats", + "kwargs": {} + }, + "get_eth_last_price": { + "module": "stats", + "kwargs": {} + }, + "_get_eth_nodes_size": { + "module": "stats", + "kwargs": { + "start_date": "2019-02-01", + "end_date": "2019-02-28", + "client_type": "geth", + "sync_mode": "default", + "sort": "asc" + } + }, + "get_total_supply_by_contract_address": { + "module": "tokens", + "kwargs": { + "contract_address": "0x57d90b64a1a57749b0f932f1a3395792e12e7055" + } + }, + "get_acc_balance_by_token_and_contract_address": { + "module": "tokens", + "kwargs": { + "contract_address": "0x57d90b64a1a57749b0f932f1a3395792e12e7055", + "address": "0xe04f27eb70e025b78871a2ad7eabe85e61212761" + } + }, + "get_contract_abi": { + "module": "contracts", + "kwargs": { + "address": "0x748D03fb181A158bea396489eA6589E7dCfBA495" + } + }, + "get_contract_source_code": { + "module": "contracts", + "kwargs": { + "address": "0xBB9bc244D798123fDe783fCc1C72d3Bb8C189413" + } + }, + "get_contract_execution_status": { + "module": "transactions", + "kwargs": { + "txhash": "0x15f8e5ea1079d9a0bb04a4c58ae5fe7654b5b2b4463375ff7ffb490aa0032f3a" + } + }, + "get_tx_receipt_status": { + "module": "transactions", + "kwargs": { + "txhash": "0x513c1ba0bebf66436b5fed86ab668452b7805593c05073eb2d51d3a52f480a76" + } + }, + "get_eth_balance": { + "module": "accounts", + "kwargs": { + "address": "0xddbd2b932c763ba5b1b7ae3b362eac3e8d40121a" + } + }, + "get_eth_balance_multiple": { + "module": "accounts", + "kwargs": { + "addresses": [ + "0xddbd2b932c763ba5b1b7ae3b362eac3e8d40121a", + "0x63a9975ba31b0b9626b34300f7f627147df1f526", + "0x198ef1ec325a96cc354c7266a038be8b5c558f67" + ] + } + }, + "get_normal_txs_by_address": { + "module": "accounts", + "kwargs": { + "address": "0xff6872f2c89ac60fbc1fc977a9724555b9796154", + "startblock": 0, + "endblock": 99999999, + "sort": "asc" + } + }, + "get_normal_txs_by_address_paginated": { + "module": "accounts", + "kwargs": { + "address": "0xff6872f2c89ac60fbc1fc977a9724555b9796154", + "startblock": 0, + "endblock": 99999999, + "page": 1, + "offset": 10, + "sort": "asc" + } + }, + "get_internal_txs_by_address": { + "module": "accounts", + "kwargs": { + "address": "0x126c5b0b637340569ee98c768e97992ea2fa426d", + "startblock": 4397831, + "endblock": 4397831, + "sort": "asc" + } + }, + "get_internal_txs_by_address_paginated": { + "module": "accounts", + "kwargs": { + "address": "0x126c5b0b637340569ee98c768e97992ea2fa426d", + "startblock": 4397831, + "endblock": 4397831, + "page": 1, + "offset": 10, + "sort": "asc" + } + }, + "get_internal_txs_by_txhash": { + "module": "accounts", + "kwargs": { + "txhash": "0x1b71be923f0dcb1f4a196d340d868ff0b35f494e7f3f6575b81812b0824696bb" + } + }, + "get_internal_txs_by_block_range_paginated": { + "module": "accounts", + "kwargs": { + "startblock": 0, + "endblock": 2702578, + "page": 1, + "offset": 10, + "sort": "asc" + } + }, + "get_erc20_token_transfer_events_by_address": { + "module": "accounts", + "kwargs": { + "address": "0x9fc8720759bf397bdc13ae08760a7aea7ebbdf56", + "startblock": 0, + "endblock": 999999999, + "sort": "asc" + } + }, + "get_erc20_token_transfer_events_by_contract_address_paginated": { + "module": "accounts", + "kwargs": { + "contract_address": "0x2ac3c1d3e24b45c6c310534bc2dd84b5ed576335", + "page": 1, + "offset": 100, + "sort": "asc" + } + }, + "get_erc20_token_transfer_events_by_address_and_contract_paginated": { + "module": "accounts", + "kwargs": { + "contract_address": "0x2ac3c1d3e24b45c6c310534bc2dd84b5ed576335", + "address": "0x9fc8720759bf397bdc13ae08760a7aea7ebbdf56", + "page": 1, + "offset": 100, + "sort": "asc" + } + }, + "get_erc721_token_transfer_events_by_address": { + "module": "accounts", + "kwargs": { + "address": "0x3b2f32d32faabd8d94df36afb956bd4d34bf905c", + "startblock": 0, + "endblock": 999999999, + "sort": "asc" + } + }, + "get_erc721_token_transfer_events_by_contract_address_paginated": { + "module": "accounts", + "kwargs": { + "contract_address": "0xe5975e7dc3dfbb4cbede646b8af7cf292b46693e", + "page": 1, + "offset": 100, + "sort": "asc" + } + }, + "get_erc721_token_transfer_events_by_address_and_contract_paginated": { + "module": "accounts", + "kwargs": { + "contract_address": "0xe5975e7dc3dfbb4cbede646b8af7cf292b46693e", + "address": "0x3b2f32d32faabd8d94df36afb956bd4d34bf905c", + "page": 1, + "offset": 100, + "sort": "asc" + } + }, + "get_mined_blocks_by_address": { + "module": "accounts", + "kwargs": { + "address": "0x0000000000000000000000000000000000000000" + } + }, + "get_mined_blocks_by_address_paginated": { + "module": "accounts", + "kwargs": { + "address": "0x0000000000000000000000000000000000000000", + "page": 1, + "offset": 100 + } + } +} \ No newline at end of file diff --git a/build/lib/configs/stable.json b/etherscan/configs/KOVAN-stable.json similarity index 83% rename from build/lib/configs/stable.json rename to etherscan/configs/KOVAN-stable.json index 0eb8ef1..a8ac91f 100644 --- a/build/lib/configs/stable.json +++ b/etherscan/configs/KOVAN-stable.json @@ -12,7 +12,7 @@ "get_proxy_uncle_by_block_number_and_index": { "module": "proxy", "kwargs": { - "tag": "0x210A9B", + "tag": "0x4d50e2", "index": "0x0" } }, @@ -31,7 +31,7 @@ "get_proxy_transaction_by_block_number_and_index": { "module": "proxy", "kwargs": { - "tag": "0x10d4f", + "tag": "0x43195c", "index": "0x0" } }, @@ -118,7 +118,7 @@ "module": "stats", "kwargs": {} }, - "get_eth_nodes_size": { + "_get_eth_nodes_size": { "module": "stats", "kwargs": { "start_date": "2019-02-01", @@ -144,7 +144,7 @@ "get_contract_abi": { "module": "contracts", "kwargs": { - "address": "0xBB9bc244D798123fDe783fCc1C72d3Bb8C189413" + "address": "0xe309239955502Bb812807e8C29B98C3441775d35" } }, "get_contract_source_code": { @@ -184,7 +184,7 @@ "get_normal_txs_by_address": { "module": "accounts", "kwargs": { - "address": "0xddbd2b932c763ba5b1b7ae3b362eac3e8d40121a", + "address": "0xc1918c20650920aa664235bc6cbd8b8728fbe931", "startblock": 0, "endblock": 99999999, "sort": "asc" @@ -193,7 +193,7 @@ "get_normal_txs_by_address_paginated": { "module": "accounts", "kwargs": { - "address": "0xddbd2b932c763ba5b1b7ae3b362eac3e8d40121a", + "address": "0xc1918c20650920aa664235bc6cbd8b8728fbe931", "startblock": 0, "endblock": 99999999, "page": 1, @@ -204,18 +204,18 @@ "get_internal_txs_by_address": { "module": "accounts", "kwargs": { - "address": "0x2c1ba59d6f58433fb1eaee7d20b26ed83bda51a3", - "startblock": 0, - "endblock": 2702578, + "address": "0xaaad7966ebe0663b8c9c6f683fb9c3e66e03467f", + "startblock": 23799593, + "endblock": 23799593, "sort": "asc" } }, "get_internal_txs_by_address_paginated": { "module": "accounts", "kwargs": { - "address": "0x2c1ba59d6f58433fb1eaee7d20b26ed83bda51a3", - "startblock": 0, - "endblock": 2702578, + "address": "0xaaad7966ebe0663b8c9c6f683fb9c3e66e03467f", + "startblock": 23799593, + "endblock": 23799593, "page": 1, "offset": 10, "sort": "asc" @@ -224,7 +224,7 @@ "get_internal_txs_by_txhash": { "module": "accounts", "kwargs": { - "txhash": "0x40eb908387324f2b575b4879cd9d7188f69c8fc9d87c901b9e2daaea4b442170" + "txhash": "0xad550ebc0f2473e3b5af8d1d30b093749cb2835bf21ed340e976b1ec25276b04" } }, "get_internal_txs_by_block_range_paginated": { @@ -240,7 +240,7 @@ "get_erc20_token_transfer_events_by_address": { "module": "accounts", "kwargs": { - "address": "0x4e83362442b8d1bec281594cea3050c8eb01311c", + "address": "0xa991b15e414ddfa78b0df1f7af6b3cf2023c738d", "startblock": 0, "endblock": 999999999, "sort": "asc" @@ -249,7 +249,7 @@ "get_erc20_token_transfer_events_by_contract_address_paginated": { "module": "accounts", "kwargs": { - "contract_address": "0x9f8f72aa9304c8b593d555f12ef6589cc3a579a2", + "contract_address": "0x8fe80f7ca77daa68b059f8b3e29e1c5d962f01e7", "page": 1, "offset": 100, "sort": "asc" @@ -258,8 +258,8 @@ "get_erc20_token_transfer_events_by_address_and_contract_paginated": { "module": "accounts", "kwargs": { - "contract_address": "0x9f8f72aa9304c8b593d555f12ef6589cc3a579a2", - "address": "0x4e83362442b8d1bec281594cea3050c8eb01311c", + "contract_address": "0x8fe80f7ca77daa68b059f8b3e29e1c5d962f01e7", + "address": "0xa991b15e414ddfa78b0df1f7af6b3cf2023c738d", "page": 1, "offset": 100, "sort": "asc" @@ -268,7 +268,7 @@ "get_erc721_token_transfer_events_by_address": { "module": "accounts", "kwargs": { - "address": "0x6975be450864c02b4613023c2152ee0743572325", + "address": "0x57e05dba059a8ff2777408e9e1f3c517c20fc719", "startblock": 0, "endblock": 999999999, "sort": "asc" @@ -277,7 +277,7 @@ "get_erc721_token_transfer_events_by_contract_address_paginated": { "module": "accounts", "kwargs": { - "contract_address": "0x06012c8cf97bead5deae237070f9587f8e7a266d", + "contract_address": "0x953067757ec1b3a859f80ae15269f95430e72e69", "page": 1, "offset": 100, "sort": "asc" @@ -286,8 +286,8 @@ "get_erc721_token_transfer_events_by_address_and_contract_paginated": { "module": "accounts", "kwargs": { - "contract_address": "0x06012c8cf97bead5deae237070f9587f8e7a266d", - "address": "0x6975be450864c02b4613023c2152ee0743572325", + "contract_address": "0x953067757ec1b3a859f80ae15269f95430e72e69", + "address": "0x57e05dba059a8ff2777408e9e1f3c517c20fc719", "page": 1, "offset": 100, "sort": "asc" @@ -296,13 +296,13 @@ "get_mined_blocks_by_address": { "module": "accounts", "kwargs": { - "address": "0x9dd134d14d1e65f84b706d6f205cd5b1cd03a46b" + "address": "0x0000000000000000000000000000000000000000" } }, "get_mined_blocks_by_address_paginated": { "module": "accounts", "kwargs": { - "address": "0x9dd134d14d1e65f84b706d6f205cd5b1cd03a46b", + "address": "0x0000000000000000000000000000000000000000", "page": 1, "offset": 100 } diff --git a/configs/stable.json b/etherscan/configs/MAIN-stable.json similarity index 100% rename from configs/stable.json rename to etherscan/configs/MAIN-stable.json diff --git a/etherscan/configs/RINKEBY-stable.json b/etherscan/configs/RINKEBY-stable.json new file mode 100644 index 0000000..3ca8296 --- /dev/null +++ b/etherscan/configs/RINKEBY-stable.json @@ -0,0 +1,310 @@ +{ + "get_proxy_block_number": { + "module": "proxy", + "kwargs": {} + }, + "get_proxy_block_by_number": { + "module": "proxy", + "kwargs": { + "tag": "0x10d4f" + } + }, + "_get_proxy_uncle_by_block_number_and_index": { + "module": "proxy", + "kwargs": { + "tag": "0x210A9B", + "index": "0x0" + } + }, + "get_proxy_block_transaction_count_by_number": { + "module": "proxy", + "kwargs": { + "tag": "0x10FB78" + } + }, + "get_proxy_transaction_by_hash": { + "module": "proxy", + "kwargs": { + "txhash": "0x1e2910a262b1008d0616a0beb24c1a491d78771baa54a33e66065e03b1f46bc1" + } + }, + "get_proxy_transaction_by_block_number_and_index": { + "module": "proxy", + "kwargs": { + "tag": "0x43195c", + "index": "0x0" + } + }, + "get_proxy_transaction_count": { + "module": "proxy", + "kwargs": { + "address": "0x2910543af39aba0cd09dbb2d50200b3e800a63d2" + } + }, + "get_proxy_transaction_receipt": { + "module": "proxy", + "kwargs": { + "txhash": "0x1e2910a262b1008d0616a0beb24c1a491d78771baa54a33e66065e03b1f46bc1" + } + }, + "get_proxy_call": { + "module": "proxy", + "kwargs": { + "to": "0xAEEF46DB4855E25702F8237E8f403FddcaF931C0", + "data": "0x70a08231000000000000000000000000e16359506c028e51f16be38986ec5746251e9724" + } + }, + "get_proxy_code_at": { + "module": "proxy", + "kwargs": { + "address": "0xf75e354c5edc8efed9b59ee9f67a80845ade7d0c" + } + }, + "get_proxy_storage_position_at": { + "module": "proxy", + "kwargs": { + "position": "0x0", + "address": "0x6e03d9cce9d60f3e9f2597e13cd4c54c55330cfd" + } + }, + "get_proxy_gas_price": { + "module": "proxy", + "kwargs": {} + }, + "get_proxy_est_gas": { + "module": "proxy", + "kwargs": { + "data": "0x4e71d92d", + "to": "0xf0160428a8552ac9bb7e050d90eeade4ddd52843", + "value": "0xff22", + "gas_price": "0x51da038cc", + "gas": "0x5f5e0ff" + } + }, + "get_est_confirmation_time": { + "module": "gastracker", + "kwargs": { + "gas_price": "2000000000" + } + }, + "get_gas_oracle": { + "module": "gastracker", + "kwargs": {} + }, + "get_block_reward_by_block_number": { + "module": "blocks", + "kwargs": { + "block_no": "2165403" + } + }, + "get_est_block_countdown_time_by_block_number": { + "module": "blocks", + "kwargs": { + "block_no": "99999999" + } + }, + "get_block_number_by_timestamp": { + "module": "blocks", + "kwargs": { + "timestamp": "1578638524", + "closest": "before" + } + }, + "get_total_eth_supply": { + "module": "stats", + "kwargs": {} + }, + "get_eth_last_price": { + "module": "stats", + "kwargs": {} + }, + "_get_eth_nodes_size": { + "module": "stats", + "kwargs": { + "start_date": "2019-02-01", + "end_date": "2019-02-28", + "client_type": "geth", + "sync_mode": "default", + "sort": "asc" + } + }, + "get_total_supply_by_contract_address": { + "module": "tokens", + "kwargs": { + "contract_address": "0x57d90b64a1a57749b0f932f1a3395792e12e7055" + } + }, + "get_acc_balance_by_token_and_contract_address": { + "module": "tokens", + "kwargs": { + "contract_address": "0x57d90b64a1a57749b0f932f1a3395792e12e7055", + "address": "0xe04f27eb70e025b78871a2ad7eabe85e61212761" + } + }, + "get_contract_abi": { + "module": "contracts", + "kwargs": { + "address": "0x79a856049A390336E221d54e2bAB9e629989187f" + } + }, + "get_contract_source_code": { + "module": "contracts", + "kwargs": { + "address": "0xBB9bc244D798123fDe783fCc1C72d3Bb8C189413" + } + }, + "get_contract_execution_status": { + "module": "transactions", + "kwargs": { + "txhash": "0x15f8e5ea1079d9a0bb04a4c58ae5fe7654b5b2b4463375ff7ffb490aa0032f3a" + } + }, + "get_tx_receipt_status": { + "module": "transactions", + "kwargs": { + "txhash": "0x513c1ba0bebf66436b5fed86ab668452b7805593c05073eb2d51d3a52f480a76" + } + }, + "get_eth_balance": { + "module": "accounts", + "kwargs": { + "address": "0xddbd2b932c763ba5b1b7ae3b362eac3e8d40121a" + } + }, + "get_eth_balance_multiple": { + "module": "accounts", + "kwargs": { + "addresses": [ + "0xddbd2b932c763ba5b1b7ae3b362eac3e8d40121a", + "0x63a9975ba31b0b9626b34300f7f627147df1f526", + "0x198ef1ec325a96cc354c7266a038be8b5c558f67" + ] + } + }, + "get_normal_txs_by_address": { + "module": "accounts", + "kwargs": { + "address": "0x0cb510e2f16c36ce039ee3164330d5f00ecf9eac", + "startblock": 0, + "endblock": 99999999, + "sort": "asc" + } + }, + "get_normal_txs_by_address_paginated": { + "module": "accounts", + "kwargs": { + "address": "0x0cb510e2f16c36ce039ee3164330d5f00ecf9eac", + "startblock": 0, + "endblock": 99999999, + "page": 1, + "offset": 10, + "sort": "asc" + } + }, + "get_internal_txs_by_address": { + "module": "accounts", + "kwargs": { + "address": "0xd16a6772163463c731e37ef42c98eee95f15a496", + "startblock": 8191436, + "endblock": 8191436, + "sort": "asc" + } + }, + "get_internal_txs_by_address_paginated": { + "module": "accounts", + "kwargs": { + "address": "0xd16a6772163463c731e37ef42c98eee95f15a496", + "startblock": 8191436, + "endblock": 8191436, + "page": 1, + "offset": 10, + "sort": "asc" + } + }, + "get_internal_txs_by_txhash": { + "module": "accounts", + "kwargs": { + "txhash": "0x55f288d70fbdcb4506a792d7cb3f5085132c5480fd06492e39a67bcb12119fe1" + } + }, + "get_internal_txs_by_block_range_paginated": { + "module": "accounts", + "kwargs": { + "startblock": 0, + "endblock": 2702578, + "page": 1, + "offset": 10, + "sort": "asc" + } + }, + "get_erc20_token_transfer_events_by_address": { + "module": "accounts", + "kwargs": { + "address": "0x18045cdf3f619e32ff4b11df689059b4d0358d11", + "startblock": 0, + "endblock": 999999999, + "sort": "asc" + } + }, + "get_erc20_token_transfer_events_by_contract_address_paginated": { + "module": "accounts", + "kwargs": { + "contract_address": "0xdf82c9014f127243ce1305dfe54151647d74b27a", + "page": 1, + "offset": 100, + "sort": "asc" + } + }, + "get_erc20_token_transfer_events_by_address_and_contract_paginated": { + "module": "accounts", + "kwargs": { + "contract_address": "0xdf82c9014f127243ce1305dfe54151647d74b27a", + "address": "0x18045cdf3f619e32ff4b11df689059b4d0358d11", + "page": 1, + "offset": 100, + "sort": "asc" + } + }, + "get_erc721_token_transfer_events_by_address": { + "module": "accounts", + "kwargs": { + "address": "0x0d4444a2473b2832700c693b81bc551e10e5c913", + "startblock": 0, + "endblock": 999999999, + "sort": "asc" + } + }, + "get_erc721_token_transfer_events_by_contract_address_paginated": { + "module": "accounts", + "kwargs": { + "contract_address": "0xd2ae28b5cb629d9018b91acb855e35cd75f5be80", + "page": 1, + "offset": 100, + "sort": "asc" + } + }, + "get_erc721_token_transfer_events_by_address_and_contract_paginated": { + "module": "accounts", + "kwargs": { + "contract_address": "0xd2ae28b5cb629d9018b91acb855e35cd75f5be80", + "address": "0x0d4444a2473b2832700c693b81bc551e10e5c913", + "page": 1, + "offset": 100, + "sort": "asc" + } + }, + "get_mined_blocks_by_address": { + "module": "accounts", + "kwargs": { + "address": "0xd6ae8250b8348c94847280928c79fb3b63ca453e" + } + }, + "get_mined_blocks_by_address_paginated": { + "module": "accounts", + "kwargs": { + "address": "0xd6ae8250b8348c94847280928c79fb3b63ca453e", + "page": 1, + "offset": 100 + } + } +} \ No newline at end of file diff --git a/etherscan/configs/ROPSTEN-stable.json b/etherscan/configs/ROPSTEN-stable.json new file mode 100644 index 0000000..012856e --- /dev/null +++ b/etherscan/configs/ROPSTEN-stable.json @@ -0,0 +1,310 @@ +{ + "get_proxy_block_number": { + "module": "proxy", + "kwargs": {} + }, + "get_proxy_block_by_number": { + "module": "proxy", + "kwargs": { + "tag": "0x10d4f" + } + }, + "get_proxy_uncle_by_block_number_and_index": { + "module": "proxy", + "kwargs": { + "tag": "0x956df5", + "index": "0x0" + } + }, + "get_proxy_block_transaction_count_by_number": { + "module": "proxy", + "kwargs": { + "tag": "0x10FB78" + } + }, + "get_proxy_transaction_by_hash": { + "module": "proxy", + "kwargs": { + "txhash": "0x1e2910a262b1008d0616a0beb24c1a491d78771baa54a33e66065e03b1f46bc1" + } + }, + "get_proxy_transaction_by_block_number_and_index": { + "module": "proxy", + "kwargs": { + "tag": "0x43195c", + "index": "0x0" + } + }, + "get_proxy_transaction_count": { + "module": "proxy", + "kwargs": { + "address": "0x2910543af39aba0cd09dbb2d50200b3e800a63d2" + } + }, + "get_proxy_transaction_receipt": { + "module": "proxy", + "kwargs": { + "txhash": "0x1e2910a262b1008d0616a0beb24c1a491d78771baa54a33e66065e03b1f46bc1" + } + }, + "get_proxy_call": { + "module": "proxy", + "kwargs": { + "to": "0xAEEF46DB4855E25702F8237E8f403FddcaF931C0", + "data": "0x70a08231000000000000000000000000e16359506c028e51f16be38986ec5746251e9724" + } + }, + "get_proxy_code_at": { + "module": "proxy", + "kwargs": { + "address": "0xf75e354c5edc8efed9b59ee9f67a80845ade7d0c" + } + }, + "get_proxy_storage_position_at": { + "module": "proxy", + "kwargs": { + "position": "0x0", + "address": "0x6e03d9cce9d60f3e9f2597e13cd4c54c55330cfd" + } + }, + "get_proxy_gas_price": { + "module": "proxy", + "kwargs": {} + }, + "get_proxy_est_gas": { + "module": "proxy", + "kwargs": { + "data": "0x4e71d92d", + "to": "0xf0160428a8552ac9bb7e050d90eeade4ddd52843", + "value": "0xff22", + "gas_price": "0x51da038cc", + "gas": "0x5f5e0ff" + } + }, + "get_est_confirmation_time": { + "module": "gastracker", + "kwargs": { + "gas_price": "2000000000" + } + }, + "get_gas_oracle": { + "module": "gastracker", + "kwargs": {} + }, + "get_block_reward_by_block_number": { + "module": "blocks", + "kwargs": { + "block_no": "2165403" + } + }, + "get_est_block_countdown_time_by_block_number": { + "module": "blocks", + "kwargs": { + "block_no": "99999999" + } + }, + "get_block_number_by_timestamp": { + "module": "blocks", + "kwargs": { + "timestamp": "1578638524", + "closest": "before" + } + }, + "get_total_eth_supply": { + "module": "stats", + "kwargs": {} + }, + "get_eth_last_price": { + "module": "stats", + "kwargs": {} + }, + "_get_eth_nodes_size": { + "module": "stats", + "kwargs": { + "start_date": "2019-02-01", + "end_date": "2019-02-28", + "client_type": "geth", + "sync_mode": "default", + "sort": "asc" + } + }, + "get_total_supply_by_contract_address": { + "module": "tokens", + "kwargs": { + "contract_address": "0x57d90b64a1a57749b0f932f1a3395792e12e7055" + } + }, + "get_acc_balance_by_token_and_contract_address": { + "module": "tokens", + "kwargs": { + "contract_address": "0x57d90b64a1a57749b0f932f1a3395792e12e7055", + "address": "0xe04f27eb70e025b78871a2ad7eabe85e61212761" + } + }, + "get_contract_abi": { + "module": "contracts", + "kwargs": { + "address": "0x036af46B35c5Fe11c1C48bC0301e325738F44c4a" + } + }, + "get_contract_source_code": { + "module": "contracts", + "kwargs": { + "address": "0xBB9bc244D798123fDe783fCc1C72d3Bb8C189413" + } + }, + "get_contract_execution_status": { + "module": "transactions", + "kwargs": { + "txhash": "0x15f8e5ea1079d9a0bb04a4c58ae5fe7654b5b2b4463375ff7ffb490aa0032f3a" + } + }, + "get_tx_receipt_status": { + "module": "transactions", + "kwargs": { + "txhash": "0x513c1ba0bebf66436b5fed86ab668452b7805593c05073eb2d51d3a52f480a76" + } + }, + "get_eth_balance": { + "module": "accounts", + "kwargs": { + "address": "0xddbd2b932c763ba5b1b7ae3b362eac3e8d40121a" + } + }, + "get_eth_balance_multiple": { + "module": "accounts", + "kwargs": { + "addresses": [ + "0xddbd2b932c763ba5b1b7ae3b362eac3e8d40121a", + "0x63a9975ba31b0b9626b34300f7f627147df1f526", + "0x198ef1ec325a96cc354c7266a038be8b5c558f67" + ] + } + }, + "get_normal_txs_by_address": { + "module": "accounts", + "kwargs": { + "address": "0x687422eea2cb73b5d3e242ba5456b782919afc85", + "startblock": 0, + "endblock": 99999999, + "sort": "asc" + } + }, + "get_normal_txs_by_address_paginated": { + "module": "accounts", + "kwargs": { + "address": "0x687422eea2cb73b5d3e242ba5456b782919afc85", + "startblock": 0, + "endblock": 99999999, + "page": 1, + "offset": 10, + "sort": "asc" + } + }, + "get_internal_txs_by_address": { + "module": "accounts", + "kwargs": { + "address": "0xf2b4e81ba39f5215db2e05b2f66f482bb8e87fd2", + "startblock": 9793067, + "endblock": 9793067, + "sort": "asc" + } + }, + "get_internal_txs_by_address_paginated": { + "module": "accounts", + "kwargs": { + "address": "0xf2b4e81ba39f5215db2e05b2f66f482bb8e87fd2", + "startblock": 9793067, + "endblock": 9793067, + "page": 1, + "offset": 10, + "sort": "asc" + } + }, + "get_internal_txs_by_txhash": { + "module": "accounts", + "kwargs": { + "txhash": "0xbfb7fd401294dd5bfbcc88842670892182bf119069ad866ac2c5e4d8511cd032" + } + }, + "get_internal_txs_by_block_range_paginated": { + "module": "accounts", + "kwargs": { + "startblock": 0, + "endblock": 2702578, + "page": 1, + "offset": 10, + "sort": "asc" + } + }, + "get_erc20_token_transfer_events_by_address": { + "module": "accounts", + "kwargs": { + "address": "0x3ebe6781be6d436cb7999cfce8b52e40819721cb", + "startblock": 0, + "endblock": 999999999, + "sort": "asc" + } + }, + "get_erc20_token_transfer_events_by_contract_address_paginated": { + "module": "accounts", + "kwargs": { + "contract_address": "0x8707a5bf4c2842d46b31a405ba41b858c0f876c4", + "page": 1, + "offset": 100, + "sort": "asc" + } + }, + "get_erc20_token_transfer_events_by_address_and_contract_paginated": { + "module": "accounts", + "kwargs": { + "contract_address": "0x8707a5bf4c2842d46b31a405ba41b858c0f876c4", + "address": "0x3ebe6781be6d436cb7999cfce8b52e40819721cb", + "page": 1, + "offset": 100, + "sort": "asc" + } + }, + "get_erc721_token_transfer_events_by_address": { + "module": "accounts", + "kwargs": { + "address": "0x07d48bdba7975f0daf73bd5b85a2e3ff87ffb24e", + "startblock": 9792696, + "endblock": 9792696, + "sort": "asc" + } + }, + "get_erc721_token_transfer_events_by_contract_address_paginated": { + "module": "accounts", + "kwargs": { + "contract_address": "0x130116e22f3e42ab82abde6d940ef4ef14b77c86", + "page": 1, + "offset": 100, + "sort": "asc" + } + }, + "get_erc721_token_transfer_events_by_address_and_contract_paginated": { + "module": "accounts", + "kwargs": { + "contract_address": "0x130116e22f3e42ab82abde6d940ef4ef14b77c86", + "address": "0x07d48bdba7975f0daf73bd5b85a2e3ff87ffb24e", + "page": 1, + "offset": 100, + "sort": "asc" + } + }, + "get_mined_blocks_by_address": { + "module": "accounts", + "kwargs": { + "address": "0x635b4764d1939dfacd3a8014726159abc277becc" + } + }, + "get_mined_blocks_by_address_paginated": { + "module": "accounts", + "kwargs": { + "address": "0x635b4764d1939dfacd3a8014726159abc277becc", + "page": 1, + "offset": 100 + } + } +} \ No newline at end of file diff --git a/build/lib/configs/__init__.py b/etherscan/configs/__init__.py similarity index 100% rename from build/lib/configs/__init__.py rename to etherscan/configs/__init__.py diff --git a/etherscan/enums/fields_enum.py b/etherscan/enums/fields_enum.py index a85fb77..b0bcc4d 100644 --- a/etherscan/enums/fields_enum.py +++ b/etherscan/enums/fields_enum.py @@ -23,7 +23,7 @@ class FieldsEnum: OFFSET: str = "&offset=" PAGE: str = "&page=" POSITION: str = "&position=" - PREFIX: str = "https://api.etherscan.io/api?" + PREFIX: str = "https://api-{}.etherscan.io/api?" SORT: str = "&sort=" START_BLOCK: str = "&startblock=" START_DATE: str = "&startdate=" diff --git a/etherscan/etherscan.py b/etherscan/etherscan.py index 0b8b8f6..5749aa8 100644 --- a/etherscan/etherscan.py +++ b/etherscan/etherscan.py @@ -1,37 +1,44 @@ import json +from importlib import resources import requests import etherscan +from etherscan import configs from etherscan.enums.fields_enum import FieldsEnum as fields from etherscan.utils.parsing import ResponseParser as parser class Etherscan: + def __new__(cls, api_key: str, net: str = "MAIN"): + with resources.path(configs, f"{net.upper()}-stable.json") as path: + config_path = str(path) + return cls.from_config(api_key=api_key, config_path=config_path, net=net) + @staticmethod def __load_config(config_path: str) -> dict: with open(config_path, "r") as f: return json.load(f) @staticmethod - def __run(func, api_key): + def __run(func, api_key: str, net: str): def wrapper(*args, **kwargs): url = ( - f"{fields.PREFIX}" + f"{fields.PREFIX.format(net.lower()).replace('-main','')}" f"{func(*args, **kwargs)}" f"{fields.API_KEY}" f"{api_key}" ) - r = requests.get(url) + r = requests.get(url, headers={"User-Agent": ""}) return parser.parse(r) return wrapper @classmethod - def from_config(cls, config_path: str, api_key: str): + def from_config(cls, api_key: str, config_path: str, net: str): config = cls.__load_config(config_path) for func, v in config.items(): if not func.startswith("_"): # disabled if _ attr = getattr(getattr(etherscan, v["module"]), func) - setattr(cls, func, cls.__run(attr, api_key)) + setattr(cls, func, cls.__run(attr, api_key, net)) return cls diff --git a/setup.py b/setup.py index 7617e16..9a4410a 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ setup( name="etherscan-python", - version="2.0.0", + version="2.1.0", description="A minimal, yet complete, python API for etherscan.io.", url="https://github.com/pcko1/etherscan-python", author="Panagiotis-Christos Kotsias", @@ -10,12 +10,12 @@ license="MIT", packages=[ "etherscan", + "etherscan.configs", "etherscan.enums", "etherscan.modules", "etherscan.utils", - "configs", ], - install_requires=["requests", "coverage"], - package_data={"configs": ["*"]}, + install_requires=["requests"], + include_package_data=True, zip_safe=False, ) diff --git a/test/test_modules.py b/test/test_modules.py index 6221cf8..8ad9f9b 100644 --- a/test/test_modules.py +++ b/test/test_modules.py @@ -1,11 +1,13 @@ import json from datetime import datetime +import time + import os from unittest import TestCase from etherscan.etherscan import Etherscan -CONFIG_PATH = "configs/stable.json" +CONFIG_PATH = "etherscan/configs/{}-stable.json" API_KEY = os.environ["API_KEY"] # Encrypted env var by Travis @@ -21,18 +23,20 @@ def dump(data, fname): class Case(TestCase): _MODULE = "" + _NETS = ["MAIN", "KOVAN", "RINKEBY", "ROPSTEN"] - def test_methods(self): - print(f"\nMODULE: {self._MODULE}") - config = load(CONFIG_PATH) - etherscan = Etherscan.from_config(CONFIG_PATH, API_KEY) + def methods(self, net): + print(f"\nNET: {net}") + print(f"MODULE: {self._MODULE}") + config = load(CONFIG_PATH.format(net)) + etherscan = Etherscan(API_KEY, net) for fun, v in config.items(): if not fun.startswith("_"): # disabled if _ if v["module"] == self._MODULE: res = getattr(etherscan, fun)(**v["kwargs"]) print(f"METHOD: {fun}, RTYPE: {type(res)}") # Create log files (will update existing ones) - fname = f"logs/standard/{fun}.json" + fname = f"logs/standard/{net}-{fun}.json" log = { "method": fun, "module": v["module"], @@ -41,6 +45,11 @@ def test_methods(self): "res": res, } dump(log, fname) + time.sleep(0.5) + + def test_net_methods(self): + for net in self._NETS: + self.methods(net) class TestAccounts(Case):