@zama-fhe/sdk 3.7.1 → 3.8.0-beta.10

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 (127) 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/fatal-batch.cjs +2 -0
  8. package/dist/cjs/fatal-batch.cjs.map +1 -0
  9. package/dist/cjs/fhevm-relayer.cjs +1 -1
  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/internal/index.cjs +2 -0
  14. package/dist/cjs/internal/index.cjs.map +1 -0
  15. package/dist/cjs/invalidation.cjs +1 -1
  16. package/dist/cjs/invalidation.cjs.map +1 -1
  17. package/dist/cjs/node/index.cjs +1 -1
  18. package/dist/cjs/node/index.cjs.map +1 -1
  19. package/dist/cjs/query/index.cjs +1 -1
  20. package/dist/cjs/query/index.cjs.map +1 -1
  21. package/dist/cjs/relayer.cjs +1 -1
  22. package/dist/cjs/relayer.cjs.map +1 -1
  23. package/dist/cjs/signing.cjs +2 -0
  24. package/dist/cjs/signing.cjs.map +1 -0
  25. package/dist/cjs/telemetry.cjs +1 -1
  26. package/dist/cjs/telemetry.cjs.map +1 -1
  27. package/dist/cjs/token.cjs +1 -1
  28. package/dist/cjs/token.cjs.map +1 -1
  29. package/dist/cjs/typed-data.cjs +2 -0
  30. package/dist/cjs/typed-data.cjs.map +1 -0
  31. package/dist/cjs/vaults/index.cjs +1 -1
  32. package/dist/cjs/vaults/index.cjs.map +1 -1
  33. package/dist/cjs/viem/index.cjs +1 -1
  34. package/dist/cjs/viem/index.cjs.map +1 -1
  35. package/dist/cjs/web/index.cjs +1 -1
  36. package/dist/cjs/web/index.cjs.map +1 -1
  37. package/dist/cjs/wrapped-token.cjs +1 -1
  38. package/dist/cjs/wrapped-token.cjs.map +1 -1
  39. package/dist/cjs/wrappers-registry.cjs +1 -1
  40. package/dist/cjs/wrappers-registry.cjs.map +1 -1
  41. package/dist/esm/base-signer-BG19z5lh.js +2 -0
  42. package/dist/esm/base-signer-BG19z5lh.js.map +1 -0
  43. package/dist/esm/{base-signer-BxIDBDTF.d.ts → base-signer-CNqEVbj7.d.ts} +2 -2
  44. package/dist/esm/chains/index.d.ts +1 -1
  45. package/dist/esm/chains/index.js +1 -1
  46. package/dist/esm/chains-CefvVW4j.js +2 -0
  47. package/dist/esm/chains-CefvVW4j.js.map +1 -0
  48. package/dist/esm/cleartext/index.d.ts +2 -2
  49. package/dist/esm/cleartext/index.js +1 -1
  50. package/dist/esm/{cleartext-DBZq4E1O.js → cleartext-Bc7FpeXr.js} +2 -2
  51. package/dist/esm/{cleartext-DBZq4E1O.js.map → cleartext-Bc7FpeXr.js.map} +1 -1
  52. package/dist/esm/{cleartext-BnTAN4-g.d.ts → cleartext-BcM98zhR.d.ts} +2 -2
  53. package/dist/esm/encrypt-worker-client-9SUUIpLM.d.ts +19 -0
  54. package/dist/esm/{encryption-6AVd-82z.js → encryption-ieCO6J5r.js} +2 -2
  55. package/dist/esm/{encryption-6AVd-82z.js.map → encryption-ieCO6J5r.js.map} +1 -1
  56. package/dist/esm/ethers/index.d.ts +4 -4
  57. package/dist/esm/ethers/index.js +1 -1
  58. package/dist/esm/ethers/index.js.map +1 -1
  59. package/dist/esm/fatal-batch-CI1pes1q.js +2 -0
  60. package/dist/esm/fatal-batch-CI1pes1q.js.map +1 -0
  61. package/dist/esm/fhevm-relayer-tbPMdPw-.js +8 -0
  62. package/dist/esm/{fhevm-relayer-BEQ31nmT.js.map → fhevm-relayer-tbPMdPw-.js.map} +1 -1
  63. package/dist/esm/{index-BlY7CCPB.d.ts → index-BNA1OOfi.d.ts} +7 -7
  64. package/dist/esm/{index-CD2sMpst.d.ts → index-BwANiTpY.d.ts} +1421 -864
  65. package/dist/esm/{index-D1Wtji3m.d.ts → index-COgydmiZ.d.ts} +5 -2
  66. package/dist/esm/{index-fsWBYM8S.d.ts → index-DwwNymCc.d.ts} +7 -6
  67. package/dist/esm/index.d.ts +9 -9
  68. package/dist/esm/index.js +1 -1
  69. package/dist/esm/index.js.map +1 -1
  70. package/dist/esm/internal/index.d.ts +34 -0
  71. package/dist/esm/internal/index.js +2 -0
  72. package/dist/esm/internal/index.js.map +1 -0
  73. package/dist/esm/{invalidation-BgFjmXeQ.js → invalidation-CzspPBR7.js} +2 -2
  74. package/dist/esm/invalidation-CzspPBR7.js.map +1 -0
  75. package/dist/esm/node/index.d.ts +4 -4
  76. package/dist/esm/node/index.js +1 -1
  77. package/dist/esm/node/index.js.map +1 -1
  78. package/dist/esm/query/index.d.ts +5 -5
  79. package/dist/esm/query/index.js +1 -1
  80. package/dist/esm/query/index.js.map +1 -1
  81. package/dist/esm/{relayer-C3jVhqSK.js → relayer-ov8b_HOu.js} +2 -2
  82. package/dist/esm/{relayer-C3jVhqSK.js.map → relayer-ov8b_HOu.js.map} +1 -1
  83. package/dist/esm/signing-CneT-WIV.js +2 -0
  84. package/dist/esm/signing-CneT-WIV.js.map +1 -0
  85. package/dist/esm/telemetry-B3iGCWLv.js +2 -0
  86. package/dist/esm/telemetry-B3iGCWLv.js.map +1 -0
  87. package/dist/esm/token-DlsiZmg5.js +2 -0
  88. package/dist/esm/token-DlsiZmg5.js.map +1 -0
  89. package/dist/esm/typed-data-eAgGr9V-.js +2 -0
  90. package/dist/esm/typed-data-eAgGr9V-.js.map +1 -0
  91. package/dist/esm/{types-Dc1fpXWt.d.ts → types-BQHRdNY-.d.ts} +3 -3
  92. package/dist/esm/{types-C2ccCjoA.d.ts → types-D-rp-sGq.d.ts} +3 -3
  93. package/dist/esm/{types-CHepK8MK.d.ts → types-hWhlvqxC.d.ts} +33 -12
  94. package/dist/esm/{validation-ClSvPh6P.js → validation-ChQwNxaY.js} +2 -2
  95. package/dist/esm/{validation-ClSvPh6P.js.map → validation-ChQwNxaY.js.map} +1 -1
  96. package/dist/esm/vaults/index.d.ts +31 -327
  97. package/dist/esm/vaults/index.js +1 -1
  98. package/dist/esm/vaults/index.js.map +1 -1
  99. package/dist/esm/viem/index.d.ts +4 -4
  100. package/dist/esm/viem/index.js +1 -1
  101. package/dist/esm/viem/index.js.map +1 -1
  102. package/dist/esm/web/index.d.ts +2 -17
  103. package/dist/esm/web/index.js +1 -1
  104. package/dist/esm/web/index.js.map +1 -1
  105. package/dist/esm/wrapped-token-C8eKid8W.js +2 -0
  106. package/dist/esm/wrapped-token-C8eKid8W.js.map +1 -0
  107. package/dist/esm/wrappers-registry-DnYVQ02R.js +2 -0
  108. package/dist/esm/wrappers-registry-DnYVQ02R.js.map +1 -0
  109. package/package.json +15 -1
  110. package/dist/cjs/erc165.cjs +0 -2
  111. package/dist/cjs/erc165.cjs.map +0 -1
  112. package/dist/esm/base-signer-ClrhHzbm.js +0 -2
  113. package/dist/esm/base-signer-ClrhHzbm.js.map +0 -1
  114. package/dist/esm/chains-BwlDI944.js +0 -2
  115. package/dist/esm/chains-BwlDI944.js.map +0 -1
  116. package/dist/esm/erc165-BAd2z3ay.js +0 -2
  117. package/dist/esm/erc165-BAd2z3ay.js.map +0 -1
  118. package/dist/esm/fhevm-relayer-BEQ31nmT.js +0 -8
  119. package/dist/esm/invalidation-BgFjmXeQ.js.map +0 -1
  120. package/dist/esm/telemetry-CBSzrmab.js +0 -2
  121. package/dist/esm/telemetry-CBSzrmab.js.map +0 -1
  122. package/dist/esm/token-CTvEGQmH.js +0 -2
  123. package/dist/esm/token-CTvEGQmH.js.map +0 -1
  124. package/dist/esm/wrapped-token-IDUEFpZx.js +0 -2
  125. package/dist/esm/wrapped-token-IDUEFpZx.js.map +0 -1
  126. package/dist/esm/wrappers-registry-Cm3JJeqx.js +0 -2
  127. package/dist/esm/wrappers-registry-Cm3JJeqx.js.map +0 -1
@@ -0,0 +1,2 @@
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../fhevm-relayer.cjs"),t=require("../relayer.cjs"),n=require("../fatal-batch.cjs"),r=require("../typed-data.cjs"),i=n.t;function a(e,n,r){let a=i[e],o=a?new a(n):new t.r(e,n,e===t.i.RelayerRequestFailed?{retryable:r.retryable}:void 0);return o.retryable&&t.y(r.retryAfter)?Object.assign(o,{retryAfter:r.retryAfter}):o}function o(e,t){return e.onWalletAccountChange(t)}exports.reviveZamaError=a,exports.subscribeWalletAccountChanges=o,exports.toFhevmAuth=e.n,exports.toViemTypedData=r.t;
2
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs","names":["fatalBatchErrors","ZamaError","ZamaErrorCode","isValidRetryAfterSeconds"],"sources":["../../../src/errors/revive.ts","../../../src/internal/wallet-events.ts"],"sourcesContent":["import { isValidRetryAfterSeconds } from \"../utils/error\";\nimport { ZamaError, ZamaErrorCode } from \"./base\";\nimport { fatalBatchErrors } from \"./fatal-batch\";\n\nconst callbackErrors: Partial<Record<ZamaErrorCode, new (message: string) => ZamaError>> =\n fatalBatchErrors;\n\n/** Restores callback failures whose class identity controls batch termination. */\nexport function reviveZamaError(\n code: ZamaErrorCode,\n message: string,\n options: { retryable: boolean; retryAfter?: number },\n): ZamaError {\n const Constructor = callbackErrors[code];\n const error = Constructor\n ? new Constructor(message)\n : new ZamaError(\n code,\n message,\n code === ZamaErrorCode.RelayerRequestFailed ? { retryable: options.retryable } : undefined,\n );\n if (error.retryable && isValidRetryAfterSeconds(options.retryAfter)) {\n return Object.assign(error, { retryAfter: options.retryAfter });\n }\n return error;\n}\n","import type { WalletAccountListener } from \"../types/signer\";\nimport type { ZamaSDK } from \"../zama-sdk\";\n\n/** Subscribe after the SDK's wallet cleanup, through the internal integration entry point. */\nexport function subscribeWalletAccountChanges(\n sdk: ZamaSDK,\n listener: WalletAccountListener,\n): () => void {\n return sdk.onWalletAccountChange(listener);\n}\n"],"mappings":"sMAIM,EACJA,EAAAA,EAGF,SAAgB,EACd,EACA,EACA,EACW,CACX,IAAM,EAAc,EAAe,GAC7B,EAAQ,EACV,IAAI,EAAY,CAAO,EACvB,IAAIC,EAAAA,EACF,EACA,EACA,IAASC,EAAAA,EAAc,qBAAuB,CAAE,UAAW,EAAQ,SAAU,EAAI,IAAA,EACnF,EAIJ,OAHI,EAAM,WAAaC,EAAAA,EAAyB,EAAQ,UAAU,EACzD,OAAO,OAAO,EAAO,CAAE,WAAY,EAAQ,UAAW,CAAC,EAEzD,CACT,CCrBA,SAAgB,EACd,EACA,EACY,CACZ,OAAO,EAAI,sBAAsB,CAAQ,CAC3C"}
@@ -1,2 +1,2 @@
1
- let e=require("viem"),t=require("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=>(0,e.getAddress)(t)),s=t=>t===void 0?void 0:(0,e.getAddress)(t),c=t=>t?{walletAddress:(0,e.getAddress)(t.address),walletChainId:t.chainId}:{},l={confidentialBalance:{all:[`zama.confidentialBalance`],token:t=>[`zama.confidentialBalance`,{tokenAddress:(0,e.getAddress)(t)}],owner:(t,n,r)=>[`zama.confidentialBalance`,{tokenAddress:(0,e.getAddress)(t),...c(r),...n?{owner:(0,e.getAddress)(n)}:{}}]},confidentialBalances:{all:[`zama.confidentialBalances`],tokens:(t,n,r)=>[`zama.confidentialBalances`,{tokenAddresses:o(t),...c(r),...n?{owner:(0,e.getAddress)(n)}:{}}]},tokenMetadata:{all:[`zama.tokenMetadata`],token:t=>[`zama.tokenMetadata`,{tokenAddress:(0,e.getAddress)(t)}]},isConfidential:{all:[`zama.isConfidential`],token:t=>[`zama.isConfidential`,{tokenAddress:(0,e.getAddress)(t)}]},isWrapper:{all:[`zama.isWrapper`],token:t=>[`zama.isWrapper`,{tokenAddress:(0,e.getAddress)(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:(0,e.getAddress)(t)}],scope:(t,n)=>[`zama.underlyingAllowance`,{tokenAddress:(0,e.getAddress)(t),...n?{owner:(0,e.getAddress)(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:(0,e.getAddress)(t)}]},pendingUnshield:{all:[`zama.pendingUnshield`],token:t=>[`zama.pendingUnshield`,{tokenAddress:(0,e.getAddress)(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:(0,e.getAddress)(n)}}],encryptedInputs:(t,n)=>[`zama.decryption`,{...c(n),encryptedInputs:[...t].sort((e,t)=>e.encryptedValue.localeCompare(t.encryptedValue)).map(t=>({encryptedValue:t.encryptedValue,contractAddress:(0,e.getAddress)(t.contractAddress)}))}]},wrappersRegistry:{all:[`zama.wrappersRegistry`],chainId:()=>[`zama.wrappersRegistry`,{type:`chainId`}],tokenPairs:t=>[`zama.wrappersRegistry`,{type:`tokenPairs`,registryAddress:(0,e.getAddress)(t)}],confidentialTokenAddress:(t,n)=>[`zama.wrappersRegistry`,{type:`confidentialTokenAddress`,registryAddress:(0,e.getAddress)(t),tokenAddress:(0,e.getAddress)(n)}],tokenAddress:(t,n)=>[`zama.wrappersRegistry`,{type:`tokenAddress`,registryAddress:(0,e.getAddress)(t),confidentialTokenAddress:(0,e.getAddress)(n)}],tokenPairsLength:t=>[`zama.wrappersRegistry`,{type:`tokenPairsLength`,registryAddress:(0,e.getAddress)(t)}],tokenPairsSlice:(t,n,r)=>[`zama.wrappersRegistry`,{type:`tokenPairsSlice`,registryAddress:(0,e.getAddress)(t),fromIndex:n,toIndex:r}],tokenPair:(t,n)=>[`zama.wrappersRegistry`,{type:`tokenPair`,registryAddress:(0,e.getAddress)(t),index:n}],isConfidentialTokenValid:(t,n)=>[`zama.wrappersRegistry`,{type:`isConfidentialTokenValid`,registryAddress:(0,e.getAddress)(t),confidentialTokenAddress:(0,e.getAddress)(n)}],listPairs:(t,n,r,i)=>[`zama.wrappersRegistry`,{type:`listPairs`,registryAddress:(0,e.getAddress)(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.z.enum([`balanceOf`,`confidentialBalanceOf`]),C=t.z.object({functionName:S}),w=t.z.object({contracts:t.z.array(t.z.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)}Object.defineProperty(exports,"a",{enumerable:!0,get:function(){return g}}),Object.defineProperty(exports,"c",{enumerable:!0,get:function(){return p}}),Object.defineProperty(exports,"d",{enumerable:!0,get:function(){return O}}),Object.defineProperty(exports,"f",{enumerable:!0,get:function(){return l}}),Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return v}}),Object.defineProperty(exports,"l",{enumerable:!0,get:function(){return m}}),Object.defineProperty(exports,"m",{enumerable:!0,get:function(){return a}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return b}}),Object.defineProperty(exports,"o",{enumerable:!0,get:function(){return _}}),Object.defineProperty(exports,"p",{enumerable:!0,get:function(){return i}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return h}}),Object.defineProperty(exports,"s",{enumerable:!0,get:function(){return f}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return y}}),Object.defineProperty(exports,"u",{enumerable:!0,get:function(){return D}});
1
+ let e=require("viem"),t=require("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=>(0,e.getAddress)(t)),s=t=>t===void 0?void 0:(0,e.getAddress)(t),c=t=>t?{walletAddress:(0,e.getAddress)(t.address),walletChainId:t.chainId}:{},l={confidentialBalance:{all:[`zama.confidentialBalance`],token:t=>[`zama.confidentialBalance`,{tokenAddress:(0,e.getAddress)(t)}],owner:(t,n,r)=>[`zama.confidentialBalance`,{tokenAddress:(0,e.getAddress)(t),...c(r),...n?{owner:(0,e.getAddress)(n)}:{}}]},confidentialBalances:{all:[`zama.confidentialBalances`],tokens:(t,n,r)=>[`zama.confidentialBalances`,{tokenAddresses:o(t),...c(r),...n?{owner:(0,e.getAddress)(n)}:{}}]},tokenMetadata:{all:[`zama.tokenMetadata`],token:t=>[`zama.tokenMetadata`,{tokenAddress:(0,e.getAddress)(t)}]},isConfidential:{all:[`zama.isConfidential`],token:t=>[`zama.isConfidential`,{tokenAddress:(0,e.getAddress)(t)}]},isWrapper:{all:[`zama.isWrapper`],token:t=>[`zama.isWrapper`,{tokenAddress:(0,e.getAddress)(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:(0,e.getAddress)(t)}],scope:(t,n)=>[`zama.underlyingAllowance`,{tokenAddress:(0,e.getAddress)(t),...n?{owner:(0,e.getAddress)(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:(0,e.getAddress)(t)}]},pendingUnshield:{all:[`zama.pendingUnshield`],token:t=>[`zama.pendingUnshield`,{tokenAddress:(0,e.getAddress)(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:(0,e.getAddress)(n)}}],encryptedInputs:(t,n)=>[`zama.decryption`,{...c(n),encryptedInputs:[...t].sort((e,t)=>e.encryptedValue.localeCompare(t.encryptedValue)).map(t=>({encryptedValue:t.encryptedValue,contractAddress:(0,e.getAddress)(t.contractAddress)}))}]},wrappersRegistry:{all:[`zama.wrappersRegistry`],chainId:e=>[`zama.wrappersRegistry`,{type:`chainId`,...e===void 0?{}:{walletChainId:e}}],tokenPairs:t=>[`zama.wrappersRegistry`,{type:`tokenPairs`,registryAddress:(0,e.getAddress)(t)}],confidentialTokenAddress:(t,n)=>[`zama.wrappersRegistry`,{type:`confidentialTokenAddress`,registryAddress:(0,e.getAddress)(t),tokenAddress:(0,e.getAddress)(n)}],tokenAddress:(t,n)=>[`zama.wrappersRegistry`,{type:`tokenAddress`,registryAddress:(0,e.getAddress)(t),confidentialTokenAddress:(0,e.getAddress)(n)}],tokenPairsLength:t=>[`zama.wrappersRegistry`,{type:`tokenPairsLength`,registryAddress:(0,e.getAddress)(t)}],tokenPairsSlice:(t,n,r)=>[`zama.wrappersRegistry`,{type:`tokenPairsSlice`,registryAddress:(0,e.getAddress)(t),fromIndex:n,toIndex:r}],tokenPair:(t,n)=>[`zama.wrappersRegistry`,{type:`tokenPair`,registryAddress:(0,e.getAddress)(t),index:n}],isConfidentialTokenValid:(t,n)=>[`zama.wrappersRegistry`,{type:`isConfidentialTokenValid`,registryAddress:(0,e.getAddress)(t),confidentialTokenAddress:(0,e.getAddress)(n)}],listPairs:(t,n,r,i)=>[`zama.wrappersRegistry`,{type:`listPairs`,registryAddress:(0,e.getAddress)(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.z.enum([`balanceOf`,`confidentialBalanceOf`]),C=t.z.object({functionName:S}),w=t.z.object({contracts:t.z.array(t.z.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)}Object.defineProperty(exports,"a",{enumerable:!0,get:function(){return g}}),Object.defineProperty(exports,"c",{enumerable:!0,get:function(){return p}}),Object.defineProperty(exports,"d",{enumerable:!0,get:function(){return O}}),Object.defineProperty(exports,"f",{enumerable:!0,get:function(){return l}}),Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return v}}),Object.defineProperty(exports,"l",{enumerable:!0,get:function(){return m}}),Object.defineProperty(exports,"m",{enumerable:!0,get:function(){return a}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return b}}),Object.defineProperty(exports,"o",{enumerable:!0,get:function(){return _}}),Object.defineProperty(exports,"p",{enumerable:!0,get:function(){return i}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return h}}),Object.defineProperty(exports,"s",{enumerable:!0,get:function(){return f}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return y}}),Object.defineProperty(exports,"u",{enumerable:!0,get:function(){return D}});
2
2
  //# sourceMappingURL=invalidation.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"invalidation.cjs","names":["z"],"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: is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S,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"}
1
+ {"version":3,"file":"invalidation.cjs","names":["z"],"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: (walletChainId?: number) =>\n [\n \"zama.wrappersRegistry\",\n { type: \"chainId\", ...(walletChainId === undefined ? {} : { walletChainId }) },\n ] 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":"4CAEA,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,S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,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"}
@@ -1,2 +1,2 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../fhevm-relayer.cjs"),t=require("../telemetry.cjs"),n=require("../cleartext.cjs"),r=require("../chains.cjs");let i=require("node:async_hooks");function a(n){return{type:`node`,createRelayer:(r,i,a)=>new e.t({chain:r,options:n,logger:i,telemetry:a&&!t.t(globalThis.process?.env??{})?{state:a,runtime:`node`}:void 0})}}var o=class{#e=new i.AsyncLocalStorage;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 s=new o;exports.AsyncLocalMapStorage=o,exports.anvil=r.t,exports.asyncLocalStorage=s,exports.bscTestnet=r.n,exports.chains=r.r,exports.cleartext=n.t,exports.hardhat=r.i,exports.hoodi=r.a,exports.mainnet=r.o,exports.node=a,exports.polygon=r.s,exports.polygonAmoy=r.c,exports.sepolia=r.l,exports.zenithTrexTestnet=r.u;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../fhevm-relayer.cjs"),t=require("../telemetry.cjs"),n=require("../cleartext.cjs"),r=require("../chains.cjs");let i=require("node:async_hooks");function a(n){return{type:`node`,createRelayer:(r,i,a)=>{let o=t.t(globalThis.process?.env?.ZAMA_SDK_TELEMETRY)??a?.mode;return new e.t({chain:r,options:n,logger:i,telemetry:a&&o!==void 0&&o!==`off`?{state:a,runtime:`node`,mode:o}:void 0})}}}var o=class{#e=new i.AsyncLocalStorage;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 s=new o;exports.AsyncLocalMapStorage=o,exports.anvil=r.t,exports.asyncLocalStorage=s,exports.bscTestnet=r.n,exports.chains=r.r,exports.cleartext=n.t,exports.hardhat=r.i,exports.hoodi=r.a,exports.mainnet=r.o,exports.node=a,exports.polygon=r.s,exports.polygonAmoy=r.c,exports.sepolia=r.l,exports.zenithTrexTestnet=r.u;
2
2
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","names":["FhevmRelayer","isTelemetryDisabledByEnv","#als","AsyncLocalStorage"],"sources":["../../../src/node/config.ts","../../../src/storage/async-local-storage.ts"],"sourcesContent":["import type { FheChain } from \"../chains/types\";\nimport type { RelayerConfig } from \"../config/types\";\nimport { FhevmRelayer } from \"../relayer/fhevm-relayer\";\nimport type { RelayerOptions } from \"../relayer/types\";\nimport type { LoggerService } from \"../services/logger-service\";\nimport { isTelemetryDisabledByEnv, type TelemetryState } from \"../telemetry\";\n\n/** Node transport — drives the FHE backend directly on the calling thread. */\nexport interface NodeRelayerConfig extends RelayerConfig {\n /** Discriminant for the node transport. */\n readonly type: \"node\";\n /** @internal */\n readonly createRelayer: (\n chain: FheChain,\n logger: LoggerService,\n telemetry?: TelemetryState,\n ) => FhevmRelayer;\n}\n\n/**\n * Node.js transport — drives `@fhevm/sdk` via {@link FhevmRelayer} on the calling thread.\n *\n * `ZAMA_SDK_TELEMETRY=0` turns off the `x-zama-sdk-*` usage headers, like\n * `createConfig({ telemetry: false })`.\n *\n * @example\n * ```ts\n * relayers: {\n * [sepolia.id]: node({ timeout: 5 * 60_000 }),\n * [mainnet.id]: node({ batchRpcCalls: true }),\n * }\n * ```\n */\nexport function node(options?: RelayerOptions): NodeRelayerConfig {\n return {\n type: \"node\",\n createRelayer: (chain, logger, telemetry) =>\n new FhevmRelayer({\n chain,\n options,\n logger,\n telemetry:\n telemetry && !isTelemetryDisabledByEnv(globalThis.process?.env ?? {})\n ? { state: telemetry, runtime: \"node\" }\n : undefined,\n }),\n };\n}\n","import { AsyncLocalStorage } from \"node:async_hooks\";\nimport type { GenericStorage } from \"../types\";\n\n/**\n * {@link GenericStorage} backed by Node.js {@link AsyncLocalStorage}.\n *\n * Each async context (e.g. HTTP request) gets its own isolated `Map`,\n * so credentials from one request never leak into another.\n *\n * Call {@link run} to establish a context before using the SDK:\n *\n * ```ts\n * import { asyncLocalStorage } from \"@zama-fhe/sdk/node\";\n *\n * app.post(\"/api/transfer\", (req, res) => {\n * asyncLocalStorage.run(async () => {\n * const sdk = new ZamaSDK({ relayer, signer, storage: asyncLocalStorage });\n * // credentials are scoped to this request\n * });\n * });\n * ```\n */\nexport class AsyncLocalMapStorage implements GenericStorage {\n readonly #als = new AsyncLocalStorage<Map<string, unknown>>();\n\n /** Execute `fn` within an isolated storage context. */\n run<R>(fn: () => R | Promise<R>): R | Promise<R> {\n return this.#als.run(new Map(), fn);\n }\n\n /**\n * Retrieve a value by key.\n * @returns The stored value, or `null` if the key does not exist.\n */\n async get<T = unknown>(key: string): Promise<T | null> {\n return (this.#als.getStore()?.get(key) as T) ?? null;\n }\n\n /** Store a value under the given key, overwriting any existing entry. */\n async set<T = unknown>(key: string, value: T): Promise<void> {\n this.#als.getStore()?.set(key, value);\n }\n\n /** Remove the entry for the given key (no-op if absent). */\n async delete(key: string): Promise<void> {\n this.#als.getStore()?.delete(key);\n }\n}\n\n/** Default singleton for application-wide use. */\nexport const asyncLocalStorage = new AsyncLocalMapStorage();\n"],"mappings":"oOAiCA,SAAgB,EAAK,EAA6C,CAChE,MAAO,CACL,KAAM,OACN,eAAgB,EAAO,EAAQ,IAC7B,IAAIA,EAAAA,EAAa,CACf,QACA,UACA,SACA,UACE,GAAa,CAACC,EAAAA,EAAyB,WAAW,SAAS,KAAO,CAAC,CAAC,EAChE,CAAE,MAAO,EAAW,QAAS,MAAO,EACpC,IAAA,EACR,CAAC,CACL,CACF,CCzBA,IAAa,EAAb,KAA4D,CAC1D,GAAgB,IAAIE,EAAAA,kBAGpB,IAAO,EAA0C,CAC/C,OAAO,KAAKD,GAAK,IAAI,IAAI,IAAO,CAAE,CACpC,CAMA,MAAM,IAAiB,EAAgC,CACrD,OAAQ,KAAKA,GAAK,SAAS,CAAC,EAAE,IAAI,CAAG,GAAW,IAClD,CAGA,MAAM,IAAiB,EAAa,EAAyB,CAC3D,KAAKA,GAAK,SAAS,CAAC,EAAE,IAAI,EAAK,CAAK,CACtC,CAGA,MAAM,OAAO,EAA4B,CACvC,KAAKA,GAAK,SAAS,CAAC,EAAE,OAAO,CAAG,CAClC,CACF,EAGA,MAAa,EAAoB,IAAI"}
1
+ {"version":3,"file":"index.cjs","names":["parseTelemetryMode","FhevmRelayer","#als","AsyncLocalStorage"],"sources":["../../../src/node/config.ts","../../../src/storage/async-local-storage.ts"],"sourcesContent":["import type { FheChain } from \"../chains/types\";\nimport type { RelayerConfig } from \"../config/types\";\nimport { FhevmRelayer } from \"../relayer/fhevm-relayer\";\nimport type { RelayerOptions } from \"../relayer/types\";\nimport type { LoggerService } from \"../services/logger-service\";\nimport { parseTelemetryMode, type TelemetryState } from \"../telemetry\";\n\n/** Node transport — drives the FHE backend directly on the calling thread. */\nexport interface NodeRelayerConfig extends RelayerConfig {\n /** Discriminant for the node transport. */\n readonly type: \"node\";\n /** @internal */\n readonly createRelayer: (\n chain: FheChain,\n logger: LoggerService,\n telemetry?: TelemetryState,\n ) => FhevmRelayer;\n}\n\n/**\n * Node.js transport — drives `@fhevm/sdk` via {@link FhevmRelayer} on the calling thread.\n *\n * `ZAMA_SDK_TELEMETRY=header|query|off` applies to the whole process\n * (case-insensitive; `0` and `false` also mean `off`). It cannot turn on what\n * `createConfig({ telemetry })` disabled.\n *\n * @example\n * ```ts\n * relayers: {\n * [sepolia.id]: node({ timeout: 5 * 60_000 }),\n * [mainnet.id]: node({ batchRpcCalls: true }),\n * }\n * ```\n */\nexport function node(options?: RelayerOptions): NodeRelayerConfig {\n return {\n type: \"node\",\n createRelayer: (chain, logger, telemetry) => {\n const mode =\n parseTelemetryMode(globalThis.process?.env?.ZAMA_SDK_TELEMETRY) ?? telemetry?.mode;\n return new FhevmRelayer({\n chain,\n options,\n logger,\n telemetry:\n telemetry && mode !== undefined && mode !== \"off\"\n ? { state: telemetry, runtime: \"node\", mode }\n : undefined,\n });\n },\n };\n}\n","import { AsyncLocalStorage } from \"node:async_hooks\";\nimport type { GenericStorage } from \"../types\";\n\n/**\n * {@link GenericStorage} backed by Node.js {@link AsyncLocalStorage}.\n *\n * Each async context (e.g. HTTP request) gets its own isolated `Map`,\n * so credentials from one request never leak into another.\n *\n * Call {@link run} to establish a context before using the SDK:\n *\n * ```ts\n * import { asyncLocalStorage } from \"@zama-fhe/sdk/node\";\n *\n * app.post(\"/api/transfer\", (req, res) => {\n * asyncLocalStorage.run(async () => {\n * const sdk = new ZamaSDK({ relayer, signer, storage: asyncLocalStorage });\n * // credentials are scoped to this request\n * });\n * });\n * ```\n */\nexport class AsyncLocalMapStorage implements GenericStorage {\n readonly #als = new AsyncLocalStorage<Map<string, unknown>>();\n\n /** Execute `fn` within an isolated storage context. */\n run<R>(fn: () => R | Promise<R>): R | Promise<R> {\n return this.#als.run(new Map(), fn);\n }\n\n /**\n * Retrieve a value by key.\n * @returns The stored value, or `null` if the key does not exist.\n */\n async get<T = unknown>(key: string): Promise<T | null> {\n return (this.#als.getStore()?.get(key) as T) ?? null;\n }\n\n /** Store a value under the given key, overwriting any existing entry. */\n async set<T = unknown>(key: string, value: T): Promise<void> {\n this.#als.getStore()?.set(key, value);\n }\n\n /** Remove the entry for the given key (no-op if absent). */\n async delete(key: string): Promise<void> {\n this.#als.getStore()?.delete(key);\n }\n}\n\n/** Default singleton for application-wide use. */\nexport const asyncLocalStorage = new AsyncLocalMapStorage();\n"],"mappings":"oOAkCA,SAAgB,EAAK,EAA6C,CAChE,MAAO,CACL,KAAM,OACN,eAAgB,EAAO,EAAQ,IAAc,CAC3C,IAAM,EACJA,EAAAA,EAAmB,WAAW,SAAS,KAAK,kBAAkB,GAAK,GAAW,KAChF,OAAO,IAAIC,EAAAA,EAAa,CACtB,QACA,UACA,SACA,UACE,GAAa,IAAS,IAAA,IAAa,IAAS,MACxC,CAAE,MAAO,EAAW,QAAS,OAAQ,MAAK,EAC1C,IAAA,EACR,CAAC,CACH,CACF,CACF,CC7BA,IAAa,EAAb,KAA4D,CAC1D,GAAgB,IAAIE,EAAAA,kBAGpB,IAAO,EAA0C,CAC/C,OAAO,KAAKD,GAAK,IAAI,IAAI,IAAO,CAAE,CACpC,CAMA,MAAM,IAAiB,EAAgC,CACrD,OAAQ,KAAKA,GAAK,SAAS,CAAC,EAAE,IAAI,CAAG,GAAW,IAClD,CAGA,MAAM,IAAiB,EAAa,EAAyB,CAC3D,KAAKA,GAAK,SAAS,CAAC,EAAE,IAAI,EAAK,CAAK,CACtC,CAGA,MAAM,OAAO,EAA4B,CACvC,KAAKA,GAAK,SAAS,CAAC,EAAE,OAAO,CAAG,CAClC,CACF,EAGA,MAAa,EAAoB,IAAI"}
@@ -1,2 +1,2 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../relayer.cjs"),t=require("../erc165.cjs"),n=require("../token.cjs"),r=require("../wrappers-registry.cjs"),i=require("../invalidation.cjs");let a=require("viem");function o(e,n,r){let a=i.f.tokenMetadata.token(n);return{...i.p(r?.query??{}),queryKey:a,queryFn:async n=>{let[,{tokenAddress:r}]=n.queryKey,[i,a,o]=await Promise.all([e.provider.readContract(t.p(r)),e.provider.readContract(t.m(r)),e.provider.readContract(t.d(r))]);return{name:i,symbol:a,decimals:o}},staleTime:1/0,enabled:r?.query?.enabled!==!1}}function s(n,r,a){let o=i.f.isConfidential.token(r);return{...i.p(a?.query??{}),queryKey:o,queryFn:async r=>{let[,{tokenAddress:i}]=r.queryKey;try{return await n.provider.readContract(t.i(i))}catch(t){if(e.f(t))return!1;throw t}},staleTime:1/0,enabled:a?.query?.enabled!==!1}}function c(n,r,a){let o=i.f.isWrapper.token(r);return{...i.p(a?.query??{}),queryKey:o,queryFn:async r=>{let[,{tokenAddress:i}]=r.queryKey;try{return await n.provider.readContract(t.a(i))}catch(t){if(e.f(t))return!1;throw t}},staleTime:1/0,enabled:a?.query?.enabled!==!1}}function l(e,n,r){let a=i.f.totalSupply.token(n);return{...i.p(r?.query??{}),queryKey:a,queryFn:async n=>{let[,{tokenAddress:r}]=n.queryKey;return e.provider.readContract(t.S(r))},staleTime:3e4,enabled:r?.query?.enabled!==!1}}function u(e,n){let r=i.f.wrapperDiscovery.token(n.tokenAddress,n.erc20Address,n.registryAddress);return{...i.p(n.query??{}),queryKey:r,queryFn:async n=>{let[,{erc20Address:r}]=n.queryKey;t.P(r,`wrapperDiscoveryQueryOptions: erc20Address`);let i=await e.getConfidentialToken(r);return i?i.confidentialTokenAddress:null},staleTime:1/0,enabled:!!(n.tokenAddress&&n.erc20Address&&n.registryAddress)&&n.query?.enabled!==!1}}function d(e,n,r){let a=r.owner,o=r.query?.enabled!==!1,s=i.f.underlyingAllowance.scope(n,a);return{...i.p(r.query??{}),queryKey:s,queryFn:async n=>{let[,{tokenAddress:r,owner:i}]=n.queryKey;t.P(i,`underlyingAllowanceQueryOptions: owner`);let a=await e.provider.readContract(t.E(r));return e.provider.readContract(t.c(a,i,r))},staleTime:3e4,enabled:!!a&&o}}function f(e,t,n){let r=i.f.pendingUnshield.token(t);return{...i.p(n?.query??{}),queryKey:r,queryFn:async t=>{let[,{tokenAddress:n}]=t.queryKey;return e.createWrappedToken(n).getPendingUnshield()},staleTime:0,enabled:n?.query?.enabled!==!1}}function p(e,n,r){let a=r.holder,o=r.spender,s=r.query?.enabled!==!1,c=i.f.confidentialIsOperator.scope(n,a,o);return{...i.p(r.query??{}),queryKey:c,queryFn:async n=>{let[,{tokenAddress:r,holder:i,spender:a}]=n.queryKey;return t.P(r,`confidentialIsOperatorQueryOptions: tokenAddress`),t.P(i,`confidentialIsOperatorQueryOptions: holder`),t.P(a,`confidentialIsOperatorQueryOptions: spender`),e.provider.readContract(t.C(r,i,a))},staleTime:3e4,enabled:!!(n&&a&&o)&&s}}function m(e,n,r={}){let a=n.query??{};return{...i.p(a),queryKey:i.f.confidentialBalance.owner(n.tokenAddress,n.account,r.walletAccount),queryFn:async n=>{let[,{owner:r}]=n.queryKey;return t.P(r,`confidentialBalanceQueryOptions: owner`),e.balanceOf(r)},enabled:!!n.account&&r.walletAccount!==void 0&&a?.enabled!==!1}}function h(e,r,a={}){let o=r?.account,s=a.walletAccount,c=r?.query??{},l=e.map(e=>e.address);return{...i.p(c),queryKey:i.f.confidentialBalances.tokens(l,o,s),queryFn:async r=>{let[,{owner:i}]=r.queryKey;return t.P(i,`confidentialBalancesQueryOptions: owner`),n.t.batchBalancesOf(e,i)},enabled:!!o&&e.length>0&&s!==void 0&&c?.enabled!==!1}}function g(e,t){let n=!!t.registryAddress&&t.query?.enabled!==!1,o=i.f.wrappersRegistry.tokenPairs(t.registryAddress??a.zeroAddress);return{...i.p(t.query??{}),queryKey:o,queryFn:async t=>{let[,{registryAddress:n}]=t.queryKey;return e.provider.readContract(r.i(n))},staleTime:e.registry.ttlMs,enabled:n}}function _(e,t){let n=!!t.registryAddress&&!!t.tokenAddress&&t.query?.enabled!==!1,o=i.f.wrappersRegistry.confidentialTokenAddress(t.registryAddress??a.zeroAddress,t.tokenAddress??a.zeroAddress);return{...i.p(t.query??{}),queryKey:o,queryFn:async t=>{let[,{registryAddress:n,tokenAddress:i}]=t.queryKey;return e.provider.readContract(r.t(n,i))},staleTime:e.registry.ttlMs,enabled:n}}function v(e,t){let n=!!t.registryAddress&&!!t.confidentialTokenAddress&&t.query?.enabled!==!1,o=i.f.wrappersRegistry.tokenAddress(t.registryAddress??a.zeroAddress,t.confidentialTokenAddress??a.zeroAddress);return{...i.p(t.query??{}),queryKey:o,queryFn:async t=>{let[,{registryAddress:n,confidentialTokenAddress:i}]=t.queryKey;return e.provider.readContract(r.n(n,i))},staleTime:e.registry.ttlMs,enabled:n}}function y(e,t){let n=!!t.registryAddress&&t.query?.enabled!==!1,o=i.f.wrappersRegistry.tokenPairsLength(t.registryAddress??a.zeroAddress);return{...i.p(t.query??{}),queryKey:o,queryFn:async t=>{let[,{registryAddress:n}]=t.queryKey;return e.provider.readContract(r.a(n))},staleTime:e.registry.ttlMs,enabled:n}}function b(e,t){let n=!!t.registryAddress&&t.fromIndex!==void 0&&t.toIndex!==void 0&&t.query?.enabled!==!1,o=i.f.wrappersRegistry.tokenPairsSlice(t.registryAddress??a.zeroAddress,String(t.fromIndex??0n),String(t.toIndex??0n));return{...i.p(t.query??{}),queryKey:o,queryFn:async t=>{let[,{registryAddress:n,fromIndex:i,toIndex:a}]=t.queryKey;return e.provider.readContract(r.o(n,BigInt(i),BigInt(a)))},staleTime:e.registry.ttlMs,enabled:n}}function x(e,t){let n=!!t.registryAddress&&t.index!==void 0&&t.query?.enabled!==!1,o=i.f.wrappersRegistry.tokenPair(t.registryAddress??a.zeroAddress,String(t.index??0n));return{...i.p(t.query??{}),queryKey:o,queryFn:async t=>{let[,{registryAddress:n,index:i}]=t.queryKey;return e.provider.readContract(r.r(n,BigInt(i)))},staleTime:e.registry.ttlMs,enabled:n}}function S(e,t){let n=!!t.registryAddress&&!!t.confidentialTokenAddress&&t.query?.enabled!==!1,o=i.f.wrappersRegistry.isConfidentialTokenValid(t.registryAddress??a.zeroAddress,t.confidentialTokenAddress??a.zeroAddress);return{...i.p(t.query??{}),queryKey:o,queryFn:async t=>{let[,{registryAddress:n,confidentialTokenAddress:i}]=t.queryKey;return e.provider.readContract(r.s(n,i))},staleTime:e.registry.ttlMs,enabled:n}}function C(e,t){let n=!!t.registryAddress&&t.query?.enabled!==!1,r=i.f.wrappersRegistry.listPairs(t.registryAddress??a.zeroAddress,t.page??1,t.pageSize??100,t.metadata??!1);return{...i.p(t.query??{}),queryKey:r,queryFn:async t=>{let[,{page:n,pageSize:r,metadata:i}]=t.queryKey;return e.listPairs({page:n,pageSize:r,metadata:i})},staleTime:e.ttlMs,enabled:n}}function w(e){return{mutationKey:[`zama.shield`,e.address],mutationFn:async({amount:t,...n})=>e.shield(t,n)}}function T(e){return{mutationKey:[`zama.confidentialTransfer`,e.address],mutationFn:async({to:t,amount:n,...r})=>e.confidentialTransfer(t,n,r)}}function E(e){return{mutationKey:[`zama.confidentialTransferAndCall`,e.address],mutationFn:async({to:t,amount:n,data:r,...i})=>e.confidentialTransferAndCall(t,n,r,i)}}function D(e){return{mutationKey:[`zama.confidentialTransferFrom`,e.address],mutationFn:async({from:t,to:n,amount:r,callbacks:i})=>e.confidentialTransferFrom(t,n,r,i)}}function O(e){return{mutationKey:[`zama.confidentialTransferFromAndCall`,e.address],mutationFn:async({from:t,to:n,amount:r,data:i,callbacks:a})=>e.confidentialTransferFromAndCall(t,n,r,i,a)}}function k(e){return{mutationKey:[`zama.confidentialSetOperator`,e.address],mutationFn:async({operator:t,until:n})=>e.setOperator(t,n)}}function A(e){return{mutationKey:[`zama.approveUnderlying`,e.address],mutationFn:async({amount:t})=>e.approveUnderlying(t)}}function ee(e){return{mutationKey:[`zama.unshield`,e.address],mutationFn:async({amount:t,...n})=>e.unshield(t,n)}}function j(e){return{mutationKey:[`zama.unshieldAll`,e.address],mutationFn:async t=>e.unshieldAll(t||void 0)}}function M(e){return{mutationKey:[`zama.resumeUnshield`,e.address],mutationFn:async({unwrapTxHash:t,...n})=>e.resumeUnshield(t,n)}}function N(e){return{mutationKey:[`zama.unwrap`,e.address],mutationFn:async({amount:t})=>e.unwrap(t)}}function P(e){return{mutationKey:[`zama.wrap`,e.address],mutationFn:async({amount:t,...n})=>e.wrap(t,n)}}function F(e){return{mutationKey:[`zama.unwrapAll`,e.address],mutationFn:async()=>e.unwrapAll()}}function I(e){return{mutationKey:[`zama.finalizeUnwrap`,e.address],mutationFn:async({unwrapRequestId:t})=>e.finalizeUnwrap(t)}}function L(e){return{mutationKey:[`zama.encrypt`],mutationFn:async t=>e.encrypt(t)}}function R(e){return{mutationKey:[`zama.delegatedDecryptValues`],mutationFn:async t=>e.decryption.delegatedDecryptValues(t.encryptedInputs,t.delegatorAddress)}}function z(e){return{mutationKey:[`zama.decryptPublicValues`],mutationFn:async t=>e.decryption.decryptPublicValues(t),onSuccess:(e,t,n,r)=>{for(let[t,n]of Object.entries(e.clearValues))r.client.setQueryData(i.f.decryption.encryptedValue(t),n)}}}function B(e){return{mutationKey:[`zama.grantPermit`],mutationFn:t=>e.permits.grantPermit(t)}}function V(e){return{mutationKey:[`zama.preparePermit`],mutationFn:t=>e.offline.preparePermit(t)}}function H(e){return{mutationKey:[`zama.batchPreparePermits`],mutationFn:t=>e.offline.batchPreparePermits(t)}}function U(e){return{mutationKey:[`zama.registerPermit`],mutationFn:({prepared:t,signature:n})=>e.permits.registerPermit(t,n)}}function W(e){return{mutationKey:[`zama.batchRegisterPermits`],mutationFn:t=>e.permits.batchRegisterPermits(t)}}function G(e,t,n={}){let r=t.query?.enabled!==!1;return{...i.p(t?.query??{}),queryKey:i.f.hasPermit.scope(t.contractAddresses,n.walletAccount),queryFn:t=>{let[,{contractAddresses:n}]=t.queryKey;return e.permits.hasPermit(n)},staleTime:0,gcTime:0,refetchOnMount:`always`,refetchOnWindowFocus:!1,enabled:r&&n.walletAccount!==void 0&&t.contractAddresses.length>0}}function K(e){return{mutationKey:[`zama.revokePermits`],mutationFn:t=>t===void 0?e.permits.revokePermits():e.permits.revokePermits(t)}}function q(e){return{mutationKey:[`zama.clearCredentials`],mutationFn:()=>e.permits.clear()}}function J(e,t){return{mutationKey:[`zama.delegateDecryption`,t],mutationFn:async({delegateAddress:n,expirationDate:r})=>e.delegations.delegateDecryption({contractAddress:t,delegateAddress:n,expirationDate:r})}}function Y(e,t,n={}){return{queryKey:i.f.decryption.encryptedInputs(t,n.walletAccount),queryFn:t=>{let[,{encryptedInputs:n}]=t.queryKey;return e.decryption.decryptValues(n)},staleTime:1/0,enabled:t.length>0&&n.walletAccount!==void 0}}function X(e){return{mutationKey:[`zama.decryptBalanceAs`,e.address],mutationFn:async({delegatorAddress:t,accountAddress:n})=>e.decryptBalanceAs({delegatorAddress:t,accountAddress:n})}}function Z(e){return{mutationKey:[`zama.batchDecryptBalancesAs`,...e.map(e=>e.address)],mutationFn:async t=>n.t.batchDecryptBalancesAs(e,t)}}function Q(e,t){return{mutationKey:[`zama.revokeDelegation`,t],mutationFn:async({delegateAddress:n})=>e.delegations.revokeDelegation({contractAddress:t,delegateAddress:n})}}function $(e,n){return{...i.p(n.query??{}),queryKey:i.f.delegationStatus.scope(n.contractAddress,n.delegatorAddress,n.delegateAddress),queryFn:async n=>{let[,{contractAddress:r,delegatorAddress:i,delegateAddress:a}]=n.queryKey;return t.P(r,`delegationStatusQueryOptions: contractAddress`),t.P(i,`delegationStatusQueryOptions: delegatorAddress`),t.P(a,`delegationStatusQueryOptions: delegateAddress`),e.delegations.getStatus({contractAddress:r,delegatorAddress:i,delegateAddress:a})},enabled:!!(n.contractAddress&&n.delegatorAddress&&n.delegateAddress)&&n.query?.enabled!==!1}}exports.ZamaSDKEvents=t.F,exports.approveUnderlyingMutationOptions=A,exports.batchDecryptBalancesAsMutationOptions=Z,exports.batchPreparePermitsMutationOptions=H,exports.batchRegisterPermitsMutationOptions=W,exports.clearCredentialsMutationOptions=q,exports.confidentialBalanceQueryOptions=m,exports.confidentialBalancesQueryOptions=h,exports.confidentialIsOperatorQueryOptions=p,exports.confidentialSetOperatorMutationOptions=k,exports.confidentialTokenAddressQueryOptions=_,exports.confidentialTransferAndCallMutationOptions=E,exports.confidentialTransferFromAndCallMutationOptions=O,exports.confidentialTransferFromMutationOptions=D,exports.confidentialTransferMutationOptions=T,exports.decryptBalanceAsMutationOptions=X,exports.decryptPublicValuesMutationOptions=z,exports.decryptValuesQueryOptions=Y,exports.delegateDecryptionMutationOptions=J,exports.delegatedDecryptValuesMutationOptions=R,exports.delegationStatusQueryOptions=$,exports.encryptMutationOptions=L,exports.filterQueryOptions=i.p,exports.finalizeUnwrapMutationOptions=I,exports.grantPermitMutationOptions=B,exports.hasPermitQueryOptions=G,exports.hashFn=i.m,exports.invalidateAfterApproveUnderlying=i.t,exports.invalidateAfterSetOperator=i.n,exports.invalidateAfterShield=i.r,exports.invalidateAfterTransfer=i.i,exports.invalidateAfterUnshield=i.a,exports.invalidateAfterUnshieldSettled=i.o,exports.invalidateAfterUnwrap=i.s,exports.invalidateAfterWrap=i.c,exports.invalidateBalanceQueries=i.l,exports.invalidateWagmiBalanceQueries=i.u,exports.invalidateWalletLifecycleQueries=i.d,exports.isConfidentialQueryOptions=s,exports.isConfidentialTokenValidQueryOptions=S,exports.isWrapperQueryOptions=c,exports.listPairsQueryOptions=C,exports.pendingUnshieldQueryOptions=f,exports.preparePermitMutationOptions=V,exports.registerPermitMutationOptions=U,exports.resumeUnshieldMutationOptions=M,exports.revokeDelegationMutationOptions=Q,exports.revokePermitsMutationOptions=K,exports.shieldMutationOptions=w,exports.tokenAddressQueryOptions=v,exports.tokenMetadataQueryOptions=o,exports.tokenPairQueryOptions=x,exports.tokenPairsLengthQueryOptions=y,exports.tokenPairsQueryOptions=g,exports.tokenPairsSliceQueryOptions=b,exports.totalSupplyQueryOptions=l,exports.underlyingAllowanceQueryOptions=d,exports.unshieldAllMutationOptions=j,exports.unshieldMutationOptions=ee,exports.unwrapAllMutationOptions=F,exports.unwrapMutationOptions=N,exports.wrapMutationOptions=P,exports.wrapperDiscoveryQueryOptions=u,exports.zamaQueryKeys=i.f;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../relayer.cjs"),t=require("../wrappers-registry.cjs"),n=require("../token.cjs"),r=require("../invalidation.cjs");let i=require("viem");function a(e,n,i){let a=r.f.tokenMetadata.token(n);return{...r.p(i?.query??{}),queryKey:a,queryFn:async n=>{let[,{tokenAddress:r}]=n.queryKey,[i,a,o]=await Promise.all([e.provider.readContract(t.b(r)),e.provider.readContract(t.x(r)),e.provider.readContract(t.v(r))]);return{name:i,symbol:a,decimals:o}},staleTime:1/0,enabled:i?.query?.enabled!==!1}}function o(n,i,a){let o=r.f.isConfidential.token(i);return{...r.p(a?.query??{}),queryKey:o,queryFn:async r=>{let[,{tokenAddress:i}]=r.queryKey;try{return await n.provider.readContract(t.d(i))}catch(t){if(e.f(t))return!1;throw t}},staleTime:1/0,enabled:a?.query?.enabled!==!1}}function s(n,i,a){let o=r.f.isWrapper.token(i);return{...r.p(a?.query??{}),queryKey:o,queryFn:async r=>{let[,{tokenAddress:i}]=r.queryKey;try{return await n.provider.readContract(t.f(i))}catch(t){if(e.f(t))return!1;throw t}},staleTime:1/0,enabled:a?.query?.enabled!==!1}}function c(e,n,i){let a=r.f.totalSupply.token(n);return{...r.p(i?.query??{}),queryKey:a,queryFn:async n=>{let[,{tokenAddress:r}]=n.queryKey;return e.provider.readContract(t.k(r))},staleTime:3e4,enabled:i?.query?.enabled!==!1}}function l(e,n){let i=r.f.wrapperDiscovery.token(n.tokenAddress,n.erc20Address,n.registryAddress);return{...r.p(n.query??{}),queryKey:i,queryFn:async n=>{let[,{erc20Address:r}]=n.queryKey;t.V(r,`wrapperDiscoveryQueryOptions: erc20Address`);let i=await e.getConfidentialToken(r);return i?i.confidentialTokenAddress:null},staleTime:1/0,enabled:!!(n.tokenAddress&&n.erc20Address&&n.registryAddress)&&n.query?.enabled!==!1}}function u(e,n,i){let a=i.owner,o=i.query?.enabled!==!1,s=r.f.underlyingAllowance.scope(n,a);return{...r.p(i.query??{}),queryKey:s,queryFn:async n=>{let[,{tokenAddress:r,owner:i}]=n.queryKey;t.V(i,`underlyingAllowanceQueryOptions: owner`);let a=await e.provider.readContract(t.N(r));return e.provider.readContract(t.h(a,i,r))},staleTime:3e4,enabled:!!a&&o}}function d(e,t,n){let i=r.f.pendingUnshield.token(t);return{...r.p(n?.query??{}),queryKey:i,queryFn:async t=>{let[,{tokenAddress:n}]=t.queryKey;return e.createWrappedToken(n).getPendingUnshield()},staleTime:0,enabled:n?.query?.enabled!==!1}}function f(e,n,i){let a=i.holder,o=i.spender,s=i.query?.enabled!==!1,c=r.f.confidentialIsOperator.scope(n,a,o);return{...r.p(i.query??{}),queryKey:c,queryFn:async n=>{let[,{tokenAddress:r,holder:i,spender:a}]=n.queryKey;return t.V(r,`confidentialIsOperatorQueryOptions: tokenAddress`),t.V(i,`confidentialIsOperatorQueryOptions: holder`),t.V(a,`confidentialIsOperatorQueryOptions: spender`),e.provider.readContract(t.A(r,i,a))},staleTime:3e4,enabled:!!(n&&a&&o)&&s}}function p(e,n,i={}){let a=n.query??{};return{...r.p(a),queryKey:r.f.confidentialBalance.owner(n.tokenAddress,n.account,i.walletAccount),queryFn:async n=>{let[,{owner:r}]=n.queryKey;return t.V(r,`confidentialBalanceQueryOptions: owner`),e.balanceOf(r)},enabled:!!n.account&&i.walletAccount!==void 0&&a?.enabled!==!1}}function m(e,i,a={}){let o=i?.account,s=a.walletAccount,c=i?.query??{},l=e.map(e=>e.address);return{...r.p(c),queryKey:r.f.confidentialBalances.tokens(l,o,s),queryFn:async r=>{let[,{owner:i}]=r.queryKey;return t.V(i,`confidentialBalancesQueryOptions: owner`),n.t.batchBalancesOf(e,i)},enabled:!!o&&e.length>0&&s!==void 0&&c?.enabled!==!1}}function h(e,n){let a=!!n.registryAddress&&n.query?.enabled!==!1,o=r.f.wrappersRegistry.tokenPairs(n.registryAddress??i.zeroAddress);return{...r.p(n.query??{}),queryKey:o,queryFn:async n=>{let[,{registryAddress:r}]=n.queryKey;return e.provider.readContract(t.i(r))},staleTime:e.registry.ttlMs,enabled:a}}function g(e,n){let a=!!n.registryAddress&&!!n.tokenAddress&&n.query?.enabled!==!1,o=r.f.wrappersRegistry.confidentialTokenAddress(n.registryAddress??i.zeroAddress,n.tokenAddress??i.zeroAddress);return{...r.p(n.query??{}),queryKey:o,queryFn:async n=>{let[,{registryAddress:r,tokenAddress:i}]=n.queryKey;return e.provider.readContract(t.t(r,i))},staleTime:e.registry.ttlMs,enabled:a}}function _(e,n){let a=!!n.registryAddress&&!!n.confidentialTokenAddress&&n.query?.enabled!==!1,o=r.f.wrappersRegistry.tokenAddress(n.registryAddress??i.zeroAddress,n.confidentialTokenAddress??i.zeroAddress);return{...r.p(n.query??{}),queryKey:o,queryFn:async n=>{let[,{registryAddress:r,confidentialTokenAddress:i}]=n.queryKey;return e.provider.readContract(t.n(r,i))},staleTime:e.registry.ttlMs,enabled:a}}function v(e,n){let a=!!n.registryAddress&&n.query?.enabled!==!1,o=r.f.wrappersRegistry.tokenPairsLength(n.registryAddress??i.zeroAddress);return{...r.p(n.query??{}),queryKey:o,queryFn:async n=>{let[,{registryAddress:r}]=n.queryKey;return e.provider.readContract(t.a(r))},staleTime:e.registry.ttlMs,enabled:a}}function y(e,n){let a=!!n.registryAddress&&n.fromIndex!==void 0&&n.toIndex!==void 0&&n.query?.enabled!==!1,o=r.f.wrappersRegistry.tokenPairsSlice(n.registryAddress??i.zeroAddress,String(n.fromIndex??0n),String(n.toIndex??0n));return{...r.p(n.query??{}),queryKey:o,queryFn:async n=>{let[,{registryAddress:r,fromIndex:i,toIndex:a}]=n.queryKey;return e.provider.readContract(t.o(r,BigInt(i),BigInt(a)))},staleTime:e.registry.ttlMs,enabled:a}}function b(e,n){let a=!!n.registryAddress&&n.index!==void 0&&n.query?.enabled!==!1,o=r.f.wrappersRegistry.tokenPair(n.registryAddress??i.zeroAddress,String(n.index??0n));return{...r.p(n.query??{}),queryKey:o,queryFn:async n=>{let[,{registryAddress:r,index:i}]=n.queryKey;return e.provider.readContract(t.r(r,BigInt(i)))},staleTime:e.registry.ttlMs,enabled:a}}function x(e,n){let a=!!n.registryAddress&&!!n.confidentialTokenAddress&&n.query?.enabled!==!1,o=r.f.wrappersRegistry.isConfidentialTokenValid(n.registryAddress??i.zeroAddress,n.confidentialTokenAddress??i.zeroAddress);return{...r.p(n.query??{}),queryKey:o,queryFn:async n=>{let[,{registryAddress:r,confidentialTokenAddress:i}]=n.queryKey;return e.provider.readContract(t.s(r,i))},staleTime:e.registry.ttlMs,enabled:a}}function S(e,t){let n=!!t.registryAddress&&t.query?.enabled!==!1,a=r.f.wrappersRegistry.listPairs(t.registryAddress??i.zeroAddress,t.page??1,t.pageSize??100,t.metadata??!1);return{...r.p(t.query??{}),queryKey:a,queryFn:async t=>{let[,{page:n,pageSize:r,metadata:i}]=t.queryKey;return e.listPairs({page:n,pageSize:r,metadata:i})},staleTime:e.ttlMs,enabled:n}}function C(e){return{mutationKey:[`zama.shield`,e.address],mutationFn:async({amount:t,...n})=>e.shield(t,n)}}function w(e){return{mutationKey:[`zama.confidentialTransfer`,e.address],mutationFn:async({to:t,amount:n,...r})=>e.confidentialTransfer(t,n,r)}}function T(e){return{mutationKey:[`zama.confidentialTransferAndCall`,e.address],mutationFn:async({to:t,amount:n,data:r,...i})=>e.confidentialTransferAndCall(t,n,r,i)}}function E(e){return{mutationKey:[`zama.confidentialTransferFrom`,e.address],mutationFn:async({from:t,to:n,amount:r,callbacks:i})=>e.confidentialTransferFrom(t,n,r,i)}}function D(e){return{mutationKey:[`zama.confidentialTransferFromAndCall`,e.address],mutationFn:async({from:t,to:n,amount:r,data:i,callbacks:a})=>e.confidentialTransferFromAndCall(t,n,r,i,a)}}function O(e){return{mutationKey:[`zama.confidentialSetOperator`,e.address],mutationFn:async({operator:t,until:n})=>e.setOperator(t,n)}}function k(e){return{mutationKey:[`zama.approveUnderlying`,e.address],mutationFn:async({amount:t})=>e.approveUnderlying(t)}}function A(e){return{mutationKey:[`zama.unshield`,e.address],mutationFn:async({amount:t,...n})=>e.unshield(t,n)}}function j(e){return{mutationKey:[`zama.unshieldAll`,e.address],mutationFn:async t=>e.unshieldAll(t||void 0)}}function M(e){return{mutationKey:[`zama.resumeUnshield`,e.address],mutationFn:async({unwrapTxHash:t,...n})=>e.resumeUnshield(t,n)}}function N(e){return{mutationKey:[`zama.unwrap`,e.address],mutationFn:async({amount:t})=>e.unwrap(t)}}function P(e){return{mutationKey:[`zama.wrap`,e.address],mutationFn:async({amount:t,...n})=>e.wrap(t,n)}}function F(e){return{mutationKey:[`zama.unwrapAll`,e.address],mutationFn:async()=>e.unwrapAll()}}function I(e){return{mutationKey:[`zama.finalizeUnwrap`,e.address],mutationFn:async({unwrapRequestId:t})=>e.finalizeUnwrap(t)}}function L(e){return{mutationKey:[`zama.encrypt`],mutationFn:async t=>e.encrypt(t)}}function R(e){return{mutationKey:[`zama.delegatedDecryptValues`],mutationFn:async t=>e.decryption.delegatedDecryptValues(t.encryptedInputs,t.delegatorAddress)}}function z(e){return{mutationKey:[`zama.decryptPublicValues`],mutationFn:async t=>e.decryption.decryptPublicValues(t),onSuccess:(e,t,n,i)=>{for(let[t,n]of Object.entries(e.clearValues))i.client.setQueryData(r.f.decryption.encryptedValue(t),n)}}}function B(e){return{mutationKey:[`zama.grantPermit`],mutationFn:t=>e.permits.grantPermit(t)}}function V(e){return{mutationKey:[`zama.preparePermit`],mutationFn:t=>e.offline.preparePermit(t)}}function H(e){return{mutationKey:[`zama.batchPreparePermits`],mutationFn:t=>e.offline.batchPreparePermits(t)}}function U(e){return{mutationKey:[`zama.registerPermit`],mutationFn:({prepared:t,signature:n})=>e.permits.registerPermit(t,n)}}function W(e){return{mutationKey:[`zama.batchRegisterPermits`],mutationFn:t=>e.permits.batchRegisterPermits(t)}}function G(e,t,n={}){let i=t.query?.enabled!==!1;return{...r.p(t?.query??{}),queryKey:r.f.hasPermit.scope(t.contractAddresses,n.walletAccount),queryFn:t=>{let[,{contractAddresses:n}]=t.queryKey;return e.permits.hasPermit(n)},staleTime:0,gcTime:0,refetchOnMount:`always`,refetchOnWindowFocus:!1,enabled:i&&n.walletAccount!==void 0&&t.contractAddresses.length>0}}function K(e){return{mutationKey:[`zama.revokePermits`],mutationFn:t=>t===void 0?e.permits.revokePermits():e.permits.revokePermits(t)}}function q(e){return{mutationKey:[`zama.clearCredentials`],mutationFn:()=>e.permits.clear()}}function J(e,t){return{mutationKey:[`zama.delegateDecryption`,t],mutationFn:async({delegateAddress:n,expirationDate:r})=>e.delegations.delegateDecryption({contractAddress:t,delegateAddress:n,expirationDate:r})}}function Y(e,t,n={}){return{queryKey:r.f.decryption.encryptedInputs(t,n.walletAccount),queryFn:t=>{let[,{encryptedInputs:n}]=t.queryKey;return e.decryption.decryptValues(n)},staleTime:1/0,enabled:t.length>0&&n.walletAccount!==void 0}}function X(e){return{mutationKey:[`zama.decryptBalanceAs`,e.address],mutationFn:async({delegatorAddress:t,accountAddress:n})=>e.decryptBalanceAs({delegatorAddress:t,accountAddress:n})}}function Z(e){return{mutationKey:[`zama.batchDecryptBalancesAs`,...e.map(e=>e.address)],mutationFn:async t=>n.t.batchDecryptBalancesAs(e,t)}}function Q(e,t){return{mutationKey:[`zama.revokeDelegation`,t],mutationFn:async({delegateAddress:n})=>e.delegations.revokeDelegation({contractAddress:t,delegateAddress:n})}}function $(e,n){return{...r.p(n.query??{}),queryKey:r.f.delegationStatus.scope(n.contractAddress,n.delegatorAddress,n.delegateAddress),queryFn:async n=>{let[,{contractAddress:r,delegatorAddress:i,delegateAddress:a}]=n.queryKey;return t.V(r,`delegationStatusQueryOptions: contractAddress`),t.V(i,`delegationStatusQueryOptions: delegatorAddress`),t.V(a,`delegationStatusQueryOptions: delegateAddress`),e.delegations.getStatus({contractAddress:r,delegatorAddress:i,delegateAddress:a})},enabled:!!(n.contractAddress&&n.delegatorAddress&&n.delegateAddress)&&n.query?.enabled!==!1}}exports.ZamaSDKEvents=t.H,exports.approveUnderlyingMutationOptions=k,exports.batchDecryptBalancesAsMutationOptions=Z,exports.batchPreparePermitsMutationOptions=H,exports.batchRegisterPermitsMutationOptions=W,exports.clearCredentialsMutationOptions=q,exports.confidentialBalanceQueryOptions=p,exports.confidentialBalancesQueryOptions=m,exports.confidentialIsOperatorQueryOptions=f,exports.confidentialSetOperatorMutationOptions=O,exports.confidentialTokenAddressQueryOptions=g,exports.confidentialTransferAndCallMutationOptions=T,exports.confidentialTransferFromAndCallMutationOptions=D,exports.confidentialTransferFromMutationOptions=E,exports.confidentialTransferMutationOptions=w,exports.decryptBalanceAsMutationOptions=X,exports.decryptPublicValuesMutationOptions=z,exports.decryptValuesQueryOptions=Y,exports.delegateDecryptionMutationOptions=J,exports.delegatedDecryptValuesMutationOptions=R,exports.delegationStatusQueryOptions=$,exports.encryptMutationOptions=L,exports.filterQueryOptions=r.p,exports.finalizeUnwrapMutationOptions=I,exports.grantPermitMutationOptions=B,exports.hasPermitQueryOptions=G,exports.hashFn=r.m,exports.invalidateAfterApproveUnderlying=r.t,exports.invalidateAfterSetOperator=r.n,exports.invalidateAfterShield=r.r,exports.invalidateAfterTransfer=r.i,exports.invalidateAfterUnshield=r.a,exports.invalidateAfterUnshieldSettled=r.o,exports.invalidateAfterUnwrap=r.s,exports.invalidateAfterWrap=r.c,exports.invalidateBalanceQueries=r.l,exports.invalidateWagmiBalanceQueries=r.u,exports.invalidateWalletLifecycleQueries=r.d,exports.isConfidentialQueryOptions=o,exports.isConfidentialTokenValidQueryOptions=x,exports.isWrapperQueryOptions=s,exports.listPairsQueryOptions=S,exports.pendingUnshieldQueryOptions=d,exports.preparePermitMutationOptions=V,exports.registerPermitMutationOptions=U,exports.resumeUnshieldMutationOptions=M,exports.revokeDelegationMutationOptions=Q,exports.revokePermitsMutationOptions=K,exports.shieldMutationOptions=C,exports.tokenAddressQueryOptions=_,exports.tokenMetadataQueryOptions=a,exports.tokenPairQueryOptions=b,exports.tokenPairsLengthQueryOptions=v,exports.tokenPairsQueryOptions=h,exports.tokenPairsSliceQueryOptions=y,exports.totalSupplyQueryOptions=c,exports.underlyingAllowanceQueryOptions=u,exports.unshieldAllMutationOptions=j,exports.unshieldMutationOptions=A,exports.unwrapAllMutationOptions=F,exports.unwrapMutationOptions=N,exports.wrapMutationOptions=P,exports.wrapperDiscoveryQueryOptions=l,exports.zamaQueryKeys=r.f;
2
2
  //# sourceMappingURL=index.cjs.map