wallet-fetcher: fix error fetching erc-20 tokens

Signed-off-by: Alexis Pentori <alexis@status.im>
This commit is contained in:
Alexis Pentori 2024-01-25 18:22:34 +01:00
parent 358063820f
commit 691a633300
No known key found for this signature in database
GPG Key ID: 65250D2801E47A10
4 changed files with 11 additions and 8 deletions

View File

@ -10,7 +10,7 @@ data:
connectorSubtype: api
connectorType: source
definitionId: 1e55cfe0-f591-4281-9a20-18d89d45f685
dockerImageTag: 0.5.0
dockerImageTag: 0.7.0
dockerRepository: harbor.status.im/status-im/airbyte/wallet-fetcher
githubIssueLabel: source-wallet-fetcher
icon: icon.svg

View File

@ -1,5 +1,4 @@
from typing import Any, Iterable, List, Mapping, MutableMapping, Optional, Tuple
from .utils import extract_token
from .stream import BitcoinToken, EthereumToken
import logging
import requests

View File

@ -4,7 +4,7 @@ import logging
import requests
import json
import time
from .utils import extract_token
logger = logging.getLogger("airbyte")
@ -100,6 +100,9 @@ class EthereumToken(BlockchainStream):
try:
yield extract_token(stream_slice['name'], t)
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
time.sleep(2)

View File

@ -8,7 +8,9 @@ def extract_token(wallet_name, token_data):
try:
if token_data['tokenInfo']['decimals'] == '22270923681254677845691103109158760375340177724800803888364822332811285364736':
# 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 = {
"wallet_name": wallet_name,
"name": token_data['tokenInfo']['name'],
@ -20,6 +22,5 @@ def extract_token(wallet_name, token_data):
"decimal": token_data['tokenInfo']['decimals']
}
return token
except KeyError:
raise Exception('Not a valid token')
except KeyError as err:
raise Exception('Invalid ERC-20 Token: %s', err)