|
| 1 | +#!/usr/bin/python3 |
| 2 | +import json |
| 3 | + |
| 4 | +import click |
| 5 | +from ape.cli import ConnectedProviderCommand, account_option, network_option |
| 6 | + |
| 7 | +from deployment import registry |
| 8 | +from deployment.constants import ( |
| 9 | + SUPPORTED_TACO_DOMAINS, TESTNET_PROVIDERS, |
| 10 | +) |
| 11 | +from deployment.params import Transactor |
| 12 | + |
| 13 | + |
| 14 | +@click.command(cls=ConnectedProviderCommand, name="get-cohort-conditions") |
| 15 | +@network_option(required=True) |
| 16 | +@click.option( |
| 17 | + "--domain", |
| 18 | + "-d", |
| 19 | + help="TACo domain", |
| 20 | + type=click.Choice(SUPPORTED_TACO_DOMAINS), |
| 21 | + required=True, |
| 22 | +) |
| 23 | +@click.option( |
| 24 | + "--cohort-id", |
| 25 | + "-cid", |
| 26 | + help="The cohort ID to set conditions on.", |
| 27 | + type=int, |
| 28 | + required=True, |
| 29 | +) |
| 30 | +@click.option( |
| 31 | + "--chain-id", |
| 32 | + "-c", |
| 33 | + help="The chain ID of the network where the cohort is being initiated.", |
| 34 | + type=int, |
| 35 | + required=True, |
| 36 | +) |
| 37 | +def cli( |
| 38 | + domain, |
| 39 | + network, |
| 40 | + cohort_id, |
| 41 | + chain_id, |
| 42 | +): |
| 43 | + |
| 44 | + if domain not in TESTNET_PROVIDERS: |
| 45 | + raise click.ClickException(f"Unsupported domain: {domain}. Supported domains are: {', '.join(TESTNET_PROVIDERS)}") |
| 46 | + |
| 47 | + print(f"Setting conditions for cohort {cohort_id} on {domain}:{network} with chain ID {chain_id}") |
| 48 | + |
| 49 | + signing_coordinator = registry.get_contract(domain=domain, contract_name="SigningCoordinator") |
| 50 | + |
| 51 | + print("Getting conditions...") |
| 52 | + print(f"Cohort ID: {cohort_id}, Chain ID: {chain_id}") |
| 53 | + result = signing_coordinator.getSigningCohortConditions(cohort_id, chain_id) |
| 54 | + |
| 55 | + print("Cohort Conditions:") |
| 56 | + print(json.dumps(json.loads(result), indent=4)) |
0 commit comments