commit a188c4e6bb4fe44f6cf0f9a1b26db2dfc254294b
parent 778994e07e9637653279f3b88ba4f7494057878a
Author: Louis Holbrook <accounts-gitlab@holbrook.no>
Date: Mon, 18 Oct 2021 10:49:40 +0000
bug: Correct rpc format for gas cli request
Diffstat:
3 files changed, 10 insertions(+), 5 deletions(-)
diff --git a/chainlib/eth/address.py b/chainlib/eth/address.py
@@ -42,3 +42,7 @@ class AddressChecksum:
:returns: Checksum address
"""
return to_checksum_address(v)
+
+
+def is_same_address(a, b):
+ return uniform(strip_0x(a)) == uniform(strip_0x(b))
diff --git a/chainlib/eth/runnable/gas.py b/chainlib/eth/runnable/gas.py
@@ -26,6 +26,7 @@ from chainlib.eth.gas import Gas
from chainlib.eth.gas import balance as gas_balance
from chainlib.chain import ChainSpec
from chainlib.eth.runnable.util import decode_for_puny_humans
+from chainlib.eth.address import is_same_address
import chainlib.eth.cli
logging.basicConfig(level=logging.WARNING)
@@ -73,27 +74,27 @@ def main():
g = Gas(chain_spec, signer=signer, gas_oracle=rpc.get_gas_oracle(), nonce_oracle=rpc.get_nonce_oracle())
recipient = to_checksum_address(config.get('_RECIPIENT'))
- if not config.true('_UNSAFE') and recipient != add_0x(config.get('_RECIPIENT')):
+ if not config.true('_UNSAFE') and is_checksum_address(recipient):
raise ValueError('invalid checksum address')
logg.info('gas transfer from {} to {} value {}'.format(signer_address, recipient, value))
if logg.isEnabledFor(logging.DEBUG):
try:
- sender_balance = balance(signer_address, rpc.id_generator)
+ sender_balance = balance(add_0x(signer_address), rpc.id_generator)
recipient_balance = balance(add_0x(recipient), rpc.id_generator)
logg.debug('sender {} balance before: {}'.format(signer_address, sender_balance))
logg.debug('recipient {} balance before: {}'.format(recipient, recipient_balance))
except urllib.error.URLError:
pass
- (tx_hash_hex, o) = g.create(signer_address, recipient, value, data=config.get('_DATA'), id_generator=rpc.id_generator)
+ (tx_hash_hex, o) = g.create(signer_address, add_0x(recipient), value, data=config.get('_DATA'), id_generator=rpc.id_generator)
if send:
conn.do(o)
if block_last:
r = conn.wait(tx_hash_hex)
if logg.isEnabledFor(logging.DEBUG):
- sender_balance = balance(signer_address, rpc.id_generator)
+ sender_balance = balance(add_0x(signer_address), rpc.id_generator)
recipient_balance = balance(add_0x(recipient), rpc.id_generator)
logg.debug('sender {} balance after: {}'.format(signer_address, sender_balance))
logg.debug('recipient {} balance after: {}'.format(recipient, recipient_balance))
diff --git a/setup.cfg b/setup.cfg
@@ -1,6 +1,6 @@
[metadata]
name = chainlib-eth
-version = 0.0.9rc3
+version = 0.0.9rc4
description = Ethereum implementation of the chainlib interface
author = Louis Holbrook
author_email = dev@holbrook.no