def initialize():
        if not ConfigManager.isInitialized():
            return False

        try:
            theta_abi_file_path = ConfigManager.getConfig(
            ).getThetaAbiFilePath()
            with open(theta_abi_file_path) as abi_json_data:
                TransactionSigner._theta_abi = json.load(abi_json_data)
        except:
            return False
        if TransactionSigner._theta_abi is None:
            return False

        try:
            theta_token_sale_abi_file_path = ConfigManager.getConfig(
            ).getThetaTokenSaleAbiFilePath()
            with open(theta_token_sale_abi_file_path) as abi_json_data:
                TransactionSigner._theta_token_sale_abi = json.load(
                    abi_json_data)
        except:
            return False
        if TransactionSigner._theta_token_sale_abi is None:
            return False

        return True
 def _getToAddress(smart_contract_name):
     if smart_contract_name == SmartContractName.THETA_TOKEN:
         return ConfigManager.getConfig().getThetaContractAddresss()
     elif smart_contract_name == SmartContractName.THETA_TOKEN_SALE:
         return ConfigManager.getConfig().getThetaTokenSaleContractAddresss(
         )
     else:
         return None
Esempio n. 3
0
def initialize(path_to_config_file, path_to_key_info_json):
    log = logging.getLogger('werkzeug')
    log.setLevel(logging.ERROR)
    success = ConfigManager.load(path_to_config_file)
    if not success:
        return False

    config = ConfigManager.getConfig()
    Logger.setLogFolder(config.server_log_file_folder)
    success = TransactionSigner.initialize()
    if not success:
        return False

    success = KeyInfoManager.load(path_to_key_info_json)
    if not success:
        return False

    if KeyInfoManager.getKeyInfo(KeyAlias.WHITELIST_CONTROLLER) == None:
        Logger.printError('%s key info not loaded!' %
                          (KeyAlias.WHITELIST_CONTROLLER))
        return False

    if KeyInfoManager.getKeyInfo(KeyAlias.EXCHANGE_RATE_CONTROLLER) == None:
        Logger.printError('%s key info not loaded!' %
                          (KeyAlias.EXCHANGE_RATE_CONTROLLER))
        return False

    success = TransactionSigner.initialize()
    if not success:
        return False

    return True
Esempio n. 4
0
        return False

    if KeyInfoManager.getKeyInfo(KeyAlias.EXCHANGE_RATE_CONTROLLER) == None:
        Logger.printError('%s key info not loaded!' %
                          (KeyAlias.EXCHANGE_RATE_CONTROLLER))
        return False

    success = TransactionSigner.initialize()
    if not success:
        return False

    return True


app = Flask(__name__)
api = Api(app)
api.add_resource(WhitelistResource, '/whitelist/sign')
api.add_resource(ExchangeRateResource, '/exchange_rate/sign')

if __name__ == '__main__':
    path_to_config_file = '../config.json'
    path_to_key_info_json = '../data/key_info.json'
    success = initialize(path_to_config_file, path_to_key_info_json)
    if not success:
        exit(1)

    host = '0.0.0.0'
    port = ConfigManager.getConfig().getPort()
    Logger.printInfo('Running test server at %s:%s' % (host, port))
    app.run(threaded=True, debug=True, host=host, port=port)