Add address filter on account registry match
This commit is contained in:
parent
021c736707
commit
c24543ca03
@ -12,20 +12,25 @@ from hexathon import (
|
|||||||
# local imports
|
# local imports
|
||||||
from .base import SyncFilter
|
from .base import SyncFilter
|
||||||
|
|
||||||
logg = logging.getLogger().getChild(__name__)
|
#logg = logging.getLogger(__name__)
|
||||||
|
logg = logging.getLogger()
|
||||||
|
|
||||||
account_registry_add_log_hash = '0x9cc987676e7d63379f176ea50df0ae8d2d9d1141d1231d4ce15b5965f73c9430'
|
account_registry_add_log_hash = '0x9cc987676e7d63379f176ea50df0ae8d2d9d1141d1231d4ce15b5965f73c9430'
|
||||||
|
|
||||||
|
|
||||||
class RegistrationFilter(SyncFilter):
|
class RegistrationFilter(SyncFilter):
|
||||||
|
|
||||||
def __init__(self, chain_spec, queue):
|
def __init__(self, chain_spec, contract_address, queue=None):
|
||||||
self.chain_spec = chain_spec
|
self.chain_spec = chain_spec
|
||||||
self.queue = queue
|
self.queue = queue
|
||||||
|
self.contract_address = contract_address
|
||||||
|
|
||||||
|
|
||||||
def filter(self, conn, block, tx, db_session=None):
|
def filter(self, conn, block, tx, db_session=None):
|
||||||
registered_address = None
|
if self.contract_address != tx.inputs[0]:
|
||||||
|
logg.debug('not an account registry tx; {} != {}'.format(self.contract_address, tx.inputs[0]))
|
||||||
|
return None
|
||||||
|
|
||||||
for l in tx.logs:
|
for l in tx.logs:
|
||||||
event_topic_hex = l['topics'][0]
|
event_topic_hex = l['topics'][0]
|
||||||
if event_topic_hex == account_registry_add_log_hash:
|
if event_topic_hex == account_registry_add_log_hash:
|
||||||
|
@ -1,3 +1,7 @@
|
|||||||
|
# standard imports
|
||||||
|
import logging
|
||||||
|
import os
|
||||||
|
|
||||||
# external imports
|
# external imports
|
||||||
from eth_accounts_index.registry import AccountRegistry
|
from eth_accounts_index.registry import AccountRegistry
|
||||||
from chainlib.connection import RPCConnection
|
from chainlib.connection import RPCConnection
|
||||||
@ -14,12 +18,17 @@ from chainlib.eth.block import (
|
|||||||
Block,
|
Block,
|
||||||
)
|
)
|
||||||
from erc20_faucet import Faucet
|
from erc20_faucet import Faucet
|
||||||
from hexathon import strip_0x
|
from hexathon import (
|
||||||
|
strip_0x,
|
||||||
|
add_0x,
|
||||||
|
)
|
||||||
from chainqueue.sql.query import get_account_tx
|
from chainqueue.sql.query import get_account_tx
|
||||||
|
|
||||||
# local imports
|
# local imports
|
||||||
from cic_eth.runnable.daemons.filters.register import RegistrationFilter
|
from cic_eth.runnable.daemons.filters.register import RegistrationFilter
|
||||||
|
|
||||||
|
logg = logging.getLogger()
|
||||||
|
|
||||||
|
|
||||||
def test_register_filter(
|
def test_register_filter(
|
||||||
default_chain_spec,
|
default_chain_spec,
|
||||||
@ -60,7 +69,11 @@ def test_register_filter(
|
|||||||
tx = Tx(tx_src, block=block, rcpt=rcpt)
|
tx = Tx(tx_src, block=block, rcpt=rcpt)
|
||||||
tx.apply_receipt(rcpt)
|
tx.apply_receipt(rcpt)
|
||||||
|
|
||||||
fltr = RegistrationFilter(default_chain_spec, queue=None)
|
fltr = RegistrationFilter(default_chain_spec, add_0x(os.urandom(20).hex()), queue=None)
|
||||||
|
t = fltr.filter(eth_rpc, block, tx, db_session=init_database)
|
||||||
|
assert t == None
|
||||||
|
|
||||||
|
fltr = RegistrationFilter(default_chain_spec, account_registry, queue=None)
|
||||||
t = fltr.filter(eth_rpc, block, tx, db_session=init_database)
|
t = fltr.filter(eth_rpc, block, tx, db_session=init_database)
|
||||||
|
|
||||||
t.get_leaf()
|
t.get_leaf()
|
||||||
|
Loading…
Reference in New Issue
Block a user