chainlib

Generic blockchain access library and tooling
Log | Files | Refs | README | LICENSE

commit e0dc8e0192c319c9c1d6d98922333d098184ef84
parent 023504bc5d5e8c6ca36159a5100ce1a331607739
Author: nolash <dev@holbrook.no>
Date:   Thu, 11 Feb 2021 12:43:54 +0100

Move hash wrappers to agnostic package

Diffstat:
Mchainlib/eth/erc20.py | 2+-
Mchainlib/eth/gas.py | 2+-
Mchainlib/eth/tx.py | 28+++++++++++++++++++++++++---
Rchainlib/eth/hash.py -> chainlib/hash.py | 0
Msetup.cfg | 2+-
5 files changed, 28 insertions(+), 6 deletions(-)

diff --git a/chainlib/eth/erc20.py b/chainlib/eth/erc20.py @@ -5,7 +5,7 @@ from eth_abi import encode_single from crypto_dev_signer.eth.transaction import EIP155Transaction # local imports -from .hash import ( +from chainlib.hash import ( keccak256_hex_to_hex, keccak256_string_to_hex, ) diff --git a/chainlib/eth/gas.py b/chainlib/eth/gas.py @@ -8,7 +8,7 @@ from crypto_dev_signer.eth.transaction import EIP155Transaction # local imports from chainlib.eth.rpc import jsonrpc_template from chainlib.eth.tx import TxFactory -from chainlib.eth.hash import keccak256_hex_to_hex +from chainlib.hash import keccak256_hex_to_hex def price(): diff --git a/chainlib/eth/tx.py b/chainlib/eth/tx.py @@ -15,6 +15,7 @@ from .address import to_checksum from .constant import ( MINIMUM_FEE_UNITS, MINIMUM_FEE_PRICE, + ZERO_ADDRESS, ) logg = logging.getLogger(__name__) @@ -142,10 +143,31 @@ class Tx: def __init__(self, src, block): self.index = int(strip_0x(src['transactionIndex']), 16) - self.nonce = src['nonce'] - self.hash = src['hash'] + self.value = int(strip_0x(src['value']), 16) + self.nonce = int(strip_0x(src['nonce']), 16) + self.hash = strip_0x(src['hash']) + self.outputs = [strip_0x(src['from'])] + + inpt = src['input'] + if inpt != '0x': + inpt = strip_0x(inpt) + else: + inpt = None + self.payload = inpt + + to = src['to'] + if to == None: + to = ZERO_ADDRESS + self.inputs = [strip_0x(to)] + self.block = block + self.wire = src['raw'] + self.src = src - def __str__(self): + def __repr__(self): return 'block {} tx {} {}'.format(self.block.number, self.index, self.hash) + + + def __str__(self): + return 'from {} to {} value {} input {}'.format(self.outputs[0], self.inputs[0], self.value, self.payload) diff --git a/chainlib/eth/hash.py b/chainlib/hash.py diff --git a/setup.cfg b/setup.cfg @@ -1,6 +1,6 @@ [metadata] name = chainlib -version = 0.0.1a5 +version = 0.0.1a6 description = Generic blockchain access library and tooling author = Louis Holbrook author_email = dev@holbrook.no