Compare commits
14 Commits
lash/cli-e
...
0.0.10-dev
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c66f5fdff9 | ||
|
|
700c52089e | ||
|
|
76c8ff58fc | ||
|
|
d6b258f214 | ||
|
|
91d748d09f | ||
|
|
a188c4e6bb | ||
|
|
778994e07e | ||
|
|
94e016366b | ||
|
|
2011ce8bb8 | ||
|
|
ab8c510fa0 | ||
|
|
ee6c97f581
|
||
|
|
14ccb8d375
|
||
|
|
1c021fae2a
|
||
|
|
46fecaf8c8
|
@@ -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))
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ from chainlib.eth.nonce import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
# TODO: how is the keystore implemented in rpc here?
|
||||||
class Rpc(BaseRpc):
|
class Rpc(BaseRpc):
|
||||||
"""Convenience constructor to set Ethereum defaults for chainlib cli Rpc object
|
"""Convenience constructor to set Ethereum defaults for chainlib cli Rpc object
|
||||||
|
|
||||||
|
|||||||
@@ -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()
|
||||||
|
|||||||
@@ -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))
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import logging
|
|||||||
# external imports
|
# external imports
|
||||||
import eth_tester
|
import eth_tester
|
||||||
import coincurve
|
import coincurve
|
||||||
|
from chainlib.encode import TxHexNormalizer
|
||||||
from chainlib.connection import (
|
from chainlib.connection import (
|
||||||
RPCConnection,
|
RPCConnection,
|
||||||
error_parser,
|
error_parser,
|
||||||
@@ -22,6 +23,7 @@ from hexathon import (
|
|||||||
add_0x,
|
add_0x,
|
||||||
strip_0x,
|
strip_0x,
|
||||||
)
|
)
|
||||||
|
from chainlib.eth.tx import receipt
|
||||||
|
|
||||||
from crypto_dev_signer.eth.signer import ReferenceSigner as EIP155Signer
|
from crypto_dev_signer.eth.signer import ReferenceSigner as EIP155Signer
|
||||||
from crypto_dev_signer.encoding import private_key_to_address
|
from crypto_dev_signer.encoding import private_key_to_address
|
||||||
@@ -80,6 +82,11 @@ class TestRPCConnection(RPCConnection):
|
|||||||
return jsonrpc_result(r, error_parser)
|
return jsonrpc_result(r, error_parser)
|
||||||
|
|
||||||
|
|
||||||
|
def wait(self, tx_hash_hex):
|
||||||
|
o = receipt(tx_hash_hex)
|
||||||
|
return self.do(o)
|
||||||
|
|
||||||
|
|
||||||
def eth_blockNumber(self, p):
|
def eth_blockNumber(self, p):
|
||||||
block = self.backend.get_block_by_number('latest')
|
block = self.backend.get_block_by_number('latest')
|
||||||
return block['number']
|
return block['number']
|
||||||
@@ -184,7 +191,8 @@ class TestRPCConnection(RPCConnection):
|
|||||||
pk_bytes = self.backend.keystore.get(tx.sender)
|
pk_bytes = self.backend.keystore.get(tx.sender)
|
||||||
pk = coincurve.PrivateKey(secret=pk_bytes)
|
pk = coincurve.PrivateKey(secret=pk_bytes)
|
||||||
result_address = private_key_to_address(pk)
|
result_address = private_key_to_address(pk)
|
||||||
assert strip_0x(result_address) == strip_0x(tx.sender)
|
tx_normalize = TxHexNormalizer()
|
||||||
|
assert tx_normalize.wallet_address(strip_0x(result_address)) == tx_normalize.wallet_address(strip_0x(tx.sender))
|
||||||
|
|
||||||
|
|
||||||
def sign_transaction(self, tx, passphrase=''):
|
def sign_transaction(self, tx, passphrase=''):
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[metadata]
|
[metadata]
|
||||||
name = chainlib-eth
|
name = chainlib-eth
|
||||||
version = 0.0.9rc1
|
version = 0.0.9rc5
|
||||||
description = Ethereum implementation of the chainlib interface
|
description = Ethereum implementation of the chainlib interface
|
||||||
author = Louis Holbrook
|
author = Louis Holbrook
|
||||||
author_email = dev@holbrook.no
|
author_email = dev@holbrook.no
|
||||||
|
|||||||
Reference in New Issue
Block a user