2021-06-28 07:48:36 +02:00
|
|
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
|
|
|
|
# standard imports
|
|
|
|
import sys
|
|
|
|
import os
|
|
|
|
import json
|
2021-08-21 09:27:40 +02:00
|
|
|
#import argparse
|
2021-06-28 07:48:36 +02:00
|
|
|
import logging
|
|
|
|
import select
|
|
|
|
|
|
|
|
# local imports
|
2021-08-21 09:27:40 +02:00
|
|
|
import chainlib.eth.cli
|
|
|
|
from chainlib.eth.address import AddressChecksum
|
2021-06-28 07:48:36 +02:00
|
|
|
from chainlib.eth.connection import EthHTTPConnection
|
|
|
|
from chainlib.eth.tx import count
|
|
|
|
from chainlib.chain import ChainSpec
|
|
|
|
from chainlib.jsonrpc import IntSequenceGenerator
|
|
|
|
from crypto_dev_signer.keystore.dict import DictKeystore
|
|
|
|
from crypto_dev_signer.eth.signer import ReferenceSigner as EIP155Signer
|
|
|
|
from hexathon import add_0x
|
|
|
|
|
|
|
|
logging.basicConfig(level=logging.WARNING)
|
|
|
|
logg = logging.getLogger()
|
|
|
|
|
2021-08-21 09:27:40 +02:00
|
|
|
script_dir = os.path.dirname(os.path.realpath(__file__))
|
|
|
|
config_dir = os.path.join(script_dir, '..', 'data', 'config')
|
2021-06-28 07:48:36 +02:00
|
|
|
|
2021-08-21 09:27:40 +02:00
|
|
|
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')
|
2021-06-28 07:48:36 +02:00
|
|
|
args = argparser.parse_args()
|
2021-08-21 09:27:40 +02:00
|
|
|
config = chainlib.eth.cli.Config.from_args(args, arg_flags, default_config_dir=config_dir)
|
2021-06-28 07:48:36 +02:00
|
|
|
|
2021-08-21 09:27:40 +02:00
|
|
|
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)
|
2021-06-28 07:48:36 +02:00
|
|
|
|
2021-08-21 09:27:40 +02:00
|
|
|
rpc = chainlib.eth.cli.Rpc(wallet=wallet)
|
|
|
|
conn = rpc.connect_by_config(config)
|
2021-06-28 07:48:36 +02:00
|
|
|
|
|
|
|
|
|
|
|
def main():
|
2021-08-21 09:27:40 +02:00
|
|
|
o = count(holder_address, id_generator=rpc.id_generator)
|
|
|
|
r = conn.do(o)
|
2021-06-28 07:48:36 +02:00
|
|
|
count_result = None
|
|
|
|
try:
|
|
|
|
count_result = int(r, 16)
|
|
|
|
except ValueError:
|
|
|
|
count_result = int(r, 10)
|
|
|
|
print(count_result)
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
main()
|