Skip to content

Conversation

@KPrasch
Copy link
Member

@KPrasch KPrasch commented Nov 5, 2025

Type of PR:
Feature

Required reviews:
1

Copy link
Contributor

Copilot AI left a 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-conditions CLI 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}")
Copy link

Copilot AI Nov 5, 2025

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.

Suggested change
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}")

Copilot uses AI. Check for mistakes.
result = signing_coordinator.getSigningCohortConditions(cohort_id, chain_id)

print("Cohort Conditions:")
print(json.dumps(json.loads(result), indent=4))
Copy link

Copilot AI Nov 5, 2025

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().

Suggested change
print(json.dumps(json.loads(result), indent=4))
print(json.dumps(result, indent=4, default=str))

Copilot uses AI. Check for mistakes.
@derekpierre
Copy link
Member

Needs a rebase.

Comment on lines +44 to +45
if domain not in TESTNET_PROVIDERS:
raise click.ClickException(f"Unsupported domain: {domain}. Supported domains are: {', '.join(TESTNET_PROVIDERS)}")
Copy link
Member

Choose a reason for hiding this comment

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

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}")
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
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}")
Copy link
Member

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")
Copy link
Member

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:

Suggested change
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.")

Copy link
Member

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

Copy link
Member

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.

@derekpierre derekpierre mentioned this pull request Nov 27, 2025
21 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants