Skip to content
This repository has been archived by the owner on Aug 21, 2023. It is now read-only.

feat: add dummy success registration for loged users #209

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file added src/certification/__init__.py
Empty file.
19 changes: 19 additions & 0 deletions src/certification/calls.py
Original file line number Diff line number Diff line change
@@ -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(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess we can use the access token as an authentication method, in a header Authorization: Bearer {access_token}

URL + route,
data={
"exercise_name": exercise_path,
"access_token": access_token,
},
)
if response.ok():
prompt.on_nft_mint()
else:
prompt.on_nft_mint_failed()
1 change: 1 addition & 0 deletions src/certification/config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
URL = "https://onlydust.zyz"
8 changes: 8 additions & 0 deletions src/prompt.py
Original file line number Diff line number Diff line change
Expand Up @@ -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...")
5 changes: 5 additions & 0 deletions src/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand All @@ -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:
Expand Down