@zama-fhe/sdk 3.7.0-beta.2 → 3.7.0-beta.3
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/dist/cjs/base-signer.cjs +1 -1
- package/dist/cjs/base-signer.cjs.map +1 -1
- package/dist/cjs/chains/index.cjs +1 -1
- package/dist/cjs/chains.cjs +1 -1
- package/dist/cjs/chains.cjs.map +1 -1
- package/dist/cjs/index.cjs +1 -1
- package/dist/cjs/node/index.cjs +1 -1
- package/dist/esm/{base-signer-DIYZwDnc.d.ts → base-signer-D902THgk.d.ts} +2 -2
- package/dist/esm/base-signer-ws-wq22y.js +2 -0
- package/dist/esm/{base-signer-D5Cwv7yb.js.map → base-signer-ws-wq22y.js.map} +1 -1
- package/dist/esm/chains/index.d.ts +2 -2
- package/dist/esm/chains/index.js +1 -1
- package/dist/esm/{chains-ByyCdrrd.js → chains-iPpnjXql.js} +2 -2
- package/dist/esm/{chains-ByyCdrrd.js.map → chains-iPpnjXql.js.map} +1 -1
- package/dist/esm/cleartext/index.d.ts +2 -2
- package/dist/esm/{cleartext-3HOk1BAg.d.ts → cleartext-B6vrnBzO.d.ts} +2 -2
- package/dist/esm/ethers/index.d.ts +4 -4
- package/dist/esm/ethers/index.js +1 -1
- package/dist/esm/{index-ijgDL4IC.d.ts → index-Cdbp_93f.d.ts} +24 -4
- package/dist/esm/{index-DJYq1rAB.d.ts → index-CnIEp8zv.d.ts} +1521 -1080
- package/dist/esm/{index-BHrjck_q.d.ts → index-CsuDB4UI.d.ts} +4 -4
- package/dist/esm/index.d.ts +99 -8
- package/dist/esm/index.js +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/node/index.d.ts +5 -5
- package/dist/esm/node/index.js +1 -1
- package/dist/esm/node/index.js.map +1 -1
- package/dist/esm/query/index.d.ts +4 -495
- package/dist/esm/{types-Bz5-wHPv.d.ts → types-Crf7ymyj.d.ts} +2 -2
- package/dist/esm/{types-v0_sfkli.d.ts → types-CuldbZne.d.ts} +3 -3
- package/dist/esm/{types-CI6BtpB7.d.ts → types-DnJSNoEC.d.ts} +3 -3
- package/dist/esm/vaults/index.d.ts +2 -3
- package/dist/esm/viem/index.d.ts +4 -4
- package/dist/esm/viem/index.js +1 -1
- package/dist/esm/web/index.d.ts +1 -1
- package/package.json +1 -1
- package/dist/esm/base-signer-D5Cwv7yb.js +0 -2
- package/dist/esm/invalidation-CJ-pzOUG.d.ts +0 -46
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { a as ZamaConfigBase } from "./types-
|
|
1
|
+
import { f as AtLeastOneChain } from "./index-Cdbp_93f.js";
|
|
2
|
+
import { a as ZamaConfigBase } from "./types-Crf7ymyj.js";
|
|
3
3
|
import { EIP1193Provider, PublicClient, WalletClient } from "viem";
|
|
4
4
|
//#region src/viem/types.d.ts
|
|
5
5
|
/** Viem config — pass native viem clients directly. */
|
|
@@ -13,4 +13,4 @@ interface ZamaConfigViem<TChains extends AtLeastOneChain = AtLeastOneChain> exte
|
|
|
13
13
|
}
|
|
14
14
|
//#endregion
|
|
15
15
|
export { ZamaConfigViem as t };
|
|
16
|
-
//# sourceMappingURL=types-
|
|
16
|
+
//# sourceMappingURL=types-DnJSNoEC.d.ts.map
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { Qt as RawLog, cn as EncryptedValue, en as TransactionResult } from "../types-
|
|
2
|
-
import {
|
|
3
|
-
import { t as QueryClientLike } from "../invalidation-CJ-pzOUG.js";
|
|
1
|
+
import { Qt as RawLog, cn as EncryptedValue, en as TransactionResult } from "../types-Crf7ymyj.js";
|
|
2
|
+
import { Tt as WrappedToken, Yt as QueryClientLike, a as ZamaSDK, dn as MutationFactoryOptions, fn as QueryFactoryOptions } from "../index-CnIEp8zv.js";
|
|
4
3
|
import { Address, Hex } from "viem";
|
|
5
4
|
//#region src/vaults/types.d.ts
|
|
6
5
|
/**
|
package/dist/esm/viem/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { $ as SetOperatorSubmittedEvent, $t as TransactionReceipt, A as WalletAccountListener, B as ApproveUnderlyingSubmittedEvent, D as GenericSigner, F as ReadContractReturnType, G as DelegationSubmittedEvent, H as DecryptEndEvent, I as ReadFunctionName, J as EncryptStartEvent, K as EncryptEndEvent, L as WriteContractArgs, M as ContractAbi, N as ReadContractArgs, O as WalletAccount, P as ReadContractConfig, Q as RevokeDelegationSubmittedEvent, Qt as RawLog, R as WriteContractConfig, U as DecryptErrorEvent, V as BaseEvent, W as DecryptStartEvent, X as PermitErrorEvent, Y as FinalizeUnwrapSubmittedEvent, Z as PermitOperation, a as ZamaConfigBase, at as UnshieldPhase1SubmittedEvent, c as GenericStorage, cn as EncryptedValue, ct as UnwrapSubmittedEvent, dt as WrapSubmittedEvent, et as ShieldSubmittedEvent, fn as FhevmRuntimeConfig, ft as ZamaSDKEvent, ht as ZamaSDKEvents, i as ZamaConfig, in as EIP712TypedData, it as TransferSubmittedEvent, j as WalletAccountStore, k as WalletAccountChange, l as GenericProvider, mt as ZamaSDKEventType, n as RelayerConfig, nt as TransactionOperation, ot as UnshieldPhase2StartedEvent, pt as ZamaSDKEventListener, q as EncryptErrorEvent, rt as TransferFromSubmittedEvent, s as GenericLogger, st as UnshieldPhase2SubmittedEvent, tn as ClearValue, tt as TransactionErrorEvent, vt as ShieldPath, z as WriteFunctionName } from "../types-
|
|
3
|
-
import { n as MutableWalletAccountStore, t as BaseSigner } from "../base-signer-
|
|
4
|
-
import { t as ZamaConfigViem } from "../types-
|
|
1
|
+
import { f as AtLeastOneChain, m as FheChainAuth, p as FheChain } from "../index-Cdbp_93f.js";
|
|
2
|
+
import { $ as SetOperatorSubmittedEvent, $t as TransactionReceipt, A as WalletAccountListener, B as ApproveUnderlyingSubmittedEvent, D as GenericSigner, F as ReadContractReturnType, G as DelegationSubmittedEvent, H as DecryptEndEvent, I as ReadFunctionName, J as EncryptStartEvent, K as EncryptEndEvent, L as WriteContractArgs, M as ContractAbi, N as ReadContractArgs, O as WalletAccount, P as ReadContractConfig, Q as RevokeDelegationSubmittedEvent, Qt as RawLog, R as WriteContractConfig, U as DecryptErrorEvent, V as BaseEvent, W as DecryptStartEvent, X as PermitErrorEvent, Y as FinalizeUnwrapSubmittedEvent, Z as PermitOperation, a as ZamaConfigBase, at as UnshieldPhase1SubmittedEvent, c as GenericStorage, cn as EncryptedValue, ct as UnwrapSubmittedEvent, dt as WrapSubmittedEvent, et as ShieldSubmittedEvent, fn as FhevmRuntimeConfig, ft as ZamaSDKEvent, ht as ZamaSDKEvents, i as ZamaConfig, in as EIP712TypedData, it as TransferSubmittedEvent, j as WalletAccountStore, k as WalletAccountChange, l as GenericProvider, mt as ZamaSDKEventType, n as RelayerConfig, nt as TransactionOperation, ot as UnshieldPhase2StartedEvent, pt as ZamaSDKEventListener, q as EncryptErrorEvent, rt as TransferFromSubmittedEvent, s as GenericLogger, st as UnshieldPhase2SubmittedEvent, tn as ClearValue, tt as TransactionErrorEvent, vt as ShieldPath, z as WriteFunctionName } from "../types-Crf7ymyj.js";
|
|
3
|
+
import { n as MutableWalletAccountStore, t as BaseSigner } from "../base-signer-D902THgk.js";
|
|
4
|
+
import { t as ZamaConfigViem } from "../types-DnJSNoEC.js";
|
|
5
5
|
import { Abi, Address, ContractFunctionArgs, ContractFunctionName, ContractFunctionReturnType, EIP1193Provider, Hex, Hex as Hex$1, PublicClient, WalletClient } from "viem";
|
|
6
6
|
//#region src/viem/config.d.ts
|
|
7
7
|
/** Create a {@link ZamaConfig} from viem clients. */
|
package/dist/esm/viem/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{A as e,D as t,E as n,L as r,M as i,O as a,T as o,h as s,s as c,v as l,x as u,z as d}from"../erc165-DbMOt-s6.js";import{i as f,t as p}from"../base-signer-
|
|
1
|
+
import{A as e,D as t,E as n,L as r,M as i,O as a,T as o,h as s,s as c,v as l,x as u,z as d}from"../erc165-DbMOt-s6.js";import{i as f,t as p}from"../base-signer-ws-wq22y.js";import{a as m,i as h,n as g,o as _,r as v,s as y,t as b}from"../wrappers-registry-Cm3JJeqx.js";import{t as x}from"../eip1193-subscribe-CNxVHW6y.js";import{encodeFunctionData as S,getAddress as C,serializeTransaction as w}from"viem";var T=class{#e;constructor(e){this.#e=e.publicClient}async getChainId(){return this.#e.getChainId()}async readContract(e){return this.#e.readContract(e)}async waitForTransactionReceipt(e){return this.#e.waitForTransactionReceipt({hash:e})}async getBlockTimestamp(){return(await this.#e.getBlock()).timestamp}async prepareTransaction(e){let{from:t,calldata:n}=e,r=S({abi:n.abi,functionName:n.functionName,args:n.args}),i=this.#e.getChainId(),a=e.nonce===void 0?this.#e.getTransactionCount({address:t,blockTag:`pending`}):Promise.resolve(e.nonce),o=e.gasLimit===void 0?n.gas??this.#e.estimateGas({account:t,to:n.address,data:r,value:n.value??0n}).catch(e=>{throw new d(`ViemProvider.prepareTransaction: gas estimation reverted for ${n.functionName} on ${n.address}`,{cause:e})}):Promise.resolve(e.gasLimit),s=e.fees??this.#e.estimateFeesPerGas(),[c,l,u,f]=await Promise.all([i,a,o,s]);return w({type:`eip1559`,chainId:c,nonce:l,to:n.address,data:r,value:n.value??0n,gas:u,maxFeePerGas:f.maxFeePerGas,maxPriorityFeePerGas:f.maxPriorityFeePerGas})}};function E(e){let t=(e.primaryType?e.types[e.primaryType]:void 0)??[],n={...e.message};for(let{name:e,type:r}of t)/^uint\d*$/.test(r)&&(n[e]=BigInt(n[e]));return n}function D(e){if(!(!e.account||!e.chain))return{address:C(e.account.address),chainId:e.chain.id}}var O=class extends p{#e;#t;#n;constructor(e){super(D(e.walletClient)),this.#e=e.walletClient,this.#t=e.ethereum,this.#n=this.#i()}#r(e){if(!this.#e.account)throw new r(e);return{walletClient:this.#e,account:this.#e.account}}async signTypedData(e){let{walletClient:t,account:n}=this.#r(`signTypedData`),{EIP712Domain:r,...i}=e.types;return t.signTypedData({account:n,primaryType:e.primaryType,types:i,domain:e.domain,message:E(e)})}async writeContract(e){let{walletClient:t,account:n}=this.#r(`writeContract`);return t.writeContract({chain:t.chain,account:n,...e})}#i(){return this.#t?x({provider:this.#t,getInitialWalletAccount:()=>D(this.#e),onWalletAccountChange:({next:e})=>{this.walletAccount.setSnapshot(e)}}):()=>{}}onDispose(){this.#n()}};function k(e){return f(new O({walletClient:e.walletClient,ethereum:e.ethereum}),new T({publicClient:e.publicClient}),e)}function A(e){if(!e.account)throw TypeError(`WalletClient has no account`);return e.account}function j(e,t,n){return e.readContract(s(t,n))}function M(e,t){return e.readContract(n(t))}function N(e,t,n){return e.readContract(c(t,n))}function P(e,t,n,r,i){return e.writeContract({chain:e.chain,account:A(e),...l(t,n,r,i)})}function F(e,n,r,i,a,o){return e.writeContract({chain:e.chain,account:A(e),...t(n,r,i,a,o)})}function I(e,t,n,r,i){return e.writeContract({chain:e.chain,account:A(e),...a(t,n,r,i)})}function L(e,t,n,r,i){return e.writeContract({chain:e.chain,account:A(e),...u(t,n,r,i)})}function R(e,t,n,r){return e.writeContract({chain:e.chain,account:A(e),...o(t,n,r)})}function z(t,n,r,i){return t.writeContract({chain:t.chain,account:A(t),...e(n,r,i)})}function B(e,t){return e.readContract(h(t))}function V(e,t){return e.readContract(m(t))}function H(e,t,n,r){return e.readContract(_(t,n,r))}function U(e,t,n){return e.readContract(v(t,n))}function W(e,t,n){return e.readContract(b(t,n))}function G(e,t,n){return e.readContract(g(t,n))}function K(e,t,n){return e.readContract(y(t,n))}export{p as BaseSigner,T as ViemProvider,O as ViemSigner,i as ZamaSDKEvents,k as createConfig,j as readConfidentialBalanceOfContract,W as readConfidentialTokenAddressContract,K as readIsConfidentialTokenValidContract,N as readSupportsInterfaceContract,G as readTokenAddressContract,U as readTokenPairContract,B as readTokenPairsContract,V as readTokenPairsLengthContract,H as readTokenPairsSliceContract,M as readUnderlyingTokenContract,P as writeConfidentialTransferContract,L as writeFinalizeUnwrapContract,R as writeSetOperatorContract,F as writeUnwrapContract,I as writeUnwrapFromBalanceContract,z as writeWrapContract};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/dist/esm/web/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { dn as FhevmRelayerOptions, fn as FhevmRuntimeConfig, n as RelayerConfig, pn as RelayerOptions, r as WebRelayerConfig, un as FhevmClientOptions } from "../types-
|
|
1
|
+
import { dn as FhevmRelayerOptions, fn as FhevmRuntimeConfig, n as RelayerConfig, pn as RelayerOptions, r as WebRelayerConfig, un as FhevmClientOptions } from "../types-Crf7ymyj.js";
|
|
2
2
|
import { EIP1193Provider } from "viem";
|
|
3
3
|
import "@fhevm/sdk/chains";
|
|
4
4
|
//#region src/worker/encrypt-worker-client.d.ts
|
package/package.json
CHANGED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{p as e,r as t,t as n}from"./relayer-CVKO9GmQ.js";import{H as r,K as i,L as a,M as o,P as s,W as c,Y as l,d as u,f as d,j as f,m as p,p as m,q as ee}from"./erc165-DbMOt-s6.js";import{r as h}from"./applied-runtime-3fzqBC2V.js";import{a as te,i as ne,n as g,o as _,r as v,s as y,t as b}from"./primitives-Cym-3HKa.js";import{t as x}from"./validation-BRu06AM_.js";import{a as S,i as re,n as C,o as w,r as ie,s as ae,t as T}from"./wrappers-registry-Cm3JJeqx.js";import{a as E,c as oe,l as se,n as ce,o as le,s as ue,u as de}from"./chains-ByyCdrrd.js";import{getAddress as D,toBytes as O,toHex as k,zeroAddress as A}from"viem";import{hasFhevmRuntimeConfig as fe,setFhevmRuntimeConfig as pe}from"@fhevm/sdk/viem";import{z as j}from"zod/mini";var M=class{#e=null;#t=null;#n;#r;#i;constructor(e=`CredentialStore`,t=1,n=`credentials`){this.#n=e,this.#r=t,this.#i=n}#a(){return this.#e?Promise.resolve(this.#e):(this.#t||=new Promise((e,t)=>{let n=indexedDB.open(this.#n,this.#r);n.onupgradeneeded=()=>{let e=n.result;e.objectStoreNames.contains(this.#i)||e.createObjectStore(this.#i,{keyPath:`key`})},n.onsuccess=()=>{this.#e=n.result,this.#t=null,this.#e.onversionchange=()=>{this.#e?.close(),this.#e=null,this.#t=null},this.#e.onclose=()=>{this.#e=null,this.#t=null},e(this.#e)},n.onerror=()=>{this.#e=null,this.#t=null,t(n.error)}}),this.#t)}async#o(e,t){let n=await this.#a();return new Promise((r,i)=>{let a=n.transaction(this.#i,e);a.onabort=()=>i(a.error??Error(`Transaction aborted`));let o=t(a.objectStore(this.#i));e===`readonly`?o.onsuccess=()=>r(o.result):a.oncomplete=()=>r(o.result),o.onerror=()=>i(o.error)})}async get(e){return(await this.#o(`readonly`,t=>t.get(e)))?.value??null}async set(e,t){await this.#o(`readwrite`,n=>n.put({key:e,value:t}))}async delete(e){await this.#o(`readwrite`,t=>t.delete(e))}async clear(){await this.#o(`readwrite`,e=>e.clear())}};const me=new M;var N=class{#e=new Map;async get(e){return this.#e.get(e)??null}async set(e,t){this.#e.set(e,t)}async delete(e){this.#e.delete(e)}};const he=new N;function ge(){return typeof window<`u`?new M(`CredentialStore`):new N}function _e(e=ge(),t=e){return{storage:e,permitStorage:t}}function ve(e,t,r){let i=e.map(e=>e.id),a=[...new Set(i.filter((e,t)=>i.indexOf(e)!==t))];if(a.length>0)throw new n(`Duplicate chain id(s) [${a.join(`, `)}] in the chains array. Each chain id must appear only once. Note: hardhat and anvil are aliases (both use 31337).`);let o=Object.keys(t).map(Number).filter(e=>!i.includes(e));o.length>0&&r.warn(`Relayer entries for chain(s) [${o.join(`, `)}] are ignored: those chains are not in the chains array. Add the chain config to use them, or drop the relayer entries.`);let s=new Map;for(let r of e){let e=t[r.id];if(!e)throw new n(`Chain ${r.id} has no relayer configured. Add a relayer entry: relayers: { [${r.id}]: web() }`);s.set(r.id,{chain:r,relayerConfig:e})}return s}var ye=class{#e;#t;#n;constructor(e,t,r){if(e.length===0)throw new n(`At least one chain is required.`);this.#e=new Map(e.map(e=>[e.id,e])),this.#n=e[0].id;let i=new Map;for(let[n,{relayerConfig:a,chain:o}]of ve(e,t,r))i.set(n,a.createRelayer(o,r));this.#t=i}get chains(){return[...this.#e.values()]}get chain(){let e=this.#e.get(this.#n);if(e===void 0)throw new n(`Chain ${this.#n} is not configured. Add it to the chains array.`);return e}switchChain(e){this.#n=e}dispose(){for(let e of new Set(this.#t.values()))e.dispose?.()}get relayer(){let e=this.#t.get(this.chain.id);if(e===void 0)throw new n(`No relayer configured for chain ${this.#n}. Add it to the relayers object.`);return e}};const P={version:1,info:`zama-sdk-keypair-wrapping-v1`,ivLengthBytes:12,tagLengthBytes:16};function F(e){return new Uint8Array(e)}function I(e){return F(new TextEncoder().encode(JSON.stringify([e.publicKey,e.createdAt,e.expiresAt,e.tkmsVersion??null])))}function be(e){return typeof e==`string`?new TextEncoder().encode(e):F(e)}var xe=class{#e;#t;constructor(e){this.#e=e}async baseKey(){return this.#t??=this.#n(this.#e),this.#t}async#n(e){let t=be(e),n=await crypto.subtle.importKey(`raw`,t,`HKDF`,!1,[`deriveKey`]);return t.fill(0),e instanceof Uint8Array&&e.fill(0),this.#e=void 0,n}};async function L(e,t){let n=await e.baseKey();return crypto.subtle.deriveKey({name:`HKDF`,hash:`SHA-256`,salt:new TextEncoder().encode(t),info:new TextEncoder().encode(P.info)},n,{name:`AES-GCM`,length:256},!1,[`encrypt`,`decrypt`])}async function Se(e,t,n,r){let i=await L(t,n),a=crypto.getRandomValues(new Uint8Array(P.ivLengthBytes)),o=await crypto.subtle.encrypt({name:`AES-GCM`,iv:a,additionalData:I(r)},i,F(O(e)));return{wrappedPrivateKey:k(new Uint8Array(o)),iv:k(a)}}async function Ce(e,t,n,r){let i=await L(t,n),a=await crypto.subtle.decrypt({name:`AES-GCM`,iv:F(O(e.iv)),additionalData:I(r)},i,F(O(e.wrappedPrivateKey)));return k(new Uint8Array(a))}function we(e){return typeof e==`object`&&!!e&&`name`in e&&e.name===`OperationError`}const R=86400;function z(){return Math.floor(Date.now()/1e3)}function B(e){return[...new Set(e.map(b))].sort()}function Te(e){let{chainId:t}=e.domain;return typeof t==`bigint`?{...e,domain:{...e.domain,chainId:t.toString()}}:e}const V=`transportKeyPairTTL must be a positive integer number of seconds`,H=`permitTTL must be a positive integer number of days`,U=`transportKeyPairScope must be a non-empty string`,W=`transportKeyPairDerivationSecret must be a Uint8Array of at least 32 bytes or a string of at least 64 characters (256 bits of entropy): source it from a CSPRNG or secrets manager, not a human-memorable passphrase`,Ee=365*R,De=j.int({error:V}).check(j.positive({error:V}),j.maximum(Ee,`transportKeyPairTTL must not exceed the fhevm ACL maximum of ${Ee}s (365 days)`)),Oe=j.int({error:H}).check(j.positive({error:H}),j.maximum(365,`permitTTL must not exceed the V1 permit maximum of 365 days`)),ke=j.string({error:U}).check(j.minLength(1,U)),Ae=j.union([j.string({error:W}).check(j.minLength(64,W)),j.instanceof(Uint8Array,{error:W}).check(j.refine(e=>e.byteLength>=32,{error:W}))],{error:W}),je=j.object({publicKey:v,privateKey:v,createdAt:y,expiresAt:_,tkmsVersion:j.optional(j.string())}),G=j.object({domain:j.record(j.string(),j.unknown()),primaryType:j.optional(j.string()),types:j.record(j.string(),j.array(j.object({name:j.string(),type:j.string()}))),message:j.record(j.string(),j.unknown())}),K=j.object({version:j.int().check(j.positive()),eip712:G,signature:v,signerAddress:g}),q=j.object({keypairPublicKey:v,contractAddresses:j.array(g).check(j.maxLength(10)),serializedPermit:K,startTimestamp:y,durationDays:te}),Me=j.array(q),Ne=j.array(j.string()),Pe=j.object({version:j.literal(1),eip712:G,signerAddress:g}),Fe=`iv must be a ${P.ivLengthBytes}-byte hex string`,Ie=`wrappedPrivateKey must be a whole number of bytes and at least ${P.tagLengthBytes} bytes (the AES-GCM authentication tag)`;function Le(e){return(e.length-2)/2}const Re=j.object({wrappingVersion:j.literal(P.version,{error:`wrappingVersion must be a wrapping scheme this SDK can read`}),publicKey:v,wrappedPrivateKey:v.check(j.refine(e=>e.length%2==0&&Le(e)>=P.tagLengthBytes,{error:Ie})),iv:v.check(j.refine(e=>Le(e)===P.ivLengthBytes,{error:Fe})),createdAt:y,expiresAt:_,tkmsVersion:j.optional(j.string())});function ze(e){let t={publicKey:e.publicKey,createdAt:e.createdAt,expiresAt:e.expiresAt};return e.tkmsVersion&&(t.tkmsVersion=e.tkmsVersion),t}const J={version:P.version,schema:Re,async encode(e,t,n){let{wrappedPrivateKey:r,iv:i}=await Se(e.privateKey,t,n,ze(e)),a={wrappingVersion:P.version,publicKey:e.publicKey,wrappedPrivateKey:r,iv:i,createdAt:e.createdAt,expiresAt:e.expiresAt};return e.tkmsVersion&&(a.tkmsVersion=e.tkmsVersion),a},async decode(e,t,n){let r=await Ce({wrappedPrivateKey:e.wrappedPrivateKey,iv:e.iv},t,n,ze(e)),i={publicKey:e.publicKey,privateKey:r,createdAt:e.createdAt,expiresAt:e.expiresAt};return e.tkmsVersion&&(i.tkmsVersion=e.tkmsVersion),i}},Be=new Map([[J.version,J]]),Ve=J;function He(e){let t=e;return t.wrappingVersion!==void 0||t.wrappedPrivateKey!==void 0&&t.iv!==void 0}function Ue(e){if(typeof e!=`object`||!e||!He(e)){let t=je.safeParse(e);return t.success?{kind:`plaintext`,keyPair:t.data}:{kind:`unrecognized`}}let t=e.wrappingVersion,n=typeof t==`number`?Be.get(t):void 0;if(n===void 0)return{kind:`unsupported-version`,version:t};let r=n.schema.safeParse(e);if(!r.success)return{kind:`corrupt-wrapped`};let i=r.data;return{kind:`wrapped`,expiresAt:i.expiresAt,decode:(e,t)=>n.decode(i,e,t)}}function We(e,t,n){return Ve.encode(e,t,n)}function Ge(e){return`keypair:${e}`}function Y(e){return`keypair:scope:${e}`}function X(e){return`permits:${e.signerAddress}:${e.chainId}:${e.delegatorAddress}`}function Z(e){return`permits-index:${e}`}function Ke(e){return`scope:${e}`}function qe(e,t){return{"wrapped-without-secret":`Transport key pair for scope "${t}" is wrapped, but this instance has no transportKeyPairDerivationSecret configured. Every instance sharing this scope must use the same transportKeyPairDerivationSecret; once they do, call permits.revokeTransportKeyPair() to rotate the entry.`,"unwrapped-under-secret":`Transport key pair for scope "${t}" is stored unwrapped, but this instance is configured with a transportKeyPairDerivationSecret. A peer instance sharing this scope is running without the secret: configure the same transportKeyPairDerivationSecret everywhere, then call permits.revokeTransportKeyPair() to migrate the scope to a wrapped entry.`,"unwrap-failed":`Transport key pair for scope "${t}" failed to unwrap. This usually means another instance created it with a different transportKeyPairDerivationSecret: every instance sharing this scope must use the same secret. It can also mean the stored entry is corrupted.`,"corrupt-wrapped":`Transport key pair for scope "${t}" is wrapped but structurally invalid: the stored iv or ciphertext is not a shape this wrapping scheme can produce. This usually means the stored entry is corrupted, or instances sharing this scope are running mismatched wrapping-scheme versions.`}[e]}const Je={"unwrapped-under-secret":`unwrapped transport key pair entry found while a transportKeyPairDerivationSecret is configured`,"unwrap-failed":`transport key pair entry failed to unwrap (wrong transportKeyPairDerivationSecret?)`,"corrupt-wrapped":`structurally invalid wrapped transport key pair entry`};function Ye(e,t){let n=typeof e==`number`?`wrappingVersion ${e}`:`no wrappingVersion this build recognizes`;return`Transport key pair ${t===void 0?`for this signer`:`for scope "${t}"`} was written under a wrapping scheme this SDK build cannot read (${n}). The entry is preserved instead of regenerated, since an instance that understands the scheme may still be using it: ${t===void 0?`run a build that supports it, or call permits.clear() to discard the entry deliberately`:`run a build that supports it everywhere, or call permits.revokeTransportKeyPair() to rotate the scope`}.`}var Xe=class{#e;#t;#n;#r;#i;#a;#o=new Map;#s=new Map;constructor(e){this.#e=e.generator,this.#t=e.storage,this.#n=e.ttl,this.#r=e.logger,this.#i=e.scope,this.#a=e.derivationSecret}#c(e){return this.#i===void 0?`signer:${e}`:Ke(this.#i)}#l(e){return this.#i===void 0?Ge(e):Y(this.#i)}async readStored(e){return this.#u(this.#l(e),this.#c(e))}async#u(e,t){let n=await this.#t.get(e);if(n==null)return null;let r=Ue(n);if(r.kind===`unsupported-version`)throw this.#f(e,Ye(r.version,this.#i));if(r.kind===`unrecognized`)return await this.#m(e,`malformed transport key pair entry`),null;let i=this.#a;if(i===void 0)return r.kind===`plaintext`?await this.#p(e,r.keyPair.expiresAt)?null:r.keyPair:this.#d(e,`wrapped-without-secret`);if(r.kind===`plaintext`)return this.#d(e,`unwrapped-under-secret`);if(r.kind===`corrupt-wrapped`)return this.#d(e,`corrupt-wrapped`);if(await this.#p(e,r.expiresAt))return null;try{return await r.decode(i,t)}catch(t){if(!we(t))throw this.#r.error(`transport key pair unwrap failed unexpectedly`,{key:e,error:t}),new c(`Transport key pair unwrap failed unexpectedly.`,{cause:t});return this.#d(e,`unwrap-failed`,t)}}async#d(e,t,n){if(this.#i!==void 0)throw this.#f(e,qe(t,this.#i),n);if(t===`wrapped-without-secret`)throw this.#f(e,`Transport key pair for this signer is wrapped, but this instance has no transportKeyPairDerivationSecret configured. Configure the same transportKeyPairDerivationSecret the entry was written with. To downgrade to plaintext at rest on purpose, discard the stored entry first by calling permits.clear(), then run without the secret.`,n);let r=Je[t];return this.#r.warn(r,{key:e}),await this.#m(e,r),null}#f(e,t,n){return this.#r.error(t,{key:e}),new c(t,{cause:n})}async#p(e,t){return z()<t?!1:(await this.#m(e,`expired transport key pair entry`),!0)}async#m(e,t){this.#r.debug(`discarding transport key pair entry`,{key:e,reason:t}),await f(`delete transport key pair entry`,()=>this.#t.delete(e),this.#r)}async getOrCreate(e,t){return this.#h(this.#l(e),this.#c(e),{strict:t?.strict})}async#h(e,t,n){let r=n?.strict??!1,i=`${e}::${r}`,a=this.#o.get(i);if(a)return a;let o=this.#s.get(e)??0,s=(async()=>{let n=await this.#u(e,t);if(n!==null)return n;let i=await this.#e(),a=z(),s=a+this.#n,u={publicKey:i.publicKey,privateKey:i.privateKey,createdAt:a,expiresAt:s};i.tkmsVersion&&(u.tkmsVersion=i.tkmsVersion);let d=u;if(this.#a!==void 0)try{d=await We(u,this.#a,t)}catch(t){let n=`Failed to wrap the transport private key for at-rest storage.`;throw this.#r.error(n,{key:e,error:t}),new c(n,{cause:t})}if((this.#s.get(e)??0)===o)r?await this.#t.set(e,d):await f(`persist transport key pair`,()=>this.#t.set(e,d),this.#r);else if(r)throw new l(`The transport key pair was rotated while it was being generated, so the freshly generated key pair could not be persisted. Retry.`);return u})().finally(()=>{this.#o.delete(i)});return this.#o.set(i,s),s}async clear(e){let t=Ge(e);await f(`delete transport key pair entry`,()=>this.#t.delete(t),this.#r)}async evict(e){let t=this.#l(e);await f(`evict transport key pair entry`,()=>this.#t.delete(t),this.#r)}async clearScope(){if(this.#i===void 0)return;let e=Y(this.#i);this.#s.set(e,(this.#s.get(e)??0)+1),await this.#t.delete(e)}async warmScope(){this.#i!==void 0&&await this.#h(Y(this.#i),Ke(this.#i),{strict:!0})}};function Ze(e,t){let n=new Set(e.flatMap(e=>e.contractAddresses));return t.filter(e=>!n.has(e))}function Qe(e){let t=[];for(let n=0;n<e.length;n+=10)t.push(e.slice(n,n+10));return t}function $e(e,t,n){return e.filter(e=>e.keypairPublicKey===t&&n<e.startTimestamp+e.durationDays*86400)}function et(e,t){let n=new Set(t);return e.filter(e=>!e.contractAddresses.some(e=>n.has(e)))}function tt(e,t){return[...new Set([...e,...t])].sort()}function nt(e,t,n){let r=new Set(n),i=e.filter(e=>new Set([...e.contractAddresses,...t]).size<=10);if(i.length===0)return null;function a(e){return e.contractAddresses.reduce((e,t)=>e+ +!!r.has(t),0)}let o=Math.max(...i.map(a));return i.filter(e=>a(e)===o).reduce((e,t)=>t.startTimestamp>e.startTimestamp?t:e)}var rt=class{#e;#t;constructor(e){this.#e=e.storage,this.#t=e.logger}async list(e){let t=X(e),n=await this.#e.get(t);if(n==null)return[];let r=Me.safeParse(n);return r.success?r.data:(await this.clearScope(e),[])}async listUsableAndPrune(e,t){let n=await this.list(e),r=$e(n,t,Math.floor(Date.now()/1e3));return r.length!==n.length&&(r.length===0?await this.clearScope(e):await f(`update permit entry`,()=>this.#e.set(X(e),r),this.#t)),r}async append(e,t){if(t.length===0)return;let n=t.map(e=>q.parse(e)),r=await this.list(e);await this.#e.set(X(e),[...r,...n]),await this.#r(e)}async replace(e,t,n){let r=q.parse(n),i=(await this.list(e)).filter(e=>e.serializedPermit.signature!==t);await this.#e.set(X(e),[...i,r]),await this.#r(e)}async deletePermitsTouching(e,t){let n=await this.list(e);if(n.length===0)return;let r=et(n,t);r.length===0?await this.clearScope(e):await this.#e.set(X(e),r)}async clearScope(e){await this.#a(X(e)),await this.#i(e)}async clearAllForSigner(e){let t=Z(e),n=await this.#n(t);await Promise.all(n.map(e=>this.#a(e))),await f(`delete permit index`,()=>this.#e.delete(t),this.#t)}async#n(e){let t=await this.#e.get(e);if(t==null)return[];let n=Ne.safeParse(t);return n.success?n.data:(await f(`delete permit index`,()=>this.#e.delete(e),this.#t),[])}async#r(e){let t=Z(e.signerAddress),n=X(e),r=await this.#n(t);r.includes(n)||await this.#e.set(t,[...r,n])}async#i(e){let t=Z(e.signerAddress),n=X(e),r=await this.#n(t),i=r.filter(e=>e!==n);i.length!==r.length&&(i.length===0?await f(`delete permit index`,()=>this.#e.delete(t),this.#t):await f(`update permit index`,()=>this.#e.set(t,i),this.#t))}async#a(e){await f(`delete permit entry`,()=>this.#e.delete(e),this.#t)}},it=class{#e;#t;#n;#r;#i;#a;#o;#s;#c=new Map;constructor(e){this.#e=new Xe({generator:async()=>{let t=e.router.relayer,n=await t.generateTransportKeyPair();return t.serializeTransportKeyPair({transportKeyPair:n})},storage:e.storage,ttl:e.transportKeyPairTTL,logger:e.logger,scope:e.scope,derivationSecret:e.derivationSecret}),this.#t=new rt({storage:e.permitStorage??e.storage,logger:e.logger}),this.#n=e.router,this.#r=e.signer,this.#i=e.permitTTL,this.#a=e.logger,this.#o=e.emitEvent,this.#s=e.scope}#l(e){if(!this.#r)throw new s(e);return this.#r}#u(e,t){let n=r(t,{operation:e});return this.#o({type:o.PermitError,operation:e,error:n}),n}async grantPermit(e,t){let n=t===void 0?`grantPermit`:`grantDelegationPermit`,r,i,a;try{r=b(this.#l(`grantPermit`).requireWalletAccount(`grantPermit`).address),i=B(e),a=this.#d(r,t)}catch(e){throw this.#u(n,e)}let o=await this.#e.getOrCreate(r);if(i.length===0)return{keypair:o,permissions:[]};let s;try{s=await this.#t.listUsableAndPrune(a,o.publicKey)}catch(e){throw this.#u(n,e)}let c=Ze(s,i);if(c.length>0){let e=nt(s,c,i);if(e!==null){let t=tt(e.contractAddresses,c),n=await this.#f({chunk:t,keypair:o,scope:a});await f(`replace permit`,()=>this.#t.replace(a,e.serializedPermit.signature,n),this.#a),s[s.indexOf(e)]=n}else for(let e of Qe(c)){let t=await this.#f({chunk:e,keypair:o,scope:a});s.push(t),await f(`persist permit`,()=>this.#t.append(a,[t]),this.#a)}}let l=new Set(i);return{keypair:o,permissions:s.filter(e=>e.contractAddresses.some(e=>l.has(e)))}}async preparePermit(e){let t=b(e.signer),r=B(e.contracts);if(r.length===0)throw new n(`preparePermit: request.contracts must not be empty.`);if(r.length>10)throw new n(`preparePermit: request.contracts must not exceed 10 addresses per call (got ${r.length}) — grantPermit chunks automatically, preparePermit does not.`);let i=e.delegator?b(e.delegator):void 0;if(i!==void 0&&i===t)throw new n(`preparePermit: request.delegator must differ from request.signer — self-delegation is not allowed.`);let a=e.durationDays===void 0?this.#i:x(Oe,e.durationDays),o=this.#n.relayer,s=await this.#e.getOrCreate(t,{strict:!0}),c=await o.parseTransportKeyPair(s),l=z();return{version:1,eip712:Te(G.parse(await o.createUnsignedLegacyDecryptionPermitEip712({transportKeyPair:c,contractAddresses:r,startTimestamp:l,durationSeconds:a*R,...i&&{delegatorAddress:i}}))),signerAddress:t}}async registerPermit(e,t){let r;try{r=x(Pe,e)}catch(e){throw this.#u(`registerPermit`,e)}let a=this.#n.relayer,o=this.#n.chain.id,{domain:s,message:c}=r.eip712,u=Number(s.chainId);if(u!==o)throw this.#u(`registerPermit`,new i({preparedChainId:u,activeChainId:o}));let d=Number(c.startTimestamp),p=Number(c.durationDays);if(z()>=d+p*86400)throw this.#u(`registerPermit`,new ee(`registerPermit: the prepared permit's validity window (starting ${d}, ${p}d) has already elapsed — call preparePermit again.`));let m=r.signerAddress,h=await this.#e.readStored(m);if(h===null||h.publicKey!==c.publicKey)throw new l(`registerPermit: the transport key pair changed since preparePermit ran — call preparePermit again to rebind the signature request to the current key pair.`);try{let e=await a.parseTransportKeyPair(h),i=await a.parseSignedDecryptionPermit({serializedPermit:{version:r.version,eip712:r.eip712,signature:t,signerAddress:m},transportKeyPair:e});if(i.version!==1)throw new n(`registerPermit: expected a V1 signed permit, got version ${i.version}.`);let s=x(K,await a.serializeSignedDecryptionPermit({signedPermit:i})),c={keypairPublicKey:h.publicKey,contractAddresses:B(i.eip712.message.contractAddresses),serializedPermit:s,startTimestamp:Number(i.eip712.message.startTimestamp),durationDays:Number(i.eip712.message.durationDays)},l={signerAddress:m,chainId:o,delegatorAddress:b(i.encryptedDataOwnerAddress)};await f(`replace permit`,()=>this.#t.replace(l,s.signature,c),this.#a)}catch(e){throw this.#u(`registerPermit`,e)}}async hasPermit(e,t){if(e.length===0)return!0;let n=this.#r?.walletAccount.getSnapshot();if(!n)return!1;let r=b(n.address),i;try{i=await this.#e.readStored(r)}catch(e){if(!(e instanceof c))throw e;return!1}if(i===null)return!1;let a=this.#d(r,t);return Ze(await this.#t.listUsableAndPrune(a,i.publicKey),B(e)).length===0}async revokePermits(e){let t=b(this.#l(`revokePermits`).requireWalletAccount(`revokePermits`).address);if(e===void 0){await this.#t.clearAllForSigner(t);return}let n=B(e);n.length!==0&&await this.#t.deletePermitsTouching(this.#d(t),n)}#d(e,t){return{signerAddress:e,chainId:this.#n.chain.id,delegatorAddress:t?b(t):e}}async clearCredentials(){let e=b(this.#l(`clearCredentials`).requireWalletAccount(`clearCredentials`).address);await this.#e.clear(e),await this.#t.clearAllForSigner(e)}async revokeTransportKeyPair(e){if(this.#s===void 0)throw new n(`revokeTransportKeyPair() requires a transportKeyPairScope to be configured on this SDK instance — there is no shared key pair to revoke.`);if(e!==this.#s)throw new n(`revokeTransportKeyPair("${e}") does not match the configured scope ("${this.#s}").`);await this.#e.clearScope()}async warmTransportKeyPair(e){await this.#e.getOrCreate(b(e))}async warmTransportKeyPairScope(e){if(this.#s===void 0)throw new n(`warmTransportKeyPairScope() requires a transportKeyPairScope to be configured on this SDK instance — there is no shared key pair to warm.`);if(e!==this.#s)throw new n(`warmTransportKeyPairScope("${e}") does not match the configured scope ("${this.#s}").`);await this.#e.warmScope()}async handleWalletAccountChange(e,t){let n=e?b(e.address):void 0;n!==(t?b(t.address):void 0)&&n&&(await this.#e.clear(n),await this.#t.clearAllForSigner(n))}async#f(n){let{chunk:r,keypair:i,scope:a}=n,o=z(),s=a.delegatorAddress!==a.signerAddress,c=this.#n.relayer;try{let e={transportKeyPair:await c.parseTransportKeyPair(i),contractAddresses:r,startTimestamp:o,durationSeconds:this.#i*R,signerAddress:a.signerAddress,signer:this.#l(`signPermit`)},t=s?await c.signDecryptionPermit({...e,delegatorAddress:a.delegatorAddress}):await c.signDecryptionPermit(e),n=x(K,await c.serializeSignedDecryptionPermit({signedPermit:t}));return{keypairPublicKey:i.publicKey,contractAddresses:r,serializedPermit:n,startTimestamp:o,durationDays:this.#i}}catch(n){let r=s?`grantDelegationPermit`:`grantPermit`;throw!(n instanceof t)&&n instanceof Error&&e(n.message)&&await this.#e.evict(a.signerAddress),this.#u(r,n)}}async evictTransportKeyPair(){let e=this.#r?.walletAccount.getSnapshot();e&&await this.#e.evict(b(e.address))}async recoverPermits(e,t,n){let r=this.#l(`recoverPermits`).requireWalletAccount(`recoverPermits`),i=this.#d(b(r.address),t),a=X(i),o=this.#c.get(a);if(o)return await o,this.grantPermit(e,t);let s=await this.#p(i),c=this.#c.get(a);if(c)return await c,this.grantPermit(e,t);if(s===null)return this.grantPermit(e,t);let l=new Set(n??[]);if(l.size>0&&!s.some(e=>l.has(e.serializedPermit.signature)))return this.grantPermit(e,t);let u=s.filter(e=>!l.has(e.serializedPermit.signature)),d=s.flatMap(e=>e.contractAddresses),f=this.#m(i,d,e,u,t).finally(()=>{this.#c.delete(a)});return this.#c.set(a,f),await f,this.grantPermit(e,t)}async#p(e){try{return await this.#t.list(e)}catch(e){return this.#a.warn(`read permits for recovery failed`,{error:e}),null}}async#m(e,t,n,r,i){await f(`evict revoked permits`,()=>this.#t.clearScope(e),this.#a);try{await this.grantPermit(tt(t,B(n)),i)}catch(t){throw r.length>0&&await f(`restore surviving permits`,async()=>{let t=await this.#t.list(e),n=new Set(t.map(e=>e.serializedPermit.signature)),i=r.filter(e=>!n.has(e.serializedPermit.signature));i.length>0&&await this.#t.append(e,i)},this.#a),t}}},at=class{#e;#t=`[zama-sdk]`;constructor(e){this.#e=e}error(e,t){this.#e?.error(`${this.#t} ${e}`,t)}warn(e,t){this.#e?.warn(`${this.#t} ${e}`,t)}info(e,t){this.#e?.info(`${this.#t} ${e}`,t)}debug(e,t){this.#e?.debug(`${this.#t} ${e}`,t)}warnAlways(e){console.warn(`${this.#t} ${e}`),this.warn(e)}};const ot={[ue.id]:ue.registryAddress,[oe.id]:oe.registryAddress,[de.id]:de.registryAddress,[se.id]:se.registryAddress,[E.id]:E.registryAddress,[le.id]:le.registryAddress,[ce.id]:ce.registryAddress},st=j.record(j.string().check(j.regex(/^\d+$/,`expected numeric chain id key`)),g),ct=ne,Q=300*1e3;var lt=class{provider;#e;#t;#n=new Map;constructor(e){this.provider=e.provider,this.#e=Object.assign({},ot,x(j.optional(st),e.registryAddresses)),this.#t=x(ct,e.registryTTL??86400)*1e3}getAddress(e){return this.#e[e]}#r(e){let t=this.#n.get(e);if(t){if(Date.now()>=t.expiresAt){this.#n.delete(e);return}return t.data}}#i(e,t,n=this.#t){return this.#n.set(e,{data:t,expiresAt:Date.now()+n}),t}refresh(){this.#n.clear()}get ttlMs(){return this.#t}async getRegistryAddress(){let e=await this.provider.getChainId(),t=this.#e[e];if(!t)throw new n(`No wrappers registry address configured for chain ${e}.\nPass a registryAddresses entry for this chain.`);return D(t)}async listPairs(e={}){let t=e.page??1,r=e.pageSize??100,i=e.metadata??!1;if(t<1)throw new n(`page must be >= 1, got ${t}`);if(r<1)throw new n(`pageSize must be >= 1, got ${r}`);let a=await this.getRegistryAddress(),o=`total:${a}`,s=this.#r(o);if(s===void 0){let e=await this.provider.readContract(S(a));s=this.#i(o,Number(e))}let c=BigInt((t-1)*r),l=c+BigInt(r)>BigInt(s)?BigInt(s):c+BigInt(r);if(c>=BigInt(s))return{items:[],total:s,page:t,pageSize:r};let u=`slice:${a}:${c}:${l}`,d=this.#r(u);if(d===void 0){let e=await this.provider.readContract(w(a,c,l));d=this.#i(u,[...e])}if(!i)return{items:d,total:s,page:t,pageSize:r};let f=`metadata:${a}:${c}:${l}`,p=this.#r(f);if(p===void 0){let e=await Promise.allSettled(d.map(e=>this.#a(e))),t=e.some(e=>e.status===`rejected`),n=e.map((e,t)=>e.status===`fulfilled`?e.value:Object.assign({},d[t],{metadataFailed:!0,underlying:{name:`Unknown`,symbol:`???`,decimals:0,totalSupply:0n},confidential:{name:`Unknown`,symbol:`???`,decimals:0}}));p=this.#i(f,n,t?Q:void 0)}return{items:p,total:s,page:t,pageSize:r}}async#a(e){let[t,n,r,i,a,o,s]=await Promise.all([this.provider.readContract(m(e.tokenAddress)),this.provider.readContract(p(e.tokenAddress)),this.provider.readContract(u(e.tokenAddress)),this.provider.readContract(d(e.tokenAddress)),this.provider.readContract(m(e.confidentialTokenAddress)),this.provider.readContract(p(e.confidentialTokenAddress)),this.provider.readContract(u(e.confidentialTokenAddress))]);return{...e,underlying:{name:t,symbol:n,decimals:r,totalSupply:i},confidential:{name:a,symbol:o,decimals:s}}}async getConfidentialToken(e){let t=await this.getRegistryAddress(),n=D(e),r=`ct:${t}:${n}`,i=this.#r(r);if(i!==void 0)return i;let[a,o]=await this.provider.readContract(T(t,n));return o===A?this.#i(r,null,Q):this.#i(r,{confidentialTokenAddress:o,isValid:a})}async getUnderlyingToken(e){let t=await this.getRegistryAddress(),n=D(e),r=`ut:${t}:${n}`,i=this.#r(r);if(i!==void 0)return i;let[a,o]=await this.provider.readContract(C(t,n));return o===A?this.#i(r,null,Q):this.#i(r,{tokenAddress:o,isValid:a})}async getTokenPairs(){let e=await this.getRegistryAddress();return this.provider.readContract(re(e))}async getTokenPairsLength(){let e=await this.getRegistryAddress();return this.provider.readContract(S(e))}async getTokenPairsSlice(e,t){let n=await this.getRegistryAddress();return this.provider.readContract(w(n,e,t))}async getTokenPair(e){let t=await this.getRegistryAddress();return this.provider.readContract(ie(t,e))}async getConfidentialTokenAddress(e){let t=await this.getRegistryAddress();return this.provider.readContract(T(t,D(e)))}async getTokenAddress(e){let t=await this.getRegistryAddress();return this.provider.readContract(C(t,D(e)))}async isConfidentialTokenValid(e){let t=await this.getRegistryAddress();return this.provider.readContract(ae(t,D(e)))}};function ut(e,t,n){let r=new at(n.logger),i=n.logger,a={wasmAssetLoadMode:`auto`,moduleVersions:`auto`,logger:{error:(e,t)=>i?.error(e,{cause:t}),warn:e=>i?.warn(e),debug:e=>i?.debug(e)},...n.runtime};if(fe()){let e=`runtime configuration is already set and cannot be changed.`;n.runtime===void 0?r.debug(e):r.warn(e)}else pe(a),h(a);let{storage:o,permitStorage:s}=_e(n.storage,n.permitStorage),c=new ye(n.chains,n.relayers,r);return{chains:n.chains,router:c,provider:t,signer:e,storage:o,permitStorage:s,transportKeyPairTTL:x(De,n.transportKeyPairTTL??2592e3),permitTTL:x(Oe,n.permitTTL??30),transportKeyPairScope:n.transportKeyPairScope===void 0?void 0:x(ke,n.transportKeyPairScope),registryTTL:x(ct,n.registryTTL??86400),logger:r,onEvent:n.onEvent}}function dt(e,t){return e?.address===t?.address&&e?.chainId===t?.chainId}var $=class{#e=new Set;#t;#n;constructor(e){this.#t=e,this.#n=e!==void 0}getSnapshot(){return this.#t}isReady(){return this.#n}setSnapshot(e){this.#n=!0;let t=this.#t;dt(t,e)||(this.#t=e,this.#r({previous:t,next:e}))}subscribe(e){this.#e.add(e);let t=this.#t;return t&&e({previous:void 0,next:t}),()=>{this.#e.delete(e)}}#r(e){for(let t of this.#e)t(e)}};function ft(e){return new $(e)}var pt=class{walletAccount;#e=!1;constructor(e){this.walletAccount=new $(e)}requireWalletAccount(e){let t=this.walletAccount.getSnapshot();if(!t)throw new a(e);return t}dispose(){this.#e||(this.#e=!0,this.onDispose())}[Symbol.dispose](){this.dispose()}onDispose(){}};export{ot as a,Ae as c,he as d,M as f,ut as i,xe as l,$ as n,lt as o,me as p,ft as r,it as s,pt as t,N as u};
|
|
2
|
-
//# sourceMappingURL=base-signer-D5Cwv7yb.js.map
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { Address } from "viem";
|
|
2
|
-
//#region src/query/invalidation.d.ts
|
|
3
|
-
/** Minimal query shape read by the invalidation predicates. */
|
|
4
|
-
interface QueryLike {
|
|
5
|
-
/** The query's cache key. */
|
|
6
|
-
queryKey: readonly unknown[];
|
|
7
|
-
}
|
|
8
|
-
/** Minimal filter shape accepted by the invalidation helpers, matching TanStack Query's `QueryFilters`. */
|
|
9
|
-
interface QueryFilterLike {
|
|
10
|
-
/** Match queries whose key starts with this prefix. */
|
|
11
|
-
queryKey?: readonly unknown[];
|
|
12
|
-
/** Match queries for which this returns `true`. */
|
|
13
|
-
predicate?: (query: QueryLike) => boolean;
|
|
14
|
-
}
|
|
15
|
-
/** Minimal `QueryClient` surface used by the invalidation helpers. */
|
|
16
|
-
interface QueryClientLike {
|
|
17
|
-
/** Mark matching queries stale so they refetch. */
|
|
18
|
-
invalidateQueries(filters: QueryFilterLike): void | Promise<void>;
|
|
19
|
-
/** Remove matching queries from the cache entirely. */
|
|
20
|
-
removeQueries(filters: QueryFilterLike): void;
|
|
21
|
-
}
|
|
22
|
-
/** Invalidates the caches affected by an unwrap: confidential balances, underlying allowance, and pending unshields. */
|
|
23
|
-
declare function invalidateAfterUnwrap(queryClient: QueryClientLike, tokenAddress: Address): void;
|
|
24
|
-
/** Invalidates the caches affected by a wrap: confidential balances and underlying allowance. */
|
|
25
|
-
declare function invalidateAfterWrap(queryClient: QueryClientLike, tokenAddress: Address): void;
|
|
26
|
-
/** Invalidates the confidential balance queries for a token (single-token and batched). */
|
|
27
|
-
declare function invalidateBalanceQueries(queryClient: QueryClientLike, tokenAddress: Address): void;
|
|
28
|
-
/** Invalidates the caches affected by a shield: confidential balances and underlying allowance. */
|
|
29
|
-
declare function invalidateAfterShield(queryClient: QueryClientLike, tokenAddress: Address): void;
|
|
30
|
-
/** Invalidates the caches affected by an unshield request: confidential balances, underlying allowance, and pending unshields. */
|
|
31
|
-
declare function invalidateAfterUnshield(queryClient: QueryClientLike, tokenAddress: Address): void;
|
|
32
|
-
/** Invalidates the pending-unshield cache once an unshield has settled on-chain. */
|
|
33
|
-
declare function invalidateAfterUnshieldSettled(queryClient: QueryClientLike, tokenAddress: Address): void;
|
|
34
|
-
/** Invalidates the confidential balance caches affected by a transfer. */
|
|
35
|
-
declare function invalidateAfterTransfer(queryClient: QueryClientLike, tokenAddress: Address): void;
|
|
36
|
-
/** Invalidates the underlying-allowance cache after approving the underlying ERC-20. */
|
|
37
|
-
declare function invalidateAfterApproveUnderlying(queryClient: QueryClientLike, tokenAddress: Address): void;
|
|
38
|
-
/** Invalidates the operator-status cache after changing a token operator. */
|
|
39
|
-
declare function invalidateAfterSetOperator(queryClient: QueryClientLike, tokenAddress: Address): void;
|
|
40
|
-
/** Invalidates any wagmi `useBalance`/`readContract` balance queries so ERC-20 balances refresh. */
|
|
41
|
-
declare function invalidateWagmiBalanceQueries(queryClient: QueryClientLike): void;
|
|
42
|
-
/** Clears wallet-local caches (decryption, permits) and invalidates all Zama queries — call on wallet connect/disconnect so a stale entitlement can't leak across accounts. */
|
|
43
|
-
declare function invalidateWalletLifecycleQueries(queryClient: QueryClientLike): void;
|
|
44
|
-
//#endregion
|
|
45
|
-
export { invalidateAfterSetOperator as a, invalidateAfterUnshield as c, invalidateAfterWrap as d, invalidateBalanceQueries as f, invalidateAfterApproveUnderlying as i, invalidateAfterUnshieldSettled as l, invalidateWalletLifecycleQueries as m, QueryFilterLike as n, invalidateAfterShield as o, invalidateWagmiBalanceQueries as p, QueryLike as r, invalidateAfterTransfer as s, QueryClientLike as t, invalidateAfterUnwrap as u };
|
|
46
|
-
//# sourceMappingURL=invalidation-CJ-pzOUG.d.ts.map
|