Adds rudimentary fix for "parse_gifto" method.
This commit is contained in:
parent
3aaa42a1a7
commit
b8fbf512fb
@ -10,6 +10,7 @@ from chainlib.eth.error import RequestMismatchException
|
|||||||
from chainlib.eth.constant import ZERO_ADDRESS
|
from chainlib.eth.constant import ZERO_ADDRESS
|
||||||
from chainlib.eth.erc20 import ERC20
|
from chainlib.eth.erc20 import ERC20
|
||||||
from hexathon import strip_0x
|
from hexathon import strip_0x
|
||||||
|
from sarafu_faucet import MinterFaucet as Faucet
|
||||||
|
|
||||||
# local imports
|
# local imports
|
||||||
from .base import SyncFilter
|
from .base import SyncFilter
|
||||||
@ -39,23 +40,19 @@ def parse_transferfrom(tx):
|
|||||||
|
|
||||||
|
|
||||||
def parse_giftto(tx):
|
def parse_giftto(tx):
|
||||||
# TODO: broken
|
r = Faucet.parse_give_to_request(tx.payload)
|
||||||
logg.error('broken')
|
logg.debug(f'TOKEN GIFT TX: {tx}')
|
||||||
return
|
transfer_data = {}
|
||||||
transfer_data = unpack_gift(tx.payload)
|
logg.debug(f'TOKEN GIFT DATA START: {transfer_data}')
|
||||||
transfer_data['from'] = tx.inputs[0]
|
transfer_data['to'] = r[0]
|
||||||
transfer_data['value'] = 0
|
logg.debug(f'TOKEN GIFT DATA TO: {transfer_data}')
|
||||||
transfer_data['token_address'] = ZERO_ADDRESS
|
transfer_data['value'] = tx['value']
|
||||||
# TODO: would be better to query the gift amount from the block state
|
logg.debug(f'TOKEN GIFT DATA VALUE: {transfer_data}')
|
||||||
for l in tx.logs:
|
transfer_data['from'] = tx['from']
|
||||||
topics = l['topics']
|
logg.debug(f'TOKEN GIFT DATA FROM: {transfer_data}')
|
||||||
logg.debug('topixx {}'.format(topics))
|
transfer_data['token_address'] = tx['to']
|
||||||
if strip_0x(topics[0]) == '45c201a59ac545000ead84f30b2db67da23353aa1d58ac522c48505412143ffa':
|
logg.debug(f'TOKEN GIFT DATA TO: {transfer_data}')
|
||||||
#transfer_data['value'] = web3.Web3.toInt(hexstr=strip_0x(l['data']))
|
logg.debug(f'TOKEN GIFT DATA FINAL: {transfer_data}')
|
||||||
transfer_data['value'] = int.from_bytes(bytes.fromhex(strip_0x(l_data)))
|
|
||||||
#token_address_bytes = topics[2][32-20:]
|
|
||||||
token_address = strip_0x(topics[2])[64-40:]
|
|
||||||
transfer_data['token_address'] = to_checksum_address(token_address)
|
|
||||||
return ('tokengift', transfer_data)
|
return ('tokengift', transfer_data)
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user