group_config_options = group_options( UrsulaConfigOptions, geth=option_geth, provider_uri=option_provider_uri(), signer_uri=option_signer_uri, gas_strategy=option_gas_strategy, worker_address=click.option( '--worker-address', help="Run the worker-ursula with a specified address", type=EIP55_CHECKSUM_ADDRESS), federated_only=option_federated_only, rest_host=click.option( '--rest-host', help="The host IP address to run Ursula network services on", type=click.STRING), rest_port=click.option( '--rest-port', help="The host port to run Ursula network services on", type=NETWORK_PORT), db_filepath=option_db_filepath, network=option_network(), registry_filepath=option_registry_filepath, poa=option_poa, light=option_light, dev=option_dev, availability_check=click.option( '--availability-check/--disable-availability-check', help="Enable or disable self-health checks while running", is_flag=True, default=None), lonely=option_lonely, )
rest_port=self.discovery_port, checksum_address=self.pay_with, registry_filepath=self.registry_filepath) except FileNotFoundError: return actions.handle_missing_configuration_file( character_config_class=AliceConfiguration, config_file=config_file) group_config_options = group_options( AliceConfigOptions, dev=option_dev, network=option_network(), provider_uri=option_provider_uri(), signer_uri=option_signer_uri, gas_strategy=option_gas_strategy, geth=option_geth, federated_only=option_federated_only, discovery_port=option_discovery_port(), pay_with=option_pay_with, registry_filepath=option_registry_filepath, middleware=option_middleware, ) class AliceFullConfigOptions: __option_name__ = 'full_config_options' def __init__(self, config_options, poa, light, m, n, duration_periods): self.config_options = config_options self.poa = poa
if is_transacting and ADMINISTRATOR.eth_balance == 0: emitter.echo(DEPLOYER_ADDRESS_ZERO_ETH, color='red', bold=True) raise click.Abort() return ADMINISTRATOR, deployer_address, deployer_interface, local_registry group_actor_options = group_options( ActorOptions, provider_uri=option_provider_uri(), gas_strategy=option_gas_strategy, max_gas_price=option_max_gas_price, signer_uri=option_signer_uri, contract_name=option_contract_name(required=False), # TODO: Make this required see Issue #2314 poa=option_poa, force=option_force, hw_wallet=option_hw_wallet, deployer_address=option_deployer_address, registry_infile=option_registry_infile, registry_outfile=option_registry_outfile, dev=click.option('--dev', '-d', help="Forcibly use the development registry filepath.", is_flag=True), config_root=option_config_root, etherscan=option_etherscan, ignore_solidity_check=option_ignore_solidity_version, network=option_network(required=True) ) @click.group() @click.option('--solidity-version', help="Echo the supported solidity version.", is_flag=True,
client_password=client_password, signer=signer, transacting=transacting) return bidder def create_bidder(self, registry, hw_wallet: bool = False): signer = Signer.from_signer_uri(self.signer_uri) if self.signer_uri else None return self.__create_bidder(registry=registry, signer=signer, hw_wallet=hw_wallet, transacting=True) def create_transactionless_bidder(self, registry): return self.__create_bidder(registry, transacting=False) group_worklock_options = group_options( WorkLockOptions, bidder_address=option_bidder_address, signer_uri=option_signer_uri ) @click.group() def worklock(): """ Participate in NuCypher's WorkLock to obtain NU tokens """ pass @worklock.command() @group_registry_options @group_worklock_options
gas_strategy=self.gas_strategy, max_gas_price=self.max_gas_price, lonely=self.lonely) # Depends on defaults being set on Configuration classes, filtrates None values updates = {k: v for k, v in payload.items() if v is not None} return updates group_config_options = group_options( BobConfigOptions, provider_uri=option_provider_uri(), gas_strategy=option_gas_strategy, max_gas_price=option_max_gas_price, signer_uri=option_signer_uri, network=option_network(), registry_filepath=option_registry_filepath, checksum_address=option_checksum_address, discovery_port=option_discovery_port(), dev=option_dev, middleware=option_middleware, federated_only=option_federated_only, lonely=option_lonely, ) class BobCharacterOptions: __option_name__ = 'character_options' def __init__(self, config_options: BobConfigOptions, teacher_uri: str, min_stake: int):
self.network = network def setup(self, general_config) -> tuple: emitter = setup_emitter(general_config) registry = get_registry(network=self.network, registry_filepath=self.registry_filepath) blockchain = connect_to_blockchain(emitter=emitter, provider_uri=self.provider_uri) return emitter, registry, blockchain group_registry_options = group_options( RegistryOptions, geth=option_geth, poa=option_poa, light=option_light, registry_filepath=option_registry_filepath, network=option_network(), provider_uri=option_provider_uri( default=os.environ.get(NUCYPHER_ENVVAR_PROVIDER_URI)), ) @click.group() def status(): """Echo a snapshot of live NuCypher Network metadata.""" @status.command() @group_registry_options @group_general_config def network(general_config, registry_options):
bidder = Bidder(checksum_address=self.bidder_address, registry=registry, client_password=client_password, is_transacting=transacting) return bidder def create_bidder(self, registry, hw_wallet: bool = False): return self.__create_bidder(registry, transacting=True, hw_wallet=hw_wallet) def create_transactionless_bidder(self, registry): return self.__create_bidder(registry, transacting=False) group_worklock_options = group_options(WorkLockOptions, bidder_address=option_bidder_address) @click.group() def worklock(): """ Participate in NuCypher's WorkLock to obtain NU tokens """ pass @worklock.command() @group_registry_options @group_worklock_options @group_general_config def status(general_config, registry_options, worklock_options):
group_config_options = group_options( UrsulaConfigOptions, geth=option_geth, provider_uri=option_provider_uri(), staker_address=click.option( '--staker-address', help="Run on behalf of a specified staking account", type=EIP55_CHECKSUM_ADDRESS), worker_address=click.option( '--worker-address', help="Run the worker-ursula with a specified address", type=EIP55_CHECKSUM_ADDRESS), federated_only=option_federated_only, rest_host=click.option( '--rest-host', help="The host IP address to run Ursula network services on", type=click.STRING), rest_port=click.option( '--rest-port', help="The host port to run Ursula network services on", type=NETWORK_PORT), db_filepath=option_db_filepath, network=option_network, registry_filepath=option_registry_filepath, poa=option_poa, light=option_light, dev=option_dev, )
signer = Signer.from_signer_uri( self.signer_uri) if self.signer_uri else None return self.__create_bidder(registry=registry, signer=signer, hw_wallet=hw_wallet, transacting=True) def create_transactionless_bidder(self, registry): return self.__create_bidder(registry, transacting=False) group_worklock_options = group_options( WorkLockOptions, bidder_address=option_bidder_address, signer_uri=option_signer_uri, provider_uri=option_provider_uri( required=True, default=os.environ.get(NUCYPHER_ENVVAR_PROVIDER_URI)), network=option_network(required=True), registry_filepath=option_registry_filepath, ) @click.group() def worklock(): """ Participate in NuCypher's WorkLock to obtain NU tokens """ pass @worklock.command()
def create_bidder(self, registry, hw_wallet: bool = False): signer = Signer.from_signer_uri( self.signer_uri) if self.signer_uri else None return self.__create_bidder(registry=registry, signer=signer, hw_wallet=hw_wallet, transacting=True) def create_transactionless_bidder(self, registry): return self.__create_bidder(registry, transacting=False) group_worklock_options = group_options( WorkLockOptions, bidder_address=option_bidder_address, signer_uri=option_signer_uri, provider_uri=option_provider_uri(required=True), network=option_network(required=True), registry_filepath=option_registry_filepath, ) @click.group() def worklock(): """ Participate in NuCypher's WorkLock to obtain NU tokens """ pass @worklock.command() @group_worklock_options
return ADMINISTRATOR, deployer_address, deployer_interface, local_registry group_actor_options = group_options( ActorOptions, provider_uri=option_provider_uri(), gas_strategy=option_gas_strategy, signer_uri=option_signer_uri, contract_name=option_contract_name( required=False), # TODO: Make this required see Issue #2314 poa=option_poa, force=option_force, hw_wallet=option_hw_wallet, deployer_address=option_deployer_address, registry_infile=option_registry_infile, registry_outfile=option_registry_outfile, dev=click.option('--dev', '-d', help="Forcibly use the development registry filepath.", is_flag=True), se_test_mode=click.option( '--se-test-mode', help="Enable test mode for StakingEscrow in deployment.", is_flag=True), config_root=option_config_root, etherscan=option_etherscan, ignore_solidity_check=option_ignore_solidity_version, network=option_network(required=True, default=NetworksInventory.DEFAULT)) @click.group()
group_config_options = group_options( # NOTE: Don't set defaults here or they will be applied to config updates. Use the Config API. UrsulaConfigOptions, eth_provider_uri=option_eth_provider_uri(), signer_uri=option_signer_uri, gas_strategy=option_gas_strategy, max_gas_price=option_max_gas_price, operator_address=click.option( '--operator-address', help="Run with the specified operator address", type=EIP55_CHECKSUM_ADDRESS), federated_only=option_federated_only, rest_host=click.option( '--rest-host', help="The host IP address to run Ursula network services on", type=OPERATOR_IP), rest_port=click.option( '--rest-port', help="The host port to run Ursula network services on", type=NETWORK_PORT), db_filepath=option_db_filepath, network=option_network(), registry_filepath=option_registry_filepath, policy_registry_filepath=option_policy_registry_filepath, poa=option_poa, light=option_light, dev=option_dev, availability_check=click.option( '--availability-check/--disable-availability-check', help="Enable or disable self-health checks while running", is_flag=True, default=None), lonely=option_lonely, payment_provider=option_payment_provider, payment_network=option_payment_network, payment_method=option_payment_method, )
provider_process=self.eth_node, registry_filepath=self.registry_filepath, poa=poa, light=light, m=m, n=n, duration_periods=duration_periods, rate=rate) group_config_options = group_options( AliceConfigOptions, dev=option_dev, network=option_network, provider_uri=option_provider_uri(), geth=option_geth, federated_only=option_federated_only, discovery_port=option_discovery_port(), pay_with=option_pay_with, registry_filepath=option_registry_filepath, middleware=option_middleware, ) class AliceCharacterOptions: __option_name__ = 'character_options' def __init__(self, config_options, hw_wallet, teacher_uri, min_stake): self.config_options = config_options self.hw_wallet = hw_wallet self.teacher_uri = teacher_uri
def setup(self, general_config) -> tuple: emitter = setup_emitter(general_config) registry = get_registry(network=self.network, registry_filepath=self.registry_filepath) blockchain = connect_to_blockchain(emitter=emitter, provider_uri=self.provider_uri) return emitter, registry, blockchain group_registry_options = group_options( RegistryOptions, geth=option_geth, poa=option_poa, light=option_light, registry_filepath=option_registry_filepath, network=option_network(default=NetworksInventory.DEFAULT, validate=True), # TODO: See 2214 provider_uri=option_provider_uri( default=os.environ.get(NUCYPHER_ENVVAR_PROVIDER_URI)), ) @click.group() def status(): """Echo a snapshot of live NuCypher Network metadata.""" @status.command() @group_registry_options @group_general_config
# Verify ETH Balance emitter.echo(f"\n\nDeployer ETH balance: {ADMINISTRATOR.eth_balance}") if ADMINISTRATOR.eth_balance == 0: emitter.echo("Deployer address has no ETH.", color='red', bold=True) raise click.Abort() return ADMINISTRATOR, deployer_address, deployer_interface, local_registry group_actor_options = group_options( ActorOptions, provider_uri=option_provider_uri(), contract_name=click.option('--contract-name', help="Deploy a single contract by name", type=click.STRING), poa=option_poa, force=option_force, hw_wallet=option_hw_wallet, deployer_address=option_deployer_address, registry_infile=option_registry_infile, registry_outfile=option_registry_outfile, dev=click.option('--dev', '-d', help="Forcibly use the development registry filepath.", is_flag=True), se_test_mode=click.option('--se-test-mode', help="Enable test mode for StakingEscrow in deployment.", is_flag=True), config_root=option_config_root, etherscan=option_etherscan, ) @click.group() def deploy(): """ Manage contract and registry deployment. """ pass
payment_network=self.payment_network) except FileNotFoundError: return handle_missing_configuration_file( character_config_class=AliceConfiguration, config_file=config_file) group_config_options = group_options( AliceConfigOptions, dev=option_dev, network=option_network(), eth_provider_uri=option_eth_provider_uri(), signer_uri=option_signer_uri, gas_strategy=option_gas_strategy, max_gas_price=option_max_gas_price, federated_only=option_federated_only, discovery_port=option_discovery_port(), pay_with=option_pay_with, registry_filepath=option_registry_filepath, middleware=option_middleware, lonely=option_lonely, payment_provider=option_payment_provider, payment_network=option_payment_network, payment_method=option_payment_method, ) class AliceFullConfigOptions: __option_name__ = 'full_config_options' def __init__(self, config_options, poa: bool, light: bool, threshold: int,
raise click.Abort() return ADMINISTRATOR, deployer_address, deployer_interface, local_registry group_actor_options = group_options( ActorOptions, provider_uri=option_provider_uri(), gas_strategy=option_gas_strategy, signer_uri=option_signer_uri, contract_name=option_contract_name, poa=option_poa, force=option_force, hw_wallet=option_hw_wallet, deployer_address=option_deployer_address, registry_infile=option_registry_infile, registry_outfile=option_registry_outfile, dev=click.option('--dev', '-d', help="Forcibly use the development registry filepath.", is_flag=True), se_test_mode=click.option( '--se-test-mode', help="Enable test mode for StakingEscrow in deployment.", is_flag=True), config_root=option_config_root, etherscan=option_etherscan, ignore_solidity_check=option_ignore_solidity_version) @click.group() @click.option('--solidity-version',
def get_updates(self) -> dict: payload = dict( provider_uri=self.provider_uri, poa=self.poa, light=self.light, registry_filepath=self.registry_filepath, domains={self.network} if self.network else None) # TODO: #1580 # Depends on defaults being set on Configuration classes, filtrates None values updates = {k: v for k, v in payload.items() if v is not None} return updates group_config_options = group_options( StakeHolderConfigOptions, provider_uri=option_provider_uri(), poa=option_poa, light=option_light, registry_filepath=option_registry_filepath, network=option_network) class StakerOptions: __option_name__ = 'staker_options' def __init__(self, config_options, staking_address): self.config_options = config_options self.staking_address = staking_address def create_character(self, emitter,
registry=registry, signer=signer, transacting=transacting) return actor def create_participant(self, registry, hw_wallet: bool = False): return self.__create_participant(registry=registry, hw_wallet=hw_wallet, transacting=True) def create_transactionless_participant(self, registry): return self.__create_participant(registry, transacting=False) group_dao_options = group_options( DaoOptions, participant_address=option_participant_address, signer_uri=option_signer_uri, provider_uri=option_provider_uri(required=True, default=os.environ.get(NUCYPHER_ENVVAR_PROVIDER_URI)), network=option_network(required=True), registry_filepath=option_registry_filepath, ) @click.group() def dao(): """Participate in the NuCypher DAO""" @dao.command() @group_general_config def inspect(general_config: GroupGeneralConfig): """Show current status of the NuCypher DAO"""
domains=self.domains, checksum_address=self.checksum_address, registry_filepath=self.registry_filepath, provider_uri=self.provider_uri, provider_process=self.eth_node, poa=self.poa) group_config_options = group_options( FelixConfigOptions, geth=option_geth, dev=option_dev, network=option_network, provider_uri=option_provider_uri(), host=click.option('--host', help="The host to run Felix HTTP services on", type=click.STRING, default='127.0.0.1'), db_filepath=option_db_filepath, checksum_address=option_checksum_address, registry_filepath=option_registry_filepath, poa=option_poa, port=option_port, ) class FelixCharacterOptions: __option_name__ = 'character_options' def __init__(self, config_options, teacher_uri, min_stake, middleware): self.config_options = config_options
return bidder def create_bidder(self, registry, hw_wallet: bool = False): return self.__create_bidder(registry=registry, hw_wallet=hw_wallet, transacting=True) def create_transactionless_bidder(self, registry): return self.__create_bidder(registry, transacting=False) group_worklock_options = group_options( WorkLockOptions, participant_address=option_participant_address, signer_uri=option_signer_uri, provider_uri=option_provider_uri( required=True, default=os.environ.get(NUCYPHER_ENVVAR_PROVIDER_URI)), network=option_network(default=NetworksInventory.DEFAULT, validate=True), # TODO: See 2214 registry_filepath=option_registry_filepath, ) @click.group() def worklock(): """Participate in NuCypher's WorkLock to obtain a NU stake""" @worklock.command() @group_worklock_options @group_general_config def status(general_config: GroupGeneralConfig,
group_general_config = group_options( GroupGeneralConfig, verbose=click.option('-v', '--verbose', help="Verbose console messages", is_flag=True), quiet=click.option('-Q', '--quiet', help="Disable console messages", is_flag=True), no_logs=click.option('-L', '--no-logs', help="Disable all logging output", is_flag=True), json_ipc=click.option( '-J', '--json-ipc', help="Send all IPC output to stdout as JSON, and turn off the rest", is_flag=True), console_logs=click.option( '--console-logs/--no-console-logs', help= "Enable/disable logging to console. Defaults to `--no-console-logs`.", default=False), file_logs=click.option( '--file-logs/--no-file-logs', help= "Enable/disable logging to file. Defaults to NUCYPHER_FILE_LOGS, or to `--file-logs` if it is not set.", default=None), sentry_logs=click.option( '--sentry-logs/--no-sentry-logs', help= "Enable/disable logging to Sentry. Defaults to NUCYPHER_SENTRY_LOGS, or to `--sentry-logs` if it is not set.", default=None), log_level=click.option( '--log-level', help="The log level for this process. Is overridden by --debug.", type=click.Choice(['critical', 'error', 'warn', 'info', 'debug']), default='info'), debug=click.option( '-D', '--debug', help= "Enable debugging mode, crashing on more exceptions instead of trying to recover. " "Also sets log level to \"debug\", turns on console and file logging " "and turns off Sentry logging.", is_flag=True), )
click.secho(str(e), bold=True, fg='red') raise click.Abort if self.registry_filepath: registry = LocalContractRegistry(filepath=self.registry_filepath) else: registry = InMemoryContractRegistry.from_latest_publication( network=self.network) return registry group_registry_options = group_options( RegistryOptions, provider_uri=option_provider_uri(), geth=option_geth, poa=option_poa, light=option_light, registry_filepath=option_registry_filepath, network=option_network, ) @click.group() def status(): """ Echo a snapshot of live NuCypher Network metadata. """ pass @status.command()
provider_uri=self.provider_uri) emitter.echo(message="Reading Latest Chaindata...") blockchain.connect() return blockchain except Exception as e: if debug: raise click.secho(str(e), bold=True, fg='red') raise click.Abort group_blockchain_options = group_options( BlockchainOptions, provider_uri=option_provider_uri(), poa=option_poa, light=option_light, registry_filepath=option_registry_filepath, network=option_network, ) class MultiSigOptions: __option_name__ = 'multisig_options' def __init__(self, checksum_address, signer_uri, hw_wallet): self.checksum_address = checksum_address self.signer_uri = signer_uri self.hw_wallet = hw_wallet def __create_executive(self, registry,
return BobConfiguration.generate( password=get_nucypher_password(confirm=True), config_root=config_root, checksum_address=checksum_address, domains=self.domains, federated_only=federated_only, registry_filepath=self.registry_filepath, provider_uri=self.provider_uri) group_config_options = group_options( BobConfigOptions, provider_uri=option_provider_uri(), network=option_network, registry_filepath=option_registry_filepath, checksum_address=option_checksum_address, discovery_port=option_discovery_port(), dev=option_dev, middleware=option_middleware, ) class BobCharacterOptions: __option_name__ = 'character_options' def __init__(self, config_options, teacher_uri, min_stake): self.config_options = config_options self.teacher_uri = teacher_uri self.min_stake = min_stake