-
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?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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)}") | ||||||
|
|
||||||
| print(f"Setting conditions for cohort {cohort_id} on {domain}:{network} with chain ID {chain_id}") | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
|
||||||
| signing_coordinator = registry.get_contract(domain=domain, contract_name="SigningCoordinator") | ||||||
|
|
||||||
| print("Getting conditions...") | ||||||
| print(f"Cohort ID: {cohort_id}, Chain ID: {chain_id}") | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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)) | ||||||
| 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 | ||||||
|
|
@@ -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") | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is the first encode needed? i.e. should it be:
Suggested change
|
||||||
|
|
||||||
| if not condition: | ||||||
| raise click.ClickException("Condition file is empty or not provided.") | ||||||
|
|
||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. L81 seems redundant given the print on L74. |
||||||
|
|
||||||
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.