From c0d981902930246beceab0c64459762a65eb4a08 Mon Sep 17 00:00:00 2001 From: Volara Date: Fri, 14 Feb 2025 11:58:33 -0500 Subject: [PATCH 1/2] Add permission validation logic --- volara_proof/__main__.py | 18 +++++++++++++++--- volara_proof/constants.py | 2 ++ 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/volara_proof/__main__.py b/volara_proof/__main__.py index 41847e5..bdef39f 100644 --- a/volara_proof/__main__.py +++ b/volara_proof/__main__.py @@ -3,10 +3,10 @@ import os import sys import traceback -import zipfile from typing import Dict, Any from volara_proof.proof import Proof +from volara_proof.constants import VOLARA_DLP_OWNER_ADDRESS, VOLARA_DLP_OWNER_PUBLIC_KEY_HEX INPUT_DIR, OUTPUT_DIR = "/input", "/output" @@ -25,13 +25,25 @@ def load_config() -> Dict[str, Any]: } return config +def assess_validity(validated_permissions) -> bool: + """Assess the validity of a validated permission.""" + for permission in validated_permissions: + if permission["address"] == VOLARA_DLP_OWNER_ADDRESS and permission["public_key"] == VOLARA_DLP_OWNER_PUBLIC_KEY_HEX: + return True + return False + def run() -> None: """Generate proofs for all input files.""" config = load_config() input_files_exist = os.path.isdir(INPUT_DIR) and bool(os.listdir(INPUT_DIR)) - print(os.listdir(INPUT_DIR)) - print(os.environ) + validated_permissions_str = os.environ.get("VALIDATED_PERMISSIONS", None) + if validated_permissions_str is None: + raise ValueError("VALIDATED_PERMISSIONS environment variable is not set") + + validated_permissions = json.loads(validated_permissions_str) + if not assess_validity(validated_permissions): + raise ValueError("Permissions failed to validate") if not input_files_exist: raise FileNotFoundError(f"No input files found in {INPUT_DIR}") diff --git a/volara_proof/constants.py b/volara_proof/constants.py index 16a6f09..05d235a 100644 --- a/volara_proof/constants.py +++ b/volara_proof/constants.py @@ -1 +1,3 @@ VOLARA_API_URL = "https://api.volara.xyz" +VOLARA_DLP_OWNER_ADDRESS = "0x07cdb997c45a008B803FCC6904a0f7E4383a63b6" +VOLARA_DLP_OWNER_PUBLIC_KEY_HEX = "0xebd0b3dbe1ba0b298bc05c5f22e9b9c0816ac4d5bbfe00d8da2ec11a2be5aa9f3532e107b2bfa9b2b3e521c570392f1868f05ae8e697a499a9d1883777102252" From 24e34770f217de805db047a62ee748c8c440f1ce Mon Sep 17 00:00:00 2001 From: Volara Date: Fri, 14 Feb 2025 12:02:04 -0500 Subject: [PATCH 2/2] Update upload step --- .github/workflows/build-and-release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-and-release.yml b/.github/workflows/build-and-release.yml index c53461d..5e3d32b 100644 --- a/.github/workflows/build-and-release.yml +++ b/.github/workflows/build-and-release.yml @@ -43,7 +43,7 @@ jobs: echo "Image SHA256: $(sha256sum volara-proof-${{ github.run_number }}.tar.gz | cut -d' ' -f1)" >> release_body.txt - name: Upload image - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: volara-proof-image path: volara-proof-${{ github.run_number }}.tar.gz