Пример #1
0
 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
Пример #2
0
    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)
Пример #3
0
    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)
Пример #4
0
    def __create_bidder(self,
                        registry,
                        domain: str,
                        transacting: bool = True,
                        hw_wallet: bool = False,
                        ) -> Bidder:

        is_clef = ClefSigner.is_valid_clef_uri(self.signer_uri)
        testnet = self.network != NetworksInventory.MAINNET
        signer = Signer.from_signer_uri(self.signer_uri, testnet=testnet) if self.signer_uri else None
        password_required = (not is_clef and not hw_wallet)
        if signer and transacting and password_required:
            client_password = get_client_password(checksum_address=self.bidder_address)
            signer.unlock_account(account=self.bidder_address, password=client_password)

        transacting_power = None
        if transacting:
            transacting_power = TransactingPower(account=self.bidder_address, signer=signer)
            transacting_power.unlock(password=client_password)

        bidder = Bidder(registry=registry,
                        transacting_power=transacting_power,
                        checksum_address=self.bidder_address if not transacting_power else None,
                        domain=domain)
        return bidder
Пример #5
0
 def get_password(self, blockchain, client_account):
     is_clef = ClefSigner.is_valid_clef_uri(self.staker_options.config_options.signer_uri)
     eth_password_needed = not self.hw_wallet and not blockchain.client.is_local and not is_clef
     password = None
     if eth_password_needed:
         password = get_client_password(checksum_address=client_account)
     return password
Пример #6
0
 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
Пример #7
0
    def __create_bidder(self,
                        registry,
                        transacting: bool = True,
                        hw_wallet: bool = False) -> Bidder:

        client_password = None
        is_clef = ClefSigner.is_valid_clef_uri(self.signer_uri)
        if transacting and not is_clef and not hw_wallet:
            client_password = get_client_password(checksum_address=self.bidder_address)
        signer = Signer.from_signer_uri(self.signer_uri) if self.signer_uri else None
        bidder = Bidder(checksum_address=self.bidder_address,
                        registry=registry,
                        client_password=client_password,
                        signer=signer,
                        transacting=transacting)
        return bidder
Пример #8
0
    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)

        # 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),
            registry_infile=self.registry_infile,
            registry_outfile=self.registry_outfile,
            dev=self.dev)
        #
        # 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
        signer = Signer.from_signer_uri(
            self.signer_uri) if self.signer_uri else None
        ADMINISTRATOR = ContractAdministrator(
            registry=local_registry,
            client_password=password,
            deployer_address=deployer_address,
            is_transacting=is_transacting,
            signer=signer,
            staking_escrow_test_mode=self.se_test_mode)
        # 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