wallet-fetcher: fix error fetching erc-20 tokens
Signed-off-by: Alexis Pentori <alexis@status.im>
This commit is contained in:
parent
358063820f
commit
691a633300
|
@ -10,7 +10,7 @@ data:
|
||||||
connectorSubtype: api
|
connectorSubtype: api
|
||||||
connectorType: source
|
connectorType: source
|
||||||
definitionId: 1e55cfe0-f591-4281-9a20-18d89d45f685
|
definitionId: 1e55cfe0-f591-4281-9a20-18d89d45f685
|
||||||
dockerImageTag: 0.5.0
|
dockerImageTag: 0.7.0
|
||||||
dockerRepository: harbor.status.im/status-im/airbyte/wallet-fetcher
|
dockerRepository: harbor.status.im/status-im/airbyte/wallet-fetcher
|
||||||
githubIssueLabel: source-wallet-fetcher
|
githubIssueLabel: source-wallet-fetcher
|
||||||
icon: icon.svg
|
icon: icon.svg
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
from typing import Any, Iterable, List, Mapping, MutableMapping, Optional, Tuple
|
from typing import Any, Iterable, List, Mapping, MutableMapping, Optional, Tuple
|
||||||
from .utils import extract_token
|
|
||||||
from .stream import BitcoinToken, EthereumToken
|
from .stream import BitcoinToken, EthereumToken
|
||||||
import logging
|
import logging
|
||||||
import requests
|
import requests
|
||||||
|
|
|
@ -4,7 +4,7 @@ import logging
|
||||||
import requests
|
import requests
|
||||||
import json
|
import json
|
||||||
import time
|
import time
|
||||||
|
from .utils import extract_token
|
||||||
logger = logging.getLogger("airbyte")
|
logger = logging.getLogger("airbyte")
|
||||||
|
|
||||||
|
|
||||||
|
@ -100,6 +100,9 @@ class EthereumToken(BlockchainStream):
|
||||||
try:
|
try:
|
||||||
yield extract_token(stream_slice['name'], t)
|
yield extract_token(stream_slice['name'], t)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.debug('Dropping token not valid %s' % t )
|
name = t
|
||||||
|
if 'name' in t:
|
||||||
|
name= t['name']
|
||||||
|
logger.warning('Dropping token %s not valid %s',name, e )
|
||||||
# Delaying calls - Not great but that works
|
# Delaying calls - Not great but that works
|
||||||
time.sleep(2)
|
time.sleep(2)
|
||||||
|
|
|
@ -8,7 +8,9 @@ def extract_token(wallet_name, token_data):
|
||||||
try:
|
try:
|
||||||
if token_data['tokenInfo']['decimals'] == '22270923681254677845691103109158760375340177724800803888364822332811285364736':
|
if token_data['tokenInfo']['decimals'] == '22270923681254677845691103109158760375340177724800803888364822332811285364736':
|
||||||
# The data is not valid, droping it.
|
# The data is not valid, droping it.
|
||||||
raise Exception('Not a valid token')
|
raise Exception('Invalid token: decimal fields not valid: %s', token_data)
|
||||||
|
if token_data['tokenInfo']['owner'] == '0x0000000000000000000000000000000000000000':
|
||||||
|
raise Exception('Invalid token, owner is the void address: %s', token_data)
|
||||||
token = {
|
token = {
|
||||||
"wallet_name": wallet_name,
|
"wallet_name": wallet_name,
|
||||||
"name": token_data['tokenInfo']['name'],
|
"name": token_data['tokenInfo']['name'],
|
||||||
|
@ -20,6 +22,5 @@ def extract_token(wallet_name, token_data):
|
||||||
"decimal": token_data['tokenInfo']['decimals']
|
"decimal": token_data['tokenInfo']['decimals']
|
||||||
}
|
}
|
||||||
return token
|
return token
|
||||||
except KeyError:
|
except KeyError as err:
|
||||||
raise Exception('Not a valid token')
|
raise Exception('Invalid ERC-20 Token: %s', err)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue