eth-accounts-index

Accounts index evm contract tooling with permissioned writes
Info | Log | Files | Refs

publish.py (2289B)


      1 """Deploys accounts index, registering arbitrary number of writers
      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 logging
     12 
     13 # external imports
     14 import chainlib.eth.cli
     15 from chainlib.chain import ChainSpec
     16 from chainlib.eth.connection import EthHTTPConnection
     17 from chainlib.eth.tx import receipt
     18 from chainlib.eth.cli.arg import (
     19         Arg,
     20         ArgFlag,
     21         process_args,
     22         )
     23 from chainlib.eth.cli.config import (
     24         Config,
     25         process_config,
     26         )
     27 from chainlib.eth.cli.log import process_log
     28 from chainlib.eth.settings import process_settings
     29 from chainlib.settings import ChainSettings
     30 
     31 # local imports
     32 from eth_accounts_index.registry import AccountRegistry
     33 
     34 logging.basicConfig(level=logging.WARNING)
     35 logg = logging.getLogger()
     36 
     37 arg_flags = ArgFlag()
     38 arg = Arg(arg_flags)
     39 flags = arg_flags.STD_WRITE 
     40 
     41 argparser = chainlib.eth.cli.ArgumentParser()
     42 argparser = process_args(argparser, arg, flags)
     43 args = argparser.parse_args()
     44 
     45 logg = process_log(args, logg)
     46 
     47 config = Config()
     48 config = process_config(config, arg, args, flags)
     49 logg.debug('config loaded:\n{}'.format(config))
     50 
     51 settings = ChainSettings()
     52 settings = process_settings(settings, config)
     53 logg.debug('settings loaded:\n{}'.format(settings))
     54 
     55 
     56 def main():
     57     conn = settings.get('CONN')
     58 
     59     c = AccountRegistry(
     60             settings.get('CHAIN_SPEC'),
     61             signer=settings.get('SIGNER'),
     62             gas_oracle=settings.get('FEE_ORACLE'),
     63             nonce_oracle=settings.get('NONCE_ORACLE'),
     64             )
     65 
     66     (tx_hash_hex, o) = c.constructor(
     67             settings.get('SENDER_ADDRESS'),
     68             )
     69 
     70     if settings.get('RPC_SEND'):
     71         conn.do(o)
     72         if config.true('_WAIT'):
     73             r = conn.wait(tx_hash_hex)
     74             if r['status'] == 0:
     75                 sys.stderr.write('EVM revert while deploying contract. Wish I had more to tell you')
     76                 sys.exit(1)
     77             # TODO: pass through translator for keys (evm tester uses underscore instead of camelcase)
     78             address = r['contractAddress']
     79 
     80             print(address)
     81         else:
     82             print(tx_hash_hex)
     83     else:
     84         print(o)
     85 
     86 
     87 if __name__ == '__main__':
     88     main()