wallet-fetcher: updating token validity check for ERC-20
Signed-off-by: Alexis Pentori <alexis@status.im>
This commit is contained in:
parent
84ebdba956
commit
7c017b76e7
|
@ -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.7.0
|
dockerImageTag: 0.8.0
|
||||||
dockerRepository: status-im/airbyte/wallet-fetcher
|
dockerRepository: status-im/airbyte/wallet-fetcher
|
||||||
githubIssueLabel: source-wallet-fetcher
|
githubIssueLabel: source-wallet-fetcher
|
||||||
icon: icon.svg
|
icon: icon.svg
|
||||||
|
|
|
@ -1,16 +1,26 @@
|
||||||
import logging
|
import logging
|
||||||
import json
|
import json
|
||||||
|
|
||||||
|
# Number used as decimal when the contract has been destroyed
|
||||||
|
INVALID_DECIMAL_NUMBER="22270923681254677845691103109158760375340177724800803888364822332811285364736"
|
||||||
|
VOID_ADDRESS="0x0000000000000000000000000000000000000000"
|
||||||
|
|
||||||
|
"""
|
||||||
|
Function to verify if the tokens contracts is still valid
|
||||||
|
"""
|
||||||
|
def check_token_validity(tokenInfo):
|
||||||
|
if "decimals" not in tokenInfo:
|
||||||
|
raise Exception('Invalid token: decimal fields not present: %s', tokenInfo)
|
||||||
|
if tokenInfo.get("decimals") == INVALID_DECIMAL_NUMBER:
|
||||||
|
raise Exception('Invalid token: decimal fields invalid: %s', tokenInfo)
|
||||||
|
if "owner" in tokenInfo and tokenInfo.get("owner") == VOID_ADDRESS:
|
||||||
|
raise Exception('Invalid token: Owner address is void: %s', tokenInfo)
|
||||||
|
|
||||||
def extract_token(wallet_name, token_data):
|
def extract_token(wallet_name, token_data):
|
||||||
description= 'No description available' if 'description' not in token_data['tokenInfo'] else token_data['tokenInfo']['description']
|
description= 'No description available' if 'description' not in token_data['tokenInfo'] else token_data['tokenInfo']['description']
|
||||||
symbol= 'No Symbol' if 'symbol' not in token_data['tokenInfo'] else token_data['tokenInfo']['symbol']
|
symbol= 'No Symbol' if 'symbol' not in token_data['tokenInfo'] else token_data['tokenInfo']['symbol']
|
||||||
try:
|
try:
|
||||||
if token_data['tokenInfo']['decimals'] == '22270923681254677845691103109158760375340177724800803888364822332811285364736':
|
check_token_validity(token_data['tokenInfo'])
|
||||||
# The data is not valid, droping it.
|
|
||||||
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'],
|
||||||
|
|
Loading…
Reference in New Issue