-
Notifications
You must be signed in to change notification settings - Fork 12
Adds get_signing_cohort_conditions script #440
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: signing
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds a new command-line script to retrieve signing cohort conditions from the SigningCoordinator contract. The script provides a CLI interface using Click to query cohort conditions by domain, cohort ID, and chain ID.
- Implements a new
get-cohort-conditionsCLI command using Click and Ape frameworks - Validates domain support and retrieves cohort conditions from the SigningCoordinator contract
- Outputs the retrieved conditions in formatted JSON
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| if domain not in TESTNET_PROVIDERS: | ||
| raise click.ClickException(f"Unsupported domain: {domain}. Supported domains are: {', '.join(TESTNET_PROVIDERS)}") | ||
|
|
||
| print(f"Setting conditions for cohort {cohort_id} on {domain}:{network} with chain ID {chain_id}") |
Copilot
AI
Nov 5, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The message says 'Setting conditions' but this script only retrieves/gets conditions. The message should read 'Getting conditions for cohort...' to accurately reflect the script's purpose.
| print(f"Setting conditions for cohort {cohort_id} on {domain}:{network} with chain ID {chain_id}") | |
| print(f"Getting conditions for cohort {cohort_id} on {domain}:{network} with chain ID {chain_id}") |
| result = signing_coordinator.getSigningCohortConditions(cohort_id, chain_id) | ||
|
|
||
| print("Cohort Conditions:") | ||
| print(json.dumps(json.loads(result), indent=4)) |
Copilot
AI
Nov 5, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Calling json.loads() on result assumes it's a JSON string, but result is likely already a structured object from the contract call. This will fail if result is not a string. Either use json.dumps(result, indent=4, default=str) directly, or verify the actual return type of getSigningCohortConditions().
| print(json.dumps(json.loads(result), indent=4)) | |
| print(json.dumps(result, indent=4, default=str)) |
|
Needs a rebase. |
9316139 to
0396b3d
Compare
| if domain not in TESTNET_PROVIDERS: | ||
| raise click.ClickException(f"Unsupported domain: {domain}. Supported domains are: {', '.join(TESTNET_PROVIDERS)}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we need this check since domain is already restricted here - https://github.com/nucypher/nucypher-contracts/pull/440/files#diff-83ec17263e71b8869b9dfef8ee753eafc12b5d3b8b0a384e038dd0e29f809fb4R20.
| if domain not in TESTNET_PROVIDERS: | ||
| raise click.ClickException(f"Unsupported domain: {domain}. Supported domains are: {', '.join(TESTNET_PROVIDERS)}") | ||
|
|
||
| print(f"Setting conditions for cohort {cohort_id} on {domain}:{network} with chain ID {chain_id}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| print(f"Setting conditions for cohort {cohort_id} on {domain}:{network} with chain ID {chain_id}") | |
| print(f"Getting conditions for cohort {cohort_id} on {domain}:{network} with chain ID {chain_id}") |
| signing_coordinator = registry.get_contract(domain=domain, contract_name="SigningCoordinator") | ||
|
|
||
| print("Getting conditions...") | ||
| print(f"Cohort ID: {cohort_id}, Chain ID: {chain_id}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems redundant based on print statement on L47?
|
|
||
| with open(condition_file, 'r') as file: | ||
| condition = file.read().strip().encode("utf-8") | ||
| condition = json.dumps(json.loads(file.read().strip().encode("utf-8"))).encode("utf-8") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the first encode needed? i.e. should it be:
| condition = json.dumps(json.loads(file.read().strip().encode("utf-8"))).encode("utf-8") | |
| condition = json.dumps(json.loads(file.read().strip())).encode("utf-8") |
|
|
||
| if not condition: | ||
| raise click.ClickException("Condition file is empty or not provided.") | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The check on L71&72 can be removed. Domain is already limited to specific values here - https://github.com/nucypher/nucypher-contracts/pull/440/files#diff-5b7786182e4b882eaf4ab7b7a4c02a0aca12a0c1df57054e720a370477fe5742R21
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
L81 seems redundant given the print on L74.
Type of PR:
Feature
Required reviews:
1