From 105dd885906a3a88eaa51b3f52885ea046be4e1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timoth=C3=A9e=20Delabrouille?= Date: Mon, 20 Jun 2022 15:00:45 +0200 Subject: [PATCH 1/2] feat: add dummy success registration for loged users --- src/certification/__init__.py | 0 src/certification/calls.py | 14 ++++++++++++++ src/certification/config.py | 1 + src/runner.py | 5 +++++ 4 files changed, 20 insertions(+) create mode 100644 src/certification/__init__.py create mode 100644 src/certification/calls.py create mode 100644 src/certification/config.py 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..c68feab3 --- /dev/null +++ b/src/certification/calls.py @@ -0,0 +1,14 @@ +import requests +from .config import URL +import src.user.access_token + + +def register_exercise_success(exercise_path: str, access_token: str): + route = "/route_to_post_at" + requests.post( + URL + route, + data={ + "exercise_name": exercise_path, + "access_token": access_token, + }, + ) 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/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: From 77fb8b213d7083f5168116dca541c81ca45d160b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timoth=C3=A9e=20Delabrouille?= Date: Mon, 20 Jun 2022 15:55:40 +0200 Subject: [PATCH 2/2] feat(mint): add prompts --- src/certification/calls.py | 9 +++++++-- src/prompt.py | 8 ++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/certification/calls.py b/src/certification/calls.py index c68feab3..2b8cf8f8 100644 --- a/src/certification/calls.py +++ b/src/certification/calls.py @@ -1,14 +1,19 @@ import requests +from src import prompt + from .config import URL -import src.user.access_token def register_exercise_success(exercise_path: str, access_token: str): route = "/route_to_post_at" - requests.post( + 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/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...")