changed try/except for approve
This commit is contained in:
parent
f2aef7e590
commit
eb79b433a4
1 changed files with 5 additions and 5 deletions
10
core.py
10
core.py
|
|
@ -61,15 +61,15 @@ def approve_token_spending(account, token_address, spender_address, amount, atte
|
||||||
token_info = get_token_info(token_address)
|
token_info = get_token_info(token_address)
|
||||||
token_amount = to_token_decimals(amount, token_info['decimals'])
|
token_amount = to_token_decimals(amount, token_info['decimals'])
|
||||||
if token_contract.functions.allowance(account.address, spender_address).call() < token_amount:
|
if token_contract.functions.allowance(account.address, spender_address).call() < token_amount:
|
||||||
tx = token_contract.functions.approve(spender_address, token_amount).build_transaction({
|
|
||||||
'nonce': get_nonce(account.address),
|
|
||||||
'from': account.address
|
|
||||||
})
|
|
||||||
try:
|
try:
|
||||||
|
tx = token_contract.functions.approve(spender_address, token_amount).build_transaction({
|
||||||
|
'nonce': get_nonce(account.address),
|
||||||
|
'from': account.address
|
||||||
|
})
|
||||||
return broadcast_transaction(account, tx, True, attempts)
|
return broadcast_transaction(account, tx, True, attempts)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
if error := interpret_exception_message(e):
|
if error := interpret_exception_message(e):
|
||||||
logging.error("{} to approve {} ({})".format(error, token_info['name'], token_info['symbol']))
|
logging.error("{}. Failed to approve {} ({})".format(error, token_info['name'], token_info['symbol']))
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue