reorganized functions
This commit is contained in:
parent
f91be09de4
commit
44ff8514c2
1 changed files with 10 additions and 10 deletions
20
core.py
20
core.py
|
|
@ -418,16 +418,6 @@ def get_token_balance(token_address, wallet_address, decimals=False):
|
||||||
return float(round(from_token_decimals(token_balance, token_info['decimals']), 15))
|
return float(round(from_token_decimals(token_balance, token_info['decimals']), 15))
|
||||||
|
|
||||||
|
|
||||||
def get_token_supply(token_address, decimals=False):
|
|
||||||
token_contract = load_contract(token_address)
|
|
||||||
token_info = get_token_info(token_address)
|
|
||||||
token_supply = token_contract.functions.totalSupply().call()
|
|
||||||
if decimals:
|
|
||||||
return token_supply
|
|
||||||
else:
|
|
||||||
return float(round(from_token_decimals(token_supply, token_info['decimals']), 15))
|
|
||||||
|
|
||||||
|
|
||||||
def get_token_info(token_address, attempts=18):
|
def get_token_info(token_address, attempts=18):
|
||||||
os.makedirs(token_folder := "./data/tokens".format(token_address), exist_ok=True)
|
os.makedirs(token_folder := "./data/tokens".format(token_address), exist_ok=True)
|
||||||
token_info_file = "{}/{}.json".format(token_folder, token_address)
|
token_info_file = "{}/{}.json".format(token_folder, token_address)
|
||||||
|
|
@ -469,6 +459,16 @@ def get_token_info(token_address, attempts=18):
|
||||||
return token_info
|
return token_info
|
||||||
|
|
||||||
|
|
||||||
|
def get_token_supply(token_address, decimals=False):
|
||||||
|
token_contract = load_contract(token_address)
|
||||||
|
token_info = get_token_info(token_address)
|
||||||
|
token_supply = token_contract.functions.totalSupply().call()
|
||||||
|
if decimals:
|
||||||
|
return token_supply
|
||||||
|
else:
|
||||||
|
return float(round(from_token_decimals(token_supply, token_info['decimals']), 15))
|
||||||
|
|
||||||
|
|
||||||
def interpret_exception_message(e):
|
def interpret_exception_message(e):
|
||||||
logging.debug(e)
|
logging.debug(e)
|
||||||
if 'insufficient funds for gas * price + value' in str(e):
|
if 'insufficient funds for gas * price + value' in str(e):
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue