transaction handling touchups
This commit is contained in:
@@ -60,6 +60,7 @@ def setup_logevent_triggers(runner):
|
||||
|
||||
runner.add_callback(check_activate_orders)
|
||||
runner.add_callback(init)
|
||||
|
||||
runner.add_event_trigger(handle_vault_created, get_contract_event('Vault', 'VaultCreated'))
|
||||
runner.add_event_trigger(handle_vault_impl_changed, get_contract_event('Vault', 'VaultImplChanged'))
|
||||
runner.add_event_trigger(handle_order_placed, get_contract_event('VaultImpl', 'DexorderSwapPlaced'))
|
||||
@@ -69,7 +70,7 @@ def setup_logevent_triggers(runner):
|
||||
runner.add_event_trigger(handle_order_canceled, get_contract_event('VaultImpl', 'DexorderSwapCanceled'))
|
||||
runner.add_event_trigger(handle_order_cancel_all, get_contract_event('VaultImpl', 'DexorderCancelAll'))
|
||||
|
||||
runner.add_event_trigger(handle_transaction_receipts) # todo handle only the transactions that were posted to this block
|
||||
runner.add_event_trigger(handle_transaction_receipts)
|
||||
runner.add_event_trigger(handle_dexorderexecutions, executions)
|
||||
runner.add_event_trigger(handle_vault_creation_requests)
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ from uuid import uuid4
|
||||
from web3.exceptions import TransactionNotFound, ContractPanicError, ContractLogicError
|
||||
|
||||
from dexorder import db, current_w3, Account
|
||||
from dexorder.alert import warningAlert
|
||||
from dexorder.base import TransactionReceiptDict, TransactionRequest
|
||||
from dexorder.base.chain import current_chain
|
||||
from dexorder.blockstate.fork import current_fork
|
||||
@@ -113,10 +114,16 @@ async def create_and_send_transactions():
|
||||
try:
|
||||
sent = await w3.eth.send_raw_transaction(ctx.data)
|
||||
except ValueError as e:
|
||||
if e.args[0]['code'] == -32003:
|
||||
try:
|
||||
msg = e.args[0].get('message','')
|
||||
except IndexError:
|
||||
msg = ''
|
||||
if msg.startswith('nonce too low'):
|
||||
# Nonce too low
|
||||
log.warning(f'Account {account.address} nonce too low')
|
||||
account.reset_nonce()
|
||||
elif msg.startswith('insufficient funds'):
|
||||
warningAlert('Account Empty', f'Account {account.address} is out of funds!')
|
||||
else:
|
||||
log.exception(f'Failure sending transaction for job {job.id}')
|
||||
await handler.release_account(account)
|
||||
|
||||
Reference in New Issue
Block a user