eth-owned

EIP-173 interface and tools for chainlib-eth
git clone git://holbrook.no/eth-owned.git
Info | Log | Files | Refs

owner.py (2101B)


      1 """Query owner (EIP 173) of contract
      2 
      3 .. moduleauthor:: Louis Holbrook <dev@holbrook.no>
      4 .. pgp:: 0826EDA1702D1E87C6E2875121D2E7BB88C2A746 
      5 
      6 """
      7 
      8 # standard imports
      9 import sys
     10 import os
     11 import json
     12 import argparse
     13 import logging
     14 
     15 # external imports
     16 from funga.eth.signer import EIP155Signer
     17 from funga.eth.keystore.dict import DictKeystore
     18 from chainlib.chain import ChainSpec
     19 from chainlib.eth.connection import EthHTTPConnection
     20 from chainlib.error import JSONRPCException
     21 
     22 # local imports
     23 from eth_owned.owned import Owned
     24 
     25 logging.basicConfig(level=logging.WARNING)
     26 logg = logging.getLogger()
     27 
     28 script_dir = os.path.dirname(__file__)
     29 data_dir = os.path.join(script_dir, '..', 'data')
     30 
     31 default_format = 'terminal'
     32 
     33 argparser = argparse.ArgumentParser()
     34 argparser.add_argument('-p', '--provider', dest='p', default='http://localhost:8545', type=str, help='RPC provider url (http only)')
     35 argparser.add_argument('-i', '--chain-spec', dest='i', type=str, default='evm:ethereum:1', help='Chain specification string')
     36 #argparser.add_argument('-a', '--contract-address', dest='a', required=True, type=str, help='Contract address')
     37 #argparser.add_argument('-f', '--format', dest='f', type=str, default=default_format, help='Output format [human, brief]')
     38 argparser.add_argument('-v', action='store_true', help='Be verbose')
     39 argparser.add_argument('-vv', action='store_true', help='Be more verbose')
     40 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')
     41 argparser.add_argument('address', type=str, nargs='?', help='Address to check registration for')
     42 args = argparser.parse_args()
     43 
     44 if args.vv:
     45     logg.setLevel(logging.DEBUG)
     46 elif args.v:
     47     logg.setLevel(logging.INFO)
     48 
     49 chain_spec = ChainSpec.from_chain_str(args.i)
     50 
     51 rpc = EthHTTPConnection(args.p)
     52 #account_registry_address = args.a
     53 address = args.address
     54 
     55 
     56 def main():
     57     c = Owned(chain_spec)
     58     o = c.owner(address)
     59 
     60     r = rpc.do(o)
     61     owner = c.parse_owner(r)
     62     print(owner)
     63 
     64 
     65 if __name__ == '__main__':
     66     main()