Add decimal bug in balance script, add receipts to tx + status enum
This commit is contained in:
parent
244b3f0a93
commit
50edca7106
@ -88,7 +88,7 @@ def main():
|
|||||||
|
|
||||||
balance_str = str(balance)
|
balance_str = str(balance)
|
||||||
balance_len = len(balance_str)
|
balance_len = len(balance_str)
|
||||||
if balance_len < 19:
|
if balance_len < decimals + 1:
|
||||||
print('0.{}'.format(balance_str.zfill(decimals)))
|
print('0.{}'.format(balance_str.zfill(decimals)))
|
||||||
else:
|
else:
|
||||||
offset = balance_len-decimals
|
offset = balance_len-decimals
|
||||||
|
@ -16,6 +16,7 @@ from crypto_dev_signer.eth.transaction import EIP155Transaction
|
|||||||
|
|
||||||
# local imports
|
# local imports
|
||||||
from chainlib.hash import keccak256_hex_to_hex
|
from chainlib.hash import keccak256_hex_to_hex
|
||||||
|
from chainlib.status import Status
|
||||||
from .address import to_checksum
|
from .address import to_checksum
|
||||||
from .constant import (
|
from .constant import (
|
||||||
MINIMUM_FEE_UNITS,
|
MINIMUM_FEE_UNITS,
|
||||||
@ -97,7 +98,7 @@ def unpack(tx_raw_bytes, chain_id=1):
|
|||||||
def receipt(hsh):
|
def receipt(hsh):
|
||||||
o = jsonrpc_template()
|
o = jsonrpc_template()
|
||||||
o['method'] = 'eth_getTransactionReceipt'
|
o['method'] = 'eth_getTransactionReceipt'
|
||||||
o['params'].append(hsh)
|
o['params'].append(add_0x(hsh))
|
||||||
return o
|
return o
|
||||||
|
|
||||||
|
|
||||||
@ -173,9 +174,8 @@ class TxFactory:
|
|||||||
|
|
||||||
class Tx:
|
class Tx:
|
||||||
|
|
||||||
def __init__(self, src, block=None):
|
def __init__(self, src, block=None, rcpt=None):
|
||||||
self.index = -1
|
self.index = -1
|
||||||
self.status = -1
|
|
||||||
if block != None:
|
if block != None:
|
||||||
self.index = int(strip_0x(src['transactionIndex']), 16)
|
self.index = int(strip_0x(src['transactionIndex']), 16)
|
||||||
self.value = int(strip_0x(src['value']), 16)
|
self.value = int(strip_0x(src['value']), 16)
|
||||||
@ -202,6 +202,20 @@ class Tx:
|
|||||||
self.wire = src['raw']
|
self.wire = src['raw']
|
||||||
self.src = src
|
self.src = src
|
||||||
|
|
||||||
|
self.status = Status.PENDING
|
||||||
|
self.logs = None
|
||||||
|
|
||||||
|
if rcpt != None:
|
||||||
|
self.apply_receipt(rcpt)
|
||||||
|
|
||||||
|
|
||||||
|
def apply_receipt(self, rcpt):
|
||||||
|
if rcpt['status'] == 1:
|
||||||
|
self.status = Status.SUCCESS
|
||||||
|
elif rcpt['status'] == 0:
|
||||||
|
self.status = Status.PENDING
|
||||||
|
self.logs = rcpt['logs']
|
||||||
|
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return 'block {} tx {} {}'.format(self.block.number, self.index, self.hash)
|
return 'block {} tx {} {}'.format(self.block.number, self.index, self.hash)
|
||||||
|
Loading…
Reference in New Issue
Block a user