Compare commits
1 Commits
Author | SHA1 | Date |
---|---|---|
lash | 4f35bc2b5a |
|
@ -2,5 +2,3 @@ __pycache__
|
||||||
*.egg-info
|
*.egg-info
|
||||||
*.pyc
|
*.pyc
|
||||||
*.d/
|
*.d/
|
||||||
.venv
|
|
||||||
state
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
- 0.0.2
|
||||||
|
* Upgrade eth-monitor support to 0.1.0 target
|
||||||
|
- 0.0.1
|
||||||
|
* Add renderers for account registry add, faucet gift
|
|
@ -9,7 +9,7 @@ from cic_contracts.erc20 import ERC20
|
||||||
from chainlib.eth.error import RequestMismatchException
|
from chainlib.eth.error import RequestMismatchException
|
||||||
from chainlib.eth.address import AddressChecksum
|
from chainlib.eth.address import AddressChecksum
|
||||||
from chainlib.eth.constant import ZERO_ADDRESS
|
from chainlib.eth.constant import ZERO_ADDRESS
|
||||||
from hexathon import uniform, add_0x
|
from hexathon import uniform
|
||||||
|
|
||||||
logg = logging.getLogger(__name__)
|
logg = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
@ -38,34 +38,32 @@ def get_method(chain_str, tx):
|
||||||
return chainmap.get(data)
|
return chainmap.get(data)
|
||||||
|
|
||||||
|
|
||||||
def apply(c, s, chain_spec, conn, block, tx, db_session=None):
|
def apply(c, result, chain_spec, conn, block, tx, db_session=None):
|
||||||
|
s = result.get()
|
||||||
try:
|
try:
|
||||||
m = get_method(str(chain_spec), tx)
|
m = get_method(str(chain_spec), tx)
|
||||||
except ValueError as e:
|
except ValueError as e:
|
||||||
return s
|
return True
|
||||||
|
|
||||||
if m == None:
|
if m == None:
|
||||||
return s
|
return True
|
||||||
|
|
||||||
r = m(c, s, chain_spec, conn, block, tx)
|
r = m(c, result, chain_spec, conn, block, tx)
|
||||||
if r != None:
|
return r
|
||||||
s = r
|
|
||||||
|
|
||||||
return s
|
|
||||||
|
|
||||||
|
|
||||||
def account_registry_add(c, s, chain_spec, conn, block, tx):
|
def account_registry_add(c, result, chain_spec, conn, block, tx):
|
||||||
try:
|
try:
|
||||||
o = AccountsIndex.parse_add_request(tx.payload)
|
o = AccountsIndex.parse_add_request(tx.payload)
|
||||||
s = '{} block {} tx {} account registration for {}'.format(c, block.number, tx.index, o[0])
|
s = '{} block {} tx {} account registration for {}'.format(c, block.number, tx.index, o[0])
|
||||||
return s
|
result.set(s)
|
||||||
except RequestMismatchException as e:
|
except RequestMismatchException as e:
|
||||||
pass
|
return True
|
||||||
|
|
||||||
return None
|
return False
|
||||||
|
|
||||||
|
|
||||||
def ge_faucet_gift(i, s, chain_spec, conn, block, tx):
|
def ge_faucet_gift(i, result, chain_spec, conn, block, tx):
|
||||||
|
|
||||||
c = Faucet(chain_spec)
|
c = Faucet(chain_spec)
|
||||||
o = c.token_amount(tx.inputs[0], sender_address=ZERO_ADDRESS, height=block.number)
|
o = c.token_amount(tx.inputs[0], sender_address=ZERO_ADDRESS, height=block.number)
|
||||||
|
@ -94,43 +92,24 @@ def ge_faucet_gift(i, s, chain_spec, conn, block, tx):
|
||||||
try:
|
try:
|
||||||
o = Faucet.parse_give_to_request(tx.payload)
|
o = Faucet.parse_give_to_request(tx.payload)
|
||||||
s = '{} GE faucet was triggered for {} {} by {} on block {} tx {}'.format(i, v, token_symbol, o[0], block.number, tx.index)
|
s = '{} GE faucet was triggered for {} {} by {} on block {} tx {}'.format(i, v, token_symbol, o[0], block.number, tx.index)
|
||||||
return s
|
result.set(s)
|
||||||
except RequestMismatchException as e:
|
except RequestMismatchException as e:
|
||||||
pass
|
return True
|
||||||
|
|
||||||
return None
|
return False
|
||||||
|
|
||||||
|
|
||||||
def erc20_transfer(c, s, chain_spec, conn, block, tx):
|
|
||||||
t = ERC20(chain_spec)
|
|
||||||
|
|
||||||
try:
|
|
||||||
transfer_data = t.parse_transfer_request(tx.payload)
|
|
||||||
|
|
||||||
token_sender = tx.outputs[0]
|
|
||||||
token_recipient = transfer_data[0]
|
|
||||||
token_value = transfer_data[1]
|
|
||||||
|
|
||||||
return '{} GFT {} sent from {} to {}'.format(c, token_value ,add_0x(token_sender), add_0x(token_recipient))
|
|
||||||
except RequestMismatchException as e:
|
|
||||||
pass
|
|
||||||
|
|
||||||
return None
|
|
||||||
|
|
||||||
|
|
||||||
sigmap = {
|
sigmap = {
|
||||||
'evm:byzantium:8996:bloxberg': {
|
'evm:kitabu:5050:sarafu': {
|
||||||
'0a3b0a4f': account_registry_add,
|
'0a3b0a4f': account_registry_add,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
addrmap = {
|
addrmap = {
|
||||||
'evm:byzantium:8996:bloxberg': {
|
'evm:kitabu:5050:sarafu': {
|
||||||
'd462aadb7251d418e6a9e4f205928f678e1c6b3b': {
|
'd462aadb7251d418e6a9e4f205928f678e1c6b3b': {
|
||||||
'63e4bff4': ge_faucet_gift,
|
'63e4bff4': ge_faucet_gift,
|
||||||
},
|
},
|
||||||
'32e860c2a0645d1b7b005273696905f5d6dc5d05': {
|
}
|
||||||
'a9059cbb': erc20_transfer,
|
}
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
eth-monitor~=0.0.6
|
|
||||||
eth_accounts_index~=0.1.2
|
eth_accounts_index~=0.1.2
|
||||||
erc20-faucet~=0.3.2
|
erc20-faucet~=0.3.2
|
||||||
cic-contracts~=0.0.5
|
cic-contracts~=0.0.5
|
||||||
|
|
Loading…
Reference in New Issue