Compare commits

...

1 Commits

Author SHA1 Message Date
lash
1efc936085
Make block by number compatible with geth 2022-02-12 12:30:13 +00:00
6 changed files with 24 additions and 11 deletions

View File

@ -1,5 +1,8 @@
- 0.0.23:
* Make get block args and responses compatible with picky golang marhaling in geth
- 0.0.22:
* Enable unpack of pre EIP-155 transactions
* Allow missing status property of receipts in non-strict modes
- 0.0.21:
* Remove warnings from cytoolz/rlp in funga-eth
- 0.0.15:

View File

@ -4,7 +4,7 @@ from chainlib.block import Block as BaseBlock
from hexathon import (
add_0x,
strip_0x,
even,
compact,
)
# local imports
@ -34,7 +34,9 @@ def block_by_hash(hsh, include_tx=True, id_generator=None):
def block_by_number(n, include_tx=True, id_generator=None):
"""Implements chainlib.interface.ChainInterface method
"""
nhx = add_0x(even(hex(n)[2:]))
hx = strip_0x(hex(n))
nhx = add_0x(compact(hx), compact_value=True)
print('>>>>> hx {}'.format(hx))
j = JSONRPCRequest(id_generator)
o = j.template()
o['method'] = 'eth_getBlockByNumber'

View File

@ -105,7 +105,10 @@ def main():
o = block_latest(id_generator=rpc.id_generator)
r = conn.do(o)
n = int(r, 16)
try:
n = int(r, 16)
except ValueError:
n = int(r)
first_block_number = n
if human:
n = format(n, ',')

View File

@ -519,7 +519,7 @@ class Tx(BaseTx):
#:todo: divide up constructor method
"""
def __init__(self, src, block=None, rcpt=None):
def __init__(self, src, block=None, rcpt=None, strict=False):
self.__rcpt_block_hash = None
src = self.src_normalize(src)
@ -575,7 +575,7 @@ class Tx(BaseTx):
self.logs = None
if rcpt != None:
self.apply_receipt(rcpt)
self.apply_receipt(rcpt, strict=strict)
self.v = src.get('v')
self.r = src.get('r')
@ -618,7 +618,7 @@ class Tx(BaseTx):
return self.src()
def apply_receipt(self, rcpt):
def apply_receipt(self, rcpt, strict=False):
"""Apply receipt data to transaction object.
Effect is the same as passing a receipt at construction.
@ -642,6 +642,12 @@ class Tx(BaseTx):
status_number = int(rcpt['status'], 16)
except TypeError:
status_number = int(rcpt['status'])
except KeyError as e:
if strict:
raise(e)
logg.warning('setting "sucess" status on missing status property for {}'.format(self.hash))
status_number = 1
if rcpt['block_number'] == None:
self.status = Status.PENDING
else:
@ -696,12 +702,12 @@ class Tx(BaseTx):
@staticmethod
def from_src(src, block=None, rcpt=None):
def from_src(src, block=None, rcpt=None, strict=False):
"""Creates a new Tx object.
Alias of constructor.
"""
return Tx(src, block=block, rcpt=rcpt)
return Tx(src, block=block, rcpt=rcpt, strict=strict)
def __str__(self):

View File

@ -1,6 +1,6 @@
funga-eth~=0.5.3
pysha3==1.0.2
hexathon~=0.1.1
hexathon~=0.1.2
websocket-client==0.57.0
potaahto~=0.1.0
chainlib~=0.0.17

View File

@ -1,6 +1,6 @@
[metadata]
name = chainlib-eth
version = 0.0.22
version = 0.0.23
description = Ethereum implementation of the chainlib interface
author = Louis Holbrook
author_email = dev@holbrook.no
@ -48,4 +48,3 @@ console_scripts =
eth-info = chainlib.eth.runnable.info:main
eth-nonce = chainlib.eth.runnable.count:main
eth-wait = chainlib.eth.runnable.wait:main
eth = chainlib.eth.runnable.info:main