Move hash wrappers to agnostic package

This commit is contained in:
nolash 2021-02-11 12:43:54 +01:00
parent 023504bc5d
commit e0dc8e0192
Signed by: lash
GPG Key ID: 21D2E7BB88C2A746
5 changed files with 28 additions and 6 deletions

View File

@ -5,7 +5,7 @@ from eth_abi import encode_single
from crypto_dev_signer.eth.transaction import EIP155Transaction from crypto_dev_signer.eth.transaction import EIP155Transaction
# local imports # local imports
from .hash import ( from chainlib.hash import (
keccak256_hex_to_hex, keccak256_hex_to_hex,
keccak256_string_to_hex, keccak256_string_to_hex,
) )

View File

@ -8,7 +8,7 @@ from crypto_dev_signer.eth.transaction import EIP155Transaction
# local imports # local imports
from chainlib.eth.rpc import jsonrpc_template from chainlib.eth.rpc import jsonrpc_template
from chainlib.eth.tx import TxFactory 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(): def price():

View File

@ -15,6 +15,7 @@ from .address import to_checksum
from .constant import ( from .constant import (
MINIMUM_FEE_UNITS, MINIMUM_FEE_UNITS,
MINIMUM_FEE_PRICE, MINIMUM_FEE_PRICE,
ZERO_ADDRESS,
) )
logg = logging.getLogger(__name__) logg = logging.getLogger(__name__)
@ -142,10 +143,31 @@ class Tx:
def __init__(self, src, block): def __init__(self, src, block):
self.index = int(strip_0x(src['transactionIndex']), 16) self.index = int(strip_0x(src['transactionIndex']), 16)
self.nonce = src['nonce'] self.value = int(strip_0x(src['value']), 16)
self.hash = src['hash'] 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.block = block
self.wire = src['raw']
self.src = src
def __repr__(self):
return 'block {} tx {} {}'.format(self.block.number, self.index, self.hash)
def __str__(self): def __str__(self):
return 'block {} tx {} {}'.format(self.block.number, self.index, self.hash) return 'from {} to {} value {} input {}'.format(self.outputs[0], self.inputs[0], self.value, self.payload)

View File

@ -1,6 +1,6 @@
[metadata] [metadata]
name = chainlib name = chainlib
version = 0.0.1a5 version = 0.0.1a6
description = Generic blockchain access library and tooling description = Generic blockchain access library and tooling
author = Louis Holbrook author = Louis Holbrook
author_email = dev@holbrook.no author_email = dev@holbrook.no