@zama-fhe/sdk 3.3.0 → 3.3.1-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +0 -2
- package/dist/cjs/base-signer.cjs +1 -1
- package/dist/cjs/base-signer.cjs.map +1 -1
- package/dist/cjs/chains.cjs +1 -1
- package/dist/cjs/chains.cjs.map +1 -1
- package/dist/cjs/cleartext/index.cjs +1 -1
- package/dist/cjs/cleartext.cjs +2 -0
- package/dist/cjs/cleartext.cjs.map +1 -0
- package/dist/cjs/ethers/index.cjs.map +1 -1
- package/dist/cjs/fhevm-relayer.cjs +2 -0
- package/dist/cjs/fhevm-relayer.cjs.map +1 -0
- package/dist/cjs/index.cjs +1 -1
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/node/index.cjs +2 -0
- package/dist/cjs/node/index.cjs.map +1 -0
- package/dist/cjs/query/index.cjs +1 -1
- package/dist/cjs/query/index.cjs.map +1 -1
- package/dist/cjs/relayer.cjs +1 -1
- package/dist/cjs/relayer.cjs.map +1 -1
- package/dist/cjs/token.cjs +1 -1
- package/dist/cjs/token.cjs.map +1 -1
- package/dist/cjs/viem/index.cjs +1 -1
- package/dist/cjs/viem/index.cjs.map +1 -1
- package/dist/cjs/web/index.cjs +1 -590
- package/dist/cjs/web/index.cjs.map +1 -1
- package/dist/cjs/wrappers-registry.cjs.map +1 -1
- package/dist/esm/base-signer-CI-FYai2.js +2 -0
- package/dist/esm/base-signer-CI-FYai2.js.map +1 -0
- package/dist/esm/{base-signer-C3Wc5oi9.d.ts → base-signer-Q2EJECrc.d.ts} +2 -2
- package/dist/esm/chains/index.d.ts +2 -3
- package/dist/esm/chains/index.js +1 -1
- package/dist/esm/chains-CLv9HEJ_.js +2 -0
- package/dist/esm/chains-CLv9HEJ_.js.map +1 -0
- package/dist/esm/cleartext/index.d.ts +3 -2
- package/dist/esm/cleartext/index.js +1 -1
- package/dist/esm/cleartext-BfXTVQu-.js +2 -0
- package/dist/esm/cleartext-BfXTVQu-.js.map +1 -0
- package/dist/esm/cleartext-U6sPs_Kd.d.ts +19 -0
- package/dist/esm/ethers/index.d.ts +4 -5
- package/dist/esm/ethers/index.js +1 -1
- package/dist/esm/ethers/index.js.map +1 -1
- package/dist/esm/fhevm-relayer-B-lEKfPQ.js +2 -0
- package/dist/esm/fhevm-relayer-B-lEKfPQ.js.map +1 -0
- package/dist/esm/index-BnIp_-Ak.d.ts +328 -0
- package/dist/esm/{index-CYBH0nyo.d.ts → index-D66eC3G7.d.ts} +60 -13
- package/dist/esm/index.d.ts +8 -11
- package/dist/esm/index.js +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/node/index.d.ts +5 -194
- package/dist/esm/node/index.js +1 -1
- package/dist/esm/node/index.js.map +1 -1
- package/dist/esm/query/index.d.ts +3 -380
- package/dist/esm/query/index.js +1 -1
- package/dist/esm/query/index.js.map +1 -1
- package/dist/esm/relayer-BYq9bLh8.js +2 -0
- package/dist/esm/relayer-BYq9bLh8.js.map +1 -0
- package/dist/esm/token-CmHTAAWW.js +2 -0
- package/dist/esm/token-CmHTAAWW.js.map +1 -0
- package/dist/esm/{types-piBsdTIP.d.ts → types-Bov8XY36.d.ts} +3 -3
- package/dist/esm/{types-OHIaPwCy.d.ts → types-BpvL50qX.d.ts} +3 -3
- package/dist/esm/types-C-WTLcHZ.d.ts +988 -0
- package/dist/esm/viem/index.d.ts +4 -5
- package/dist/esm/viem/index.js +1 -1
- package/dist/esm/viem/index.js.map +1 -1
- package/dist/esm/web/index.d.ts +6 -9
- package/dist/esm/web/index.js +1 -590
- package/dist/esm/web/index.js.map +1 -1
- package/dist/esm/{wrappers-registry-C1oK8Bi6.js → wrappers-registry-xZWzyAi4.js} +2 -2
- package/dist/esm/wrappers-registry-xZWzyAi4.js.map +1 -0
- package/dist/esm/{index-C1Mtc8Rw.d.ts → zama-sdk-q4_qt64Q.d.ts} +1471 -1102
- package/package.json +6 -2
- package/dist/cjs/assertions.cjs +0 -2
- package/dist/cjs/assertions.cjs.map +0 -1
- package/dist/cjs/encryption.cjs +0 -2
- package/dist/cjs/encryption.cjs.map +0 -1
- package/dist/cjs/relayer-cleartext.cjs +0 -2
- package/dist/cjs/relayer-cleartext.cjs.map +0 -1
- package/dist/cjs/relayer-sdk.worker.js +0 -589
- package/dist/cjs/timeout.cjs +0 -2
- package/dist/cjs/timeout.cjs.map +0 -1
- package/dist/cjs/validation.cjs +0 -2
- package/dist/cjs/validation.cjs.map +0 -1
- package/dist/esm/assertions-zYseN5Xz.js +0 -2
- package/dist/esm/assertions-zYseN5Xz.js.map +0 -1
- package/dist/esm/base-signer-DjytqPkd.js +0 -2
- package/dist/esm/base-signer-DjytqPkd.js.map +0 -1
- package/dist/esm/chains-CXcO1DBP.js +0 -2
- package/dist/esm/chains-CXcO1DBP.js.map +0 -1
- package/dist/esm/cleartext-DAkOTlrE.d.ts +0 -19
- package/dist/esm/cleartext-rTWFctyd.js +0 -2
- package/dist/esm/cleartext-rTWFctyd.js.map +0 -1
- package/dist/esm/encryption-x4Z_Icqk.js +0 -2
- package/dist/esm/encryption-x4Z_Icqk.js.map +0 -1
- package/dist/esm/hex-A72GrTf9.js +0 -2
- package/dist/esm/hex-A72GrTf9.js.map +0 -1
- package/dist/esm/indexeddb-storage-Mi-fCWN3.js +0 -2
- package/dist/esm/indexeddb-storage-Mi-fCWN3.js.map +0 -1
- package/dist/esm/memory-storage-fp9RY5BQ.js +0 -2
- package/dist/esm/memory-storage-fp9RY5BQ.js.map +0 -1
- package/dist/esm/node/relayer-sdk.node-worker.d.ts +0 -1
- package/dist/esm/node/relayer-sdk.node-worker.js +0 -2
- package/dist/esm/node/relayer-sdk.node-worker.js.map +0 -1
- package/dist/esm/relayer-cleartext-Bp6jtxDd.js +0 -2
- package/dist/esm/relayer-cleartext-Bp6jtxDd.js.map +0 -1
- package/dist/esm/relayer-cleartext-CSeMlmGO.d.ts +0 -844
- package/dist/esm/relayer-eavK5bfZ.js +0 -2
- package/dist/esm/relayer-eavK5bfZ.js.map +0 -1
- package/dist/esm/relayer-sdk.worker.js +0 -589
- package/dist/esm/timeout-CNVfiaJD.js +0 -2
- package/dist/esm/timeout-CNVfiaJD.js.map +0 -1
- package/dist/esm/token-Bt33g0zQ.js +0 -2
- package/dist/esm/token-Bt33g0zQ.js.map +0 -1
- package/dist/esm/types-BgczXqW2.d.ts +0 -49
- package/dist/esm/types-Gn5MeDsr.d.ts +0 -669
- package/dist/esm/validation-DLszOweh.js +0 -2
- package/dist/esm/validation-DLszOweh.js.map +0 -1
- package/dist/esm/worker.base-client-BVnT4yJa.js +0 -2
- package/dist/esm/worker.base-client-BVnT4yJa.js.map +0 -1
- package/dist/esm/wrappers-registry-C1oK8Bi6.js.map +0 -1
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../fhevm-relayer.cjs"),t=require("../cleartext.cjs"),n=require("../chains.cjs");let r=require("node:async_hooks");function i(t){return{type:`node`,createRelayer:n=>new e.t({chain:n,options:t})}}var a=class{#e=new r.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 o=new a;exports.AsyncLocalMapStorage=a,exports.anvil=n.t,exports.asyncLocalStorage=o,exports.bscTestnet=n.n,exports.chains=n.r,exports.cleartext=t.t,exports.hardhat=n.i,exports.hoodi=n.a,exports.ingenTestnet=n.o,exports.mainnet=n.s,exports.node=i,exports.sepolia=n.c;
|
|
2
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["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\";\n\n/** Node transport — drives the FHE backend directly on the calling thread. */\nexport interface NodeRelayerConfig extends RelayerConfig {\n readonly type: \"node\";\n readonly createRelayer: (chain: FheChain) => FhevmRelayer;\n}\n\n/**\n * Node.js transport — drives `@fhevm/sdk` via {@link FhevmRelayer} on the calling thread.\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 { type: \"node\", createRelayer: (chain) => new FhevmRelayer({ chain, options }) };\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 async get<T = unknown>(key: string): Promise<T | null> {\n return (this.#als.getStore()?.get(key) as T) ?? null;\n }\n\n async set<T = unknown>(key: string, value: T): Promise<void> {\n this.#als.getStore()?.set(key, value);\n }\n\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":"sMAsBA,SAAgB,EAAK,EAA6C,CAChE,MAAO,CAAE,KAAM,OAAQ,cAAgB,GAAU,IAAIA,EAAAA,EAAa,CAAE,QAAO,SAAQ,CAAC,CAAE,CACxF,CCFA,IAAa,EAAb,KAA4D,CAC1D,GAAgB,IAAIE,EAAAA,kBAGpB,IAAO,EAA0C,CAC/C,OAAO,KAAKD,GAAK,IAAI,IAAI,IAAO,CAAE,CACpC,CAEA,MAAM,IAAiB,EAAgC,CACrD,OAAQ,KAAKA,GAAK,SAAS,CAAC,EAAE,IAAI,CAAG,GAAW,IAClD,CAEA,MAAM,IAAiB,EAAa,EAAyB,CAC3D,KAAKA,GAAK,SAAS,CAAC,EAAE,IAAI,EAAK,CAAK,CACtC,CAEA,MAAM,OAAO,EAA4B,CACvC,KAAKA,GAAK,SAAS,CAAC,EAAE,OAAO,CAAG,CAClC,CACF,EAGA,MAAa,EAAoB,IAAI"}
|
package/dist/cjs/query/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../wrappers-registry.cjs"),t=require("../token.cjs"),n=require("../assertions.cjs");let r=require("viem"),i=require("zod/mini");function a(e){if(!o(e))return!1;let t=e.constructor;if(t===void 0)return!0;let n=t.prototype;return!(!o(n)||!n.hasOwnProperty(`isPrototypeOf`))}function o(e){return Object.prototype.toString.call(e)===`[object Object]`}function s(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:ee,meta:y,query:b,pollingInterval:x,...S}=e;return S}function c(e){return JSON.stringify(e,(e,t)=>a(t)?Object.keys(t).toSorted().reduce((e,n)=>(e[n]=t[n],e),{}):typeof t==`bigint`?t.toString():t)}const l=e=>e.map(e=>(0,r.getAddress)(e)),u=e=>e===void 0?void 0:(0,r.getAddress)(e),d=e=>e?{walletAddress:(0,r.getAddress)(e.address),walletChainId:e.chainId}:{},f={confidentialBalance:{all:[`zama.confidentialBalance`],token:e=>[`zama.confidentialBalance`,{tokenAddress:(0,r.getAddress)(e)}],owner:(e,t,n)=>[`zama.confidentialBalance`,{tokenAddress:(0,r.getAddress)(e),...d(n),...t?{owner:(0,r.getAddress)(t)}:{}}]},confidentialBalances:{all:[`zama.confidentialBalances`],tokens:(e,t,n)=>[`zama.confidentialBalances`,{tokenAddresses:l(e),...d(n),...t?{owner:(0,r.getAddress)(t)}:{}}]},tokenMetadata:{all:[`zama.tokenMetadata`],token:e=>[`zama.tokenMetadata`,{tokenAddress:(0,r.getAddress)(e)}]},isConfidential:{all:[`zama.isConfidential`],token:e=>[`zama.isConfidential`,{tokenAddress:(0,r.getAddress)(e)}]},isWrapper:{all:[`zama.isWrapper`],token:e=>[`zama.isWrapper`,{tokenAddress:(0,r.getAddress)(e)}]},wrapperDiscovery:{all:[`zama.wrapperDiscovery`],token:(e,t,n)=>{let r=u(e),i=u(t),a=u(n);return[`zama.wrapperDiscovery`,{...r?{tokenAddress:r}:{},...i?{erc20Address:i}:{},...a?{registryAddress:a}:{}}]}},underlyingAllowance:{all:[`zama.underlyingAllowance`],token:e=>[`zama.underlyingAllowance`,{tokenAddress:(0,r.getAddress)(e)}],scope:(e,t)=>[`zama.underlyingAllowance`,{tokenAddress:(0,r.getAddress)(e),...t?{owner:(0,r.getAddress)(t)}:{}}]},confidentialIsOperator:{all:[`zama.confidentialIsOperator`],token:e=>{let t=u(e);return[`zama.confidentialIsOperator`,t?{tokenAddress:t}:{}]},scope:(e,t,n)=>{let r=u(e),i=u(t),a=u(n);return[`zama.confidentialIsOperator`,{...r?{tokenAddress:r}:{},...i?{holder:i}:{},...a?{spender:a}:{}}]}},totalSupply:{all:[`zama.totalSupply`],token:e=>[`zama.totalSupply`,{tokenAddress:(0,r.getAddress)(e)}]},pendingUnshield:{all:[`zama.pendingUnshield`],token:e=>[`zama.pendingUnshield`,{tokenAddress:(0,r.getAddress)(e)}]},hasPermit:{all:[`zama.hasPermit`],scope:(e,t)=>[`zama.hasPermit`,{...d(t),contractAddresses:l(e).toSorted()}]},delegationStatus:{all:[`zama.delegationStatus`],contract:e=>{let t=u(e);return[`zama.delegationStatus`,t?{contractAddress:t}:{}]},scope:(e,t,n)=>{let r=u(e),i=u(t),a=u(n);return[`zama.delegationStatus`,{...r?{contractAddress:r}:{},...i?{delegatorAddress:i}:{},...a?{delegateAddress:a}:{}}]}},decryption:{all:[`zama.decryption`],encryptedValue:(e,t)=>[`zama.decryption`,{encryptedValue:e,...t===void 0?{}:{contractAddress:(0,r.getAddress)(t)}}],encryptedInputs:(e,t)=>[`zama.decryption`,{...d(t),encryptedInputs:[...e].toSorted((e,t)=>e.encryptedValue.localeCompare(t.encryptedValue)).map(e=>({encryptedValue:e.encryptedValue,contractAddress:(0,r.getAddress)(e.contractAddress)}))}]},wrappersRegistry:{all:[`zama.wrappersRegistry`],chainId:()=>[`zama.wrappersRegistry`,{type:`chainId`}],tokenPairs:e=>[`zama.wrappersRegistry`,{type:`tokenPairs`,registryAddress:(0,r.getAddress)(e)}],confidentialTokenAddress:(e,t)=>[`zama.wrappersRegistry`,{type:`confidentialTokenAddress`,registryAddress:(0,r.getAddress)(e),tokenAddress:(0,r.getAddress)(t)}],tokenAddress:(e,t)=>[`zama.wrappersRegistry`,{type:`tokenAddress`,registryAddress:(0,r.getAddress)(e),confidentialTokenAddress:(0,r.getAddress)(t)}],tokenPairsLength:e=>[`zama.wrappersRegistry`,{type:`tokenPairsLength`,registryAddress:(0,r.getAddress)(e)}],tokenPairsSlice:(e,t,n)=>[`zama.wrappersRegistry`,{type:`tokenPairsSlice`,registryAddress:(0,r.getAddress)(e),fromIndex:t,toIndex:n}],tokenPair:(e,t)=>[`zama.wrappersRegistry`,{type:`tokenPair`,registryAddress:(0,r.getAddress)(e),index:t}],isConfidentialTokenValid:(e,t)=>[`zama.wrappersRegistry`,{type:`isConfidentialTokenValid`,registryAddress:(0,r.getAddress)(e),confidentialTokenAddress:(0,r.getAddress)(t)}],listPairs:(e,t,n,i)=>[`zama.wrappersRegistry`,{type:`listPairs`,registryAddress:(0,r.getAddress)(e),page:t,pageSize:n,metadata:i}]}};function p(e,t){e.invalidateQueries({queryKey:f.underlyingAllowance.token(t)})}function m(e,t){e.invalidateQueries({queryKey:f.pendingUnshield.token(t)})}function h(e,t){g(e,t),p(e,t),m(e,t),O(e)}function g(e,t){e.invalidateQueries({queryKey:f.confidentialBalance.token(t)}),e.invalidateQueries({queryKey:f.confidentialBalances.all})}function _(e,t){g(e,t),p(e,t),O(e)}function v(e,t){g(e,t),p(e,t),m(e,t),O(e)}function ee(e,t){m(e,t)}function y(e,t){g(e,t)}function b(e,t){p(e,t)}function x(e,t){e.invalidateQueries({queryKey:f.confidentialIsOperator.token(t)})}function S(e){return Array.isArray(e.queryKey)&&typeof e.queryKey[0]==`string`?e.queryKey[0].startsWith(`zama.`):!1}const C=i.z.enum([`balanceOf`,`confidentialBalanceOf`]),w=i.z.object({functionName:C}),T=i.z.object({contracts:i.z.array(i.z.unknown())});function E(e){if(w.safeParse(e).success)return!0;let t=T.safeParse(e);return t.success&&t.data.contracts.some(e=>w.safeParse(e).success)}function D(e){return Array.isArray(e.queryKey)&&e.queryKey.some(E)}function O(e){e.invalidateQueries({predicate:D})}function k(e){e.removeQueries({queryKey:f.decryption.all}),e.removeQueries({queryKey:f.hasPermit.all}),e.invalidateQueries({predicate:S}),O(e)}function A(t,n,r){let i=f.tokenMetadata.token(n);return{...s(r?.query??{}),queryKey:i,queryFn:async n=>{let[,{tokenAddress:r}]=n.queryKey,[i,a,o]=await Promise.all([t.provider.readContract(e.b(r)),t.provider.readContract(e.x(r)),t.provider.readContract(e.v(r))]);return{name:i,symbol:a,decimals:o}},staleTime:1/0,enabled:r?.query?.enabled!==!1}}function j(t,r,i){let a=f.isConfidential.token(r);return{...s(i?.query??{}),queryKey:a,queryFn:async r=>{let[,{tokenAddress:i}]=r.queryKey;try{return await t.provider.readContract(e.d(i))}catch(e){if(n.u(e))return!1;throw e}},staleTime:1/0,enabled:i?.query?.enabled!==!1}}function M(t,r,i){let a=f.isWrapper.token(r);return{...s(i?.query??{}),queryKey:a,queryFn:async r=>{let[,{tokenAddress:i}]=r.queryKey;try{return await t.provider.readContract(e.f(i))}catch(e){if(n.u(e))return!1;throw e}},staleTime:1/0,enabled:i?.query?.enabled!==!1}}function N(t,n,r){let i=f.totalSupply.token(n);return{...s(r?.query??{}),queryKey:i,queryFn:async n=>{let[,{tokenAddress:r}]=n.queryKey;return t.provider.readContract(e.k(r))},staleTime:3e4,enabled:r?.query?.enabled!==!1}}function P(e,t){let r=f.wrapperDiscovery.token(t.tokenAddress,t.erc20Address,t.registryAddress);return{...s(t.query??{}),queryKey:r,queryFn:async t=>{let[,{erc20Address:r}]=t.queryKey;n.r(r,`wrapperDiscoveryQueryOptions: erc20Address`);let i=await e.getConfidentialToken(r);return i?i.confidentialTokenAddress:null},staleTime:1/0,enabled:!!(t.tokenAddress&&t.erc20Address&&t.registryAddress)&&t.query?.enabled!==!1}}function F(t,r,i){let a=i.owner,o=i.query?.enabled!==!1,c=f.underlyingAllowance.scope(r,a);return{...s(i.query??{}),queryKey:c,queryFn:async r=>{let[,{tokenAddress:i,owner:a}]=r.queryKey;n.r(a,`underlyingAllowanceQueryOptions: owner`);let o=await t.provider.readContract(e.N(i));return t.provider.readContract(e.h(o,a,i))},staleTime:3e4,enabled:!!a&&o}}function I(e,t,n){let r=f.pendingUnshield.token(t);return{...s(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 L(t,r,i){let a=i.holder,o=i.spender,c=i.query?.enabled!==!1,l=f.confidentialIsOperator.scope(r,a,o);return{...s(i.query??{}),queryKey:l,queryFn:async r=>{let[,{tokenAddress:i,holder:a,spender:o}]=r.queryKey;return n.r(i,`confidentialIsOperatorQueryOptions: tokenAddress`),n.r(a,`confidentialIsOperatorQueryOptions: holder`),n.r(o,`confidentialIsOperatorQueryOptions: spender`),t.provider.readContract(e.A(i,a,o))},staleTime:3e4,enabled:!!(r&&a&&o)&&c}}function R(e,t,r={}){let i=t.query??{};return{...s(i),queryKey:f.confidentialBalance.owner(t.tokenAddress,t.account,r.walletAccount),queryFn:async t=>{let[,{owner:r}]=t.queryKey;return n.r(r,`confidentialBalanceQueryOptions: owner`),e.balanceOf(r)},enabled:!!t.account&&r.walletAccount!==void 0&&i?.enabled!==!1}}function z(e,r,i={}){let a=r?.account,o=i.walletAccount,c=r?.query??{},l=e.map(e=>e.address);return{...s(c),queryKey:f.confidentialBalances.tokens(l,a,o),queryFn:async r=>{let[,{owner:i}]=r.queryKey;return n.r(i,`confidentialBalancesQueryOptions: owner`),t.t.batchBalancesOf(e,i)},enabled:!!a&&e.length>0&&o!==void 0&&c?.enabled!==!1}}function B(t,n){let i=!!n.registryAddress&&n.query?.enabled!==!1,a=f.wrappersRegistry.tokenPairs(n.registryAddress??r.zeroAddress);return{...s(n.query??{}),queryKey:a,queryFn:async n=>{let[,{registryAddress:r}]=n.queryKey;return t.provider.readContract(e.i(r))},staleTime:t.registry.ttlMs,enabled:i}}function V(t,n){let i=!!n.registryAddress&&!!n.tokenAddress&&n.query?.enabled!==!1,a=f.wrappersRegistry.confidentialTokenAddress(n.registryAddress??r.zeroAddress,n.tokenAddress??r.zeroAddress);return{...s(n.query??{}),queryKey:a,queryFn:async n=>{let[,{registryAddress:r,tokenAddress:i}]=n.queryKey;return t.provider.readContract(e.t(r,i))},staleTime:t.registry.ttlMs,enabled:i}}function H(t,n){let i=!!n.registryAddress&&!!n.confidentialTokenAddress&&n.query?.enabled!==!1,a=f.wrappersRegistry.tokenAddress(n.registryAddress??r.zeroAddress,n.confidentialTokenAddress??r.zeroAddress);return{...s(n.query??{}),queryKey:a,queryFn:async n=>{let[,{registryAddress:r,confidentialTokenAddress:i}]=n.queryKey;return t.provider.readContract(e.n(r,i))},staleTime:t.registry.ttlMs,enabled:i}}function te(t,n){let i=!!n.registryAddress&&n.query?.enabled!==!1,a=f.wrappersRegistry.tokenPairsLength(n.registryAddress??r.zeroAddress);return{...s(n.query??{}),queryKey:a,queryFn:async n=>{let[,{registryAddress:r}]=n.queryKey;return t.provider.readContract(e.a(r))},staleTime:t.registry.ttlMs,enabled:i}}function U(t,n){let i=!!n.registryAddress&&n.fromIndex!==void 0&&n.toIndex!==void 0&&n.query?.enabled!==!1,a=f.wrappersRegistry.tokenPairsSlice(n.registryAddress??r.zeroAddress,String(n.fromIndex??0n),String(n.toIndex??0n));return{...s(n.query??{}),queryKey:a,queryFn:async n=>{let[,{registryAddress:r,fromIndex:i,toIndex:a}]=n.queryKey;return t.provider.readContract(e.o(r,BigInt(i),BigInt(a)))},staleTime:t.registry.ttlMs,enabled:i}}function W(t,n){let i=!!n.registryAddress&&n.index!==void 0&&n.query?.enabled!==!1,a=f.wrappersRegistry.tokenPair(n.registryAddress??r.zeroAddress,String(n.index??0n));return{...s(n.query??{}),queryKey:a,queryFn:async n=>{let[,{registryAddress:r,index:i}]=n.queryKey;return t.provider.readContract(e.r(r,BigInt(i)))},staleTime:t.registry.ttlMs,enabled:i}}function G(t,n){let i=!!n.registryAddress&&!!n.confidentialTokenAddress&&n.query?.enabled!==!1,a=f.wrappersRegistry.isConfidentialTokenValid(n.registryAddress??r.zeroAddress,n.confidentialTokenAddress??r.zeroAddress);return{...s(n.query??{}),queryKey:a,queryFn:async n=>{let[,{registryAddress:r,confidentialTokenAddress:i}]=n.queryKey;return t.provider.readContract(e.s(r,i))},staleTime:t.registry.ttlMs,enabled:i}}function K(e,t){let n=!!t.registryAddress&&t.query?.enabled!==!1,i=f.wrappersRegistry.listPairs(t.registryAddress??r.zeroAddress,t.page??1,t.pageSize??100,t.metadata??!1);return{...s(t.query??{}),queryKey:i,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 q(e){return{mutationKey:[`zama.shield`,e.address],mutationFn:async({amount:t,...n})=>e.shield(t,n)}}function J(e){return{mutationKey:[`zama.confidentialTransfer`,e.address],mutationFn:async({to:t,amount:n,...r})=>e.confidentialTransfer(t,n,r)}}function Y(e){return{mutationKey:[`zama.confidentialTransferAndCall`,e.address],mutationFn:async({to:t,amount:n,data:r,...i})=>e.confidentialTransferAndCall(t,n,r,i)}}function X(e){return{mutationKey:[`zama.confidentialTransferFrom`,e.address],mutationFn:async({from:t,to:n,amount:r,callbacks:i})=>e.confidentialTransferFrom(t,n,r,i)}}function Z(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 Q(e){return{mutationKey:[`zama.confidentialSetOperator`,e.address],mutationFn:async({operator:t,until:n})=>e.setOperator(t,n)}}function ne(e){return{mutationKey:[`zama.approveUnderlying`,e.address],mutationFn:async({amount:t})=>e.approveUnderlying(t)}}function re(e){return{mutationKey:[`zama.unshield`,e.address],mutationFn:async({amount:t,...n})=>e.unshield(t,n)}}function ie(e){return{mutationKey:[`zama.unshieldAll`,e.address],mutationFn:async t=>e.unshieldAll(t||void 0)}}function ae(e){return{mutationKey:[`zama.resumeUnshield`,e.address],mutationFn:async({unwrapTxHash:t,...n})=>e.resumeUnshield(t,n)}}function oe(e){return{mutationKey:[`zama.unwrap`,e.address],mutationFn:async({amount:t})=>e.unwrap(t)}}function se(e){return{mutationKey:[`zama.unwrapAll`,e.address],mutationFn:async()=>e.unwrapAll()}}function ce(e){return{mutationKey:[`zama.finalizeUnwrap`,e.address],mutationFn:async({unwrapRequestId:t})=>e.finalizeUnwrap(t)}}function le(e){return{mutationKey:[`zama.encrypt`],mutationFn:async t=>e.encrypt(t)}}function ue(e){return{mutationKey:[`zama.delegatedDecryptValues`],mutationFn:async t=>e.decryption.delegatedDecryptValues(t.encryptedInputs,t.delegatorAddress)}}function de(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(f.decryption.encryptedValue(t),n)}}}function fe(e){return{mutationKey:[`zama.grantPermit`],mutationFn:t=>e.permits.grantPermit(t)}}function pe(e,t,n={}){let r=t.query?.enabled!==!1;return{...s(t?.query??{}),queryKey: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 $(e){return{mutationKey:[`zama.revokePermits`],mutationFn:t=>t===void 0?e.permits.revokePermits():e.permits.revokePermits(t)}}function me(e){return{mutationKey:[`zama.clearCredentials`],mutationFn:()=>e.permits.clear()}}function he(e,t){return{mutationKey:[`zama.delegateDecryption`,t],mutationFn:async({delegateAddress:n,expirationDate:r})=>e.delegations.delegateDecryption({contractAddress:t,delegateAddress:n,expirationDate:r})}}function ge(e,t,n={}){return{queryKey: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 _e(e){return{mutationKey:[`zama.decryptBalanceAs`,e.address],mutationFn:async({delegatorAddress:t,accountAddress:n})=>e.decryptBalanceAs({delegatorAddress:t,accountAddress:n})}}function ve(e){return{mutationKey:[`zama.batchDecryptBalancesAs`,...e.map(e=>e.address)],mutationFn:async n=>t.t.batchDecryptBalancesAs(e,n)}}function ye(e,t){return{mutationKey:[`zama.revokeDelegation`,t],mutationFn:async({delegateAddress:n})=>e.delegations.revokeDelegation({contractAddress:t,delegateAddress:n})}}function be(e,r){return{...s(r.query??{}),queryKey:f.delegationStatus.scope(r.contractAddress,r.delegatorAddress,r.delegateAddress),queryFn:async r=>{let[,{contractAddress:i,delegatorAddress:a,delegateAddress:o}]=r.queryKey;n.r(i,`delegationStatusQueryOptions: contractAddress`),n.r(a,`delegationStatusQueryOptions: delegatorAddress`),n.r(o,`delegationStatusQueryOptions: delegateAddress`);let s=await e.relayer.getAclAddress(),c=await e.provider.readContract(t.d(s,a,o,i)),l;return l=c===0n?!1:c===t.l?!0:c>await e.provider.getBlockTimestamp(),{isActive:l,expiryTimestamp:c}},enabled:!!(r.contractAddress&&r.delegatorAddress&&r.delegateAddress)&&r.query?.enabled!==!1}}exports.ZamaSDKEvents=t.o,exports.approveUnderlyingMutationOptions=ne,exports.batchDecryptBalancesAsMutationOptions=ve,exports.clearCredentialsMutationOptions=me,exports.confidentialBalanceQueryOptions=R,exports.confidentialBalancesQueryOptions=z,exports.confidentialIsOperatorQueryOptions=L,exports.confidentialSetOperatorMutationOptions=Q,exports.confidentialTokenAddressQueryOptions=V,exports.confidentialTransferAndCallMutationOptions=Y,exports.confidentialTransferFromAndCallMutationOptions=Z,exports.confidentialTransferFromMutationOptions=X,exports.confidentialTransferMutationOptions=J,exports.decryptBalanceAsMutationOptions=_e,exports.decryptPublicValuesMutationOptions=de,exports.decryptValuesQueryOptions=ge,exports.delegateDecryptionMutationOptions=he,exports.delegatedDecryptValuesMutationOptions=ue,exports.delegationStatusQueryOptions=be,exports.encryptMutationOptions=le,exports.filterQueryOptions=s,exports.finalizeUnwrapMutationOptions=ce,exports.grantPermitMutationOptions=fe,exports.hasPermitQueryOptions=pe,exports.hashFn=c,exports.invalidateAfterApproveUnderlying=b,exports.invalidateAfterSetOperator=x,exports.invalidateAfterShield=_,exports.invalidateAfterTransfer=y,exports.invalidateAfterUnshield=v,exports.invalidateAfterUnshieldSettled=ee,exports.invalidateAfterUnwrap=h,exports.invalidateBalanceQueries=g,exports.invalidateWagmiBalanceQueries=O,exports.invalidateWalletLifecycleQueries=k,exports.isConfidentialQueryOptions=j,exports.isConfidentialTokenValidQueryOptions=G,exports.isWrapperQueryOptions=M,exports.listPairsQueryOptions=K,exports.pendingUnshieldQueryOptions=I,exports.resumeUnshieldMutationOptions=ae,exports.revokeDelegationMutationOptions=ye,exports.revokePermitsMutationOptions=$,exports.shieldMutationOptions=q,exports.tokenAddressQueryOptions=H,exports.tokenMetadataQueryOptions=A,exports.tokenPairQueryOptions=W,exports.tokenPairsLengthQueryOptions=te,exports.tokenPairsQueryOptions=B,exports.tokenPairsSliceQueryOptions=U,exports.totalSupplyQueryOptions=N,exports.underlyingAllowanceQueryOptions=F,exports.unshieldAllMutationOptions=ie,exports.unshieldMutationOptions=re,exports.unwrapAllMutationOptions=se,exports.unwrapMutationOptions=oe,exports.wrapperDiscoveryQueryOptions=P,exports.zamaQueryKeys=f;
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../wrappers-registry.cjs"),t=require("../token.cjs");let n=require("viem"),r=require("zod/mini");function i(e){if(!a(e))return!1;let t=e.constructor;if(t===void 0)return!0;let n=t.prototype;return!(!a(n)||!n.hasOwnProperty(`isPrototypeOf`))}function a(e){return Object.prototype.toString.call(e)===`[object Object]`}function o(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:ee,throwOnError:v,meta:y,query:b,pollingInterval:x,...S}=e;return S}function s(e){return JSON.stringify(e,(e,t)=>i(t)?Object.keys(t).toSorted().reduce((e,n)=>(e[n]=t[n],e),{}):typeof t==`bigint`?t.toString():t)}const c=e=>e.map(e=>(0,n.getAddress)(e)),l=e=>e===void 0?void 0:(0,n.getAddress)(e),u=e=>e?{walletAddress:(0,n.getAddress)(e.address),walletChainId:e.chainId}:{},d={confidentialBalance:{all:[`zama.confidentialBalance`],token:e=>[`zama.confidentialBalance`,{tokenAddress:(0,n.getAddress)(e)}],owner:(e,t,r)=>[`zama.confidentialBalance`,{tokenAddress:(0,n.getAddress)(e),...u(r),...t?{owner:(0,n.getAddress)(t)}:{}}]},confidentialBalances:{all:[`zama.confidentialBalances`],tokens:(e,t,r)=>[`zama.confidentialBalances`,{tokenAddresses:c(e),...u(r),...t?{owner:(0,n.getAddress)(t)}:{}}]},tokenMetadata:{all:[`zama.tokenMetadata`],token:e=>[`zama.tokenMetadata`,{tokenAddress:(0,n.getAddress)(e)}]},isConfidential:{all:[`zama.isConfidential`],token:e=>[`zama.isConfidential`,{tokenAddress:(0,n.getAddress)(e)}]},isWrapper:{all:[`zama.isWrapper`],token:e=>[`zama.isWrapper`,{tokenAddress:(0,n.getAddress)(e)}]},wrapperDiscovery:{all:[`zama.wrapperDiscovery`],token:(e,t,n)=>{let r=l(e),i=l(t),a=l(n);return[`zama.wrapperDiscovery`,{...r?{tokenAddress:r}:{},...i?{erc20Address:i}:{},...a?{registryAddress:a}:{}}]}},underlyingAllowance:{all:[`zama.underlyingAllowance`],token:e=>[`zama.underlyingAllowance`,{tokenAddress:(0,n.getAddress)(e)}],scope:(e,t)=>[`zama.underlyingAllowance`,{tokenAddress:(0,n.getAddress)(e),...t?{owner:(0,n.getAddress)(t)}:{}}]},confidentialIsOperator:{all:[`zama.confidentialIsOperator`],token:e=>{let t=l(e);return[`zama.confidentialIsOperator`,t?{tokenAddress:t}:{}]},scope:(e,t,n)=>{let r=l(e),i=l(t),a=l(n);return[`zama.confidentialIsOperator`,{...r?{tokenAddress:r}:{},...i?{holder:i}:{},...a?{spender:a}:{}}]}},totalSupply:{all:[`zama.totalSupply`],token:e=>[`zama.totalSupply`,{tokenAddress:(0,n.getAddress)(e)}]},pendingUnshield:{all:[`zama.pendingUnshield`],token:e=>[`zama.pendingUnshield`,{tokenAddress:(0,n.getAddress)(e)}]},hasPermit:{all:[`zama.hasPermit`],scope:(e,t)=>[`zama.hasPermit`,{...u(t),contractAddresses:c(e).toSorted()}]},delegationStatus:{all:[`zama.delegationStatus`],contract:e=>{let t=l(e);return[`zama.delegationStatus`,t?{contractAddress:t}:{}]},scope:(e,t,n)=>{let r=l(e),i=l(t),a=l(n);return[`zama.delegationStatus`,{...r?{contractAddress:r}:{},...i?{delegatorAddress:i}:{},...a?{delegateAddress:a}:{}}]}},decryption:{all:[`zama.decryption`],encryptedValue:(e,t)=>[`zama.decryption`,{encryptedValue:e,...t===void 0?{}:{contractAddress:(0,n.getAddress)(t)}}],encryptedInputs:(e,t)=>[`zama.decryption`,{...u(t),encryptedInputs:[...e].toSorted((e,t)=>e.encryptedValue.localeCompare(t.encryptedValue)).map(e=>({encryptedValue:e.encryptedValue,contractAddress:(0,n.getAddress)(e.contractAddress)}))}]},wrappersRegistry:{all:[`zama.wrappersRegistry`],chainId:()=>[`zama.wrappersRegistry`,{type:`chainId`}],tokenPairs:e=>[`zama.wrappersRegistry`,{type:`tokenPairs`,registryAddress:(0,n.getAddress)(e)}],confidentialTokenAddress:(e,t)=>[`zama.wrappersRegistry`,{type:`confidentialTokenAddress`,registryAddress:(0,n.getAddress)(e),tokenAddress:(0,n.getAddress)(t)}],tokenAddress:(e,t)=>[`zama.wrappersRegistry`,{type:`tokenAddress`,registryAddress:(0,n.getAddress)(e),confidentialTokenAddress:(0,n.getAddress)(t)}],tokenPairsLength:e=>[`zama.wrappersRegistry`,{type:`tokenPairsLength`,registryAddress:(0,n.getAddress)(e)}],tokenPairsSlice:(e,t,r)=>[`zama.wrappersRegistry`,{type:`tokenPairsSlice`,registryAddress:(0,n.getAddress)(e),fromIndex:t,toIndex:r}],tokenPair:(e,t)=>[`zama.wrappersRegistry`,{type:`tokenPair`,registryAddress:(0,n.getAddress)(e),index:t}],isConfidentialTokenValid:(e,t)=>[`zama.wrappersRegistry`,{type:`isConfidentialTokenValid`,registryAddress:(0,n.getAddress)(e),confidentialTokenAddress:(0,n.getAddress)(t)}],listPairs:(e,t,r,i)=>[`zama.wrappersRegistry`,{type:`listPairs`,registryAddress:(0,n.getAddress)(e),page:t,pageSize:r,metadata:i}]}};function f(e,t){e.invalidateQueries({queryKey:d.underlyingAllowance.token(t)})}function p(e,t){e.invalidateQueries({queryKey:d.pendingUnshield.token(t)})}function m(e,t){h(e,t),f(e,t),p(e,t),D(e)}function h(e,t){e.invalidateQueries({queryKey:d.confidentialBalance.token(t)}),e.invalidateQueries({queryKey:d.confidentialBalances.all})}function g(e,t){h(e,t),f(e,t),D(e)}function _(e,t){h(e,t),f(e,t),p(e,t),D(e)}function ee(e,t){p(e,t)}function v(e,t){h(e,t)}function y(e,t){f(e,t)}function b(e,t){e.invalidateQueries({queryKey:d.confidentialIsOperator.token(t)})}function x(e){return Array.isArray(e.queryKey)&&typeof e.queryKey[0]==`string`?e.queryKey[0].startsWith(`zama.`):!1}const S=r.z.enum([`balanceOf`,`confidentialBalanceOf`]),C=r.z.object({functionName:S}),w=r.z.object({contracts:r.z.array(r.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:d.decryption.all}),e.removeQueries({queryKey:d.hasPermit.all}),e.invalidateQueries({predicate:x}),D(e)}function k(t,n,r){let i=d.tokenMetadata.token(n);return{...o(r?.query??{}),queryKey:i,queryFn:async n=>{let[,{tokenAddress:r}]=n.queryKey,[i,a,o]=await Promise.all([t.provider.readContract(e.b(r)),t.provider.readContract(e.x(r)),t.provider.readContract(e.v(r))]);return{name:i,symbol:a,decimals:o}},staleTime:1/0,enabled:r?.query?.enabled!==!1}}function A(n,r,i){let a=d.isConfidential.token(r);return{...o(i?.query??{}),queryKey:a,queryFn:async r=>{let[,{tokenAddress:i}]=r.queryKey;try{return await n.provider.readContract(e.d(i))}catch(e){if(t.b(e))return!1;throw e}},staleTime:1/0,enabled:i?.query?.enabled!==!1}}function j(n,r,i){let a=d.isWrapper.token(r);return{...o(i?.query??{}),queryKey:a,queryFn:async r=>{let[,{tokenAddress:i}]=r.queryKey;try{return await n.provider.readContract(e.f(i))}catch(e){if(t.b(e))return!1;throw e}},staleTime:1/0,enabled:i?.query?.enabled!==!1}}function M(t,n,r){let i=d.totalSupply.token(n);return{...o(r?.query??{}),queryKey:i,queryFn:async n=>{let[,{tokenAddress:r}]=n.queryKey;return t.provider.readContract(e.k(r))},staleTime:3e4,enabled:r?.query?.enabled!==!1}}function N(e,n){let r=d.wrapperDiscovery.token(n.tokenAddress,n.erc20Address,n.registryAddress);return{...o(n.query??{}),queryKey:r,queryFn:async n=>{let[,{erc20Address:r}]=n.queryKey;t.c(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 P(n,r,i){let a=i.owner,s=i.query?.enabled!==!1,c=d.underlyingAllowance.scope(r,a);return{...o(i.query??{}),queryKey:c,queryFn:async r=>{let[,{tokenAddress:i,owner:a}]=r.queryKey;t.c(a,`underlyingAllowanceQueryOptions: owner`);let o=await n.provider.readContract(e.N(i));return n.provider.readContract(e.h(o,a,i))},staleTime:3e4,enabled:!!a&&s}}function F(e,t,n){let r=d.pendingUnshield.token(t);return{...o(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 I(n,r,i){let a=i.holder,s=i.spender,c=i.query?.enabled!==!1,l=d.confidentialIsOperator.scope(r,a,s);return{...o(i.query??{}),queryKey:l,queryFn:async r=>{let[,{tokenAddress:i,holder:a,spender:o}]=r.queryKey;return t.c(i,`confidentialIsOperatorQueryOptions: tokenAddress`),t.c(a,`confidentialIsOperatorQueryOptions: holder`),t.c(o,`confidentialIsOperatorQueryOptions: spender`),n.provider.readContract(e.A(i,a,o))},staleTime:3e4,enabled:!!(r&&a&&s)&&c}}function L(e,n,r={}){let i=n.query??{};return{...o(i),queryKey:d.confidentialBalance.owner(n.tokenAddress,n.account,r.walletAccount),queryFn:async n=>{let[,{owner:r}]=n.queryKey;return t.c(r,`confidentialBalanceQueryOptions: owner`),e.balanceOf(r)},enabled:!!n.account&&r.walletAccount!==void 0&&i?.enabled!==!1}}function R(e,n,r={}){let i=n?.account,a=r.walletAccount,s=n?.query??{},c=e.map(e=>e.address);return{...o(s),queryKey:d.confidentialBalances.tokens(c,i,a),queryFn:async n=>{let[,{owner:r}]=n.queryKey;return t.c(r,`confidentialBalancesQueryOptions: owner`),t.t.batchBalancesOf(e,r)},enabled:!!i&&e.length>0&&a!==void 0&&s?.enabled!==!1}}function z(t,r){let i=!!r.registryAddress&&r.query?.enabled!==!1,a=d.wrappersRegistry.tokenPairs(r.registryAddress??n.zeroAddress);return{...o(r.query??{}),queryKey:a,queryFn:async n=>{let[,{registryAddress:r}]=n.queryKey;return t.provider.readContract(e.i(r))},staleTime:t.registry.ttlMs,enabled:i}}function B(t,r){let i=!!r.registryAddress&&!!r.tokenAddress&&r.query?.enabled!==!1,a=d.wrappersRegistry.confidentialTokenAddress(r.registryAddress??n.zeroAddress,r.tokenAddress??n.zeroAddress);return{...o(r.query??{}),queryKey:a,queryFn:async n=>{let[,{registryAddress:r,tokenAddress:i}]=n.queryKey;return t.provider.readContract(e.t(r,i))},staleTime:t.registry.ttlMs,enabled:i}}function V(t,r){let i=!!r.registryAddress&&!!r.confidentialTokenAddress&&r.query?.enabled!==!1,a=d.wrappersRegistry.tokenAddress(r.registryAddress??n.zeroAddress,r.confidentialTokenAddress??n.zeroAddress);return{...o(r.query??{}),queryKey:a,queryFn:async n=>{let[,{registryAddress:r,confidentialTokenAddress:i}]=n.queryKey;return t.provider.readContract(e.n(r,i))},staleTime:t.registry.ttlMs,enabled:i}}function te(t,r){let i=!!r.registryAddress&&r.query?.enabled!==!1,a=d.wrappersRegistry.tokenPairsLength(r.registryAddress??n.zeroAddress);return{...o(r.query??{}),queryKey:a,queryFn:async n=>{let[,{registryAddress:r}]=n.queryKey;return t.provider.readContract(e.a(r))},staleTime:t.registry.ttlMs,enabled:i}}function H(t,r){let i=!!r.registryAddress&&r.fromIndex!==void 0&&r.toIndex!==void 0&&r.query?.enabled!==!1,a=d.wrappersRegistry.tokenPairsSlice(r.registryAddress??n.zeroAddress,String(r.fromIndex??0n),String(r.toIndex??0n));return{...o(r.query??{}),queryKey:a,queryFn:async n=>{let[,{registryAddress:r,fromIndex:i,toIndex:a}]=n.queryKey;return t.provider.readContract(e.o(r,BigInt(i),BigInt(a)))},staleTime:t.registry.ttlMs,enabled:i}}function U(t,r){let i=!!r.registryAddress&&r.index!==void 0&&r.query?.enabled!==!1,a=d.wrappersRegistry.tokenPair(r.registryAddress??n.zeroAddress,String(r.index??0n));return{...o(r.query??{}),queryKey:a,queryFn:async n=>{let[,{registryAddress:r,index:i}]=n.queryKey;return t.provider.readContract(e.r(r,BigInt(i)))},staleTime:t.registry.ttlMs,enabled:i}}function W(t,r){let i=!!r.registryAddress&&!!r.confidentialTokenAddress&&r.query?.enabled!==!1,a=d.wrappersRegistry.isConfidentialTokenValid(r.registryAddress??n.zeroAddress,r.confidentialTokenAddress??n.zeroAddress);return{...o(r.query??{}),queryKey:a,queryFn:async n=>{let[,{registryAddress:r,confidentialTokenAddress:i}]=n.queryKey;return t.provider.readContract(e.s(r,i))},staleTime:t.registry.ttlMs,enabled:i}}function G(e,t){let r=!!t.registryAddress&&t.query?.enabled!==!1,i=d.wrappersRegistry.listPairs(t.registryAddress??n.zeroAddress,t.page??1,t.pageSize??100,t.metadata??!1);return{...o(t.query??{}),queryKey:i,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:r}}function K(e){return{mutationKey:[`zama.shield`,e.address],mutationFn:async({amount:t,...n})=>e.shield(t,n)}}function q(e){return{mutationKey:[`zama.confidentialTransfer`,e.address],mutationFn:async({to:t,amount:n,...r})=>e.confidentialTransfer(t,n,r)}}function J(e){return{mutationKey:[`zama.confidentialTransferAndCall`,e.address],mutationFn:async({to:t,amount:n,data:r,...i})=>e.confidentialTransferAndCall(t,n,r,i)}}function Y(e){return{mutationKey:[`zama.confidentialTransferFrom`,e.address],mutationFn:async({from:t,to:n,amount:r,callbacks:i})=>e.confidentialTransferFrom(t,n,r,i)}}function X(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 Z(e){return{mutationKey:[`zama.confidentialSetOperator`,e.address],mutationFn:async({operator:t,until:n})=>e.setOperator(t,n)}}function Q(e){return{mutationKey:[`zama.approveUnderlying`,e.address],mutationFn:async({amount:t})=>e.approveUnderlying(t)}}function ne(e){return{mutationKey:[`zama.unshield`,e.address],mutationFn:async({amount:t,...n})=>e.unshield(t,n)}}function re(e){return{mutationKey:[`zama.unshieldAll`,e.address],mutationFn:async t=>e.unshieldAll(t||void 0)}}function ie(e){return{mutationKey:[`zama.resumeUnshield`,e.address],mutationFn:async({unwrapTxHash:t,...n})=>e.resumeUnshield(t,n)}}function ae(e){return{mutationKey:[`zama.unwrap`,e.address],mutationFn:async({amount:t})=>e.unwrap(t)}}function oe(e){return{mutationKey:[`zama.unwrapAll`,e.address],mutationFn:async()=>e.unwrapAll()}}function se(e){return{mutationKey:[`zama.finalizeUnwrap`,e.address],mutationFn:async({unwrapRequestId:t})=>e.finalizeUnwrap(t)}}function ce(e){return{mutationKey:[`zama.encrypt`],mutationFn:async t=>e.encrypt(t)}}function le(e){return{mutationKey:[`zama.delegatedDecryptValues`],mutationFn:async t=>e.decryption.delegatedDecryptValues(t.encryptedInputs,t.delegatorAddress)}}function ue(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(d.decryption.encryptedValue(t),n)}}}function de(e){return{mutationKey:[`zama.grantPermit`],mutationFn:t=>e.permits.grantPermit(t)}}function fe(e,t,n={}){let r=t.query?.enabled!==!1;return{...o(t?.query??{}),queryKey:d.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 pe(e){return{mutationKey:[`zama.revokePermits`],mutationFn:t=>t===void 0?e.permits.revokePermits():e.permits.revokePermits(t)}}function $(e){return{mutationKey:[`zama.clearCredentials`],mutationFn:()=>e.permits.clear()}}function me(e,t){return{mutationKey:[`zama.delegateDecryption`,t],mutationFn:async({delegateAddress:n,expirationDate:r})=>e.delegations.delegateDecryption({contractAddress:t,delegateAddress:n,expirationDate:r})}}function he(e,t,n={}){return{queryKey:d.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 ge(e){return{mutationKey:[`zama.decryptBalanceAs`,e.address],mutationFn:async({delegatorAddress:t,accountAddress:n})=>e.decryptBalanceAs({delegatorAddress:t,accountAddress:n})}}function _e(e){return{mutationKey:[`zama.batchDecryptBalancesAs`,...e.map(e=>e.address)],mutationFn:async n=>t.t.batchDecryptBalancesAs(e,n)}}function ve(e,t){return{mutationKey:[`zama.revokeDelegation`,t],mutationFn:async({delegateAddress:n})=>e.delegations.revokeDelegation({contractAddress:t,delegateAddress:n})}}function ye(e,n){return{...o(n.query??{}),queryKey:d.delegationStatus.scope(n.contractAddress,n.delegatorAddress,n.delegateAddress),queryFn:async n=>{let[,{contractAddress:r,delegatorAddress:i,delegateAddress:a}]=n.queryKey;t.c(r,`delegationStatusQueryOptions: contractAddress`),t.c(i,`delegationStatusQueryOptions: delegatorAddress`),t.c(a,`delegationStatusQueryOptions: delegateAddress`);let o=e.relayer.chain.aclContractAddress,s=await e.provider.readContract(t.p(o,i,a,r)),c;return c=s===0n?!1:s===t.d?!0:s>await e.provider.getBlockTimestamp(),{isActive:c,expiryTimestamp:s}},enabled:!!(n.contractAddress&&n.delegatorAddress&&n.delegateAddress)&&n.query?.enabled!==!1}}exports.ZamaSDKEvents=t.o,exports.approveUnderlyingMutationOptions=Q,exports.batchDecryptBalancesAsMutationOptions=_e,exports.clearCredentialsMutationOptions=$,exports.confidentialBalanceQueryOptions=L,exports.confidentialBalancesQueryOptions=R,exports.confidentialIsOperatorQueryOptions=I,exports.confidentialSetOperatorMutationOptions=Z,exports.confidentialTokenAddressQueryOptions=B,exports.confidentialTransferAndCallMutationOptions=J,exports.confidentialTransferFromAndCallMutationOptions=X,exports.confidentialTransferFromMutationOptions=Y,exports.confidentialTransferMutationOptions=q,exports.decryptBalanceAsMutationOptions=ge,exports.decryptPublicValuesMutationOptions=ue,exports.decryptValuesQueryOptions=he,exports.delegateDecryptionMutationOptions=me,exports.delegatedDecryptValuesMutationOptions=le,exports.delegationStatusQueryOptions=ye,exports.encryptMutationOptions=ce,exports.filterQueryOptions=o,exports.finalizeUnwrapMutationOptions=se,exports.grantPermitMutationOptions=de,exports.hasPermitQueryOptions=fe,exports.hashFn=s,exports.invalidateAfterApproveUnderlying=y,exports.invalidateAfterSetOperator=b,exports.invalidateAfterShield=g,exports.invalidateAfterTransfer=v,exports.invalidateAfterUnshield=_,exports.invalidateAfterUnshieldSettled=ee,exports.invalidateAfterUnwrap=m,exports.invalidateBalanceQueries=h,exports.invalidateWagmiBalanceQueries=D,exports.invalidateWalletLifecycleQueries=O,exports.isConfidentialQueryOptions=A,exports.isConfidentialTokenValidQueryOptions=W,exports.isWrapperQueryOptions=j,exports.listPairsQueryOptions=G,exports.pendingUnshieldQueryOptions=F,exports.resumeUnshieldMutationOptions=ie,exports.revokeDelegationMutationOptions=ve,exports.revokePermitsMutationOptions=pe,exports.shieldMutationOptions=K,exports.tokenAddressQueryOptions=V,exports.tokenMetadataQueryOptions=k,exports.tokenPairQueryOptions=U,exports.tokenPairsLengthQueryOptions=te,exports.tokenPairsQueryOptions=z,exports.tokenPairsSliceQueryOptions=H,exports.totalSupplyQueryOptions=M,exports.underlyingAllowanceQueryOptions=P,exports.unshieldAllMutationOptions=re,exports.unshieldMutationOptions=ne,exports.unwrapAllMutationOptions=oe,exports.unwrapMutationOptions=ae,exports.wrapperDiscoveryQueryOptions=N,exports.zamaQueryKeys=d;
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["z","nameContract","symbolContract","decimalsContract","isConfidentialTokenContract","isContractCallError","isConfidentialWrapperContract","inferredTotalSupplyContract","underlyingContract","allowanceContract","isOperatorContract","Token","zeroAddress","getTokenPairsContract","getConfidentialTokenAddressContract","getTokenAddressContract","getTokenPairsLengthContract","getTokenPairsSliceContract","getTokenPairContract","isConfidentialTokenValidContract","Token","getDelegationExpiryContract","MAX_UINT64"],"sources":["../../../src/query/utils.ts","../../../src/query/query-keys.ts","../../../src/query/invalidation.ts","../../../src/query/token-metadata.ts","../../../src/query/is-confidential.ts","../../../src/query/total-supply.ts","../../../src/query/wrapper-discovery.ts","../../../src/query/underlying-allowance.ts","../../../src/query/pending-unshield.ts","../../../src/query/confidential-is-operator.ts","../../../src/query/confidential-balance.ts","../../../src/query/confidential-balances.ts","../../../src/query/wrappers-registry.ts","../../../src/query/shield.ts","../../../src/query/transfer.ts","../../../src/query/transfer-and-call.ts","../../../src/query/transfer-from.ts","../../../src/query/transfer-from-and-call.ts","../../../src/query/set-operator.ts","../../../src/query/approve-underlying.ts","../../../src/query/unshield.ts","../../../src/query/unshield-all.ts","../../../src/query/resume-unshield.ts","../../../src/query/unwrap.ts","../../../src/query/unwrap-all.ts","../../../src/query/finalize-unwrap.ts","../../../src/query/encrypt.ts","../../../src/query/delegated-decrypt.ts","../../../src/query/public-decrypt.ts","../../../src/query/grant-permit.ts","../../../src/query/has-permit.ts","../../../src/query/revoke-permits.ts","../../../src/query/clear-credentials.ts","../../../src/query/delegate-decryption.ts","../../../src/query/user-decrypt.ts","../../../src/query/decrypt-balance-as.ts","../../../src/query/batch-decrypt-balances-as.ts","../../../src/query/revoke-delegation.ts","../../../src/query/delegation-status.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\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 .toSorted()\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).toSorted(),\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 .toSorted((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\nexport interface QueryLike {\n queryKey: readonly unknown[];\n}\n\nexport interface QueryFilterLike {\n queryKey?: readonly unknown[];\n predicate?: (query: QueryLike) => boolean;\n}\n\nexport interface QueryClientLike {\n invalidateQueries(filters: QueryFilterLike): void | Promise<void>;\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\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\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\nexport function invalidateAfterShield(queryClient: QueryClientLike, tokenAddress: Address): void {\n invalidateBalanceQueries(queryClient, tokenAddress);\n invalidateUnderlyingAllowanceQueries(queryClient, tokenAddress);\n invalidateWagmiBalanceQueries(queryClient);\n}\n\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\nexport function invalidateAfterUnshieldSettled(\n queryClient: QueryClientLike,\n tokenAddress: Address,\n): void {\n invalidatePendingUnshieldQueries(queryClient, tokenAddress);\n}\n\nexport function invalidateAfterTransfer(queryClient: QueryClientLike, tokenAddress: Address): void {\n invalidateBalanceQueries(queryClient, tokenAddress);\n}\n\nexport function invalidateAfterApproveUnderlying(\n queryClient: QueryClientLike,\n tokenAddress: Address,\n): void {\n invalidateUnderlyingAllowanceQueries(queryClient, tokenAddress);\n}\n\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\nexport function invalidateWagmiBalanceQueries(queryClient: QueryClientLike): void {\n void queryClient.invalidateQueries({ predicate: isWagmiBalanceQuery });\n}\n\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","import { decimalsContract, nameContract, symbolContract } from \"../contracts\";\n\nimport type { ZamaSDK } from \"../zama-sdk\";\nimport type { QueryFactoryOptions } from \"./factory-types\";\nimport { zamaQueryKeys } from \"./query-keys\";\nimport { filterQueryOptions } from \"./utils\";\nimport type { Address } from \"viem\";\n\n/** ERC-20 token metadata returned by {@link tokenMetadataQueryOptions}. */\nexport interface TokenMetadata {\n name: string;\n symbol: string;\n decimals: number;\n}\n\nexport interface TokenMetadataQueryConfig {\n query?: Record<string, unknown>;\n}\n\nexport function tokenMetadataQueryOptions(\n sdk: ZamaSDK,\n tokenAddress: Address,\n config?: TokenMetadataQueryConfig,\n): QueryFactoryOptions<\n TokenMetadata,\n Error,\n TokenMetadata,\n ReturnType<typeof zamaQueryKeys.tokenMetadata.token>\n> {\n const queryKey = zamaQueryKeys.tokenMetadata.token(tokenAddress);\n\n return {\n ...filterQueryOptions(config?.query ?? {}),\n queryKey,\n queryFn: async (context) => {\n const [, { tokenAddress: keyTokenAddress }] = context.queryKey;\n const [name, symbol, decimals] = await Promise.all([\n sdk.provider.readContract(nameContract(keyTokenAddress)),\n sdk.provider.readContract(symbolContract(keyTokenAddress)),\n sdk.provider.readContract(decimalsContract(keyTokenAddress)),\n ]);\n return { name, symbol, decimals };\n },\n staleTime: Infinity,\n enabled: config?.query?.enabled !== false,\n };\n}\n","import { isConfidentialTokenContract, isConfidentialWrapperContract } from \"../contracts\";\nimport type { ZamaSDK } from \"../zama-sdk\";\nimport { isContractCallError } from \"../utils\";\nimport type { QueryFactoryOptions } from \"./factory-types\";\nimport { zamaQueryKeys } from \"./query-keys\";\nimport { filterQueryOptions } from \"./utils\";\nimport type { Address } from \"viem\";\n\nexport interface IsConfidentialQueryConfig {\n query?: Record<string, unknown>;\n}\n\nexport function isConfidentialQueryOptions(\n sdk: ZamaSDK,\n tokenAddress: Address,\n config?: IsConfidentialQueryConfig,\n): QueryFactoryOptions<\n boolean,\n Error,\n boolean,\n ReturnType<typeof zamaQueryKeys.isConfidential.token>\n> {\n const queryKey = zamaQueryKeys.isConfidential.token(tokenAddress);\n return {\n ...filterQueryOptions(config?.query ?? {}),\n queryKey,\n queryFn: async (context) => {\n const [, { tokenAddress: keyTokenAddress }] = context.queryKey;\n try {\n return await sdk.provider.readContract(isConfidentialTokenContract(keyTokenAddress));\n } catch (err) {\n // Only suppress contract execution reverts (non-ERC-165 contracts).\n // Re-throw network/transport errors so TanStack Query's retry logic applies.\n if (isContractCallError(err)) {\n return false;\n }\n throw err;\n }\n },\n staleTime: Infinity,\n enabled: config?.query?.enabled !== false,\n };\n}\n\nexport function isWrapperQueryOptions(\n sdk: ZamaSDK,\n tokenAddress: Address,\n config?: IsConfidentialQueryConfig,\n): QueryFactoryOptions<boolean, Error, boolean, ReturnType<typeof zamaQueryKeys.isWrapper.token>> {\n const queryKey = zamaQueryKeys.isWrapper.token(tokenAddress);\n return {\n ...filterQueryOptions(config?.query ?? {}),\n queryKey,\n queryFn: async (context) => {\n const [, { tokenAddress: keyTokenAddress }] = context.queryKey;\n try {\n return await sdk.provider.readContract(isConfidentialWrapperContract(keyTokenAddress));\n } catch (err) {\n // Only suppress contract execution reverts (non-ERC-165 contracts).\n // Re-throw network/transport errors so TanStack Query's retry logic applies.\n if (isContractCallError(err)) {\n return false;\n }\n throw err;\n }\n },\n staleTime: Infinity,\n enabled: config?.query?.enabled !== false,\n };\n}\n","import { inferredTotalSupplyContract } from \"../contracts\";\nimport type { ZamaSDK } from \"../zama-sdk\";\nimport type { QueryFactoryOptions } from \"./factory-types\";\nimport { zamaQueryKeys } from \"./query-keys\";\nimport { filterQueryOptions } from \"./utils\";\nimport type { Address } from \"viem\";\n\nexport interface TotalSupplyQueryConfig {\n query?: Record<string, unknown>;\n}\n\nexport function totalSupplyQueryOptions(\n sdk: ZamaSDK,\n tokenAddress: Address,\n config?: TotalSupplyQueryConfig,\n): QueryFactoryOptions<bigint, Error, bigint, ReturnType<typeof zamaQueryKeys.totalSupply.token>> {\n const queryKey = zamaQueryKeys.totalSupply.token(tokenAddress);\n\n return {\n ...filterQueryOptions(config?.query ?? {}),\n queryKey,\n queryFn: async (context) => {\n const [, { tokenAddress: keyTokenAddress }] = context.queryKey;\n return sdk.provider.readContract(inferredTotalSupplyContract(keyTokenAddress));\n },\n staleTime: 30_000,\n enabled: config?.query?.enabled !== false,\n };\n}\n","import type { Address } from \"viem\";\nimport type { WrappersRegistry } from \"../wrappers-registry\";\nimport type { QueryFactoryOptions } from \"./factory-types\";\nimport { zamaQueryKeys } from \"./query-keys\";\nimport { assertNonNullable } from \"../utils/assertions\";\nimport { filterQueryOptions } from \"./utils\";\n\nexport interface WrapperDiscoveryQueryConfig {\n /**\n * Address of any confidential token you control.\n * Used to scope the query cache key and to gate whether the query\n * is enabled — it does not affect which wrapper the registry returns.\n */\n tokenAddress?: Address;\n /**\n * The ERC-20 token address to discover the confidential wrapper for.\n * The registry is resolved automatically from chain config.\n */\n erc20Address?: Address;\n /**\n * The resolved registry contract address for the current chain.\n * Included in the query key so that switching chains invalidates\n * stale cached results. Pass `undefined` when the chain ID is not\n * yet known — the query will be disabled.\n */\n registryAddress?: Address;\n query?: Record<string, unknown>;\n}\n\nexport function wrapperDiscoveryQueryOptions(\n registry: WrappersRegistry,\n config: WrapperDiscoveryQueryConfig,\n): QueryFactoryOptions<\n Address | null,\n Error,\n Address | null,\n ReturnType<typeof zamaQueryKeys.wrapperDiscovery.token>\n> {\n const queryKey = zamaQueryKeys.wrapperDiscovery.token(\n config.tokenAddress,\n config.erc20Address,\n config.registryAddress,\n );\n\n return {\n ...filterQueryOptions(config.query ?? {}),\n queryKey,\n queryFn: async (context) => {\n const [, { erc20Address }] = context.queryKey;\n assertNonNullable(erc20Address, \"wrapperDiscoveryQueryOptions: erc20Address\");\n const result = await registry.getConfidentialToken(erc20Address);\n return result ? result.confidentialTokenAddress : null;\n },\n staleTime: Infinity,\n enabled:\n Boolean(config.tokenAddress && config.erc20Address && config.registryAddress) &&\n config.query?.enabled !== false,\n };\n}\n","import { allowanceContract, underlyingContract } from \"../contracts\";\nimport type { ZamaSDK } from \"../zama-sdk\";\nimport { assertNonNullable } from \"../utils/assertions\";\nimport type { QueryFactoryOptions } from \"./factory-types\";\nimport { zamaQueryKeys } from \"./query-keys\";\nimport { filterQueryOptions } from \"./utils\";\nimport type { Address } from \"viem\";\n\nexport interface UnderlyingAllowanceQueryConfig {\n owner?: Address;\n query?: Record<string, unknown>;\n}\n\nexport function underlyingAllowanceQueryOptions(\n sdk: ZamaSDK,\n tokenAddress: Address,\n config: UnderlyingAllowanceQueryConfig,\n): QueryFactoryOptions<\n bigint,\n Error,\n bigint,\n ReturnType<typeof zamaQueryKeys.underlyingAllowance.scope>\n> {\n const ownerKey = config.owner;\n const queryEnabled = config.query?.enabled !== false;\n const queryKey = zamaQueryKeys.underlyingAllowance.scope(tokenAddress, ownerKey);\n\n return {\n ...filterQueryOptions(config.query ?? {}),\n queryKey,\n queryFn: async (context) => {\n const [, { tokenAddress: keyTokenAddress, owner: keyOwner }] = context.queryKey;\n assertNonNullable(keyOwner, \"underlyingAllowanceQueryOptions: owner\");\n const underlying = await sdk.provider.readContract(underlyingContract(keyTokenAddress));\n return sdk.provider.readContract(allowanceContract(underlying, keyOwner, keyTokenAddress));\n },\n staleTime: 30_000,\n enabled: Boolean(ownerKey) && queryEnabled,\n };\n}\n","import type { Address, Hex } from \"viem\";\nimport type { ZamaSDK } from \"../zama-sdk\";\nimport type { QueryFactoryOptions } from \"./factory-types\";\nimport { zamaQueryKeys } from \"./query-keys\";\nimport { filterQueryOptions } from \"./utils\";\n\nexport interface PendingUnshieldQueryConfig {\n query?: Record<string, unknown>;\n}\n\n/**\n * Query options for reading the unwrap tx hash of an unshield that was\n * interrupted between its two phases (returns `null` if none is pending).\n *\n * Backed by {@link ZamaSDK} storage via `WrappedToken.getPendingUnshield()`.\n * `staleTime: 0` so the value reflects storage on mount; the unshield/unwrap\n * mutations also invalidate this key on success.\n */\nexport function pendingUnshieldQueryOptions(\n sdk: ZamaSDK,\n tokenAddress: Address,\n config?: PendingUnshieldQueryConfig,\n): QueryFactoryOptions<\n Hex | null,\n Error,\n Hex | null,\n ReturnType<typeof zamaQueryKeys.pendingUnshield.token>\n> {\n const queryKey = zamaQueryKeys.pendingUnshield.token(tokenAddress);\n\n return {\n ...filterQueryOptions(config?.query ?? {}),\n queryKey,\n queryFn: async (context) => {\n const [, { tokenAddress: keyTokenAddress }] = context.queryKey;\n return sdk.createWrappedToken(keyTokenAddress).getPendingUnshield();\n },\n staleTime: 0,\n enabled: config?.query?.enabled !== false,\n };\n}\n","import { isOperatorContract } from \"../contracts\";\nimport type { ZamaSDK } from \"../zama-sdk\";\nimport { assertNonNullable } from \"../utils/assertions\";\nimport type { QueryFactoryOptions } from \"./factory-types\";\nimport { filterQueryOptions } from \"./utils\";\nimport { zamaQueryKeys } from \"./query-keys\";\nimport type { Address } from \"viem\";\n\nexport interface ConfidentialIsOperatorQueryConfig {\n holder?: Address;\n spender?: Address;\n query?: Record<string, unknown>;\n}\n\nexport function confidentialIsOperatorQueryOptions(\n sdk: ZamaSDK,\n tokenAddress: Address | undefined,\n config: ConfidentialIsOperatorQueryConfig,\n): QueryFactoryOptions<\n boolean,\n Error,\n boolean,\n ReturnType<typeof zamaQueryKeys.confidentialIsOperator.scope>\n> {\n const holderKey = config.holder;\n const spenderKey = config.spender;\n const queryEnabled = config.query?.enabled !== false;\n const queryKey = zamaQueryKeys.confidentialIsOperator.scope(tokenAddress, holderKey, spenderKey);\n\n return {\n ...filterQueryOptions(config.query ?? {}),\n queryKey,\n queryFn: async (context) => {\n const [, { tokenAddress: keyTokenAddress, holder: keyHolder, spender: keySpender }] =\n context.queryKey;\n assertNonNullable(keyTokenAddress, \"confidentialIsOperatorQueryOptions: tokenAddress\");\n assertNonNullable(keyHolder, \"confidentialIsOperatorQueryOptions: holder\");\n assertNonNullable(keySpender, \"confidentialIsOperatorQueryOptions: spender\");\n return sdk.provider.readContract(isOperatorContract(keyTokenAddress, keyHolder, keySpender));\n },\n staleTime: 30_000,\n enabled: Boolean(tokenAddress && holderKey && spenderKey) && queryEnabled,\n };\n}\n","import type { Address } from \"viem\";\nimport type { Token } from \"../token\";\nimport { assertNonNullable } from \"../utils/assertions\";\nimport type { QueryFactoryOptions } from \"./factory-types\";\nimport { zamaQueryKeys } from \"./query-keys\";\nimport type { SignerQueryContext } from \"./signer-query-context\";\nimport { filterQueryOptions } from \"./utils\";\n\nexport interface ConfidentialBalanceQueryConfig {\n tokenAddress: Address;\n account?: Address;\n query?: Record<string, unknown>;\n}\n\n/** Query options for a single confidential token balance. Auto-gated on `account`. */\nexport function confidentialBalanceQueryOptions(\n token: Token,\n config: ConfidentialBalanceQueryConfig,\n signerContext: SignerQueryContext = {},\n): QueryFactoryOptions<\n bigint,\n Error,\n bigint,\n ReturnType<typeof zamaQueryKeys.confidentialBalance.owner>\n> {\n const queryOpts = config.query ?? {};\n\n return {\n ...filterQueryOptions(queryOpts),\n queryKey: zamaQueryKeys.confidentialBalance.owner(\n config.tokenAddress,\n config.account,\n signerContext.walletAccount,\n ),\n queryFn: async (context) => {\n const [, { owner: keyOwner }] = context.queryKey;\n assertNonNullable(keyOwner, \"confidentialBalanceQueryOptions: owner\");\n return token.balanceOf(keyOwner);\n },\n enabled:\n Boolean(config.account) &&\n signerContext.walletAccount !== undefined &&\n queryOpts?.enabled !== false,\n };\n}\n","import type { Address } from \"viem\";\nimport { Token, type BatchBalancesResult } from \"../token/token\";\nimport { assertNonNullable } from \"../utils/assertions\";\nimport type { QueryFactoryOptions } from \"./factory-types\";\nimport { zamaQueryKeys } from \"./query-keys\";\nimport type { SignerQueryContext } from \"./signer-query-context\";\nimport { filterQueryOptions } from \"./utils\";\n\nexport interface ConfidentialBalancesQueryConfig {\n account?: Address;\n query?: Record<string, unknown>;\n}\n\nexport function confidentialBalancesQueryOptions(\n tokens: Token[],\n config?: ConfidentialBalancesQueryConfig,\n signerContext: SignerQueryContext = {},\n): QueryFactoryOptions<\n BatchBalancesResult,\n Error,\n BatchBalancesResult,\n ReturnType<typeof zamaQueryKeys.confidentialBalances.tokens>\n> {\n const accountKey = config?.account;\n const walletAccount = signerContext.walletAccount;\n const queryOpts = config?.query ?? {};\n const tokenAddresses = tokens.map((token) => token.address);\n\n return {\n ...filterQueryOptions(queryOpts),\n queryKey: zamaQueryKeys.confidentialBalances.tokens(tokenAddresses, accountKey, walletAccount),\n queryFn: async (signerContextQuery) => {\n const [, { owner: keyOwner }] = signerContextQuery.queryKey;\n assertNonNullable(keyOwner, \"confidentialBalancesQueryOptions: owner\");\n return Token.batchBalancesOf(tokens, keyOwner);\n },\n enabled:\n Boolean(accountKey) &&\n tokens.length > 0 &&\n walletAccount !== undefined &&\n queryOpts?.enabled !== false,\n };\n}\n","import { type Address, zeroAddress } from \"viem\";\nimport {\n getTokenPairsContract,\n getTokenPairsLengthContract,\n getTokenPairsSliceContract,\n getTokenPairContract,\n getConfidentialTokenAddressContract,\n getTokenAddressContract,\n isConfidentialTokenValidContract,\n} from \"../contracts\";\nimport type {\n TokenWrapperPair,\n TokenWrapperPairWithMetadata,\n PaginatedResult,\n} from \"../contracts/wrappers-registry\";\nimport type { WrappersRegistry } from \"../wrappers-registry\";\nimport type { ZamaSDK } from \"../zama-sdk\";\nimport type { QueryFactoryOptions } from \"./factory-types\";\nimport { zamaQueryKeys } from \"./query-keys\";\nimport { filterQueryOptions } from \"./utils\";\n\nexport interface WrappersRegistryQueryConfig {\n registryAddress: Address | undefined;\n query?: Record<string, unknown>;\n}\n\nexport function tokenPairsQueryOptions(\n sdk: ZamaSDK,\n config: WrappersRegistryQueryConfig,\n): QueryFactoryOptions<\n readonly TokenWrapperPair[],\n Error,\n readonly TokenWrapperPair[],\n ReturnType<typeof zamaQueryKeys.wrappersRegistry.tokenPairs>\n> {\n const enabled = Boolean(config.registryAddress) && config.query?.enabled !== false;\n const queryKey = zamaQueryKeys.wrappersRegistry.tokenPairs(config.registryAddress ?? zeroAddress);\n return {\n ...filterQueryOptions(config.query ?? {}),\n queryKey,\n queryFn: async (context) => {\n const [, { registryAddress }] = context.queryKey;\n return sdk.provider.readContract(getTokenPairsContract(registryAddress));\n },\n staleTime: sdk.registry.ttlMs,\n enabled,\n };\n}\n\nexport interface ConfidentialTokenAddressQueryConfig extends WrappersRegistryQueryConfig {\n tokenAddress?: Address;\n}\n\nexport function confidentialTokenAddressQueryOptions(\n sdk: ZamaSDK,\n config: ConfidentialTokenAddressQueryConfig,\n): QueryFactoryOptions<\n readonly [boolean, Address],\n Error,\n readonly [boolean, Address],\n ReturnType<typeof zamaQueryKeys.wrappersRegistry.confidentialTokenAddress>\n> {\n const enabled =\n Boolean(config.registryAddress) &&\n Boolean(config.tokenAddress) &&\n config.query?.enabled !== false;\n const queryKey = zamaQueryKeys.wrappersRegistry.confidentialTokenAddress(\n config.registryAddress ?? zeroAddress,\n config.tokenAddress ?? zeroAddress,\n );\n return {\n ...filterQueryOptions(config.query ?? {}),\n queryKey,\n queryFn: async (context) => {\n const [, { registryAddress, tokenAddress }] = context.queryKey;\n return sdk.provider.readContract(\n getConfidentialTokenAddressContract(registryAddress, tokenAddress),\n );\n },\n staleTime: sdk.registry.ttlMs,\n enabled,\n };\n}\n\nexport interface TokenAddressQueryConfig extends WrappersRegistryQueryConfig {\n confidentialTokenAddress?: Address;\n}\n\nexport function tokenAddressQueryOptions(\n sdk: ZamaSDK,\n config: TokenAddressQueryConfig,\n): QueryFactoryOptions<\n readonly [boolean, Address],\n Error,\n readonly [boolean, Address],\n ReturnType<typeof zamaQueryKeys.wrappersRegistry.tokenAddress>\n> {\n const enabled =\n Boolean(config.registryAddress) &&\n Boolean(config.confidentialTokenAddress) &&\n config.query?.enabled !== false;\n const queryKey = zamaQueryKeys.wrappersRegistry.tokenAddress(\n config.registryAddress ?? zeroAddress,\n config.confidentialTokenAddress ?? zeroAddress,\n );\n return {\n ...filterQueryOptions(config.query ?? {}),\n queryKey,\n queryFn: async (context) => {\n const [, { registryAddress, confidentialTokenAddress }] = context.queryKey;\n return sdk.provider.readContract(\n getTokenAddressContract(registryAddress, confidentialTokenAddress),\n );\n },\n staleTime: sdk.registry.ttlMs,\n enabled,\n };\n}\n\nexport function tokenPairsLengthQueryOptions(\n sdk: ZamaSDK,\n config: WrappersRegistryQueryConfig,\n): QueryFactoryOptions<\n bigint,\n Error,\n bigint,\n ReturnType<typeof zamaQueryKeys.wrappersRegistry.tokenPairsLength>\n> {\n const enabled = Boolean(config.registryAddress) && config.query?.enabled !== false;\n const queryKey = zamaQueryKeys.wrappersRegistry.tokenPairsLength(\n config.registryAddress ?? zeroAddress,\n );\n return {\n ...filterQueryOptions(config.query ?? {}),\n queryKey,\n queryFn: async (context) => {\n const [, { registryAddress }] = context.queryKey;\n return sdk.provider.readContract(getTokenPairsLengthContract(registryAddress));\n },\n staleTime: sdk.registry.ttlMs,\n enabled,\n };\n}\n\nexport interface TokenPairsSliceQueryConfig extends WrappersRegistryQueryConfig {\n fromIndex?: bigint;\n toIndex?: bigint;\n}\n\nexport function tokenPairsSliceQueryOptions(\n sdk: ZamaSDK,\n config: TokenPairsSliceQueryConfig,\n): QueryFactoryOptions<\n readonly TokenWrapperPair[],\n Error,\n readonly TokenWrapperPair[],\n ReturnType<typeof zamaQueryKeys.wrappersRegistry.tokenPairsSlice>\n> {\n const enabled =\n Boolean(config.registryAddress) &&\n config.fromIndex !== undefined &&\n config.toIndex !== undefined &&\n config.query?.enabled !== false;\n const queryKey = zamaQueryKeys.wrappersRegistry.tokenPairsSlice(\n config.registryAddress ?? zeroAddress,\n String(config.fromIndex ?? 0n),\n String(config.toIndex ?? 0n),\n );\n return {\n ...filterQueryOptions(config.query ?? {}),\n queryKey,\n queryFn: async (context) => {\n const [, { registryAddress, fromIndex, toIndex }] = context.queryKey;\n return sdk.provider.readContract(\n getTokenPairsSliceContract(registryAddress, BigInt(fromIndex), BigInt(toIndex)),\n );\n },\n staleTime: sdk.registry.ttlMs,\n enabled,\n };\n}\n\nexport interface TokenPairQueryConfig extends WrappersRegistryQueryConfig {\n index?: bigint;\n}\n\nexport function tokenPairQueryOptions(\n sdk: ZamaSDK,\n config: TokenPairQueryConfig,\n): QueryFactoryOptions<\n TokenWrapperPair,\n Error,\n TokenWrapperPair,\n ReturnType<typeof zamaQueryKeys.wrappersRegistry.tokenPair>\n> {\n const enabled =\n Boolean(config.registryAddress) &&\n config.index !== undefined &&\n config.query?.enabled !== false;\n const queryKey = zamaQueryKeys.wrappersRegistry.tokenPair(\n config.registryAddress ?? zeroAddress,\n String(config.index ?? 0n),\n );\n return {\n ...filterQueryOptions(config.query ?? {}),\n queryKey,\n queryFn: async (context) => {\n const [, { registryAddress, index }] = context.queryKey;\n return sdk.provider.readContract(getTokenPairContract(registryAddress, BigInt(index)));\n },\n staleTime: sdk.registry.ttlMs,\n enabled,\n };\n}\n\nexport interface IsConfidentialTokenValidQueryConfig extends WrappersRegistryQueryConfig {\n confidentialTokenAddress?: Address;\n}\n\nexport function isConfidentialTokenValidQueryOptions(\n sdk: ZamaSDK,\n config: IsConfidentialTokenValidQueryConfig,\n): QueryFactoryOptions<\n boolean,\n Error,\n boolean,\n ReturnType<typeof zamaQueryKeys.wrappersRegistry.isConfidentialTokenValid>\n> {\n const enabled =\n Boolean(config.registryAddress) &&\n Boolean(config.confidentialTokenAddress) &&\n config.query?.enabled !== false;\n const queryKey = zamaQueryKeys.wrappersRegistry.isConfidentialTokenValid(\n config.registryAddress ?? zeroAddress,\n config.confidentialTokenAddress ?? zeroAddress,\n );\n return {\n ...filterQueryOptions(config.query ?? {}),\n queryKey,\n queryFn: async (context) => {\n const [, { registryAddress, confidentialTokenAddress }] = context.queryKey;\n return sdk.provider.readContract(\n isConfidentialTokenValidContract(registryAddress, confidentialTokenAddress),\n );\n },\n staleTime: sdk.registry.ttlMs,\n enabled,\n };\n}\n\nexport interface ListPairsQueryConfig {\n /**\n * The registry address for this chain — used as a query key discriminator.\n * The registry instance already knows how to resolve the address for the\n * current chain; this field just keeps the TanStack Query cache isolated\n * per registry contract.\n */\n registryAddress: Address | undefined;\n page?: number;\n pageSize?: number;\n metadata?: boolean;\n query?: Record<string, unknown>;\n}\n\n/**\n * Query options for paginated listing of token wrapper pairs.\n *\n * Accepts a {@link WrappersRegistry} instance rather than a raw provider so that the\n * class-level TTL cache is shared across multiple `queryFn` executions. Pass\n * `sdk.registry` (the ZamaSDK lazy singleton) to ensure a single shared cache.\n */\nexport function listPairsQueryOptions(\n registry: WrappersRegistry,\n config: ListPairsQueryConfig,\n): QueryFactoryOptions<\n PaginatedResult<TokenWrapperPair | TokenWrapperPairWithMetadata>,\n Error,\n PaginatedResult<TokenWrapperPair | TokenWrapperPairWithMetadata>,\n ReturnType<typeof zamaQueryKeys.wrappersRegistry.listPairs>\n> {\n const enabled = Boolean(config.registryAddress) && config.query?.enabled !== false;\n const queryKey = zamaQueryKeys.wrappersRegistry.listPairs(\n config.registryAddress ?? zeroAddress,\n config.page ?? 1,\n config.pageSize ?? 100,\n config.metadata ?? false,\n );\n return {\n ...filterQueryOptions(config.query ?? {}),\n queryKey,\n queryFn: async (context) => {\n const [, { page, pageSize, metadata }] = context.queryKey;\n return registry.listPairs({ page, pageSize, metadata });\n },\n // Use the registry's own TTL so TanStack Query and the class-level cache\n // operate under the same freshness contract.\n staleTime: registry.ttlMs,\n enabled,\n };\n}\n","import type { Address } from \"viem\";\nimport type { WrappedToken } from \"../token/wrapped-token\";\nimport type { ShieldOptions, TransactionResult } from \"../types\";\nimport type { MutationFactoryOptions } from \"./factory-types\";\n\n/** Variables for {@link shieldMutationOptions}. */\nexport interface ShieldParams extends ShieldOptions {\n amount: bigint;\n}\n\nexport function shieldMutationOptions(\n token: WrappedToken,\n): MutationFactoryOptions<readonly [\"zama.shield\", Address], ShieldParams, TransactionResult> {\n return {\n mutationKey: [\"zama.shield\", token.address] as const,\n mutationFn: async ({ amount, ...rest }) => token.shield(amount, rest),\n };\n}\n","import type { Token } from \"../token/token\";\nimport type { TransactionResult, TransferOptions } from \"../types\";\nimport type { MutationFactoryOptions } from \"./factory-types\";\nimport type { Address } from \"viem\";\n\n/** Variables for {@link confidentialTransferMutationOptions}. */\nexport interface ConfidentialTransferParams extends TransferOptions {\n to: Address;\n amount: bigint;\n}\n\nexport function confidentialTransferMutationOptions(\n token: Token,\n): MutationFactoryOptions<\n readonly [\"zama.confidentialTransfer\", Address],\n ConfidentialTransferParams,\n TransactionResult\n> {\n return {\n mutationKey: [\"zama.confidentialTransfer\", token.address] as const,\n mutationFn: async ({ to, amount, ...options }) =>\n token.confidentialTransfer(to, amount, options),\n };\n}\n","import type { Token } from \"../token/token\";\nimport type { TransactionResult, TransferOptions } from \"../types\";\nimport type { MutationFactoryOptions } from \"./factory-types\";\nimport type { Address, Hex } from \"viem\";\n\n/** Variables for {@link confidentialTransferAndCallMutationOptions}. */\nexport interface ConfidentialTransferAndCallParams extends TransferOptions {\n to: Address;\n amount: bigint;\n /** Opaque bytes forwarded to the recipient's ERC-7984 receiver hook. */\n data: Hex;\n}\n\nexport function confidentialTransferAndCallMutationOptions(\n token: Token,\n): MutationFactoryOptions<\n readonly [\"zama.confidentialTransferAndCall\", Address],\n ConfidentialTransferAndCallParams,\n TransactionResult\n> {\n return {\n mutationKey: [\"zama.confidentialTransferAndCall\", token.address] as const,\n mutationFn: async ({ to, amount, data, ...options }) =>\n token.confidentialTransferAndCall(to, amount, data, options),\n };\n}\n","import type { Token } from \"../token/token\";\nimport type { TransferCallbacks, TransactionResult } from \"../types\";\nimport type { MutationFactoryOptions } from \"./factory-types\";\nimport type { Address } from \"viem\";\n\n/** Variables for {@link confidentialTransferFromMutationOptions}. */\nexport interface ConfidentialTransferFromParams {\n from: Address;\n to: Address;\n amount: bigint;\n /** Optional progress callbacks for the multi-step transfer flow. */\n callbacks?: TransferCallbacks;\n}\n\nexport function confidentialTransferFromMutationOptions(\n token: Token,\n): MutationFactoryOptions<\n readonly [\"zama.confidentialTransferFrom\", Address],\n ConfidentialTransferFromParams,\n TransactionResult\n> {\n return {\n mutationKey: [\"zama.confidentialTransferFrom\", token.address] as const,\n mutationFn: async ({ from, to, amount, callbacks }) =>\n token.confidentialTransferFrom(from, to, amount, callbacks),\n };\n}\n","import type { Token } from \"../token/token\";\nimport type { TransferCallbacks, TransactionResult } from \"../types\";\nimport type { MutationFactoryOptions } from \"./factory-types\";\nimport type { Address, Hex } from \"viem\";\n\n/** Variables for {@link confidentialTransferFromAndCallMutationOptions}. */\nexport interface ConfidentialTransferFromAndCallParams {\n from: Address;\n to: Address;\n amount: bigint;\n /** Opaque bytes forwarded to the recipient's ERC-7984 receiver hook. */\n data: Hex;\n /** Optional progress callbacks for the multi-step transfer flow. */\n callbacks?: TransferCallbacks;\n}\n\nexport function confidentialTransferFromAndCallMutationOptions(\n token: Token,\n): MutationFactoryOptions<\n readonly [\"zama.confidentialTransferFromAndCall\", Address],\n ConfidentialTransferFromAndCallParams,\n TransactionResult\n> {\n return {\n mutationKey: [\"zama.confidentialTransferFromAndCall\", token.address] as const,\n mutationFn: async ({ from, to, amount, data, callbacks }) =>\n token.confidentialTransferFromAndCall(from, to, amount, data, callbacks),\n };\n}\n","import type { Token } from \"../token/token\";\nimport type { TransactionResult } from \"../types\";\nimport type { MutationFactoryOptions } from \"./factory-types\";\nimport type { Address } from \"viem\";\n\n/** Variables for {@link confidentialSetOperatorMutationOptions}. */\nexport interface ConfidentialSetOperatorParams {\n operator: Address;\n until?: number;\n}\n\nexport function confidentialSetOperatorMutationOptions(\n token: Token,\n): MutationFactoryOptions<\n readonly [\"zama.confidentialSetOperator\", Address],\n ConfidentialSetOperatorParams,\n TransactionResult\n> {\n return {\n mutationKey: [\"zama.confidentialSetOperator\", token.address] as const,\n mutationFn: async ({ operator, until }) => token.setOperator(operator, until),\n };\n}\n","import type { WrappedToken } from \"../token/wrapped-token\";\nimport type { TransactionResult } from \"../types\";\nimport type { MutationFactoryOptions } from \"./factory-types\";\nimport type { Address } from \"viem\";\n\n/** Variables for {@link approveUnderlyingMutationOptions}. */\nexport interface ApproveUnderlyingParams {\n amount?: bigint;\n}\n\nexport function approveUnderlyingMutationOptions(\n token: WrappedToken,\n): MutationFactoryOptions<\n readonly [\"zama.approveUnderlying\", Address],\n ApproveUnderlyingParams,\n TransactionResult\n> {\n return {\n mutationKey: [\"zama.approveUnderlying\", token.address] as const,\n mutationFn: async ({ amount }) => token.approveUnderlying(amount),\n };\n}\n","import type { WrappedToken } from \"../token/wrapped-token\";\nimport type { TransactionResult, UnshieldOptions } from \"../types\";\nimport type { MutationFactoryOptions } from \"./factory-types\";\nimport type { Address } from \"viem\";\n\n/** Variables for {@link unshieldMutationOptions}. */\nexport interface UnshieldParams extends UnshieldOptions {\n amount: bigint;\n}\n\nexport function unshieldMutationOptions(\n token: WrappedToken,\n): MutationFactoryOptions<readonly [\"zama.unshield\", Address], UnshieldParams, TransactionResult> {\n return {\n mutationKey: [\"zama.unshield\", token.address] as const,\n mutationFn: async ({ amount, ...options }) => token.unshield(amount, options),\n };\n}\n","import type { WrappedToken } from \"../token/wrapped-token\";\nimport type { TransactionResult, UnshieldCallbacks } from \"../types\";\nimport type { MutationFactoryOptions } from \"./factory-types\";\nimport type { Address } from \"viem\";\n\n/** Variables for {@link unshieldAllMutationOptions}. */\nexport interface UnshieldAllParams extends UnshieldCallbacks {}\n\nexport function unshieldAllMutationOptions(\n token: WrappedToken,\n): MutationFactoryOptions<\n readonly [\"zama.unshieldAll\", Address],\n UnshieldAllParams | void,\n TransactionResult\n> {\n return {\n mutationKey: [\"zama.unshieldAll\", token.address] as const,\n mutationFn: async (params) => token.unshieldAll(params || undefined),\n };\n}\n","import type { WrappedToken } from \"../token/wrapped-token\";\nimport type { TransactionResult, UnshieldCallbacks } from \"../types\";\nimport type { MutationFactoryOptions } from \"./factory-types\";\nimport type { Address, Hex } from \"viem\";\n\n/** Variables for {@link resumeUnshieldMutationOptions}. */\nexport interface ResumeUnshieldParams extends UnshieldCallbacks {\n unwrapTxHash: Hex;\n}\n\nexport function resumeUnshieldMutationOptions(\n token: WrappedToken,\n): MutationFactoryOptions<\n readonly [\"zama.resumeUnshield\", Address],\n ResumeUnshieldParams,\n TransactionResult\n> {\n return {\n mutationKey: [\"zama.resumeUnshield\", token.address] as const,\n mutationFn: async ({ unwrapTxHash, ...callbacks }) =>\n token.resumeUnshield(unwrapTxHash, callbacks),\n };\n}\n","import type { WrappedToken } from \"../token/wrapped-token\";\nimport type { TransactionResult } from \"../types\";\nimport type { MutationFactoryOptions } from \"./factory-types\";\nimport type { Address } from \"viem\";\n\n/** Variables for {@link unwrapMutationOptions}. */\nexport interface UnwrapParams {\n amount: bigint;\n}\n\nexport function unwrapMutationOptions(\n token: WrappedToken,\n): MutationFactoryOptions<readonly [\"zama.unwrap\", Address], UnwrapParams, TransactionResult> {\n return {\n mutationKey: [\"zama.unwrap\", token.address] as const,\n mutationFn: async ({ amount }) => token.unwrap(amount),\n };\n}\n","import type { WrappedToken } from \"../token/wrapped-token\";\nimport type { TransactionResult } from \"../types\";\nimport type { MutationFactoryOptions } from \"./factory-types\";\nimport type { Address } from \"viem\";\n\nexport function unwrapAllMutationOptions(\n token: WrappedToken,\n): MutationFactoryOptions<readonly [\"zama.unwrapAll\", Address], void, TransactionResult> {\n return {\n mutationKey: [\"zama.unwrapAll\", token.address] as const,\n mutationFn: async () => token.unwrapAll(),\n };\n}\n","import type { EncryptedValue } from \"../relayer/relayer-sdk.types\";\nimport type { WrappedToken } from \"../token/wrapped-token\";\nimport type { TransactionResult } from \"../types\";\nimport type { MutationFactoryOptions } from \"./factory-types\";\nimport type { Address } from \"viem\";\n/** Variables for {@link finalizeUnwrapMutationOptions}. */\nexport type FinalizeUnwrapParams = {\n /** Identifier from an `UnwrapRequested` event. */\n unwrapRequestId: EncryptedValue;\n};\n\nexport function finalizeUnwrapMutationOptions(\n token: WrappedToken,\n): MutationFactoryOptions<\n readonly [\"zama.finalizeUnwrap\", Address],\n FinalizeUnwrapParams,\n TransactionResult\n> {\n return {\n mutationKey: [\"zama.finalizeUnwrap\", token.address] as const,\n mutationFn: async ({ unwrapRequestId }) => token.finalizeUnwrap(unwrapRequestId),\n };\n}\n","import type { EncryptParams, EncryptResult } from \"../relayer/relayer-sdk.types\";\nimport type { ZamaSDK } from \"../zama-sdk\";\nimport type { MutationFactoryOptions } from \"./factory-types\";\n\nexport function encryptMutationOptions(\n sdk: ZamaSDK,\n): MutationFactoryOptions<readonly [\"zama.encrypt\"], EncryptParams, EncryptResult> {\n return { mutationKey: [\"zama.encrypt\"], mutationFn: async (params) => sdk.encrypt(params) };\n}\n","import type { Address } from \"viem\";\nimport type { ClearValue, EncryptedValue } from \"../relayer/relayer-sdk.types\";\nimport type { EncryptedInput } from \"./user-decrypt\";\nimport type { ZamaSDK } from \"../zama-sdk\";\nimport type { MutationFactoryOptions } from \"./factory-types\";\n\nexport interface DelegatedDecryptValuesMutationParams {\n encryptedInputs: EncryptedInput[];\n delegatorAddress: Address;\n}\n\nexport function delegatedDecryptValuesMutationOptions(\n sdk: ZamaSDK,\n): MutationFactoryOptions<\n readonly [\"zama.delegatedDecryptValues\"],\n DelegatedDecryptValuesMutationParams,\n Readonly<Record<EncryptedValue, ClearValue>>\n> {\n return {\n mutationKey: [\"zama.delegatedDecryptValues\"],\n mutationFn: async (params) =>\n sdk.decryption.delegatedDecryptValues(params.encryptedInputs, params.delegatorAddress),\n };\n}\n","import type { ClearValue, EncryptedValue, PublicDecryptResult } from \"../relayer/relayer-sdk.types\";\nimport type { ZamaSDK } from \"../zama-sdk\";\nimport type { MutationFactoryOptions } from \"./factory-types\";\nimport { zamaQueryKeys } from \"./query-keys\";\n\nexport function decryptPublicValuesMutationOptions(\n sdk: ZamaSDK,\n): MutationFactoryOptions<\n readonly [\"zama.decryptPublicValues\"],\n EncryptedValue[],\n PublicDecryptResult\n> {\n return {\n mutationKey: [\"zama.decryptPublicValues\"],\n mutationFn: async (handles) => sdk.decryption.decryptPublicValues(handles),\n onSuccess: (data, _variables, _onMutateResult, context) => {\n for (const [handle, value] of Object.entries(data.clearValues) as [\n EncryptedValue,\n ClearValue,\n ][]) {\n context.client.setQueryData(zamaQueryKeys.decryption.encryptedValue(handle), value);\n }\n },\n };\n}\n","import type { Address } from \"viem\";\nimport type { ZamaSDK } from \"../zama-sdk\";\nimport type { MutationFactoryOptions } from \"./factory-types\";\n\nexport function grantPermitMutationOptions(\n sdk: ZamaSDK,\n): MutationFactoryOptions<readonly [\"zama.grantPermit\"], Address[], void> {\n return {\n mutationKey: [\"zama.grantPermit\"],\n mutationFn: (contractAddresses) => sdk.permits.grantPermit(contractAddresses),\n };\n}\n","import type { Address } from \"viem\";\nimport type { ZamaSDK } from \"../zama-sdk\";\nimport type { QueryFactoryOptions } from \"./factory-types\";\nimport { zamaQueryKeys } from \"./query-keys\";\nimport type { SignerQueryContext } from \"./signer-query-context\";\nimport { filterQueryOptions } from \"./utils\";\n\nexport interface HasPermitQueryConfig {\n /** Contract addresses to check credentials against. */\n contractAddresses: Address[];\n /**\n * Standard TanStack query options. `hasPermit` intentionally overrides cache\n * timing because permit state is wallet-local, not server state: every fetch\n * should read the SDK credential service directly.\n */\n query?: Record<string, unknown>;\n}\n\nexport function hasPermitQueryOptions(\n sdk: ZamaSDK,\n config: HasPermitQueryConfig,\n signerContext: SignerQueryContext = {},\n): QueryFactoryOptions<boolean, Error, boolean, ReturnType<typeof zamaQueryKeys.hasPermit.scope>> {\n const callerEnabled = config.query?.enabled !== false;\n return {\n ...filterQueryOptions(config?.query ?? {}),\n queryKey: zamaQueryKeys.hasPermit.scope(config.contractAddresses, signerContext.walletAccount),\n queryFn: (context) => {\n const [, { contractAddresses }] = context.queryKey;\n return sdk.permits.hasPermit(contractAddresses as Address[]);\n },\n staleTime: 0,\n gcTime: 0,\n refetchOnMount: \"always\",\n refetchOnWindowFocus: false,\n enabled:\n callerEnabled &&\n signerContext.walletAccount !== undefined &&\n config.contractAddresses.length > 0,\n } as const;\n}\n","import type { Address } from \"viem\";\nimport type { ZamaSDK } from \"../zama-sdk\";\nimport type { MutationFactoryOptions } from \"./factory-types\";\n\n/** TanStack Query mutation factory for {@link Permits.revokePermits}. */\nexport function revokePermitsMutationOptions(\n sdk: ZamaSDK,\n): MutationFactoryOptions<readonly [\"zama.revokePermits\"], Address[] | void, void> {\n return {\n mutationKey: [\"zama.revokePermits\"],\n mutationFn: (contracts: Address[] | void) =>\n contracts === undefined ? sdk.permits.revokePermits() : sdk.permits.revokePermits(contracts),\n };\n}\n","import type { ZamaSDK } from \"../zama-sdk\";\nimport type { MutationFactoryOptions } from \"./factory-types\";\n\n/** TanStack Query mutation factory for {@link Permits.clear}. */\nexport function clearCredentialsMutationOptions(\n sdk: ZamaSDK,\n): MutationFactoryOptions<readonly [\"zama.clearCredentials\"], void, void> {\n return { mutationKey: [\"zama.clearCredentials\"], mutationFn: () => sdk.permits.clear() };\n}\n","import type { Address } from \"viem\";\nimport type { TransactionResult } from \"../types\";\nimport type { ZamaSDK } from \"../zama-sdk\";\nimport type { MutationFactoryOptions } from \"./factory-types\";\n\n/** Variables for {@link delegateDecryptionMutationOptions}. */\nexport interface DelegateDecryptionParams {\n delegateAddress: Address;\n expirationDate?: Date;\n}\n\nexport function delegateDecryptionMutationOptions(\n sdk: ZamaSDK,\n contractAddress: Address,\n): MutationFactoryOptions<\n readonly [\"zama.delegateDecryption\", Address],\n DelegateDecryptionParams,\n TransactionResult\n> {\n return {\n mutationKey: [\"zama.delegateDecryption\", contractAddress] as const,\n mutationFn: async ({ delegateAddress, expirationDate }) =>\n sdk.delegations.delegateDecryption({ contractAddress, delegateAddress, expirationDate }),\n };\n}\n","import type { UserDecryptResults } from \"@zama-fhe/relayer-sdk/bundle\";\nimport type { Address } from \"viem\";\nimport type { EncryptedValue } from \"../relayer/relayer-sdk.types\";\nimport type { ZamaSDK } from \"../zama-sdk\";\nimport type { QueryFactoryOptions } from \"./factory-types\";\nimport { zamaQueryKeys } from \"./query-keys\";\nimport type { SignerQueryContext } from \"./signer-query-context\";\n\nexport interface EncryptedInput {\n encryptedValue: EncryptedValue;\n contractAddress: Address;\n}\n\n/** Alias for {@link UserDecryptResults}. */\nexport type DecryptResult = UserDecryptResults;\n\nexport function decryptValuesQueryOptions(\n sdk: ZamaSDK,\n encryptedInputs: EncryptedInput[],\n signerContext: SignerQueryContext = {},\n): QueryFactoryOptions<\n DecryptResult,\n Error,\n DecryptResult,\n ReturnType<typeof zamaQueryKeys.decryption.encryptedInputs>\n> {\n return {\n queryKey: zamaQueryKeys.decryption.encryptedInputs(\n encryptedInputs,\n signerContext.walletAccount,\n ),\n queryFn: (context) => {\n const [, { encryptedInputs: keyedInputs }] = context.queryKey;\n return sdk.decryption.decryptValues(keyedInputs);\n },\n staleTime: Infinity,\n enabled: encryptedInputs.length > 0 && signerContext.walletAccount !== undefined,\n };\n}\n","import type { Address } from \"viem\";\nimport type { Token } from \"../token/token\";\nimport type { MutationFactoryOptions } from \"./factory-types\";\n\n/** Variables for {@link decryptBalanceAsMutationOptions}. */\nexport interface DecryptBalanceAsParams {\n delegatorAddress: Address;\n accountAddress?: Address;\n}\n\nexport function decryptBalanceAsMutationOptions(\n token: Token,\n): MutationFactoryOptions<\n readonly [\"zama.decryptBalanceAs\", Address],\n DecryptBalanceAsParams,\n bigint\n> {\n return {\n mutationKey: [\"zama.decryptBalanceAs\", token.address] as const,\n mutationFn: async ({ delegatorAddress, accountAddress }) =>\n token.decryptBalanceAs({ delegatorAddress, accountAddress }),\n };\n}\n","import { Token, type BatchDecryptAsOptions } from \"../token/token\";\nimport type { Address } from \"viem\";\nimport type { MutationFactoryOptions } from \"./factory-types\";\n\n/** Variables for {@link batchDecryptBalancesAsMutationOptions}. */\nexport type BatchDecryptBalancesAsParams = BatchDecryptAsOptions;\n\nexport function batchDecryptBalancesAsMutationOptions(\n tokens: Token[],\n): MutationFactoryOptions<\n readonly [\"zama.batchDecryptBalancesAs\", ...Address[]],\n BatchDecryptBalancesAsParams,\n Map<Address, bigint>\n> {\n return {\n mutationKey: [\"zama.batchDecryptBalancesAs\", ...tokens.map((t) => t.address)] as const,\n mutationFn: async (params) => Token.batchDecryptBalancesAs(tokens, params),\n };\n}\n","import type { Address } from \"viem\";\nimport type { TransactionResult } from \"../types\";\nimport type { ZamaSDK } from \"../zama-sdk\";\nimport type { MutationFactoryOptions } from \"./factory-types\";\n\n/** Variables for {@link revokeDelegationMutationOptions}. */\nexport interface RevokeDelegationParams {\n delegateAddress: Address;\n}\n\nexport function revokeDelegationMutationOptions(\n sdk: ZamaSDK,\n contractAddress: Address,\n): MutationFactoryOptions<\n readonly [\"zama.revokeDelegation\", Address],\n RevokeDelegationParams,\n TransactionResult\n> {\n return {\n mutationKey: [\"zama.revokeDelegation\", contractAddress] as const,\n mutationFn: async ({ delegateAddress }) =>\n sdk.delegations.revokeDelegation({ contractAddress, delegateAddress }),\n };\n}\n","import type { Address } from \"viem\";\nimport { MAX_UINT64 } from \"../contracts\";\nimport { getDelegationExpiryContract } from \"../contracts/acl\";\nimport type { ZamaSDK } from \"../zama-sdk\";\nimport type { QueryFactoryOptions } from \"./factory-types\";\nimport { filterQueryOptions } from \"./utils\";\nimport { zamaQueryKeys } from \"./query-keys\";\nimport { assertNonNullable } from \"../utils\";\n\nexport interface DelegationStatusData {\n isActive: boolean;\n expiryTimestamp: bigint;\n}\n\nexport interface DelegationStatusQueryConfig {\n contractAddress: Address | undefined;\n delegatorAddress?: Address;\n delegateAddress?: Address;\n query?: Record<string, unknown>;\n}\n\nexport function delegationStatusQueryOptions(\n sdk: ZamaSDK,\n config: DelegationStatusQueryConfig,\n): QueryFactoryOptions<\n DelegationStatusData,\n Error,\n DelegationStatusData,\n ReturnType<typeof zamaQueryKeys.delegationStatus.scope>\n> {\n return {\n ...filterQueryOptions(config.query ?? {}),\n queryKey: zamaQueryKeys.delegationStatus.scope(\n config.contractAddress,\n config.delegatorAddress,\n config.delegateAddress,\n ),\n queryFn: async (context) => {\n const [, { contractAddress, delegatorAddress, delegateAddress }] = context.queryKey;\n assertNonNullable(contractAddress, \"delegationStatusQueryOptions: contractAddress\");\n assertNonNullable(delegatorAddress, \"delegationStatusQueryOptions: delegatorAddress\");\n assertNonNullable(delegateAddress, \"delegationStatusQueryOptions: delegateAddress\");\n const acl = await sdk.relayer.getAclAddress();\n const expiryTimestamp = await sdk.provider.readContract(\n getDelegationExpiryContract(acl, delegatorAddress, delegateAddress, contractAddress),\n );\n // Derive isActive from expiry + chain time to stay consistent\n // with sdk.delegations.isActive() (avoids client-clock skew).\n let isActive: boolean;\n if (expiryTimestamp === 0n) {\n isActive = false;\n } else if (expiryTimestamp === MAX_UINT64) {\n isActive = true;\n } else {\n const now = await sdk.provider.getBlockTimestamp();\n isActive = expiryTimestamp > now;\n }\n return { isActive, expiryTimestamp };\n },\n enabled:\n Boolean(config.contractAddress && config.delegatorAddress && config.delegateAddress) &&\n config.query?.enabled !== false,\n } as const;\n}\n"],"mappings":"oNAEA,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,CA2CA,SAAgB,EACd,EACyC,CACzC,GAAM,CACJ,OAAQ,EACR,UAAW,EACX,QAAS,EACT,OAAQ,EACR,gBAAiB,EACjB,eAAgB,EAChB,qBAAsB,EACtB,mBAAoB,EACpB,MAAO,EACP,WAAY,EACZ,aAAc,EACd,QAAS,EACT,SAAU,EACV,eAAgB,EAChB,YAAa,EACb,qBAAsB,EACtB,gBAAiB,EACjB,kBAAmB,EACnB,aAAc,GACd,KAAM,EACN,MAAO,EACP,gBAAiB,EACjB,GAAG,GACD,EAEJ,OAAO,CACT,CAWA,SAAgB,EAAO,EAAsC,CAC3D,OAAO,KAAK,UAAU,GAAW,EAAG,IAC9B,EAAc,CAAK,EACd,OAAO,KAAK,CAAK,CAAC,CACtB,SAAS,CAAC,CACV,QACE,EAAQ,KACP,EAAO,GAAO,EAAM,GACb,GAET,CAAC,CACH,EAGA,OAAO,GAAU,SACZ,EAAM,SAAS,EAGjB,CACR,CACH,CCpIA,MAAM,EAAsB,GAC1B,EAAU,IAAK,IAAA,EAAA,EAAA,WAAA,CAAuB,CAAO,CAAC,EAC1C,EAAoB,GACxB,IAAY,IAAA,GAAY,IAAA,IAAA,EAAA,EAAA,WAAA,CAAuB,CAAO,EAClD,EAAoB,GACxB,EACI,CAAE,eAAA,EAAA,EAAA,WAAA,CAA0B,EAAc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oBACrC,EAAM,iBAAiB,CAAE,mBAAkB,gBAAe,CAAC,CAC/D,CACF,CCfA,SAAgB,GACd,EAKA,CACA,MAAO,CACL,YAAa,CAAC,8BAA+B,GAAG,EAAO,IAAK,GAAM,EAAE,OAAO,CAAC,EAC5E,WAAY,KAAO,IAAWQ,EAAAA,EAAM,uBAAuB,EAAQ,CAAM,CAC3E,CACF,CCRA,SAAgB,GACd,EACA,EAKA,CACA,MAAO,CACL,YAAa,CAAC,wBAAyB,CAAe,EACtD,WAAY,MAAO,CAAE,qBACnB,EAAI,YAAY,iBAAiB,CAAE,kBAAiB,iBAAgB,CAAC,CACzE,CACF,CCFA,SAAgB,GACd,EACA,EAMA,CACA,MAAO,CACL,GAAG,EAAmB,EAAO,OAAS,CAAC,CAAC,EACxC,SAAU,EAAc,iBAAiB,MACvC,EAAO,gBACP,EAAO,iBACP,EAAO,eACT,EACA,QAAS,KAAO,IAAY,CAC1B,GAAM,EAAG,CAAE,kBAAiB,mBAAkB,oBAAqB,EAAQ,SAC3E,EAAA,EAAkB,EAAiB,+CAA+C,EAClF,EAAA,EAAkB,EAAkB,gDAAgD,EACpF,EAAA,EAAkB,EAAiB,+CAA+C,EAClF,IAAM,EAAM,MAAM,EAAI,QAAQ,cAAc,EACtC,EAAkB,MAAM,EAAI,SAAS,aACzCC,EAAAA,EAA4B,EAAK,EAAkB,EAAiB,CAAe,CACrF,EAGI,EASJ,MARA,CAME,EANE,IAAoB,GACX,GACF,IAAoBC,EAAAA,EAClB,GAGA,EAAkB,MADX,EAAI,SAAS,kBAAkB,EAG5C,CAAE,WAAU,iBAAgB,CACrC,EACA,QACE,GAAQ,EAAO,iBAAmB,EAAO,kBAAoB,EAAO,kBACpE,EAAO,OAAO,UAAY,EAC9B,CACF"}
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["z","nameContract","symbolContract","decimalsContract","isConfidentialTokenContract","isContractCallError","isConfidentialWrapperContract","inferredTotalSupplyContract","underlyingContract","allowanceContract","isOperatorContract","Token","zeroAddress","getTokenPairsContract","getConfidentialTokenAddressContract","getTokenAddressContract","getTokenPairsLengthContract","getTokenPairsSliceContract","getTokenPairContract","isConfidentialTokenValidContract","Token","getDelegationExpiryContract","MAX_UINT64"],"sources":["../../../src/query/utils.ts","../../../src/query/query-keys.ts","../../../src/query/invalidation.ts","../../../src/query/token-metadata.ts","../../../src/query/is-confidential.ts","../../../src/query/total-supply.ts","../../../src/query/wrapper-discovery.ts","../../../src/query/underlying-allowance.ts","../../../src/query/pending-unshield.ts","../../../src/query/confidential-is-operator.ts","../../../src/query/confidential-balance.ts","../../../src/query/confidential-balances.ts","../../../src/query/wrappers-registry.ts","../../../src/query/shield.ts","../../../src/query/transfer.ts","../../../src/query/transfer-and-call.ts","../../../src/query/transfer-from.ts","../../../src/query/transfer-from-and-call.ts","../../../src/query/set-operator.ts","../../../src/query/approve-underlying.ts","../../../src/query/unshield.ts","../../../src/query/unshield-all.ts","../../../src/query/resume-unshield.ts","../../../src/query/unwrap.ts","../../../src/query/unwrap-all.ts","../../../src/query/finalize-unwrap.ts","../../../src/query/encrypt.ts","../../../src/query/delegated-decrypt.ts","../../../src/query/public-decrypt.ts","../../../src/query/grant-permit.ts","../../../src/query/has-permit.ts","../../../src/query/revoke-permits.ts","../../../src/query/clear-credentials.ts","../../../src/query/delegate-decryption.ts","../../../src/query/user-decrypt.ts","../../../src/query/decrypt-balance-as.ts","../../../src/query/batch-decrypt-balances-as.ts","../../../src/query/revoke-delegation.ts","../../../src/query/delegation-status.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\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 .toSorted()\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).toSorted(),\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 .toSorted((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\nexport interface QueryLike {\n queryKey: readonly unknown[];\n}\n\nexport interface QueryFilterLike {\n queryKey?: readonly unknown[];\n predicate?: (query: QueryLike) => boolean;\n}\n\nexport interface QueryClientLike {\n invalidateQueries(filters: QueryFilterLike): void | Promise<void>;\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\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\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\nexport function invalidateAfterShield(queryClient: QueryClientLike, tokenAddress: Address): void {\n invalidateBalanceQueries(queryClient, tokenAddress);\n invalidateUnderlyingAllowanceQueries(queryClient, tokenAddress);\n invalidateWagmiBalanceQueries(queryClient);\n}\n\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\nexport function invalidateAfterUnshieldSettled(\n queryClient: QueryClientLike,\n tokenAddress: Address,\n): void {\n invalidatePendingUnshieldQueries(queryClient, tokenAddress);\n}\n\nexport function invalidateAfterTransfer(queryClient: QueryClientLike, tokenAddress: Address): void {\n invalidateBalanceQueries(queryClient, tokenAddress);\n}\n\nexport function invalidateAfterApproveUnderlying(\n queryClient: QueryClientLike,\n tokenAddress: Address,\n): void {\n invalidateUnderlyingAllowanceQueries(queryClient, tokenAddress);\n}\n\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\nexport function invalidateWagmiBalanceQueries(queryClient: QueryClientLike): void {\n void queryClient.invalidateQueries({ predicate: isWagmiBalanceQuery });\n}\n\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","import { decimalsContract, nameContract, symbolContract } from \"../contracts\";\n\nimport type { ZamaSDK } from \"../zama-sdk\";\nimport type { QueryFactoryOptions } from \"./factory-types\";\nimport { zamaQueryKeys } from \"./query-keys\";\nimport { filterQueryOptions } from \"./utils\";\nimport type { Address } from \"viem\";\n\n/** ERC-20 token metadata returned by {@link tokenMetadataQueryOptions}. */\nexport interface TokenMetadata {\n name: string;\n symbol: string;\n decimals: number;\n}\n\nexport interface TokenMetadataQueryConfig {\n query?: Record<string, unknown>;\n}\n\nexport function tokenMetadataQueryOptions(\n sdk: ZamaSDK,\n tokenAddress: Address,\n config?: TokenMetadataQueryConfig,\n): QueryFactoryOptions<\n TokenMetadata,\n Error,\n TokenMetadata,\n ReturnType<typeof zamaQueryKeys.tokenMetadata.token>\n> {\n const queryKey = zamaQueryKeys.tokenMetadata.token(tokenAddress);\n\n return {\n ...filterQueryOptions(config?.query ?? {}),\n queryKey,\n queryFn: async (context) => {\n const [, { tokenAddress: keyTokenAddress }] = context.queryKey;\n const [name, symbol, decimals] = await Promise.all([\n sdk.provider.readContract(nameContract(keyTokenAddress)),\n sdk.provider.readContract(symbolContract(keyTokenAddress)),\n sdk.provider.readContract(decimalsContract(keyTokenAddress)),\n ]);\n return { name, symbol, decimals };\n },\n staleTime: Infinity,\n enabled: config?.query?.enabled !== false,\n };\n}\n","import { isConfidentialTokenContract, isConfidentialWrapperContract } from \"../contracts\";\nimport type { ZamaSDK } from \"../zama-sdk\";\nimport { isContractCallError } from \"../utils\";\nimport type { QueryFactoryOptions } from \"./factory-types\";\nimport { zamaQueryKeys } from \"./query-keys\";\nimport { filterQueryOptions } from \"./utils\";\nimport type { Address } from \"viem\";\n\nexport interface IsConfidentialQueryConfig {\n query?: Record<string, unknown>;\n}\n\nexport function isConfidentialQueryOptions(\n sdk: ZamaSDK,\n tokenAddress: Address,\n config?: IsConfidentialQueryConfig,\n): QueryFactoryOptions<\n boolean,\n Error,\n boolean,\n ReturnType<typeof zamaQueryKeys.isConfidential.token>\n> {\n const queryKey = zamaQueryKeys.isConfidential.token(tokenAddress);\n return {\n ...filterQueryOptions(config?.query ?? {}),\n queryKey,\n queryFn: async (context) => {\n const [, { tokenAddress: keyTokenAddress }] = context.queryKey;\n try {\n return await sdk.provider.readContract(isConfidentialTokenContract(keyTokenAddress));\n } catch (err) {\n // Only suppress contract execution reverts (non-ERC-165 contracts).\n // Re-throw network/transport errors so TanStack Query's retry logic applies.\n if (isContractCallError(err)) {\n return false;\n }\n throw err;\n }\n },\n staleTime: Infinity,\n enabled: config?.query?.enabled !== false,\n };\n}\n\nexport function isWrapperQueryOptions(\n sdk: ZamaSDK,\n tokenAddress: Address,\n config?: IsConfidentialQueryConfig,\n): QueryFactoryOptions<boolean, Error, boolean, ReturnType<typeof zamaQueryKeys.isWrapper.token>> {\n const queryKey = zamaQueryKeys.isWrapper.token(tokenAddress);\n return {\n ...filterQueryOptions(config?.query ?? {}),\n queryKey,\n queryFn: async (context) => {\n const [, { tokenAddress: keyTokenAddress }] = context.queryKey;\n try {\n return await sdk.provider.readContract(isConfidentialWrapperContract(keyTokenAddress));\n } catch (err) {\n // Only suppress contract execution reverts (non-ERC-165 contracts).\n // Re-throw network/transport errors so TanStack Query's retry logic applies.\n if (isContractCallError(err)) {\n return false;\n }\n throw err;\n }\n },\n staleTime: Infinity,\n enabled: config?.query?.enabled !== false,\n };\n}\n","import { inferredTotalSupplyContract } from \"../contracts\";\nimport type { ZamaSDK } from \"../zama-sdk\";\nimport type { QueryFactoryOptions } from \"./factory-types\";\nimport { zamaQueryKeys } from \"./query-keys\";\nimport { filterQueryOptions } from \"./utils\";\nimport type { Address } from \"viem\";\n\nexport interface TotalSupplyQueryConfig {\n query?: Record<string, unknown>;\n}\n\nexport function totalSupplyQueryOptions(\n sdk: ZamaSDK,\n tokenAddress: Address,\n config?: TotalSupplyQueryConfig,\n): QueryFactoryOptions<bigint, Error, bigint, ReturnType<typeof zamaQueryKeys.totalSupply.token>> {\n const queryKey = zamaQueryKeys.totalSupply.token(tokenAddress);\n\n return {\n ...filterQueryOptions(config?.query ?? {}),\n queryKey,\n queryFn: async (context) => {\n const [, { tokenAddress: keyTokenAddress }] = context.queryKey;\n return sdk.provider.readContract(inferredTotalSupplyContract(keyTokenAddress));\n },\n staleTime: 30_000,\n enabled: config?.query?.enabled !== false,\n };\n}\n","import type { Address } from \"viem\";\nimport type { WrappersRegistry } from \"../wrappers-registry\";\nimport type { QueryFactoryOptions } from \"./factory-types\";\nimport { zamaQueryKeys } from \"./query-keys\";\nimport { assertNonNullable } from \"../utils/assertions\";\nimport { filterQueryOptions } from \"./utils\";\n\nexport interface WrapperDiscoveryQueryConfig {\n /**\n * Address of any confidential token you control.\n * Used to scope the query cache key and to gate whether the query\n * is enabled — it does not affect which wrapper the registry returns.\n */\n tokenAddress?: Address;\n /**\n * The ERC-20 token address to discover the confidential wrapper for.\n * The registry is resolved automatically from chain config.\n */\n erc20Address?: Address;\n /**\n * The resolved registry contract address for the current chain.\n * Included in the query key so that switching chains invalidates\n * stale cached results. Pass `undefined` when the chain ID is not\n * yet known — the query will be disabled.\n */\n registryAddress?: Address;\n query?: Record<string, unknown>;\n}\n\nexport function wrapperDiscoveryQueryOptions(\n registry: WrappersRegistry,\n config: WrapperDiscoveryQueryConfig,\n): QueryFactoryOptions<\n Address | null,\n Error,\n Address | null,\n ReturnType<typeof zamaQueryKeys.wrapperDiscovery.token>\n> {\n const queryKey = zamaQueryKeys.wrapperDiscovery.token(\n config.tokenAddress,\n config.erc20Address,\n config.registryAddress,\n );\n\n return {\n ...filterQueryOptions(config.query ?? {}),\n queryKey,\n queryFn: async (context) => {\n const [, { erc20Address }] = context.queryKey;\n assertNonNullable(erc20Address, \"wrapperDiscoveryQueryOptions: erc20Address\");\n const result = await registry.getConfidentialToken(erc20Address);\n return result ? result.confidentialTokenAddress : null;\n },\n staleTime: Infinity,\n enabled:\n Boolean(config.tokenAddress && config.erc20Address && config.registryAddress) &&\n config.query?.enabled !== false,\n };\n}\n","import { allowanceContract, underlyingContract } from \"../contracts\";\nimport type { ZamaSDK } from \"../zama-sdk\";\nimport { assertNonNullable } from \"../utils/assertions\";\nimport type { QueryFactoryOptions } from \"./factory-types\";\nimport { zamaQueryKeys } from \"./query-keys\";\nimport { filterQueryOptions } from \"./utils\";\nimport type { Address } from \"viem\";\n\nexport interface UnderlyingAllowanceQueryConfig {\n owner?: Address;\n query?: Record<string, unknown>;\n}\n\nexport function underlyingAllowanceQueryOptions(\n sdk: ZamaSDK,\n tokenAddress: Address,\n config: UnderlyingAllowanceQueryConfig,\n): QueryFactoryOptions<\n bigint,\n Error,\n bigint,\n ReturnType<typeof zamaQueryKeys.underlyingAllowance.scope>\n> {\n const ownerKey = config.owner;\n const queryEnabled = config.query?.enabled !== false;\n const queryKey = zamaQueryKeys.underlyingAllowance.scope(tokenAddress, ownerKey);\n\n return {\n ...filterQueryOptions(config.query ?? {}),\n queryKey,\n queryFn: async (context) => {\n const [, { tokenAddress: keyTokenAddress, owner: keyOwner }] = context.queryKey;\n assertNonNullable(keyOwner, \"underlyingAllowanceQueryOptions: owner\");\n const underlying = await sdk.provider.readContract(underlyingContract(keyTokenAddress));\n return sdk.provider.readContract(allowanceContract(underlying, keyOwner, keyTokenAddress));\n },\n staleTime: 30_000,\n enabled: Boolean(ownerKey) && queryEnabled,\n };\n}\n","import type { Address, Hex } from \"viem\";\nimport type { ZamaSDK } from \"../zama-sdk\";\nimport type { QueryFactoryOptions } from \"./factory-types\";\nimport { zamaQueryKeys } from \"./query-keys\";\nimport { filterQueryOptions } from \"./utils\";\n\nexport interface PendingUnshieldQueryConfig {\n query?: Record<string, unknown>;\n}\n\n/**\n * Query options for reading the unwrap tx hash of an unshield that was\n * interrupted between its two phases (returns `null` if none is pending).\n *\n * Backed by {@link ZamaSDK} storage via `WrappedToken.getPendingUnshield()`.\n * `staleTime: 0` so the value reflects storage on mount; the unshield/unwrap\n * mutations also invalidate this key on success.\n */\nexport function pendingUnshieldQueryOptions(\n sdk: ZamaSDK,\n tokenAddress: Address,\n config?: PendingUnshieldQueryConfig,\n): QueryFactoryOptions<\n Hex | null,\n Error,\n Hex | null,\n ReturnType<typeof zamaQueryKeys.pendingUnshield.token>\n> {\n const queryKey = zamaQueryKeys.pendingUnshield.token(tokenAddress);\n\n return {\n ...filterQueryOptions(config?.query ?? {}),\n queryKey,\n queryFn: async (context) => {\n const [, { tokenAddress: keyTokenAddress }] = context.queryKey;\n return sdk.createWrappedToken(keyTokenAddress).getPendingUnshield();\n },\n staleTime: 0,\n enabled: config?.query?.enabled !== false,\n };\n}\n","import { isOperatorContract } from \"../contracts\";\nimport type { ZamaSDK } from \"../zama-sdk\";\nimport { assertNonNullable } from \"../utils/assertions\";\nimport type { QueryFactoryOptions } from \"./factory-types\";\nimport { filterQueryOptions } from \"./utils\";\nimport { zamaQueryKeys } from \"./query-keys\";\nimport type { Address } from \"viem\";\n\nexport interface ConfidentialIsOperatorQueryConfig {\n holder?: Address;\n spender?: Address;\n query?: Record<string, unknown>;\n}\n\nexport function confidentialIsOperatorQueryOptions(\n sdk: ZamaSDK,\n tokenAddress: Address | undefined,\n config: ConfidentialIsOperatorQueryConfig,\n): QueryFactoryOptions<\n boolean,\n Error,\n boolean,\n ReturnType<typeof zamaQueryKeys.confidentialIsOperator.scope>\n> {\n const holderKey = config.holder;\n const spenderKey = config.spender;\n const queryEnabled = config.query?.enabled !== false;\n const queryKey = zamaQueryKeys.confidentialIsOperator.scope(tokenAddress, holderKey, spenderKey);\n\n return {\n ...filterQueryOptions(config.query ?? {}),\n queryKey,\n queryFn: async (context) => {\n const [, { tokenAddress: keyTokenAddress, holder: keyHolder, spender: keySpender }] =\n context.queryKey;\n assertNonNullable(keyTokenAddress, \"confidentialIsOperatorQueryOptions: tokenAddress\");\n assertNonNullable(keyHolder, \"confidentialIsOperatorQueryOptions: holder\");\n assertNonNullable(keySpender, \"confidentialIsOperatorQueryOptions: spender\");\n return sdk.provider.readContract(isOperatorContract(keyTokenAddress, keyHolder, keySpender));\n },\n staleTime: 30_000,\n enabled: Boolean(tokenAddress && holderKey && spenderKey) && queryEnabled,\n };\n}\n","import type { Address } from \"viem\";\nimport type { Token } from \"../token\";\nimport { assertNonNullable } from \"../utils/assertions\";\nimport type { QueryFactoryOptions } from \"./factory-types\";\nimport { zamaQueryKeys } from \"./query-keys\";\nimport type { SignerQueryContext } from \"./signer-query-context\";\nimport { filterQueryOptions } from \"./utils\";\n\nexport interface ConfidentialBalanceQueryConfig {\n tokenAddress: Address;\n account?: Address;\n query?: Record<string, unknown>;\n}\n\n/** Query options for a single confidential token balance. Auto-gated on `account`. */\nexport function confidentialBalanceQueryOptions(\n token: Token,\n config: ConfidentialBalanceQueryConfig,\n signerContext: SignerQueryContext = {},\n): QueryFactoryOptions<\n bigint,\n Error,\n bigint,\n ReturnType<typeof zamaQueryKeys.confidentialBalance.owner>\n> {\n const queryOpts = config.query ?? {};\n\n return {\n ...filterQueryOptions(queryOpts),\n queryKey: zamaQueryKeys.confidentialBalance.owner(\n config.tokenAddress,\n config.account,\n signerContext.walletAccount,\n ),\n queryFn: async (context) => {\n const [, { owner: keyOwner }] = context.queryKey;\n assertNonNullable(keyOwner, \"confidentialBalanceQueryOptions: owner\");\n return token.balanceOf(keyOwner);\n },\n enabled:\n Boolean(config.account) &&\n signerContext.walletAccount !== undefined &&\n queryOpts?.enabled !== false,\n };\n}\n","import type { Address } from \"viem\";\nimport { Token, type BatchBalancesResult } from \"../token/token\";\nimport { assertNonNullable } from \"../utils/assertions\";\nimport type { QueryFactoryOptions } from \"./factory-types\";\nimport { zamaQueryKeys } from \"./query-keys\";\nimport type { SignerQueryContext } from \"./signer-query-context\";\nimport { filterQueryOptions } from \"./utils\";\n\nexport interface ConfidentialBalancesQueryConfig {\n account?: Address;\n query?: Record<string, unknown>;\n}\n\nexport function confidentialBalancesQueryOptions(\n tokens: Token[],\n config?: ConfidentialBalancesQueryConfig,\n signerContext: SignerQueryContext = {},\n): QueryFactoryOptions<\n BatchBalancesResult,\n Error,\n BatchBalancesResult,\n ReturnType<typeof zamaQueryKeys.confidentialBalances.tokens>\n> {\n const accountKey = config?.account;\n const walletAccount = signerContext.walletAccount;\n const queryOpts = config?.query ?? {};\n const tokenAddresses = tokens.map((token) => token.address);\n\n return {\n ...filterQueryOptions(queryOpts),\n queryKey: zamaQueryKeys.confidentialBalances.tokens(tokenAddresses, accountKey, walletAccount),\n queryFn: async (signerContextQuery) => {\n const [, { owner: keyOwner }] = signerContextQuery.queryKey;\n assertNonNullable(keyOwner, \"confidentialBalancesQueryOptions: owner\");\n return Token.batchBalancesOf(tokens, keyOwner);\n },\n enabled:\n Boolean(accountKey) &&\n tokens.length > 0 &&\n walletAccount !== undefined &&\n queryOpts?.enabled !== false,\n };\n}\n","import { type Address, zeroAddress } from \"viem\";\nimport {\n getTokenPairsContract,\n getTokenPairsLengthContract,\n getTokenPairsSliceContract,\n getTokenPairContract,\n getConfidentialTokenAddressContract,\n getTokenAddressContract,\n isConfidentialTokenValidContract,\n} from \"../contracts\";\nimport type {\n TokenWrapperPair,\n TokenWrapperPairWithMetadata,\n PaginatedResult,\n} from \"../contracts/wrappers-registry\";\nimport type { WrappersRegistry } from \"../wrappers-registry\";\nimport type { ZamaSDK } from \"../zama-sdk\";\nimport type { QueryFactoryOptions } from \"./factory-types\";\nimport { zamaQueryKeys } from \"./query-keys\";\nimport { filterQueryOptions } from \"./utils\";\n\nexport interface WrappersRegistryQueryConfig {\n registryAddress: Address | undefined;\n query?: Record<string, unknown>;\n}\n\nexport function tokenPairsQueryOptions(\n sdk: ZamaSDK,\n config: WrappersRegistryQueryConfig,\n): QueryFactoryOptions<\n readonly TokenWrapperPair[],\n Error,\n readonly TokenWrapperPair[],\n ReturnType<typeof zamaQueryKeys.wrappersRegistry.tokenPairs>\n> {\n const enabled = Boolean(config.registryAddress) && config.query?.enabled !== false;\n const queryKey = zamaQueryKeys.wrappersRegistry.tokenPairs(config.registryAddress ?? zeroAddress);\n return {\n ...filterQueryOptions(config.query ?? {}),\n queryKey,\n queryFn: async (context) => {\n const [, { registryAddress }] = context.queryKey;\n return sdk.provider.readContract(getTokenPairsContract(registryAddress));\n },\n staleTime: sdk.registry.ttlMs,\n enabled,\n };\n}\n\nexport interface ConfidentialTokenAddressQueryConfig extends WrappersRegistryQueryConfig {\n tokenAddress?: Address;\n}\n\nexport function confidentialTokenAddressQueryOptions(\n sdk: ZamaSDK,\n config: ConfidentialTokenAddressQueryConfig,\n): QueryFactoryOptions<\n readonly [boolean, Address],\n Error,\n readonly [boolean, Address],\n ReturnType<typeof zamaQueryKeys.wrappersRegistry.confidentialTokenAddress>\n> {\n const enabled =\n Boolean(config.registryAddress) &&\n Boolean(config.tokenAddress) &&\n config.query?.enabled !== false;\n const queryKey = zamaQueryKeys.wrappersRegistry.confidentialTokenAddress(\n config.registryAddress ?? zeroAddress,\n config.tokenAddress ?? zeroAddress,\n );\n return {\n ...filterQueryOptions(config.query ?? {}),\n queryKey,\n queryFn: async (context) => {\n const [, { registryAddress, tokenAddress }] = context.queryKey;\n return sdk.provider.readContract(\n getConfidentialTokenAddressContract(registryAddress, tokenAddress),\n );\n },\n staleTime: sdk.registry.ttlMs,\n enabled,\n };\n}\n\nexport interface TokenAddressQueryConfig extends WrappersRegistryQueryConfig {\n confidentialTokenAddress?: Address;\n}\n\nexport function tokenAddressQueryOptions(\n sdk: ZamaSDK,\n config: TokenAddressQueryConfig,\n): QueryFactoryOptions<\n readonly [boolean, Address],\n Error,\n readonly [boolean, Address],\n ReturnType<typeof zamaQueryKeys.wrappersRegistry.tokenAddress>\n> {\n const enabled =\n Boolean(config.registryAddress) &&\n Boolean(config.confidentialTokenAddress) &&\n config.query?.enabled !== false;\n const queryKey = zamaQueryKeys.wrappersRegistry.tokenAddress(\n config.registryAddress ?? zeroAddress,\n config.confidentialTokenAddress ?? zeroAddress,\n );\n return {\n ...filterQueryOptions(config.query ?? {}),\n queryKey,\n queryFn: async (context) => {\n const [, { registryAddress, confidentialTokenAddress }] = context.queryKey;\n return sdk.provider.readContract(\n getTokenAddressContract(registryAddress, confidentialTokenAddress),\n );\n },\n staleTime: sdk.registry.ttlMs,\n enabled,\n };\n}\n\nexport function tokenPairsLengthQueryOptions(\n sdk: ZamaSDK,\n config: WrappersRegistryQueryConfig,\n): QueryFactoryOptions<\n bigint,\n Error,\n bigint,\n ReturnType<typeof zamaQueryKeys.wrappersRegistry.tokenPairsLength>\n> {\n const enabled = Boolean(config.registryAddress) && config.query?.enabled !== false;\n const queryKey = zamaQueryKeys.wrappersRegistry.tokenPairsLength(\n config.registryAddress ?? zeroAddress,\n );\n return {\n ...filterQueryOptions(config.query ?? {}),\n queryKey,\n queryFn: async (context) => {\n const [, { registryAddress }] = context.queryKey;\n return sdk.provider.readContract(getTokenPairsLengthContract(registryAddress));\n },\n staleTime: sdk.registry.ttlMs,\n enabled,\n };\n}\n\nexport interface TokenPairsSliceQueryConfig extends WrappersRegistryQueryConfig {\n fromIndex?: bigint;\n toIndex?: bigint;\n}\n\nexport function tokenPairsSliceQueryOptions(\n sdk: ZamaSDK,\n config: TokenPairsSliceQueryConfig,\n): QueryFactoryOptions<\n readonly TokenWrapperPair[],\n Error,\n readonly TokenWrapperPair[],\n ReturnType<typeof zamaQueryKeys.wrappersRegistry.tokenPairsSlice>\n> {\n const enabled =\n Boolean(config.registryAddress) &&\n config.fromIndex !== undefined &&\n config.toIndex !== undefined &&\n config.query?.enabled !== false;\n const queryKey = zamaQueryKeys.wrappersRegistry.tokenPairsSlice(\n config.registryAddress ?? zeroAddress,\n String(config.fromIndex ?? 0n),\n String(config.toIndex ?? 0n),\n );\n return {\n ...filterQueryOptions(config.query ?? {}),\n queryKey,\n queryFn: async (context) => {\n const [, { registryAddress, fromIndex, toIndex }] = context.queryKey;\n return sdk.provider.readContract(\n getTokenPairsSliceContract(registryAddress, BigInt(fromIndex), BigInt(toIndex)),\n );\n },\n staleTime: sdk.registry.ttlMs,\n enabled,\n };\n}\n\nexport interface TokenPairQueryConfig extends WrappersRegistryQueryConfig {\n index?: bigint;\n}\n\nexport function tokenPairQueryOptions(\n sdk: ZamaSDK,\n config: TokenPairQueryConfig,\n): QueryFactoryOptions<\n TokenWrapperPair,\n Error,\n TokenWrapperPair,\n ReturnType<typeof zamaQueryKeys.wrappersRegistry.tokenPair>\n> {\n const enabled =\n Boolean(config.registryAddress) &&\n config.index !== undefined &&\n config.query?.enabled !== false;\n const queryKey = zamaQueryKeys.wrappersRegistry.tokenPair(\n config.registryAddress ?? zeroAddress,\n String(config.index ?? 0n),\n );\n return {\n ...filterQueryOptions(config.query ?? {}),\n queryKey,\n queryFn: async (context) => {\n const [, { registryAddress, index }] = context.queryKey;\n return sdk.provider.readContract(getTokenPairContract(registryAddress, BigInt(index)));\n },\n staleTime: sdk.registry.ttlMs,\n enabled,\n };\n}\n\nexport interface IsConfidentialTokenValidQueryConfig extends WrappersRegistryQueryConfig {\n confidentialTokenAddress?: Address;\n}\n\nexport function isConfidentialTokenValidQueryOptions(\n sdk: ZamaSDK,\n config: IsConfidentialTokenValidQueryConfig,\n): QueryFactoryOptions<\n boolean,\n Error,\n boolean,\n ReturnType<typeof zamaQueryKeys.wrappersRegistry.isConfidentialTokenValid>\n> {\n const enabled =\n Boolean(config.registryAddress) &&\n Boolean(config.confidentialTokenAddress) &&\n config.query?.enabled !== false;\n const queryKey = zamaQueryKeys.wrappersRegistry.isConfidentialTokenValid(\n config.registryAddress ?? zeroAddress,\n config.confidentialTokenAddress ?? zeroAddress,\n );\n return {\n ...filterQueryOptions(config.query ?? {}),\n queryKey,\n queryFn: async (context) => {\n const [, { registryAddress, confidentialTokenAddress }] = context.queryKey;\n return sdk.provider.readContract(\n isConfidentialTokenValidContract(registryAddress, confidentialTokenAddress),\n );\n },\n staleTime: sdk.registry.ttlMs,\n enabled,\n };\n}\n\nexport interface ListPairsQueryConfig {\n /**\n * The registry address for this chain — used as a query key discriminator.\n * The registry instance already knows how to resolve the address for the\n * current chain; this field just keeps the TanStack Query cache isolated\n * per registry contract.\n */\n registryAddress: Address | undefined;\n page?: number;\n pageSize?: number;\n metadata?: boolean;\n query?: Record<string, unknown>;\n}\n\n/**\n * Query options for paginated listing of token wrapper pairs.\n *\n * Accepts a {@link WrappersRegistry} instance rather than a raw provider so that the\n * class-level TTL cache is shared across multiple `queryFn` executions. Pass\n * `sdk.registry` (the ZamaSDK lazy singleton) to ensure a single shared cache.\n */\nexport function listPairsQueryOptions(\n registry: WrappersRegistry,\n config: ListPairsQueryConfig,\n): QueryFactoryOptions<\n PaginatedResult<TokenWrapperPair | TokenWrapperPairWithMetadata>,\n Error,\n PaginatedResult<TokenWrapperPair | TokenWrapperPairWithMetadata>,\n ReturnType<typeof zamaQueryKeys.wrappersRegistry.listPairs>\n> {\n const enabled = Boolean(config.registryAddress) && config.query?.enabled !== false;\n const queryKey = zamaQueryKeys.wrappersRegistry.listPairs(\n config.registryAddress ?? zeroAddress,\n config.page ?? 1,\n config.pageSize ?? 100,\n config.metadata ?? false,\n );\n return {\n ...filterQueryOptions(config.query ?? {}),\n queryKey,\n queryFn: async (context) => {\n const [, { page, pageSize, metadata }] = context.queryKey;\n return registry.listPairs({ page, pageSize, metadata });\n },\n // Use the registry's own TTL so TanStack Query and the class-level cache\n // operate under the same freshness contract.\n staleTime: registry.ttlMs,\n enabled,\n };\n}\n","import type { Address } from \"viem\";\nimport type { WrappedToken } from \"../token/wrapped-token\";\nimport type { ShieldOptions, TransactionResult } from \"../types\";\nimport type { MutationFactoryOptions } from \"./factory-types\";\n\n/** Variables for {@link shieldMutationOptions}. */\nexport interface ShieldParams extends ShieldOptions {\n amount: bigint;\n}\n\nexport function shieldMutationOptions(\n token: WrappedToken,\n): MutationFactoryOptions<readonly [\"zama.shield\", Address], ShieldParams, TransactionResult> {\n return {\n mutationKey: [\"zama.shield\", token.address] as const,\n mutationFn: async ({ amount, ...rest }) => token.shield(amount, rest),\n };\n}\n","import type { Token } from \"../token/token\";\nimport type { TransactionResult, TransferOptions } from \"../types\";\nimport type { MutationFactoryOptions } from \"./factory-types\";\nimport type { Address } from \"viem\";\n\n/** Variables for {@link confidentialTransferMutationOptions}. */\nexport interface ConfidentialTransferParams extends TransferOptions {\n to: Address;\n amount: bigint;\n}\n\nexport function confidentialTransferMutationOptions(\n token: Token,\n): MutationFactoryOptions<\n readonly [\"zama.confidentialTransfer\", Address],\n ConfidentialTransferParams,\n TransactionResult\n> {\n return {\n mutationKey: [\"zama.confidentialTransfer\", token.address] as const,\n mutationFn: async ({ to, amount, ...options }) =>\n token.confidentialTransfer(to, amount, options),\n };\n}\n","import type { Token } from \"../token/token\";\nimport type { TransactionResult, TransferOptions } from \"../types\";\nimport type { MutationFactoryOptions } from \"./factory-types\";\nimport type { Address, Hex } from \"viem\";\n\n/** Variables for {@link confidentialTransferAndCallMutationOptions}. */\nexport interface ConfidentialTransferAndCallParams extends TransferOptions {\n to: Address;\n amount: bigint;\n /** Opaque bytes forwarded to the recipient's ERC-7984 receiver hook. */\n data: Hex;\n}\n\nexport function confidentialTransferAndCallMutationOptions(\n token: Token,\n): MutationFactoryOptions<\n readonly [\"zama.confidentialTransferAndCall\", Address],\n ConfidentialTransferAndCallParams,\n TransactionResult\n> {\n return {\n mutationKey: [\"zama.confidentialTransferAndCall\", token.address] as const,\n mutationFn: async ({ to, amount, data, ...options }) =>\n token.confidentialTransferAndCall(to, amount, data, options),\n };\n}\n","import type { Token } from \"../token/token\";\nimport type { TransferCallbacks, TransactionResult } from \"../types\";\nimport type { MutationFactoryOptions } from \"./factory-types\";\nimport type { Address } from \"viem\";\n\n/** Variables for {@link confidentialTransferFromMutationOptions}. */\nexport interface ConfidentialTransferFromParams {\n from: Address;\n to: Address;\n amount: bigint;\n /** Optional progress callbacks for the multi-step transfer flow. */\n callbacks?: TransferCallbacks;\n}\n\nexport function confidentialTransferFromMutationOptions(\n token: Token,\n): MutationFactoryOptions<\n readonly [\"zama.confidentialTransferFrom\", Address],\n ConfidentialTransferFromParams,\n TransactionResult\n> {\n return {\n mutationKey: [\"zama.confidentialTransferFrom\", token.address] as const,\n mutationFn: async ({ from, to, amount, callbacks }) =>\n token.confidentialTransferFrom(from, to, amount, callbacks),\n };\n}\n","import type { Token } from \"../token/token\";\nimport type { TransferCallbacks, TransactionResult } from \"../types\";\nimport type { MutationFactoryOptions } from \"./factory-types\";\nimport type { Address, Hex } from \"viem\";\n\n/** Variables for {@link confidentialTransferFromAndCallMutationOptions}. */\nexport interface ConfidentialTransferFromAndCallParams {\n from: Address;\n to: Address;\n amount: bigint;\n /** Opaque bytes forwarded to the recipient's ERC-7984 receiver hook. */\n data: Hex;\n /** Optional progress callbacks for the multi-step transfer flow. */\n callbacks?: TransferCallbacks;\n}\n\nexport function confidentialTransferFromAndCallMutationOptions(\n token: Token,\n): MutationFactoryOptions<\n readonly [\"zama.confidentialTransferFromAndCall\", Address],\n ConfidentialTransferFromAndCallParams,\n TransactionResult\n> {\n return {\n mutationKey: [\"zama.confidentialTransferFromAndCall\", token.address] as const,\n mutationFn: async ({ from, to, amount, data, callbacks }) =>\n token.confidentialTransferFromAndCall(from, to, amount, data, callbacks),\n };\n}\n","import type { Token } from \"../token/token\";\nimport type { TransactionResult } from \"../types\";\nimport type { MutationFactoryOptions } from \"./factory-types\";\nimport type { Address } from \"viem\";\n\n/** Variables for {@link confidentialSetOperatorMutationOptions}. */\nexport interface ConfidentialSetOperatorParams {\n operator: Address;\n until?: number;\n}\n\nexport function confidentialSetOperatorMutationOptions(\n token: Token,\n): MutationFactoryOptions<\n readonly [\"zama.confidentialSetOperator\", Address],\n ConfidentialSetOperatorParams,\n TransactionResult\n> {\n return {\n mutationKey: [\"zama.confidentialSetOperator\", token.address] as const,\n mutationFn: async ({ operator, until }) => token.setOperator(operator, until),\n };\n}\n","import type { WrappedToken } from \"../token/wrapped-token\";\nimport type { TransactionResult } from \"../types\";\nimport type { MutationFactoryOptions } from \"./factory-types\";\nimport type { Address } from \"viem\";\n\n/** Variables for {@link approveUnderlyingMutationOptions}. */\nexport interface ApproveUnderlyingParams {\n amount?: bigint;\n}\n\nexport function approveUnderlyingMutationOptions(\n token: WrappedToken,\n): MutationFactoryOptions<\n readonly [\"zama.approveUnderlying\", Address],\n ApproveUnderlyingParams,\n TransactionResult\n> {\n return {\n mutationKey: [\"zama.approveUnderlying\", token.address] as const,\n mutationFn: async ({ amount }) => token.approveUnderlying(amount),\n };\n}\n","import type { WrappedToken } from \"../token/wrapped-token\";\nimport type { TransactionResult, UnshieldOptions } from \"../types\";\nimport type { MutationFactoryOptions } from \"./factory-types\";\nimport type { Address } from \"viem\";\n\n/** Variables for {@link unshieldMutationOptions}. */\nexport interface UnshieldParams extends UnshieldOptions {\n amount: bigint;\n}\n\nexport function unshieldMutationOptions(\n token: WrappedToken,\n): MutationFactoryOptions<readonly [\"zama.unshield\", Address], UnshieldParams, TransactionResult> {\n return {\n mutationKey: [\"zama.unshield\", token.address] as const,\n mutationFn: async ({ amount, ...options }) => token.unshield(amount, options),\n };\n}\n","import type { WrappedToken } from \"../token/wrapped-token\";\nimport type { TransactionResult, UnshieldCallbacks } from \"../types\";\nimport type { MutationFactoryOptions } from \"./factory-types\";\nimport type { Address } from \"viem\";\n\n/** Variables for {@link unshieldAllMutationOptions}. */\nexport interface UnshieldAllParams extends UnshieldCallbacks {}\n\nexport function unshieldAllMutationOptions(\n token: WrappedToken,\n): MutationFactoryOptions<\n readonly [\"zama.unshieldAll\", Address],\n UnshieldAllParams | void,\n TransactionResult\n> {\n return {\n mutationKey: [\"zama.unshieldAll\", token.address] as const,\n mutationFn: async (params) => token.unshieldAll(params || undefined),\n };\n}\n","import type { WrappedToken } from \"../token/wrapped-token\";\nimport type { TransactionResult, UnshieldCallbacks } from \"../types\";\nimport type { MutationFactoryOptions } from \"./factory-types\";\nimport type { Address, Hex } from \"viem\";\n\n/** Variables for {@link resumeUnshieldMutationOptions}. */\nexport interface ResumeUnshieldParams extends UnshieldCallbacks {\n unwrapTxHash: Hex;\n}\n\nexport function resumeUnshieldMutationOptions(\n token: WrappedToken,\n): MutationFactoryOptions<\n readonly [\"zama.resumeUnshield\", Address],\n ResumeUnshieldParams,\n TransactionResult\n> {\n return {\n mutationKey: [\"zama.resumeUnshield\", token.address] as const,\n mutationFn: async ({ unwrapTxHash, ...callbacks }) =>\n token.resumeUnshield(unwrapTxHash, callbacks),\n };\n}\n","import type { WrappedToken } from \"../token/wrapped-token\";\nimport type { TransactionResult } from \"../types\";\nimport type { MutationFactoryOptions } from \"./factory-types\";\nimport type { Address } from \"viem\";\n\n/** Variables for {@link unwrapMutationOptions}. */\nexport interface UnwrapParams {\n amount: bigint;\n}\n\nexport function unwrapMutationOptions(\n token: WrappedToken,\n): MutationFactoryOptions<readonly [\"zama.unwrap\", Address], UnwrapParams, TransactionResult> {\n return {\n mutationKey: [\"zama.unwrap\", token.address] as const,\n mutationFn: async ({ amount }) => token.unwrap(amount),\n };\n}\n","import type { WrappedToken } from \"../token/wrapped-token\";\nimport type { TransactionResult } from \"../types\";\nimport type { MutationFactoryOptions } from \"./factory-types\";\nimport type { Address } from \"viem\";\n\nexport function unwrapAllMutationOptions(\n token: WrappedToken,\n): MutationFactoryOptions<readonly [\"zama.unwrapAll\", Address], void, TransactionResult> {\n return {\n mutationKey: [\"zama.unwrapAll\", token.address] as const,\n mutationFn: async () => token.unwrapAll(),\n };\n}\n","import type { EncryptedValue } from \"../relayer/types\";\nimport type { WrappedToken } from \"../token/wrapped-token\";\nimport type { TransactionResult } from \"../types\";\nimport type { MutationFactoryOptions } from \"./factory-types\";\nimport type { Address } from \"viem\";\n/** Variables for {@link finalizeUnwrapMutationOptions}. */\nexport type FinalizeUnwrapParams = {\n /** Identifier from an `UnwrapRequested` event. */\n unwrapRequestId: EncryptedValue;\n};\n\nexport function finalizeUnwrapMutationOptions(\n token: WrappedToken,\n): MutationFactoryOptions<\n readonly [\"zama.finalizeUnwrap\", Address],\n FinalizeUnwrapParams,\n TransactionResult\n> {\n return {\n mutationKey: [\"zama.finalizeUnwrap\", token.address] as const,\n mutationFn: async ({ unwrapRequestId }) => token.finalizeUnwrap(unwrapRequestId),\n };\n}\n","import type { EncryptParams } from \"../node\";\nimport type { EncryptResult } from \"../relayer/types\";\nimport type { ZamaSDK } from \"../zama-sdk\";\nimport type { MutationFactoryOptions } from \"./factory-types\";\n\nexport function encryptMutationOptions(\n sdk: ZamaSDK,\n): MutationFactoryOptions<readonly [\"zama.encrypt\"], EncryptParams, EncryptResult> {\n return { mutationKey: [\"zama.encrypt\"], mutationFn: async (params) => sdk.encrypt(params) };\n}\n","import type { Address } from \"viem\";\nimport type { ClearValue, EncryptedValue } from \"../relayer/types\";\nimport type { EncryptedInput } from \"./user-decrypt\";\nimport type { ZamaSDK } from \"../zama-sdk\";\nimport type { MutationFactoryOptions } from \"./factory-types\";\n\nexport interface DelegatedDecryptValuesMutationParams {\n encryptedInputs: EncryptedInput[];\n delegatorAddress: Address;\n}\n\nexport function delegatedDecryptValuesMutationOptions(\n sdk: ZamaSDK,\n): MutationFactoryOptions<\n readonly [\"zama.delegatedDecryptValues\"],\n DelegatedDecryptValuesMutationParams,\n Readonly<Record<EncryptedValue, ClearValue>>\n> {\n return {\n mutationKey: [\"zama.delegatedDecryptValues\"],\n mutationFn: async (params) =>\n sdk.decryption.delegatedDecryptValues(params.encryptedInputs, params.delegatorAddress),\n };\n}\n","import type { ClearValue, EncryptedValue, DecryptPublicValuesResult } from \"../relayer/types\";\nimport type { ZamaSDK } from \"../zama-sdk\";\nimport type { MutationFactoryOptions } from \"./factory-types\";\nimport { zamaQueryKeys } from \"./query-keys\";\n\nexport function decryptPublicValuesMutationOptions(\n sdk: ZamaSDK,\n): MutationFactoryOptions<\n readonly [\"zama.decryptPublicValues\"],\n EncryptedValue[],\n DecryptPublicValuesResult\n> {\n return {\n mutationKey: [\"zama.decryptPublicValues\"],\n mutationFn: async (handles) => sdk.decryption.decryptPublicValues(handles),\n onSuccess: (data, _variables, _onMutateResult, context) => {\n for (const [handle, value] of Object.entries(data.clearValues) as [\n EncryptedValue,\n ClearValue,\n ][]) {\n context.client.setQueryData(zamaQueryKeys.decryption.encryptedValue(handle), value);\n }\n },\n };\n}\n","import type { Address } from \"viem\";\nimport type { ZamaSDK } from \"../zama-sdk\";\nimport type { MutationFactoryOptions } from \"./factory-types\";\n\nexport function grantPermitMutationOptions(\n sdk: ZamaSDK,\n): MutationFactoryOptions<readonly [\"zama.grantPermit\"], Address[], void> {\n return {\n mutationKey: [\"zama.grantPermit\"],\n mutationFn: (contractAddresses) => sdk.permits.grantPermit(contractAddresses),\n };\n}\n","import type { Address } from \"viem\";\nimport type { ZamaSDK } from \"../zama-sdk\";\nimport type { QueryFactoryOptions } from \"./factory-types\";\nimport { zamaQueryKeys } from \"./query-keys\";\nimport type { SignerQueryContext } from \"./signer-query-context\";\nimport { filterQueryOptions } from \"./utils\";\n\nexport interface HasPermitQueryConfig {\n /** Contract addresses to check credentials against. */\n contractAddresses: Address[];\n /**\n * Standard TanStack query options. `hasPermit` intentionally overrides cache\n * timing because permit state is wallet-local, not server state: every fetch\n * should read the SDK credential service directly.\n */\n query?: Record<string, unknown>;\n}\n\nexport function hasPermitQueryOptions(\n sdk: ZamaSDK,\n config: HasPermitQueryConfig,\n signerContext: SignerQueryContext = {},\n): QueryFactoryOptions<boolean, Error, boolean, ReturnType<typeof zamaQueryKeys.hasPermit.scope>> {\n const callerEnabled = config.query?.enabled !== false;\n return {\n ...filterQueryOptions(config?.query ?? {}),\n queryKey: zamaQueryKeys.hasPermit.scope(config.contractAddresses, signerContext.walletAccount),\n queryFn: (context) => {\n const [, { contractAddresses }] = context.queryKey;\n return sdk.permits.hasPermit(contractAddresses as Address[]);\n },\n staleTime: 0,\n gcTime: 0,\n refetchOnMount: \"always\",\n refetchOnWindowFocus: false,\n enabled:\n callerEnabled &&\n signerContext.walletAccount !== undefined &&\n config.contractAddresses.length > 0,\n } as const;\n}\n","import type { Address } from \"viem\";\nimport type { ZamaSDK } from \"../zama-sdk\";\nimport type { MutationFactoryOptions } from \"./factory-types\";\n\n/** TanStack Query mutation factory for {@link Permits.revokePermits}. */\nexport function revokePermitsMutationOptions(\n sdk: ZamaSDK,\n): MutationFactoryOptions<readonly [\"zama.revokePermits\"], Address[] | void, void> {\n return {\n mutationKey: [\"zama.revokePermits\"],\n mutationFn: (contracts: Address[] | void) =>\n contracts === undefined ? sdk.permits.revokePermits() : sdk.permits.revokePermits(contracts),\n };\n}\n","import type { ZamaSDK } from \"../zama-sdk\";\nimport type { MutationFactoryOptions } from \"./factory-types\";\n\n/** TanStack Query mutation factory for {@link Permits.clear}. */\nexport function clearCredentialsMutationOptions(\n sdk: ZamaSDK,\n): MutationFactoryOptions<readonly [\"zama.clearCredentials\"], void, void> {\n return { mutationKey: [\"zama.clearCredentials\"], mutationFn: () => sdk.permits.clear() };\n}\n","import type { Address } from \"viem\";\nimport type { TransactionResult } from \"../types\";\nimport type { ZamaSDK } from \"../zama-sdk\";\nimport type { MutationFactoryOptions } from \"./factory-types\";\n\n/** Variables for {@link delegateDecryptionMutationOptions}. */\nexport interface DelegateDecryptionParams {\n delegateAddress: Address;\n expirationDate?: Date;\n}\n\nexport function delegateDecryptionMutationOptions(\n sdk: ZamaSDK,\n contractAddress: Address,\n): MutationFactoryOptions<\n readonly [\"zama.delegateDecryption\", Address],\n DelegateDecryptionParams,\n TransactionResult\n> {\n return {\n mutationKey: [\"zama.delegateDecryption\", contractAddress] as const,\n mutationFn: async ({ delegateAddress, expirationDate }) =>\n sdk.delegations.delegateDecryption({ contractAddress, delegateAddress, expirationDate }),\n };\n}\n","import type { Address } from \"viem\";\nimport type { ClearValue, EncryptedValue } from \"../relayer/types\";\nimport type { ZamaSDK } from \"../zama-sdk\";\nimport type { QueryFactoryOptions } from \"./factory-types\";\nimport { zamaQueryKeys } from \"./query-keys\";\nimport type { SignerQueryContext } from \"./signer-query-context\";\n\nexport interface EncryptedInput {\n encryptedValue: EncryptedValue;\n contractAddress: Address;\n}\n\n/** Decrypted clear values keyed by encrypted handle. */\nexport type DecryptResult = Readonly<Record<EncryptedValue, ClearValue>>;\n\nexport function decryptValuesQueryOptions(\n sdk: ZamaSDK,\n encryptedInputs: EncryptedInput[],\n signerContext: SignerQueryContext = {},\n): QueryFactoryOptions<\n DecryptResult,\n Error,\n DecryptResult,\n ReturnType<typeof zamaQueryKeys.decryption.encryptedInputs>\n> {\n return {\n queryKey: zamaQueryKeys.decryption.encryptedInputs(\n encryptedInputs,\n signerContext.walletAccount,\n ),\n queryFn: (context) => {\n const [, { encryptedInputs: keyedInputs }] = context.queryKey;\n return sdk.decryption.decryptValues(keyedInputs);\n },\n staleTime: Infinity,\n enabled: encryptedInputs.length > 0 && signerContext.walletAccount !== undefined,\n };\n}\n","import type { Address } from \"viem\";\nimport type { Token } from \"../token/token\";\nimport type { MutationFactoryOptions } from \"./factory-types\";\n\n/** Variables for {@link decryptBalanceAsMutationOptions}. */\nexport interface DecryptBalanceAsParams {\n delegatorAddress: Address;\n accountAddress?: Address;\n}\n\nexport function decryptBalanceAsMutationOptions(\n token: Token,\n): MutationFactoryOptions<\n readonly [\"zama.decryptBalanceAs\", Address],\n DecryptBalanceAsParams,\n bigint\n> {\n return {\n mutationKey: [\"zama.decryptBalanceAs\", token.address] as const,\n mutationFn: async ({ delegatorAddress, accountAddress }) =>\n token.decryptBalanceAs({ delegatorAddress, accountAddress }),\n };\n}\n","import { Token, type BatchDecryptAsOptions } from \"../token/token\";\nimport type { Address } from \"viem\";\nimport type { MutationFactoryOptions } from \"./factory-types\";\n\n/** Variables for {@link batchDecryptBalancesAsMutationOptions}. */\nexport type BatchDecryptBalancesAsParams = BatchDecryptAsOptions;\n\nexport function batchDecryptBalancesAsMutationOptions(\n tokens: Token[],\n): MutationFactoryOptions<\n readonly [\"zama.batchDecryptBalancesAs\", ...Address[]],\n BatchDecryptBalancesAsParams,\n Map<Address, bigint>\n> {\n return {\n mutationKey: [\"zama.batchDecryptBalancesAs\", ...tokens.map((t) => t.address)] as const,\n mutationFn: async (params) => Token.batchDecryptBalancesAs(tokens, params),\n };\n}\n","import type { Address } from \"viem\";\nimport type { TransactionResult } from \"../types\";\nimport type { ZamaSDK } from \"../zama-sdk\";\nimport type { MutationFactoryOptions } from \"./factory-types\";\n\n/** Variables for {@link revokeDelegationMutationOptions}. */\nexport interface RevokeDelegationParams {\n delegateAddress: Address;\n}\n\nexport function revokeDelegationMutationOptions(\n sdk: ZamaSDK,\n contractAddress: Address,\n): MutationFactoryOptions<\n readonly [\"zama.revokeDelegation\", Address],\n RevokeDelegationParams,\n TransactionResult\n> {\n return {\n mutationKey: [\"zama.revokeDelegation\", contractAddress] as const,\n mutationFn: async ({ delegateAddress }) =>\n sdk.delegations.revokeDelegation({ contractAddress, delegateAddress }),\n };\n}\n","import type { Address } from \"viem\";\nimport { MAX_UINT64 } from \"../contracts\";\nimport { getDelegationExpiryContract } from \"../contracts/acl\";\nimport type { ZamaSDK } from \"../zama-sdk\";\nimport type { QueryFactoryOptions } from \"./factory-types\";\nimport { filterQueryOptions } from \"./utils\";\nimport { zamaQueryKeys } from \"./query-keys\";\nimport { assertNonNullable } from \"../utils\";\n\nexport interface DelegationStatusData {\n isActive: boolean;\n expiryTimestamp: bigint;\n}\n\nexport interface DelegationStatusQueryConfig {\n contractAddress: Address | undefined;\n delegatorAddress?: Address;\n delegateAddress?: Address;\n query?: Record<string, unknown>;\n}\n\nexport function delegationStatusQueryOptions(\n sdk: ZamaSDK,\n config: DelegationStatusQueryConfig,\n): QueryFactoryOptions<\n DelegationStatusData,\n Error,\n DelegationStatusData,\n ReturnType<typeof zamaQueryKeys.delegationStatus.scope>\n> {\n return {\n ...filterQueryOptions(config.query ?? {}),\n queryKey: zamaQueryKeys.delegationStatus.scope(\n config.contractAddress,\n config.delegatorAddress,\n config.delegateAddress,\n ),\n queryFn: async (context) => {\n const [, { contractAddress, delegatorAddress, delegateAddress }] = context.queryKey;\n assertNonNullable(contractAddress, \"delegationStatusQueryOptions: contractAddress\");\n assertNonNullable(delegatorAddress, \"delegationStatusQueryOptions: delegatorAddress\");\n assertNonNullable(delegateAddress, \"delegationStatusQueryOptions: delegateAddress\");\n const acl = sdk.relayer.chain.aclContractAddress;\n const expiryTimestamp = await sdk.provider.readContract(\n getDelegationExpiryContract(acl, delegatorAddress, delegateAddress, contractAddress),\n );\n // Derive isActive from expiry + chain time to stay consistent\n // with sdk.delegations.isActive() (avoids client-clock skew).\n let isActive: boolean;\n if (expiryTimestamp === 0n) {\n isActive = false;\n } else if (expiryTimestamp === MAX_UINT64) {\n isActive = true;\n } else {\n const now = await sdk.provider.getBlockTimestamp();\n isActive = expiryTimestamp > now;\n }\n return { isActive, expiryTimestamp };\n },\n enabled:\n Boolean(config.contractAddress && config.delegatorAddress && config.delegateAddress) &&\n config.query?.enabled !== false,\n } as const;\n}\n"],"mappings":"qLAEA,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,CA2CA,SAAgB,EACd,EACyC,CACzC,GAAM,CACJ,OAAQ,EACR,UAAW,EACX,QAAS,EACT,OAAQ,EACR,gBAAiB,EACjB,eAAgB,EAChB,qBAAsB,EACtB,mBAAoB,EACpB,MAAO,EACP,WAAY,EACZ,aAAc,EACd,QAAS,EACT,SAAU,EACV,eAAgB,EAChB,YAAa,EACb,qBAAsB,EACtB,gBAAiB,EACjB,kBAAmB,GACnB,aAAc,EACd,KAAM,EACN,MA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F,EAAA,EAAkB,EAAiB,+CAA+C,EAClF,IAAM,EAAM,EAAI,QAAQ,MAAM,mBACxB,EAAkB,MAAM,EAAI,SAAS,aACzCC,EAAAA,EAA4B,EAAK,EAAkB,EAAiB,CAAe,CACrF,EAGI,EASJ,MARA,CAME,EANE,IAAoB,GACX,GACF,IAAoBC,EAAAA,EAClB,GAGA,EAAkB,MADX,EAAI,SAAS,kBAAkB,EAG5C,CAAE,WAAU,iBAAgB,CACrC,EACA,QACE,GAAQ,EAAO,iBAAmB,EAAO,kBAAoB,EAAO,kBACpE,EAAO,OAAO,UAAY,EAC9B,CACF"}
|
package/dist/cjs/relayer.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const e={SigningRejected:`SIGNING_REJECTED`,SigningFailed:`SIGNING_FAILED`,EncryptionFailed:`ENCRYPTION_FAILED`,DecryptionFailed:`DECRYPTION_FAILED`,TransactionReverted:`TRANSACTION_REVERTED`,TransportKeyPairExpired:`KEYPAIR_EXPIRED`,InvalidTransportKeyPair:`INVALID_KEYPAIR`,NoCiphertext:`NO_CIPHERTEXT`,RelayerRequestFailed:`RELAYER_REQUEST_FAILED`,NotEntitled:`NOT_ENTITLED`,RpcRateLimited:`RPC_RATE_LIMITED`,
|
|
1
|
+
const e={SigningRejected:`SIGNING_REJECTED`,SigningFailed:`SIGNING_FAILED`,EncryptionFailed:`ENCRYPTION_FAILED`,DecryptionFailed:`DECRYPTION_FAILED`,TransactionReverted:`TRANSACTION_REVERTED`,TransportKeyPairExpired:`KEYPAIR_EXPIRED`,InvalidTransportKeyPair:`INVALID_KEYPAIR`,NoCiphertext:`NO_CIPHERTEXT`,RelayerRequestFailed:`RELAYER_REQUEST_FAILED`,NotEntitled:`NOT_ENTITLED`,RpcRateLimited:`RPC_RATE_LIMITED`,Configuration:`CONFIGURATION`,DelegationSelfNotAllowed:`DELEGATION_SELF_NOT_ALLOWED`,DelegationCooldown:`DELEGATION_COOLDOWN`,DelegationNotFound:`DELEGATION_NOT_FOUND`,DelegationExpired:`DELEGATION_EXPIRED`,InsufficientConfidentialBalance:`INSUFFICIENT_CONFIDENTIAL_BALANCE`,InsufficientERC20Balance:`INSUFFICIENT_ERC20_BALANCE`,BalanceCheckUnavailable:`BALANCE_CHECK_UNAVAILABLE`,ERC20ReadFailed:`ERC20_READ_FAILED`,DelegationExpiryUnchanged:`DELEGATION_EXPIRY_UNCHANGED`,DelegationDelegateEqualsContract:`DELEGATION_DELEGATE_EQUALS_CONTRACT`,DelegationContractIsSelf:`DELEGATION_CONTRACT_IS_SELF`,AclPaused:`ACL_PAUSED`,DelegationExpirationTooSoon:`DELEGATION_EXPIRATION_TOO_SOON`,DelegationNotPropagated:`DELEGATION_NOT_PROPAGATED`,ChainMismatch:`CHAIN_MISMATCH`,SignerNotConfigured:`SIGNER_NOT_CONFIGURED`,WalletNotConnected:`WALLET_NOT_CONNECTED`,WalletAccountNotReady:`WALLET_ACCOUNT_NOT_READY`};var t=class extends Error{code;constructor(e,t,n){super(t,n),Object.setPrototypeOf(this,new.target.prototype),this.name=`ZamaError`,this.code=e}},n=class extends t{statusCode;retryAfter;retryable;constructor(t,n,r){super(e.RelayerRequestFailed,t,r),this.name=`RelayerRequestFailedError`,this.statusCode=n,this.retryable=r?.retryable??n===429,this.retryAfter=this.retryable?r?.retryAfter:void 0}},r=class extends t{constructor(t,n){super(e.Configuration,t,n),this.name=`ConfigurationError`}};Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return e}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return n}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return t}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return r}});
|
|
2
2
|
//# sourceMappingURL=relayer.cjs.map
|