Skip to content
Open
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
56 changes: 56 additions & 0 deletions scripts/get_signing_cohort_conditions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#!/usr/bin/python3
import json

import click
from ape.cli import ConnectedProviderCommand, account_option, network_option

from deployment import registry
from deployment.constants import (
SUPPORTED_TACO_DOMAINS, TESTNET_PROVIDERS,
)
from deployment.params import Transactor


@click.command(cls=ConnectedProviderCommand, name="get-cohort-conditions")
@network_option(required=True)
@click.option(
"--domain",
"-d",
help="TACo domain",
type=click.Choice(SUPPORTED_TACO_DOMAINS),
required=True,
)
@click.option(
"--cohort-id",
"-cid",
help="The cohort ID to set conditions on.",
type=int,
required=True,
)
@click.option(
"--chain-id",
"-c",
help="The chain ID of the network where the cohort is being initiated.",
type=int,
required=True,
)
def cli(
domain,
network,
cohort_id,
chain_id,
):

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

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}")
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?

result = signing_coordinator.getSigningCohortConditions(cohort_id, chain_id)

print("Cohort Conditions:")
print(json.dumps(json.loads(result), indent=4))
4 changes: 3 additions & 1 deletion scripts/set_signing_cohort_conditions.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/python3
import json

import click
from ape.cli import ConnectedProviderCommand, account_option, network_option
Expand Down Expand Up @@ -62,7 +63,8 @@ def cli(
"""

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.

Expand Down
Loading