@zama-fhe/sdk 3.7.0-alpha.2 → 3.7.0-beta.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 (102) 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/erc165.cjs +2 -0
  6. package/dist/cjs/erc165.cjs.map +1 -0
  7. package/dist/cjs/ethers/index.cjs +1 -1
  8. package/dist/cjs/ethers/index.cjs.map +1 -1
  9. package/dist/cjs/fhevm-relayer.cjs +2 -2
  10. package/dist/cjs/fhevm-relayer.cjs.map +1 -1
  11. package/dist/cjs/index.cjs +1 -1
  12. package/dist/cjs/index.cjs.map +1 -1
  13. package/dist/cjs/invalidation.cjs +2 -0
  14. package/dist/cjs/invalidation.cjs.map +1 -0
  15. package/dist/cjs/primitives.cjs +2 -0
  16. package/dist/cjs/primitives.cjs.map +1 -0
  17. package/dist/cjs/query/index.cjs +1 -1
  18. package/dist/cjs/query/index.cjs.map +1 -1
  19. package/dist/cjs/relayer.cjs +1 -1
  20. package/dist/cjs/relayer.cjs.map +1 -1
  21. package/dist/cjs/token.cjs +1 -1
  22. package/dist/cjs/token.cjs.map +1 -1
  23. package/dist/cjs/vaults/index.cjs +2 -0
  24. package/dist/cjs/vaults/index.cjs.map +1 -0
  25. package/dist/cjs/viem/index.cjs +1 -1
  26. package/dist/cjs/viem/index.cjs.map +1 -1
  27. package/dist/cjs/wrapped-token.cjs +2 -0
  28. package/dist/cjs/wrapped-token.cjs.map +1 -0
  29. package/dist/cjs/wrappers-registry.cjs +1 -1
  30. package/dist/cjs/wrappers-registry.cjs.map +1 -1
  31. package/dist/esm/base-signer-D5Cwv7yb.js +2 -0
  32. package/dist/esm/base-signer-D5Cwv7yb.js.map +1 -0
  33. package/dist/esm/{base-signer-S2Ogf6L4.d.ts → base-signer-DIYZwDnc.d.ts} +2 -2
  34. package/dist/esm/chains/index.d.ts +1 -1
  35. package/dist/esm/chains/index.js +1 -1
  36. package/dist/esm/chains-ByyCdrrd.js +2 -0
  37. package/dist/esm/chains-ByyCdrrd.js.map +1 -0
  38. package/dist/esm/cleartext/index.d.ts +2 -2
  39. package/dist/esm/cleartext/index.js +1 -1
  40. package/dist/esm/{cleartext-pv2blbFU.d.ts → cleartext-3HOk1BAg.d.ts} +2 -2
  41. package/dist/esm/{cleartext-DcbDCDXj.js → cleartext-PCpNqRGV.js} +2 -2
  42. package/dist/esm/{cleartext-DcbDCDXj.js.map → cleartext-PCpNqRGV.js.map} +1 -1
  43. package/dist/esm/encrypt.worker.js +51 -51
  44. package/dist/esm/{encryption-DJljZ2oV.js → encryption-BKoalB4o.js} +2 -2
  45. package/dist/esm/{encryption-DJljZ2oV.js.map → encryption-BKoalB4o.js.map} +1 -1
  46. package/dist/esm/erc165-DbMOt-s6.js +2 -0
  47. package/dist/esm/erc165-DbMOt-s6.js.map +1 -0
  48. package/dist/esm/ethers/index.d.ts +5 -5
  49. package/dist/esm/ethers/index.js +1 -1
  50. package/dist/esm/ethers/index.js.map +1 -1
  51. package/dist/esm/fhevm-relayer-CtrnKjJf.js +8 -0
  52. package/dist/esm/fhevm-relayer-CtrnKjJf.js.map +1 -0
  53. package/dist/esm/{index-tfvbrVa2.d.ts → index-BHrjck_q.d.ts} +4 -4
  54. package/dist/esm/{index-DRrrBtMX.d.ts → index-DJYq1rAB.d.ts} +989 -1874
  55. package/dist/esm/{index-Gk1S0gjO.d.ts → index-ijgDL4IC.d.ts} +1 -14
  56. package/dist/esm/index.d.ts +8 -108
  57. package/dist/esm/index.js +1 -1
  58. package/dist/esm/index.js.map +1 -1
  59. package/dist/esm/invalidation-BgFjmXeQ.js +2 -0
  60. package/dist/esm/invalidation-BgFjmXeQ.js.map +1 -0
  61. package/dist/esm/invalidation-CJ-pzOUG.d.ts +46 -0
  62. package/dist/esm/node/index.d.ts +4 -4
  63. package/dist/esm/node/index.js +1 -1
  64. package/dist/esm/primitives-Cym-3HKa.js +2 -0
  65. package/dist/esm/primitives-Cym-3HKa.js.map +1 -0
  66. package/dist/esm/query/index.d.ts +495 -4
  67. package/dist/esm/query/index.js +1 -1
  68. package/dist/esm/query/index.js.map +1 -1
  69. package/dist/esm/relayer-CVKO9GmQ.js +2 -0
  70. package/dist/esm/relayer-CVKO9GmQ.js.map +1 -0
  71. package/dist/esm/token-CRJ8eCr7.js +2 -0
  72. package/dist/esm/token-CRJ8eCr7.js.map +1 -0
  73. package/dist/esm/{types-BOyFfG7D.d.ts → types-Bz5-wHPv.d.ts} +23 -43
  74. package/dist/esm/{types-BRIpBy9n.d.ts → types-CI6BtpB7.d.ts} +3 -3
  75. package/dist/esm/{types-OXQqX_kH.d.ts → types-v0_sfkli.d.ts} +3 -3
  76. package/dist/esm/{validation-DWe2k89s.js → validation-BRu06AM_.js} +2 -2
  77. package/dist/esm/{validation-DWe2k89s.js.map → validation-BRu06AM_.js.map} +1 -1
  78. package/dist/esm/vaults/index.d.ts +13833 -0
  79. package/dist/esm/vaults/index.js +2 -0
  80. package/dist/esm/vaults/index.js.map +1 -0
  81. package/dist/esm/viem/index.d.ts +5 -5
  82. package/dist/esm/viem/index.js +1 -1
  83. package/dist/esm/viem/index.js.map +1 -1
  84. package/dist/esm/web/index.d.ts +1 -1
  85. package/dist/esm/web/index.js +1 -1
  86. package/dist/esm/wrapped-token-BOtzaSAY.js +2 -0
  87. package/dist/esm/wrapped-token-BOtzaSAY.js.map +1 -0
  88. package/dist/esm/wrappers-registry-Cm3JJeqx.js +2 -0
  89. package/dist/esm/wrappers-registry-Cm3JJeqx.js.map +1 -0
  90. package/package.json +19 -5
  91. package/dist/esm/base-signer--sBO2qJp.js +0 -2
  92. package/dist/esm/base-signer--sBO2qJp.js.map +0 -1
  93. package/dist/esm/chains-DEpKup1n.js +0 -2
  94. package/dist/esm/chains-DEpKup1n.js.map +0 -1
  95. package/dist/esm/fhevm-relayer-CPmCytDX.js +0 -8
  96. package/dist/esm/fhevm-relayer-CPmCytDX.js.map +0 -1
  97. package/dist/esm/relayer-B6Zo6EkX.js +0 -2
  98. package/dist/esm/relayer-B6Zo6EkX.js.map +0 -1
  99. package/dist/esm/token-BMQ6xlrk.js +0 -2
  100. package/dist/esm/token-BMQ6xlrk.js.map +0 -1
  101. package/dist/esm/wrappers-registry-BfQr2QHn.js +0 -2
  102. package/dist/esm/wrappers-registry-BfQr2QHn.js.map +0 -1
@@ -0,0 +1,2 @@
1
+ import{getAddress as e}from"viem";import{z as t}from"zod/mini";function n(e){if(!r(e))return!1;let t=e.constructor;if(t===void 0)return!0;let n=t.prototype;return!(!r(n)||!n.hasOwnProperty(`isPrototypeOf`))}function r(e){return Object.prototype.toString.call(e)===`[object Object]`}function i(e){let{gcTime:t,staleTime:n,enabled:r,select:i,refetchInterval:a,refetchOnMount:o,refetchOnWindowFocus:s,refetchOnReconnect:c,retry:l,retryDelay:u,retryOnMount:d,queryFn:f,queryKey:p,queryKeyHashFn:m,initialData:h,initialDataUpdatedAt:g,placeholderData:_,structuralSharing:v,throwOnError:y,meta:b,query:x,pollingInterval:S,...C}=e;return C}function a(e){return JSON.stringify(e,(e,t)=>n(t)?Object.keys(t).sort().reduce((e,n)=>(e[n]=t[n],e),{}):typeof t==`bigint`?t.toString():t)}const o=t=>t.map(t=>e(t)),s=t=>t===void 0?void 0:e(t),c=t=>t?{walletAddress:e(t.address),walletChainId:t.chainId}:{},l={confidentialBalance:{all:[`zama.confidentialBalance`],token:t=>[`zama.confidentialBalance`,{tokenAddress:e(t)}],owner:(t,n,r)=>[`zama.confidentialBalance`,{tokenAddress:e(t),...c(r),...n?{owner:e(n)}:{}}]},confidentialBalances:{all:[`zama.confidentialBalances`],tokens:(t,n,r)=>[`zama.confidentialBalances`,{tokenAddresses:o(t),...c(r),...n?{owner:e(n)}:{}}]},tokenMetadata:{all:[`zama.tokenMetadata`],token:t=>[`zama.tokenMetadata`,{tokenAddress:e(t)}]},isConfidential:{all:[`zama.isConfidential`],token:t=>[`zama.isConfidential`,{tokenAddress:e(t)}]},isWrapper:{all:[`zama.isWrapper`],token:t=>[`zama.isWrapper`,{tokenAddress:e(t)}]},wrapperDiscovery:{all:[`zama.wrapperDiscovery`],token:(e,t,n)=>{let r=s(e),i=s(t),a=s(n);return[`zama.wrapperDiscovery`,{...r?{tokenAddress:r}:{},...i?{erc20Address:i}:{},...a?{registryAddress:a}:{}}]}},underlyingAllowance:{all:[`zama.underlyingAllowance`],token:t=>[`zama.underlyingAllowance`,{tokenAddress:e(t)}],scope:(t,n)=>[`zama.underlyingAllowance`,{tokenAddress:e(t),...n?{owner:e(n)}:{}}]},confidentialIsOperator:{all:[`zama.confidentialIsOperator`],token:e=>{let t=s(e);return[`zama.confidentialIsOperator`,t?{tokenAddress:t}:{}]},scope:(e,t,n)=>{let r=s(e),i=s(t),a=s(n);return[`zama.confidentialIsOperator`,{...r?{tokenAddress:r}:{},...i?{holder:i}:{},...a?{spender:a}:{}}]}},totalSupply:{all:[`zama.totalSupply`],token:t=>[`zama.totalSupply`,{tokenAddress:e(t)}]},pendingUnshield:{all:[`zama.pendingUnshield`],token:t=>[`zama.pendingUnshield`,{tokenAddress:e(t)}]},hasPermit:{all:[`zama.hasPermit`],scope:(e,t)=>[`zama.hasPermit`,{...c(t),contractAddresses:o(e).sort()}]},delegationStatus:{all:[`zama.delegationStatus`],contract:e=>{let t=s(e);return[`zama.delegationStatus`,t?{contractAddress:t}:{}]},scope:(e,t,n)=>{let r=s(e),i=s(t),a=s(n);return[`zama.delegationStatus`,{...r?{contractAddress:r}:{},...i?{delegatorAddress:i}:{},...a?{delegateAddress:a}:{}}]}},decryption:{all:[`zama.decryption`],encryptedValue:(t,n)=>[`zama.decryption`,{encryptedValue:t,...n===void 0?{}:{contractAddress:e(n)}}],encryptedInputs:(t,n)=>[`zama.decryption`,{...c(n),encryptedInputs:[...t].sort((e,t)=>e.encryptedValue.localeCompare(t.encryptedValue)).map(t=>({encryptedValue:t.encryptedValue,contractAddress:e(t.contractAddress)}))}]},wrappersRegistry:{all:[`zama.wrappersRegistry`],chainId:()=>[`zama.wrappersRegistry`,{type:`chainId`}],tokenPairs:t=>[`zama.wrappersRegistry`,{type:`tokenPairs`,registryAddress:e(t)}],confidentialTokenAddress:(t,n)=>[`zama.wrappersRegistry`,{type:`confidentialTokenAddress`,registryAddress:e(t),tokenAddress:e(n)}],tokenAddress:(t,n)=>[`zama.wrappersRegistry`,{type:`tokenAddress`,registryAddress:e(t),confidentialTokenAddress:e(n)}],tokenPairsLength:t=>[`zama.wrappersRegistry`,{type:`tokenPairsLength`,registryAddress:e(t)}],tokenPairsSlice:(t,n,r)=>[`zama.wrappersRegistry`,{type:`tokenPairsSlice`,registryAddress:e(t),fromIndex:n,toIndex:r}],tokenPair:(t,n)=>[`zama.wrappersRegistry`,{type:`tokenPair`,registryAddress:e(t),index:n}],isConfidentialTokenValid:(t,n)=>[`zama.wrappersRegistry`,{type:`isConfidentialTokenValid`,registryAddress:e(t),confidentialTokenAddress:e(n)}],listPairs:(t,n,r,i)=>[`zama.wrappersRegistry`,{type:`listPairs`,registryAddress:e(t),page:n,pageSize:r,metadata:i}]}};function u(e,t){e.invalidateQueries({queryKey:l.underlyingAllowance.token(t)})}function d(e,t){e.invalidateQueries({queryKey:l.pendingUnshield.token(t)})}function f(e,t){m(e,t),u(e,t),d(e,t),D(e)}function p(e,t){m(e,t),u(e,t),D(e)}function m(e,t){e.invalidateQueries({queryKey:l.confidentialBalance.token(t)}),e.invalidateQueries({queryKey:l.confidentialBalances.all})}function h(e,t){m(e,t),u(e,t),D(e)}function g(e,t){m(e,t),u(e,t),d(e,t),D(e)}function _(e,t){d(e,t)}function v(e,t){m(e,t)}function y(e,t){u(e,t)}function b(e,t){e.invalidateQueries({queryKey:l.confidentialIsOperator.token(t)})}function x(e){return Array.isArray(e.queryKey)&&typeof e.queryKey[0]==`string`?e.queryKey[0].startsWith(`zama.`):!1}const S=t.enum([`balanceOf`,`confidentialBalanceOf`]),C=t.object({functionName:S}),w=t.object({contracts:t.array(t.unknown())});function T(e){if(C.safeParse(e).success)return!0;let t=w.safeParse(e);return t.success&&t.data.contracts.some(e=>C.safeParse(e).success)}function E(e){return Array.isArray(e.queryKey)&&e.queryKey.some(T)}function D(e){e.invalidateQueries({predicate:E})}function O(e){e.removeQueries({queryKey:l.decryption.all}),e.removeQueries({queryKey:l.hasPermit.all}),e.invalidateQueries({predicate:x}),D(e)}export{g as a,p as c,O as d,l as f,v as i,m as l,a as m,b as n,_ as o,i as p,h as r,f as s,y as t,D as u};
2
+ //# sourceMappingURL=invalidation-BgFjmXeQ.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"invalidation-BgFjmXeQ.js","names":[],"sources":["../../src/query/utils.ts","../../src/query/query-keys.ts","../../src/query/invalidation.ts"],"sourcesContent":["// Adapted from the wagmi codebase\n// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-wrapper-object-types\nfunction isPlainObject(value: any): value is Object {\n if (!hasObjectPrototype(value)) {\n return false;\n }\n\n // If has modified constructor\n const ctor = value.constructor;\n if (ctor === undefined) {\n return true;\n }\n\n // If has modified prototype\n const prot = ctor.prototype;\n if (!hasObjectPrototype(prot)) {\n return false;\n }\n\n // If constructor does not have an Object-specific method\n // eslint-disable-next-line no-prototype-builtins\n if (!prot.hasOwnProperty(\"isPrototypeOf\")) {\n return false;\n }\n\n // Most likely a plain Object\n return true;\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nfunction hasObjectPrototype(o: any): boolean {\n return Object.prototype.toString.call(o) === \"[object Object]\";\n}\n\n/** Union of TanStack Query option keys stripped by {@link filterQueryOptions}, leaving only domain parameters. */\nexport type StrippedQueryOptionKeys =\n // Keep this union aligned with @tanstack/query-core behavioral options\n // (for example QueryObserverOptions). Revisit on every upgrade to avoid\n // leaking query controls into lower-level query factories.\n | \"gcTime\"\n | \"staleTime\"\n | \"enabled\"\n | \"select\"\n | \"refetchInterval\"\n | \"refetchOnMount\"\n | \"refetchOnWindowFocus\"\n | \"refetchOnReconnect\"\n | \"retry\"\n | \"retryDelay\"\n | \"retryOnMount\"\n | \"queryFn\"\n | \"queryKey\"\n | \"queryKeyHashFn\"\n | \"initialData\"\n | \"initialDataUpdatedAt\"\n | \"placeholderData\"\n | \"structuralSharing\"\n | \"throwOnError\"\n | \"meta\"\n | \"query\"\n | \"pollingInterval\";\n\n/**\n * Remove TanStack behavioral options from a query config object so only domain\n * parameters remain for the lower-level factory.\n *\n * @example\n * ```ts\n * const params = filterQueryOptions({\n * query: { enabled: false },\n * gcTime: 60_000,\n * owner: \"0xabc\",\n * });\n * // => { owner: \"0xabc\" }\n * ```\n */\nexport function filterQueryOptions<TOptions extends Record<string, unknown>>(\n options: TOptions,\n): Omit<TOptions, StrippedQueryOptionKeys> {\n const {\n gcTime: _gcTime,\n staleTime: _staleTime,\n enabled: _enabled,\n select: _select,\n refetchInterval: _refetchInterval,\n refetchOnMount: _refetchOnMount,\n refetchOnWindowFocus: _refetchOnWindowFocus,\n refetchOnReconnect: _refetchOnReconnect,\n retry: _retry,\n retryDelay: _retryDelay,\n retryOnMount: _retryOnMount,\n queryFn: _queryFn,\n queryKey: _queryKey,\n queryKeyHashFn: _queryKeyHashFn,\n initialData: _initialData,\n initialDataUpdatedAt: _initialDataUpdatedAt,\n placeholderData: _placeholderData,\n structuralSharing: _structuralSharing,\n throwOnError: _throwOnError,\n meta: _meta,\n query: _query,\n pollingInterval: _pollingInterval,\n ...rest\n } = options;\n\n return rest;\n}\n\n/**\n * Stable hash function for query keys.\n * Sorts object keys recursively and converts bigint values to strings.\n *\n * @remarks\n * bigint values are serialized as decimal strings, so `42n` and `\"42\"` hash to\n * the same token when they occupy the same position. This collision is accepted\n * by design for the current query-key conventions in this package.\n */\nexport function hashFn(queryKey: readonly unknown[]): string {\n return JSON.stringify(queryKey, (_, value) => {\n if (isPlainObject(value)) {\n return Object.keys(value)\n .sort()\n .reduce(\n (result, key) => {\n result[key] = value[key];\n return result;\n },\n {} as Record<string, unknown>,\n );\n }\n\n if (typeof value === \"bigint\") {\n return value.toString();\n }\n\n return value;\n });\n}\n","import { getAddress } from \"viem\";\nimport type { Address, Hex } from \"viem\";\nimport type { WalletAccount } from \"../types\";\n\nconst normalizeAddresses = (addresses: Address[]): Address[] =>\n addresses.map((address) => getAddress(address));\nconst normalizeAddress = (address?: Address): Address | undefined =>\n address === undefined ? undefined : getAddress(address);\nconst walletAccountKey = (walletAccount?: WalletAccount) =>\n walletAccount\n ? { walletAddress: getAddress(walletAccount.address), walletChainId: walletAccount.chainId }\n : {};\n\n/**\n * Canonical query-key namespace for `@zama-fhe/sdk/query`.\n *\n * @example\n * ```ts\n * queryClient.invalidateQueries({\n * queryKey: zamaQueryKeys.confidentialBalance.token(\"0xToken\"),\n * });\n * ```\n */\nexport const zamaQueryKeys = {\n confidentialBalance: {\n all: [\"zama.confidentialBalance\"] as const,\n token: (tokenAddress: Address) =>\n [\"zama.confidentialBalance\", { tokenAddress: getAddress(tokenAddress) }] as const,\n owner: (tokenAddress: Address, owner?: Address, walletAccount?: WalletAccount) =>\n [\n \"zama.confidentialBalance\",\n {\n tokenAddress: getAddress(tokenAddress),\n ...walletAccountKey(walletAccount),\n ...(owner ? { owner: getAddress(owner) } : {}),\n },\n ] as const,\n },\n\n confidentialBalances: {\n all: [\"zama.confidentialBalances\"] as const,\n tokens: (tokenAddresses: Address[], owner?: Address, walletAccount?: WalletAccount) =>\n [\n \"zama.confidentialBalances\",\n {\n tokenAddresses: normalizeAddresses(tokenAddresses),\n ...walletAccountKey(walletAccount),\n ...(owner ? { owner: getAddress(owner) } : {}),\n },\n ] as const,\n },\n\n tokenMetadata: {\n all: [\"zama.tokenMetadata\"] as const,\n token: (tokenAddress: Address) =>\n [\"zama.tokenMetadata\", { tokenAddress: getAddress(tokenAddress) }] as const,\n },\n\n isConfidential: {\n all: [\"zama.isConfidential\"] as const,\n token: (tokenAddress: Address) =>\n [\"zama.isConfidential\", { tokenAddress: getAddress(tokenAddress) }] as const,\n },\n\n isWrapper: {\n all: [\"zama.isWrapper\"] as const,\n token: (tokenAddress: Address) =>\n [\"zama.isWrapper\", { tokenAddress: getAddress(tokenAddress) }] as const,\n },\n\n wrapperDiscovery: {\n all: [\"zama.wrapperDiscovery\"] as const,\n token: (tokenAddress?: Address, erc20Address?: Address, registryAddress?: Address) => {\n const t = normalizeAddress(tokenAddress);\n const e = normalizeAddress(erc20Address);\n const r = normalizeAddress(registryAddress);\n return [\n \"zama.wrapperDiscovery\",\n {\n ...(t ? { tokenAddress: t } : {}),\n ...(e ? { erc20Address: e } : {}),\n ...(r ? { registryAddress: r } : {}),\n },\n ] as const;\n },\n },\n\n underlyingAllowance: {\n all: [\"zama.underlyingAllowance\"] as const,\n token: (tokenAddress: Address) =>\n [\"zama.underlyingAllowance\", { tokenAddress: getAddress(tokenAddress) }] as const,\n scope: (tokenAddress: Address, owner?: Address) =>\n [\n \"zama.underlyingAllowance\",\n { tokenAddress: getAddress(tokenAddress), ...(owner ? { owner: getAddress(owner) } : {}) },\n ] as const,\n },\n\n confidentialIsOperator: {\n all: [\"zama.confidentialIsOperator\"] as const,\n token: (tokenAddress?: Address) => {\n const t = normalizeAddress(tokenAddress);\n return [\"zama.confidentialIsOperator\", t ? { tokenAddress: t } : {}] as const;\n },\n scope: (tokenAddress?: Address, holder?: Address, spender?: Address) => {\n const t = normalizeAddress(tokenAddress);\n const h = normalizeAddress(holder);\n const s = normalizeAddress(spender);\n return [\n \"zama.confidentialIsOperator\",\n {\n ...(t ? { tokenAddress: t } : {}),\n ...(h ? { holder: h } : {}),\n ...(s ? { spender: s } : {}),\n },\n ] as const;\n },\n },\n\n totalSupply: {\n all: [\"zama.totalSupply\"] as const,\n token: (tokenAddress: Address) =>\n [\"zama.totalSupply\", { tokenAddress: getAddress(tokenAddress) }] as const,\n },\n\n pendingUnshield: {\n all: [\"zama.pendingUnshield\"] as const,\n token: (tokenAddress: Address) =>\n [\"zama.pendingUnshield\", { tokenAddress: getAddress(tokenAddress) }] as const,\n },\n\n hasPermit: {\n all: [\"zama.hasPermit\"] as const,\n scope: (contractAddresses: Address[], walletAccount?: WalletAccount) =>\n [\n \"zama.hasPermit\",\n {\n ...walletAccountKey(walletAccount),\n contractAddresses: normalizeAddresses(contractAddresses).sort(),\n },\n ] as const,\n },\n\n delegationStatus: {\n all: [\"zama.delegationStatus\"] as const,\n contract: (contractAddress?: Address) => {\n const t = normalizeAddress(contractAddress);\n return [\"zama.delegationStatus\", t ? { contractAddress: t } : {}] as const;\n },\n scope: (contractAddress?: Address, delegator?: Address, delegate?: Address) => {\n const t = normalizeAddress(contractAddress);\n const dr = normalizeAddress(delegator);\n const de = normalizeAddress(delegate);\n return [\n \"zama.delegationStatus\",\n {\n ...(t ? { contractAddress: t } : {}),\n ...(dr ? { delegatorAddress: dr } : {}),\n ...(de ? { delegateAddress: de } : {}),\n },\n ] as const;\n },\n },\n\n decryption: {\n all: [\"zama.decryption\"] as const,\n encryptedValue: (encryptedValue: string, contractAddress?: Address) =>\n [\n \"zama.decryption\",\n {\n encryptedValue,\n ...(contractAddress === undefined\n ? {}\n : { contractAddress: getAddress(contractAddress) }),\n },\n ] as const,\n encryptedInputs: (\n encryptedInputs: readonly { encryptedValue: string; contractAddress: Address }[],\n walletAccount?: WalletAccount,\n ) =>\n [\n \"zama.decryption\",\n {\n ...walletAccountKey(walletAccount),\n encryptedInputs: [...encryptedInputs]\n .sort((a, b) => a.encryptedValue.localeCompare(b.encryptedValue))\n .map((h) => ({\n encryptedValue: h.encryptedValue as Hex,\n contractAddress: getAddress(h.contractAddress),\n })),\n },\n ] as const,\n },\n\n wrappersRegistry: {\n all: [\"zama.wrappersRegistry\"] as const,\n chainId: () => [\"zama.wrappersRegistry\", { type: \"chainId\" }] as const,\n tokenPairs: (registryAddress: Address) =>\n [\n \"zama.wrappersRegistry\",\n { type: \"tokenPairs\", registryAddress: getAddress(registryAddress) },\n ] as const,\n confidentialTokenAddress: (registryAddress: Address, tokenAddress: Address) =>\n [\n \"zama.wrappersRegistry\",\n {\n type: \"confidentialTokenAddress\",\n registryAddress: getAddress(registryAddress),\n tokenAddress: getAddress(tokenAddress),\n },\n ] as const,\n tokenAddress: (registryAddress: Address, confidentialTokenAddress: Address) =>\n [\n \"zama.wrappersRegistry\",\n {\n type: \"tokenAddress\",\n registryAddress: getAddress(registryAddress),\n confidentialTokenAddress: getAddress(confidentialTokenAddress),\n },\n ] as const,\n tokenPairsLength: (registryAddress: Address) =>\n [\n \"zama.wrappersRegistry\",\n { type: \"tokenPairsLength\", registryAddress: getAddress(registryAddress) },\n ] as const,\n tokenPairsSlice: (registryAddress: Address, fromIndex: string, toIndex: string) =>\n [\n \"zama.wrappersRegistry\",\n {\n type: \"tokenPairsSlice\",\n registryAddress: getAddress(registryAddress),\n fromIndex,\n toIndex,\n },\n ] as const,\n tokenPair: (registryAddress: Address, index: string) =>\n [\n \"zama.wrappersRegistry\",\n { type: \"tokenPair\", registryAddress: getAddress(registryAddress), index },\n ] as const,\n isConfidentialTokenValid: (registryAddress: Address, confidentialTokenAddress: Address) =>\n [\n \"zama.wrappersRegistry\",\n {\n type: \"isConfidentialTokenValid\",\n registryAddress: getAddress(registryAddress),\n confidentialTokenAddress: getAddress(confidentialTokenAddress),\n },\n ] as const,\n listPairs: (registryAddress: Address, page: number, pageSize: number, metadata: boolean) =>\n [\n \"zama.wrappersRegistry\",\n {\n type: \"listPairs\",\n registryAddress: getAddress(registryAddress),\n page,\n pageSize,\n metadata,\n },\n ] as const,\n },\n} as const;\n","import type { Address } from \"viem\";\nimport { z } from \"zod/mini\";\nimport { zamaQueryKeys } from \"./query-keys\";\n\n/** Minimal query shape read by the invalidation predicates. */\nexport interface QueryLike {\n /** The query's cache key. */\n queryKey: readonly unknown[];\n}\n\n/** Minimal filter shape accepted by the invalidation helpers, matching TanStack Query's `QueryFilters`. */\nexport interface QueryFilterLike {\n /** Match queries whose key starts with this prefix. */\n queryKey?: readonly unknown[];\n /** Match queries for which this returns `true`. */\n predicate?: (query: QueryLike) => boolean;\n}\n\n/** Minimal `QueryClient` surface used by the invalidation helpers. */\nexport interface QueryClientLike {\n /** Mark matching queries stale so they refetch. */\n invalidateQueries(filters: QueryFilterLike): void | Promise<void>;\n /** Remove matching queries from the cache entirely. */\n removeQueries(filters: QueryFilterLike): void;\n}\n\nfunction invalidateUnderlyingAllowanceQueries(\n queryClient: QueryClientLike,\n tokenAddress: Address,\n): void {\n void queryClient.invalidateQueries({\n queryKey: zamaQueryKeys.underlyingAllowance.token(tokenAddress),\n });\n}\n\nfunction invalidatePendingUnshieldQueries(\n queryClient: QueryClientLike,\n tokenAddress: Address,\n): void {\n void queryClient.invalidateQueries({\n queryKey: zamaQueryKeys.pendingUnshield.token(tokenAddress),\n });\n}\n\n/** Invalidates the caches affected by an unwrap: confidential balances, underlying allowance, and pending unshields. */\nexport function invalidateAfterUnwrap(queryClient: QueryClientLike, tokenAddress: Address): void {\n invalidateBalanceQueries(queryClient, tokenAddress);\n invalidateUnderlyingAllowanceQueries(queryClient, tokenAddress);\n invalidatePendingUnshieldQueries(queryClient, tokenAddress);\n invalidateWagmiBalanceQueries(queryClient);\n}\n\n/** Invalidates the caches affected by a wrap: confidential balances and underlying allowance. */\nexport function invalidateAfterWrap(queryClient: QueryClientLike, tokenAddress: Address): void {\n invalidateBalanceQueries(queryClient, tokenAddress);\n invalidateUnderlyingAllowanceQueries(queryClient, tokenAddress);\n invalidateWagmiBalanceQueries(queryClient);\n}\n\n/** Invalidates the confidential balance queries for a token (single-token and batched). */\nexport function invalidateBalanceQueries(\n queryClient: QueryClientLike,\n tokenAddress: Address,\n): void {\n void queryClient.invalidateQueries({\n queryKey: zamaQueryKeys.confidentialBalance.token(tokenAddress),\n });\n void queryClient.invalidateQueries({ queryKey: zamaQueryKeys.confidentialBalances.all });\n}\n\n/** Invalidates the caches affected by a shield: confidential balances and underlying allowance. */\nexport function invalidateAfterShield(queryClient: QueryClientLike, tokenAddress: Address): void {\n invalidateBalanceQueries(queryClient, tokenAddress);\n invalidateUnderlyingAllowanceQueries(queryClient, tokenAddress);\n invalidateWagmiBalanceQueries(queryClient);\n}\n\n/** Invalidates the caches affected by an unshield request: confidential balances, underlying allowance, and pending unshields. */\nexport function invalidateAfterUnshield(queryClient: QueryClientLike, tokenAddress: Address): void {\n invalidateBalanceQueries(queryClient, tokenAddress);\n invalidateUnderlyingAllowanceQueries(queryClient, tokenAddress);\n invalidatePendingUnshieldQueries(queryClient, tokenAddress);\n invalidateWagmiBalanceQueries(queryClient);\n}\n\n/** Invalidates the pending-unshield cache once an unshield has settled on-chain. */\nexport function invalidateAfterUnshieldSettled(\n queryClient: QueryClientLike,\n tokenAddress: Address,\n): void {\n invalidatePendingUnshieldQueries(queryClient, tokenAddress);\n}\n\n/** Invalidates the confidential balance caches affected by a transfer. */\nexport function invalidateAfterTransfer(queryClient: QueryClientLike, tokenAddress: Address): void {\n invalidateBalanceQueries(queryClient, tokenAddress);\n}\n\n/** Invalidates the underlying-allowance cache after approving the underlying ERC-20. */\nexport function invalidateAfterApproveUnderlying(\n queryClient: QueryClientLike,\n tokenAddress: Address,\n): void {\n invalidateUnderlyingAllowanceQueries(queryClient, tokenAddress);\n}\n\n/** Invalidates the operator-status cache after changing a token operator. */\nexport function invalidateAfterSetOperator(\n queryClient: QueryClientLike,\n tokenAddress: Address,\n): void {\n void queryClient.invalidateQueries({\n queryKey: zamaQueryKeys.confidentialIsOperator.token(tokenAddress),\n });\n}\n\nfunction isZamaQuery(query: QueryLike): boolean {\n return Array.isArray(query.queryKey) && typeof query.queryKey[0] === \"string\"\n ? query.queryKey[0].startsWith(\"zama.\")\n : false;\n}\n\nconst balanceFunctionName = z.enum([\"balanceOf\", \"confidentialBalanceOf\"]);\n\nconst balanceReadArgs = z.object({ functionName: balanceFunctionName });\n\nconst batchedReadArgs = z.object({ contracts: z.array(z.unknown()) });\n\nfunction isBalanceReadPart(part: unknown): boolean {\n if (balanceReadArgs.safeParse(part).success) {\n return true;\n }\n const batched = batchedReadArgs.safeParse(part);\n return (\n batched.success && batched.data.contracts.some((c) => balanceReadArgs.safeParse(c).success)\n );\n}\n\nfunction isWagmiBalanceQuery(query: QueryLike): boolean {\n return Array.isArray(query.queryKey) && query.queryKey.some(isBalanceReadPart);\n}\n\n/** Invalidates any wagmi `useBalance`/`readContract` balance queries so ERC-20 balances refresh. */\nexport function invalidateWagmiBalanceQueries(queryClient: QueryClientLike): void {\n void queryClient.invalidateQueries({ predicate: isWagmiBalanceQuery });\n}\n\n/** Clears wallet-local caches (decryption, permits) and invalidates all Zama queries — call on wallet connect/disconnect so a stale entitlement can't leak across accounts. */\nexport function invalidateWalletLifecycleQueries(queryClient: QueryClientLike): void {\n // Remove (not just invalidate) wallet-local caches so a stale allowed/true\n // cannot surface between wallet disconnect and the next refetch.\n queryClient.removeQueries({ queryKey: zamaQueryKeys.decryption.all });\n queryClient.removeQueries({ queryKey: zamaQueryKeys.hasPermit.all });\n void queryClient.invalidateQueries({ predicate: isZamaQuery });\n invalidateWagmiBalanceQueries(queryClient);\n}\n"],"mappings":"+DAEA,SAAS,EAAc,EAA6B,CAClD,GAAI,CAAC,EAAmB,CAAK,EAC3B,MAAO,GAIT,IAAM,EAAO,EAAM,YACnB,GAAI,IAAS,IAAA,GACX,MAAO,GAIT,IAAM,EAAO,EAAK,UAYlB,MALA,EANI,CAAC,EAAmB,CAAI,GAMxB,CAAC,EAAK,eAAe,eAAe,EAM1C,CAGA,SAAS,EAAmB,EAAiB,CAC3C,OAAO,OAAO,UAAU,SAAS,KAAK,CAAC,IAAM,iBAC/C,CA4CA,SAAgB,EACd,EACyC,CACzC,GAAM,CACJ,OAAQ,EACR,UAAW,EACX,QAAS,EACT,OAAQ,EACR,gBAAiB,EACjB,eAAgB,EAChB,qBAAsB,EACtB,mBAAoB,EACpB,MAAO,EACP,WAAY,EACZ,aAAc,EACd,QAAS,EACT,SAAU,EACV,eAAgB,EAChB,YAAa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kB,EAAE,OAAO,CAAE,UAAW,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAE,CAAC,EAEpE,SAAS,EAAkB,EAAwB,CACjD,GAAI,EAAgB,UAAU,CAAI,CAAC,CAAC,QAClC,MAAO,GAET,IAAM,EAAU,EAAgB,UAAU,CAAI,EAC9C,OACE,EAAQ,SAAW,EAAQ,KAAK,UAAU,KAAM,GAAM,EAAgB,UAAU,CAAC,CAAC,CAAC,OAAO,CAE9F,CAEA,SAAS,EAAoB,EAA2B,CACtD,OAAO,MAAM,QAAQ,EAAM,QAAQ,GAAK,EAAM,SAAS,KAAK,CAAiB,CAC/E,CAGA,SAAgB,EAA8B,EAAoC,CAChF,EAAiB,kBAAkB,CAAE,UAAW,CAAoB,CAAC,CACvE,CAGA,SAAgB,EAAiC,EAAoC,CAGnF,EAAY,cAAc,CAAE,SAAU,EAAc,WAAW,GAAI,CAAC,EACpE,EAAY,cAAc,CAAE,SAAU,EAAc,UAAU,GAAI,CAAC,EACnE,EAAiB,kBAAkB,CAAE,UAAW,CAAY,CAAC,EAC7D,EAA8B,CAAW,CAC3C"}
@@ -0,0 +1,46 @@
1
+ import { Address } from "viem";
2
+ //#region src/query/invalidation.d.ts
3
+ /** Minimal query shape read by the invalidation predicates. */
4
+ interface QueryLike {
5
+ /** The query's cache key. */
6
+ queryKey: readonly unknown[];
7
+ }
8
+ /** Minimal filter shape accepted by the invalidation helpers, matching TanStack Query's `QueryFilters`. */
9
+ interface QueryFilterLike {
10
+ /** Match queries whose key starts with this prefix. */
11
+ queryKey?: readonly unknown[];
12
+ /** Match queries for which this returns `true`. */
13
+ predicate?: (query: QueryLike) => boolean;
14
+ }
15
+ /** Minimal `QueryClient` surface used by the invalidation helpers. */
16
+ interface QueryClientLike {
17
+ /** Mark matching queries stale so they refetch. */
18
+ invalidateQueries(filters: QueryFilterLike): void | Promise<void>;
19
+ /** Remove matching queries from the cache entirely. */
20
+ removeQueries(filters: QueryFilterLike): void;
21
+ }
22
+ /** Invalidates the caches affected by an unwrap: confidential balances, underlying allowance, and pending unshields. */
23
+ declare function invalidateAfterUnwrap(queryClient: QueryClientLike, tokenAddress: Address): void;
24
+ /** Invalidates the caches affected by a wrap: confidential balances and underlying allowance. */
25
+ declare function invalidateAfterWrap(queryClient: QueryClientLike, tokenAddress: Address): void;
26
+ /** Invalidates the confidential balance queries for a token (single-token and batched). */
27
+ declare function invalidateBalanceQueries(queryClient: QueryClientLike, tokenAddress: Address): void;
28
+ /** Invalidates the caches affected by a shield: confidential balances and underlying allowance. */
29
+ declare function invalidateAfterShield(queryClient: QueryClientLike, tokenAddress: Address): void;
30
+ /** Invalidates the caches affected by an unshield request: confidential balances, underlying allowance, and pending unshields. */
31
+ declare function invalidateAfterUnshield(queryClient: QueryClientLike, tokenAddress: Address): void;
32
+ /** Invalidates the pending-unshield cache once an unshield has settled on-chain. */
33
+ declare function invalidateAfterUnshieldSettled(queryClient: QueryClientLike, tokenAddress: Address): void;
34
+ /** Invalidates the confidential balance caches affected by a transfer. */
35
+ declare function invalidateAfterTransfer(queryClient: QueryClientLike, tokenAddress: Address): void;
36
+ /** Invalidates the underlying-allowance cache after approving the underlying ERC-20. */
37
+ declare function invalidateAfterApproveUnderlying(queryClient: QueryClientLike, tokenAddress: Address): void;
38
+ /** Invalidates the operator-status cache after changing a token operator. */
39
+ declare function invalidateAfterSetOperator(queryClient: QueryClientLike, tokenAddress: Address): void;
40
+ /** Invalidates any wagmi `useBalance`/`readContract` balance queries so ERC-20 balances refresh. */
41
+ declare function invalidateWagmiBalanceQueries(queryClient: QueryClientLike): void;
42
+ /** Clears wallet-local caches (decryption, permits) and invalidates all Zama queries — call on wallet connect/disconnect so a stale entitlement can't leak across accounts. */
43
+ declare function invalidateWalletLifecycleQueries(queryClient: QueryClientLike): void;
44
+ //#endregion
45
+ export { invalidateAfterSetOperator as a, invalidateAfterUnshield as c, invalidateAfterWrap as d, invalidateBalanceQueries as f, invalidateAfterApproveUnderlying as i, invalidateAfterUnshieldSettled as l, invalidateWalletLifecycleQueries as m, QueryFilterLike as n, invalidateAfterShield as o, invalidateWagmiBalanceQueries as p, QueryLike as r, invalidateAfterTransfer as s, QueryClientLike as t, invalidateAfterUnwrap as u };
46
+ //# sourceMappingURL=invalidation-CJ-pzOUG.d.ts.map
@@ -1,5 +1,5 @@
1
- import { a as hoodi, c as polygon, f as FheChain, i as hardhat, l as polygonAmoy, n as bscTestnet, o as ingenTestnet, p as FheChainAuth, r as chains, s as mainnet, t as anvil, u as sepolia } from "../index-Gk1S0gjO.js";
2
- import { an as EncryptParams, c as GenericStorage, dn as FhevmRuntimeConfig, en as ClearValue, fn as RelayerOptions, in as EncryptInput, ln as FhevmClientOptions, n as RelayerConfig, rn as EIP712TypedData, s as GenericLogger, sn as EncryptedValue, t as CleartextRelayerConfig, tn as DecryptPublicValuesResult, un as FhevmRelayerOptions } from "../types-BOyFfG7D.js";
3
- import { t as cleartext } from "../cleartext-pv2blbFU.js";
4
- import { i as node, n as asyncLocalStorage, r as NodeRelayerConfig, t as AsyncLocalMapStorage } from "../index-tfvbrVa2.js";
1
+ import { a as hoodi, c as polygon, f as FheChain, i as hardhat, l as polygonAmoy, n as bscTestnet, o as ingenTestnet, p as FheChainAuth, r as chains, s as mainnet, t as anvil, u as sepolia } from "../index-ijgDL4IC.js";
2
+ import { an as EncryptInput, c as GenericStorage, cn as EncryptedValue, dn as FhevmRelayerOptions, fn as FhevmRuntimeConfig, in as EIP712TypedData, n as RelayerConfig, nn as DecryptPublicValuesResult, on as EncryptParams, pn as RelayerOptions, s as GenericLogger, t as CleartextRelayerConfig, tn as ClearValue, un as FhevmClientOptions } from "../types-Bz5-wHPv.js";
3
+ import { t as cleartext } from "../cleartext-3HOk1BAg.js";
4
+ import { i as node, n as asyncLocalStorage, r as NodeRelayerConfig, t as AsyncLocalMapStorage } from "../index-BHrjck_q.js";
5
5
  export { AsyncLocalMapStorage, type ClearValue, type CleartextRelayerConfig, type DecryptPublicValuesResult, type EIP712TypedData, type EncryptInput, type EncryptParams, type EncryptedValue, type FheChain, type FheChainAuth, type FhevmClientOptions, type FhevmRelayerOptions, type FhevmRuntimeConfig, type GenericLogger, type GenericStorage, type NodeRelayerConfig, type RelayerConfig, type RelayerOptions, anvil, asyncLocalStorage, bscTestnet, chains, cleartext, hardhat, hoodi, ingenTestnet, mainnet, node, polygon, polygonAmoy, sepolia };
@@ -1,2 +1,2 @@
1
- import{t as e}from"../fhevm-relayer-CPmCytDX.js";import{t}from"../cleartext-DcbDCDXj.js";import{a as n,c as r,i,l as a,n as o,o as s,r as c,s as l,t as u,u as d}from"../chains-DEpKup1n.js";import{AsyncLocalStorage as f}from"node:async_hooks";function p(t){return{type:`node`,createRelayer:(n,r)=>new e({chain:n,options:t,logger:r})}}var m=class{#e=new f;run(e){return this.#e.run(new Map,e)}async get(e){return this.#e.getStore()?.get(e)??null}async set(e,t){this.#e.getStore()?.set(e,t)}async delete(e){this.#e.getStore()?.delete(e)}};const h=new m;export{m as AsyncLocalMapStorage,u as anvil,h as asyncLocalStorage,o as bscTestnet,c as chains,t as cleartext,i as hardhat,n as hoodi,s as ingenTestnet,l as mainnet,p as node,r as polygon,a as polygonAmoy,d as sepolia};
1
+ import{t as e}from"../fhevm-relayer-CtrnKjJf.js";import{t}from"../cleartext-PCpNqRGV.js";import{a as n,c as r,i,l as a,n as o,o as s,r as c,s as l,t as u,u as d}from"../chains-ByyCdrrd.js";import{AsyncLocalStorage as f}from"node:async_hooks";function p(t){return{type:`node`,createRelayer:(n,r)=>new e({chain:n,options:t,logger:r})}}var m=class{#e=new f;run(e){return this.#e.run(new Map,e)}async get(e){return this.#e.getStore()?.get(e)??null}async set(e,t){this.#e.getStore()?.set(e,t)}async delete(e){this.#e.getStore()?.delete(e)}};const h=new m;export{m as AsyncLocalMapStorage,u as anvil,h as asyncLocalStorage,o as bscTestnet,c as chains,t as cleartext,i as hardhat,n as hoodi,s as ingenTestnet,l as mainnet,p as node,r as polygon,a as polygonAmoy,d as sepolia};
2
2
  //# sourceMappingURL=index.js.map
@@ -0,0 +1,2 @@
1
+ import{getAddress as e,isAddress as t,isHex as n}from"viem";import{z as r}from"zod/mini";function i(t){return e(t)}const a=r.custom(e=>typeof e==`string`&&n(e,{strict:!0}),`expected 0x-prefixed hex string`),o=r.custom(e=>typeof e==`string`&&t(e,{strict:!1}),`expected EVM address`),s=r.pipe(o,r.transform(i)),c=r.int().check(r.nonnegative()),l=r.int().check(r.positive()),u=r.int().check(r.nonnegative()),d=r.int().check(r.positive());r.int().check(r.positive());export{d as a,u as i,s as n,l as o,a as r,c as s,i as t};
2
+ //# sourceMappingURL=primitives-Cym-3HKa.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"primitives-Cym-3HKa.js","names":[],"sources":["../../src/schemas/primitives.ts"],"sourcesContent":["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"],"mappings":"yFASA,SAAgB,EAAS,EAAoC,CAC3D,OAAO,EAAW,CAAK,CACzB,CAGA,MAAa,EAAM,EAAE,OAClB,GAAM,OAAO,GAAM,UAAY,EAAM,EAAG,CAAE,OAAQ,EAAK,CAAC,EACzD,iCACF,EAGa,EAAa,EAAE,OACzB,GAAM,OAAO,GAAM,UAAY,EAAU,EAAG,CAAE,OAAQ,EAAM,CAAC,EAC9D,sBACF,EAGa,EAAqB,EAAE,KAAK,EAAY,EAAE,UAAU,CAAQ,CAAC,EAG7D,EAAc,EAAE,IAAI,CAAC,CAAC,MAAM,EAAE,YAAY,CAAC,EAG3C,EAAkB,EAAE,IAAI,CAAC,CAAC,MAAM,EAAE,SAAS,CAAC,EAG5C,EAAqB,EAAE,IAAI,CAAC,CAAC,MAAM,EAAE,YAAY,CAAC,EAGlD,EAAe,EAAE,IAAI,CAAC,CAAC,MAAM,EAAE,SAAS,CAAC,EAG/B,EAAE,IAAI,CAAC,CAAC,MAAM,EAAE,SAAS,CAAC"}