From 33d0aff38d7b5650ba5685108fcfc29747dc6abe Mon Sep 17 00:00:00 2001 From: icpp Date: Tue, 22 Apr 2025 20:56:09 -0400 Subject: [PATCH] get_message from icpp_pro_messaging_canister deployed on IC . --- src/icpp/commands_build_native.py | 21 +++++++++++++++++++++ src/icpp/commands_build_wasm.py | 21 ++++++++++++++++++--- src/icpp/config_default.py | 5 +++++ 3 files changed, 44 insertions(+), 3 deletions(-) diff --git a/src/icpp/commands_build_native.py b/src/icpp/commands_build_native.py index bd56d46..6dbaf19 100644 --- a/src/icpp/commands_build_native.py +++ b/src/icpp/commands_build_native.py @@ -4,6 +4,7 @@ import sys import platform import os +import json from pathlib import Path import subprocess import shutil @@ -247,3 +248,23 @@ def c_compile_file_mine(file: str) -> None: # ---------------------------------------------------------------------- typer.echo("-----") + + icpp_pro_messaging_canister_message = ( + config_default.ICPP_PRO_MESSAGING_CANISTER_DEFAULT_MESSAGE + ) + try: + cmd = ( + f"dfx canister call {config_default.ICPP_PRO_MESSAGING_CANISTER} " + f"get_message --ic --output json" + ) + response_str = run_shell_cmd(cmd, capture_output=True) + if response_str is not None: + response = json.loads(response_str) + if "Ok" in response and "message" in response["Ok"]: + icpp_pro_messaging_canister_message = response["Ok"]["message"] + except: # pylint: disable=bare-except + pass + + typer.echo(icpp_pro_messaging_canister_message) + typer.echo("-----") + # ---------------------------------------------------------------------- diff --git a/src/icpp/commands_build_wasm.py b/src/icpp/commands_build_wasm.py index d4863f5..0d28914 100644 --- a/src/icpp/commands_build_wasm.py +++ b/src/icpp/commands_build_wasm.py @@ -3,6 +3,7 @@ # pylint: disable = too-many-statements import sys import os +import json from pathlib import Path import subprocess import shutil @@ -376,8 +377,22 @@ def c_compile_file_mine(file: str) -> None: # ---------------------------------------------------------------------- typer.echo("-----") - # ---------------------------------------------------------------------- - typer.echo("Support icpp-pro by purchasing an icpp-art NFT at:") - typer.echo("https://bioniq.io/launch/icpp-art/public") + icpp_pro_messaging_canister_message = ( + config_default.ICPP_PRO_MESSAGING_CANISTER_DEFAULT_MESSAGE + ) + try: + cmd = ( + f"dfx canister call {config_default.ICPP_PRO_MESSAGING_CANISTER} " + f"get_message --ic --output json" + ) + response_str = run_shell_cmd(cmd, capture_output=True) + if response_str is not None: + response = json.loads(response_str) + if "Ok" in response and "message" in response["Ok"]: + icpp_pro_messaging_canister_message = response["Ok"]["message"] + except: # pylint: disable=bare-except + pass + + typer.echo(icpp_pro_messaging_canister_message) # ---------------------------------------------------------------------- typer.echo("-----") diff --git a/src/icpp/config_default.py b/src/icpp/config_default.py index 4bba76d..9c91a9f 100644 --- a/src/icpp/config_default.py +++ b/src/icpp/config_default.py @@ -15,6 +15,11 @@ OS_SYSTEM = platform.system() OS_PROCESSOR = platform.processor() +####################################################################### +# See: https://github.com/onicai/icpp_pro_messaging_canister +ICPP_PRO_MESSAGING_CANISTER = "ahlje-dqaaa-aaaag-aua5q-cai" +ICPP_PRO_MESSAGING_CANISTER_DEFAULT_MESSAGE = "Thank you for using icpp-pro 💻️" + ####################################################################### # Paths for logs & to install dependencies (wasi-sdk, rust, ...) ICPP_ROOT = Path.home() / ".icpp"