Skip to content

Commit

Permalink
Merge pull request #2782 from Drakkar-Software/dev
Browse files Browse the repository at this point in the history
Dev merge
  • Loading branch information
GuillaumeDSM authored Oct 26, 2024
2 parents 91a3460 + ffb69f7 commit 538e205
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 12 deletions.
21 changes: 12 additions & 9 deletions octobot/community/supabase_backend/community_supabase_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ async def sign_in(self, email: str, password: str) -> None:
if "email" in str(err).lower():
# AuthApiError('Email not confirmed')
raise errors.EmailValidationRequiredError(err) from err
raise authentication.FailedAuthentication(err) from err
raise authentication.FailedAuthentication(f"Community auth error: {err}") from err

async def sign_up(self, email: str, password: str) -> None:
try:
Expand All @@ -117,7 +117,7 @@ async def sign_up(self, email: str, password: str) -> None:
if self._requires_email_validation(resp.user):
raise errors.EmailValidationRequiredError()
except gotrue.errors.AuthError as err:
raise authentication.AuthenticationError(err) from err
raise authentication.AuthenticationError(f"Community auth error: {err}") from err

async def sign_out(self, options: gotrue.types.SignOutOptions) -> None:
try:
Expand All @@ -132,13 +132,13 @@ async def restore_session(self):
self.event_loop = asyncio.get_event_loop()
await self.auth.initialize_from_storage()
if not self.is_signed_in():
raise authentication.FailedAuthentication()
raise authentication.FailedAuthentication(f"Community auth error: restoring session failed")

async def refresh_session(self, refresh_token: typing.Union[str, None] = None):
try:
await self.auth.refresh_session(refresh_token=refresh_token)
except gotrue.errors.AuthError as err:
raise authentication.AuthenticationError(err) from err
raise authentication.AuthenticationError(f"Community auth error: {err}") from err

async def sign_in_with_otp_token(self, token):
self.event_loop = asyncio.get_event_loop()
Expand All @@ -156,7 +156,7 @@ async def sign_in_with_otp_token(self, token):
except gotrue.errors.AuthImplicitGrantRedirectError as err:
if saved_session:
await self.auth._storage.set_item(self.auth._storage_key, saved_session)
raise authentication.AuthenticationError(err) from err
raise authentication.AuthenticationError(f"Community auth error: {err}") from err

def is_signed_in(self) -> bool:
# is signed in when a user auth key is set
Expand Down Expand Up @@ -201,7 +201,7 @@ async def get_otp_with_auth_key(self, user_email: str, auth_key: str) -> str:
)
return json.loads(resp)["token"]
except Exception:
raise authentication.AuthenticationError(f"Invalid auth key authentication details")
raise authentication.AuthenticationError(f"Community auth error: invalid auth key authentication details")

async def fetch_extensions(self, mqtt_uuid: typing.Optional[str]) -> dict:
resp = await self.functions.invoke(
Expand Down Expand Up @@ -449,14 +449,17 @@ async def fetch_bot_profile_data(self, bot_config_id: str) -> commons_profiles.P
if profile_data.trader_simulator.enabled:
# attempt 1: set exchange using exchange_id when set in bot_config
exchange_ids = [
config["exchange_id"]
config[enums.ExchangeKeys.EXCHANGE_ID.value]
for config in bot_config["exchanges"]
if config.get("exchange_id", None)
if config.get(enums.ExchangeKeys.EXCHANGE_ID.value, None)
]
if exchange_ids:
exchanges = await self.fetch_exchanges(exchange_ids)
exchanges_config = [
{enums.ExchangeKeys.INTERNAL_NAME.value: exchange[enums.ExchangeKeys.INTERNAL_NAME.value]}
{
enums.ExchangeKeys.INTERNAL_NAME.value: exchange[enums.ExchangeKeys.INTERNAL_NAME.value],
enums.ExchangeKeys.EXCHANGE_ID.value: exchange[enums.ExchangeKeys.ID.value],
}
for exchange in exchanges
]
else:
Expand Down
2 changes: 2 additions & 0 deletions octobot/community/supabase_backend/enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ class ExchangeAccountStatuses(enum.Enum):
class ExchangeKeys(enum.Enum):
ID = "id"
INTERNAL_NAME = "internal_name"
EXCHANGE_CREDENTIAL_ID = "exchange_credential_id"
EXCHANGE_ID = "exchange_id"


class SignalKeys(enum.Enum):
Expand Down
6 changes: 3 additions & 3 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# Drakkar-Software requirements
OctoBot-Commons==1.9.59
OctoBot-Trading==2.4.114
OctoBot-Commons==1.9.61
OctoBot-Trading==2.4.117
OctoBot-Evaluators==1.9.7
OctoBot-Tentacles-Manager==2.9.16
OctoBot-Services==1.6.20
OctoBot-Services==1.6.21
OctoBot-Backtesting==1.9.7
Async-Channel==2.2.1
trading-backend==1.2.29
Expand Down

0 comments on commit 538e205

Please sign in to comment.