"""Vaultfire Key Protocol — Emergency Revoke Example

Something went wrong? One call to revoke everything.
This example shows all three emergency mechanisms:
1. Freeze your KeyVault (stops all spending)
2. Revoke all session keys
3. Revoke all delegations
"""

from vkp import VKPClient

client = VKPClient(
    rpc_url="https://mainnet.base.org",
    network_id="base-mainnet",
    factory_address="0x...",
    session_manager_address="0x...",
    delegation_registry_address="0x...",
)

AGENT_ADDRESS = "0xYourAgentAddress"
VAULT_ADDRESS = "0xYourVaultAddress"

# ─────────────────────────────────────────────────────────
# 1. FREEZE KEYVAULT — Stops all spending immediately
# ─────────────────────────────────────────────────────────

tx = client.keyvault.freeze(
    vault_address=VAULT_ADDRESS,
    from_address=AGENT_ADDRESS,
)
print("Freeze vault:", tx)

# ─────────────────────────────────────────────────────────
# 2. REVOKE ALL SESSION KEYS — Kills all temporary keys
# ─────────────────────────────────────────────────────────

tx = client.sessions.revoke_all(from_address=AGENT_ADDRESS)
print("Revoke all sessions:", tx)

# ─────────────────────────────────────────────────────────
# 3. REVOKE ALL DELEGATIONS — Kills all agent-to-agent trust
# ─────────────────────────────────────────────────────────

tx = client.delegations.revoke_all(from_address=AGENT_ADDRESS)
print("Revoke all delegations:", tx)

# ─────────────────────────────────────────────────────────
# 4. EMERGENCY WITHDRAW — Pull all funds from vault
# ─────────────────────────────────────────────────────────

tx = client.keyvault.emergency_withdraw(
    vault_address=VAULT_ADDRESS,
    from_address=AGENT_ADDRESS,
)
print("Emergency withdraw:", tx)

print("\nAll done. Your agent is fully locked down.")
