eth-token-index

Token symbol to address unique index
Info | Log | Files | Refs

publish.py (2278B)


      1 """Deploys the token symbol index
      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 import chainlib.eth.cli
     17 from chainlib.chain import ChainSpec
     18 from chainlib.eth.tx import receipt
     19 from chainlib.eth.cli.arg import (
     20         Arg,
     21         ArgFlag,
     22         process_args,
     23         )
     24 from chainlib.eth.cli.config import (
     25         Config,
     26         process_config,
     27         )
     28 from chainlib.eth.cli.log import process_log
     29 from chainlib.eth.settings import process_settings
     30 from chainlib.settings import ChainSettings
     31 
     32 # local imports
     33 from eth_token_index import TokenUniqueSymbolIndex
     34 
     35 logging.basicConfig(level=logging.WARNING)
     36 logg = logging.getLogger()
     37 
     38 
     39 arg_flags = ArgFlag()
     40 arg = Arg(arg_flags)
     41 flags = arg_flags.STD_WRITE 
     42 
     43 argparser = chainlib.eth.cli.ArgumentParser()
     44 argparser = process_args(argparser, arg, flags)
     45 args = argparser.parse_args()
     46 
     47 logg = process_log(args, logg)
     48 
     49 config = Config()
     50 config = process_config(config, arg, args, flags)
     51 #config = process_config_local(config, arg, args, flags)
     52 logg.debug('config loaded:\n{}'.format(config))
     53 
     54 settings = ChainSettings()
     55 settings = process_settings(settings, config)
     56 logg.debug('settings loaded:\n{}'.format(settings))
     57 
     58 
     59 def main():
     60     conn = settings.get('CONN')
     61     c = TokenUniqueSymbolIndex(
     62             settings.get('CHAIN_SPEC'),
     63             signer=settings.get('SIGNER'),
     64             gas_oracle=settings.get('FEE_ORACLE'),
     65             nonce_oracle=settings.get('NONCE_ORACLE'),
     66             )
     67     (tx_hash_hex, o) = c.constructor(
     68         settings.get('SENDER_ADDRESS')
     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()