Revert "Add stdin input to replace single positional argument"
This reverts commit 494cb1e0af
.
This commit is contained in:
parent
9f799a9805
commit
1e73579824
@ -1 +1 @@
|
|||||||
include *requirements.txt LICENSE
|
include requirements.txt
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
# standard imports
|
# standard imports
|
||||||
import sys
|
import sys
|
||||||
import select
|
|
||||||
|
|
||||||
# external imports
|
# external imports
|
||||||
from hexathon import strip_0x
|
from hexathon import strip_0x
|
||||||
@ -8,25 +7,8 @@ from hexathon import strip_0x
|
|||||||
# local imports
|
# local imports
|
||||||
from chainlib.eth.address import to_checksum_address
|
from chainlib.eth.address import to_checksum_address
|
||||||
|
|
||||||
v = None
|
|
||||||
if len(sys.argv) > 1:
|
|
||||||
v = sys.argv[1]
|
|
||||||
else:
|
|
||||||
h = select.select([sys.stdin], [], [], 0)
|
|
||||||
if len(h[0]) > 0:
|
|
||||||
v = h[0][0].read()
|
|
||||||
v = v.rstrip()
|
|
||||||
|
|
||||||
if v == None:
|
|
||||||
sys.stderr.write('input missing\n')
|
|
||||||
sys.exit(1)
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
try:
|
print(to_checksum_address(strip_0x(sys.argv[1])))
|
||||||
print(to_checksum_address(strip_0x(v)))
|
|
||||||
except ValueError as e:
|
|
||||||
sys.stderr.write('invalid input: {}\n'.format(e))
|
|
||||||
sys.exit(1)
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
@ -6,7 +6,6 @@ import os
|
|||||||
import json
|
import json
|
||||||
import argparse
|
import argparse
|
||||||
import logging
|
import logging
|
||||||
import select
|
|
||||||
|
|
||||||
# local imports
|
# local imports
|
||||||
from chainlib.eth.address import to_checksum
|
from chainlib.eth.address import to_checksum
|
||||||
@ -15,20 +14,12 @@ from chainlib.eth.tx import count
|
|||||||
from chainlib.chain import ChainSpec
|
from chainlib.chain import ChainSpec
|
||||||
from crypto_dev_signer.keystore.dict import DictKeystore
|
from crypto_dev_signer.keystore.dict import DictKeystore
|
||||||
from crypto_dev_signer.eth.signer import ReferenceSigner as EIP155Signer
|
from crypto_dev_signer.eth.signer import ReferenceSigner as EIP155Signer
|
||||||
from hexathon import add_0x
|
|
||||||
|
|
||||||
logging.basicConfig(level=logging.WARNING)
|
logging.basicConfig(level=logging.WARNING)
|
||||||
logg = logging.getLogger()
|
logg = logging.getLogger()
|
||||||
|
|
||||||
default_eth_provider = os.environ.get('ETH_PROVIDER', 'http://localhost:8545')
|
default_eth_provider = os.environ.get('ETH_PROVIDER', 'http://localhost:8545')
|
||||||
|
|
||||||
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 = argparse.ArgumentParser()
|
||||||
argparser.add_argument('-p', '--provider', dest='p', default='http://localhost:8545', type=str, help='Web3 provider url (http only)')
|
argparser.add_argument('-p', '--provider', dest='p', default='http://localhost:8545', 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('-i', '--chain-spec', dest='i', type=str, default='evm:ethereum:1', help='Chain specification string')
|
||||||
@ -37,17 +28,15 @@ argparser.add_argument('--env-prefix', default=os.environ.get('CONFINI_ENV_PREFI
|
|||||||
argparser.add_argument('-u', '--unsafe', dest='u', action='store_true', help='Auto-convert address to checksum adddress')
|
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('-v', action='store_true', help='Be verbose')
|
||||||
argparser.add_argument('-vv', action='store_true', help='Be more 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')
|
argparser.add_argument('address', type=str, help='Ethereum address of recipient')
|
||||||
args = argparser.parse_args()
|
args = argparser.parse_args()
|
||||||
|
|
||||||
if args.address == None:
|
|
||||||
argparser.error('need first positional argument or value from stdin')
|
|
||||||
|
|
||||||
if args.vv:
|
if args.vv:
|
||||||
logg.setLevel(logging.DEBUG)
|
logg.setLevel(logging.DEBUG)
|
||||||
elif args.v:
|
elif args.v:
|
||||||
logg.setLevel(logging.INFO)
|
logg.setLevel(logging.INFO)
|
||||||
|
|
||||||
|
|
||||||
signer_address = None
|
signer_address = None
|
||||||
keystore = DictKeystore()
|
keystore = DictKeystore()
|
||||||
if args.y != None:
|
if args.y != None:
|
||||||
@ -63,7 +52,7 @@ def main():
|
|||||||
if not args.u and recipient != add_0x(args.address):
|
if not args.u and recipient != add_0x(args.address):
|
||||||
raise ValueError('invalid checksum address')
|
raise ValueError('invalid checksum address')
|
||||||
|
|
||||||
o = count(recipient)
|
o = count(args.address)
|
||||||
print(rpc.do(o))
|
print(rpc.do(o))
|
||||||
|
|
||||||
|
|
||||||
|
@ -15,9 +15,8 @@ import os
|
|||||||
import json
|
import json
|
||||||
import argparse
|
import argparse
|
||||||
import logging
|
import logging
|
||||||
import select
|
|
||||||
|
|
||||||
# external imports
|
# third-party imports
|
||||||
from chainlib.eth.tx import unpack
|
from chainlib.eth.tx import unpack
|
||||||
from chainlib.chain import ChainSpec
|
from chainlib.chain import ChainSpec
|
||||||
|
|
||||||
@ -31,27 +30,14 @@ logg = logging.getLogger()
|
|||||||
default_abi_dir = os.environ.get('ETH_ABI_DIR', '/usr/share/local/cic/solidity/abi')
|
default_abi_dir = os.environ.get('ETH_ABI_DIR', '/usr/share/local/cic/solidity/abi')
|
||||||
default_eth_provider = os.environ.get('ETH_PROVIDER', 'http://localhost:8545')
|
default_eth_provider = os.environ.get('ETH_PROVIDER', 'http://localhost:8545')
|
||||||
|
|
||||||
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 = argparse.ArgumentParser()
|
||||||
argparser.add_argument('-i', '--chain-id', dest='i', default='evm:ethereum:1', type=str, help='Numeric network id')
|
|
||||||
argparser.add_argument('tx', type=str, nargs='?', default=stdin_arg(), help='hex-encoded signed raw transaction')
|
|
||||||
argparser.add_argument('-v', action='store_true', help='Be verbose')
|
argparser.add_argument('-v', action='store_true', help='Be verbose')
|
||||||
argparser.add_argument('-vv', action='store_true', help='Be more verbose')
|
argparser.add_argument('-i', '--chain-id', dest='i', default='evm:ethereum:1', type=str, help='Numeric network id')
|
||||||
|
argparser.add_argument('tx', type=str, help='hex-encoded signed raw transaction')
|
||||||
args = argparser.parse_args()
|
args = argparser.parse_args()
|
||||||
|
|
||||||
if args.tx == None:
|
if args.v:
|
||||||
argparser.error('need first positional argument or value from stdin')
|
|
||||||
|
|
||||||
if args.vv:
|
|
||||||
logg.setLevel(logging.DEBUG)
|
logg.setLevel(logging.DEBUG)
|
||||||
elif args.v:
|
|
||||||
logg.setLevel(logging.INFO)
|
|
||||||
|
|
||||||
chain_spec = ChainSpec.from_chain_str(args.i)
|
chain_spec = ChainSpec.from_chain_str(args.i)
|
||||||
|
|
||||||
|
@ -16,7 +16,6 @@ import json
|
|||||||
import argparse
|
import argparse
|
||||||
import logging
|
import logging
|
||||||
import enum
|
import enum
|
||||||
import select
|
|
||||||
|
|
||||||
# external imports
|
# external imports
|
||||||
from hexathon import (
|
from hexathon import (
|
||||||
@ -44,14 +43,7 @@ logg = logging.getLogger()
|
|||||||
default_abi_dir = os.environ.get('ETH_ABI_DIR', '/usr/share/local/cic/solidity/abi')
|
default_abi_dir = os.environ.get('ETH_ABI_DIR', '/usr/share/local/cic/solidity/abi')
|
||||||
default_eth_provider = os.environ.get('ETH_PROVIDER', 'http://localhost:8545')
|
default_eth_provider = os.environ.get('ETH_PROVIDER', 'http://localhost:8545')
|
||||||
|
|
||||||
def stdin_arg():
|
argparser = argparse.ArgumentParser()
|
||||||
h = select.select([sys.stdin], [], [], 0)
|
|
||||||
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('-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('-i', '--chain-spec', dest='i', type=str, default='evm:ethereum:1', help='Chain specification string')
|
||||||
argparser.add_argument('-t', '--token-address', dest='t', type=str, help='Token address. If not set, will return gas balance')
|
argparser.add_argument('-t', '--token-address', dest='t', type=str, help='Token address. If not set, will return gas balance')
|
||||||
@ -59,12 +51,9 @@ argparser.add_argument('-u', '--unsafe', dest='u', action='store_true', help='Au
|
|||||||
argparser.add_argument('--abi-dir', dest='abi_dir', type=str, default=default_abi_dir, help='Directory containing bytecode and abi (default {})'.format(default_abi_dir))
|
argparser.add_argument('--abi-dir', dest='abi_dir', type=str, default=default_abi_dir, help='Directory containing bytecode and abi (default {})'.format(default_abi_dir))
|
||||||
argparser.add_argument('-v', action='store_true', help='Be verbose')
|
argparser.add_argument('-v', action='store_true', help='Be verbose')
|
||||||
argparser.add_argument('-vv', action='store_true', help='Be more 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)')
|
argparser.add_argument('item', type=str, help='Item to get information for (address og transaction)')
|
||||||
args = argparser.parse_args()
|
args = argparser.parse_args()
|
||||||
|
|
||||||
if args.item == None:
|
|
||||||
argparser.error('need first positional argument or value from stdin')
|
|
||||||
|
|
||||||
if args.vv:
|
if args.vv:
|
||||||
logg.setLevel(logging.DEBUG)
|
logg.setLevel(logging.DEBUG)
|
||||||
elif args.v:
|
elif args.v:
|
||||||
|
Loading…
Reference in New Issue
Block a user