{
  "$schema": "https://farmslot.io/schemas/recipe-v1.schema.json",
  "title": "Assets release custom-network token persistence",
  "description": "Adds PulseChain and PLSX, proves both survive lock/unlock, then removes the custom network.",
  "paramsSchema": {
    "type": "object",
    "additionalProperties": false,
    "properties": {
      "network": { "type": "string", "default": "PulseChain" },
      "rpc_url": { "type": "string", "default": "https://rpc.pulsechain.com" },
      "chain_id": { "type": "integer", "minimum": 1, "default": 369 },
      "native_symbol": { "type": "string", "default": "PLS" },
      "explorer_url": { "type": "string", "default": "https://scan.pulsechain.com" },
      "token_address": { "type": "string", "default": "0x95B303987A60C71504D99Aa1b13B4DA07b0790ab" },
      "token_symbol": { "type": "string", "default": "PLSX" },
      "token_decimals": { "type": "integer", "minimum": 0, "default": 18 },
      "timeout_ms": { "type": "integer", "minimum": 1000, "default": 60000 }
    }
  },
  "workflow": {
    "entry": "open-wallet",
    "nodes": {
      "open-wallet": {
        "action": "ui.navigate",
        "page": "home",
        "intent": "Open the wallet before custom-network setup",
        "next": "add-network"
      },
      "add-network": {
        "action": "metamask.networks.add_custom",
        "network": "{{params.network}}",
        "rpc_url": "{{params.rpc_url}}",
        "chain_id": "{{params.chain_id}}",
        "symbol": "{{params.native_symbol}}",
        "explorer_url": "{{params.explorer_url}}",
        "require_absent": true,
        "timeout_ms": "{{params.timeout_ms}}",
        "intent": "Add and select the custom network through visible settings",
        "next": "import-token"
      },
      "import-token": {
        "action": "metamask.assets.import_custom_token",
        "network": "{{params.network}}",
        "chain_id": "{{params.chain_id}}",
        "address": "{{params.token_address}}",
        "expected_symbol": "{{params.token_symbol}}",
        "decimals": "{{params.token_decimals}}",
        "timeout_ms": "{{params.timeout_ms}}",
        "intent": "Import the custom-network token and verify its metadata",
        "next": "capture-before"
      },
      "capture-before": {
        "action": "ui.screenshot",
        "path": "screenshots/custom-network-token-before-lock.png",
        "label": "Custom network token before lock",
        "intent": "Preserve pre-lock PulseChain and PLSX evidence",
        "next": "lock-wallet"
      },
      "lock-wallet": {
        "action": "metamask.wallet.lock",
        "intent": "Lock the wallet through visible UI",
        "next": "unlock-wallet"
      },
      "unlock-wallet": {
        "action": "metamask.wallet.ensure_unlocked",
        "intent": "Unlock the same persisted profile",
        "next": "select-persisted-network"
      },
      "select-persisted-network": {
        "action": "ui.navigate",
        "page": "network",
        "network": "{{params.network}}",
        "chain_id": "{{params.chain_id}}",
        "add_if_missing": false,
        "timeout_ms": "{{params.timeout_ms}}",
        "intent": "Prove the custom network persisted and select it",
        "next": "assert-persisted-token"
      },
      "assert-persisted-token": {
        "action": "metamask.networks.read_visible_state",
        "network": "{{params.network}}",
        "chain_id": "{{params.chain_id}}",
        "require_symbols": ["{{params.token_symbol}}"],
        "minimum_asset_count": 1,
        "settle_ms": 1000,
        "intent": "Prove the custom token persisted on the custom network",
        "next": "capture-after"
      },
      "capture-after": {
        "action": "ui.screenshot",
        "path": "screenshots/custom-network-token-after-unlock.png",
        "label": "Custom network token after unlock",
        "intent": "Preserve post-unlock PulseChain and PLSX evidence",
        "next": "remove-network"
      },
      "remove-network": {
        "action": "metamask.networks.remove_custom",
        "network": "{{params.network}}",
        "chain_id": "{{params.chain_id}}",
        "timeout_ms": "{{params.timeout_ms}}",
        "intent": "Remove the custom network and its token during cleanup",
        "next": "done"
      },
      "done": { "action": "end", "status": "pass" }
    }
  }
}
