Skip to content

Commit

Permalink
Merge branch 'develop' into eip1559-fields
Browse files Browse the repository at this point in the history
# Conflicts:
#	setup.py
  • Loading branch information
medvedev1088 committed Aug 1, 2021
2 parents 55332cd + 45c3baf commit 5dd9555
Show file tree
Hide file tree
Showing 9 changed files with 102 additions and 14 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Ethereum ETL

[![Build Status](https://travis-ci.org/blockchain-etl/ethereum-etl.png)](https://travis-ci.org/blockchain-etl/ethereum-etl)
[![Build Status](https://travis-ci.com/blockchain-etl/ethereum-etl.png)](https://travis-ci.com/blockchain-etl/ethereum-etl)
[![Join the chat at https://gitter.im/ethereum-eth](https://badges.gitter.im/ethereum-etl.svg)](https://gitter.im/ethereum-etl/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
[![Telegram](https://img.shields.io/badge/telegram-join%20chat-blue.svg)](https://t.me/joinchat/GsMpbA3mv1OJ6YMp3T5ORQ)
[![Discord](https://img.shields.io/badge/discord-join%20chat-blue.svg)](https://discord.gg/wukrezR)
Expand Down Expand Up @@ -78,8 +78,9 @@ For the latest version, check out the repo and call
```bash
> pip3 install -e .[dev,streaming]
> export ETHEREUM_ETL_RUN_SLOW_TESTS=True
> export PROVIDER_URL=<your_porvider_uri>
> pytest -vv
```
```

### Running Tox Tests

Expand Down
2 changes: 1 addition & 1 deletion docs/dockerhub.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Uploading to Docker Hub

```bash
ETHEREUMETL_VERSION=1.6.3
ETHEREUMETL_VERSION=1.6.5
docker build -t ethereum-etl:${ETHEREUMETL_VERSION} -f Dockerfile .
docker tag ethereum-etl:${ETHEREUMETL_VERSION} blockchainetl/ethereum-etl:${ETHEREUMETL_VERSION}
docker push blockchainetl/ethereum-etl:${ETHEREUMETL_VERSION}
Expand Down
2 changes: 1 addition & 1 deletion ethereumetl/cli/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@


@click.group()
@click.version_option(version='1.6.3')
@click.version_option(version='1.6.5')
@click.pass_context
def cli(ctx):
pass
Expand Down
61 changes: 61 additions & 0 deletions ethereumetl/erc20_abi.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,3 +284,64 @@
}
]
''')

ERC20_ABI_ALTERNATIVE_1 = json.loads('''
[
{
"constant": true,
"inputs": [],
"name": "symbol",
"outputs": [
{
"name": "",
"type": "bytes32"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": true,
"inputs": [],
"name": "SYMBOL",
"outputs": [
{
"name": "",
"type": "bytes32"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": true,
"inputs": [],
"name": "name",
"outputs": [
{
"name": "",
"type": "bytes32"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": true,
"inputs": [],
"name": "NAME",
"outputs": [
{
"name": "",
"type": "bytes32"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
}
]
''')
31 changes: 28 additions & 3 deletions ethereumetl/service/eth_token_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
from web3.exceptions import BadFunctionCallOutput

from ethereumetl.domain.token import EthToken
from ethereumetl.erc20_abi import ERC20_ABI
from ethereumetl.erc20_abi import ERC20_ABI, ERC20_ABI_ALTERNATIVE_1

logger = logging.getLogger('eth_token_service')

Expand All @@ -37,9 +37,26 @@ def __init__(self, web3, function_call_result_transformer=None):
def get_token(self, token_address):
checksum_address = self._web3.toChecksumAddress(token_address)
contract = self._web3.eth.contract(address=checksum_address, abi=ERC20_ABI)
contract_alternative_1 = self._web3.eth.contract(address=checksum_address, abi=ERC20_ABI_ALTERNATIVE_1)

symbol = self._get_first_result(
contract.functions.symbol(),
contract.functions.SYMBOL(),
contract_alternative_1.functions.symbol(),
contract_alternative_1.functions.SYMBOL(),
)
if isinstance(symbol, bytes):
symbol = self._bytes_to_string(symbol)

name = self._get_first_result(
contract.functions.name(),
contract.functions.NAME(),
contract_alternative_1.functions.name(),
contract_alternative_1.functions.NAME(),
)
if isinstance(name, bytes):
name = self._bytes_to_string(name)

symbol = self._get_first_result(contract.functions.symbol(), contract.functions.SYMBOL())
name = self._get_first_result(contract.functions.name(), contract.functions.NAME())
decimals = self._get_first_result(contract.functions.decimals(), contract.functions.DECIMALS())
total_supply = self._get_first_result(contract.functions.totalSupply())

Expand Down Expand Up @@ -73,6 +90,14 @@ def _call_contract_function(self, func):
else:
return result

def _bytes_to_string(self, b):
if b is None:
return b
b = b.decode('utf-8')
if self._function_call_result_transformer is not None:
b = self._function_call_result_transformer(b)
return b


def call_contract_function(func, ignore_errors, default_value=None):
try:
Expand Down
6 changes: 3 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def read(fname):

setup(
name='ethereum-etl',
version='1.6.3',
version='1.6.5',
author='Evgeny Medvedev',
author_email='[email protected]',
description='Tools for exporting Ethereum blockchain data to CSV or JSON',
Expand All @@ -34,11 +34,11 @@ def read(fname):
python_requires='>=3.5.3,<4',
install_requires=[
'web3==4.7.2',
'eth-utils==1.8.4',
'eth-utils==1.10.0',
'eth-abi==1.3.0',
# TODO: This has to be removed when "ModuleNotFoundError: No module named 'eth_utils.toolz'" is fixed at eth-abi
'python-dateutil==2.8.0',
'click==7.0',
'click==7.1.2',
'ethereum-dasm==0.1.4',
'base58',
'requests',
Expand Down
2 changes: 1 addition & 1 deletion tests/ethereumetl/job/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def get_web3_provider(provider_type, read_resource_lambda=None, batch=False):
else:
provider = MockWeb3Provider(read_resource_lambda)
elif provider_type == 'infura':
provider_url = os.environ.get('PROVIDER_URL', 'https://mainnet.infura.io')
provider_url = os.environ.get('PROVIDER_URL', 'https://mainnet.infura.io/v3/7aef3f0cd1f64408b163814b22cc643c')
if batch:
provider = BatchHTTPProvider(provider_url)
else:
Expand Down
5 changes: 3 additions & 2 deletions tests/ethereumetl/service/test_eth_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

import os

import pytest
from dateutil.parser import parse
Expand Down Expand Up @@ -75,5 +75,6 @@ def test_get_block_range_for_timestamps_fail(start_timestamp, end_timestamp):


def get_new_eth_service():
web3 = Web3(HTTPProvider('https://mainnet.infura.io'))
provider_url = os.environ.get('PROVIDER_URL', 'https://mainnet.infura.io/v3/7aef3f0cd1f64408b163814b22cc643c')
web3 = Web3(HTTPProvider(provider_url))
return EthService(web3)
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
address,symbol,name,decimals,total_supply,block_number
0x86fa049857e0209aa7d9e616f7eb3b3b78ecfdb0,,,18,1000000000000000000000000000,
0x86fa049857e0209aa7d9e616f7eb3b3b78ecfdb0,EOS,,18,1000000000000000000000000000,

0 comments on commit 5dd9555

Please sign in to comment.