chainlib-eth

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

commit c954f4d1b4610c558226e754c89f4135fa5d2240
parent b59eebe181b50a6467047b669e760900f7c5d5a2
Author: lash <dev@holbrook.no>
Date:   Tue,  1 Mar 2022 07:50:30 +0000

Allow encode without nonce when not tx, add rcpt src to tx

Diffstat:
MCHANGELOG | 3+++
Mchainlib/eth/runnable/encode.py | 13++++++++-----
Mchainlib/eth/tx.py | 10++++++++--
Msetup.cfg | 2+-
4 files changed, 20 insertions(+), 8 deletions(-)

diff --git a/CHANGELOG b/CHANGELOG @@ -1,3 +1,6 @@ +- 0.1.0: + * Allow nonce ommission in encode when not tx mode + * Add rcpt src to tx object - 0.0.27: * Add man pages with chainlib man page generator helper * Remove redundant arg flags from runnables: get diff --git a/chainlib/eth/runnable/encode.py b/chainlib/eth/runnable/encode.py @@ -11,8 +11,7 @@ import urllib import sha3 # external imports -import chainlib.eth.cli -from chainlib.eth.cli.encode import CLIEncoder +from chainlib.cli import flag_reset from funga.eth.signer import EIP155Signer from funga.eth.keystore.dict import DictKeystore from hexathon import ( @@ -21,6 +20,8 @@ from hexathon import ( ) # local imports +import chainlib.eth.cli +from chainlib.eth.cli.encode import CLIEncoder from chainlib.eth.constant import ZERO_ADDRESS from chainlib.eth.address import to_checksum from chainlib.eth.connection import EthHTTPConnection @@ -47,6 +48,7 @@ config_dir = os.path.join(script_dir, '..', 'data', 'config') arg_flags = chainlib.eth.cli.argflag_std_write | chainlib.eth.cli.Flag.EXEC | chainlib.eth.cli.Flag.FEE | chainlib.eth.cli.Flag.FMT_HUMAN | chainlib.eth.cli.Flag.FMT_WIRE | chainlib.eth.cli.Flag.FMT_RPC +arg_flags = flag_reset(arg_flags, chainlib.cli.Flag.NO_TARGET) argparser = chainlib.eth.cli.ArgumentParser(arg_flags) argparser.add_argument('--mode', type=str, choices=['tx', 'call', 'arg'], help='Mode of operation') argparser.add_argument('--signature', type=str, help='Method signature to encode') @@ -131,9 +133,10 @@ def main(): if not config.get('_FEE_LIMIT'): config.add(limit, '_FEE_LIMIT') - if not config.get('_NONCE'): - nonce_oracle = rpc.get_nonce_oracle() - config.add(nonce_oracle.get_nonce(), '_NONCE') + if mode == 'tx': + if not config.get('_NONCE'): + nonce_oracle = rpc.get_nonce_oracle() + config.add(nonce_oracle.get_nonce(), '_NONCE') else: for arg in [ '_FEE_PRICE', diff --git a/chainlib/eth/tx.py b/chainlib/eth/tx.py @@ -571,11 +571,12 @@ class Tx(BaseTx): try: self.wire = src['raw'] except KeyError: - logg.warning('no inline raw tx src, and no raw rendering implemented, field will be "None"') + logg.debug('no inline raw tx src, and no raw rendering implemented, field will be "None"') self.status = Status.PENDING self.logs = None + self.tx_rcpt_src = None if rcpt != None: self.apply_receipt(rcpt, strict=strict) @@ -620,6 +621,10 @@ class Tx(BaseTx): return self.src() + def rcpt_src(self): + return self.tx_rcpt_src + + def apply_receipt(self, rcpt, strict=False): """Apply receipt data to transaction object. @@ -630,6 +635,7 @@ class Tx(BaseTx): """ rcpt = self.src_normalize(rcpt) logg.debug('rcpt {}'.format(rcpt)) + self.tx_rcpt_src = rcpt tx_hash = add_0x(rcpt['transaction_hash']) if rcpt['transaction_hash'] != add_0x(self.hash): @@ -647,7 +653,7 @@ class Tx(BaseTx): except KeyError as e: if strict: raise(e) - logg.warning('setting "sucess" status on missing status property for {}'.format(self.hash)) + logg.debug('setting "success" status on missing status property for {}'.format(self.hash)) status_number = 1 if rcpt['block_number'] == None: diff --git a/setup.cfg b/setup.cfg @@ -1,6 +1,6 @@ [metadata] name = chainlib-eth -version = 0.0.27 +version = 0.1.0b2 description = Ethereum implementation of the chainlib interface author = Louis Holbrook author_email = dev@holbrook.no