async def register(self, email: Optional[str] = None, eth_address: Optional[str] = None) -> Dict[str, Any]: if email is None or eth_address is None: bounty_config: Dict[str, Any] = {key: cvar.value for key, cvar in liquidity_bounty_config_map.items()} assert bounty_config["liquidity_bounty_enabled"] assert bounty_config["agree_to_terms"] assert bounty_config["agree_to_data_collection"] assert bounty_config["final_confirmation"] email = bounty_config["email"] eth_address = bounty_config["eth_address"] try: client = await self._http_client() data = {"email": email, "eth_address": eth_address} async with client.request("POST", f"{self.LIQUIDITY_BOUNTY_REST_API}/client", json=data) as resp: # registration_status = "success" or <reason_for_failure> if resp.status not in {200, 400}: raise Exception(f"Liquidity bounty server error. Server responded with status {resp.status}") results = await resp.json() if results["registration_status"] != "success": raise Exception(f"Failed to register for liquidity bounty: {results['registration_status']}") return results except AssertionError: raise except asyncio.CancelledError: raise except Exception: raise
async def bounty_config_loop(self, # type: HummingbotApplication ): """ Configuration loop for bounty registration """ self.placeholder_mode = True self.app.toggle_hide_input() self._notify("Starting registration process for liquidity bounties:") try: for key, cvar in liquidity_bounty_config_map.items(): if key == "liquidity_bounty_enabled": await self.print_doc(join(dirname(__file__), "../liquidity_bounty/requirements.txt")) elif key == "agree_to_terms": await self.bounty_print_terms() elif key == "agree_to_data_collection": await self.print_doc(join(dirname(__file__), "../liquidity_bounty/data_collection_policy.txt")) elif key == "eth_address": self._notify("\nYour wallets:") self.list("wallets") value = await self.prompt_single_variable(cvar) cvar.value = parse_cvar_value(cvar, value) if cvar.type == "bool" and cvar.value is False: raise ValueError(f"{cvar.key} is required.") await save_to_yml(LIQUIDITY_BOUNTY_CONFIG_PATH, liquidity_bounty_config_map) except ValueError as e: self._notify(f"Registration aborted: {str(e)}") except Exception as e: self.logger().error(f"Error configuring liquidity bounty: {str(e)}") self.app.change_prompt(prompt=">>> ") self.app.toggle_hide_input() self.placeholder_mode = False