def get_matchmaking_config() -> dict: """Return the endpoint for a particular dragonchain Args: dragonchain_id: dragonchain id to fetch the endpoint Returns: String of dragonchain endpoint """ config = { "level": int(os.environ["LEVEL"]), "url": os.environ["DRAGONCHAIN_ENDPOINT"], "scheme": os.environ.get("PROOF_SCHEME") or "trust", "hashAlgo": os.environ["HASH"], "version": os.environ["DRAGONCHAIN_VERSION"], "encryptionAlgo": os.environ["ENCRYPTION"], } if os.environ["LEVEL"] == "5": client = interchain_dao.get_default_interchain_client() network_extra = "" if client.blockchain == "ethereum": client = cast("eth.EthereumNetwork", client) network_extra += f" network_id {client.chain_id}" elif client.blockchain == "bitcoin": client = cast("btc.BitcoinNetwork", client) network_extra += f" {'testnet3' if client.testnet else 'mainnet'}" config["network"] = f"{client.blockchain}{network_extra}" config["funded"] = bool(redis.get_sync("dc:isFunded", decode=False)) config["broadcastInterval"] = float(os.environ.get("BROADCAST_INTERVAL") or "2") config["interchainWallet"] = client.address return config
def get_matchmaking_config() -> dict: """Return the endpoint for a particular dragonchain Args: dragonchain_id: dragonchain id to fetch the endpoint Returns: String of dragonchain endpoint """ config = { "level": int(os.environ["LEVEL"]), "url": os.environ["DRAGONCHAIN_ENDPOINT"], "scheme": os.environ.get("PROOF_SCHEME") or "trust", "hashAlgo": os.environ["HASH"], "version": os.environ["DRAGONCHAIN_VERSION"], "encryptionAlgo": os.environ["ENCRYPTION"], } if os.environ["LEVEL"] == "5": try: client = interchain_dao.get_default_interchain_client() config["network"] = client.get_network_string() config["interchainWallet"] = client.address except exceptions.NotFound: _log.warning( "L5 chain does not have a default interchain network set") config["funded"] = bool(redis.get_sync("dc:isFunded", decode=False)) config["broadcastInterval"] = float( os.environ.get("BROADCAST_INTERVAL") or "2") return config
def setup() -> None: """ This function must be called to set up module state before using the rest of the module This is stubbed like so to assist in testing """ global BROADCAST_INTERVAL global INTERCHAIN_NETWORK global FUNDED global _interchain_client my_config = matchmaking.get_matchmaking_config() BROADCAST_INTERVAL = int(my_config["broadcastInterval"] * 3600) INTERCHAIN_NETWORK = my_config["network"] FUNDED = my_config["funded"] _interchain_client = interchain_dao.get_default_interchain_client() _log.info(f"[L5] MY CONFIG -------> {my_config}")
def get_default_interchain_v1() -> Dict[str, Any]: return _get_output_dto_v1(interchain_dao.get_default_interchain_client())
def test_get_default_client_gets_from_storage(self, mock_get_storage, mock_get_interchain_client): self.assertEqual(interchain_dao.get_default_interchain_client(), "yes") mock_get_storage.assert_called_once_with("INTERCHAINS/default") mock_get_interchain_client.assert_called_once_with( "thing", "something")