Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a392f80440
|
||
|
|
310ace8244
|
||
|
|
772781c1b8
|
@@ -1,3 +1,8 @@
|
||||
- 0.3.2
|
||||
* Fix crash when supplying block number to block cli tool
|
||||
* Allow non-pending nonce bootstrap
|
||||
- 0.3.1
|
||||
* Fix missing application of status on tx result
|
||||
- 0.3.0
|
||||
* Implement chainlib with new arg and config handling
|
||||
* Implement cli tools on settings module
|
||||
|
||||
@@ -23,7 +23,7 @@ class Rpc(BaseRpc):
|
||||
super(Rpc, self).__init__(EthHTTPConnection, wallet=wallet)
|
||||
|
||||
|
||||
def connect_by_config(self, config):
|
||||
def connect_by_config(self, config, nonce_confirmed=True):
|
||||
"""
|
||||
|
||||
If the standard arguments for nonce and fee price/price have been defined (which generate the configuration keys "_NONCE", "_FEE_PRICE" and "_FEE_LIMIT" respectively) , the corresponding overrides for fee and nonce generators will be defined.
|
||||
@@ -38,9 +38,9 @@ class Rpc(BaseRpc):
|
||||
except KeyError:
|
||||
pass
|
||||
if nonce != None:
|
||||
self.nonce_oracle = OverrideNonceOracle(self.get_sender_address(), nonce, id_generator=self.id_generator)
|
||||
self.nonce_oracle = OverrideNonceOracle(self.get_sender_address(), nonce, confirmed=nonce_confirmed, id_generator=self.id_generator)
|
||||
else:
|
||||
self.nonce_oracle = RPCNonceOracle(self.get_sender_address(), self.conn, id_generator=self.id_generator)
|
||||
self.nonce_oracle = RPCNonceOracle(self.get_sender_address(), self.conn, confirmed=nonce_confirmed, id_generator=self.id_generator)
|
||||
|
||||
fee_price = None
|
||||
fee_limit = None
|
||||
|
||||
@@ -42,12 +42,12 @@ class NonceOracle(BaseNonceOracle):
|
||||
:param id_generator: json-rpc id generator
|
||||
:type id_generator: chainlib.connection.JSONRPCIdGenerator
|
||||
"""
|
||||
def __init__(self, address, id_generator=None):
|
||||
def __init__(self, address, id_generator=None, confirmed=None):
|
||||
self.id_generator = id_generator
|
||||
super(NonceOracle, self).__init__(add_0x(address))
|
||||
super(NonceOracle, self).__init__(add_0x(address), confirmed=confirmed)
|
||||
|
||||
|
||||
def get_nonce(self):
|
||||
def get_nonce(self, confirmed=False):
|
||||
"""Load initial nonce value.
|
||||
"""
|
||||
raise NotImplementedError('Class must be extended')
|
||||
@@ -74,12 +74,12 @@ class RPCNonceOracle(NonceOracle):
|
||||
:param id_generator: json-rpc id generator
|
||||
:type id_generator: chainlib.connection.JSONRPCIdGenerator
|
||||
"""
|
||||
def __init__(self, address, conn, id_generator=None):
|
||||
def __init__(self, address, conn, id_generator=None, confirmed=False):
|
||||
self.conn = conn
|
||||
super(RPCNonceOracle, self).__init__(address, id_generator=id_generator)
|
||||
super(RPCNonceOracle, self).__init__(address, id_generator=id_generator, confirmed=confirmed)
|
||||
|
||||
|
||||
def get_nonce(self):
|
||||
def get_nonce(self, confirmed=False):
|
||||
"""Load and return nonce value from network.
|
||||
|
||||
Note! First call to next_nonce after calling get_nonce will return the same value!
|
||||
@@ -87,7 +87,7 @@ class RPCNonceOracle(NonceOracle):
|
||||
:rtype: int
|
||||
:returns: Initial nonce
|
||||
"""
|
||||
o = nonce(self.address, id_generator=self.id_generator)
|
||||
o = nonce(self.address, confirmed=confirmed, id_generator=self.id_generator)
|
||||
r = self.conn.do(o)
|
||||
n = strip_0x(r)
|
||||
return int(n, 16)
|
||||
@@ -103,13 +103,13 @@ class OverrideNonceOracle(NonceOracle):
|
||||
:param id_generator: json-rpc id generator (not used)
|
||||
:type id_generator: chainlib.connection.JSONRPCIdGenerator
|
||||
"""
|
||||
def __init__(self, address, nonce, id_generator=None):
|
||||
def __init__(self, address, nonce, id_generator=None, confirmed=False):
|
||||
self.initial_nonce = nonce
|
||||
self.nonce = self.initial_nonce
|
||||
super(OverrideNonceOracle, self).__init__(address, id_generator=id_generator)
|
||||
super(OverrideNonceOracle, self).__init__(address, id_generator=id_generator, confirmed=confirmed)
|
||||
|
||||
|
||||
def get_nonce(self):
|
||||
def get_nonce(self, confirmed=False):
|
||||
"""Returns initial nonce value set at object construction.
|
||||
|
||||
:rtype: int
|
||||
|
||||
@@ -112,7 +112,11 @@ logg.debug('settings loaded:\n{}'.format(settings))
|
||||
|
||||
|
||||
def get_block(settings):
|
||||
hsh = settings.get('HASH')[0]
|
||||
hsh = None
|
||||
try:
|
||||
hsh = settings.get('HASH')[0]
|
||||
except TypeError:
|
||||
pass
|
||||
r = None
|
||||
if hsh == None:
|
||||
r = get_block_number(
|
||||
|
||||
@@ -14,7 +14,7 @@ from chainlib.eth.address import to_checksum_address
|
||||
|
||||
def process_settings_rpc(settings, config):
|
||||
rpc = chainlib.eth.cli.Rpc(settings.get('WALLET'))
|
||||
conn = rpc.connect_by_config(config)
|
||||
conn = rpc.connect_by_config(config, nonce_confirmed=True)
|
||||
|
||||
settings.set('CONN', conn)
|
||||
settings.set('RPC_ID_GENERATOR', rpc.id_generator)
|
||||
|
||||
@@ -658,7 +658,7 @@ class Tx(BaseTx, Src):
|
||||
|
||||
|
||||
def apply_receipt(self, rcpt, strict=False):
|
||||
result = TxResult(rcpt)
|
||||
result = TxResult(src=rcpt)
|
||||
self.apply_result(result)
|
||||
|
||||
|
||||
@@ -754,9 +754,9 @@ input {}
|
||||
if self.result != None and self.result.status != Status.PENDING:
|
||||
s += """gas_used {}
|
||||
""".format(
|
||||
self.result.fee_cost,
|
||||
status = self.result.status.name
|
||||
self.result.fee_cost,
|
||||
)
|
||||
status = self.result.status.name
|
||||
|
||||
s += 'status ' + status + '\n'
|
||||
|
||||
|
||||
Reference in New Issue
Block a user