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
|
|
|
|
|
2022-05-12 17:19:16 +02:00
|
|
|
# external imports
|
|
|
|
from chainlib.settings import ChainSettings
|
|
|
|
from chainlib.chain import ChainSpec
|
|
|
|
from chainlib.jsonrpc import IntSequenceGenerator
|
|
|
|
from funga.eth.keystore.dict import DictKeystore
|
|
|
|
from funga.eth.signer import EIP155Signer
|
|
|
|
from hexathon import add_0x
|
|
|
|
|
2021-06-28 07:48:36 +02:00
|
|
|
# local imports
|
2021-08-21 09:27:40 +02:00
|
|
|
import chainlib.eth.cli
|
2022-05-12 10:20:06 +02:00
|
|
|
from chainlib.eth.cli.arg import (
|
|
|
|
Arg,
|
|
|
|
ArgFlag,
|
|
|
|
process_args,
|
|
|
|
)
|
|
|
|
from chainlib.eth.cli.config import (
|
|
|
|
Config,
|
|
|
|
process_config,
|
|
|
|
)
|
|
|
|
from chainlib.eth.cli.log import process_log
|
2021-08-21 09:27:40 +02:00
|
|
|
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
|
2022-05-12 17:19:16 +02:00
|
|
|
from chainlib.eth.settings import process_settings
|
2021-06-28 07:48:36 +02:00
|
|
|
|
|
|
|
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
|
|
|
|
2022-05-12 17:19:16 +02:00
|
|
|
|
|
|
|
def process_config_local(config, arg, args, flags):
|
|
|
|
config.add(args.address, '_RECIPIENT', False)
|
|
|
|
return config
|
|
|
|
|
2022-05-12 10:20:06 +02:00
|
|
|
argparser = chainlib.eth.cli.ArgumentParser()
|
|
|
|
arg_flags = ArgFlag()
|
|
|
|
arg = Arg(arg_flags)
|
|
|
|
flags = arg_flags.STD_BASE_READ | arg_flags.WALLET | arg_flags.UNSAFE
|
|
|
|
argparser = process_args(argparser, arg, flags)
|
|
|
|
|
|
|
|
argparser.add_argument('address', type=str, help='Ethereum address of recipient')
|
2021-06-28 07:48:36 +02:00
|
|
|
args = argparser.parse_args()
|
2022-05-12 10:20:06 +02:00
|
|
|
|
|
|
|
logg = process_log(args, logg)
|
|
|
|
logg.debug('flags {} {} {}'.format(flags, arg_flags.SEQ, flags & arg_flags.SEQ))
|
|
|
|
|
|
|
|
config = Config()
|
|
|
|
config = process_config(config, arg, args, flags)
|
2022-05-12 17:19:16 +02:00
|
|
|
config = process_config_local(config, arg, args, flags)
|
2022-05-12 10:20:06 +02:00
|
|
|
logg.debug('config loaded:\n{}'.format(config))
|
2021-06-28 07:48:36 +02:00
|
|
|
|
2022-05-12 17:19:16 +02:00
|
|
|
settings = ChainSettings()
|
|
|
|
settings = process_settings(settings, config)
|
|
|
|
logg.debug('settings loaded:\n{}'.format(settings))
|
2021-06-28 07:48:36 +02:00
|
|
|
|
|
|
|
|
|
|
|
def main():
|
2021-09-13 08:49:44 +02:00
|
|
|
# TODO: should tolerate if address not prefixed with 0x
|
2022-05-12 17:19:16 +02:00
|
|
|
o = count(
|
|
|
|
settings.get('RECIPIENT'),
|
|
|
|
id_generator=settings.get('RPC_ID_GENERATOR'),
|
|
|
|
)
|
|
|
|
r = settings.get('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()
|