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A,EAAS;AACd,MAAA,CAAA,CAAE,OAAA,GAAU,EAAE,OAAA,CAAQ,MAAA;AAAA,QACpB,CAAC,CAAA,KAAM,CAAA,CAAE,CAAA,KAAM,MAAA,CAAO,OAAO,CAAA,IAAK,CAAA,CAAE,CAAA,KAAM,MAAA,CAAO,MAAA,CAAO;AAAA,OAC1D;AAAA,IACF;AAAA,EACF;AACF;;;ACxBO,SAAS,cAAA,CACd,MACA,QAAA,EACG;AACH,EAAA,IAAI,IAAA,EAAM,GAAA,KAAQ,MAAA,EAAW,OAAO,IAAA,CAAK,GAAA;AACzC,EAAA,IAAI,MAAM,SAAA,KAAc,MAAA,EAAW,OAAQ,IAAA,CAAK,YAAY,WAAA,GAAc,MAAA;AAC1E,EAAA,OAAO,QAAA;AACT","file":"chunk-BOQJOFOZ.mjs","sourcesContent":["import type { DevicePublicKey } from \"../signer/DeviceSigner\";\n\n/**\n * First-write claim of a derived address. Native Ed25519 addresses come from\n * the MasterDEK, not from this map. Cavos records the claim for billing and\n * so two first devices cannot publish two different accounts for one login.\n */\nexport interface WalletRegistry {\n  /** The user's existing wallet, or null if they don't have one yet. */\n  lookup(userId: string): Promise<RegisteredWallet | null>;\n\n  /**\n   * Claim the address this device derived. Insert-only: if another device got\n   * there first, the returned address is THAT one.\n   */\n  register(params: {\n    userId: string;\n    address: string;\n    initialSigner: DevicePublicKey;\n  }): Promise<RegisterResult>;\n\n  /** Note an additional device signer for the user's wallet (after approval). */\n  addDevice?(params: {\n    userId: string;\n    address: string;\n    signer: DevicePublicKey;\n  }): Promise<void>;\n\n  /** Drop a device signer after it has been revoked on-chain. */\n  removeDevice?(params: {\n    userId: string;\n    address: string;\n    signer: DevicePublicKey;\n  }): Promise<void>;\n}\n\nexport interface RegisterResult {\n  /** The address that is now recorded — ours, or the winner's on a conflict. */\n  address: string;\n  /** True when someone else had already claimed this identity's row. */\n  conflict: boolean;\n}\n\nexport interface RegisteredWallet {\n  address: string;\n  /** Public keys of the devices registered on this wallet (if tracked). */\n  devices?: DevicePublicKey[];\n}\n\n/** Simple in-memory registry for demos / tests. */\nexport class InMemoryWalletRegistry implements WalletRegistry {\n  private wallets = new Map<string, RegisteredWallet>();\n\n  async lookup(userId: string): Promise<RegisteredWallet | null> {\n    return this.wallets.get(userId) ?? null;\n  }\n  async register(params: { userId: string; address: string; initialSigner: DevicePublicKey }) {\n    const existing = this.wallets.get(params.userId);\n    if (existing) return { address: existing.address, conflict: existing.address !== params.address };\n    this.wallets.set(params.userId, { address: params.address, devices: [params.initialSigner] });\n    return { address: params.address, conflict: false };\n  }\n  async addDevice(params: { userId: string; address: string; signer: DevicePublicKey }) {\n    const w = this.wallets.get(params.userId);\n    if (w) w.devices = [...(w.devices ?? []), params.signer];\n  }\n  async removeDevice(params: { userId: string; address: string; signer: DevicePublicKey }) {\n    const w = this.wallets.get(params.userId);\n    if (w?.devices) {\n      w.devices = w.devices.filter(\n        (d) => d.x !== params.signer.x || d.y !== params.signer.y,\n      );\n    }\n  }\n}\n","/** A chain-native contract call (Starknet `Call`-shaped; generic for portability). */\nexport interface ChainCall {\n  contractAddress: string;\n  entrypoint: string;\n  calldata: string[];\n}\n\n/**\n * Options for state-changing wallet calls (`execute`, `upgrade`, etc.).\n *\n *   await wallet.execute(calls);                          // the account pays\n *   await wallet.execute(calls, { fee: 'sponsored' });    // the app pays\n *   await wallet.execute(calls, { fee: { token: USDC } }); // the user pays, in USDC\n *\n * `fee` answers one question — who pays, and in what — so the three answers are\n * one field rather than several flags that look independent and are not.\n *\n *   - `'self'` (the default on Solana): the account pays from its own balance.\n *   - `'sponsored'`: the Cavos relayer / paymaster pays, so the user signs but\n *     never holds a gas token. On Starknet and Stellar this is the default,\n *     because a fresh account there cannot deploy itself or meet the base\n *     reserve without help.\n *   - `{ token }`: the user pays, in a token they already hold. Solana only.\n *     Toll is the fee payer and settles in that token in the same transaction,\n *     so an account holding no SOL still transacts. Requires a `toll` client.\n */\n/** Who pays. Meaningful on every chain. */\nexport type FeeMode = 'self' | 'sponsored';\n\n/**\n * Solana can also be paid in a token, through Toll. No other chain can, so no\n * other chain's options accept it — a `{ token }` written against Stellar or\n * Starknet fails to compile rather than being quietly ignored, which is what\n * it was doing when `fee` lived in the shared type but only Solana read it.\n */\nexport type SolanaFeeMode = FeeMode | { token: string };\n\nexport interface ExecuteOptions {\n  fee?: FeeMode;\n  /**\n   * @deprecated Use `fee`. `true` is `'sponsored'`, `false` is `'self'`.\n   */\n  sponsored?: boolean;\n}\n\nexport interface SolanaExecuteOptions extends Omit<ExecuteOptions, 'fee'> {\n  fee?: SolanaFeeMode;\n}\n\n/** `fee` wins; `sponsored` is honoured while it is still around. */\nexport function resolveFeeMode<M extends SolanaFeeMode>(\n  opts: { fee?: M; sponsored?: boolean } | undefined,\n  fallback: M,\n): M {\n  if (opts?.fee !== undefined) return opts.fee;\n  if (opts?.sponsored !== undefined) return (opts.sponsored ? 'sponsored' : 'self') as M;\n  return fallback;\n}\n"]}