48 lines
1.1 KiB
Python
48 lines
1.1 KiB
Python
# standard imports
|
||
import logging
|
||
|
||
# external imports
|
||
from eth_accounts_index import AccountsIndex
|
||
from chainlib.eth.error import RequestMismatchException
|
||
|
||
logg = logging.getLogger(__name__)
|
||
|
||
|
||
def get_method(chain_str, tx):
|
||
data = tx.payload
|
||
s = None
|
||
if len(data) >= 8:
|
||
s = data[:8]
|
||
v = sigmap.get(chain_str)
|
||
if v != None:
|
||
return v.get(s)
|
||
raise ValueError('not minimum signature length')
|
||
|
||
|
||
def apply(c, s, chain_str, conn, block, tx, db_session=None):
|
||
try:
|
||
m = get_method(chain_str, tx)
|
||
except ValueError as e:
|
||
return s
|
||
|
||
if m == None:
|
||
return s
|
||
|
||
return m(c, s, conn, block, tx)
|
||
|
||
|
||
def account_registry_add(c, s, conn, block, tx):
|
||
try:
|
||
o = AccountsIndex.parse_add_request(tx.payload)
|
||
ss = '{} block {} tx {} account registration for {}'.format(c, block.number, tx.index, o[0])
|
||
return ss
|
||
except RequestMismatchException as e:
|
||
return None
|
||
|
||
|
||
sigmap = {
|
||
'evm:byzantium:8996:bloxberg': {
|
||
'0a3b0a4f': account_registry_add,
|
||
},
|
||
}
|