-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* use DTO instead of tuples * return partial results when fetching antisybil status - they are enough for FE * lineup declared and actual types
- Loading branch information
1 parent
d5076f6
commit 7872931
Showing
7 changed files
with
59 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,37 @@ | ||
from datetime import datetime | ||
from typing import List, Optional, Tuple | ||
from typing import Optional, Tuple | ||
|
||
from app.context.epoch_state import EpochState | ||
from app.context.manager import state_context | ||
from app.modules.registry import get_services | ||
from app.modules.user.antisybil.service.holonym import HolonymAntisybilDTO | ||
from app.modules.user.antisybil.service.passport import GitcoinAntisybilDTO | ||
|
||
|
||
def get_user_antisybil_status( | ||
user_address: str, | ||
) -> Optional[Tuple[Tuple[int, datetime], Tuple[bool, List[str]]]]: | ||
) -> Tuple[Optional[GitcoinAntisybilDTO], Optional[HolonymAntisybilDTO]]: | ||
context = state_context(EpochState.CURRENT) | ||
passport = get_services(context.epoch_state).user_antisybil_passport_service | ||
passport_status = passport.get_antisybil_status(context, user_address) | ||
gpscore = passport.get_antisybil_status(context, user_address) | ||
holonym = get_services(context.epoch_state).user_antisybil_holonym_service | ||
holonym_status = holonym.get_sbt_status(context, user_address) | ||
if passport_status is None or holonym_status is None: | ||
return None | ||
|
||
return (passport_status, holonym_status) | ||
sbt = holonym.get_sbt_status(context, user_address) | ||
return (gpscore, sbt) | ||
|
||
|
||
def update_user_antisybil_status( | ||
user_address: str, | ||
) -> Tuple[Tuple[int, datetime], Tuple[bool, List[str]]]: | ||
) -> Tuple[GitcoinAntisybilDTO, HolonymAntisybilDTO]: | ||
context = state_context(EpochState.CURRENT) | ||
passport = get_services(context.epoch_state).user_antisybil_passport_service | ||
|
||
score, expires_at, all_stamps = passport.fetch_antisybil_status( | ||
context, user_address | ||
) | ||
gpscore, stamps = passport.fetch_antisybil_status(context, user_address) | ||
passport.update_antisybil_status( | ||
context, user_address, score, expires_at, all_stamps | ||
context, user_address, gpscore.score, gpscore.expires_at, stamps | ||
) | ||
|
||
holonym = get_services(context.epoch_state).user_antisybil_holonym_service | ||
|
||
has_sbt, cred_type = holonym.fetch_sbt_status(context, user_address) | ||
holonym.update_sbt_status(context, user_address, has_sbt, cred_type) | ||
sbt = holonym.fetch_sbt_status(context, user_address) | ||
holonym.update_sbt_status(context, user_address, sbt.has_sbt, sbt.sbt_details) | ||
|
||
return ((score, expires_at), (has_sbt, cred_type)) | ||
return (gpscore, sbt) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters