from typing import Tuple
from typing import Any


def walletClientWalletKeypair(walletclient) -> Tuple[Any, str, str, str]:
    """
    Provide a `WalletClient` that has had a wallet and keypair added.

    Returns:
    * a `WalletClient`
    * a random wallet name
    * a random passphrase
    * a public key
    """

    # Use a traderbot bot for Staging.
    wname = "demo"
    wpass = "123"

    # Log in
    r = walletclient.login(wname, wpass)
    assert (
        r.status_code == 200
    ), f"{r.url} returned HTTP {r.status_code} {r.text}"

    r = walletclient.listkeys()
    assert (
        r.status_code == 200
    ), f"{r.url} returned HTTP {r.status_code} {r.text}"
    j = r.json()
    assert len(j["keys"]) > 0
    pubkey = j["keys"][0]["pub"]

    return (walletclient, wname, wpass, pubkey)