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

This commit is contained in:
lash 2022-03-01 07:50:30 +00:00
parent b59eebe181
commit c954f4d1b4
Signed by: lash
GPG Key ID: 21D2E7BB88C2A746
4 changed files with 20 additions and 8 deletions

View File

@ -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

View File

@ -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',

View File

@ -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:

View File

@ -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