chainlib

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

commit 0c43d17816c0401357d708e0294997ab0b6eb9a1
parent 7838244a90f2c4f8482a56a337f15cf009d361a8
Author: nolash <dev@holbrook.no>
Date:   Wed, 17 Feb 2021 10:13:22 +0100

Bump registry

Diffstat:
Mchainlib/eth/runnable/decode.py | 4++--
Mchainlib/eth/tx.py | 15+++++++++++++--
Mrequirements.txt | 4++--
Msetup.cfg | 2+-
4 files changed, 18 insertions(+), 7 deletions(-)

diff --git a/chainlib/eth/runnable/decode.py b/chainlib/eth/runnable/decode.py @@ -16,7 +16,7 @@ import argparse import logging # third-party imports -from chainlib.eth.tx import unpack_signed +from chainlib.eth.tx import unpack logging.basicConfig(level=logging.WARNING) @@ -42,7 +42,7 @@ def main(): if tx_raw[:2] == '0x': tx_raw = tx_raw[2:] tx_raw_bytes = bytes.fromhex(tx_raw) - tx = unpack_signed(tx_raw_bytes, int(chain_id)) + tx = unpack(tx_raw_bytes, int(chain_id)) for k in tx.keys(): print('{}: {}'.format(k, tx[k])) diff --git a/chainlib/eth/tx.py b/chainlib/eth/tx.py @@ -39,7 +39,7 @@ field_debugs = [ 's', ] -def unpack_signed(tx_raw_bytes, chain_id=1): +def unpack(tx_raw_bytes, chain_id=1): d = rlp_decode(tx_raw_bytes) logg.debug('decoding using chain id {}'.format(chain_id)) @@ -94,6 +94,13 @@ def unpack_signed(tx_raw_bytes, chain_id=1): } +def receipt(hsh): + o = jsonrpc_template() + o['method'] = 'eth_getTransactionReceipt' + o['params'].append(hsh) + return o + + class TxFactory: def __init__(self, signer=None, gas_oracle=None, nonce_oracle=None, chain_id=1): @@ -103,12 +110,16 @@ class TxFactory: self.signer = signer - def build(self, tx): + def build_raw(self, tx): txe = EIP155Transaction(tx, tx['nonce'], tx['chainId']) self.signer.signTransaction(txe) tx_raw = txe.rlp_serialize() tx_raw_hex = add_0x(tx_raw.hex()) tx_hash_hex = add_0x(keccak256_hex_to_hex(tx_raw_hex)) + return (tx_hash_hex, tx_raw_hex) + + def build(self, tx): + (tx_hash_hex, tx_raw_hex) = self.build_raw(tx) o = jsonrpc_template() o['method'] = 'eth_sendRawTransaction' diff --git a/requirements.txt b/requirements.txt @@ -1,8 +1,8 @@ -cryptocurrency-cli-tools==0.0.4 +cryptocurrency-cli-tools~=0.0.4 faker==4.17.1 crypto-dev-signer~=0.4.13rc2 pysha3==1.0.2 -hexathon==0.0.1a2 +hexathon~=0.0.1a3 eth-abi==2.1.1 eth-keys==0.3.3 websocket-client==0.57.0 diff --git a/setup.cfg b/setup.cfg @@ -1,6 +1,6 @@ [metadata] name = chainlib -version = 0.0.1a11 +version = 0.0.1a12 description = Generic blockchain access library and tooling author = Louis Holbrook author_email = dev@holbrook.no