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 index 39d0704..952e599 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1 +1,5 @@ -include etherscan/configs/stable.json \ No newline at end of file +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 26aa122..3a415f6 100644 --- a/README.md +++ b/README.md @@ -1,15 +1,22 @@ # 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) [![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/). All standard 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). @@ -148,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 @@ -189,7 +184,7 @@ The tests also include the PRO endpoints so if your key is not PRO, the correspo In `python`, create a client with your personal [Etherscan.io](https://etherscan.io/) API key: ``` python -from etherscan.etherscan import Etherscan +from etherscan import Etherscan eth = Etherscan(YOUR_API_KEY) # key in quotation marks ``` @@ -200,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 @@ -234,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.4256826 +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.4256826} + doi = {10.5281/zenodo.4306855} } ``` diff --git a/env.yml b/env.yml deleted file mode 100644 index fb66517..0000000 --- a/env.yml +++ /dev/null @@ -1,32 +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 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/etherscan/configs/KOVAN-stable.json b/etherscan/configs/KOVAN-stable.json new file mode 100644 index 0000000..a8ac91f --- /dev/null +++ b/etherscan/configs/KOVAN-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": "0x4d50e2", + "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": "0xe309239955502Bb812807e8C29B98C3441775d35" + } + }, + "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": "0xc1918c20650920aa664235bc6cbd8b8728fbe931", + "startblock": 0, + "endblock": 99999999, + "sort": "asc" + } + }, + "get_normal_txs_by_address_paginated": { + "module": "accounts", + "kwargs": { + "address": "0xc1918c20650920aa664235bc6cbd8b8728fbe931", + "startblock": 0, + "endblock": 99999999, + "page": 1, + "offset": 10, + "sort": "asc" + } + }, + "get_internal_txs_by_address": { + "module": "accounts", + "kwargs": { + "address": "0xaaad7966ebe0663b8c9c6f683fb9c3e66e03467f", + "startblock": 23799593, + "endblock": 23799593, + "sort": "asc" + } + }, + "get_internal_txs_by_address_paginated": { + "module": "accounts", + "kwargs": { + "address": "0xaaad7966ebe0663b8c9c6f683fb9c3e66e03467f", + "startblock": 23799593, + "endblock": 23799593, + "page": 1, + "offset": 10, + "sort": "asc" + } + }, + "get_internal_txs_by_txhash": { + "module": "accounts", + "kwargs": { + "txhash": "0xad550ebc0f2473e3b5af8d1d30b093749cb2835bf21ed340e976b1ec25276b04" + } + }, + "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": "0xa991b15e414ddfa78b0df1f7af6b3cf2023c738d", + "startblock": 0, + "endblock": 999999999, + "sort": "asc" + } + }, + "get_erc20_token_transfer_events_by_contract_address_paginated": { + "module": "accounts", + "kwargs": { + "contract_address": "0x8fe80f7ca77daa68b059f8b3e29e1c5d962f01e7", + "page": 1, + "offset": 100, + "sort": "asc" + } + }, + "get_erc20_token_transfer_events_by_address_and_contract_paginated": { + "module": "accounts", + "kwargs": { + "contract_address": "0x8fe80f7ca77daa68b059f8b3e29e1c5d962f01e7", + "address": "0xa991b15e414ddfa78b0df1f7af6b3cf2023c738d", + "page": 1, + "offset": 100, + "sort": "asc" + } + }, + "get_erc721_token_transfer_events_by_address": { + "module": "accounts", + "kwargs": { + "address": "0x57e05dba059a8ff2777408e9e1f3c517c20fc719", + "startblock": 0, + "endblock": 999999999, + "sort": "asc" + } + }, + "get_erc721_token_transfer_events_by_contract_address_paginated": { + "module": "accounts", + "kwargs": { + "contract_address": "0x953067757ec1b3a859f80ae15269f95430e72e69", + "page": 1, + "offset": 100, + "sort": "asc" + } + }, + "get_erc721_token_transfer_events_by_address_and_contract_paginated": { + "module": "accounts", + "kwargs": { + "contract_address": "0x953067757ec1b3a859f80ae15269f95430e72e69", + "address": "0x57e05dba059a8ff2777408e9e1f3c517c20fc719", + "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/etherscan/configs/stable.json b/etherscan/configs/MAIN-stable.json similarity index 100% rename from etherscan/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/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 34d9d5b..5749aa8 100644 --- a/etherscan/etherscan.py +++ b/etherscan/etherscan.py @@ -10,10 +10,10 @@ class Etherscan: - def __new__(cls, api_key: str): - with resources.path(configs, "stable.json") as path: + 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) + return cls.from_config(api_key=api_key, config_path=config_path, net=net) @staticmethod def __load_config(config_path: str) -> dict: @@ -21,24 +21,24 @@ def __load_config(config_path: str) -> dict: return json.load(f) @staticmethod - def __run(func, api_key: str): + 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, api_key: str, config_path: 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 9cd3086..9a4410a 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ setup( name="etherscan-python", - version="2.0.2", + 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", @@ -15,7 +15,7 @@ "etherscan.modules", "etherscan.utils", ], - install_requires=["requests", "coverage"], + install_requires=["requests"], include_package_data=True, zip_safe=False, ) diff --git a/test/test_modules.py b/test/test_modules.py index 7ec2004..8ad9f9b 100644 --- a/test/test_modules.py +++ b/test/test_modules.py @@ -1,12 +1,13 @@ import json from datetime import datetime +import time import os from unittest import TestCase from etherscan.etherscan import Etherscan -CONFIG_PATH = "etherscan/configs/stable.json" +CONFIG_PATH = "etherscan/configs/{}-stable.json" API_KEY = os.environ["API_KEY"] # Encrypted env var by Travis @@ -22,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(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"], @@ -42,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):