def ethr_leader(multisig_account, configuration: Config, web3_provider, multisig_wallet, ether_accounts): configuration['leader_key'] = ether_accounts[0].key configuration['leader_acc_addr'] = normalize_address(ether_accounts[0].address) configuration['eth_start_block'] = web3_provider.eth.blockNumber leader = EtherLeader(multisig_wallet, configuration['leader_key'], configuration['leader_acc_addr'], configuration) leader.start() yield leader leader.stop_event.set()
def run_bridge(): # pylint: disable=too-many-statements runners = [] logger = get_logger(logger_name='runner') required_configs = ['MODE', 'secret_node', 'multisig_acc_addr', 'chain_id'] cfg = Config(required=required_configs) try: configure_secretcli(cfg) except RuntimeError: logger = get_logger(logger_name='runner') logger.error('Failed to set up secretcli') sys.exit(1) if cfg.get('token', ''): signer = Pkcs11CryptoStore(store=cfg["PKCS11_MODULE"], token=cfg["token"], user_pin=cfg["user_pin"], label=cfg.get('label')) else: signer = LocalCryptoStore(private_key=bytes_from_hex( cfg['eth_private_key']), account=cfg['eth_address']) logger.info(f'Starting with ETH address {signer.address}') with database(db=cfg['db_name'], host=cfg['db_host'], password=cfg['db_password'], username=cfg['db_username']): eth_wallet = MultisigWallet(w3, cfg['multisig_wallet_address']) secret_account = SecretAccount(cfg['multisig_acc_addr'], cfg['secret_key_name']) eth_signer = EtherSigner(eth_wallet, signer, dst_network="Secret", config=cfg) s20_signer = Secret20Signer(secret_account, eth_wallet, cfg) runners.append(eth_signer) runners.append(s20_signer) if cfg['MODE'].lower() == 'leader': eth_leader = EtherLeader(eth_wallet, signer, dst_network="Secret", config=cfg) secret_leader = SecretAccount(cfg['multisig_acc_addr'], cfg['multisig_key_name']) s20_leader = Secret20Leader(secret_leader, eth_wallet, src_network="Ethereum", config=cfg) runners.append(eth_leader) runners.append(s20_leader) run_all(runners)
def run_bridge(): # pylint: disable=too-many-statements runners = [] logger = get_logger(logger_name='runner', loglevel=config.log_level) try: configure_secretcli(config) except RuntimeError: logger = get_logger(logger_name='runner', loglevel=config.log_level) logger.error('Failed to set up secretcli') sys.exit(1) if config.token: signer = Pkcs11CryptoStore(store=config.pkcs11_module, token=config.token, user_pin=config.user_pin, label=config.label) else: signer = LocalCryptoStore(private_key=bytes_from_hex( config.eth_private_key), account=config.eth_address) logger.info(f'Starting with ETH address {signer.address}') uri = config.db_uri if not uri: db = config.db_name or 'test_db' host = config.db_host or 'localhost' password = config.db_password username = config.db_username uri = f"mongodb+srv://{username}:{password}@{host}/{db}?retryWrites=true&w=majority" with database(uri): eth_wallet = MultisigWallet(w3, config.multisig_wallet_address) secret_account = SecretAccount(config.multisig_acc_addr, config.secret_key_name) eth_signer = EtherSigner(eth_wallet, signer, config=config) s20_signer = Secret20Signer(secret_account, eth_wallet, config) runners.append(s20_signer) if config.mode.lower() == 'signer': runners.append(eth_signer) if config.mode.lower() == 'leader': eth_leader = EtherLeader(eth_wallet, signer, config=config) secret_leader = SecretAccount(config.multisig_acc_addr, config.multisig_key_name) s20_leader = Secret20Leader(secret_leader, eth_wallet, config=config) runners.append(eth_leader) runners.append(s20_leader) # run_all(runners) run(runners, config)
def get_leader(coin_name: str, eth_contract: Union[Erc20, MultisigWallet], private_key, account, cfg: Config) -> Thread: if NETWORK_PARAMS[coin_name]['type'] == 'erc20': token = get_token(coin_name, cfg['network']) return ERC20Leader(eth_contract, token, private_key, account, config=cfg) if NETWORK_PARAMS[coin_name]['type'] == 'eth': return EtherLeader(eth_contract, private_key, account, config=cfg) if NETWORK_PARAMS[coin_name]['type'] == 's20': s20token = get_token(coin_name, cfg['chain_id']) account = SecretAccount(cfg['multisig_acc_addr'], cfg['multisig_key_name']) return Secret20Leader(account, s20token, eth_contract, config=cfg) raise TypeError
def ethr_leader(multisig_account, configuration: Config, web3_provider, erc20_token, multisig_wallet, ether_accounts): configuration['leader_key'] = ether_accounts[0].key configuration['leader_acc_addr'] = normalize_address( ether_accounts[0].address) configuration['eth_start_block'] = web3_provider.eth.blockNumber # token_map = configuration["token_map_scrt"] signer = LocalCryptoStore(private_key=configuration['leader_key'], account=configuration['leader_acc_addr']) leader = EtherLeader(multisig_wallet, signer, dst_network="Secret", config=configuration) leader.start() yield leader leader.stop()