diff --git a/src/certification/__init__.py b/src/certification/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/src/certification/calls.py b/src/certification/calls.py new file mode 100644 index 00000000..2b8cf8f8 --- /dev/null +++ b/src/certification/calls.py @@ -0,0 +1,19 @@ +import requests +from src import prompt + +from .config import URL + + +def register_exercise_success(exercise_path: str, access_token: str): + route = "/route_to_post_at" + response = requests.post( + URL + route, + data={ + "exercise_name": exercise_path, + "access_token": access_token, + }, + ) + if response.ok(): + prompt.on_nft_mint() + else: + prompt.on_nft_mint_failed() diff --git a/src/certification/config.py b/src/certification/config.py new file mode 100644 index 00000000..efa30be2 --- /dev/null +++ b/src/certification/config.py @@ -0,0 +1 @@ +URL = "https://onlydust.zyz" diff --git a/src/prompt.py b/src/prompt.py index e5ebfdbb..e6c136f4 100644 --- a/src/prompt.py +++ b/src/prompt.py @@ -53,5 +53,13 @@ def on_user_verification(verification_uri: str, verification_code: str): ) +def on_nft_mint(): + rich_print("Your NFT is being minted") + + +def on_nft_mint_failed(): + rich_print("Failed to mint your NFT") + + def waiting_for_user_login(): return console.status("Waiting for user login...") diff --git a/src/runner.py b/src/runner.py index 56cbb165..c2a04109 100644 --- a/src/runner.py +++ b/src/runner.py @@ -12,6 +12,8 @@ from src import prompt from src.exercises.seeker import ExerciseSeeker from src.config import current_working_directory +from src.certification.calls import register_exercise_success +from src.user.access_token import get_access_token check_exercise_lock = Lock() @@ -25,6 +27,9 @@ async def single_exercise_check(exercise_path: Path, watch_mode=False): await check_exercise(str(exercise_path)) capture_exercise_solved(exercise_path) prompt.on_single_exercise_success(exercise_path) + access_token = get_access_token() + if access_token is not False: + register_exercise_success(exercise_path, access_token) if watch_mode: prompt.on_watch_exercise_success() except ExerciceFailed as error: