Add noarg tx helpers, bytes32 in decoder
This commit is contained in:
parent
3e3a351c2d
commit
5bac222e9c
@ -57,6 +57,10 @@ class ABIContractDecoder:
|
|||||||
return int(v, 16)
|
return int(v, 16)
|
||||||
|
|
||||||
|
|
||||||
|
def bytes32(self, v):
|
||||||
|
return v
|
||||||
|
|
||||||
|
|
||||||
def bool(self, v):
|
def bool(self, v):
|
||||||
return bool(self.uint256(v))
|
return bool(self.uint256(v))
|
||||||
|
|
||||||
|
@ -47,6 +47,7 @@ class Gas(TxFactory):
|
|||||||
tx_raw_hex = add_0x(tx_raw.hex())
|
tx_raw_hex = add_0x(tx_raw.hex())
|
||||||
tx_hash_hex = add_0x(keccak256_hex_to_hex(tx_raw_hex))
|
tx_hash_hex = add_0x(keccak256_hex_to_hex(tx_raw_hex))
|
||||||
|
|
||||||
|
o = None
|
||||||
if tx_format == TxFormat.JSONRPC:
|
if tx_format == TxFormat.JSONRPC:
|
||||||
o = raw(tx_raw_hex)
|
o = raw(tx_raw_hex)
|
||||||
elif tx_format == TxFormat.RLP_SIGNED:
|
elif tx_format == TxFormat.RLP_SIGNED:
|
||||||
|
@ -26,6 +26,7 @@ from .constant import (
|
|||||||
MINIMUM_FEE_PRICE,
|
MINIMUM_FEE_PRICE,
|
||||||
ZERO_ADDRESS,
|
ZERO_ADDRESS,
|
||||||
)
|
)
|
||||||
|
from .contract import ABIContractEncoder
|
||||||
from chainlib.jsonrpc import jsonrpc_template
|
from chainlib.jsonrpc import jsonrpc_template
|
||||||
|
|
||||||
logg = logging.getLogger().getChild(__name__)
|
logg = logging.getLogger().getChild(__name__)
|
||||||
@ -272,6 +273,29 @@ class TxFactory:
|
|||||||
return tx
|
return tx
|
||||||
|
|
||||||
|
|
||||||
|
def transact_noarg(self, method, contract_address, sender_address, tx_format=TxFormat.JSONRPC):
|
||||||
|
enc = ABIContractEncoder()
|
||||||
|
enc.method(method)
|
||||||
|
data = enc.get()
|
||||||
|
tx = self.template(sender_address, contract_address, use_nonce=True)
|
||||||
|
tx = self.set_code(tx, data)
|
||||||
|
tx = self.finalize(tx, tx_format)
|
||||||
|
return tx
|
||||||
|
|
||||||
|
|
||||||
|
def call_noarg(self, method, contract_address, sender_address=ZERO_ADDRESS):
|
||||||
|
o = jsonrpc_template()
|
||||||
|
o['method'] = 'eth_call'
|
||||||
|
enc = ABIContractEncoder()
|
||||||
|
enc.method(method)
|
||||||
|
data = add_0x(enc.get())
|
||||||
|
tx = self.template(sender_address, contract_address)
|
||||||
|
tx = self.set_code(tx, data)
|
||||||
|
o['params'].append(self.normalize(tx))
|
||||||
|
o['params'].append('latest')
|
||||||
|
return o
|
||||||
|
|
||||||
|
|
||||||
class Tx:
|
class Tx:
|
||||||
|
|
||||||
# TODO: force tx type schema parser (whether expect hex or int etc)
|
# TODO: force tx type schema parser (whether expect hex or int etc)
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
[metadata]
|
[metadata]
|
||||||
name = chainlib
|
name = chainlib
|
||||||
version = 0.0.3rc2
|
version = 0.0.3rc3
|
||||||
description = Generic blockchain access library and tooling
|
description = Generic blockchain access library and tooling
|
||||||
author = Louis Holbrook
|
author = Louis Holbrook
|
||||||
author_email = dev@holbrook.no
|
author_email = dev@holbrook.no
|
||||||
|
Loading…
Reference in New Issue
Block a user