def at(self, address: str, force: bool = False) -> "LocalAccount": """ Retrieve an `Account` instance from the address string. Raises `ValueError` if the account cannot be found. Arguments --------- address: string Address of the account force: bool When True, will add the account even if it was not found in web3.eth.accounts Returns ------- Account """ address = _resolve_address(address) acct = next((i for i in self._accounts if i == address), None) if acct is None and (address in web3.eth.accounts or force): acct = Account(address) if CONFIG.network_type == "development" and address not in web3.eth.accounts: # prior to ganache v6.11.0 this does nothing, but should not raise web3.provider.make_request("evm_unlockUnknownAccount", [address]) # type: ignore self._accounts.append(acct) if acct: return acct raise UnknownAccount(f"No account exists for {address}")
def at(self, address: str, force: bool = False) -> "LocalAccount": """ Retrieve an `Account` instance from the address string. Raises `ValueError` if the account cannot be found. Arguments --------- address: string Address of the account force: bool When True, will add the account even if it was not found in web3.eth.accounts Returns ------- Account """ address = _resolve_address(address) acct = next((i for i in self._accounts if i == address), None) if acct is None and (address in web3.eth.accounts or force): acct = Account(address) if CONFIG.network_type == "development" and address not in web3.eth.accounts: rpc.unlock_account(address) self._accounts.append(acct) if acct: return acct raise UnknownAccount(f"No account exists for {address}")
def at(self, address: str) -> "LocalAccount": """ Retrieve an `Account` instance from the address string. Raises `ValueError` if the account cannot be found. Arguments --------- address: string Address of the account Returns ------- Account """ address = _resolve_address(address) acct = next((i for i in self._accounts if i == address), None) if acct is None and address in web3.eth.accounts: acct = Account(address) self._accounts.append(acct) if acct: return acct raise UnknownAccount(f"No account exists for {address}")
def _release(project_path, registry_address, sender): network.connect("mainnet") with project_path.joinpath("ethpm-config.yaml").open() as fp: project_config = yaml.safe_load(fp) print("Generating manifest and pinning assets to IPFS...") manifest, uri = ethpm.create_manifest(project_path, project_config, True, False) if sender in accounts: account = accounts.at(sender) else: try: account = accounts.load(sender) except FileNotFoundError: raise UnknownAccount(f"Unknown account '{sender}'") name = f'{manifest["package_name"]}@{manifest["version"]}' print(f'Releasing {name} on "{registry_address}"...') try: tx = ethpm.release_package(registry_address, account, manifest["package_name"], manifest["version"], uri) if tx.status == 1: notify("SUCCESS", f"{name} has been released!") print( f"\nURI: {color('bright magenta')}ethpm://{registry_address}:1/{name}{color}" ) return except Exception: pass notify( "ERROR", f'Transaction reverted when releasing {name} on "{registry_address}"')
def remove(self, address): '''Removes an account instance from the container. Args: address: Account instance or address string of account to remove.''' address = to_address(address) try: self._accounts.remove(address) except ValueError: raise UnknownAccount(f"No account exists for {address}")
def remove(self, address: str) -> None: """Removes an account instance from the container. Args: address: Account instance or address string of account to remove.""" address = _resolve_address(address) try: self._accounts.remove(address) except ValueError: raise UnknownAccount(f"No account exists for {address}")
def remove(self, address: Union[str, "Account"]) -> None: """ Remove an `Account` instance from the container. Arguments --------- address: str | Account Account instance, or string of the account address. """ address = _resolve_address(str(address)) try: self._accounts.remove(address) except ValueError: raise UnknownAccount(f"No account exists for {address}")
def at(self, address): '''Retrieves an Account instance from the address string. Raises ValueError if the account cannot be found. Args: address: string of the account address. Returns: Account instance. ''' address = to_address(address) try: return next(i for i in self._accounts if i == address) except StopIteration: raise UnknownAccount(f"No account exists for {address}")