Merge branch 'master' of file:///home/lash/src/client/cic/grassrootseconomics/chainlib-eth

This commit is contained in:
nolash 2021-10-18 13:31:18 +02:00
commit 700c52089e
3 changed files with 12 additions and 4 deletions

View File

@ -42,3 +42,7 @@ class AddressChecksum:
:returns: Checksum address :returns: Checksum address
""" """
return to_checksum_address(v) return to_checksum_address(v)
def is_same_address(a, b):
return uniform(strip_0x(a)) == uniform(strip_0x(b))

View File

@ -45,7 +45,10 @@ from chainlib.error import SignerMissingException
from chainlib.chain import ChainSpec from chainlib.chain import ChainSpec
from chainlib.eth.runnable.util import decode_for_puny_humans from chainlib.eth.runnable.util import decode_for_puny_humans
from chainlib.eth.jsonrpc import to_blockheight_param from chainlib.eth.jsonrpc import to_blockheight_param
<<<<<<< HEAD
from chainlib.eth.address import to_checksum_address from chainlib.eth.address import to_checksum_address
=======
>>>>>>> d6b258f2140f5ce555f765a90c14a65a5f3fc6de
logging.basicConfig(level=logging.WARNING) logging.basicConfig(level=logging.WARNING)
logg = logging.getLogger() logg = logging.getLogger()

View File

@ -26,6 +26,7 @@ from chainlib.eth.gas import Gas
from chainlib.eth.gas import balance as gas_balance from chainlib.eth.gas import balance as gas_balance
from chainlib.chain import ChainSpec from chainlib.chain import ChainSpec
from chainlib.eth.runnable.util import decode_for_puny_humans from chainlib.eth.runnable.util import decode_for_puny_humans
from chainlib.eth.address import is_same_address
import chainlib.eth.cli import chainlib.eth.cli
logging.basicConfig(level=logging.WARNING) 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()) 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')) 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') raise ValueError('invalid checksum address')
logg.info('gas transfer from {} to {} value {}'.format(signer_address, recipient, value)) logg.info('gas transfer from {} to {} value {}'.format(signer_address, recipient, value))
if logg.isEnabledFor(logging.DEBUG): if logg.isEnabledFor(logging.DEBUG):
try: 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) recipient_balance = balance(add_0x(recipient), rpc.id_generator)
logg.debug('sender {} balance before: {}'.format(signer_address, sender_balance)) logg.debug('sender {} balance before: {}'.format(signer_address, sender_balance))
logg.debug('recipient {} balance before: {}'.format(recipient, recipient_balance)) logg.debug('recipient {} balance before: {}'.format(recipient, recipient_balance))
except urllib.error.URLError: except urllib.error.URLError:
pass 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: if send:
conn.do(o) conn.do(o)
if block_last: if block_last:
r = conn.wait(tx_hash_hex) r = conn.wait(tx_hash_hex)
if logg.isEnabledFor(logging.DEBUG): 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) recipient_balance = balance(add_0x(recipient), rpc.id_generator)
logg.debug('sender {} balance after: {}'.format(signer_address, sender_balance)) logg.debug('sender {} balance after: {}'.format(signer_address, sender_balance))
logg.debug('recipient {} balance after: {}'.format(recipient, recipient_balance)) logg.debug('recipient {} balance after: {}'.format(recipient, recipient_balance))