chainlib-eth

Ethereum implementation of the chainlib interface
Info | Log | Files | Refs | README | LICENSE

decode.py (515B)


      1 # external imports
      2 from hexathon import (
      3         strip_0x,
      4         add_0x,
      5         )
      6 
      7 # local imports
      8 from chainlib.eth.tx import unpack
      9 from chainlib.eth.tx import Tx
     10 
     11 
     12 def decode_for_puny_humans(tx_raw, chain_spec, writer, fields=None, skip_keys=False):
     13     tx_raw = strip_0x(tx_raw)
     14     tx_raw_bytes = bytes.fromhex(tx_raw)
     15     tx_src = unpack(tx_raw_bytes, chain_spec)
     16     tx = Tx.from_src(tx_src, chain_spec=chain_spec)
     17     writer.write(tx.to_human(fields=fields, skip_keys=skip_keys))
     18     writer.write('\n')