예제 #1
0
    async def bounty_restore_id(self,  # type: HummingbotApplication
                               ):
        """ Retrieve bounty client id with email when the id is lost"""
        if self.liquidity_bounty is None:
            self.liquidity_bounty: LiquidityBounty = LiquidityBounty.get_instance()

        self.placeholder_mode = True
        self.app.toggle_hide_input()
        self._notify("Starting registration process for liquidity bounties:")

        try:
            email: str = await self.app.prompt("What is the email address you used to register for the bounty? >>> ")
            msg: str = await self.liquidity_bounty.restore_id(email)
            self._notify(msg)

            verification_code: str = await self.app.prompt("Please enter the verification code you received in the "
                                                           "email >>> ")
            client_id = await self.liquidity_bounty.send_verification_code(email, verification_code)

            liquidity_bounty_config_map.get("liquidity_bounty_enabled").value = True
            liquidity_bounty_config_map.get("liquidity_bounty_client_id").value = client_id
            await save_to_yml(LIQUIDITY_BOUNTY_CONFIG_PATH, liquidity_bounty_config_map)

            self._notify("\nYour bounty ID has been reset successfully. You may now start collecting bounties!\n")
            self.liquidity_bounty.start()
        except Exception as e:
            self._notify(f"Bounty reset aborted: {str(e)}")

        self.app.change_prompt(prompt=">>> ")
        self.app.toggle_hide_input()
        self.placeholder_mode = False
예제 #2
0
 def _initialize_liquidity_bounty(self):
     if (
         liquidity_bounty_config_map.get("liquidity_bounty_enabled").value is not None
         and liquidity_bounty_config_map.get("liquidity_bounty_client_id").value is not None
     ):
         self.liquidity_bounty = LiquidityBounty.get_instance()
         self.liquidity_bounty.start()
예제 #3
0
    async def authenticated_request(self, request_method: str, url: str,
                                    **kwargs) -> Dict[str, Any]:
        try:
            # Set default data value here in case an assertion error occurs
            data = None
            client = await self._http_client()
            client_id = liquidity_bounty_config_map.get(
                "liquidity_bounty_client_id").value
            assert client_id is not None
            headers = {"Client-ID": client_id}

            async with client.request(request_method,
                                      url,
                                      headers=headers,
                                      **kwargs) as resp:
                data = await resp.text()
                self.logger().debug(f"{resp.status} {data}")
                results = json.loads(data)
                if "error" in results:
                    raise Exception(results.get("error"))
                if resp.status == 500:
                    raise Exception(
                        f"Server side error when submitting to {url}")
                if results.get("status", "") == "Unknown client id":
                    raise Exception("User not registered")
                return results
        except Exception as e:
            self.logger().network(
                f"Error in authenticated request: {str(e)}, data: {data}",
                exc_info=True)
            raise
예제 #4
0
 async def bounty_registration(self,  # type: HummingbotApplication
                               ):
     """ Register for the bounty program """
     if liquidity_bounty_config_map.get("liquidity_bounty_enabled").value and \
         liquidity_bounty_config_map.get("liquidity_bounty_client_id").value:
         self._notify("You are already registered to collect bounties.")
         return
     await self.bounty_config_loop()
     self._notify("Registering for liquidity bounties...")
     self.liquidity_bounty = LiquidityBounty.get_instance()
     try:
         registration_results = await self.liquidity_bounty.register()
         self._notify("Registration successful.")
         client_id = registration_results["client_id"]
         liquidity_bounty_config_map.get("liquidity_bounty_client_id").value = client_id
         await save_to_yml(LIQUIDITY_BOUNTY_CONFIG_PATH, liquidity_bounty_config_map)
         self.liquidity_bounty.start()
         self._notify("Hooray! You are now collecting bounties. ")
     except Exception as e:
         self._notify(str(e))
         self.liquidity_bounty = None