Add docstrings
This commit is contained in:
@@ -1,30 +1,19 @@
|
||||
#!python3
|
||||
|
||||
"""Token balance query script
|
||||
|
||||
.. moduleauthor:: Louis Holbrook <dev@holbrook.no>
|
||||
.. pgp:: 0826EDA1702D1E87C6E2875121D2E7BB88C2A746
|
||||
|
||||
"""
|
||||
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
# standard imports
|
||||
import os
|
||||
import json
|
||||
import argparse
|
||||
import logging
|
||||
|
||||
# third-party imports
|
||||
# external imports
|
||||
from hexathon import (
|
||||
add_0x,
|
||||
strip_0x,
|
||||
even,
|
||||
)
|
||||
import sha3
|
||||
|
||||
# local imports
|
||||
from chainlib.eth.address import to_checksum
|
||||
import chainlib.eth.cli
|
||||
from chainlib.eth.address import AddressChecksum
|
||||
from chainlib.jsonrpc import (
|
||||
jsonrpc_result,
|
||||
IntSequenceGenerator,
|
||||
@@ -35,53 +24,37 @@ from chainlib.eth.gas import (
|
||||
balance,
|
||||
)
|
||||
from chainlib.chain import ChainSpec
|
||||
from crypto_dev_signer.eth.signer import ReferenceSigner as EIP155Signer
|
||||
|
||||
logging.basicConfig(level=logging.WARNING)
|
||||
logg = logging.getLogger()
|
||||
|
||||
default_eth_provider = os.environ.get('RPC_PROVIDER')
|
||||
if default_eth_provider == None:
|
||||
default_eth_provider = os.environ.get('ETH_PROVIDER', 'http://localhost:8545')
|
||||
script_dir = os.path.dirname(os.path.realpath(__file__))
|
||||
#config_dir = os.path.join(script_dir, '..', 'data', 'config')
|
||||
|
||||
argparser = argparse.ArgumentParser()
|
||||
argparser.add_argument('-p', '--provider', dest='p', default=default_eth_provider, type=str, help='Web3 provider url (http only)')
|
||||
argparser.add_argument('-i', '--chain-spec', dest='i', type=str, default='evm:ethereum:1', help='Chain specification string')
|
||||
argparser.add_argument('-u', '--unsafe', dest='u', action='store_true', help='Auto-convert address to checksum adddress')
|
||||
argparser.add_argument('--seq', action='store_true', help='Use sequential rpc ids')
|
||||
argparser.add_argument('-v', action='store_true', help='Be verbose')
|
||||
argparser.add_argument('-vv', action='store_true', help='Be more verbose')
|
||||
argparser.add_argument('address', type=str, help='Account address')
|
||||
arg_flags = chainlib.eth.cli.argflag_std_read
|
||||
argparser = chainlib.eth.cli.ArgumentParser(arg_flags)
|
||||
argparser.add_positional('address', type=str, help='Ethereum address of recipient')
|
||||
args = argparser.parse_args()
|
||||
#config = chainlib.eth.cli.Config.from_args(args, arg_flags, default_config_dir=config_dir)
|
||||
config = chainlib.eth.cli.Config.from_args(args, arg_flags)
|
||||
|
||||
wallet = chainlib.eth.cli.Wallet()
|
||||
wallet.from_config(config)
|
||||
holder_address = args.address
|
||||
if wallet.get_signer_address() == None and holder_address != None:
|
||||
holder_address = wallet.from_address(holder_address)
|
||||
|
||||
if args.vv:
|
||||
logg.setLevel(logging.DEBUG)
|
||||
elif args.v:
|
||||
logg.setLevel(logging.INFO)
|
||||
rpc = chainlib.eth.cli.Rpc()
|
||||
conn = rpc.connect_by_config(config)
|
||||
|
||||
rpc_id_generator = None
|
||||
if args.seq:
|
||||
rpc_id_generator = IntSequenceGenerator()
|
||||
|
||||
auth = None
|
||||
if os.environ.get('RPC_AUTHENTICATION') == 'basic':
|
||||
from chainlib.auth import BasicAuth
|
||||
auth = BasicAuth(os.environ['RPC_USERNAME'], os.environ['RPC_PASSWORD'])
|
||||
conn = EthHTTPConnection(args.p, auth=auth)
|
||||
|
||||
gas_oracle = OverrideGasOracle(conn)
|
||||
|
||||
address = to_checksum(args.address)
|
||||
if not args.u and address != add_0x(args.address):
|
||||
raise ValueError('invalid checksum address')
|
||||
|
||||
chain_spec = ChainSpec.from_chain_str(args.i)
|
||||
chain_spec = ChainSpec.from_chain_str(config.get('CHAIN_SPEC'))
|
||||
|
||||
def main():
|
||||
r = None
|
||||
decimals = 18
|
||||
|
||||
o = balance(address, id_generator=rpc_id_generator)
|
||||
o = balance(holder_address, id_generator=rpc.id_generator)
|
||||
r = conn.do(o)
|
||||
|
||||
hx = strip_0x(r)
|
||||
|
||||
@@ -4,12 +4,13 @@
|
||||
import sys
|
||||
import os
|
||||
import json
|
||||
import argparse
|
||||
#import argparse
|
||||
import logging
|
||||
import select
|
||||
|
||||
# local imports
|
||||
from chainlib.eth.address import to_checksum
|
||||
import chainlib.eth.cli
|
||||
from chainlib.eth.address import AddressChecksum
|
||||
from chainlib.eth.connection import EthHTTPConnection
|
||||
from chainlib.eth.tx import count
|
||||
from chainlib.chain import ChainSpec
|
||||
@@ -21,63 +22,28 @@ from hexathon import add_0x
|
||||
logging.basicConfig(level=logging.WARNING)
|
||||
logg = logging.getLogger()
|
||||
|
||||
default_eth_provider = os.environ.get('RPC_PROVIDER')
|
||||
if default_eth_provider == None:
|
||||
default_eth_provider = os.environ.get('ETH_PROVIDER', 'http://localhost:8545')
|
||||
script_dir = os.path.dirname(os.path.realpath(__file__))
|
||||
config_dir = os.path.join(script_dir, '..', 'data', 'config')
|
||||
|
||||
def stdin_arg():
|
||||
h = select.select([sys.stdin], [], [], 0)
|
||||
if len(h[0]) > 0:
|
||||
v = h[0][0].read()
|
||||
return v.rstrip()
|
||||
return None
|
||||
|
||||
argparser = argparse.ArgumentParser()
|
||||
argparser.add_argument('-p', '--provider', dest='p', default=default_eth_provider, type=str, help='Web3 provider url (http only)')
|
||||
argparser.add_argument('-i', '--chain-spec', dest='i', type=str, default='evm:ethereum:1', help='Chain specification string')
|
||||
argparser.add_argument('-y', '--key-file', dest='y', type=str, help='Ethereum keystore file to use for signing')
|
||||
argparser.add_argument('--env-prefix', default=os.environ.get('CONFINI_ENV_PREFIX'), dest='env_prefix', type=str, help='environment prefix for variables to overwrite configuration')
|
||||
argparser.add_argument('-u', '--unsafe', dest='u', action='store_true', help='Auto-convert address to checksum adddress')
|
||||
argparser.add_argument('--seq', action='store_true', help='Use sequential rpc ids')
|
||||
argparser.add_argument('-v', action='store_true', help='Be verbose')
|
||||
argparser.add_argument('-vv', action='store_true', help='Be more verbose')
|
||||
argparser.add_argument('address', nargs='?', type=str, default=stdin_arg(), help='Ethereum address of recipient')
|
||||
arg_flags = chainlib.eth.cli.argflag_std_read
|
||||
argparser = chainlib.eth.cli.ArgumentParser(arg_flags)
|
||||
argparser.add_positional('address', type=str, help='Ethereum address of recipient')
|
||||
args = argparser.parse_args()
|
||||
config = chainlib.eth.cli.Config.from_args(args, arg_flags, default_config_dir=config_dir)
|
||||
|
||||
if args.address == None:
|
||||
argparser.error('need first positional argument or value from stdin')
|
||||
holder_address = args.address
|
||||
wallet = chainlib.eth.cli.Wallet()
|
||||
wallet.from_config(config)
|
||||
if wallet.get_signer_address() == None and holder_address != None:
|
||||
wallet.from_address(holder_address)
|
||||
|
||||
if args.vv:
|
||||
logg.setLevel(logging.DEBUG)
|
||||
elif args.v:
|
||||
logg.setLevel(logging.INFO)
|
||||
rpc = chainlib.eth.cli.Rpc(wallet=wallet)
|
||||
conn = rpc.connect_by_config(config)
|
||||
|
||||
|
||||
signer_address = None
|
||||
keystore = DictKeystore()
|
||||
if args.y != None:
|
||||
logg.debug('loading keystore file {}'.format(args.y))
|
||||
signer_address = keystore.import_keystore_file(args.y, passphrase)
|
||||
logg.debug('now have key for signer address {}'.format(signer_address))
|
||||
signer = EIP155Signer(keystore)
|
||||
|
||||
rpc_id_generator = None
|
||||
if args.seq:
|
||||
rpc_id_generator = IntSequenceGenerator()
|
||||
|
||||
auth = None
|
||||
if os.environ.get('RPC_AUTHENTICATION') == 'basic':
|
||||
from chainlib.auth import BasicAuth
|
||||
auth = BasicAuth(os.environ['RPC_USERNAME'], os.environ['RPC_PASSWORD'])
|
||||
rpc = EthHTTPConnection(args.p, auth=auth)
|
||||
|
||||
def main():
|
||||
recipient = to_checksum(args.address)
|
||||
if not args.u and recipient != add_0x(args.address):
|
||||
raise ValueError('invalid checksum address')
|
||||
|
||||
o = count(recipient, id_generator=rpc_id_generator)
|
||||
r = rpc.do(o)
|
||||
o = count(holder_address, id_generator=rpc.id_generator)
|
||||
r = conn.do(o)
|
||||
count_result = None
|
||||
try:
|
||||
count_result = int(r, 16)
|
||||
|
||||
@@ -1,12 +1,3 @@
|
||||
#!python3
|
||||
|
||||
"""Decode raw transaction
|
||||
|
||||
.. moduleauthor:: Louis Holbrook <dev@holbrook.no>
|
||||
.. pgp:: 0826EDA1702D1E87C6E2875121D2E7BB88C2A746
|
||||
|
||||
"""
|
||||
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
# standard imports
|
||||
@@ -18,48 +9,29 @@ import logging
|
||||
import select
|
||||
|
||||
# external imports
|
||||
import chainlib.eth.cli
|
||||
from chainlib.eth.tx import unpack
|
||||
from chainlib.chain import ChainSpec
|
||||
|
||||
# local imports
|
||||
from chainlib.eth.runnable.util import decode_for_puny_humans
|
||||
|
||||
|
||||
logging.basicConfig(level=logging.WARNING)
|
||||
logg = logging.getLogger()
|
||||
|
||||
def stdin_arg(t=0):
|
||||
h = select.select([sys.stdin], [], [], t)
|
||||
if len(h[0]) > 0:
|
||||
v = h[0][0].read()
|
||||
return v.rstrip()
|
||||
return None
|
||||
script_dir = os.path.dirname(os.path.realpath(__file__))
|
||||
config_dir = os.path.join(script_dir, '..', 'data', 'config')
|
||||
|
||||
argparser = argparse.ArgumentParser()
|
||||
argparser.add_argument('-i', '--chain-id', dest='i', default='evm:ethereum:1', type=str, help='Numeric network id')
|
||||
argparser.add_argument('-v', action='store_true', help='Be verbose')
|
||||
argparser.add_argument('-vv', action='store_true', help='Be more verbose')
|
||||
argparser.add_argument('tx', type=str, nargs='?', default=stdin_arg(), help='hex-encoded signed raw transaction')
|
||||
arg_flags = chainlib.eth.cli.Flag.VERBOSE | chainlib.eth.cli.Flag.CHAIN_SPEC | chainlib.eth.cli.Flag.ENV_PREFIX | chainlib.eth.cli.Flag.RAW
|
||||
argparser = chainlib.eth.cli.ArgumentParser(arg_flags)
|
||||
argparser.add_positional('tx_data', type=str, help='Transaction data to decode')
|
||||
args = argparser.parse_args()
|
||||
config = chainlib.eth.cli.Config.from_args(args, arg_flags, default_config_dir=config_dir)
|
||||
|
||||
if args.vv:
|
||||
logg.setLevel(logging.DEBUG)
|
||||
elif args.v:
|
||||
logg.setLevel(logging.INFO)
|
||||
|
||||
argp = args.tx
|
||||
logg.debug('txxxx {}'.format(args.tx))
|
||||
if argp == None:
|
||||
argp = stdin_arg(t=3)
|
||||
if argp == None:
|
||||
argparser.error('need first positional argument or value from stdin')
|
||||
|
||||
chain_spec = ChainSpec.from_chain_str(args.i)
|
||||
|
||||
chain_spec = ChainSpec.from_chain_str(config.get('CHAIN_SPEC'))
|
||||
|
||||
def main():
|
||||
tx_raw = argp
|
||||
decode_for_puny_humans(tx_raw, chain_spec, sys.stdout)
|
||||
decode_for_puny_humans(args.tx_data, chain_spec, sys.stdout)
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
||||
@@ -1,12 +1,3 @@
|
||||
#!python3
|
||||
|
||||
"""Gas transfer script
|
||||
|
||||
.. moduleauthor:: Louis Holbrook <dev@holbrook.no>
|
||||
.. pgp:: 0826EDA1702D1E87C6E2875121D2E7BB88C2A746
|
||||
|
||||
"""
|
||||
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
# standard imports
|
||||
@@ -19,114 +10,53 @@ import logging
|
||||
import urllib
|
||||
|
||||
# external imports
|
||||
from crypto_dev_signer.eth.signer import ReferenceSigner as EIP155Signer
|
||||
from crypto_dev_signer.keystore.dict import DictKeystore
|
||||
from hexathon import (
|
||||
add_0x,
|
||||
strip_0x,
|
||||
)
|
||||
|
||||
# local imports
|
||||
from chainlib.eth.address import to_checksum
|
||||
from chainlib.eth.address import to_checksum_address
|
||||
from chainlib.eth.connection import EthHTTPConnection
|
||||
from chainlib.jsonrpc import (
|
||||
JSONRPCRequest,
|
||||
IntSequenceGenerator,
|
||||
)
|
||||
from chainlib.eth.nonce import (
|
||||
RPCNonceOracle,
|
||||
OverrideNonceOracle,
|
||||
)
|
||||
from chainlib.eth.gas import (
|
||||
RPCGasOracle,
|
||||
OverrideGasOracle,
|
||||
Gas,
|
||||
)
|
||||
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
|
||||
import chainlib.eth.cli
|
||||
|
||||
logging.basicConfig(level=logging.WARNING)
|
||||
logg = logging.getLogger()
|
||||
|
||||
default_eth_provider = os.environ.get('RPC_PROVIDER')
|
||||
if default_eth_provider == None:
|
||||
default_eth_provider = os.environ.get('ETH_PROVIDER', 'http://localhost:8545')
|
||||
|
||||
argparser = argparse.ArgumentParser()
|
||||
argparser.add_argument('-p', '--provider', dest='p', default=default_eth_provider, type=str, help='Web3 provider url (http only)')
|
||||
argparser.add_argument('-w', action='store_true', help='Wait for the last transaction to be confirmed')
|
||||
argparser.add_argument('-ww', action='store_true', help='Wait for every transaction to be confirmed')
|
||||
argparser.add_argument('-i', '--chain-spec', dest='i', type=str, default='evm:ethereum:1', help='Chain specification string')
|
||||
argparser.add_argument('-y', '--key-file', dest='y', type=str, help='Ethereum keystore file to use for signing')
|
||||
argparser.add_argument('--env-prefix', default=os.environ.get('CONFINI_ENV_PREFIX'), dest='env_prefix', type=str, help='environment prefix for variables to overwrite configuration')
|
||||
argparser.add_argument('--nonce', type=int, help='override nonce')
|
||||
argparser.add_argument('--gas-price', dest='gas_price', type=int, help='override gas price')
|
||||
argparser.add_argument('--gas-limit', dest='gas_limit', type=int, help='override gas limit')
|
||||
argparser.add_argument('-u', '--unsafe', dest='u', action='store_true', help='Auto-convert address to checksum adddress')
|
||||
argparser.add_argument('--seq', action='store_true', help='Use sequential rpc ids')
|
||||
argparser.add_argument('-v', action='store_true', help='Be verbose')
|
||||
argparser.add_argument('-vv', action='store_true', help='Be more verbose')
|
||||
argparser.add_argument('-s', '--send', dest='s', action='store_true', help='Send to network')
|
||||
argparser.add_argument('recipient', type=str, help='ethereum address of recipient')
|
||||
argparser.add_argument('amount', type=int, help='gas value in wei')
|
||||
arg_flags = chainlib.eth.cli.argflag_std_write | chainlib.eth.cli.Flag.WALLET
|
||||
argparser = chainlib.eth.cli.ArgumentParser(arg_flags)
|
||||
argparser.add_argument('--data', type=str, help='Transaction data')
|
||||
argparser.add_positional('amount', type=int, help='Token amount to send')
|
||||
args = argparser.parse_args()
|
||||
|
||||
|
||||
if args.vv:
|
||||
logg.setLevel(logging.DEBUG)
|
||||
elif args.v:
|
||||
logg.setLevel(logging.INFO)
|
||||
extra_args = {
|
||||
'data': None,
|
||||
'amount': None,
|
||||
}
|
||||
#config = chainlib.eth.cli.Config.from_args(args, arg_flags, extra_args=extra_args, default_config_dir=config_dir)
|
||||
config = chainlib.eth.cli.Config.from_args(args, arg_flags, extra_args=extra_args)
|
||||
|
||||
block_all = args.ww
|
||||
block_last = args.w or block_all
|
||||
|
||||
passphrase_env = 'ETH_PASSPHRASE'
|
||||
if args.env_prefix != None:
|
||||
passphrase_env = args.env_prefix + '_' + passphrase_env
|
||||
passphrase = os.environ.get(passphrase_env)
|
||||
if passphrase == None:
|
||||
logg.warning('no passphrase given')
|
||||
passphrase=''
|
||||
wallet = chainlib.eth.cli.Wallet()
|
||||
wallet.from_config(config)
|
||||
|
||||
signer_address = None
|
||||
keystore = DictKeystore()
|
||||
if args.y != None:
|
||||
logg.debug('loading keystore file {}'.format(args.y))
|
||||
signer_address = keystore.import_keystore_file(args.y, password=passphrase)
|
||||
logg.debug('now have key for signer address {}'.format(signer_address))
|
||||
signer = EIP155Signer(keystore)
|
||||
rpc = chainlib.eth.cli.Rpc(wallet=wallet)
|
||||
conn = rpc.connect_by_config(config)
|
||||
|
||||
rpc_id_generator = None
|
||||
if args.seq:
|
||||
rpc_id_generator = IntSequenceGenerator()
|
||||
chain_spec = ChainSpec.from_chain_str(config.get('CHAIN_SPEC'))
|
||||
|
||||
auth = None
|
||||
if os.environ.get('RPC_AUTHENTICATION') == 'basic':
|
||||
from chainlib.auth import BasicAuth
|
||||
auth = BasicAuth(os.environ['RPC_USERNAME'], os.environ['RPC_PASSWORD'])
|
||||
conn = EthHTTPConnection(args.p, auth=auth)
|
||||
value = config.get('_AMOUNT')
|
||||
|
||||
nonce_oracle = None
|
||||
if args.nonce != None:
|
||||
nonce_oracle = OverrideNonceOracle(signer_address, args.nonce, id_generator=rpc_id_generator)
|
||||
else:
|
||||
nonce_oracle = RPCNonceOracle(signer_address, conn, id_generator=rpc_id_generator)
|
||||
|
||||
gas_oracle = None
|
||||
if args.gas_price or args.gas_limit != None:
|
||||
gas_oracle = OverrideGasOracle(price=args.gas_price, limit=args.gas_limit, conn=conn, id_generator=rpc_id_generator)
|
||||
else:
|
||||
gas_oracle = RPCGasOracle(conn, id_generator=rpc_id_generator)
|
||||
|
||||
|
||||
chain_spec = ChainSpec.from_chain_str(args.i)
|
||||
|
||||
value = args.amount
|
||||
|
||||
send = args.s
|
||||
|
||||
g = Gas(chain_spec, signer=signer, gas_oracle=gas_oracle, nonce_oracle=nonce_oracle)
|
||||
send = config.true('_RPC_SEND')
|
||||
|
||||
|
||||
def balance(address, id_generator):
|
||||
@@ -137,29 +67,34 @@ def balance(address, id_generator):
|
||||
|
||||
|
||||
def main():
|
||||
recipient = to_checksum(args.recipient)
|
||||
if not args.u and recipient != add_0x(args.recipient):
|
||||
signer = rpc.get_signer()
|
||||
signer_address = rpc.get_sender_address()
|
||||
|
||||
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')):
|
||||
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)
|
||||
recipient_balance = balance(recipient, rpc_id_generator)
|
||||
sender_balance = balance(signer_address, rpc.id_generator)
|
||||
recipient_balance = balance(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, id_generator=rpc_id_generator)
|
||||
(tx_hash_hex, o) = g.create(signer_address, 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)
|
||||
recipient_balance = balance(recipient, rpc_id_generator)
|
||||
sender_balance = balance(signer_address, rpc.id_generator)
|
||||
recipient_balance = balance(recipient, rpc.id_generator)
|
||||
logg.debug('sender {} balance after: {}'.format(signer_address, sender_balance))
|
||||
logg.debug('recipient {} balance after: {}'.format(recipient, recipient_balance))
|
||||
if r['status'] == 0:
|
||||
@@ -167,12 +102,13 @@ def main():
|
||||
sys.exit(1)
|
||||
print(tx_hash_hex)
|
||||
else:
|
||||
if logg.isEnabledFor(logging.INFO):
|
||||
#if logg.isEnabledFor(logging.INFO):
|
||||
if config.true('_RAW'):
|
||||
print(o['params'][0])
|
||||
else:
|
||||
io_str = io.StringIO()
|
||||
decode_for_puny_humans(o['params'][0], chain_spec, io_str)
|
||||
print(io_str.getvalue())
|
||||
else:
|
||||
print(o['params'][0])
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,12 +1,3 @@
|
||||
#!python3
|
||||
|
||||
"""Data retrieval script
|
||||
|
||||
.. moduleauthor:: Louis Holbrook <dev@holbrook.no>
|
||||
.. pgp:: 0826EDA1702D1E87C6E2875121D2E7BB88C2A746
|
||||
|
||||
"""
|
||||
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
# standard imports
|
||||
@@ -19,80 +10,56 @@ import enum
|
||||
import select
|
||||
|
||||
# external imports
|
||||
from potaahto.symbols import snake_and_camel
|
||||
from hexathon import (
|
||||
add_0x,
|
||||
strip_0x,
|
||||
)
|
||||
import sha3
|
||||
|
||||
# local imports
|
||||
from chainlib.eth.address import to_checksum
|
||||
from chainlib.jsonrpc import (
|
||||
JSONRPCRequest,
|
||||
jsonrpc_result,
|
||||
IntSequenceGenerator,
|
||||
)
|
||||
from chainlib.chain import ChainSpec
|
||||
from chainlib.status import Status
|
||||
|
||||
# local imports
|
||||
from chainlib.eth.connection import EthHTTPConnection
|
||||
from chainlib.eth.tx import (
|
||||
Tx,
|
||||
pack,
|
||||
)
|
||||
from chainlib.eth.address import to_checksum_address
|
||||
from chainlib.eth.block import Block
|
||||
from chainlib.chain import ChainSpec
|
||||
from chainlib.status import Status
|
||||
from chainlib.eth.address import (
|
||||
to_checksum_address,
|
||||
is_checksum_address,
|
||||
)
|
||||
from chainlib.eth.block import (
|
||||
Block,
|
||||
block_by_hash,
|
||||
)
|
||||
from chainlib.eth.runnable.util import decode_for_puny_humans
|
||||
from chainlib.eth.jsonrpc import to_blockheight_param
|
||||
import chainlib.eth.cli
|
||||
|
||||
logging.basicConfig(level=logging.WARNING, format='%(asctime)s %(levelname)s %(filename)s:%(lineno)d %(message)s')
|
||||
logg = logging.getLogger()
|
||||
|
||||
default_eth_provider = os.environ.get('RPC_PROVIDER')
|
||||
if default_eth_provider == None:
|
||||
default_eth_provider = os.environ.get('ETH_PROVIDER', 'http://localhost:8545')
|
||||
script_dir = os.path.dirname(os.path.realpath(__file__))
|
||||
config_dir = os.path.join(script_dir, '..', 'data', 'config')
|
||||
|
||||
def stdin_arg(t=0):
|
||||
h = select.select([sys.stdin], [], [], t)
|
||||
if len(h[0]) > 0:
|
||||
v = h[0][0].read()
|
||||
return v.rstrip()
|
||||
return None
|
||||
|
||||
argparser = argparse.ArgumentParser('eth-get', description='display information about an Ethereum address or transaction', epilog='address/transaction can be provided as an argument or from standard input')
|
||||
argparser.add_argument('-p', '--provider', dest='p', default=default_eth_provider, type=str, help='Web3 provider url (http only)')
|
||||
argparser.add_argument('-i', '--chain-spec', dest='i', type=str, default='evm:ethereum:1', help='Chain specification string')
|
||||
argparser.add_argument('--rlp', action='store_true', help='Display transaction as raw rlp')
|
||||
argparser.add_argument('--seq', action='store_true', help='Use sequential rpc ids')
|
||||
argparser.add_argument('-u', '--unsafe', dest='u', action='store_true', help='Auto-convert address to checksum adddress')
|
||||
argparser.add_argument('-v', action='store_true', help='Be verbose')
|
||||
argparser.add_argument('-vv', action='store_true', help='Be more verbose')
|
||||
argparser.add_argument('item', nargs='?', default=stdin_arg(), type=str, help='Item to get information for (address og transaction)')
|
||||
arg_flags = chainlib.eth.cli.argflag_std_read
|
||||
argparser = chainlib.eth.cli.ArgumentParser(arg_flags)
|
||||
argparser.add_positional('item', type=str, help='Address or transaction to retrieve data for')
|
||||
args = argparser.parse_args()
|
||||
config = chainlib.eth.cli.Config.from_args(args, arg_flags, default_config_dir=config_dir)
|
||||
|
||||
if args.vv:
|
||||
logg.setLevel(logging.DEBUG)
|
||||
elif args.v:
|
||||
logg.setLevel(logging.INFO)
|
||||
rpc = chainlib.eth.cli.Rpc()
|
||||
conn = rpc.connect_by_config(config)
|
||||
|
||||
argp = args.item
|
||||
if argp == None:
|
||||
argp = stdin_arg(None)
|
||||
if argsp == None:
|
||||
argparser.error('need first positional argument or value from stdin')
|
||||
|
||||
rpc_id_generator = None
|
||||
if args.seq:
|
||||
rpc_id_generator = IntSequenceGenerator()
|
||||
|
||||
auth = None
|
||||
if os.environ.get('RPC_AUTHENTICATION') == 'basic':
|
||||
from chainlib.auth import BasicAuth
|
||||
auth = BasicAuth(os.environ['RPC_USERNAME'], os.environ['RPC_PASSWORD'])
|
||||
conn = EthHTTPConnection(args.p, auth=auth)
|
||||
|
||||
chain_spec = ChainSpec.from_chain_str(args.i)
|
||||
chain_spec = ChainSpec.from_chain_str(config.get('CHAIN_SPEC'))
|
||||
|
||||
item = add_0x(args.item)
|
||||
as_rlp = bool(args.rlp)
|
||||
|
||||
|
||||
def get_transaction(conn, tx_hash, id_generator):
|
||||
@@ -106,7 +73,7 @@ def get_transaction(conn, tx_hash, id_generator):
|
||||
logg.error('Transaction {} not found'.format(tx_hash))
|
||||
sys.exit(1)
|
||||
|
||||
if as_rlp:
|
||||
if config.true('_RAW'):
|
||||
tx_src = Tx.src_normalize(tx_src)
|
||||
return pack(tx_src, chain_spec).hex()
|
||||
|
||||
@@ -125,16 +92,24 @@ def get_transaction(conn, tx_hash, id_generator):
|
||||
tx = Tx(tx_src)
|
||||
if rcpt != None:
|
||||
tx.apply_receipt(rcpt)
|
||||
rcpt = snake_and_camel(rcpt)
|
||||
o = block_by_hash(rcpt['block_hash'])
|
||||
r = conn.do(o)
|
||||
block = Block(r)
|
||||
tx.apply_block(block)
|
||||
logg.debug('foo {}'.format(tx_src))
|
||||
tx.generate_wire(chain_spec)
|
||||
return tx
|
||||
|
||||
|
||||
|
||||
def get_address(conn, address, id_generator):
|
||||
def get_address(conn, address, id_generator, height):
|
||||
j = JSONRPCRequest(id_generator=id_generator)
|
||||
o = j.template()
|
||||
o['method'] = 'eth_getCode'
|
||||
o['params'].append(address)
|
||||
o['params'].append('latest')
|
||||
height = to_blockheight_param(height)
|
||||
o['params'].append(height)
|
||||
o = j.finalize(o)
|
||||
code = conn.do(o)
|
||||
|
||||
@@ -146,11 +121,18 @@ def get_address(conn, address, id_generator):
|
||||
|
||||
|
||||
def main():
|
||||
address = item
|
||||
r = None
|
||||
if len(item) > 42:
|
||||
r = get_transaction(conn, item, rpc_id_generator).to_human()
|
||||
elif args.u or to_checksum_address(item):
|
||||
r = get_address(conn, item, rpc_id_generator)
|
||||
if len(address) > 42:
|
||||
r = get_transaction(conn, address, rpc.id_generator)
|
||||
if not config.true('_RAW'):
|
||||
r = r.to_human()
|
||||
else:
|
||||
if config.get('_UNSAFE'):
|
||||
address = to_checksum_address(address)
|
||||
elif not is_checksum_address(address):
|
||||
raise ValueError('invalid checksum address: {}'.format(address))
|
||||
r = get_address(conn, address, rpc.id_generator, config.get('_HEIGHT'))
|
||||
print(r)
|
||||
|
||||
|
||||
|
||||
@@ -1,12 +1,3 @@
|
||||
#!python3
|
||||
|
||||
"""Token balance query script
|
||||
|
||||
.. moduleauthor:: Louis Holbrook <dev@holbrook.no>
|
||||
.. pgp:: 0826EDA1702D1E87C6E2875121D2E7BB88C2A746
|
||||
|
||||
"""
|
||||
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
# standard imports
|
||||
@@ -17,19 +8,18 @@ import json
|
||||
import argparse
|
||||
import logging
|
||||
|
||||
# third-party imports
|
||||
# external imports
|
||||
from chainlib.chain import ChainSpec
|
||||
from hexathon import (
|
||||
add_0x,
|
||||
strip_0x,
|
||||
even,
|
||||
)
|
||||
import sha3
|
||||
from crypto_dev_signer.eth.signer import ReferenceSigner as EIP155Signer
|
||||
|
||||
# local imports
|
||||
from chainlib.eth.address import (
|
||||
to_checksum_address,
|
||||
is_checksum_address,
|
||||
)
|
||||
from chainlib.eth.address import AddressChecksum
|
||||
from chainlib.eth.chain import network_id
|
||||
from chainlib.eth.block import (
|
||||
block_latest,
|
||||
@@ -43,79 +33,49 @@ from chainlib.eth.gas import (
|
||||
balance,
|
||||
price,
|
||||
)
|
||||
from chainlib.jsonrpc import (
|
||||
IntSequenceGenerator,
|
||||
)
|
||||
from chainlib.chain import ChainSpec
|
||||
import chainlib.eth.cli
|
||||
|
||||
BLOCK_SAMPLES = 10
|
||||
|
||||
logging.basicConfig(level=logging.WARNING)
|
||||
logg = logging.getLogger()
|
||||
|
||||
default_eth_provider = os.environ.get('RPC_PROVIDER')
|
||||
if default_eth_provider == None:
|
||||
default_eth_provider = os.environ.get('ETH_PROVIDER', 'http://localhost:8545')
|
||||
script_dir = os.path.dirname(os.path.realpath(__file__))
|
||||
config_dir = os.path.join(script_dir, '..', 'data', 'config')
|
||||
|
||||
argparser = argparse.ArgumentParser()
|
||||
argparser.add_argument('-p', '--provider', dest='p', default=default_eth_provider, type=str, help='Web3 provider url (http only)')
|
||||
argparser.add_argument('-i', '--chain-spec', dest='i', type=str, default='evm:ethereum:1', help='Chain specification string')
|
||||
argparser.add_argument('-H', '--human', dest='human', action='store_true', help='Use human-friendly formatting')
|
||||
argparser.add_argument('-u', '--unsafe', dest='u', action='store_true', help='Auto-convert address to checksum adddress')
|
||||
argparser.add_argument('-l', '--long', dest='l', action='store_true', help='Calculate averages through sampling of blocks and txs')
|
||||
argparser.add_argument('-v', action='store_true', help='Be verbose')
|
||||
argparser.add_argument('--seq', action='store_true', help='Use sequential rpc ids')
|
||||
argparser.add_argument('-vv', action='store_true', help='Be more verbose')
|
||||
argparser.add_argument('-y', '--key-file', dest='y', type=str, help='Include summary for keyfile')
|
||||
argparser.add_argument('address', nargs='?', type=str, help='Include summary for address (conflicts with -y)')
|
||||
arg_flags = chainlib.eth.cli.argflag_std_read
|
||||
argparser = chainlib.eth.cli.ArgumentParser(arg_flags)
|
||||
argparser.add_positional('address', type=str, help='Address to retrieve info for', required=False)
|
||||
argparser.add_argument('--long', action='store_true', help='Calculate averages through sampling of blocks and txs')
|
||||
args = argparser.parse_args()
|
||||
|
||||
config = chainlib.eth.cli.Config.from_args(args, arg_flags, extra_args={'long': None}, default_config_dir=config_dir)
|
||||
|
||||
if args.vv:
|
||||
logg.setLevel(logging.DEBUG)
|
||||
elif args.v:
|
||||
logg.setLevel(logging.INFO)
|
||||
holder_address = args.address
|
||||
wallet = chainlib.eth.cli.Wallet()
|
||||
wallet.from_config(config)
|
||||
if wallet.get_signer_address() == None and holder_address != None:
|
||||
wallet.from_address(holder_address)
|
||||
|
||||
signer = None
|
||||
holder_address = None
|
||||
if args.address != None:
|
||||
if not args.u and not is_checksum_address(args.address):
|
||||
raise ValueError('invalid checksum address {}'.format(args.address))
|
||||
holder_address = add_0x(args.address)
|
||||
elif args.y != None:
|
||||
f = open(args.y, 'r')
|
||||
o = json.load(f)
|
||||
f.close()
|
||||
holder_address = add_0x(to_checksum_address(o['address']))
|
||||
|
||||
rpc_id_generator = None
|
||||
if args.seq:
|
||||
rpc_id_generator = IntSequenceGenerator()
|
||||
|
||||
auth = None
|
||||
if os.environ.get('RPC_AUTHENTICATION') == 'basic':
|
||||
from chainlib.auth import BasicAuth
|
||||
auth = BasicAuth(os.environ['RPC_USERNAME'], os.environ['RPC_PASSWORD'])
|
||||
conn = EthHTTPConnection(args.p, auth=auth)
|
||||
|
||||
gas_oracle = OverrideGasOracle(conn)
|
||||
rpc = chainlib.eth.cli.Rpc(wallet=wallet)
|
||||
conn = rpc.connect_by_config(config)
|
||||
|
||||
token_symbol = 'eth'
|
||||
|
||||
chain_spec = ChainSpec.from_chain_str(args.i)
|
||||
chain_spec = ChainSpec.from_chain_str(config.get('CHAIN_SPEC'))
|
||||
|
||||
human = args.human
|
||||
human = not config.true('_RAW')
|
||||
|
||||
longmode = args.l
|
||||
longmode = config.true('_LONG')
|
||||
|
||||
def main():
|
||||
o = network_id(id_generator=rpc_id_generator)
|
||||
o = network_id(id_generator=rpc.id_generator)
|
||||
r = conn.do(o)
|
||||
#if human:
|
||||
# n = format(n, ',')
|
||||
sys.stdout.write('Network id: {}\n'.format(r))
|
||||
|
||||
o = block_latest(id_generator=rpc_id_generator)
|
||||
o = block_latest(id_generator=rpc.id_generator)
|
||||
r = conn.do(o)
|
||||
n = int(r, 16)
|
||||
first_block_number = n
|
||||
@@ -123,7 +83,7 @@ def main():
|
||||
n = format(n, ',')
|
||||
sys.stdout.write('Block: {}\n'.format(n))
|
||||
|
||||
o = block_by_number(first_block_number, False, id_generator=rpc_id_generator)
|
||||
o = block_by_number(first_block_number, False, id_generator=rpc.id_generator)
|
||||
r = conn.do(o)
|
||||
last_block = Block(r)
|
||||
last_timestamp = last_block.timestamp
|
||||
@@ -132,7 +92,7 @@ def main():
|
||||
aggr_time = 0.0
|
||||
aggr_gas = 0
|
||||
for i in range(BLOCK_SAMPLES):
|
||||
o = block_by_number(first_block_number-i, False, id_generator=rpc_id_generator)
|
||||
o = block_by_number(first_block_number-i, False, id_generator=rpc.id_generator)
|
||||
r = conn.do(o)
|
||||
block = Block(r)
|
||||
aggr_time += last_block.timestamp - block.timestamp
|
||||
@@ -150,7 +110,7 @@ def main():
|
||||
sys.stdout.write('Gaslimit: {}\n'.format(n))
|
||||
sys.stdout.write('Blocktime: {}\n'.format(aggr_time / BLOCK_SAMPLES))
|
||||
|
||||
o = price(id_generator=rpc_id_generator)
|
||||
o = price(id_generator=rpc.id_generator)
|
||||
r = conn.do(o)
|
||||
n = int(r, 16)
|
||||
if human:
|
||||
|
||||
@@ -1,12 +1,3 @@
|
||||
#!python3
|
||||
|
||||
"""Gas transfer script
|
||||
|
||||
.. moduleauthor:: Louis Holbrook <dev@holbrook.no>
|
||||
.. pgp:: 0826EDA1702D1E87C6E2875121D2E7BB88C2A746
|
||||
|
||||
"""
|
||||
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
# standard imports
|
||||
@@ -19,6 +10,7 @@ import logging
|
||||
import urllib
|
||||
|
||||
# external imports
|
||||
import chainlib.eth.cli
|
||||
from crypto_dev_signer.eth.signer import ReferenceSigner as EIP155Signer
|
||||
from crypto_dev_signer.keystore.dict import DictKeystore
|
||||
from hexathon import (
|
||||
@@ -45,129 +37,88 @@ from chainlib.eth.tx import (
|
||||
TxFactory,
|
||||
raw,
|
||||
)
|
||||
from chainlib.error import SignerMissingException
|
||||
from chainlib.chain import ChainSpec
|
||||
from chainlib.eth.runnable.util import decode_for_puny_humans
|
||||
from chainlib.eth.jsonrpc import to_blockheight_param
|
||||
|
||||
logging.basicConfig(level=logging.WARNING)
|
||||
logg = logging.getLogger()
|
||||
|
||||
default_eth_provider = os.environ.get('RPC_PROVIDER')
|
||||
if default_eth_provider == None:
|
||||
default_eth_provider = os.environ.get('ETH_PROVIDER', 'http://localhost:8545')
|
||||
script_dir = os.path.dirname(os.path.realpath(__file__))
|
||||
config_dir = os.path.join(script_dir, '..', 'data', 'config')
|
||||
|
||||
argparser = argparse.ArgumentParser()
|
||||
argparser.add_argument('-p', '--provider', dest='p', default=default_eth_provider, type=str, help='Web3 provider url (http only)')
|
||||
argparser.add_argument('-w', action='store_true', help='Wait for the last transaction to be confirmed')
|
||||
argparser.add_argument('-ww', action='store_true', help='Wait for every transaction to be confirmed')
|
||||
argparser.add_argument('-i', '--chain-spec', dest='i', type=str, default='evm:ethereum:1', help='Chain specification string')
|
||||
argparser.add_argument('-y', '--key-file', dest='y', type=str, help='Ethereum keystore file to use for signing')
|
||||
argparser.add_argument('-u', '--unsafe', dest='u', action='store_true', help='Auto-convert address to checksum adddress')
|
||||
argparser.add_argument('--env-prefix', default=os.environ.get('CONFINI_ENV_PREFIX'), dest='env_prefix', type=str, help='environment prefix for variables to overwrite configuration')
|
||||
argparser.add_argument('--nonce', type=int, help='override nonce')
|
||||
argparser.add_argument('--gas-price', dest='gas_price', type=int, help='override gas price')
|
||||
argparser.add_argument('--gas-limit', dest='gas_limit', type=int, help='override gas limit')
|
||||
argparser.add_argument('-a', '--recipient', dest='a', type=str, help='recipient address (None for contract creation)')
|
||||
argparser.add_argument('-value', type=int, help='gas value of transaction in wei')
|
||||
argparser.add_argument('--seq', action='store_true', help='Use sequential rpc ids')
|
||||
argparser.add_argument('-v', action='store_true', help='Be verbose')
|
||||
argparser.add_argument('-vv', action='store_true', help='Be more verbose')
|
||||
argparser.add_argument('-s', '--send', dest='s', action='store_true', help='Send to network')
|
||||
argparser.add_argument('-l', '--local', dest='l', action='store_true', help='Local contract call')
|
||||
argparser.add_argument('data', nargs='?', type=str, help='Transaction data')
|
||||
arg_flags = chainlib.eth.cli.argflag_std_write | chainlib.eth.cli.Flag.EXEC
|
||||
argparser = chainlib.eth.cli.ArgumentParser(arg_flags)
|
||||
argparser.add_positional('data', type=str, help='Transaction data')
|
||||
args = argparser.parse_args()
|
||||
|
||||
|
||||
if args.vv:
|
||||
logg.setLevel(logging.DEBUG)
|
||||
elif args.v:
|
||||
logg.setLevel(logging.INFO)
|
||||
config = chainlib.eth.cli.Config.from_args(args, arg_flags, default_config_dir=config_dir)
|
||||
|
||||
block_all = args.ww
|
||||
block_last = args.w or block_all
|
||||
|
||||
passphrase_env = 'ETH_PASSPHRASE'
|
||||
if args.env_prefix != None:
|
||||
passphrase_env = args.env_prefix + '_' + passphrase_env
|
||||
passphrase = os.environ.get(passphrase_env)
|
||||
if passphrase == None:
|
||||
logg.warning('no passphrase given')
|
||||
passphrase=''
|
||||
wallet = chainlib.eth.cli.Wallet(EIP155Signer)
|
||||
wallet.from_config(config)
|
||||
|
||||
signer_address = None
|
||||
keystore = DictKeystore()
|
||||
if args.y != None:
|
||||
logg.debug('loading keystore file {}'.format(args.y))
|
||||
signer_address = keystore.import_keystore_file(args.y, password=passphrase)
|
||||
logg.debug('now have key for signer address {}'.format(signer_address))
|
||||
signer = EIP155Signer(keystore)
|
||||
rpc = chainlib.eth.cli.Rpc(wallet=wallet)
|
||||
conn = rpc.connect_by_config(config)
|
||||
|
||||
rpc_id_generator = None
|
||||
if args.seq:
|
||||
rpc_id_generator = IntSequenceGenerator()
|
||||
send = config.true('_RPC_SEND')
|
||||
|
||||
auth = None
|
||||
if os.environ.get('RPC_AUTHENTICATION') == 'basic':
|
||||
from chainlib.auth import BasicAuth
|
||||
auth = BasicAuth(os.environ['RPC_USERNAME'], os.environ['RPC_PASSWORD'])
|
||||
conn = EthHTTPConnection(args.p, auth=auth)
|
||||
|
||||
send = args.s
|
||||
|
||||
local = args.l
|
||||
if local:
|
||||
if config.get('_EXEC_ADDRESS') != None:
|
||||
send = False
|
||||
|
||||
nonce_oracle = None
|
||||
gas_oracle = None
|
||||
if signer_address != None and not local:
|
||||
if args.nonce != None:
|
||||
nonce_oracle = OverrideNonceOracle(signer_address, args.nonce)
|
||||
else:
|
||||
nonce_oracle = RPCNonceOracle(signer_address, conn)
|
||||
|
||||
if args.gas_price or args.gas_limit != None:
|
||||
gas_oracle = OverrideGasOracle(price=args.gas_price, limit=args.gas_limit, conn=conn, id_generator=rpc_id_generator)
|
||||
else:
|
||||
gas_oracle = RPCGasOracle(conn, id_generator=rpc_id_generator)
|
||||
|
||||
chain_spec = ChainSpec.from_chain_str(args.i)
|
||||
|
||||
value = args.value
|
||||
|
||||
|
||||
g = TxFactory(chain_spec, signer=signer, gas_oracle=gas_oracle, nonce_oracle=nonce_oracle)
|
||||
chain_spec = None
|
||||
try:
|
||||
chain_spec = ChainSpec.from_chain_str(config.get('CHAIN_SPEC'))
|
||||
except AttributeError:
|
||||
pass
|
||||
|
||||
def main():
|
||||
recipient = None
|
||||
if args.a != None:
|
||||
recipient = add_0x(to_checksum(args.a))
|
||||
if not args.u and recipient != add_0x(recipient):
|
||||
|
||||
signer_address = None
|
||||
try:
|
||||
signer = rpc.get_signer()
|
||||
signer_address = rpc.get_signer_address()
|
||||
except SignerMissingException:
|
||||
pass
|
||||
|
||||
if config.get('_EXEC_ADDRESS') != None:
|
||||
exec_address = add_0x(to_checksum(config.get('_EXEC_ADDRESS')))
|
||||
if not args.u and exec_address != add_0x(exec_address):
|
||||
raise ValueError('invalid checksum address')
|
||||
|
||||
if local:
|
||||
j = JSONRPCRequest(id_generator=rpc_id_generator)
|
||||
j = JSONRPCRequest(id_generator=rpc.id_generator)
|
||||
o = j.template()
|
||||
o['method'] = 'eth_call'
|
||||
o['params'].append({
|
||||
'to': recipient,
|
||||
'to': exec_address,
|
||||
'from': signer_address,
|
||||
'value': '0x00',
|
||||
'gas': add_0x(int.to_bytes(8000000, 8, byteorder='big').hex()), # TODO: better get of network gas limit
|
||||
'gasPrice': '0x01',
|
||||
'data': add_0x(args.data),
|
||||
})
|
||||
o['params'].append('latest')
|
||||
height = to_blockheight_param(config.get('_HEIGHT'))
|
||||
o['params'].append(height)
|
||||
o = j.finalize(o)
|
||||
r = conn.do(o)
|
||||
print(strip_0x(r))
|
||||
try:
|
||||
print(strip_0x(r))
|
||||
except ValueError:
|
||||
sys.stderr.write('query returned an empty value\n')
|
||||
sys.exit(1)
|
||||
return
|
||||
|
||||
elif signer_address != None:
|
||||
if chain_spec == None:
|
||||
raise ValueError('chain spec must be specified')
|
||||
g = TxFactory(chain_spec, signer=rpc.get_signer(), gas_oracle=rpc.get_gas_oracle(), nonce_oracle=rpc.get_nonce_oracle())
|
||||
tx = g.template(signer_address, recipient, use_nonce=True)
|
||||
if args.data != None:
|
||||
tx = g.set_code(tx, add_0x(args.data))
|
||||
|
||||
(tx_hash_hex, o) = g.finalize(tx, id_generator=rpc_id_generator)
|
||||
(tx_hash_hex, o) = g.finalize(tx, id_generator=rpc.id_generator)
|
||||
|
||||
if send:
|
||||
r = conn.do(o)
|
||||
@@ -177,7 +128,7 @@ def main():
|
||||
print(tx_hash_hex)
|
||||
|
||||
else:
|
||||
o = raw(args.data, id_generator=rpc_id_generator)
|
||||
o = raw(args.data, id_generator=rpc.id_generator)
|
||||
if send:
|
||||
r = conn.do(o)
|
||||
print(r)
|
||||
|
||||
Reference in New Issue
Block a user