@zama-fhe/sdk 3.6.0 → 3.7.0-alpha.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (79) hide show
  1. package/dist/cjs/base-signer.cjs +1 -1
  2. package/dist/cjs/base-signer.cjs.map +1 -1
  3. package/dist/cjs/chains.cjs +1 -1
  4. package/dist/cjs/chains.cjs.map +1 -1
  5. package/dist/cjs/ethers/index.cjs +1 -1
  6. package/dist/cjs/ethers/index.cjs.map +1 -1
  7. package/dist/cjs/fhevm-relayer.cjs +2 -2
  8. package/dist/cjs/fhevm-relayer.cjs.map +1 -1
  9. package/dist/cjs/index.cjs +1 -1
  10. package/dist/cjs/index.cjs.map +1 -1
  11. package/dist/cjs/query/index.cjs +1 -1
  12. package/dist/cjs/query/index.cjs.map +1 -1
  13. package/dist/cjs/relayer.cjs +1 -1
  14. package/dist/cjs/relayer.cjs.map +1 -1
  15. package/dist/cjs/token.cjs +1 -1
  16. package/dist/cjs/token.cjs.map +1 -1
  17. package/dist/cjs/viem/index.cjs +1 -1
  18. package/dist/cjs/viem/index.cjs.map +1 -1
  19. package/dist/cjs/wrappers-registry.cjs +1 -1
  20. package/dist/cjs/wrappers-registry.cjs.map +1 -1
  21. package/dist/esm/base-signer--sBO2qJp.js +2 -0
  22. package/dist/esm/base-signer--sBO2qJp.js.map +1 -0
  23. package/dist/esm/{base-signer-Iu5Lszrf.d.ts → base-signer-S2Ogf6L4.d.ts} +2 -2
  24. package/dist/esm/chains/index.d.ts +1 -1
  25. package/dist/esm/chains/index.js +1 -1
  26. package/dist/esm/chains-DEpKup1n.js +2 -0
  27. package/dist/esm/chains-DEpKup1n.js.map +1 -0
  28. package/dist/esm/cleartext/index.d.ts +2 -2
  29. package/dist/esm/cleartext/index.js +1 -1
  30. package/dist/esm/{cleartext-iE4sWgSP.js → cleartext-DcbDCDXj.js} +2 -2
  31. package/dist/esm/{cleartext-iE4sWgSP.js.map → cleartext-DcbDCDXj.js.map} +1 -1
  32. package/dist/esm/{cleartext-B2DI8fgm.d.ts → cleartext-pv2blbFU.d.ts} +2 -2
  33. package/dist/esm/encrypt.worker.js +51 -51
  34. package/dist/esm/{encryption-BKoalB4o.js → encryption-DJljZ2oV.js} +2 -2
  35. package/dist/esm/{encryption-BKoalB4o.js.map → encryption-DJljZ2oV.js.map} +1 -1
  36. package/dist/esm/ethers/index.d.ts +5 -5
  37. package/dist/esm/ethers/index.js +1 -1
  38. package/dist/esm/ethers/index.js.map +1 -1
  39. package/dist/esm/fhevm-relayer-CPmCytDX.js +8 -0
  40. package/dist/esm/fhevm-relayer-CPmCytDX.js.map +1 -0
  41. package/dist/esm/{index-BCh3VaZo.d.ts → index-DRrrBtMX.d.ts} +2000 -1115
  42. package/dist/esm/{index-ijgDL4IC.d.ts → index-Gk1S0gjO.d.ts} +14 -1
  43. package/dist/esm/{index-S6QjPkZE.d.ts → index-tfvbrVa2.d.ts} +4 -4
  44. package/dist/esm/index.d.ts +108 -8
  45. package/dist/esm/index.js +1 -1
  46. package/dist/esm/index.js.map +1 -1
  47. package/dist/esm/node/index.d.ts +4 -4
  48. package/dist/esm/node/index.js +1 -1
  49. package/dist/esm/query/index.d.ts +4 -537
  50. package/dist/esm/query/index.js +1 -1
  51. package/dist/esm/query/index.js.map +1 -1
  52. package/dist/esm/relayer-B6Zo6EkX.js +2 -0
  53. package/dist/esm/relayer-B6Zo6EkX.js.map +1 -0
  54. package/dist/esm/token-BMQ6xlrk.js +2 -0
  55. package/dist/esm/{token-BejFVO8m.js.map → token-BMQ6xlrk.js.map} +1 -1
  56. package/dist/esm/{types-D3W3J65M.d.ts → types-BOyFfG7D.d.ts} +42 -7
  57. package/dist/esm/{types-Ce9Lhvrf.d.ts → types-BRIpBy9n.d.ts} +3 -3
  58. package/dist/esm/{types-CFDG6lIJ.d.ts → types-OXQqX_kH.d.ts} +3 -3
  59. package/dist/esm/{validation-BRu06AM_.js → validation-DWe2k89s.js} +2 -2
  60. package/dist/esm/{validation-BRu06AM_.js.map → validation-DWe2k89s.js.map} +1 -1
  61. package/dist/esm/viem/index.d.ts +5 -5
  62. package/dist/esm/viem/index.js +1 -1
  63. package/dist/esm/viem/index.js.map +1 -1
  64. package/dist/esm/web/index.d.ts +1 -1
  65. package/dist/esm/web/index.js +1 -1
  66. package/dist/esm/wrappers-registry-BfQr2QHn.js +2 -0
  67. package/dist/esm/wrappers-registry-BfQr2QHn.js.map +1 -0
  68. package/package.json +2 -2
  69. package/dist/esm/base-signer-DGIEzavu.js +0 -2
  70. package/dist/esm/base-signer-DGIEzavu.js.map +0 -1
  71. package/dist/esm/chains-ByyCdrrd.js +0 -2
  72. package/dist/esm/chains-ByyCdrrd.js.map +0 -1
  73. package/dist/esm/fhevm-relayer-Cm-ZR1vP.js +0 -8
  74. package/dist/esm/fhevm-relayer-Cm-ZR1vP.js.map +0 -1
  75. package/dist/esm/relayer-CVKO9GmQ.js +0 -2
  76. package/dist/esm/relayer-CVKO9GmQ.js.map +0 -1
  77. package/dist/esm/token-BejFVO8m.js +0 -2
  78. package/dist/esm/wrappers-registry-BLe7PkZi.js +0 -2
  79. package/dist/esm/wrappers-registry-BLe7PkZi.js.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wrappers-registry-BfQr2QHn.js","names":[],"sources":["../../src/errors/credential.ts","../../src/errors/signing.ts","../../src/errors/transaction.ts","../../src/errors/signer.ts","../../src/events/sdk-events.ts","../../src/schemas/primitives.ts","../../src/utils/swallow.ts","../../src/credentials/utils.ts","../../src/abi/confidential-wrapper.abi.ts","../../src/contracts/confidential-wrapper.ts","../../src/contracts/erc20.ts","../../src/abi/erc165.abi.ts","../../src/contracts/erc165.ts","../../src/contracts/wrappers-registry.ts"],"sourcesContent":["import { isUnsupportedUnifiedPermitMessage } from \"../utils/error\";\nimport { ZamaError, ZamaErrorCode } from \"./base\";\n\n/** Transport key pair has expired and needs regeneration. */\nexport class TransportKeyPairExpiredError extends ZamaError {\n constructor(message: string, options?: ErrorOptions) {\n super(ZamaErrorCode.TransportKeyPairExpired, message, options);\n this.name = \"TransportKeyPairExpiredError\";\n }\n}\n\n/** Relayer rejected the transport key pair (stale, expired, or malformed). */\nexport class InvalidTransportKeyPairError extends ZamaError {\n constructor(message: string, options?: ErrorOptions) {\n super(ZamaErrorCode.InvalidTransportKeyPair, message, options);\n this.name = \"InvalidTransportKeyPairError\";\n }\n}\n\n/**\n * The permit's KMS context has been revoked on-chain, so the permit (and every\n * other permit signed under that context) is permanently unusable. The SDK\n * already tried to self-heal before surfacing this. Check `cause` to tell why\n * it failed: a `SigningFailedError` means the configured signer could not\n * produce a new permit, waiting will not help, establish a new permit with a\n * working signer. Any other cause means the retry hit the same revoked\n * context, typically because the upstream validity check caches a stale\n * \"valid\" verdict for up to 15 minutes; wait out that window and retry.\n */\nexport class RevokedKmsContextError extends ZamaError {\n constructor(message: string, options?: ErrorOptions) {\n super(ZamaErrorCode.RevokedKmsContext, message, options);\n this.name = \"RevokedKmsContextError\";\n }\n}\n\n/** No FHE ciphertext exists for this account (never shielded). */\nexport class NoCiphertextError extends ZamaError {\n constructor(message: string, options?: ErrorOptions) {\n super(ZamaErrorCode.NoCiphertext, message, options);\n this.name = \"NoCiphertextError\";\n }\n}\n\n/**\n * Wrapping or unwrapping the transport private key with `transportKeyPairDerivationSecret` failed:\n * a scoped entry that fails to unwrap may belong to a peer using a different secret, so it fails\n * loudly instead of silently regenerating and clobbering that peer's entry, or the underlying\n * WebCrypto operation itself failed (e.g. `crypto.subtle` unavailable in this environment).\n */\nexport class KeyWrappingError extends ZamaError {\n constructor(message: string, options?: ErrorOptions) {\n super(ZamaErrorCode.KeyWrappingFailed, message, options);\n this.name = \"KeyWrappingError\";\n }\n}\n\n/**\n * The transport key pair changed between `preparePermit` and `registerPermit`\n * (expired, evicted, or rotated in between). The prepared EIP-712 payload was\n * signed against the old key pair's public key — registering it under a\n * different one would persist a permit bound to the wrong key. Call\n * `preparePermit` again to rebind the signature request to the current key pair.\n */\nexport class TransportKeyPairChangedError extends ZamaError {\n constructor(message: string, options?: ErrorOptions) {\n super(ZamaErrorCode.TransportKeyPairChanged, message, options);\n this.name = \"TransportKeyPairChangedError\";\n }\n}\n\n/**\n * A prepared permit's `chainId` doesn't match the chain `registerPermit` is\n * running against. The EIP-712 payload's domain is bound to the chain it was\n * prepared for; registering it under a different chain would persist a permit\n * whose signed payload disagrees with its storage scope.\n */\nexport class PreparedPermitChainMismatchError extends ZamaError {\n /** Chain ID the permit was prepared for. */\n readonly preparedChainId: number;\n /** Chain ID `registerPermit` is currently running against. */\n readonly activeChainId: number;\n\n constructor(\n { preparedChainId, activeChainId }: { preparedChainId: number; activeChainId: number },\n options?: ErrorOptions,\n ) {\n super(\n ZamaErrorCode.PreparedPermitChainMismatch,\n `registerPermit: prepared.chainId (${preparedChainId}) does not match the active chain ` +\n `(${activeChainId}). Register the permit while the SDK is configured for the chain it was prepared for.`,\n options,\n );\n this.name = \"PreparedPermitChainMismatchError\";\n this.preparedChainId = preparedChainId;\n this.activeChainId = activeChainId;\n }\n}\n\n/** A prepared permit's validity window elapsed before its signature was registered. */\nexport class PreparedPermitExpiredError extends ZamaError {\n constructor(message: string, options?: ErrorOptions) {\n super(ZamaErrorCode.PreparedPermitExpired, message, options);\n this.name = \"PreparedPermitExpiredError\";\n }\n}\n\n/**\n * The connected chain doesn't support V2 (unified) decryption permits yet —\n * including {@link WILDCARD_PERMIT} — because it hasn't upgraded to protocol\n * v0.14 or later. Thrown before any wallet prompt: the SDK detects this from\n * the chain's on-chain KMS context, without a signature attempt. V1 permits\n * (an explicit contract list, not `WILDCARD_PERMIT`) are unaffected — grant\n * one of those instead, or retry once the network upgrades.\n */\nexport class UnifiedPermitNotSupportedError extends ZamaError {\n constructor(message: string, options?: ErrorOptions) {\n super(ZamaErrorCode.UnifiedPermitNotSupported, message, options);\n this.name = \"UnifiedPermitNotSupportedError\";\n }\n}\n\nfunction unifiedPermitNotSupportedMessage(op: \"grantPermit\" | \"preparePermit\"): string {\n return (\n `${op}: V2 (unified) decryption permits — including wildcard permits — require protocol ` +\n \"v0.14 or later on this network. The connected chain hasn't upgraded yet (or its \" +\n \"ProtocolConfig contract address isn't configured on this FheChain). \" +\n `Call ${op} with an explicit V1 contract list instead, or retry once the network upgrades.`\n );\n}\n\n/**\n * A {@link WILDCARD_PERMIT} request the caller already confirmed is unsupported,\n * before any relayer call was attempted. See {@link toUnifiedPermitNotSupportedError}\n * for the converted-error counterpart.\n *\n * @param op Which `CredentialService` entry point is rejecting the request.\n */\nexport function wildcardPermitNotSupportedError(\n op: \"grantPermit\" | \"preparePermit\",\n): UnifiedPermitNotSupportedError {\n return new UnifiedPermitNotSupportedError(unifiedPermitNotSupportedMessage(op));\n}\n\n/**\n * Converts the `@fhevm/sdk` \"invalid extraData version\" signal — the chain\n * hasn't upgraded to protocol v0.14+ — into a typed\n * {@link UnifiedPermitNotSupportedError} worded for the calling entry point.\n *\n * @param op Which `CredentialService` entry point is converting the error.\n * @returns The typed error, or `undefined` when `error` doesn't match so the\n * caller can fall through to its own handling.\n */\nexport function toUnifiedPermitNotSupportedError(\n op: \"grantPermit\" | \"preparePermit\",\n error: unknown,\n): UnifiedPermitNotSupportedError | undefined {\n if (!(error instanceof Error) || !isUnsupportedUnifiedPermitMessage(error.message)) {\n return undefined;\n }\n return new UnifiedPermitNotSupportedError(unifiedPermitNotSupportedMessage(op), { cause: error });\n}\n\n/**\n * A stored V2 (unified/wildcard) permit's scope is needed for this decrypt,\n * but the connected relayer instance hasn't deployed the `/v3/user-decrypt`\n * route it requires. Distinct from {@link UnifiedPermitNotSupportedError}:\n * that one fires at *signing* time because the *chain* hasn't upgraded to\n * protocol v0.14+; this one fires at *decrypt* time even though the chain and\n * the stored permit are both V2-capable — only this particular relayer\n * instance hasn't deployed the route yet. Grant a specific-contract (V1)\n * permit instead, or retry once the relayer upgrades.\n */\nexport class UnifiedDecryptionUnsupportedError extends ZamaError {\n constructor(message: string, options?: ErrorOptions) {\n super(ZamaErrorCode.UnifiedDecryptionUnsupported, message, options);\n this.name = \"UnifiedDecryptionUnsupportedError\";\n }\n}\n\n/**\n * The requested invalidation cutoff was not strictly later than the account's\n * current one. The ACL only ever moves the cutoff forward, so re-sending the\n * same or an older timestamp always reverts.\n */\nexport class InvalidationTimestampTooLowError extends ZamaError {\n constructor(message: string, options?: ErrorOptions) {\n super(ZamaErrorCode.InvalidationTimestampTooLow, message, options);\n this.name = \"InvalidationTimestampTooLowError\";\n }\n}\n\n/**\n * The requested invalidation cutoff was in the future. The ACL refuses to\n * invalidate signatures that have not been produced yet.\n */\nexport class InvalidationTimestampInFutureError extends ZamaError {\n constructor(message: string, options?: ErrorOptions) {\n super(ZamaErrorCode.InvalidationTimestampInFuture, message, options);\n this.name = \"InvalidationTimestampInFutureError\";\n }\n}\n","import {\n extractRpcErrorCode,\n extractWalletErrorName,\n isInvalidTransportKeyPairMessage,\n} from \"../utils/error\";\nimport { ZamaError, ZamaErrorCode } from \"./base\";\nimport { InvalidTransportKeyPairError } from \"./credential\";\n\n/**\n * Diagnostic metadata attached to a signing-failure error, on top of the\n * inherited `cause`. All optional and best-effort: `operation` comes from the\n * caller, `rpcCode`/`walletErrorName` are extracted from the wallet's raw\n * error by {@link wrapSigningError}.\n */\nexport interface SigningErrorMetadata {\n /** Name of the SDK operation that was signing when the wallet/provider failed (e.g. \"grantPermit\"). */\n operation?: string;\n /** JSON-RPC / EIP-1193 numeric error code found in the failure's cause chain, if any. */\n rpcCode?: number;\n /** `name` of the error class the wallet/provider library threw (e.g. viem's `InvalidParamsRpcError`). */\n walletErrorName?: string;\n}\n\n/** User rejected the wallet signature prompt. */\nexport class SigningRejectedError extends ZamaError {\n /** Name of the SDK operation that was signing when the user rejected. */\n readonly operation: string | undefined;\n /** JSON-RPC / EIP-1193 numeric error code found in the failure's cause chain, if any. */\n readonly rpcCode: number | undefined;\n /** `name` of the error class the wallet/provider library threw. */\n readonly walletErrorName: string | undefined;\n\n constructor(message: string, options?: ErrorOptions & SigningErrorMetadata) {\n const { operation, rpcCode, walletErrorName, ...errorOptions } = options ?? {};\n super(ZamaErrorCode.SigningRejected, message, errorOptions);\n this.name = \"SigningRejectedError\";\n this.operation = operation;\n this.rpcCode = rpcCode;\n this.walletErrorName = walletErrorName;\n }\n}\n\n/** Wallet signature failed for a reason other than rejection. */\nexport class SigningFailedError extends ZamaError {\n /** Name of the SDK operation that was signing when the wallet/provider failed. */\n readonly operation: string | undefined;\n /** JSON-RPC / EIP-1193 numeric error code found in the failure's cause chain, if any. */\n readonly rpcCode: number | undefined;\n /** `name` of the error class the wallet/provider library threw. */\n readonly walletErrorName: string | undefined;\n\n constructor(message: string, options?: ErrorOptions & SigningErrorMetadata) {\n const { operation, rpcCode, walletErrorName, ...errorOptions } = options ?? {};\n super(ZamaErrorCode.SigningFailed, message, errorOptions);\n this.name = \"SigningFailedError\";\n this.operation = operation;\n this.rpcCode = rpcCode;\n this.walletErrorName = walletErrorName;\n }\n}\n\n/**\n * Classify a caught signing error into {@link SigningRejectedError},\n * {@link SigningFailedError}, or {@link InvalidTransportKeyPairError} and\n * return it rather than throw (mirroring {@link wrapDecryptError}/\n * {@link wrapEncryptError}), so a caller can emit an observability event\n * carrying the classified error before throwing it themselves. Enriches the\n * result with `rpcCode`/`walletErrorName` extracted from `error`'s cause\n * chain, and passes an already-typed `ZamaError` through unchanged.\n */\nexport function wrapSigningError(error: unknown, context: { operation: string }): ZamaError {\n if (error instanceof ZamaError) {\n return error;\n }\n const { operation } = context;\n const hasCode4001 =\n typeof error === \"object\" && error !== null && \"code\" in error && error.code === 4001;\n const originalMsg = error instanceof Error ? error.message : String(error);\n const lowerMsg = originalMsg.toLowerCase();\n const hasRejectionMessage =\n lowerMsg.includes(\"user rejected\") || lowerMsg.includes(\"user denied\");\n const fullMessage = `${operation}: ${originalMsg}`;\n if (hasCode4001 || hasRejectionMessage) {\n return new SigningRejectedError(fullMessage, {\n cause: error,\n operation,\n rpcCode: extractRpcErrorCode(error),\n walletErrorName: extractWalletErrorName(error),\n });\n }\n // A stale transport key pair the relayer can't re-derive (post-rotation) is\n // not a signing failure per se — surface it as the typed, self-heal signal so\n // the caller can evict the vault entry and regenerate.\n if (isInvalidTransportKeyPairMessage(originalMsg)) {\n return new InvalidTransportKeyPairError(fullMessage, { cause: error });\n }\n return new SigningFailedError(fullMessage, {\n cause: error,\n operation,\n rpcCode: extractRpcErrorCode(error),\n walletErrorName: extractWalletErrorName(error),\n });\n}\n","import { ZamaError, ZamaErrorCode } from \"./base\";\n\n/** On-chain transaction reverted. */\nexport class TransactionRevertedError extends ZamaError {\n constructor(message: string, options?: ErrorOptions) {\n super(ZamaErrorCode.TransactionReverted, message, options);\n this.name = \"TransactionRevertedError\";\n }\n}\n","import { ZamaError, ZamaErrorCode } from \"./base\";\n\n/**\n * Base class for signer/account readiness failures.\n */\nexport class SignerRequiredError extends ZamaError {\n /** Name of the operation that required a signer. */\n readonly operation: string;\n\n constructor(code: ZamaErrorCode, operation: string, message: string, options?: ErrorOptions) {\n super(code, message, options);\n this.name = \"SignerRequiredError\";\n this.operation = operation;\n }\n}\n\n/**\n * Thrown when an operation requires a signer but none is configured.\n *\n * The SDK can be constructed without a signer. Operations that need wallet\n * authority throw this before probing wallet state.\n *\n * @example\n * ```ts\n * try {\n * await token.confidentialTransfer(\"0xTo\", 100n);\n * } catch (e) {\n * if (e instanceof SignerNotConfiguredError) {\n * // Fix SDK/provider configuration.\n * }\n * }\n * ```\n */\nexport class SignerNotConfiguredError extends SignerRequiredError {\n constructor(operation: string, options?: ErrorOptions) {\n super(\n ZamaErrorCode.SignerNotConfigured,\n operation,\n `Cannot ${operation} without a signer. Configure one via createConfig({ signer: ... }) or <ZamaProvider config={createConfig({ signer: ... })}>.`,\n options,\n );\n this.name = \"SignerNotConfiguredError\";\n }\n}\n\n/** Thrown when a signer exists but no wallet account is currently connected. */\nexport class WalletNotConnectedError extends SignerRequiredError {\n constructor(operation: string, options?: ErrorOptions) {\n super(\n ZamaErrorCode.WalletNotConnected,\n operation,\n `Cannot ${operation} without a connected wallet account.`,\n options,\n );\n this.name = \"WalletNotConnectedError\";\n }\n}\n\n/** Thrown when an async adapter has not resolved its initial wallet account yet. */\nexport class WalletAccountNotReadyError extends SignerRequiredError {\n constructor(operation: string, options?: ErrorOptions) {\n super(\n ZamaErrorCode.WalletAccountNotReady,\n operation,\n `Cannot ${operation} before the wallet account is ready.`,\n options,\n );\n this.name = \"WalletAccountNotReadyError\";\n }\n}\n\n/**\n * Narrow a nullable signer-dependent value or throw {@link SignerNotConfiguredError}.\n */\nexport function requireConfigured<T>(value: T, operation: string): NonNullable<T> {\n if (value === null || value === undefined) {\n throw new SignerNotConfiguredError(operation);\n }\n return value as NonNullable<T>;\n}\n","import type { Address, Hex } from \"viem\";\nimport type { ClearValue, EncryptedValue } from \"../relayer/types\";\nimport type { ShieldPath } from \"../types/token\";\n\n/**\n * All SDK event keys, accessible as `ZamaSDKEvents.EncryptStart` etc.\n */\nexport const ZamaSDKEvents = {\n // FHE operations\n EncryptStart: \"encrypt:start\",\n EncryptEnd: \"encrypt:end\",\n EncryptError: \"encrypt:error\",\n DecryptStart: \"decrypt:start\",\n DecryptEnd: \"decrypt:end\",\n DecryptError: \"decrypt:error\",\n // Credential operations\n PermitError: \"permit:error\",\n // Write operations\n TransactionError: \"transaction:error\",\n ShieldSubmitted: \"shield:submitted\",\n TransferSubmitted: \"transfer:submitted\",\n TransferFromSubmitted: \"transferFrom:submitted\",\n SetOperatorSubmitted: \"setOperator:submitted\",\n ApproveUnderlyingSubmitted: \"approveUnderlying:submitted\",\n WrapSubmitted: \"wrap:submitted\",\n UnwrapSubmitted: \"unwrap:submitted\",\n FinalizeUnwrapSubmitted: \"finalizeUnwrap:submitted\",\n // Delegation operations\n DelegationSubmitted: \"delegation:submitted\",\n RevokeDelegationSubmitted: \"revokeDelegation:submitted\",\n // Permit operations\n InvalidateDecryptionSignaturesSubmitted: \"invalidateDecryptionSignatures:submitted\",\n // Unshield orchestration\n UnshieldPhase1Submitted: \"unshield:phase1_submitted\",\n UnshieldPhase2Started: \"unshield:phase2_started\",\n UnshieldPhase2Submitted: \"unshield:phase2_submitted\",\n} as const;\n\n/** Union of all SDK event type strings. */\nexport type ZamaSDKEventType = (typeof ZamaSDKEvents)[keyof typeof ZamaSDKEvents];\n\n// -- Base fields present on every event --\n\n/** Fields present on every SDK event; each concrete event extends this. */\nexport interface BaseEvent {\n /** Confidential token this event relates to, when the operation targets one. */\n tokenAddress?: Address;\n /** Unix epoch time (milliseconds) at which the event was emitted. */\n timestamp: number;\n /** Shared identifier linking related events in multi-phase operations (e.g. unshield). */\n operationId?: string;\n}\n\n// -- Per-event typed payloads --\n\n/** Emitted when an FHE encryption starts. */\nexport interface EncryptStartEvent extends BaseEvent {\n /** Event type discriminant. */\n type: typeof ZamaSDKEvents.EncryptStart;\n}\n\n/** Emitted when an FHE encryption completes successfully. */\nexport interface EncryptEndEvent extends BaseEvent {\n /** Event type discriminant. */\n type: typeof ZamaSDKEvents.EncryptEnd;\n /** Time the encryption took, in milliseconds. */\n durationMs: number;\n}\n\n/** Emitted when an FHE encryption fails. */\nexport interface EncryptErrorEvent extends BaseEvent {\n /** Event type discriminant. */\n type: typeof ZamaSDKEvents.EncryptError;\n /** The error that caused the encryption to fail. */\n error: Error;\n /** Time elapsed before the encryption failed, in milliseconds. */\n durationMs: number;\n}\n\n/** Emitted when an FHE decryption starts. */\nexport interface DecryptStartEvent extends BaseEvent {\n /** Event type discriminant. */\n type: typeof ZamaSDKEvents.DecryptStart;\n /** Encrypted values being decrypted — correlate with matching DecryptEnd/DecryptError. */\n encryptedValues: EncryptedValue[];\n}\n\n/** Emitted when an FHE decryption completes successfully. */\nexport interface DecryptEndEvent extends BaseEvent {\n /** Event type discriminant. */\n type: typeof ZamaSDKEvents.DecryptEnd;\n /** Time the decryption took, in milliseconds. */\n durationMs: number;\n /** Encrypted values that were decrypted. */\n encryptedValues: EncryptedValue[];\n /** Decrypted values keyed by encrypted value — use this to correlate events to specific entries. */\n result: Record<EncryptedValue, ClearValue>;\n}\n\n/** Emitted when an FHE decryption fails. */\nexport interface DecryptErrorEvent extends BaseEvent {\n /** Event type discriminant. */\n type: typeof ZamaSDKEvents.DecryptError;\n /** The error that caused the decryption to fail. */\n error: Error;\n /** Time elapsed before the decryption failed, in milliseconds. */\n durationMs: number;\n /** Encrypted values that were being decrypted when the error occurred. */\n encryptedValues: EncryptedValue[];\n}\n\n/**\n * SDK credential/permit operations that emit a {@link PermitErrorEvent} on failure.\n * `grantPermit` and `grantDelegationPermit` are distinguished so an integrator\n * can tell a direct-decrypt permit failure from a delegation-permit failure\n * without parsing the error message.\n */\nexport type PermitOperation = \"grantPermit\" | \"grantDelegationPermit\" | \"registerPermit\";\n\n/**\n * Emitted when signing or registering a decryption permit fails — including\n * wallet/provider signing failures (`SigningFailedError`/`SigningRejectedError`)\n * that would otherwise only be visible by catching the thrown error at the call\n * site. Mirrors {@link TransactionErrorEvent} for the credential/permit path.\n */\nexport interface PermitErrorEvent extends BaseEvent {\n /** Event type discriminant. */\n type: typeof ZamaSDKEvents.PermitError;\n /** Which permit operation failed. */\n operation: PermitOperation;\n /** The error that caused the operation to fail. */\n error: Error;\n}\n\n/** Emitted when a write operation's transaction fails (before or after submission). */\nexport interface TransactionErrorEvent extends BaseEvent {\n /** Event type discriminant. */\n type: typeof ZamaSDKEvents.TransactionError;\n /** Which SDK operation failed. */\n operation: TransactionOperation;\n /** The error that caused the transaction to fail. */\n error: Error;\n}\n\n/** Emitted when a shield transaction has been submitted to the network. */\nexport interface ShieldSubmittedEvent extends BaseEvent {\n /** Event type discriminant. */\n type: typeof ZamaSDKEvents.ShieldSubmitted;\n /** Hash of the submitted shield transaction. */\n txHash: Hex;\n /** Which execution path was used: single-tx `transferAndCall` or two-tx `approveAndWrap`. */\n shieldPath: ShieldPath;\n}\n\n/** Emitted when a confidential transfer transaction has been submitted to the network. */\nexport interface TransferSubmittedEvent extends BaseEvent {\n /** Event type discriminant. */\n type: typeof ZamaSDKEvents.TransferSubmitted;\n /** Hash of the submitted transfer transaction. */\n txHash: Hex;\n}\n\n/** Emitted when a confidential `transferFrom` transaction has been submitted to the network. */\nexport interface TransferFromSubmittedEvent extends BaseEvent {\n /** Event type discriminant. */\n type: typeof ZamaSDKEvents.TransferFromSubmitted;\n /** Hash of the submitted transferFrom transaction. */\n txHash: Hex;\n}\n\n/** Emitted when a set-operator transaction has been submitted to the network. */\nexport interface SetOperatorSubmittedEvent extends BaseEvent {\n /** Event type discriminant. */\n type: typeof ZamaSDKEvents.SetOperatorSubmitted;\n /** Hash of the submitted setOperator transaction. */\n txHash: Hex;\n}\n\n/** Emitted when an underlying-ERC-20 approval transaction has been submitted to the network. */\nexport interface ApproveUnderlyingSubmittedEvent extends BaseEvent {\n /** Event type discriminant. */\n type: typeof ZamaSDKEvents.ApproveUnderlyingSubmitted;\n /** Hash of the submitted approval transaction. */\n txHash: Hex;\n /** Which approval transaction was submitted. */\n step: \"reset\" | \"approve\";\n}\n\n/**\n * Emitted by the standalone `wrap()` escape hatch (not by `shield()`, which\n * emits {@link ShieldSubmittedEvent}). Distinct so a caller-initiated `wrap`\n * isn't conflated with `shield()`'s internal `approveAndWrap` leg — mirroring\n * how `unwrap` emits its own event rather than reusing the unshield phases.\n */\nexport interface WrapSubmittedEvent extends BaseEvent {\n /** Event type discriminant. */\n type: typeof ZamaSDKEvents.WrapSubmitted;\n /** Hash of the submitted wrap transaction. */\n txHash: Hex;\n}\n\n/** Emitted when an unwrap transaction has been submitted to the network. */\nexport interface UnwrapSubmittedEvent extends BaseEvent {\n /** Event type discriminant. */\n type: typeof ZamaSDKEvents.UnwrapSubmitted;\n /** Hash of the submitted unwrap transaction. */\n txHash: Hex;\n}\n\n/** Emitted when a finalize-unwrap transaction has been submitted to the network. */\nexport interface FinalizeUnwrapSubmittedEvent extends BaseEvent {\n /** Event type discriminant. */\n type: typeof ZamaSDKEvents.FinalizeUnwrapSubmitted;\n /** Hash of the submitted finalizeUnwrap transaction. */\n txHash: Hex;\n}\n\n/** Emitted when a decryption-delegation transaction has been submitted to the network. */\nexport interface DelegationSubmittedEvent extends BaseEvent {\n /** Event type discriminant. */\n type: typeof ZamaSDKEvents.DelegationSubmitted;\n /** Hash of the submitted delegation transaction. */\n txHash: Hex;\n}\n\n/** Emitted when a revoke-delegation transaction has been submitted to the network. */\nexport interface RevokeDelegationSubmittedEvent extends BaseEvent {\n /** Event type discriminant. */\n type: typeof ZamaSDKEvents.RevokeDelegationSubmitted;\n /** Hash of the submitted revokeDelegation transaction. */\n txHash: Hex;\n}\n\n/** Emitted when an invalidate-decryption-signatures transaction has been submitted to the network. */\nexport interface InvalidateDecryptionSignaturesSubmittedEvent extends BaseEvent {\n /** Event type discriminant. */\n type: typeof ZamaSDKEvents.InvalidateDecryptionSignaturesSubmitted;\n /** Hash of the submitted invalidateDecryptionSignatures transaction. */\n txHash: Hex;\n}\n\n/** Emitted when the first phase of an unshield (the unwrap request) has been submitted. */\nexport interface UnshieldPhase1SubmittedEvent extends BaseEvent {\n /** Event type discriminant. */\n type: typeof ZamaSDKEvents.UnshieldPhase1Submitted;\n /** Hash of the submitted phase-1 transaction. */\n txHash: Hex;\n}\n\n/** Emitted when the second phase of an unshield (finalization) starts. */\nexport interface UnshieldPhase2StartedEvent extends BaseEvent {\n /** Event type discriminant. */\n type: typeof ZamaSDKEvents.UnshieldPhase2Started;\n}\n\n/** Emitted when the second phase of an unshield (finalization) has been submitted. */\nexport interface UnshieldPhase2SubmittedEvent extends BaseEvent {\n /** Event type discriminant. */\n type: typeof ZamaSDKEvents.UnshieldPhase2Submitted;\n /** Hash of the submitted phase-2 transaction. */\n txHash: Hex;\n}\n\n/**\n * Discriminated union of all SDK events.\n *\n * Decrypt events carry encrypted values and decrypted clear-text values so event\n * subscribers can correlate and bind them in UI layers. Events never carry\n * private keys, permit signatures, or ZK proofs.\n */\nexport type ZamaSDKEvent =\n | EncryptStartEvent\n | EncryptEndEvent\n | EncryptErrorEvent\n | DecryptStartEvent\n | DecryptEndEvent\n | DecryptErrorEvent\n | PermitErrorEvent\n | TransactionErrorEvent\n | ShieldSubmittedEvent\n | TransferSubmittedEvent\n | TransferFromSubmittedEvent\n | SetOperatorSubmittedEvent\n | ApproveUnderlyingSubmittedEvent\n | WrapSubmittedEvent\n | UnwrapSubmittedEvent\n | FinalizeUnwrapSubmittedEvent\n | DelegationSubmittedEvent\n | RevokeDelegationSubmittedEvent\n | InvalidateDecryptionSignaturesSubmittedEvent\n | UnshieldPhase1SubmittedEvent\n | UnshieldPhase2StartedEvent\n | UnshieldPhase2SubmittedEvent;\n\n/** Callback invoked with each emitted {@link ZamaSDKEvent}. */\nexport type ZamaSDKEventListener = (event: ZamaSDKEvent) => void;\n\n/**\n * Distributive Omit that preserves the discriminated union. Internal emit-side\n * shape — consumers only ever receive fully-populated {@link ZamaSDKEvent}.\n * @internal\n */\nexport type ZamaSDKEventInput = ZamaSDKEvent extends infer E\n ? E extends ZamaSDKEvent\n ? Omit<E, \"timestamp\" | \"tokenAddress\">\n : never\n : never;\n\n/**\n * SDK transaction operations that emit submitted/error lifecycle events.\n *\n * Operation strings encode the execution-path discriminator for flows that have\n * one (`shield:transferAndCall` vs. `shield:approveAndWrap`), routing both error\n * and success events on a single field — see {@link transactionOperationMetadata}.\n */\nexport type TransactionOperation =\n | \"approveUnderlying\"\n | \"approveUnderlying:reset\"\n | \"delegateDecryption\"\n | \"finalizeUnwrap\"\n | \"invalidateDecryptionSignatures\"\n | \"revokeDelegation\"\n | \"setOperator\"\n | \"shield:transferAndCall\"\n | \"shield:approveAndWrap\"\n | \"wrap\"\n | \"transfer\"\n | \"transferAndCall\"\n | \"transferFrom\"\n | \"transferFromAndCall\"\n | \"unwrap\"\n | \"unwrapAll\";\n\n/**\n * Single source of truth for each transaction operation's submitted-event payload.\n *\n * Adding a write op = adding one entry here plus its {@link TransactionOperation}\n * member; the `satisfies Record<TransactionOperation, …>` check enforces that the\n * table and the union stay in lockstep (missing or extra keys fail the build) and\n * that every entry produces a valid {@link ZamaSDKEventInput}.\n *\n * @internal\n */\nexport const transactionOperationMetadata = {\n approveUnderlying: {\n submittedEvent: (txHash: Hex) => ({\n type: ZamaSDKEvents.ApproveUnderlyingSubmitted,\n txHash,\n step: \"approve\" as const,\n }),\n },\n \"approveUnderlying:reset\": {\n submittedEvent: (txHash: Hex) => ({\n type: ZamaSDKEvents.ApproveUnderlyingSubmitted,\n txHash,\n step: \"reset\" as const,\n }),\n },\n delegateDecryption: {\n submittedEvent: (txHash: Hex) => ({ type: ZamaSDKEvents.DelegationSubmitted, txHash }),\n },\n finalizeUnwrap: {\n submittedEvent: (txHash: Hex) => ({ type: ZamaSDKEvents.FinalizeUnwrapSubmitted, txHash }),\n },\n invalidateDecryptionSignatures: {\n submittedEvent: (txHash: Hex) => ({\n type: ZamaSDKEvents.InvalidateDecryptionSignaturesSubmitted,\n txHash,\n }),\n },\n revokeDelegation: {\n submittedEvent: (txHash: Hex) => ({ type: ZamaSDKEvents.RevokeDelegationSubmitted, txHash }),\n },\n setOperator: {\n submittedEvent: (txHash: Hex) => ({ type: ZamaSDKEvents.SetOperatorSubmitted, txHash }),\n },\n \"shield:transferAndCall\": {\n submittedEvent: (txHash: Hex) => ({\n type: ZamaSDKEvents.ShieldSubmitted,\n txHash,\n shieldPath: \"transferAndCall\" as const,\n }),\n },\n \"shield:approveAndWrap\": {\n submittedEvent: (txHash: Hex) => ({\n type: ZamaSDKEvents.ShieldSubmitted,\n txHash,\n shieldPath: \"approveAndWrap\" as const,\n }),\n },\n wrap: { submittedEvent: (txHash: Hex) => ({ type: ZamaSDKEvents.WrapSubmitted, txHash }) },\n transfer: {\n submittedEvent: (txHash: Hex) => ({ type: ZamaSDKEvents.TransferSubmitted, txHash }),\n },\n transferAndCall: {\n submittedEvent: (txHash: Hex) => ({ type: ZamaSDKEvents.TransferSubmitted, txHash }),\n },\n transferFrom: {\n submittedEvent: (txHash: Hex) => ({ type: ZamaSDKEvents.TransferFromSubmitted, txHash }),\n },\n transferFromAndCall: {\n submittedEvent: (txHash: Hex) => ({ type: ZamaSDKEvents.TransferFromSubmitted, txHash }),\n },\n unwrap: { submittedEvent: (txHash: Hex) => ({ type: ZamaSDKEvents.UnwrapSubmitted, txHash }) },\n unwrapAll: { submittedEvent: (txHash: Hex) => ({ type: ZamaSDKEvents.UnwrapSubmitted, txHash }) },\n} satisfies Record<TransactionOperation, { submittedEvent: (txHash: Hex) => ZamaSDKEventInput }>;\n","import { type Address, getAddress, isAddress, isHex, type Hex } from \"viem\";\nimport { z } from \"zod/mini\";\n\ndeclare const checksummedTag: unique symbol;\n\n/** An EVM address that has been put through `getAddress` (EIP-55 checksum form). */\nexport type ChecksummedAddress = Address & { readonly [checksummedTag]: true };\n\n/** Stamp the brand on an arbitrary `Address` after normalizing it. */\nexport function checksum(value: Address): ChecksummedAddress {\n return getAddress(value) as ChecksummedAddress;\n}\n\n/** `0x`-prefixed hex string. */\nexport const hex = z.custom<Hex>(\n (v) => typeof v === \"string\" && isHex(v, { strict: true }),\n \"expected 0x-prefixed hex string\",\n);\n\n/** Validates an EVM address string. Output type is `Address` (`` `0x${string}` ``). */\nexport const evmAddress = z.custom<Address>(\n (v) => typeof v === \"string\" && isAddress(v, { strict: false }),\n \"expected EVM address\",\n);\n\n/** Validates and EIP-55 checksums an EVM address. Output is {@link ChecksummedAddress}. */\nexport const checksummedAddress = z.pipe(evmAddress, z.transform(checksum));\n\n/** Non-negative integer Unix timestamp in seconds. */\nexport const unixSeconds = z.int().check(z.nonnegative());\n\n/** Positive integer count of seconds (e.g. a TTL). */\nexport const positiveSeconds = z.int().check(z.positive());\n\n/** Non-negative integer count of seconds (e.g. a cache TTL where 0 disables caching). */\nexport const nonNegativeSeconds = z.int().check(z.nonnegative());\n\n/** Positive integer count of days (e.g. a permit duration). */\nexport const positiveDays = z.int().check(z.positive());\n\n/** Positive integer EVM chain ID. */\nexport const chainId = z.int().check(z.positive());\n","import type { GenericLogger } from \"../types\";\n\n/**\n * Runs a function and swallows any errors.\n *\n * The swallowed error is a handled, best-effort failure — when a logger is\n * supplied it is routed to the {@link GenericLogger} at `warn`, never to the\n * console. Most SDK call sites pass the SDK-wide logger; a few (e.g. a signer\n * constructed before `createConfig` exists) genuinely have none, so the logger\n * is optional and the failure is then silent.\n */\nexport async function swallow(\n label: string,\n fn: () => Promise<void> | void,\n logger?: GenericLogger,\n): Promise<void> {\n try {\n await fn();\n } catch (error) {\n logger?.warn(`${label} failed`, { error });\n }\n}\n","import type { Address } from \"viem\";\nimport { type ChecksummedAddress, checksum } from \"../schemas/primitives\";\nexport { checksum, type ChecksummedAddress };\n\n/** Maximum number of contract addresses a single permit may bind, enforced by the FHE protocol. */\nexport const MAX_CONTRACTS_PER_PERMIT = 10;\n\n/**\n * Maximum `durationDays` a V1 permit accepts (`@fhevm/sdk`'s `MAX_USER_DECRYPT_DURATION_DAYS`).\n * The unsigned typed-data builder `preparePermit` uses does not enforce this itself — only the\n * atomic sign path does — so `preparePermit` checks it explicitly to fail before an\n * out-of-process signing ceremony instead of after.\n */\nexport const MAX_V1_PERMIT_DURATION_DAYS = 365;\n\nexport const SECONDS_PER_DAY = 86400;\n\n/**\n * Sentinel requesting a V2 permissive (\"wildcard\") permit from\n * {@link CredentialService.grantPermit} / {@link Permits.grantPermit} /\n * {@link Permits.grantDelegationPermit} — one permit covering every contract,\n * present and future, instead of an explicit list. Always an explicit opt-in:\n * passing a contract list, however large, never signs a wildcard permit.\n *\n * @example\n * ```ts\n * import { WILDCARD_PERMIT } from \"@zama-fhe/sdk\";\n *\n * await sdk.permits.grantPermit(WILDCARD_PERMIT);\n * ```\n */\nexport const WILDCARD_PERMIT = \"wildcard\" as const;\n\n/** The type of {@link WILDCARD_PERMIT}. */\nexport type WildcardPermit = typeof WILDCARD_PERMIT;\n\n/** Current Unix time in whole seconds. */\nexport function nowSeconds(): number {\n return Math.floor(Date.now() / 1000);\n}\n\n/** Deduplicate and sort a list of addresses by their checksummed form. */\nexport function normalizeAddresses(addresses: readonly Address[]): ChecksummedAddress[] {\n return [...new Set(addresses.map(checksum))].sort();\n}\n\n/**\n * Converts an EIP-712 domain's `chainId` from `bigint` to a decimal string, mirroring\n * `@fhevm/sdk`'s internal (unexported) `_toJsonSafeEip712`: its unsigned permit builders\n * return a `bigint` `domain.chainId`, which `JSON.stringify` cannot serialize, so a\n * `PreparedPermit` built from one is not JSON-safe as documented until normalized here.\n * `parseSignedDecryptionPermit` accepts the chainId back as a string or number\n * (`_normalizeSerializedPermitDomainChainId`), so the round-trip is lossless.\n */\nexport function toJsonSafeEip712<T extends { domain: Record<string, unknown> }>(eip712: T): T {\n const { chainId } = eip712.domain;\n if (typeof chainId !== \"bigint\") {\n return eip712;\n }\n return { ...eip712, domain: { ...eip712.domain, chainId: chainId.toString() } };\n}\n","// DO NOT EDIT: generated by `pnpm abi:build` from\n// contracts/out/ConfidentialWrapperV3.sol/ConfidentialWrapperV3.json.\n// Regenerate after `pnpm contracts:build`; `pnpm abi:check` enforces this in CI.\nexport const confidentialWrapperAbi = [\n {\n type: \"function\",\n name: \"UPGRADE_INTERFACE_VERSION\",\n inputs: [],\n outputs: [{ name: \"\", type: \"string\", internalType: \"string\" }],\n stateMutability: \"view\",\n },\n {\n type: \"function\",\n name: \"acceptOwnership\",\n inputs: [],\n outputs: [],\n stateMutability: \"nonpayable\",\n },\n {\n type: \"function\",\n name: \"blockUser\",\n inputs: [{ name: \"user\", type: \"address\", internalType: \"address\" }],\n outputs: [],\n stateMutability: \"nonpayable\",\n },\n {\n type: \"function\",\n name: \"confidentialBalanceOf\",\n inputs: [{ name: \"account\", type: \"address\", internalType: \"address\" }],\n outputs: [{ name: \"\", type: \"bytes32\", internalType: \"euint64\" }],\n stateMutability: \"view\",\n },\n {\n type: \"function\",\n name: \"confidentialProtocolId\",\n inputs: [],\n outputs: [{ name: \"\", type: \"uint256\", internalType: \"uint256\" }],\n stateMutability: \"view\",\n },\n {\n type: \"function\",\n name: \"confidentialTotalSupply\",\n inputs: [],\n outputs: [{ name: \"\", type: \"bytes32\", internalType: \"euint64\" }],\n stateMutability: \"view\",\n },\n {\n type: \"function\",\n name: \"confidentialTransfer\",\n inputs: [\n { name: \"to\", type: \"address\", internalType: \"address\" },\n { name: \"encryptedAmount\", type: \"bytes32\", internalType: \"externalEuint64\" },\n { name: \"inputProof\", type: \"bytes\", internalType: \"bytes\" },\n ],\n outputs: [{ name: \"\", type: \"bytes32\", internalType: \"euint64\" }],\n stateMutability: \"nonpayable\",\n },\n {\n type: \"function\",\n name: \"confidentialTransfer\",\n inputs: [\n { name: \"to\", type: \"address\", internalType: \"address\" },\n { name: \"amount\", type: \"bytes32\", internalType: \"euint64\" },\n ],\n outputs: [{ name: \"\", type: \"bytes32\", internalType: \"euint64\" }],\n stateMutability: \"nonpayable\",\n },\n {\n type: \"function\",\n name: \"confidentialTransferAndCall\",\n inputs: [\n { name: \"to\", type: \"address\", internalType: \"address\" },\n { name: \"amount\", type: \"bytes32\", internalType: \"euint64\" },\n { name: \"data\", type: \"bytes\", internalType: \"bytes\" },\n ],\n outputs: [{ name: \"transferred\", type: \"bytes32\", internalType: \"euint64\" }],\n stateMutability: \"nonpayable\",\n },\n {\n type: \"function\",\n name: \"confidentialTransferAndCall\",\n inputs: [\n { name: \"to\", type: \"address\", internalType: \"address\" },\n { name: \"encryptedAmount\", type: \"bytes32\", internalType: \"externalEuint64\" },\n { name: \"inputProof\", type: \"bytes\", internalType: \"bytes\" },\n { name: \"data\", type: \"bytes\", internalType: \"bytes\" },\n ],\n outputs: [{ name: \"transferred\", type: \"bytes32\", internalType: \"euint64\" }],\n stateMutability: \"nonpayable\",\n },\n {\n type: \"function\",\n name: \"confidentialTransferFrom\",\n inputs: [\n { name: \"from\", type: \"address\", internalType: \"address\" },\n { name: \"to\", type: \"address\", internalType: \"address\" },\n { name: \"encryptedAmount\", type: \"bytes32\", internalType: \"externalEuint64\" },\n { name: \"inputProof\", type: \"bytes\", internalType: \"bytes\" },\n ],\n outputs: [{ name: \"transferred\", type: \"bytes32\", internalType: \"euint64\" }],\n stateMutability: \"nonpayable\",\n },\n {\n type: \"function\",\n name: \"confidentialTransferFrom\",\n inputs: [\n { name: \"from\", type: \"address\", internalType: \"address\" },\n { name: \"to\", type: \"address\", internalType: \"address\" },\n { name: \"amount\", type: \"bytes32\", internalType: \"euint64\" },\n ],\n outputs: [{ name: \"transferred\", type: \"bytes32\", internalType: \"euint64\" }],\n stateMutability: \"nonpayable\",\n },\n {\n type: \"function\",\n name: \"confidentialTransferFromAndCall\",\n inputs: [\n { name: \"from\", type: \"address\", internalType: \"address\" },\n { name: \"to\", type: \"address\", internalType: \"address\" },\n { name: \"encryptedAmount\", type: \"bytes32\", internalType: \"externalEuint64\" },\n { name: \"inputProof\", type: \"bytes\", internalType: \"bytes\" },\n { name: \"data\", type: \"bytes\", internalType: \"bytes\" },\n ],\n outputs: [{ name: \"transferred\", type: \"bytes32\", internalType: \"euint64\" }],\n stateMutability: \"nonpayable\",\n },\n {\n type: \"function\",\n name: \"confidentialTransferFromAndCall\",\n inputs: [\n { name: \"from\", type: \"address\", internalType: \"address\" },\n { name: \"to\", type: \"address\", internalType: \"address\" },\n { name: \"amount\", type: \"bytes32\", internalType: \"euint64\" },\n { name: \"data\", type: \"bytes\", internalType: \"bytes\" },\n ],\n outputs: [{ name: \"transferred\", type: \"bytes32\", internalType: \"euint64\" }],\n stateMutability: \"nonpayable\",\n },\n {\n type: \"function\",\n name: \"contractURI\",\n inputs: [],\n outputs: [{ name: \"\", type: \"string\", internalType: \"string\" }],\n stateMutability: \"view\",\n },\n {\n type: \"function\",\n name: \"decimals\",\n inputs: [],\n outputs: [{ name: \"\", type: \"uint8\", internalType: \"uint8\" }],\n stateMutability: \"view\",\n },\n {\n type: \"function\",\n name: \"discloseEncryptedAmount\",\n inputs: [\n { name: \"encryptedAmount\", type: \"bytes32\", internalType: \"euint64\" },\n { name: \"cleartextAmount\", type: \"uint64\", internalType: \"uint64\" },\n { name: \"decryptionProof\", type: \"bytes\", internalType: \"bytes\" },\n ],\n outputs: [],\n stateMutability: \"nonpayable\",\n },\n {\n type: \"function\",\n name: \"finalizeUnwrap\",\n inputs: [\n { name: \"unwrapRequestId\", type: \"bytes32\", internalType: \"bytes32\" },\n { name: \"unwrapAmountCleartext\", type: \"uint64\", internalType: \"uint64\" },\n { name: \"decryptionProof\", type: \"bytes\", internalType: \"bytes\" },\n ],\n outputs: [],\n stateMutability: \"nonpayable\",\n },\n {\n type: \"function\",\n name: \"getUnderlyingDenyListSelector\",\n inputs: [],\n outputs: [\n { name: \"isSet\", type: \"bool\", internalType: \"bool\" },\n { name: \"selector\", type: \"bytes4\", internalType: \"bytes4\" },\n ],\n stateMutability: \"view\",\n },\n {\n type: \"function\",\n name: \"inferredTotalSupply\",\n inputs: [],\n outputs: [{ name: \"\", type: \"uint256\", internalType: \"uint256\" }],\n stateMutability: \"view\",\n },\n {\n type: \"function\",\n name: \"initialize\",\n inputs: [\n { name: \"name_\", type: \"string\", internalType: \"string\" },\n { name: \"symbol_\", type: \"string\", internalType: \"string\" },\n { name: \"contractURI_\", type: \"string\", internalType: \"string\" },\n { name: \"underlying_\", type: \"address\", internalType: \"contract IERC20\" },\n { name: \"owner_\", type: \"address\", internalType: \"address\" },\n ],\n outputs: [],\n stateMutability: \"nonpayable\",\n },\n {\n type: \"function\",\n name: \"isBlocked\",\n inputs: [{ name: \"user\", type: \"address\", internalType: \"address\" }],\n outputs: [{ name: \"\", type: \"bool\", internalType: \"bool\" }],\n stateMutability: \"view\",\n },\n {\n type: \"function\",\n name: \"isOperator\",\n inputs: [\n { name: \"holder\", type: \"address\", internalType: \"address\" },\n { name: \"spender\", type: \"address\", internalType: \"address\" },\n ],\n outputs: [{ name: \"\", type: \"bool\", internalType: \"bool\" }],\n stateMutability: \"view\",\n },\n {\n type: \"function\",\n name: \"maxTotalSupply\",\n inputs: [],\n outputs: [{ name: \"\", type: \"uint256\", internalType: \"uint256\" }],\n stateMutability: \"view\",\n },\n {\n type: \"function\",\n name: \"name\",\n inputs: [],\n outputs: [{ name: \"\", type: \"string\", internalType: \"string\" }],\n stateMutability: \"view\",\n },\n {\n type: \"function\",\n name: \"onTransferReceived\",\n inputs: [\n { name: \"operator\", type: \"address\", internalType: \"address\" },\n { name: \"from\", type: \"address\", internalType: \"address\" },\n { name: \"amount\", type: \"uint256\", internalType: \"uint256\" },\n { name: \"data\", type: \"bytes\", internalType: \"bytes\" },\n ],\n outputs: [{ name: \"\", type: \"bytes4\", internalType: \"bytes4\" }],\n stateMutability: \"nonpayable\",\n },\n {\n type: \"function\",\n name: \"owner\",\n inputs: [],\n outputs: [{ name: \"\", type: \"address\", internalType: \"address\" }],\n stateMutability: \"view\",\n },\n {\n type: \"function\",\n name: \"pendingOwner\",\n inputs: [],\n outputs: [{ name: \"\", type: \"address\", internalType: \"address\" }],\n stateMutability: \"view\",\n },\n {\n type: \"function\",\n name: \"proxiableUUID\",\n inputs: [],\n outputs: [{ name: \"\", type: \"bytes32\", internalType: \"bytes32\" }],\n stateMutability: \"view\",\n },\n {\n type: \"function\",\n name: \"rate\",\n inputs: [],\n outputs: [{ name: \"\", type: \"uint256\", internalType: \"uint256\" }],\n stateMutability: \"view\",\n },\n {\n type: \"function\",\n name: \"reinitializeV2\",\n inputs: [],\n outputs: [],\n stateMutability: \"nonpayable\",\n },\n {\n type: \"function\",\n name: \"reinitializeV3\",\n inputs: [\n { name: \"blockedUsers\", type: \"address[]\", internalType: \"address[]\" },\n { name: \"underlyingDenyListSelector\", type: \"bytes4\", internalType: \"bytes4\" },\n { name: \"hasUnderlyingDenyListSelector_\", type: \"bool\", internalType: \"bool\" },\n ],\n outputs: [],\n stateMutability: \"nonpayable\",\n },\n {\n type: \"function\",\n name: \"renounceOwnership\",\n inputs: [],\n outputs: [],\n stateMutability: \"nonpayable\",\n },\n {\n type: \"function\",\n name: \"requestDiscloseEncryptedAmount\",\n inputs: [{ name: \"encryptedAmount\", type: \"bytes32\", internalType: \"euint64\" }],\n outputs: [],\n stateMutability: \"nonpayable\",\n },\n {\n type: \"function\",\n name: \"setOperator\",\n inputs: [\n { name: \"operator\", type: \"address\", internalType: \"address\" },\n { name: \"until\", type: \"uint48\", internalType: \"uint48\" },\n ],\n outputs: [],\n stateMutability: \"nonpayable\",\n },\n {\n type: \"function\",\n name: \"supportsInterface\",\n inputs: [{ name: \"interfaceId\", type: \"bytes4\", internalType: \"bytes4\" }],\n outputs: [{ name: \"\", type: \"bool\", internalType: \"bool\" }],\n stateMutability: \"view\",\n },\n {\n type: \"function\",\n name: \"symbol\",\n inputs: [],\n outputs: [{ name: \"\", type: \"string\", internalType: \"string\" }],\n stateMutability: \"view\",\n },\n {\n type: \"function\",\n name: \"transferOwnership\",\n inputs: [{ name: \"newOwner\", type: \"address\", internalType: \"address\" }],\n outputs: [],\n stateMutability: \"nonpayable\",\n },\n {\n type: \"function\",\n name: \"unblockUser\",\n inputs: [{ name: \"user\", type: \"address\", internalType: \"address\" }],\n outputs: [],\n stateMutability: \"nonpayable\",\n },\n {\n type: \"function\",\n name: \"underlying\",\n inputs: [],\n outputs: [{ name: \"\", type: \"address\", internalType: \"address\" }],\n stateMutability: \"view\",\n },\n {\n type: \"function\",\n name: \"unwrap\",\n inputs: [\n { name: \"from\", type: \"address\", internalType: \"address\" },\n { name: \"to\", type: \"address\", internalType: \"address\" },\n { name: \"encryptedAmount\", type: \"bytes32\", internalType: \"externalEuint64\" },\n { name: \"inputProof\", type: \"bytes\", internalType: \"bytes\" },\n ],\n outputs: [{ name: \"\", type: \"bytes32\", internalType: \"bytes32\" }],\n stateMutability: \"nonpayable\",\n },\n {\n type: \"function\",\n name: \"unwrap\",\n inputs: [\n { name: \"from\", type: \"address\", internalType: \"address\" },\n { name: \"to\", type: \"address\", internalType: \"address\" },\n { name: \"amount\", type: \"bytes32\", internalType: \"euint64\" },\n ],\n outputs: [{ name: \"\", type: \"bytes32\", internalType: \"bytes32\" }],\n stateMutability: \"nonpayable\",\n },\n {\n type: \"function\",\n name: \"unwrapAmount\",\n inputs: [{ name: \"unwrapRequestId\", type: \"bytes32\", internalType: \"bytes32\" }],\n outputs: [{ name: \"\", type: \"bytes32\", internalType: \"euint64\" }],\n stateMutability: \"view\",\n },\n {\n type: \"function\",\n name: \"unwrapRequester\",\n inputs: [{ name: \"unwrapRequestId\", type: \"bytes32\", internalType: \"bytes32\" }],\n outputs: [{ name: \"\", type: \"address\", internalType: \"address\" }],\n stateMutability: \"view\",\n },\n {\n type: \"function\",\n name: \"upgradeToAndCall\",\n inputs: [\n { name: \"newImplementation\", type: \"address\", internalType: \"address\" },\n { name: \"data\", type: \"bytes\", internalType: \"bytes\" },\n ],\n outputs: [],\n stateMutability: \"payable\",\n },\n {\n type: \"function\",\n name: \"wrap\",\n inputs: [\n { name: \"to\", type: \"address\", internalType: \"address\" },\n { name: \"amount\", type: \"uint256\", internalType: \"uint256\" },\n ],\n outputs: [{ name: \"\", type: \"bytes32\", internalType: \"euint64\" }],\n stateMutability: \"nonpayable\",\n },\n {\n type: \"event\",\n name: \"AmountDiscloseRequested\",\n inputs: [\n { name: \"encryptedAmount\", type: \"bytes32\", indexed: true, internalType: \"euint64\" },\n { name: \"requester\", type: \"address\", indexed: true, internalType: \"address\" },\n ],\n anonymous: false,\n },\n {\n type: \"event\",\n name: \"AmountDisclosed\",\n inputs: [\n { name: \"encryptedAmount\", type: \"bytes32\", indexed: true, internalType: \"euint64\" },\n { name: \"amount\", type: \"uint64\", indexed: false, internalType: \"uint64\" },\n ],\n anonymous: false,\n },\n {\n type: \"event\",\n name: \"ConfidentialTransfer\",\n inputs: [\n { name: \"from\", type: \"address\", indexed: true, internalType: \"address\" },\n { name: \"to\", type: \"address\", indexed: true, internalType: \"address\" },\n { name: \"amount\", type: \"bytes32\", indexed: true, internalType: \"euint64\" },\n ],\n anonymous: false,\n },\n {\n type: \"event\",\n name: \"Initialized\",\n inputs: [{ name: \"version\", type: \"uint64\", indexed: false, internalType: \"uint64\" }],\n anonymous: false,\n },\n {\n type: \"event\",\n name: \"OperatorSet\",\n inputs: [\n { name: \"holder\", type: \"address\", indexed: true, internalType: \"address\" },\n { name: \"operator\", type: \"address\", indexed: true, internalType: \"address\" },\n { name: \"until\", type: \"uint48\", indexed: false, internalType: \"uint48\" },\n ],\n anonymous: false,\n },\n {\n type: \"event\",\n name: \"OwnershipTransferStarted\",\n inputs: [\n { name: \"previousOwner\", type: \"address\", indexed: true, internalType: \"address\" },\n { name: \"newOwner\", type: \"address\", indexed: true, internalType: \"address\" },\n ],\n anonymous: false,\n },\n {\n type: \"event\",\n name: \"OwnershipTransferred\",\n inputs: [\n { name: \"previousOwner\", type: \"address\", indexed: true, internalType: \"address\" },\n { name: \"newOwner\", type: \"address\", indexed: true, internalType: \"address\" },\n ],\n anonymous: false,\n },\n {\n type: \"event\",\n name: \"PublicDecryptionVerified\",\n inputs: [\n { name: \"handlesList\", type: \"bytes32[]\", indexed: false, internalType: \"bytes32[]\" },\n { name: \"abiEncodedCleartexts\", type: \"bytes\", indexed: false, internalType: \"bytes\" },\n ],\n anonymous: false,\n },\n {\n type: \"event\",\n name: \"UnwrapFinalized\",\n inputs: [\n { name: \"receiver\", type: \"address\", indexed: true, internalType: \"address\" },\n { name: \"unwrapRequestId\", type: \"bytes32\", indexed: true, internalType: \"bytes32\" },\n { name: \"encryptedAmount\", type: \"bytes32\", indexed: false, internalType: \"euint64\" },\n { name: \"cleartextAmount\", type: \"uint64\", indexed: false, internalType: \"uint64\" },\n ],\n anonymous: false,\n },\n {\n type: \"event\",\n name: \"UnwrapRequested\",\n inputs: [\n { name: \"receiver\", type: \"address\", indexed: true, internalType: \"address\" },\n { name: \"unwrapRequestId\", type: \"bytes32\", indexed: true, internalType: \"bytes32\" },\n { name: \"amount\", type: \"bytes32\", indexed: false, internalType: \"euint64\" },\n ],\n anonymous: false,\n },\n {\n type: \"event\",\n name: \"Upgraded\",\n inputs: [{ name: \"implementation\", type: \"address\", indexed: true, internalType: \"address\" }],\n anonymous: false,\n },\n {\n type: \"event\",\n name: \"UserBlocked\",\n inputs: [{ name: \"user\", type: \"address\", indexed: true, internalType: \"address\" }],\n anonymous: false,\n },\n {\n type: \"event\",\n name: \"UserUnblocked\",\n inputs: [{ name: \"user\", type: \"address\", indexed: true, internalType: \"address\" }],\n anonymous: false,\n },\n {\n type: \"event\",\n name: \"Wrap\",\n inputs: [\n { name: \"to\", type: \"address\", indexed: true, internalType: \"address\" },\n { name: \"roundedAmount\", type: \"uint256\", indexed: false, internalType: \"uint256\" },\n { name: \"encryptedWrappedAmount\", type: \"bytes32\", indexed: false, internalType: \"euint64\" },\n ],\n anonymous: false,\n },\n {\n type: \"error\",\n name: \"AddressEmptyCode\",\n inputs: [{ name: \"target\", type: \"address\", internalType: \"address\" }],\n },\n {\n type: \"error\",\n name: \"BlockedUser\",\n inputs: [{ name: \"user\", type: \"address\", internalType: \"address\" }],\n },\n {\n type: \"error\",\n name: \"ERC1967InvalidImplementation\",\n inputs: [{ name: \"implementation\", type: \"address\", internalType: \"address\" }],\n },\n { type: \"error\", name: \"ERC1967NonPayable\", inputs: [] },\n {\n type: \"error\",\n name: \"ERC7984InvalidReceiver\",\n inputs: [{ name: \"receiver\", type: \"address\", internalType: \"address\" }],\n },\n {\n type: \"error\",\n name: \"ERC7984InvalidReceiver\",\n inputs: [{ name: \"receiver\", type: \"address\", internalType: \"address\" }],\n },\n {\n type: \"error\",\n name: \"ERC7984InvalidSender\",\n inputs: [{ name: \"sender\", type: \"address\", internalType: \"address\" }],\n },\n { type: \"error\", name: \"ERC7984TotalSupplyOverflow\", inputs: [] },\n {\n type: \"error\",\n name: \"ERC7984UnauthorizedCaller\",\n inputs: [{ name: \"caller\", type: \"address\", internalType: \"address\" }],\n },\n {\n type: \"error\",\n name: \"ERC7984UnauthorizedSpender\",\n inputs: [\n { name: \"holder\", type: \"address\", internalType: \"address\" },\n { name: \"spender\", type: \"address\", internalType: \"address\" },\n ],\n },\n {\n type: \"error\",\n name: \"ERC7984UnauthorizedUseOfEncryptedAmount\",\n inputs: [\n { name: \"amount\", type: \"bytes32\", internalType: \"euint64\" },\n { name: \"user\", type: \"address\", internalType: \"address\" },\n ],\n },\n {\n type: \"error\",\n name: \"ERC7984ZeroBalance\",\n inputs: [{ name: \"holder\", type: \"address\", internalType: \"address\" }],\n },\n { type: \"error\", name: \"FailedCall\", inputs: [] },\n { type: \"error\", name: \"InvalidInitialization\", inputs: [] },\n { type: \"error\", name: \"InvalidKMSSignatures\", inputs: [] },\n { type: \"error\", name: \"InvalidUnderlyingDenyListResponse\", inputs: [] },\n {\n type: \"error\",\n name: \"InvalidUnwrapRequest\",\n inputs: [{ name: \"unwrapRequestId\", type: \"bytes32\", internalType: \"bytes32\" }],\n },\n { type: \"error\", name: \"NotInitializing\", inputs: [] },\n {\n type: \"error\",\n name: \"OwnableInvalidOwner\",\n inputs: [{ name: \"owner\", type: \"address\", internalType: \"address\" }],\n },\n {\n type: \"error\",\n name: \"OwnableUnauthorizedAccount\",\n inputs: [{ name: \"account\", type: \"address\", internalType: \"address\" }],\n },\n {\n type: \"error\",\n name: \"SafeCastOverflowedUintDowncast\",\n inputs: [\n { name: \"bits\", type: \"uint8\", internalType: \"uint8\" },\n { name: \"value\", type: \"uint256\", internalType: \"uint256\" },\n ],\n },\n {\n type: \"error\",\n name: \"SafeERC20FailedOperation\",\n inputs: [{ name: \"token\", type: \"address\", internalType: \"address\" }],\n },\n {\n type: \"error\",\n name: \"SenderNotAllowedToUseHandle\",\n inputs: [\n { name: \"handle\", type: \"bytes32\", internalType: \"bytes32\" },\n { name: \"sender\", type: \"address\", internalType: \"address\" },\n ],\n },\n { type: \"error\", name: \"UUPSUnauthorizedCallContext\", inputs: [] },\n {\n type: \"error\",\n name: \"UUPSUnsupportedProxiableUUID\",\n inputs: [{ name: \"slot\", type: \"bytes32\", internalType: \"bytes32\" }],\n },\n { type: \"error\", name: \"UnderlyingDenyListCallFailed\", inputs: [] },\n {\n type: \"error\",\n name: \"UnderlyingDenyListedAddress\",\n inputs: [{ name: \"user\", type: \"address\", internalType: \"address\" }],\n },\n {\n type: \"error\",\n name: \"UserAlreadyBlocked\",\n inputs: [{ name: \"user\", type: \"address\", internalType: \"address\" }],\n },\n {\n type: \"error\",\n name: \"UserAlreadyUnblocked\",\n inputs: [{ name: \"user\", type: \"address\", internalType: \"address\" }],\n },\n { type: \"error\", name: \"ZamaProtocolUnsupported\", inputs: [] },\n] as const;\n","import type { Address, Hex } from \"viem\";\nimport { confidentialWrapperAbi } from \"../abi/confidential-wrapper.abi\";\nimport type { EncryptedValue } from \"../relayer/types\";\n\n/**\n * Returns the contract config to read an encrypted balance.\n *\n * @example\n * ```ts\n * const handle = await provider.readContract(\n * confidentialBalanceOfContract(tokenAddress, userAddress),\n * );\n * ```\n */\nexport function confidentialBalanceOfContract(tokenAddress: Address, userAddress: Address) {\n return {\n address: tokenAddress,\n abi: confidentialWrapperAbi,\n functionName: \"confidentialBalanceOf\",\n args: [userAddress],\n } as const;\n}\n\n/**\n * Returns the contract config for a confidential transfer.\n *\n * @example\n * ```ts\n * const txHash = await signer.writeContract(\n * confidentialTransferContract(tokenAddress, to, encryptedValues[0], inputProof),\n * );\n * ```\n */\nexport function confidentialTransferContract(\n encryptedErc20: Address,\n to: Address,\n encryptedAmount: EncryptedValue,\n inputProof: Hex,\n) {\n return {\n address: encryptedErc20,\n abi: confidentialWrapperAbi,\n functionName: \"confidentialTransfer\",\n args: [to, encryptedAmount, inputProof],\n } as const;\n}\n\n/**\n * Returns the contract config for a confidential transferFrom.\n *\n * @example\n * ```ts\n * const txHash = await signer.writeContract(\n * confidentialTransferFromContract(tokenAddress, from, to, encryptedValues[0], inputProof),\n * );\n * ```\n */\nexport function confidentialTransferFromContract(\n encryptedErc20: Address,\n from: Address,\n to: Address,\n encryptedAmount: EncryptedValue,\n inputProof: Hex,\n) {\n return {\n address: encryptedErc20,\n abi: confidentialWrapperAbi,\n functionName: \"confidentialTransferFrom\",\n args: [from, to, encryptedAmount, inputProof],\n } as const;\n}\n\n/**\n * Returns the contract config for a confidential transferAndCall. The caller\n * supplies an opaque `data` payload that is forwarded to the recipient's\n * ERC-7984 receiver hook (`onConfidentialTransferReceived`). The SDK does not\n * craft, validate, or inspect `data` — encoding the call site's domain message\n * is the caller's responsibility.\n *\n * @example\n * ```ts\n * const txHash = await signer.writeContract(\n * confidentialTransferAndCallContract(\n * tokenAddress,\n * to,\n * encryptedValues[0],\n * inputProof,\n * data,\n * ),\n * );\n * ```\n */\nexport function confidentialTransferAndCallContract(\n encryptedErc20: Address,\n to: Address,\n encryptedAmount: EncryptedValue,\n inputProof: Hex,\n data: Hex,\n) {\n return {\n address: encryptedErc20,\n abi: confidentialWrapperAbi,\n functionName: \"confidentialTransferAndCall\",\n args: [to, encryptedAmount, inputProof, data],\n } as const;\n}\n\n/**\n * Returns the contract config for a confidential transferFromAndCall. The\n * caller supplies an opaque `data` payload forwarded to the recipient's\n * ERC-7984 receiver hook; the SDK does not craft or inspect it.\n *\n * @example\n * ```ts\n * const txHash = await signer.writeContract(\n * confidentialTransferFromAndCallContract(\n * tokenAddress,\n * from,\n * to,\n * encryptedValues[0],\n * inputProof,\n * data,\n * ),\n * );\n * ```\n */\nexport function confidentialTransferFromAndCallContract(\n encryptedErc20: Address,\n from: Address,\n to: Address,\n encryptedAmount: EncryptedValue,\n inputProof: Hex,\n data: Hex,\n) {\n return {\n address: encryptedErc20,\n abi: confidentialWrapperAbi,\n functionName: \"confidentialTransferFromAndCall\",\n args: [from, to, encryptedAmount, inputProof, data],\n } as const;\n}\n\n/**\n * Returns the contract config for checking operator status.\n *\n * @example\n * ```ts\n * const isOperator = await provider.readContract(\n * isOperatorContract(tokenAddress, holder, spender),\n * );\n * ```\n */\nexport function isOperatorContract(tokenAddress: Address, holder: Address, spender: Address) {\n return {\n address: tokenAddress,\n abi: confidentialWrapperAbi,\n functionName: \"isOperator\",\n args: [holder, spender],\n } as const;\n}\n\n/**\n * Returns the contract config for setting an operator.\n * Defaults until to 1 hour from now.\n *\n * @example\n * ```ts\n * const txHash = await signer.writeContract(\n * setOperatorContract(tokenAddress, operator),\n * );\n * ```\n */\nexport function setOperatorContract(tokenAddress: Address, operator: Address, until?: number) {\n const effectiveUntil = until ?? Math.floor(Date.now() / 1000) + 3600;\n return {\n address: tokenAddress,\n abi: confidentialWrapperAbi,\n functionName: \"setOperator\",\n args: [operator, effectiveUntil],\n } as const;\n}\n\n/**\n * Returns the contract config for an unwrap with newly encrypted amount.\n *\n * @example\n * ```ts\n * const txHash = await signer.writeContract(\n * unwrapContract(encryptedErc20, from, to, encryptedValues[0], inputProof),\n * );\n * ```\n */\nexport function unwrapContract(\n encryptedErc20: Address,\n from: Address,\n to: Address,\n encryptedAmount: EncryptedValue,\n inputProof: Hex,\n) {\n return {\n address: encryptedErc20,\n abi: confidentialWrapperAbi,\n functionName: \"unwrap\",\n args: [from, to, encryptedAmount, inputProof],\n } as const;\n}\n\n/**\n * Returns the contract config for an unwrap with an existing balance handle.\n *\n * @example\n * ```ts\n * const txHash = await signer.writeContract(\n * unwrapFromBalanceContract(encryptedErc20, from, to, encryptedBalance),\n * );\n * ```\n */\nexport function unwrapFromBalanceContract(\n encryptedErc20: Address,\n from: Address,\n to: Address,\n encryptedBalance: EncryptedValue,\n) {\n return {\n address: encryptedErc20,\n abi: confidentialWrapperAbi,\n functionName: \"unwrap\",\n args: [from, to, encryptedBalance],\n } as const;\n}\n\n/**\n * Returns the contract config to read the confidential (encrypted) total supply.\n *\n * @example\n * ```ts\n * const handle = await provider.readContract(\n * confidentialTotalSupplyContract(tokenAddress),\n * );\n * ```\n */\nexport function confidentialTotalSupplyContract(tokenAddress: Address) {\n return {\n address: tokenAddress,\n abi: confidentialWrapperAbi,\n functionName: \"confidentialTotalSupply\",\n args: [],\n } as const;\n}\n\n/**\n * Returns the contract config to read the wrap/unwrap conversion rate.\n *\n * @example\n * ```ts\n * const rate = await provider.readContract(rateContract(tokenAddress));\n * ```\n */\nexport function rateContract(tokenAddress: Address) {\n return {\n address: tokenAddress,\n abi: confidentialWrapperAbi,\n functionName: \"rate\",\n args: [],\n } as const;\n}\n\n/**\n * Returns the contract config for finalizing an unwrap.\n *\n * @example\n * ```ts\n * const txHash = await signer.writeContract(\n * finalizeUnwrapContract(wrapper, unwrapRequestId, cleartext, proof),\n * );\n * ```\n */\nexport function finalizeUnwrapContract(\n wrapper: Address,\n unwrapRequestId: EncryptedValue,\n unwrapAmountCleartext: bigint,\n decryptionProof: Hex,\n) {\n return {\n address: wrapper,\n abi: confidentialWrapperAbi,\n functionName: \"finalizeUnwrap\",\n args: [unwrapRequestId, unwrapAmountCleartext, decryptionProof],\n } as const;\n}\n\n/**\n * Returns the contract config to read the requester of an open unwrap request.\n * The wrapper deletes the request on finalize, so the zero address means the\n * request no longer exists.\n *\n * @example\n * ```ts\n * const requester = await provider.readContract(\n * unwrapRequesterContract(wrapperAddress, unwrapRequestId),\n * );\n * ```\n */\nexport function unwrapRequesterContract(wrapperAddress: Address, unwrapRequestId: EncryptedValue) {\n return {\n address: wrapperAddress,\n abi: confidentialWrapperAbi,\n functionName: \"unwrapRequester\",\n args: [unwrapRequestId],\n } as const;\n}\n\n/**\n * Returns the contract config to read the underlying ERC-20 token of a wrapper.\n *\n * @example\n * ```ts\n * const token = await provider.readContract(underlyingContract(wrapperAddress));\n * ```\n */\nexport function underlyingContract(wrapperAddress: Address) {\n return {\n address: wrapperAddress,\n abi: confidentialWrapperAbi,\n functionName: \"underlying\",\n args: [],\n } as const;\n}\n\n/**\n * Returns the contract config to read the inferred plaintext total supply.\n *\n * @example\n * ```ts\n * const supply = await provider.readContract(\n * inferredTotalSupplyContract(wrapperAddress),\n * );\n * ```\n */\nexport function inferredTotalSupplyContract(wrapperAddress: Address) {\n return {\n address: wrapperAddress,\n abi: confidentialWrapperAbi,\n functionName: \"inferredTotalSupply\",\n args: [],\n } as const;\n}\n\n/**\n * Returns the contract config for a wrap (shield) operation.\n *\n * @example\n * ```ts\n * const txHash = await signer.writeContract(\n * wrapContract(wrapperAddress, to, amount),\n * );\n * ```\n */\nexport function wrapContract(wrapperAddress: Address, to: Address, amount: bigint) {\n return {\n address: wrapperAddress,\n abi: confidentialWrapperAbi,\n functionName: \"wrap\",\n args: [to, amount],\n } as const;\n}\n","import { erc20Abi, type Address } from \"viem\";\n\n/**\n * Returns the contract config to read a token's name.\n *\n * @example\n * ```ts\n * const name = await provider.readContract(nameContract(tokenAddress));\n * ```\n */\nexport function nameContract(tokenAddress: Address) {\n return { address: tokenAddress, abi: erc20Abi, functionName: \"name\", args: [] } as const;\n}\n\n/**\n * Returns the contract config to read a token's symbol.\n *\n * @example\n * ```ts\n * const symbol = await provider.readContract(symbolContract(tokenAddress));\n * ```\n */\nexport function symbolContract(tokenAddress: Address) {\n return { address: tokenAddress, abi: erc20Abi, functionName: \"symbol\", args: [] } as const;\n}\n\n/**\n * Returns the contract config to read a token's decimals.\n *\n * @example\n * ```ts\n * const decimals = await provider.readContract(decimalsContract(tokenAddress));\n * ```\n */\nexport function decimalsContract(tokenAddress: Address) {\n return { address: tokenAddress, abi: erc20Abi, functionName: \"decimals\", args: [] } as const;\n}\n\n/**\n * Returns the contract config to read an ERC-20 token's total supply.\n *\n * @example\n * ```ts\n * const supply = await provider.readContract(erc20TotalSupplyContract(tokenAddress));\n * ```\n */\nexport function erc20TotalSupplyContract(tokenAddress: Address) {\n return { address: tokenAddress, abi: erc20Abi, functionName: \"totalSupply\", args: [] } as const;\n}\n\n/**\n * Returns the contract config to read an ERC-20 balance.\n *\n * @example\n * ```ts\n * const balance = await provider.readContract(\n * balanceOfContract(tokenAddress, account),\n * );\n * ```\n */\nexport function balanceOfContract(tokenAddress: Address, account: Address) {\n return {\n address: tokenAddress,\n abi: erc20Abi,\n functionName: \"balanceOf\",\n args: [account],\n } as const;\n}\n\n/**\n * Returns the contract config to read an ERC-20 allowance.\n *\n * @example\n * ```ts\n * const allowance = await provider.readContract(\n * allowanceContract(tokenAddress, owner, spender),\n * );\n * ```\n */\nexport function allowanceContract(tokenAddress: Address, owner: Address, spender: Address) {\n return {\n address: tokenAddress,\n abi: erc20Abi,\n functionName: \"allowance\",\n args: [owner, spender],\n } as const;\n}\n\n/**\n * Returns the contract config for an ERC-20 approve.\n *\n * @example\n * ```ts\n * const txHash = await signer.writeContract(\n * approveContract(tokenAddress, spender, amount),\n * );\n * ```\n */\nexport function approveContract(tokenAddress: Address, spender: Address, value: bigint) {\n return {\n address: tokenAddress,\n abi: erc20Abi,\n functionName: \"approve\",\n args: [spender, value],\n } as const;\n}\n","// DO NOT EDIT: generated by `pnpm abi:build` from\n// contracts/out/IERC165.sol/IERC165.json.\n// Regenerate after `pnpm contracts:build`; `pnpm abi:check` enforces this in CI.\nexport const erc165Abi = [\n {\n type: \"function\",\n name: \"supportsInterface\",\n inputs: [{ name: \"interfaceId\", type: \"bytes4\", internalType: \"bytes4\" }],\n outputs: [{ name: \"\", type: \"bool\", internalType: \"bool\" }],\n stateMutability: \"view\",\n },\n] as const;\n","import type { Address } from \"viem\";\nimport { erc165Abi } from \"../abi/erc165.abi\";\n\n/** ERC-165 interface ID for IERC7984 (confidential fungible token). */\nexport const ERC7984_INTERFACE_ID = \"0x4958f2a4\" as const;\n\n/** ERC-165 interface ID for IERC7984ERC20Wrapper (confidential wrapper). */\nexport const ERC7984_WRAPPER_INTERFACE_ID = \"0x1f1c62b2\" as const;\n\n/** ERC-165 interface ID for ERC-1363 (payable token — `transferAndCall`). */\nexport const ERC1363_INTERFACE_ID = \"0xb0202a11\" as const;\n\n/**\n * Returns the contract config for an ERC-165 `supportsInterface` check.\n *\n * Use with {@link ERC7984_INTERFACE_ID} to detect confidential tokens,\n * or {@link ERC7984_WRAPPER_INTERFACE_ID} to detect wrappers.\n *\n * @example\n * ```ts\n * const isConfidential = await provider.readContract(\n * supportsInterfaceContract(tokenAddress, ERC7984_INTERFACE_ID),\n * );\n * ```\n */\nexport function supportsInterfaceContract(tokenAddress: Address, interfaceId: Address) {\n return {\n address: tokenAddress,\n abi: erc165Abi,\n functionName: \"supportsInterface\",\n args: [interfaceId],\n } as const;\n}\n\n/**\n * Returns contract config to check if a token implements IERC7984 (confidential fungible token).\n *\n * @example\n * ```ts\n * const isConfidential = await provider.readContract(\n * isConfidentialTokenContract(\"0xTokenAddress\"),\n * );\n * ```\n */\nexport function isConfidentialTokenContract(tokenAddress: Address) {\n return supportsInterfaceContract(tokenAddress, ERC7984_INTERFACE_ID);\n}\n\n/**\n * Returns contract config to check if a token implements IERC7984ERC20Wrapper (confidential wrapper).\n *\n * @example\n * ```ts\n * const isWrapper = await provider.readContract(\n * isConfidentialWrapperContract(\"0xWrapperAddress\"),\n * );\n * ```\n */\nexport function isConfidentialWrapperContract(tokenAddress: Address) {\n return supportsInterfaceContract(tokenAddress, ERC7984_WRAPPER_INTERFACE_ID);\n}\n\n/**\n * Returns contract config to check if a token implements ERC-1363 (payable token).\n *\n * @example\n * ```ts\n * const isPayable = await provider.readContract(\n * isPayableTokenContract(\"0xTokenAddress\"),\n * );\n * ```\n */\nexport function isPayableTokenContract(tokenAddress: Address) {\n return supportsInterfaceContract(tokenAddress, ERC1363_INTERFACE_ID);\n}\n","import type { Address } from \"viem\";\n\nexport const wrappersRegistryAbi = [\n {\n inputs: [],\n name: \"getTokenConfidentialTokenPairs\",\n outputs: [\n {\n components: [\n { internalType: \"address\", name: \"tokenAddress\", type: \"address\" },\n { internalType: \"address\", name: \"confidentialTokenAddress\", type: \"address\" },\n { internalType: \"bool\", name: \"isValid\", type: \"bool\" },\n ],\n internalType: \"struct ConfidentialTokenWrappersRegistry.TokenWrapperPair[]\",\n name: \"\",\n type: \"tuple[]\",\n },\n ],\n stateMutability: \"view\",\n type: \"function\",\n },\n {\n inputs: [],\n name: \"getTokenConfidentialTokenPairsLength\",\n outputs: [{ internalType: \"uint256\", name: \"\", type: \"uint256\" }],\n stateMutability: \"view\",\n type: \"function\",\n },\n {\n inputs: [\n { internalType: \"uint256\", name: \"fromIndex\", type: \"uint256\" },\n { internalType: \"uint256\", name: \"toIndex\", type: \"uint256\" },\n ],\n name: \"getTokenConfidentialTokenPairsSlice\",\n outputs: [\n {\n components: [\n { internalType: \"address\", name: \"tokenAddress\", type: \"address\" },\n { internalType: \"address\", name: \"confidentialTokenAddress\", type: \"address\" },\n { internalType: \"bool\", name: \"isValid\", type: \"bool\" },\n ],\n internalType: \"struct ConfidentialTokenWrappersRegistry.TokenWrapperPair[]\",\n name: \"\",\n type: \"tuple[]\",\n },\n ],\n stateMutability: \"view\",\n type: \"function\",\n },\n {\n inputs: [{ internalType: \"uint256\", name: \"index\", type: \"uint256\" }],\n name: \"getTokenConfidentialTokenPair\",\n outputs: [\n {\n components: [\n { internalType: \"address\", name: \"tokenAddress\", type: \"address\" },\n { internalType: \"address\", name: \"confidentialTokenAddress\", type: \"address\" },\n { internalType: \"bool\", name: \"isValid\", type: \"bool\" },\n ],\n internalType: \"struct ConfidentialTokenWrappersRegistry.TokenWrapperPair\",\n name: \"\",\n type: \"tuple\",\n },\n ],\n stateMutability: \"view\",\n type: \"function\",\n },\n {\n inputs: [{ internalType: \"address\", name: \"tokenAddress\", type: \"address\" }],\n name: \"getConfidentialTokenAddress\",\n outputs: [\n { internalType: \"bool\", name: \"\", type: \"bool\" },\n { internalType: \"address\", name: \"\", type: \"address\" },\n ],\n stateMutability: \"view\",\n type: \"function\",\n },\n {\n inputs: [{ internalType: \"address\", name: \"confidentialTokenAddress\", type: \"address\" }],\n name: \"getTokenAddress\",\n outputs: [\n { internalType: \"bool\", name: \"\", type: \"bool\" },\n { internalType: \"address\", name: \"\", type: \"address\" },\n ],\n stateMutability: \"view\",\n type: \"function\",\n },\n {\n inputs: [{ internalType: \"address\", name: \"confidentialTokenAddress\", type: \"address\" }],\n name: \"isConfidentialTokenValid\",\n outputs: [{ internalType: \"bool\", name: \"\", type: \"bool\" }],\n stateMutability: \"view\",\n type: \"function\",\n },\n {\n inputs: [{ internalType: \"address\", name: \"initialOwner\", type: \"address\" }],\n name: \"initialize\",\n outputs: [],\n stateMutability: \"nonpayable\",\n type: \"function\",\n },\n {\n inputs: [\n { internalType: \"address\", name: \"tokenAddress\", type: \"address\" },\n { internalType: \"address\", name: \"confidentialTokenAddress\", type: \"address\" },\n ],\n name: \"registerConfidentialToken\",\n outputs: [],\n stateMutability: \"nonpayable\",\n type: \"function\",\n },\n {\n inputs: [{ internalType: \"address\", name: \"confidentialTokenAddress\", type: \"address\" }],\n name: \"revokeConfidentialToken\",\n outputs: [],\n stateMutability: \"nonpayable\",\n type: \"function\",\n },\n] as const;\n\n/** A registered plain-token / confidential-token pairing from the wrappers registry. */\nexport interface TokenWrapperPair {\n /** Address of the underlying public ERC-20 token. */\n readonly tokenAddress: Address;\n /** Address of the paired confidential (ERC-7984) token. */\n readonly confidentialTokenAddress: Address;\n /** Whether the pairing is currently valid (registered and not revoked). */\n readonly isValid: boolean;\n}\n\n/** Extended pair with on-chain metadata for both tokens. */\nexport interface TokenWrapperPairWithMetadata extends TokenWrapperPair {\n /** On-chain metadata of the underlying public ERC-20 token. */\n readonly underlying: {\n readonly name: string;\n readonly symbol: string;\n readonly decimals: number;\n readonly totalSupply: bigint;\n };\n /** On-chain metadata of the confidential token. */\n readonly confidential: {\n readonly name: string;\n readonly symbol: string;\n readonly decimals: number;\n };\n}\n\n/** Paginated result set modeled after standard API pagination. */\nexport interface PaginatedResult<T> {\n /** Items on the current page. */\n readonly items: readonly T[];\n /** Total number of items across all pages. */\n readonly total: number;\n /** One-based index of the current page. */\n readonly page: number;\n /** Maximum number of items per page. */\n readonly pageSize: number;\n}\n\n/**\n * Returns the contract config to fetch all token wrapper pairs.\n *\n * @example\n * ```ts\n * const pairs = await client.readContract(\n * getTokenPairsContract(registryAddress),\n * );\n * ```\n */\nexport function getTokenPairsContract(registry: Address) {\n return {\n address: registry,\n abi: wrappersRegistryAbi,\n functionName: \"getTokenConfidentialTokenPairs\",\n args: [],\n } as const;\n}\n\n/**\n * Returns the contract config to get the number of token wrapper pairs.\n *\n * @example\n * ```ts\n * const length = await client.readContract(\n * getTokenPairsLengthContract(registryAddress),\n * );\n * ```\n */\nexport function getTokenPairsLengthContract(registry: Address) {\n return {\n address: registry,\n abi: wrappersRegistryAbi,\n functionName: \"getTokenConfidentialTokenPairsLength\",\n args: [],\n } as const;\n}\n\n/**\n * Returns the contract config to fetch a slice of token wrapper pairs.\n *\n * @example\n * ```ts\n * const pairs = await client.readContract(\n * getTokenPairsSliceContract(registryAddress, 0n, 10n),\n * );\n * ```\n */\nexport function getTokenPairsSliceContract(registry: Address, fromIndex: bigint, toIndex: bigint) {\n return {\n address: registry,\n abi: wrappersRegistryAbi,\n functionName: \"getTokenConfidentialTokenPairsSlice\",\n args: [fromIndex, toIndex],\n } as const;\n}\n\n/**\n * Returns the contract config to fetch a single token wrapper pair by index.\n *\n * @example\n * ```ts\n * const pair = await client.readContract(\n * getTokenPairContract(registryAddress, 0n),\n * );\n * ```\n */\nexport function getTokenPairContract(registry: Address, index: bigint) {\n return {\n address: registry,\n abi: wrappersRegistryAbi,\n functionName: \"getTokenConfidentialTokenPair\",\n args: [index],\n } as const;\n}\n\n/**\n * Returns the contract config to look up the confidential token for a given plain token.\n *\n * @example\n * ```ts\n * const [isValid, confidentialToken] = await client.readContract(\n * getConfidentialTokenAddressContract(registryAddress, tokenAddress),\n * );\n * // isValid=false + confidentialToken=zeroAddress → not registered\n * // isValid=false + confidentialToken=nonZeroAddress → registered but revoked\n * // isValid=true + confidentialToken=nonZeroAddress → registered and valid\n * ```\n */\nexport function getConfidentialTokenAddressContract(registry: Address, tokenAddress: Address) {\n return {\n address: registry,\n abi: wrappersRegistryAbi,\n functionName: \"getConfidentialTokenAddress\",\n args: [tokenAddress],\n } as const;\n}\n\n/**\n * Returns the contract config to look up the plain token for a given confidential token.\n *\n * @example\n * ```ts\n * const [isValid, token] = await client.readContract(\n * getTokenAddressContract(registryAddress, confidentialTokenAddress),\n * );\n * // isValid=false + token=zeroAddress → not registered\n * // isValid=false + token=nonZeroAddress → registered but revoked\n * // isValid=true + token=nonZeroAddress → registered and valid\n * ```\n */\nexport function getTokenAddressContract(registry: Address, confidentialTokenAddress: Address) {\n return {\n address: registry,\n abi: wrappersRegistryAbi,\n functionName: \"getTokenAddress\",\n args: [confidentialTokenAddress],\n } as const;\n}\n\n/**\n * Returns the contract config to check if a confidential token is valid.\n *\n * @example\n * ```ts\n * const isValid = await client.readContract(\n * isConfidentialTokenValidContract(registryAddress, confidentialTokenAddress),\n * );\n * ```\n */\nexport function isConfidentialTokenValidContract(\n registry: Address,\n confidentialTokenAddress: Address,\n) {\n return {\n address: registry,\n abi: wrappersRegistryAbi,\n functionName: \"isConfidentialTokenValid\",\n args: [confidentialTokenAddress],\n } as const;\n}\n"],"mappings":"oLAIA,IAAa,EAAb,cAAkD,CAAU,CAC1D,YAAY,EAAiB,EAAwB,CACnD,MAAM,EAAc,wBAAyB,EAAS,CAAO,EAC7D,KAAK,KAAO,8BACd,CACF,EAGa,EAAb,cAAkD,CAAU,CAC1D,YAAY,EAAiB,EAAwB,CACnD,MAAM,EAAc,wBAAyB,EAAS,CAAO,EAC7D,KAAK,KAAO,8BACd,CACF,EAYa,EAAb,cAA4C,CAAU,CACpD,YAAY,EAAiB,EAAwB,CACnD,MAAM,EAAc,kBAAmB,EAAS,CAAO,EACvD,KAAK,KAAO,wBACd,CACF,EAGa,EAAb,cAAuC,CAAU,CAC/C,YAAY,EAAiB,EAAwB,CACnD,MAAM,EAAc,aAAc,EAAS,CAAO,EAClD,KAAK,KAAO,mBACd,CACF,EAQa,GAAb,cAAsC,CAAU,CAC9C,YAAY,EAAiB,EAAwB,CACnD,MAAM,EAAc,kBAAmB,EAAS,CAAO,EACvD,KAAK,KAAO,kBACd,CACF,EASa,GAAb,cAAkD,CAAU,CAC1D,YAAY,EAAiB,EAAwB,CACnD,MAAM,EAAc,wBAAyB,EAAS,CAAO,EAC7D,KAAK,KAAO,8BACd,CACF,EAQa,EAAb,cAAsD,CAAU,CAE9D,gBAEA,cAEA,YACE,CAAE,kBAAiB,iBACnB,EACA,CACA,MACE,EAAc,4BACd,qCAAqC,EAAg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L,QAAS,EACT,IAAK,EACL,aAAc,uCACd,KAAM,CAAC,CACT,CACF,CAYA,SAAgB,GAA2B,EAAmB,EAAmB,EAAiB,CAChG,MAAO,CACL,QAAS,EACT,IAAK,EACL,aAAc,sCACd,KAAM,CAAC,EAAW,CAAO,CAC3B,CACF,CAYA,SAAgB,GAAqB,EAAmB,EAAe,CACrE,MAAO,CACL,QAAS,EACT,IAAK,EACL,aAAc,gCACd,KAAM,CAAC,CAAK,CACd,CACF,CAeA,SAAgB,GAAoC,EAAmB,EAAuB,CAC5F,MAAO,CACL,QAAS,EACT,IAAK,EACL,aAAc,8BACd,KAAM,CAAC,CAAY,CACrB,CACF,CAeA,SAAgB,GAAwB,EAAmB,EAAmC,CAC5F,MAAO,CACL,QAAS,EACT,IAAK,EACL,aAAc,kBACd,KAAM,CAAC,CAAwB,CACjC,CACF,CAYA,SAAgB,GACd,EACA,EACA,CACA,MAAO,CACL,QAAS,EACT,IAAK,EACL,aAAc,2BACd,KAAM,CAAC,CAAwB,CACjC,CACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zama-fhe/sdk",
3
- "version": "3.6.0",
3
+ "version": "3.7.0-alpha.2",
4
4
  "description": "TypeScript SDK for Zama fhEVM confidential smart contracts",
5
5
  "keywords": [
6
6
  "blockchain",
@@ -167,7 +167,7 @@
167
167
  "api-report:check": "api-extractor run -c api-extractor.json && api-extractor run -c api-extractor.web.json && api-extractor run -c api-extractor.viem.json && api-extractor run -c api-extractor.ethers.json && api-extractor run -c api-extractor.node.json && api-extractor run -c api-extractor.query.json"
168
168
  },
169
169
  "dependencies": {
170
- "@fhevm/sdk": "0.13.2",
170
+ "@fhevm/sdk": "0.14.1-1",
171
171
  "viem": ">=2",
172
172
  "zod": ">=4"
173
173
  },
@@ -1,2 +0,0 @@
1
- import{p as e,r as t,t as n}from"./relayer-CVKO9GmQ.js";import{$ as r,R as i,V as a,W as o,Y as s,Z as c,a as l,b as u,et as d,i as f,n as p,nt as m,o as h,r as g,s as ee,t as te,v as ne,x as _,y as re,z as ie}from"./wrappers-registry-BLe7PkZi.js";import{r as ae}from"./applied-runtime-3fzqBC2V.js";import{t as v}from"./validation-BRu06AM_.js";import{a as y,c as oe,l as se,n as ce,o as b,s as le,u as x}from"./chains-ByyCdrrd.js";import{getAddress as S,isAddress as ue,isHex as de,toBytes as C,toHex as w,zeroAddress as fe}from"viem";import{hasFhevmRuntimeConfig as pe,setFhevmRuntimeConfig as me}from"@fhevm/sdk/viem";import{z as T}from"zod/mini";var E=class{#e=null;#t=null;#n;#r;#i;constructor(e=`CredentialStore`,t=1,n=`credentials`){this.#n=e,this.#r=t,this.#i=n}#a(){return this.#e?Promise.resolve(this.#e):(this.#t||=new Promise((e,t)=>{let n=indexedDB.open(this.#n,this.#r);n.onupgradeneeded=()=>{let e=n.result;e.objectStoreNames.contains(this.#i)||e.createObjectStore(this.#i,{keyPath:`key`})},n.onsuccess=()=>{this.#e=n.result,this.#t=null,this.#e.onversionchange=()=>{this.#e?.close(),this.#e=null,this.#t=null},this.#e.onclose=()=>{this.#e=null,this.#t=null},e(this.#e)},n.onerror=()=>{this.#e=null,this.#t=null,t(n.error)}}),this.#t)}async#o(e,t){let n=await this.#a();return new Promise((r,i)=>{let a=n.transaction(this.#i,e);a.onabort=()=>i(a.error??Error(`Transaction aborted`));let o=t(a.objectStore(this.#i));e===`readonly`?o.onsuccess=()=>r(o.result):a.oncomplete=()=>r(o.result),o.onerror=()=>i(o.error)})}async get(e){return(await this.#o(`readonly`,t=>t.get(e)))?.value??null}async set(e,t){await this.#o(`readwrite`,n=>n.put({key:e,value:t}))}async delete(e){await this.#o(`readwrite`,t=>t.delete(e))}async clear(){await this.#o(`readwrite`,e=>e.clear())}};const he=new E;var D=class{#e=new Map;async get(e){return this.#e.get(e)??null}async set(e,t){this.#e.set(e,t)}async delete(e){this.#e.delete(e)}};const ge=new D;function _e(){return typeof window<`u`?new E(`CredentialStore`):new D}function ve(e=_e(),t=e){return{storage:e,permitStorage:t}}function ye(e,t,r){let i=e.map(e=>e.id),a=[...new Set(i.filter((e,t)=>i.indexOf(e)!==t))];if(a.length>0)throw new n(`Duplicate chain id(s) [${a.join(`, `)}] in the chains array. Each chain id must appear only once. Note: hardhat and anvil are aliases (both use 31337).`);let o=Object.keys(t).map(Number).filter(e=>!i.includes(e));o.length>0&&r.warn(`Relayer entries for chain(s) [${o.join(`, `)}] are ignored: those chains are not in the chains array. Add the chain config to use them, or drop the relayer entries.`);let s=new Map;for(let r of e){let e=t[r.id];if(!e)throw new n(`Chain ${r.id} has no relayer configured. Add a relayer entry: relayers: { [${r.id}]: web() }`);s.set(r.id,{chain:r,relayerConfig:e})}return s}var be=class{#e;#t;#n;constructor(e,t,r){if(e.length===0)throw new n(`At least one chain is required.`);this.#e=new Map(e.map(e=>[e.id,e])),this.#n=e[0].id;let i=new Map;for(let[n,{relayerConfig:a,chain:o}]of ye(e,t,r))i.set(n,a.createRelayer(o,r));this.#t=i}get chains(){return[...this.#e.values()]}get chain(){let e=this.#e.get(this.#n);if(e===void 0)throw new n(`Chain ${this.#n} is not configured. Add it to the chains array.`);return e}switchChain(e){this.#n=e}dispose(){for(let e of new Set(this.#t.values()))e.dispose?.()}get relayer(){let e=this.#t.get(this.chain.id);if(e===void 0)throw new n(`No relayer configured for chain ${this.#n}. Add it to the relayers object.`);return e}};function O(e){return S(e)}const k=T.custom(e=>typeof e==`string`&&de(e,{strict:!0}),`expected 0x-prefixed hex string`),xe=T.custom(e=>typeof e==`string`&&ue(e,{strict:!1}),`expected EVM address`),A=T.pipe(xe,T.transform(O)),j=T.int().check(T.nonnegative()),M=T.int().check(T.positive()),Se=T.int().check(T.nonnegative()),Ce=T.int().check(T.positive());T.int().check(T.positive());const N={version:1,info:`zama-sdk-keypair-wrapping-v1`,ivLengthBytes:12,tagLengthBytes:16};function P(e){return new Uint8Array(e)}function we(e){return P(new TextEncoder().encode(JSON.stringify([e.publicKey,e.createdAt,e.expiresAt,e.tkmsVersion??null])))}function Te(e){return typeof e==`string`?new TextEncoder().encode(e):P(e)}var Ee=class{#e;#t;constructor(e){this.#e=e}async baseKey(){return this.#t??=this.#n(this.#e),this.#t}async#n(e){let t=Te(e),n=await crypto.subtle.importKey(`raw`,t,`HKDF`,!1,[`deriveKey`]);return t.fill(0),e instanceof Uint8Array&&e.fill(0),this.#e=void 0,n}};async function De(e,t){let n=await e.baseKey();return crypto.subtle.deriveKey({name:`HKDF`,hash:`SHA-256`,salt:new TextEncoder().encode(t),info:new TextEncoder().encode(N.info)},n,{name:`AES-GCM`,length:256},!1,[`encrypt`,`decrypt`])}async function Oe(e,t,n,r){let i=await De(t,n),a=crypto.getRandomValues(new Uint8Array(N.ivLengthBytes)),o=await crypto.subtle.encrypt({name:`AES-GCM`,iv:a,additionalData:we(r)},i,P(C(e)));return{wrappedPrivateKey:w(new Uint8Array(o)),iv:w(a)}}async function ke(e,t,n,r){let i=await De(t,n),a=await crypto.subtle.decrypt({name:`AES-GCM`,iv:P(C(e.iv)),additionalData:we(r)},i,P(C(e.wrappedPrivateKey)));return w(new Uint8Array(a))}function Ae(e){return typeof e==`object`&&!!e&&`name`in e&&e.name===`OperationError`}const F=86400;function I(){return Math.floor(Date.now()/1e3)}function L(e){return[...new Set(e.map(O))].sort()}function je(e){let{chainId:t}=e.domain;return typeof t==`bigint`?{...e,domain:{...e.domain,chainId:t.toString()}}:e}const R=`transportKeyPairTTL must be a positive integer number of seconds`,z=`permitTTL must be a positive integer number of days`,B=`transportKeyPairScope must be a non-empty string`,V=`transportKeyPairDerivationSecret must be a Uint8Array of at least 32 bytes or a string of at least 64 characters (256 bits of entropy): source it from a CSPRNG or secrets manager, not a human-memorable passphrase`,H=365*F,Me=T.int({error:R}).check(T.positive({error:R}),T.maximum(H,`transportKeyPairTTL must not exceed the fhevm ACL maximum of ${H}s (365 days)`)),U=T.int({error:z}).check(T.positive({error:z}),T.maximum(365,`permitTTL must not exceed the V1 permit maximum of 365 days`)),Ne=T.string({error:B}).check(T.minLength(1,B)),Pe=T.union([T.string({error:V}).check(T.minLength(64,V)),T.instanceof(Uint8Array,{error:V}).check(T.refine(e=>e.byteLength>=32,{error:V}))],{error:V}),Fe=T.object({publicKey:k,privateKey:k,createdAt:j,expiresAt:M,tkmsVersion:T.optional(T.string())}),W=T.object({domain:T.record(T.string(),T.unknown()),primaryType:T.optional(T.string()),types:T.record(T.string(),T.array(T.object({name:T.string(),type:T.string()}))),message:T.record(T.string(),T.unknown())}),G=T.object({version:T.int().check(T.positive()),eip712:W,signature:k,signerAddress:A}),K=T.object({keypairPublicKey:k,contractAddresses:T.array(A).check(T.maxLength(10)),serializedPermit:G,startTimestamp:j,durationDays:Ce}),Ie=T.array(K),Le=T.array(T.string()),Re=T.object({version:T.literal(1),eip712:W,signerAddress:A}),ze=`iv must be a ${N.ivLengthBytes}-byte hex string`,Be=`wrappedPrivateKey must be a whole number of bytes and at least ${N.tagLengthBytes} bytes (the AES-GCM authentication tag)`;function Ve(e){return(e.length-2)/2}const He=T.object({wrappingVersion:T.literal(N.version,{error:`wrappingVersion must be a wrapping scheme this SDK can read`}),publicKey:k,wrappedPrivateKey:k.check(T.refine(e=>e.length%2==0&&Ve(e)>=N.tagLengthBytes,{error:Be})),iv:k.check(T.refine(e=>Ve(e)===N.ivLengthBytes,{error:ze})),createdAt:j,expiresAt:M,tkmsVersion:T.optional(T.string())});function Ue(e){let t={publicKey:e.publicKey,createdAt:e.createdAt,expiresAt:e.expiresAt};return e.tkmsVersion&&(t.tkmsVersion=e.tkmsVersion),t}const q={version:N.version,schema:He,async encode(e,t,n){let{wrappedPrivateKey:r,iv:i}=await Oe(e.privateKey,t,n,Ue(e)),a={wrappingVersion:N.version,publicKey:e.publicKey,wrappedPrivateKey:r,iv:i,createdAt:e.createdAt,expiresAt:e.expiresAt};return e.tkmsVersion&&(a.tkmsVersion=e.tkmsVersion),a},async decode(e,t,n){let r=await ke({wrappedPrivateKey:e.wrappedPrivateKey,iv:e.iv},t,n,Ue(e)),i={publicKey:e.publicKey,privateKey:r,createdAt:e.createdAt,expiresAt:e.expiresAt};return e.tkmsVersion&&(i.tkmsVersion=e.tkmsVersion),i}},We=new Map([[q.version,q]]),Ge=q;function Ke(e){let t=e;return t.wrappingVersion!==void 0||t.wrappedPrivateKey!==void 0&&t.iv!==void 0}function qe(e){if(typeof e!=`object`||!e||!Ke(e)){let t=Fe.safeParse(e);return t.success?{kind:`plaintext`,keyPair:t.data}:{kind:`unrecognized`}}let t=e.wrappingVersion,n=typeof t==`number`?We.get(t):void 0;if(n===void 0)return{kind:`unsupported-version`,version:t};let r=n.schema.safeParse(e);if(!r.success)return{kind:`corrupt-wrapped`};let i=r.data;return{kind:`wrapped`,expiresAt:i.expiresAt,decode:(e,t)=>n.decode(i,e,t)}}function Je(e,t,n){return Ge.encode(e,t,n)}function J(e){return`keypair:${e}`}function Y(e){return`keypair:scope:${e}`}function X(e){return`permits:${e.signerAddress}:${e.chainId}:${e.delegatorAddress}`}function Z(e){return`permits-index:${e}`}function Ye(e){return`scope:${e}`}function Xe(e,t){return{"wrapped-without-secret":`Transport key pair for scope "${t}" is wrapped, but this instance has no transportKeyPairDerivationSecret configured. Every instance sharing this scope must use the same transportKeyPairDerivationSecret; once they do, call permits.revokeTransportKeyPair() to rotate the entry.`,"unwrapped-under-secret":`Transport key pair for scope "${t}" is stored unwrapped, but this instance is configured with a transportKeyPairDerivationSecret. A peer instance sharing this scope is running without the secret: configure the same transportKeyPairDerivationSecret everywhere, then call permits.revokeTransportKeyPair() to migrate the scope to a wrapped entry.`,"unwrap-failed":`Transport key pair for scope "${t}" failed to unwrap. This usually means another instance created it with a different transportKeyPairDerivationSecret: every instance sharing this scope must use the same secret. It can also mean the stored entry is corrupted.`,"corrupt-wrapped":`Transport key pair for scope "${t}" is wrapped but structurally invalid: the stored iv or ciphertext is not a shape this wrapping scheme can produce. This usually means the stored entry is corrupted, or instances sharing this scope are running mismatched wrapping-scheme versions.`}[e]}const Ze={"unwrapped-under-secret":`unwrapped transport key pair entry found while a transportKeyPairDerivationSecret is configured`,"unwrap-failed":`transport key pair entry failed to unwrap (wrong transportKeyPairDerivationSecret?)`,"corrupt-wrapped":`structurally invalid wrapped transport key pair entry`};function Qe(e,t){let n=typeof e==`number`?`wrappingVersion ${e}`:`no wrappingVersion this build recognizes`;return`Transport key pair ${t===void 0?`for this signer`:`for scope "${t}"`} was written under a wrapping scheme this SDK build cannot read (${n}). The entry is preserved instead of regenerated, since an instance that understands the scheme may still be using it: ${t===void 0?`run a build that supports it, or call permits.clear() to discard the entry deliberately`:`run a build that supports it everywhere, or call permits.revokeTransportKeyPair() to rotate the scope`}.`}var $e=class{#e;#t;#n;#r;#i;#a;#o=new Map;#s=new Map;constructor(e){this.#e=e.generator,this.#t=e.storage,this.#n=e.ttl,this.#r=e.logger,this.#i=e.scope,this.#a=e.derivationSecret}#c(e){return this.#i===void 0?`signer:${e}`:Ye(this.#i)}#l(e){return this.#i===void 0?J(e):Y(this.#i)}async readStored(e){return this.#u(this.#l(e),this.#c(e))}async#u(e,t){let n=await this.#t.get(e);if(n==null)return null;let r=qe(n);if(r.kind===`unsupported-version`)throw this.#f(e,Qe(r.version,this.#i));if(r.kind===`unrecognized`)return await this.#m(e,`malformed transport key pair entry`),null;let i=this.#a;if(i===void 0)return r.kind===`plaintext`?await this.#p(e,r.keyPair.expiresAt)?null:r.keyPair:this.#d(e,`wrapped-without-secret`);if(r.kind===`plaintext`)return this.#d(e,`unwrapped-under-secret`);if(r.kind===`corrupt-wrapped`)return this.#d(e,`corrupt-wrapped`);if(await this.#p(e,r.expiresAt))return null;try{return await r.decode(i,t)}catch(t){if(!Ae(t))throw this.#r.error(`transport key pair unwrap failed unexpectedly`,{key:e,error:t}),new c(`Transport key pair unwrap failed unexpectedly.`,{cause:t});return this.#d(e,`unwrap-failed`,t)}}async#d(e,t,n){if(this.#i!==void 0)throw this.#f(e,Xe(t,this.#i),n);if(t===`wrapped-without-secret`)throw this.#f(e,`Transport key pair for this signer is wrapped, but this instance has no transportKeyPairDerivationSecret configured. Configure the same transportKeyPairDerivationSecret the entry was written with. To downgrade to plaintext at rest on purpose, discard the stored entry first by calling permits.clear(), then run without the secret.`,n);let r=Ze[t];return this.#r.warn(r,{key:e}),await this.#m(e,r),null}#f(e,t,n){return this.#r.error(t,{key:e}),new c(t,{cause:n})}async#p(e,t){return I()<t?!1:(await this.#m(e,`expired transport key pair entry`),!0)}async#m(e,t){this.#r.debug(`discarding transport key pair entry`,{key:e,reason:t}),await i(`delete transport key pair entry`,()=>this.#t.delete(e),this.#r)}async getOrCreate(e,t){return this.#h(this.#l(e),this.#c(e),{strict:t?.strict})}async#h(e,t,n){let r=n?.strict??!1,a=`${e}::${r}`,o=this.#o.get(a);if(o)return o;let s=this.#s.get(e)??0,l=(async()=>{let n=await this.#u(e,t);if(n!==null)return n;let a=await this.#e(),o=I(),l=o+this.#n,u={publicKey:a.publicKey,privateKey:a.privateKey,createdAt:o,expiresAt:l};a.tkmsVersion&&(u.tkmsVersion=a.tkmsVersion);let d=u;if(this.#a!==void 0)try{d=await Je(u,this.#a,t)}catch(t){let n=`Failed to wrap the transport private key for at-rest storage.`;throw this.#r.error(n,{key:e,error:t}),new c(n,{cause:t})}if((this.#s.get(e)??0)===s)r?await this.#t.set(e,d):await i(`persist transport key pair`,()=>this.#t.set(e,d),this.#r);else if(r)throw new m(`The transport key pair was rotated while it was being generated, so the freshly generated key pair could not be persisted. Retry.`);return u})().finally(()=>{this.#o.delete(a)});return this.#o.set(a,l),l}async clear(e){let t=J(e);await i(`delete transport key pair entry`,()=>this.#t.delete(t),this.#r)}async evict(e){let t=this.#l(e);await i(`evict transport key pair entry`,()=>this.#t.delete(t),this.#r)}async clearScope(){if(this.#i===void 0)return;let e=Y(this.#i);this.#s.set(e,(this.#s.get(e)??0)+1),await this.#t.delete(e)}async warmScope(){this.#i!==void 0&&await this.#h(Y(this.#i),Ye(this.#i),{strict:!0})}};function et(e,t){let n=new Set(e.flatMap(e=>e.contractAddresses));return t.filter(e=>!n.has(e))}function tt(e){let t=[];for(let n=0;n<e.length;n+=10)t.push(e.slice(n,n+10));return t}function nt(e,t,n){return e.filter(e=>e.keypairPublicKey===t&&n<e.startTimestamp+e.durationDays*86400)}function rt(e,t){let n=new Set(t);return e.filter(e=>!e.contractAddresses.some(e=>n.has(e)))}function it(e,t){return[...new Set([...e,...t])].sort()}function at(e,t,n){let r=new Set(n),i=e.filter(e=>new Set([...e.contractAddresses,...t]).size<=10);if(i.length===0)return null;function a(e){return e.contractAddresses.reduce((e,t)=>e+ +!!r.has(t),0)}let o=Math.max(...i.map(a));return i.filter(e=>a(e)===o).reduce((e,t)=>t.startTimestamp>e.startTimestamp?t:e)}var ot=class{#e;#t;constructor(e){this.#e=e.storage,this.#t=e.logger}async list(e){let t=X(e),n=await this.#e.get(t);if(n==null)return[];let r=Ie.safeParse(n);return r.success?r.data:(await this.clearScope(e),[])}async listUsableAndPrune(e,t){let n=await this.list(e),r=nt(n,t,Math.floor(Date.now()/1e3));return r.length!==n.length&&(r.length===0?await this.clearScope(e):await i(`update permit entry`,()=>this.#e.set(X(e),r),this.#t)),r}async append(e,t){if(t.length===0)return;let n=t.map(e=>K.parse(e)),r=await this.list(e);await this.#e.set(X(e),[...r,...n]),await this.#r(e)}async replace(e,t,n){let r=K.parse(n),i=(await this.list(e)).filter(e=>e.serializedPermit.signature!==t);await this.#e.set(X(e),[...i,r]),await this.#r(e)}async deletePermitsTouching(e,t){let n=await this.list(e);if(n.length===0)return;let r=rt(n,t);r.length===0?await this.clearScope(e):await this.#e.set(X(e),r)}async clearScope(e){await this.#a(X(e)),await this.#i(e)}async clearAllForSigner(e){let t=Z(e),n=await this.#n(t);await Promise.all(n.map(e=>this.#a(e))),await i(`delete permit index`,()=>this.#e.delete(t),this.#t)}async#n(e){let t=await this.#e.get(e);if(t==null)return[];let n=Le.safeParse(t);return n.success?n.data:(await i(`delete permit index`,()=>this.#e.delete(e),this.#t),[])}async#r(e){let t=Z(e.signerAddress),n=X(e),r=await this.#n(t);r.includes(n)||await this.#e.set(t,[...r,n])}async#i(e){let t=Z(e.signerAddress),n=X(e),r=await this.#n(t),a=r.filter(e=>e!==n);a.length!==r.length&&(a.length===0?await i(`delete permit index`,()=>this.#e.delete(t),this.#t):await i(`update permit index`,()=>this.#e.set(t,a),this.#t))}async#a(e){await i(`delete permit entry`,()=>this.#e.delete(e),this.#t)}},st=class{#e;#t;#n;#r;#i;#a;#o;#s;#c=new Map;constructor(e){this.#e=new $e({generator:async()=>{let t=e.router.relayer,n=await t.generateTransportKeyPair();return t.serializeTransportKeyPair({transportKeyPair:n})},storage:e.storage,ttl:e.transportKeyPairTTL,logger:e.logger,scope:e.scope,derivationSecret:e.derivationSecret}),this.#t=new ot({storage:e.permitStorage??e.storage,logger:e.logger}),this.#n=e.router,this.#r=e.signer,this.#i=e.permitTTL,this.#a=e.logger,this.#o=e.emitEvent,this.#s=e.scope}#l(e){if(!this.#r)throw new a(e);return this.#r}#u(e,t){let n=s(t,{operation:e});return this.#o({type:ie.PermitError,operation:e,error:n}),n}async grantPermit(e,t){let n=t===void 0?`grantPermit`:`grantDelegationPermit`,r,a,o;try{r=O(this.#l(`grantPermit`).requireWalletAccount(`grantPermit`).address),a=L(e),o=this.#d(r,t)}catch(e){throw this.#u(n,e)}let s=await this.#e.getOrCreate(r);if(a.length===0)return{keypair:s,permissions:[]};let c;try{c=await this.#t.listUsableAndPrune(o,s.publicKey)}catch(e){throw this.#u(n,e)}let l=et(c,a);if(l.length>0){let e=at(c,l,a);if(e!==null){let t=it(e.contractAddresses,l),n=await this.#f({chunk:t,keypair:s,scope:o});await i(`replace permit`,()=>this.#t.replace(o,e.serializedPermit.signature,n),this.#a),c[c.indexOf(e)]=n}else for(let e of tt(l)){let t=await this.#f({chunk:e,keypair:s,scope:o});c.push(t),await i(`persist permit`,()=>this.#t.append(o,[t]),this.#a)}}let u=new Set(a);return{keypair:s,permissions:c.filter(e=>e.contractAddresses.some(e=>u.has(e)))}}async preparePermit(e){let t=O(e.signer),r=L(e.contracts);if(r.length===0)throw new n(`preparePermit: request.contracts must not be empty.`);if(r.length>10)throw new n(`preparePermit: request.contracts must not exceed 10 addresses per call (got ${r.length}) — grantPermit chunks automatically, preparePermit does not.`);let i=e.delegator?O(e.delegator):void 0;if(i!==void 0&&i===t)throw new n(`preparePermit: request.delegator must differ from request.signer — self-delegation is not allowed.`);let a=e.durationDays===void 0?this.#i:v(U,e.durationDays),o=this.#n.relayer,s=await this.#e.getOrCreate(t,{strict:!0}),c=await o.parseTransportKeyPair(s),l=I();return{version:1,eip712:je(W.parse(await o.createUnsignedLegacyDecryptionPermitEip712({transportKeyPair:c,contractAddresses:r,startTimestamp:l,durationSeconds:a*F,...i&&{delegatorAddress:i}}))),signerAddress:t}}async registerPermit(e,t){let a;try{a=v(Re,e)}catch(e){throw this.#u(`registerPermit`,e)}let o=this.#n.relayer,s=this.#n.chain.id,{domain:c,message:l}=a.eip712,u=Number(c.chainId);if(u!==s)throw this.#u(`registerPermit`,new r({preparedChainId:u,activeChainId:s}));let f=Number(l.startTimestamp),p=Number(l.durationDays);if(I()>=f+p*86400)throw this.#u(`registerPermit`,new d(`registerPermit: the prepared permit's validity window (starting ${f}, ${p}d) has already elapsed — call preparePermit again.`));let h=a.signerAddress,g=await this.#e.readStored(h);if(g===null||g.publicKey!==l.publicKey)throw new m(`registerPermit: the transport key pair changed since preparePermit ran — call preparePermit again to rebind the signature request to the current key pair.`);try{let e=await o.parseTransportKeyPair(g),r=await o.parseSignedDecryptionPermit({serializedPermit:{version:a.version,eip712:a.eip712,signature:t,signerAddress:h},transportKeyPair:e});if(r.version!==1)throw new n(`registerPermit: expected a V1 signed permit, got version ${r.version}.`);let c=v(G,await o.serializeSignedDecryptionPermit({signedPermit:r})),l={keypairPublicKey:g.publicKey,contractAddresses:L(r.eip712.message.contractAddresses),serializedPermit:c,startTimestamp:Number(r.eip712.message.startTimestamp),durationDays:Number(r.eip712.message.durationDays)},u={signerAddress:h,chainId:s,delegatorAddress:O(r.encryptedDataOwnerAddress)};await i(`replace permit`,()=>this.#t.replace(u,c.signature,l),this.#a)}catch(e){throw this.#u(`registerPermit`,e)}}async hasPermit(e,t){if(e.length===0)return!0;let n=this.#r?.walletAccount.getSnapshot();if(!n)return!1;let r=O(n.address),i;try{i=await this.#e.readStored(r)}catch(e){if(!(e instanceof c))throw e;return!1}if(i===null)return!1;let a=this.#d(r,t);return et(await this.#t.listUsableAndPrune(a,i.publicKey),L(e)).length===0}async revokePermits(e){let t=O(this.#l(`revokePermits`).requireWalletAccount(`revokePermits`).address);if(e===void 0){await this.#t.clearAllForSigner(t);return}let n=L(e);n.length!==0&&await this.#t.deletePermitsTouching(this.#d(t),n)}#d(e,t){return{signerAddress:e,chainId:this.#n.chain.id,delegatorAddress:t?O(t):e}}async clearCredentials(){let e=O(this.#l(`clearCredentials`).requireWalletAccount(`clearCredentials`).address);await this.#e.clear(e),await this.#t.clearAllForSigner(e)}async revokeTransportKeyPair(e){if(this.#s===void 0)throw new n(`revokeTransportKeyPair() requires a transportKeyPairScope to be configured on this SDK instance — there is no shared key pair to revoke.`);if(e!==this.#s)throw new n(`revokeTransportKeyPair("${e}") does not match the configured scope ("${this.#s}").`);await this.#e.clearScope()}async warmTransportKeyPair(e){await this.#e.getOrCreate(O(e))}async warmTransportKeyPairScope(e){if(this.#s===void 0)throw new n(`warmTransportKeyPairScope() requires a transportKeyPairScope to be configured on this SDK instance — there is no shared key pair to warm.`);if(e!==this.#s)throw new n(`warmTransportKeyPairScope("${e}") does not match the configured scope ("${this.#s}").`);await this.#e.warmScope()}async handleWalletAccountChange(e,t){let n=e?O(e.address):void 0;n!==(t?O(t.address):void 0)&&n&&(await this.#e.clear(n),await this.#t.clearAllForSigner(n))}async#f(n){let{chunk:r,keypair:i,scope:a}=n,o=I(),s=a.delegatorAddress!==a.signerAddress,c=this.#n.relayer;try{let e={transportKeyPair:await c.parseTransportKeyPair(i),contractAddresses:r,startTimestamp:o,durationSeconds:this.#i*F,signerAddress:a.signerAddress,signer:this.#l(`signPermit`)},t=s?await c.signDecryptionPermit({...e,delegatorAddress:a.delegatorAddress}):await c.signDecryptionPermit(e),n=v(G,await c.serializeSignedDecryptionPermit({signedPermit:t}));return{keypairPublicKey:i.publicKey,contractAddresses:r,serializedPermit:n,startTimestamp:o,durationDays:this.#i}}catch(n){let r=s?`grantDelegationPermit`:`grantPermit`;throw!(n instanceof t)&&n instanceof Error&&e(n.message)&&await this.#e.evict(a.signerAddress),this.#u(r,n)}}async evictTransportKeyPair(){let e=this.#r?.walletAccount.getSnapshot();e&&await this.#e.evict(O(e.address))}async recoverPermits(e,t,n){let r=this.#l(`recoverPermits`).requireWalletAccount(`recoverPermits`),i=this.#d(O(r.address),t),a=X(i),o=this.#c.get(a);if(o)return await o,this.grantPermit(e,t);let s=await this.#p(i),c=this.#c.get(a);if(c)return await c,this.grantPermit(e,t);if(s===null)return this.grantPermit(e,t);let l=new Set(n??[]);if(l.size>0&&!s.some(e=>l.has(e.serializedPermit.signature)))return this.grantPermit(e,t);let u=s.filter(e=>!l.has(e.serializedPermit.signature)),d=s.flatMap(e=>e.contractAddresses),f=this.#m(i,d,e,u,t).finally(()=>{this.#c.delete(a)});return this.#c.set(a,f),await f,this.grantPermit(e,t)}async#p(e){try{return await this.#t.list(e)}catch(e){return this.#a.warn(`read permits for recovery failed`,{error:e}),null}}async#m(e,t,n,r,a){await i(`evict revoked permits`,()=>this.#t.clearScope(e),this.#a);try{await this.grantPermit(it(t,L(n)),a)}catch(t){throw r.length>0&&await i(`restore surviving permits`,async()=>{let t=await this.#t.list(e),n=new Set(t.map(e=>e.serializedPermit.signature)),i=r.filter(e=>!n.has(e.serializedPermit.signature));i.length>0&&await this.#t.append(e,i)},this.#a),t}}},ct=class{#e;#t=`[zama-sdk]`;constructor(e){this.#e=e}error(e,t){this.#e?.error(`${this.#t} ${e}`,t)}warn(e,t){this.#e?.warn(`${this.#t} ${e}`,t)}info(e,t){this.#e?.info(`${this.#t} ${e}`,t)}debug(e,t){this.#e?.debug(`${this.#t} ${e}`,t)}warnAlways(e){console.warn(`${this.#t} ${e}`),this.warn(e)}};const lt={[le.id]:le.registryAddress,[oe.id]:oe.registryAddress,[x.id]:x.registryAddress,[se.id]:se.registryAddress,[y.id]:y.registryAddress,[b.id]:b.registryAddress,[ce.id]:ce.registryAddress},ut=T.record(T.string().check(T.regex(/^\d+$/,`expected numeric chain id key`)),A),dt=Se,Q=300*1e3;var ft=class{provider;#e;#t;#n=new Map;constructor(e){this.provider=e.provider,this.#e=Object.assign({},lt,v(T.optional(ut),e.registryAddresses)),this.#t=v(dt,e.registryTTL??86400)*1e3}getAddress(e){return this.#e[e]}#r(e){let t=this.#n.get(e);if(t){if(Date.now()>=t.expiresAt){this.#n.delete(e);return}return t.data}}#i(e,t,n=this.#t){return this.#n.set(e,{data:t,expiresAt:Date.now()+n}),t}refresh(){this.#n.clear()}get ttlMs(){return this.#t}async getRegistryAddress(){let e=await this.provider.getChainId(),t=this.#e[e];if(!t)throw new n(`No wrappers registry address configured for chain ${e}.\nPass a registryAddresses entry for this chain.`);return S(t)}async listPairs(e={}){let t=e.page??1,r=e.pageSize??100,i=e.metadata??!1;if(t<1)throw new n(`page must be >= 1, got ${t}`);if(r<1)throw new n(`pageSize must be >= 1, got ${r}`);let a=await this.getRegistryAddress(),o=`total:${a}`,s=this.#r(o);if(s===void 0){let e=await this.provider.readContract(l(a));s=this.#i(o,Number(e))}let c=BigInt((t-1)*r),u=c+BigInt(r)>BigInt(s)?BigInt(s):c+BigInt(r);if(c>=BigInt(s))return{items:[],total:s,page:t,pageSize:r};let d=`slice:${a}:${c}:${u}`,f=this.#r(d);if(f===void 0){let e=await this.provider.readContract(h(a,c,u));f=this.#i(d,[...e])}if(!i)return{items:f,total:s,page:t,pageSize:r};let p=`metadata:${a}:${c}:${u}`,m=this.#r(p);if(m===void 0){let e=await Promise.allSettled(f.map(e=>this.#a(e))),t=e.some(e=>e.status===`rejected`),n=e.map((e,t)=>e.status===`fulfilled`?e.value:Object.assign({},f[t],{metadataFailed:!0,underlying:{name:`Unknown`,symbol:`???`,decimals:0,totalSupply:0n},confidential:{name:`Unknown`,symbol:`???`,decimals:0}}));m=this.#i(p,n,t?Q:void 0)}return{items:m,total:s,page:t,pageSize:r}}async#a(e){let[t,n,r,i,a,o,s]=await Promise.all([this.provider.readContract(u(e.tokenAddress)),this.provider.readContract(_(e.tokenAddress)),this.provider.readContract(ne(e.tokenAddress)),this.provider.readContract(re(e.tokenAddress)),this.provider.readContract(u(e.confidentialTokenAddress)),this.provider.readContract(_(e.confidentialTokenAddress)),this.provider.readContract(ne(e.confidentialTokenAddress))]);return{...e,underlying:{name:t,symbol:n,decimals:r,totalSupply:i},confidential:{name:a,symbol:o,decimals:s}}}async getConfidentialToken(e){let t=await this.getRegistryAddress(),n=S(e),r=`ct:${t}:${n}`,i=this.#r(r);if(i!==void 0)return i;let[a,o]=await this.provider.readContract(te(t,n));return o===fe?this.#i(r,null,Q):this.#i(r,{confidentialTokenAddress:o,isValid:a})}async getUnderlyingToken(e){let t=await this.getRegistryAddress(),n=S(e),r=`ut:${t}:${n}`,i=this.#r(r);if(i!==void 0)return i;let[a,o]=await this.provider.readContract(p(t,n));return o===fe?this.#i(r,null,Q):this.#i(r,{tokenAddress:o,isValid:a})}async getTokenPairs(){let e=await this.getRegistryAddress();return this.provider.readContract(f(e))}async getTokenPairsLength(){let e=await this.getRegistryAddress();return this.provider.readContract(l(e))}async getTokenPairsSlice(e,t){let n=await this.getRegistryAddress();return this.provider.readContract(h(n,e,t))}async getTokenPair(e){let t=await this.getRegistryAddress();return this.provider.readContract(g(t,e))}async getConfidentialTokenAddress(e){let t=await this.getRegistryAddress();return this.provider.readContract(te(t,S(e)))}async getTokenAddress(e){let t=await this.getRegistryAddress();return this.provider.readContract(p(t,S(e)))}async isConfidentialTokenValid(e){let t=await this.getRegistryAddress();return this.provider.readContract(ee(t,S(e)))}};function pt(e,t,n){let r=new ct(n.logger),i=n.logger,a={wasmAssetLoadMode:`auto`,moduleVersions:`auto`,logger:{error:(e,t)=>i?.error(e,{cause:t}),warn:e=>i?.warn(e),debug:e=>i?.debug(e)},...n.runtime};if(pe()){let e=`runtime configuration is already set and cannot be changed.`;n.runtime===void 0?r.debug(e):r.warn(e)}else me(a),ae(a);let{storage:o,permitStorage:s}=ve(n.storage,n.permitStorage),c=new be(n.chains,n.relayers,r);return{chains:n.chains,router:c,provider:t,signer:e,storage:o,permitStorage:s,transportKeyPairTTL:v(Me,n.transportKeyPairTTL??2592e3),permitTTL:v(U,n.permitTTL??30),transportKeyPairScope:n.transportKeyPairScope===void 0?void 0:v(Ne,n.transportKeyPairScope),registryTTL:v(dt,n.registryTTL??86400),logger:r,onEvent:n.onEvent}}function mt(e,t){return e?.address===t?.address&&e?.chainId===t?.chainId}var $=class{#e=new Set;#t;#n;constructor(e){this.#t=e,this.#n=e!==void 0}getSnapshot(){return this.#t}isReady(){return this.#n}setSnapshot(e){this.#n=!0;let t=this.#t;mt(t,e)||(this.#t=e,this.#r({previous:t,next:e}))}subscribe(e){this.#e.add(e);let t=this.#t;return t&&e({previous:void 0,next:t}),()=>{this.#e.delete(e)}}#r(e){for(let t of this.#e)t(e)}};function ht(e){return new $(e)}var gt=class{walletAccount;#e=!1;constructor(e){this.walletAccount=new $(e)}requireWalletAccount(e){let t=this.walletAccount.getSnapshot();if(!t)throw new o(e);return t}dispose(){this.#e||(this.#e=!0,this.onDispose())}[Symbol.dispose](){this.dispose()}onDispose(){}};export{he as _,lt as a,Pe as c,A as d,k as f,E as g,ge as h,pt as i,Ee as l,D as m,$ as n,ft as o,j as p,ht as r,st as s,gt as t,O as u};
2
- //# sourceMappingURL=base-signer-DGIEzavu.js.map