def __create_trustee(self, registry, transacting: bool = False) -> Trustee: client_password = None is_clef = ClefSigner.is_valid_clef_uri(self.signer_uri) if transacting and not self.hw_wallet and not is_clef: client_password = get_client_password(checksum_address=self.checksum_address) trustee = Trustee(checksum_address=self.checksum_address, registry=registry, client_password=client_password) return trustee
def create_character(self, emitter, config_file, json_ipc, load_seednodes=True): config = self.config_options.create_config(emitter, config_file) client_password = None is_clef = ClefSigner.is_valid_clef_uri(self.config_options.signer_uri) eth_password_is_needed = not config.federated_only and not self.hw_wallet and not config.dev_mode and not is_clef if eth_password_is_needed: if json_ipc: client_password = os.environ.get(NUCYPHER_ENVVAR_ALICE_ETH_PASSWORD, NO_PASSWORD) if client_password is NO_PASSWORD: message = f"--json-ipc implies the {NUCYPHER_ENVVAR_ALICE_ETH_PASSWORD} envvar must be set." click.BadOptionUsage(option_name='--json-ipc', message=message) else: client_password = get_client_password(checksum_address=config.checksum_address, envvar=NUCYPHER_ENVVAR_ALICE_ETH_PASSWORD) try: ALICE = make_cli_character(character_config=config, emitter=emitter, unlock_keyring=not config.dev_mode, teacher_uri=self.teacher_uri, min_stake=self.min_stake, client_password=client_password, start_learning_now=load_seednodes, lonely=self.config_options.lonely) return ALICE except NucypherKeyring.AuthenticationFailed as e: emitter.echo(str(e), color='red', bold=True) click.get_current_context().exit(1)
def create_character(self, emitter, config_file, json_ipc, load_seednodes=True): # TODO: embed compatibility layer? ursula_config = self.config_options.create_config(emitter, config_file) is_clef = ClefSigner.is_valid_clef_uri(self.config_options.signer_uri) # TODO: Oh client_password = None if not ursula_config.federated_only: if not self.config_options.dev and not json_ipc and not is_clef: client_password = get_client_password( checksum_address=ursula_config.worker_address, envvar=NUCYPHER_ENVVAR_WORKER_ETH_PASSWORD) try: URSULA = make_cli_character( character_config=ursula_config, emitter=emitter, min_stake=self.min_stake, teacher_uri=self.teacher_uri, unlock_keyring=not self.config_options.dev, lonely=self.config_options.lonely, client_password=client_password, start_learning_now=load_seednodes) return ursula_config, URSULA except NucypherKeyring.AuthenticationFailed as e: emitter.echo(str(e), color='red', bold=True) # TODO: Exit codes (not only for this, but for other exceptions) return click.get_current_context().exit(1)
def create_character(self, emitter, config_file, json_ipc, load_seednodes=True): ursula_config = self.config_options.create_config(emitter, config_file) is_clef = ClefSigner.is_valid_clef_uri(self.config_options.signer_uri) password_required = all( (not ursula_config.federated_only, not self.config_options.dev, not json_ipc, not is_clef)) __password = None if password_required: __password = get_client_password( checksum_address=ursula_config.worker_address, envvar=NUCYPHER_ENVVAR_WORKER_ETH_PASSWORD) try: URSULA = make_cli_character( character_config=ursula_config, emitter=emitter, min_stake=self.min_stake, teacher_uri=self.teacher_uri, unlock_keyring=not self.config_options.dev, client_password=__password, unlock_signer= False, # Ursula's unlock is managed separately using client_password. lonely=self.config_options.lonely, start_learning_now=load_seednodes, json_ipc=json_ipc) return ursula_config, URSULA except NucypherKeyring.AuthenticationFailed as e: emitter.echo(str(e), color='red', bold=True) # TODO: Exit codes (not only for this, but for other exceptions) return click.get_current_context().exit(1)
def __create_executive(self, registry, transacting: bool = False) -> Executive: client_password = None is_clef = ClefSigner.is_valid_clef_uri(self.signer_uri) if transacting and not self.hw_wallet and not is_clef: client_password = get_client_password(checksum_address=self.checksum_address) executive = Executive(checksum_address=self.checksum_address, registry=registry, signer=ClefSigner(self.signer_uri), client_password=client_password) return executive
def __create_participant(self, registry, transacting: bool = True, hw_wallet: bool = False) -> DaoActor: client_password = None is_clef = ClefSigner.is_valid_clef_uri(self.signer_uri) # TODO: why not allow the clef signer's validator act on this? if transacting and not is_clef and not hw_wallet: client_password = get_client_password(checksum_address=self.participant_address) testnet = self.network != NetworksInventory.MAINNET signer = Signer.from_signer_uri(self.signer_uri, testnet=testnet) if self.signer_uri else None actor = DaoActor(checksum_address=self.participant_address, network=self.network, registry=registry, signer=signer, transacting=transacting) return actor
def unlock_signer_account(config: CharacterConfiguration, json_ipc: bool) -> None: # TODO: Remove this block after deprecating 'worker_address' from nucypher.config.characters import UrsulaConfiguration if isinstance(config, UrsulaConfiguration): account = config.worker_address else: account = config.checksum_address is_clef = ClefSigner.is_valid_clef_uri(config.signer_uri) eth_password_is_needed = all((not config.federated_only, not config.signer.is_device(account=account), not config.dev_mode, not is_clef)) __password = None if eth_password_is_needed: if json_ipc and not os.environ.get(config.SIGNER_ENVVAR): raise ValueError(f'{config.SIGNER_ENVVAR} is required to use JSON IPC mode.') __password = get_client_password(checksum_address=account, envvar=config.SIGNER_ENVVAR) config.signer.unlock_account(account=config.checksum_address, password=__password)
def create_actor(self, emitter: StdoutEmitter, is_multisig: bool = False ) -> Tuple[ContractAdministrator, str, BlockchainInterface, BaseContractRegistry]: ensure_config_root(self.config_root) deployer_interface = initialize_deployer_interface(poa=self.poa, provider_uri=self.provider_uri, emitter=emitter, ignore_solidity_check=self.ignore_solidity_check, gas_strategy=self.gas_strategy, max_gas_price=self.max_gas_price) # Warnings deployer_pre_launch_warnings(emitter, self.etherscan, self.hw_wallet) # # Establish Registry # local_registry = establish_deployer_registry(emitter=emitter, use_existing_registry=bool(self.contract_name), # TODO: Issue #2314 registry_infile=self.registry_infile, registry_outfile=self.registry_outfile, dev=self.dev, network=self.network) # # Make Authenticated Deployment Actor # # Verify Address & collect password password = None if is_multisig: multisig_agent = ContractAgency.get_agent(MultiSigAgent, registry=local_registry) deployer_address = multisig_agent.contract.address is_transacting = False else: is_transacting = True deployer_address = self.deployer_address if not deployer_address: deployer_address = select_client_account(emitter=emitter, prompt=SELECT_DEPLOYER_ACCOUNT, provider_uri=self.provider_uri, signer_uri=self.signer_uri, show_eth_balance=True) if not self.force: click.confirm(CONFIRM_SELECTED_ACCOUNT.format(address=deployer_address), abort=True) is_clef = ClefSigner.is_valid_clef_uri(self.signer_uri) eth_password_is_needed = not self.hw_wallet and not deployer_interface.client.is_local and not is_clef if eth_password_is_needed: password = get_client_password(checksum_address=deployer_address) # Produce Actor testnet = deployer_interface.client.chain_name != PUBLIC_CHAINS[1] # Mainnet signer = Signer.from_signer_uri(self.signer_uri, testnet=testnet) if self.signer_uri else None ADMINISTRATOR = ContractAdministrator(registry=local_registry, client_password=password, deployer_address=deployer_address, is_transacting=is_transacting, signer=signer) # Verify ETH Balance emitter.echo(DEPLOYER_BALANCE.format(eth_balance=ADMINISTRATOR.eth_balance)) 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