@zama-fhe/sdk 2.1.0-alpha.4 → 2.1.0

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.
@@ -491,5 +491,5 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=requi
491
491
  };
492
492
  //#endregion
493
493
  })();
494
- `,l=class extends s{constructor(e){super(e,e.logger)}createWorker(){let e=t.z();if(e)return new Worker(e.getURL(`relayer-sdk.worker.js`));let n=URL.createObjectURL(new Blob([c],{type:`application/javascript`}));try{return new Worker(n)}finally{URL.revokeObjectURL(n)}}wireEvents(e){e.onmessage=e=>this.handleResponse(e.data),e.onerror=e=>this.handleWorkerError(e.message),e.onmessageerror=()=>this.handleWorkerMessageError()}postMessage(e,t){e.postMessage(t)}terminateWorker(e){e.terminate()}generateRequestId(){return crypto.randomUUID()}getInitPayload(){return{type:`INIT`,payload:this.config}}async updateCsrf(e){await this.sendRequest(`UPDATE_CSRF`,{csrfToken:e})}};const u=8192,d=300*1e3;function f(e){let t=[];for(let n=0;n<e.length;n+=u)t.push(String.fromCharCode(...e.subarray(n,n+u)));return btoa(t.join(``))}function p(e){let t;try{t=atob(e)}catch{throw Error(`Invalid base64 data (length: ${e.length})`)}if(t.length===0)throw Error(`Decoded artifact is empty`);let n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return n}function m(e){return`fhe:pubkey:${e}`}function h(e,t){return`fhe:params:${e}:${t}`}function g(e){return`fhe:params-index:${e}`}function _(e){t.L(e,`CachedPublicKey`),t.R(e,`publicKeyId`,`CachedPublicKey.publicKeyId`),t.R(e,`publicKey`,`CachedPublicKey.publicKey`)}function v(e){t.L(e,`CachedPublicParams`),t.R(e,`publicParamsId`,`CachedPublicParams.publicParamsId`),t.R(e,`publicParams`,`CachedPublicParams.publicParams`)}var y=class{#e;#t;#n;#r;#i;#a;#o=new Map;#s=null;#c=new Map;#l=null;#u=null;constructor(e){this.#e=e.storage,this.#t=e.chainId,this.#n=e.relayerUrl,this.#r=(e.ttl??86400)*1e3,this.#i=e.logger??console}async getPublicKey(e){if(this.#a!==void 0)return this.#a;if(this.#s)return this.#s;this.#s=this.#d(e);try{return await this.#s}finally{this.#s=null}}async#d(e){let n=m(this.#t);try{let e=await this.#e.get(n);if(e){_(e);let t={publicKeyId:e.publicKeyId,publicKey:p(e.publicKey)};return this.#a=t,t}}catch(e){await this.#g(n),this.#i.warn(`Failed to read public key from persistent storage, falling back to network fetch`,{chainId:this.#t,error:t.B(e).message})}let r=await e();if(r===null)return null;this.#a=r;try{let e={publicKeyId:r.publicKeyId,publicKey:f(r.publicKey),lastValidatedAt:Date.now()};await this.#e.set(n,e)}catch(e){this.#i.warn(`Failed to persist public key to storage`,{chainId:this.#t,error:t.B(e).message})}return r}async getPublicParams(e,t){let n=this.#o.get(e);if(n!==void 0)return n;let r=this.#c.get(e);if(r)return r;let i=this.#f(e,t);this.#c.set(e,i);try{return await i}finally{this.#c.delete(e)}}async#f(e,n){let r=h(this.#t,e);try{let t=await this.#e.get(r);if(t){v(t);let n={publicParamsId:t.publicParamsId,publicParams:p(t.publicParams)};return this.#o.set(e,n),n}}catch(n){await this.#g(r),this.#i.warn(`Failed to read public params from persistent storage, falling back to network fetch`,{chainId:this.#t,bits:e,error:t.B(n).message})}let i=await n();if(i===null)return null;this.#o.set(e,i);try{let n={publicParamsId:i.publicParamsId,publicParams:f(i.publicParams),lastValidatedAt:Date.now()};await this.#e.set(r,n);let a=g(this.#t),o=await this.#e.get(a).catch(e=>(this.#i.warn(`Failed to read params index from storage`,{chainId:this.#t,error:t.B(e).message}),null))??[];o.includes(e)||await this.#e.set(a,[...o,e])}catch(n){this.#i.warn(`Failed to persist public params to storage`,{chainId:this.#t,bits:e,error:t.B(n).message})}return i}async revalidateIfDue(){if(this.#l)return this.#l;this.#l=this.#p();try{return await this.#l}finally{this.#l=null}}async#p(){let e=Date.now();if(this.#u!==null&&e-this.#u<this.#r||!this.#n)return!1;let n=m(this.#t),r=null,i=[];try{let[a,o]=await Promise.all([this.#e.get(n),this.#h()]);if(a)try{_(a),r={...a,lastValidatedAt:a.lastValidatedAt??0}}catch(e){this.#i.warn(`Corrupt public key cache entry detected, deleting`,{chainId:this.#t,error:t.B(e).message}),await this.#g(n)}if(i=o,!r)return!1;if([r,...i.map(e=>e.data)].every(t=>e-t.lastValidatedAt<this.#r))return this.#u=e,!1;let s=await globalThis.fetch(`${this.#n}/keyurl`);if(!s.ok){let t=e-this.#r+d;return this.#i.warn(`Manifest fetch failed during revalidation, retrying in 5 min`,{status:s.status,relayerUrl:this.#n}),await this.#v(n,{...r,lastValidatedAt:t},i.map(e=>({...e,data:{...e.data,lastValidatedAt:t}}))),this.#u=t,!1}let c=await s.json();if(!c||typeof c!=`object`||!(`fhePublicKey`in c)||!c.fhePublicKey?.urls?.length||!(`crs`in c)||typeof c.crs!=`object`){this.#i.error(`Relayer manifest has unexpected shape — check relayer URL and API version`,{relayerUrl:this.#n,manifestKeys:c&&typeof c==`object`?Object.keys(c):[]});let t=e-this.#r+d;return await this.#v(n,{...r,lastValidatedAt:t},i.map(e=>({...e,data:{...e.data,lastValidatedAt:t}}))),this.#u=t,!1}let l=c,u=l.fhePublicKey.urls[0];if(r.artifactUrl&&u&&u!==r.artifactUrl)return await this.#_(n,i),this.#u=null,!0;let f={...r,lastValidatedAt:e};if(u){let e=await this.#m(u,r);if(!e.fresh)return await this.#_(n,i),this.#u=null,!0;f={...f,artifactUrl:u,etag:e.etag,lastModified:e.lastModified}}let p=[];for(let t of i){let r=l.crs[String(t.bits)]?.urls[0];if(t.data.artifactUrl&&r&&r!==t.data.artifactUrl)return await this.#_(n,i),this.#u=null,!0;let a={...t.data,lastValidatedAt:e};if(r){let e=await this.#m(r,t.data);if(!e.fresh)return await this.#_(n,i),this.#u=null,!0;a={...a,artifactUrl:r,etag:e.etag,lastModified:e.lastModified}}p.push({...t,data:a})}return await this.#v(n,f,p),this.#u=e,!1}catch(a){let o=t.B(a),s=a instanceof TypeError||a instanceof ReferenceError||a instanceof RangeError||a instanceof SyntaxError,c=s?`error`:`warn`;this.#i[c](s?`Unexpected error during revalidation (possible bug)`:`Revalidation failed, using cached artifacts (fail-open)`,{chainId:this.#t,relayerUrl:this.#n,error:o.message});let l=e-this.#r+d;try{r&&await this.#v(n,{...r,lastValidatedAt:l},i.map(e=>({...e,data:{...e.data,lastValidatedAt:l}})))}catch(e){this.#i.warn(`Failed to update validation timestamps after revalidation error`,{chainId:this.#t,error:t.B(e).message})}return this.#u=l,!1}}async#m(e,t){let n=!!(t.etag||t.lastModified),r={};t.etag&&(r[`If-None-Match`]=t.etag),t.lastModified&&(r[`If-Modified-Since`]=t.lastModified);let i=await globalThis.fetch(e,{method:`HEAD`,headers:r});if(i.status===405&&(i=await globalThis.fetch(e,{headers:r})),!i.ok&&i.status!==304)throw Error(`Artifact freshness check failed: HEAD ${e} returned ${i.status}`);let a=i.headers.get(`etag`)??void 0,o=i.headers.get(`last-modified`)??void 0;return i.status===304?{fresh:!0,etag:a??t.etag,lastModified:o??t.lastModified}:n?{fresh:!1,etag:a,lastModified:o}:{fresh:!0,etag:a,lastModified:o}}async#h(){let e=g(this.#t),n=await this.#e.get(e).catch(e=>(this.#i.warn(`Failed to read params index, CRS revalidation may be incomplete`,{chainId:this.#t,error:t.B(e).message}),null))??[],r=new Set([...this.#o.keys(),...n]),i=Array.from(r);return(await Promise.all(i.map(async e=>{let n=h(this.#t,e),r;try{r=await this.#e.get(n)}catch(n){return this.#i.warn(`Failed to read cached params entry during revalidation`,{chainId:this.#t,bits:e,error:t.B(n).message}),null}if(!r)return null;try{return v(r),{bits:e,key:n,data:{...r,lastValidatedAt:r.lastValidatedAt??0}}}catch(r){return this.#i.warn(`Corrupt params cache entry detected, deleting`,{chainId:this.#t,bits:e,error:t.B(r).message}),await this.#g(n),null}}))).filter(e=>e!==null)}async#g(e){await this.#e.delete(e).catch(n=>{this.#i.warn(`Failed to delete cache entry`,{chainId:this.#t,key:e,error:t.B(n).message})})}async#_(e,n){let r=g(this.#t);try{await Promise.all([this.#e.delete(e),this.#e.delete(r),...n.map(e=>this.#e.delete(e.key))])}catch(e){this.#i.warn(`Failed to clear stale artifacts from persistent storage`,{chainId:this.#t,error:t.B(e).message})}this.#a=void 0,this.#o.clear()}async#v(e,n,r){let i=[this.#e.set(e,n).catch(e=>{this.#i.warn(`Failed to update public key validation timestamp`,{chainId:this.#t,error:t.B(e).message})}),...r.map(e=>this.#e.set(e.key,e.data).catch(e=>{this.#i.warn(`Failed to update params validation timestamp`,{chainId:this.#t,error:t.B(e).message})}))];await Promise.all(i)}},b=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=()=>{console.warn(`IndexedDB "${this.#n}" closing due to version change from another tab`),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 x=new b;var S=class{#e=null;#t=null;#n=null;#r=!1;#i=null;#a=null;#o=null;#s=`idle`;#c;#l;constructor(e){this.#l=e}get status(){return this.#s}get initError(){return this.#c}#u(e,t){this.#s=e,this.#c=t,this.#l.onStatusChange?.(e,t)}async#d(){let e=await this.#l.getChainId(),{transports:t,security:r,threads:i}=this.#l;if(i!==void 0&&(!Number.isInteger(i)||i<1))throw Error(`Invalid thread count: ${i}. Must be a positive integer.`);return i!==void 0&&globalThis.SharedArrayBuffer===void 0&&this.#l.logger?.warn(`threads option requires SharedArrayBuffer (COOP/COEP headers). Falling back to single-threaded.`),{cdnUrl:`https://cdn.zama.org/relayer-sdk-js/0.4.1/relayer-sdk-js.umd.cjs`,fhevmConfig:Object.assign({},n.t[e],t[e]),csrfToken:r?.getCsrfToken?.()??``,integrity:r?.integrityCheck===!1?void 0:`2bd5401738b74509549bed2029bbbabedd481b10ac260f66e64a4ff3723d6d704180c51e882757c56ca1840491e90e33`,logger:this.#l.logger,thread:i}}async#f(){if(this.#n)return this.#n;this.#n=this.#m();try{return await this.#n}finally{this.#n=null}}#p(){this.#e?.terminate(),this.#e=null,this.#t=null,this.#a=null}async#m(){this.#r&&(this.#r=!1,this.#e=null,this.#t=null,this.#i=null);let t=await this.#l.getChainId();if(this.#i!==null&&t!==this.#i&&this.#p(),this.#i=t,this.#o||=this.#l.fheArtifactStorage??new b(`FheArtifactCache`,1,`artifacts`),!this.#a){let e=Object.assign({},n.t[t],this.#l.transports[t]);this.#a=new y({storage:this.#o,chainId:t,relayerUrl:e.relayerUrl,ttl:this.#l.fheArtifactCacheTTL,logger:this.#l.logger})}if(this.#a){let e=!1;try{e=await this.#a.revalidateIfDue()}catch(e){this.#l.logger?.warn(`Artifact revalidation failed, proceeding with potentially stale cache`,{error:e instanceof Error?e.message:String(e)})}e&&(this.#l.logger?.info(`Cached FHE artifacts are stale — reinitializing`),this.#p())}return this.#t||=(this.#u(`initializing`),this.#h().then(e=>(this.#u(`ready`),e)).catch(t=>{this.#t=null;let n=t instanceof e.g?t:new e.c(`Failed to initialize FHE worker`,{cause:t instanceof Error?t:void 0});throw this.#u(`error`,n),n})),this.#t}async#h(){let e=new l(await this.#d());if(await e.initWorker(),this.#r)throw e.terminate(),Error(`RelayerWeb was terminated during initialization`);return this.#e=e,e}terminate(){this.#r=!0,this.#e&&=(this.#e.terminate(),null),this.#t=null,this.#n=null}async#g(){if(this.#e){let e=this.#l.security?.getCsrfToken?.()??``;e&&await this.#e.updateCsrf(e)}}async generateKeypair(){let e=await(await this.#f()).generateKeypair();return{publicKey:e.publicKey,privateKey:e.privateKey}}async createEIP712(e,t,r,i=7){let a=await(await this.#f()).createEIP712({publicKey:e,contractAddresses:t,startTimestamp:r,durationDays:i}),o={name:a.domain.name,version:a.domain.version,chainId:a.domain.chainId,verifyingContract:a.domain.verifyingContract};return{domain:o,types:{EIP712Domain:n.a(o),UserDecryptRequestVerification:a.types.UserDecryptRequestVerification},message:{publicKey:a.message.publicKey,contractAddresses:a.message.contractAddresses,startTimestamp:a.message.startTimestamp,durationDays:a.message.durationDays,extraData:a.message.extraData}}}async encrypt(e){let{values:t,contractAddress:r,userAddress:i}=e;return n.o(async()=>{let e=await this.#f();await this.#g();let n=await e.encrypt({values:t,contractAddress:r,userAddress:i});return{handles:n.handles,inputProof:n.inputProof}})}async userDecrypt(e){return n.o(async()=>{let t=await this.#f();return await this.#g(),(await t.userDecrypt(e)).clearValues})}async publicDecrypt(e){return n.o(async()=>{let t=await this.#f();await this.#g();let n=await t.publicDecrypt(e);return{clearValues:n.clearValues,abiEncodedClearValues:n.abiEncodedClearValues,decryptionProof:n.decryptionProof}})}async createDelegatedUserDecryptEIP712(e,t,n,r,i=7){return(await this.#f()).createDelegatedUserDecryptEIP712({publicKey:e,contractAddresses:t,delegatorAddress:n,startTimestamp:r,durationDays:i})}async delegatedUserDecrypt(e){return n.o(async()=>{let t=await this.#f();return await this.#g(),(await t.delegatedUserDecrypt(e)).clearValues})}async requestZKProofVerification(e){return n.o(async()=>{let t=await this.#f();return await this.#g(),t.requestZKProofVerification(e)})}async getPublicKey(){let e=await this.#f();return this.#a?this.#a.getPublicKey(async()=>(await e.getPublicKey()).result):(await e.getPublicKey()).result}async getPublicParams(e){let t=await this.#f();return this.#a?this.#a.getPublicParams(e,async()=>(await t.getPublicParams(e)).result):(await t.getPublicParams(e)).result}async getAclAddress(){let t=await this.#l.getChainId(),r=Object.assign({},n.t[t],this.#l.transports[t]);if(!r.aclContractAddress)throw new e.n(`No ACL address configured for chain ${t}`);return r.aclContractAddress}},C=class n extends t.g{static ZERO_ADDRESS=`0x0000000000000000000000000000000000000000`;wrapper;#e;#t=null;constructor(e){super(e),this.wrapper=e.wrapper?(0,a.getAddress)(e.wrapper):this.address}async#n(){return this.#e===void 0?(this.#t||=this.signer.readContract(r.l(this.wrapper)).then(e=>(this.#e=e,this.#t=null,e)).catch(e=>{throw this.#t=null,e}),this.#t):this.#e}async confidentialTransfer(n,i,o){let s=(0,a.getAddress)(n),c,l,u=Date.now();try{this.emit({type:t.S.EncryptStart}),{handles:c,inputProof:l}=await this.relayer.encrypt({values:[{value:i,type:`euint64`}],contractAddress:this.address,userAddress:await this.signer.getAddress()}),this.emit({type:t.S.EncryptEnd,durationMs:Date.now()-u}),w(()=>o?.onEncryptComplete?.())}catch(n){throw this.emit({type:t.S.EncryptError,error:t.B(n),durationMs:Date.now()-u}),n instanceof e.g?n:new e.c(`Failed to encrypt transfer amount`,{cause:n instanceof Error?n:void 0})}if(c.length===0)throw new e.c(`Encryption returned no handles`);try{let e=await this.signer.writeContract(r.m(this.address,s,c[0],l));return this.emit({type:t.S.TransferSubmitted,txHash:e}),w(()=>o?.onTransferSubmitted?.(e)),{txHash:e,receipt:await this.signer.waitForTransactionReceipt(e)}}catch(n){throw this.emit({type:t.S.TransactionError,operation:`transfer`,error:t.B(n)}),n instanceof e.g?n:new e.h(`Transfer transaction failed`,{cause:n instanceof Error?n:void 0})}}async confidentialTransferFrom(n,i,o,s){let c=(0,a.getAddress)(n),l=(0,a.getAddress)(i),u,d,f=Date.now();try{this.emit({type:t.S.EncryptStart}),{handles:u,inputProof:d}=await this.relayer.encrypt({values:[{value:o,type:`euint64`}],contractAddress:this.address,userAddress:c}),this.emit({type:t.S.EncryptEnd,durationMs:Date.now()-f}),w(()=>s?.onEncryptComplete?.())}catch(n){throw this.emit({type:t.S.EncryptError,error:t.B(n),durationMs:Date.now()-f}),n instanceof e.g?n:new e.c(`Failed to encrypt transferFrom amount`,{cause:n instanceof Error?n:void 0})}if(u.length===0)throw new e.c(`Encryption returned no handles`);try{let e=await this.signer.writeContract(r.h(this.address,c,l,u[0],d));return this.emit({type:t.S.TransferFromSubmitted,txHash:e}),w(()=>s?.onTransferSubmitted?.(e)),{txHash:e,receipt:await this.signer.waitForTransactionReceipt(e)}}catch(n){throw this.emit({type:t.S.TransactionError,operation:`transferFrom`,error:t.B(n)}),n instanceof e.g?n:new e.h(`TransferFrom transaction failed`,{cause:n instanceof Error?n:void 0})}}async approve(n,i){let o=(0,a.getAddress)(n);try{let e=await this.signer.writeContract(r.x(this.address,o,i));return this.emit({type:t.S.ApproveSubmitted,txHash:e}),{txHash:e,receipt:await this.signer.waitForTransactionReceipt(e)}}catch(n){throw this.emit({type:t.S.TransactionError,operation:`approve`,error:t.B(n)}),n instanceof e.g?n:new e.t(`Operator approval failed`,{cause:n instanceof Error?n:void 0})}}async isApproved(e,t){let n=(0,a.getAddress)(e),i=t?(0,a.getAddress)(t):await this.signer.getAddress();return this.signer.readContract(r.v(this.address,i,n))}async shield(i,o){if(await this.#n()===n.ZERO_ADDRESS)return this.shieldETH(i,i+(o?.fees??0n));let s=o?.approvalStrategy??`exact`;s!==`skip`&&await this.#a(i,s===`max`,o?.callbacks);try{let e=o?.to?(0,a.getAddress)(o.to):await this.signer.getAddress(),n=await this.signer.writeContract(r.u(this.wrapper,e,i));return this.emit({type:t.S.ShieldSubmitted,txHash:n}),w(()=>o?.callbacks?.onShieldSubmitted?.(n)),{txHash:n,receipt:await this.signer.waitForTransactionReceipt(n)}}catch(n){throw this.emit({type:t.S.TransactionError,operation:`shield`,error:t.B(n)}),n instanceof e.g?n:new e.h(`Shield transaction failed`,{cause:n instanceof Error?n:void 0})}}async shieldETH(n,i){try{let e=await this.signer.getAddress(),a=await this.signer.writeContract(r.d(this.wrapper,e,n,i??n));return this.emit({type:t.S.ShieldSubmitted,txHash:a}),{txHash:a,receipt:await this.signer.waitForTransactionReceipt(a)}}catch(n){throw this.emit({type:t.S.TransactionError,operation:`shieldETH`,error:t.B(n)}),n instanceof e.g?n:new e.h(`Shield ETH transaction failed`,{cause:n instanceof Error?n:void 0})}}async unwrap(n){let i=await this.signer.getAddress(),a,o,s=Date.now();try{this.emit({type:t.S.EncryptStart}),{handles:a,inputProof:o}=await this.relayer.encrypt({values:[{value:n,type:`euint64`}],contractAddress:this.wrapper,userAddress:i}),this.emit({type:t.S.EncryptEnd,durationMs:Date.now()-s})}catch(n){throw this.emit({type:t.S.EncryptError,error:t.B(n),durationMs:Date.now()-s}),n instanceof e.g?n:new e.c(`Failed to encrypt unshield amount`,{cause:n instanceof Error?n:void 0})}if(a.length===0)throw new e.c(`Encryption returned no handles`);try{let e=await this.signer.writeContract(r.C(this.address,i,i,a[0],o));return this.emit({type:t.S.UnwrapSubmitted,txHash:e}),{txHash:e,receipt:await this.signer.waitForTransactionReceipt(e)}}catch(n){throw this.emit({type:t.S.TransactionError,operation:`unwrap`,error:t.B(n)}),n instanceof e.g?n:new e.h(`Unshield transaction failed`,{cause:n instanceof Error?n:void 0})}}async unwrapAll(){let n=await this.signer.getAddress(),i=await this.readConfidentialBalanceOf(n);if(this.isZeroHandle(i))throw new e.r(`Cannot unshield: balance is zero`);try{let e=await this.signer.writeContract(r.w(this.address,n,n,i));return this.emit({type:t.S.UnwrapSubmitted,txHash:e}),{txHash:e,receipt:await this.signer.waitForTransactionReceipt(e)}}catch(n){throw this.emit({type:t.S.TransactionError,operation:`unwrap`,error:t.B(n)}),n instanceof e.g?n:new e.h(`Unshield-all transaction failed`,{cause:n instanceof Error?n:void 0})}}async unshield(e,t){let n=crypto.randomUUID(),r=await this.unwrap(e);return w(()=>t?.onUnwrapSubmitted?.(r.txHash)),this.#i(r.txHash,t,n)}async unshieldAll(e){let t=crypto.randomUUID(),n=await this.unwrapAll();return w(()=>e?.onUnwrapSubmitted?.(n.txHash)),this.#i(n.txHash,e,t)}async resumeUnshield(e,t){return this.#i(e,t,crypto.randomUUID())}async finalizeUnwrap(n){let i,o,s=Date.now();try{this.emit({type:t.S.DecryptStart});let r=await this.relayer.publicDecrypt([n]);this.emit({type:t.S.DecryptEnd,durationMs:Date.now()-s}),o=r.decryptionProof;try{i=(0,a.hexToBigInt)(r.abiEncodedClearValues)}catch{throw new e.r(`Cannot parse decrypted value: ${r.abiEncodedClearValues}`)}}catch(n){throw this.emit({type:t.S.DecryptError,error:t.B(n),durationMs:Date.now()-s}),n instanceof e.g?n:new e.r(`Failed to finalize unshield`,{cause:n instanceof Error?n:void 0})}try{let e=await this.signer.writeContract(r.c(this.wrapper,n,i,o));return this.emit({type:t.S.FinalizeUnwrapSubmitted,txHash:e}),{txHash:e,receipt:await this.signer.waitForTransactionReceipt(e)}}catch(n){throw this.emit({type:t.S.TransactionError,operation:`finalizeUnwrap`,error:t.B(n)}),n instanceof e.g?n:new e.h(`Failed to finalize unshield`,{cause:n instanceof Error?n:void 0})}}async approveUnderlying(n){let r=await this.#n(),i=n??2n**256n-1n;try{if(i>0n){let e=await this.signer.getAddress();await this.signer.readContract(t.j(r,e,this.wrapper))>0n&&await this.signer.writeContract(t.M(r,this.wrapper,0n))}let e=await this.signer.writeContract(t.M(r,this.wrapper,i));return this.emit({type:t.S.ApproveUnderlyingSubmitted,txHash:e}),{txHash:e,receipt:await this.signer.waitForTransactionReceipt(e)}}catch(n){throw this.emit({type:t.S.TransactionError,operation:`approveUnderlying`,error:t.B(n)}),n instanceof e.g?n:new e.t(`ERC-20 approval failed`,{cause:n instanceof Error?n:void 0})}}async delegateDecryption({delegateAddress:n,expirationDate:r}){if(r&&r.getTime()<=Date.now())throw new e.n(`Expiration date must be in the future`);let i=await this.getAclAddress(),o=r?BigInt(Math.floor(r.getTime()/1e3)):t.C;try{let e=await this.signer.writeContract(t.w(i,(0,a.getAddress)(n),this.address,o));return this.emit({type:t.S.DelegationSubmitted,txHash:e}),{txHash:e,receipt:await this.signer.waitForTransactionReceipt(e)}}catch(n){throw this.emit({type:t.S.TransactionError,operation:`delegateDecryption`,error:t.B(n)}),n instanceof e.g?n:new e.h(`Delegation transaction failed`,{cause:n instanceof Error?n:void 0})}}async revokeDelegation({delegateAddress:n}){let r=await this.getAclAddress();try{let e=await this.signer.writeContract(t.E(r,(0,a.getAddress)(n),this.address));return this.emit({type:t.S.RevokeDelegationSubmitted,txHash:e}),{txHash:e,receipt:await this.signer.waitForTransactionReceipt(e)}}catch(n){throw this.emit({type:t.S.TransactionError,operation:`revokeDelegation`,error:t.B(n)}),n instanceof e.g?n:new e.h(`Revoke delegation transaction failed`,{cause:n instanceof Error?n:void 0})}}static async batchDelegateDecryption({tokens:e,delegateAddress:t,expirationDate:r}){return n.#r(e,e=>e.delegateDecryption({delegateAddress:t,expirationDate:r}),`Delegation failed`)}static async batchRevokeDelegation({tokens:e,delegateAddress:t}){return n.#r(e,e=>e.revokeDelegation({delegateAddress:t}),`Revoke delegation failed`)}static async#r(t,n,r){let i=new Map,a=await Promise.allSettled(t.map(n));for(let n=0;n<t.length;n++){let o=a[n];if(o.status===`fulfilled`)i.set(t[n].address,o.value);else{let a=o.reason instanceof e.g?o.reason:new e.h(r,{cause:o.reason});i.set(t[n].address,a)}}return i}async#i(n,r,i){this.emit({type:t.S.UnshieldPhase1Submitted,txHash:n,operationId:i});let a;try{a=await this.signer.waitForTransactionReceipt(n)}catch(t){throw t instanceof e.g?t:new e.h(`Failed to get unshield receipt`,{cause:t})}let o=t.m(a.logs);if(!o)throw new e.h(`No UnwrapRequested event found in unshield receipt`);this.emit({type:t.S.UnshieldPhase2Started,operationId:i}),w(()=>r?.onFinalizing?.());let s=await this.finalizeUnwrap(o.encryptedAmount);return this.emit({type:t.S.UnshieldPhase2Submitted,txHash:s.txHash,operationId:i}),w(()=>r?.onFinalizeSubmitted?.(s.txHash)),s}async#a(n,r,i){let a=await this.#n(),o=await this.signer.getAddress(),s=await this.signer.readContract(t.j(a,o,this.wrapper));if(!(s>=n))try{s>0n&&await this.signer.writeContract(t.M(a,this.wrapper,0n));let e=r?2n**256n-1n:n,o=await this.signer.writeContract(t.M(a,this.wrapper,e));this.emit({type:t.S.ApproveUnderlyingSubmitted,txHash:o}),w(()=>i?.onApprovalSubmitted?.(o))}catch(t){throw t instanceof e.g?t:new e.t(`ERC-20 approval failed`,{cause:t instanceof Error?t:void 0})}}};function w(e){try{e()}catch(e){console.warn(`[zama-sdk] Callback threw:`,e)}}var T=class{relayer;signer;storage;sessionStorage;credentials;delegatedCredentials;#e;#t;#n;#r=null;#i=null;constructor(e){this.relayer=e.relayer,this.signer=e.signer,this.storage=e.storage,this.sessionStorage=e.sessionStorage??new t.b,this.#e=e.onEvent??function(){};let n={relayer:this.relayer,signer:this.signer,storage:this.storage,sessionStorage:this.sessionStorage,keypairTTL:(()=>{let t=e.keypairTTL??86400;if(t<=0)throw Error(`keypairTTL must be a positive number (seconds)`);return t})(),sessionTTL:e.sessionTTL??2592e3,onEvent:this.#e};if(this.credentials=new t.y(n),this.delegatedCredentials=new t.v(n),this.#n=this.#a(),this.signer.subscribe){let n=e.signerLifecycleCallbacks,r=(e,n)=>{n().catch(n=>{this.#e?.({type:t.S.TransactionError,operation:e,error:t.B(n),timestamp:Date.now()})})};this.#t=this.signer.subscribe({onDisconnect:()=>{r(`signerDisconnect`,async()=>{await this.#o(),this.#r=null,this.#i=null,n?.onDisconnect?.()})},onAccountChange:e=>{r(`signerAccountChange`,async()=>{await this.#o(),this.#r=(0,a.getAddress)(e);try{this.#i=await this.signer.getChainId()}catch{}n?.onAccountChange?.(e)})},onChainChange:e=>{r(`signerChainChange`,async()=>{await this.#o(),this.#i=e;try{this.#r=await this.signer.getAddress()}catch{}n?.onChainChange?.(e)})}})}}async#a(){try{let e=await this.signer.getAddress(),t=await this.signer.getChainId();this.#r=e,this.#i=t}catch{}}async#o(){if(await this.#n,this.#r===null||this.#i===null)return;let e=await t.y.computeStoreKey(this.#r,this.#i);await this.credentials.revokeByKey(e)}createReadonlyToken(e){return new t.g({relayer:this.relayer,signer:this.signer,storage:this.storage,sessionStorage:this.sessionStorage,credentials:this.credentials,delegatedCredentials:this.delegatedCredentials,address:(0,a.getAddress)(e),onEvent:this.#e})}createToken(e,t){return new C({relayer:this.relayer,signer:this.signer,storage:this.storage,sessionStorage:this.sessionStorage,credentials:this.credentials,delegatedCredentials:this.delegatedCredentials,address:(0,a.getAddress)(e),wrapper:t?(0,a.getAddress)(t):void 0,onEvent:this.#e})}async allow(...e){await this.credentials.allow(...e)}async revoke(...e){await this.credentials.revoke(...e)}async revokeSession(){await this.#n;let e=this.#r??await this.signer.getAddress(),n=this.#i??await this.signer.getChainId(),r=await t.y.computeStoreKey(e,n);await this.credentials.revokeByKey(r)}async isAllowed(){return this.credentials.isAllowed()}dispose(){this.#t?.(),this.#t=void 0}terminate(){this.dispose(),this.relayer.terminate()}},E=class{async get(e){return(await chrome.storage.session.get(e))[e]??null}async set(e,t){await chrome.storage.session.set({[e]:t})}async delete(e){await chrome.storage.session.remove(e)}};const D=new E;function O(e){return`zama:pending-unshield:${e}`}async function k(e,t,n){await e.set(O(t),n)}async function A(e,t){return e.get(O(t))}async function j(e,t){await e.delete(O(t))}exports.ApprovalFailedError=e.t,exports.ChromeSessionStorage=E,exports.ConfigurationError=e.n,exports.CredentialsManager=t.y,exports.DecryptionFailedError=e.r,exports.DelegatedCredentialsManager=t.v,exports.DelegationCooldownError=e.i,exports.DelegationExpiredError=e.a,exports.DelegationNotFoundError=e.o,exports.DelegationSelfNotAllowedError=e.s,exports.ERC7984_INTERFACE_ID=r.t,exports.ERC7984_WRAPPER_INTERFACE_ID=r.n,exports.EncryptionFailedError=e.c,exports.HardhatConfig=n.n,exports.IndexedDBStorage=b,exports.InvalidKeypairError=e.l,exports.KeypairExpiredError=e.u,exports.MainnetConfig=n.r,exports.MemoryStorage=t.b,exports.NoCiphertextError=e.d,exports.ReadonlyToken=t.g,exports.RelayerRequestFailedError=e.f,exports.RelayerWeb=S,exports.SepoliaConfig=n.i,exports.SigningFailedError=e.p,exports.SigningRejectedError=e.m,exports.TOKEN_TOPICS=t.a,exports.Token=C,exports.Topics=t.o,exports.TransactionRevertedError=e.h,exports.ZERO_HANDLE=t._,exports.ZamaError=e.g,exports.ZamaErrorCode=e._,exports.ZamaSDK=T,exports.ZamaSDKEvents=t.S,exports.allowanceContract=t.j,exports.applyDecryptedValues=t.t,exports.approveContract=t.M,exports.balanceOfContract=t.N,exports.chromeSessionStorage=D,exports.clearPendingUnshield=j,exports.confidentialBalanceOfContract=r.f,exports.confidentialBatchTransferContract=i.t,exports.confidentialTotalSupplyContract=r.p,exports.confidentialTransferContract=r.m,exports.confidentialTransferFromContract=r.h,exports.decimalsContract=t.P,exports.decodeConfidentialTransfer=t.s,exports.decodeOnChainEvent=t.c,exports.decodeOnChainEvents=t.l,exports.decodeUnwrapRequested=t.u,exports.decodeUnwrappedFinalized=t.d,exports.decodeUnwrappedStarted=t.f,exports.decodeWrapped=t.p,exports.delegateForUserDecryptionContract=t.w,exports.deploymentCoordinatorContract=r.g,exports.extractEncryptedHandles=t.n,exports.finalizeUnwrapContract=r.c,exports.findUnwrapRequested=t.m,exports.findWrapped=t.h,exports.getBatchTransferFeeContract=t.D,exports.getDelegationExpiryContract=t.T,exports.getFeeRecipientContract=t.O,exports.getUnwrapFeeContract=t.k,exports.getWrapFeeContract=t.A,exports.getWrapperContract=r.o,exports.indexedDBStorage=x,exports.isConfidentialTokenContract=r.r,exports.isConfidentialWrapperContract=r.i,exports.isFinalizeUnwrapOperatorContract=r._,exports.isOperatorContract=r.v,exports.loadPendingUnshield=A,exports.matchZamaError=e.v,exports.memoryStorage=t.x,exports.nameContract=t.F,exports.parseActivityFeed=t.r,exports.rateContract=r.y,exports.revokeDelegationContract=t.E,exports.savePendingUnshield=k,exports.setFinalizeUnwrapOperatorContract=r.b,exports.setOperatorContract=r.x,exports.sortByBlockNumber=t.i,exports.supportsInterfaceContract=r.a,exports.symbolContract=t.I,exports.totalSupplyContract=r.S,exports.underlyingContract=r.l,exports.unwrapContract=r.C,exports.unwrapFromBalanceContract=r.w,exports.wrapContract=r.u,exports.wrapETHContract=r.d,exports.wrapperExistsContract=r.s;
494
+ `,l=class extends s{constructor(e){super(e,e.logger)}createWorker(){let e=t.z();if(e)return new Worker(e.getURL(`relayer-sdk.worker.js`));let n=URL.createObjectURL(new Blob([c],{type:`application/javascript`}));try{return new Worker(n)}finally{URL.revokeObjectURL(n)}}wireEvents(e){e.onmessage=e=>this.handleResponse(e.data),e.onerror=e=>this.handleWorkerError(e.message),e.onmessageerror=()=>this.handleWorkerMessageError()}postMessage(e,t){e.postMessage(t)}terminateWorker(e){e.terminate()}generateRequestId(){return crypto.randomUUID()}getInitPayload(){let{cdnUrl:e,fhevmConfig:t,csrfToken:n,integrity:r,thread:i}=this.config;return{type:`INIT`,payload:{cdnUrl:e,fhevmConfig:t,csrfToken:n,integrity:r,thread:i}}}async updateCsrf(e){await this.sendRequest(`UPDATE_CSRF`,{csrfToken:e})}};const u=8192,d=300*1e3;function f(e){let t=[];for(let n=0;n<e.length;n+=u)t.push(String.fromCharCode(...e.subarray(n,n+u)));return btoa(t.join(``))}function p(e){let t;try{t=atob(e)}catch{throw Error(`Invalid base64 data (length: ${e.length})`)}if(t.length===0)throw Error(`Decoded artifact is empty`);let n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return n}function m(e){return`fhe:pubkey:${e}`}function h(e,t){return`fhe:params:${e}:${t}`}function g(e){return`fhe:params-index:${e}`}function _(e){t.L(e,`CachedPublicKey`),t.R(e,`publicKeyId`,`CachedPublicKey.publicKeyId`),t.R(e,`publicKey`,`CachedPublicKey.publicKey`)}function v(e){t.L(e,`CachedPublicParams`),t.R(e,`publicParamsId`,`CachedPublicParams.publicParamsId`),t.R(e,`publicParams`,`CachedPublicParams.publicParams`)}var y=class{#e;#t;#n;#r;#i;#a;#o=new Map;#s=null;#c=new Map;#l=null;#u=null;constructor(e){this.#e=e.storage,this.#t=e.chainId,this.#n=e.relayerUrl,this.#r=(e.ttl??86400)*1e3,this.#i=e.logger??console}async getPublicKey(e){if(this.#a!==void 0)return this.#a;if(this.#s)return this.#s;this.#s=this.#d(e);try{return await this.#s}finally{this.#s=null}}async#d(e){let n=m(this.#t);try{let e=await this.#e.get(n);if(e){_(e);let t={publicKeyId:e.publicKeyId,publicKey:p(e.publicKey)};return this.#a=t,t}}catch(e){await this.#g(n),this.#i.warn(`Failed to read public key from persistent storage, falling back to network fetch`,{chainId:this.#t,error:t.B(e).message})}let r=await e();if(r===null)return null;this.#a=r;try{let e={publicKeyId:r.publicKeyId,publicKey:f(r.publicKey),lastValidatedAt:Date.now()};await this.#e.set(n,e)}catch(e){this.#i.warn(`Failed to persist public key to storage`,{chainId:this.#t,error:t.B(e).message})}return r}async getPublicParams(e,t){let n=this.#o.get(e);if(n!==void 0)return n;let r=this.#c.get(e);if(r)return r;let i=this.#f(e,t);this.#c.set(e,i);try{return await i}finally{this.#c.delete(e)}}async#f(e,n){let r=h(this.#t,e);try{let t=await this.#e.get(r);if(t){v(t);let n={publicParamsId:t.publicParamsId,publicParams:p(t.publicParams)};return this.#o.set(e,n),n}}catch(n){await this.#g(r),this.#i.warn(`Failed to read public params from persistent storage, falling back to network fetch`,{chainId:this.#t,bits:e,error:t.B(n).message})}let i=await n();if(i===null)return null;this.#o.set(e,i);try{let n={publicParamsId:i.publicParamsId,publicParams:f(i.publicParams),lastValidatedAt:Date.now()};await this.#e.set(r,n);let a=g(this.#t),o=await this.#e.get(a).catch(e=>(this.#i.warn(`Failed to read params index from storage`,{chainId:this.#t,error:t.B(e).message}),null))??[];o.includes(e)||await this.#e.set(a,[...o,e])}catch(n){this.#i.warn(`Failed to persist public params to storage`,{chainId:this.#t,bits:e,error:t.B(n).message})}return i}async revalidateIfDue(){if(this.#l)return this.#l;this.#l=this.#p();try{return await this.#l}finally{this.#l=null}}async#p(){let e=Date.now();if(this.#u!==null&&e-this.#u<this.#r||!this.#n)return!1;let n=m(this.#t),r=null,i=[];try{let[a,o]=await Promise.all([this.#e.get(n),this.#h()]);if(a)try{_(a),r={...a,lastValidatedAt:a.lastValidatedAt??0}}catch(e){this.#i.warn(`Corrupt public key cache entry detected, deleting`,{chainId:this.#t,error:t.B(e).message}),await this.#g(n)}if(i=o,!r)return!1;if([r,...i.map(e=>e.data)].every(t=>e-t.lastValidatedAt<this.#r))return this.#u=e,!1;let s=await globalThis.fetch(`${this.#n}/keyurl`);if(!s.ok){let t=e-this.#r+d;return this.#i.warn(`Manifest fetch failed during revalidation, retrying in 5 min`,{status:s.status,relayerUrl:this.#n}),await this.#v(n,{...r,lastValidatedAt:t},i.map(e=>({...e,data:{...e.data,lastValidatedAt:t}}))),this.#u=t,!1}let c=await s.json();if(!c||typeof c!=`object`||!(`fhePublicKey`in c)||!c.fhePublicKey?.urls?.length||!(`crs`in c)||typeof c.crs!=`object`){this.#i.error(`Relayer manifest has unexpected shape — check relayer URL and API version`,{relayerUrl:this.#n,manifestKeys:c&&typeof c==`object`?Object.keys(c):[]});let t=e-this.#r+d;return await this.#v(n,{...r,lastValidatedAt:t},i.map(e=>({...e,data:{...e.data,lastValidatedAt:t}}))),this.#u=t,!1}let l=c,u=l.fhePublicKey.urls[0];if(r.artifactUrl&&u&&u!==r.artifactUrl)return await this.#_(n,i),this.#u=null,!0;let f={...r,lastValidatedAt:e};if(u){let e=await this.#m(u,r);if(!e.fresh)return await this.#_(n,i),this.#u=null,!0;f={...f,artifactUrl:u,etag:e.etag,lastModified:e.lastModified}}let p=[];for(let t of i){let r=l.crs[String(t.bits)]?.urls[0];if(t.data.artifactUrl&&r&&r!==t.data.artifactUrl)return await this.#_(n,i),this.#u=null,!0;let a={...t.data,lastValidatedAt:e};if(r){let e=await this.#m(r,t.data);if(!e.fresh)return await this.#_(n,i),this.#u=null,!0;a={...a,artifactUrl:r,etag:e.etag,lastModified:e.lastModified}}p.push({...t,data:a})}return await this.#v(n,f,p),this.#u=e,!1}catch(a){let o=t.B(a),s=a instanceof TypeError||a instanceof ReferenceError||a instanceof RangeError||a instanceof SyntaxError,c=s?`error`:`warn`;this.#i[c](s?`Unexpected error during revalidation (possible bug)`:`Revalidation failed, using cached artifacts (fail-open)`,{chainId:this.#t,relayerUrl:this.#n,error:o.message});let l=e-this.#r+d;try{r&&await this.#v(n,{...r,lastValidatedAt:l},i.map(e=>({...e,data:{...e.data,lastValidatedAt:l}})))}catch(e){this.#i.warn(`Failed to update validation timestamps after revalidation error`,{chainId:this.#t,error:t.B(e).message})}return this.#u=l,!1}}async#m(e,t){let n=!!(t.etag||t.lastModified),r={};t.etag&&(r[`If-None-Match`]=t.etag),t.lastModified&&(r[`If-Modified-Since`]=t.lastModified);let i=await globalThis.fetch(e,{method:`HEAD`,headers:r});if(i.status===405&&(i=await globalThis.fetch(e,{headers:r})),!i.ok&&i.status!==304)throw Error(`Artifact freshness check failed: HEAD ${e} returned ${i.status}`);let a=i.headers.get(`etag`)??void 0,o=i.headers.get(`last-modified`)??void 0;return i.status===304?{fresh:!0,etag:a??t.etag,lastModified:o??t.lastModified}:n?{fresh:!1,etag:a,lastModified:o}:{fresh:!0,etag:a,lastModified:o}}async#h(){let e=g(this.#t),n=await this.#e.get(e).catch(e=>(this.#i.warn(`Failed to read params index, CRS revalidation may be incomplete`,{chainId:this.#t,error:t.B(e).message}),null))??[],r=new Set([...this.#o.keys(),...n]),i=Array.from(r);return(await Promise.all(i.map(async e=>{let n=h(this.#t,e),r;try{r=await this.#e.get(n)}catch(n){return this.#i.warn(`Failed to read cached params entry during revalidation`,{chainId:this.#t,bits:e,error:t.B(n).message}),null}if(!r)return null;try{return v(r),{bits:e,key:n,data:{...r,lastValidatedAt:r.lastValidatedAt??0}}}catch(r){return this.#i.warn(`Corrupt params cache entry detected, deleting`,{chainId:this.#t,bits:e,error:t.B(r).message}),await this.#g(n),null}}))).filter(e=>e!==null)}async#g(e){await this.#e.delete(e).catch(n=>{this.#i.warn(`Failed to delete cache entry`,{chainId:this.#t,key:e,error:t.B(n).message})})}async#_(e,n){let r=g(this.#t);try{await Promise.all([this.#e.delete(e),this.#e.delete(r),...n.map(e=>this.#e.delete(e.key))])}catch(e){this.#i.warn(`Failed to clear stale artifacts from persistent storage`,{chainId:this.#t,error:t.B(e).message})}this.#a=void 0,this.#o.clear()}async#v(e,n,r){let i=[this.#e.set(e,n).catch(e=>{this.#i.warn(`Failed to update public key validation timestamp`,{chainId:this.#t,error:t.B(e).message})}),...r.map(e=>this.#e.set(e.key,e.data).catch(e=>{this.#i.warn(`Failed to update params validation timestamp`,{chainId:this.#t,error:t.B(e).message})}))];await Promise.all(i)}},b=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=()=>{console.warn(`IndexedDB "${this.#n}" closing due to version change from another tab`),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 x=new b;var S=class{#e=null;#t=null;#n=null;#r=!1;#i=null;#a=null;#o=null;#s=`idle`;#c;#l;constructor(e){this.#l=e}get status(){return this.#s}get initError(){return this.#c}#u(e,t){this.#s=e,this.#c=t,this.#l.onStatusChange?.(e,t)}async#d(){let e=await this.#l.getChainId(),{transports:t,security:r,threads:i}=this.#l;if(i!==void 0&&(!Number.isInteger(i)||i<1))throw Error(`Invalid thread count: ${i}. Must be a positive integer.`);return i!==void 0&&globalThis.SharedArrayBuffer===void 0&&this.#l.logger?.warn(`threads option requires SharedArrayBuffer (COOP/COEP headers). Falling back to single-threaded.`),{cdnUrl:`https://cdn.zama.org/relayer-sdk-js/0.4.2/relayer-sdk-js.umd.cjs`,fhevmConfig:Object.assign({},n.t[e],t[e]),csrfToken:r?.getCsrfToken?.()??``,integrity:r?.integrityCheck===!1?void 0:`114438b01d518b53a447fa3e8bfbe6e71031cb42ac43219bb9f53488456fdfa4bbc8989628366d436e68f6526c7647eb`,logger:this.#l.logger,thread:i}}async#f(){if(this.#n)return this.#n;this.#n=this.#m();try{return await this.#n}finally{this.#n=null}}#p(){this.#e?.terminate(),this.#e=null,this.#t=null,this.#a=null}async#m(){this.#r&&(this.#r=!1,this.#e=null,this.#t=null,this.#i=null);let t=await this.#l.getChainId();if(this.#i!==null&&t!==this.#i&&this.#p(),this.#i=t,this.#o||=this.#l.fheArtifactStorage??new b(`FheArtifactCache`,1,`artifacts`),!this.#a){let e=Object.assign({},n.t[t],this.#l.transports[t]);this.#a=new y({storage:this.#o,chainId:t,relayerUrl:e.relayerUrl,ttl:this.#l.fheArtifactCacheTTL,logger:this.#l.logger})}if(this.#a){let e=!1;try{e=await this.#a.revalidateIfDue()}catch(e){this.#l.logger?.warn(`Artifact revalidation failed, proceeding with potentially stale cache`,{error:e instanceof Error?e.message:String(e)})}e&&(this.#l.logger?.info(`Cached FHE artifacts are stale — reinitializing`),this.#p())}return this.#t||=(this.#u(`initializing`),this.#h().then(e=>(this.#u(`ready`),e)).catch(t=>{this.#t=null;let n=t instanceof e.g?t:new e.n(`Failed to initialize FHE worker`,{cause:t});throw this.#u(`error`,n),n})),this.#t}async#h(){let e=new l(await this.#d());if(await e.initWorker(),this.#r)throw e.terminate(),Error(`RelayerWeb was terminated during initialization`);return this.#e=e,e}terminate(){this.#r=!0,this.#e&&=(this.#e.terminate(),null),this.#t=null,this.#n=null}async#g(){if(this.#e){let e=this.#l.security?.getCsrfToken?.()??``;e&&await this.#e.updateCsrf(e)}}async generateKeypair(){let e=await(await this.#f()).generateKeypair();return{publicKey:e.publicKey,privateKey:e.privateKey}}async createEIP712(e,t,r,i=7){let a=await(await this.#f()).createEIP712({publicKey:e,contractAddresses:t,startTimestamp:r,durationDays:i}),o={name:a.domain.name,version:a.domain.version,chainId:a.domain.chainId,verifyingContract:a.domain.verifyingContract};return{domain:o,types:{EIP712Domain:n.a(o),UserDecryptRequestVerification:a.types.UserDecryptRequestVerification},message:{publicKey:a.message.publicKey,contractAddresses:a.message.contractAddresses,startTimestamp:a.message.startTimestamp,durationDays:a.message.durationDays,extraData:a.message.extraData}}}async encrypt(e){let{values:t,contractAddress:r,userAddress:i}=e;return n.o(async()=>{let e=await this.#f();await this.#g();let n=await e.encrypt({values:t,contractAddress:r,userAddress:i});return{handles:n.handles,inputProof:n.inputProof}})}async userDecrypt(e){return n.o(async()=>{let t=await this.#f();return await this.#g(),(await t.userDecrypt(e)).clearValues})}async publicDecrypt(e){return n.o(async()=>{let t=await this.#f();await this.#g();let n=await t.publicDecrypt(e);return{clearValues:n.clearValues,abiEncodedClearValues:n.abiEncodedClearValues,decryptionProof:n.decryptionProof}})}async createDelegatedUserDecryptEIP712(e,t,n,r,i=7){return(await this.#f()).createDelegatedUserDecryptEIP712({publicKey:e,contractAddresses:t,delegatorAddress:n,startTimestamp:r,durationDays:i})}async delegatedUserDecrypt(e){return n.o(async()=>{let t=await this.#f();return await this.#g(),(await t.delegatedUserDecrypt(e)).clearValues})}async requestZKProofVerification(e){return n.o(async()=>{let t=await this.#f();return await this.#g(),t.requestZKProofVerification(e)})}async getPublicKey(){let e=await this.#f();return this.#a?this.#a.getPublicKey(async()=>(await e.getPublicKey()).result):(await e.getPublicKey()).result}async getPublicParams(e){let t=await this.#f();return this.#a?this.#a.getPublicParams(e,async()=>(await t.getPublicParams(e)).result):(await t.getPublicParams(e)).result}async getAclAddress(){let t=await this.#l.getChainId(),r=Object.assign({},n.t[t],this.#l.transports[t]);if(!r.aclContractAddress)throw new e.n(`No ACL address configured for chain ${t}`);return r.aclContractAddress}},C=class n extends t.g{static ZERO_ADDRESS=`0x0000000000000000000000000000000000000000`;wrapper;#e;#t=null;constructor(e){super(e),this.wrapper=e.wrapper?(0,a.getAddress)(e.wrapper):this.address}async#n(){return this.#e===void 0?(this.#t||=this.signer.readContract(r.l(this.wrapper)).then(e=>(this.#e=e,this.#t=null,e)).catch(e=>{throw this.#t=null,e}),this.#t):this.#e}async confidentialTransfer(n,i,o){let s=(0,a.getAddress)(n),c,l,u=Date.now();try{this.emit({type:t.S.EncryptStart}),{handles:c,inputProof:l}=await this.relayer.encrypt({values:[{value:i,type:`euint64`}],contractAddress:this.address,userAddress:await this.signer.getAddress()}),this.emit({type:t.S.EncryptEnd,durationMs:Date.now()-u}),w(()=>o?.onEncryptComplete?.())}catch(n){throw this.emit({type:t.S.EncryptError,error:t.B(n),durationMs:Date.now()-u}),n instanceof e.g?n:new e.c(`Failed to encrypt transfer amount`,{cause:n instanceof Error?n:void 0})}if(c.length===0)throw new e.c(`Encryption returned no handles`);try{let e=await this.signer.writeContract(r.m(this.address,s,c[0],l));return this.emit({type:t.S.TransferSubmitted,txHash:e}),w(()=>o?.onTransferSubmitted?.(e)),{txHash:e,receipt:await this.signer.waitForTransactionReceipt(e)}}catch(n){throw this.emit({type:t.S.TransactionError,operation:`transfer`,error:t.B(n)}),n instanceof e.g?n:new e.h(`Transfer transaction failed`,{cause:n instanceof Error?n:void 0})}}async confidentialTransferFrom(n,i,o,s){let c=(0,a.getAddress)(n),l=(0,a.getAddress)(i),u,d,f=Date.now();try{this.emit({type:t.S.EncryptStart}),{handles:u,inputProof:d}=await this.relayer.encrypt({values:[{value:o,type:`euint64`}],contractAddress:this.address,userAddress:c}),this.emit({type:t.S.EncryptEnd,durationMs:Date.now()-f}),w(()=>s?.onEncryptComplete?.())}catch(n){throw this.emit({type:t.S.EncryptError,error:t.B(n),durationMs:Date.now()-f}),n instanceof e.g?n:new e.c(`Failed to encrypt transferFrom amount`,{cause:n instanceof Error?n:void 0})}if(u.length===0)throw new e.c(`Encryption returned no handles`);try{let e=await this.signer.writeContract(r.h(this.address,c,l,u[0],d));return this.emit({type:t.S.TransferFromSubmitted,txHash:e}),w(()=>s?.onTransferSubmitted?.(e)),{txHash:e,receipt:await this.signer.waitForTransactionReceipt(e)}}catch(n){throw this.emit({type:t.S.TransactionError,operation:`transferFrom`,error:t.B(n)}),n instanceof e.g?n:new e.h(`TransferFrom transaction failed`,{cause:n instanceof Error?n:void 0})}}async approve(n,i){let o=(0,a.getAddress)(n);try{let e=await this.signer.writeContract(r.x(this.address,o,i));return this.emit({type:t.S.ApproveSubmitted,txHash:e}),{txHash:e,receipt:await this.signer.waitForTransactionReceipt(e)}}catch(n){throw this.emit({type:t.S.TransactionError,operation:`approve`,error:t.B(n)}),n instanceof e.g?n:new e.t(`Operator approval failed`,{cause:n instanceof Error?n:void 0})}}async isApproved(e,t){let n=(0,a.getAddress)(e),i=t?(0,a.getAddress)(t):await this.signer.getAddress();return this.signer.readContract(r.v(this.address,i,n))}async shield(i,o){if(await this.#n()===n.ZERO_ADDRESS)return this.shieldETH(i,i+(o?.fees??0n));let s=o?.approvalStrategy??`exact`;s!==`skip`&&await this.#a(i,s===`max`,o?.callbacks);try{let e=o?.to?(0,a.getAddress)(o.to):await this.signer.getAddress(),n=await this.signer.writeContract(r.u(this.wrapper,e,i));return this.emit({type:t.S.ShieldSubmitted,txHash:n}),w(()=>o?.callbacks?.onShieldSubmitted?.(n)),{txHash:n,receipt:await this.signer.waitForTransactionReceipt(n)}}catch(n){throw this.emit({type:t.S.TransactionError,operation:`shield`,error:t.B(n)}),n instanceof e.g?n:new e.h(`Shield transaction failed`,{cause:n instanceof Error?n:void 0})}}async shieldETH(n,i){try{let e=await this.signer.getAddress(),a=await this.signer.writeContract(r.d(this.wrapper,e,n,i??n));return this.emit({type:t.S.ShieldSubmitted,txHash:a}),{txHash:a,receipt:await this.signer.waitForTransactionReceipt(a)}}catch(n){throw this.emit({type:t.S.TransactionError,operation:`shieldETH`,error:t.B(n)}),n instanceof e.g?n:new e.h(`Shield ETH transaction failed`,{cause:n instanceof Error?n:void 0})}}async unwrap(n){let i=await this.signer.getAddress(),a,o,s=Date.now();try{this.emit({type:t.S.EncryptStart}),{handles:a,inputProof:o}=await this.relayer.encrypt({values:[{value:n,type:`euint64`}],contractAddress:this.wrapper,userAddress:i}),this.emit({type:t.S.EncryptEnd,durationMs:Date.now()-s})}catch(n){throw this.emit({type:t.S.EncryptError,error:t.B(n),durationMs:Date.now()-s}),n instanceof e.g?n:new e.c(`Failed to encrypt unshield amount`,{cause:n instanceof Error?n:void 0})}if(a.length===0)throw new e.c(`Encryption returned no handles`);try{let e=await this.signer.writeContract(r.C(this.address,i,i,a[0],o));return this.emit({type:t.S.UnwrapSubmitted,txHash:e}),{txHash:e,receipt:await this.signer.waitForTransactionReceipt(e)}}catch(n){throw this.emit({type:t.S.TransactionError,operation:`unwrap`,error:t.B(n)}),n instanceof e.g?n:new e.h(`Unshield transaction failed`,{cause:n instanceof Error?n:void 0})}}async unwrapAll(){let n=await this.signer.getAddress(),i=await this.readConfidentialBalanceOf(n);if(this.isZeroHandle(i))throw new e.r(`Cannot unshield: balance is zero`);try{let e=await this.signer.writeContract(r.w(this.address,n,n,i));return this.emit({type:t.S.UnwrapSubmitted,txHash:e}),{txHash:e,receipt:await this.signer.waitForTransactionReceipt(e)}}catch(n){throw this.emit({type:t.S.TransactionError,operation:`unwrap`,error:t.B(n)}),n instanceof e.g?n:new e.h(`Unshield-all transaction failed`,{cause:n instanceof Error?n:void 0})}}async unshield(e,t){let n=crypto.randomUUID(),r=await this.unwrap(e);return w(()=>t?.onUnwrapSubmitted?.(r.txHash)),this.#i(r.txHash,t,n)}async unshieldAll(e){let t=crypto.randomUUID(),n=await this.unwrapAll();return w(()=>e?.onUnwrapSubmitted?.(n.txHash)),this.#i(n.txHash,e,t)}async resumeUnshield(e,t){return this.#i(e,t,crypto.randomUUID())}async finalizeUnwrap(n){let i,o,s=Date.now();try{this.emit({type:t.S.DecryptStart});let r=await this.relayer.publicDecrypt([n]);this.emit({type:t.S.DecryptEnd,durationMs:Date.now()-s}),o=r.decryptionProof;try{i=(0,a.hexToBigInt)(r.abiEncodedClearValues)}catch{throw new e.r(`Cannot parse decrypted value: ${r.abiEncodedClearValues}`)}}catch(n){throw this.emit({type:t.S.DecryptError,error:t.B(n),durationMs:Date.now()-s}),n instanceof e.g?n:new e.r(`Failed to finalize unshield`,{cause:n instanceof Error?n:void 0})}try{let e=await this.signer.writeContract(r.c(this.wrapper,n,i,o));return this.emit({type:t.S.FinalizeUnwrapSubmitted,txHash:e}),{txHash:e,receipt:await this.signer.waitForTransactionReceipt(e)}}catch(n){throw this.emit({type:t.S.TransactionError,operation:`finalizeUnwrap`,error:t.B(n)}),n instanceof e.g?n:new e.h(`Failed to finalize unshield`,{cause:n instanceof Error?n:void 0})}}async approveUnderlying(n){let r=await this.#n(),i=n??2n**256n-1n;try{if(i>0n){let e=await this.signer.getAddress();await this.signer.readContract(t.j(r,e,this.wrapper))>0n&&await this.signer.writeContract(t.M(r,this.wrapper,0n))}let e=await this.signer.writeContract(t.M(r,this.wrapper,i));return this.emit({type:t.S.ApproveUnderlyingSubmitted,txHash:e}),{txHash:e,receipt:await this.signer.waitForTransactionReceipt(e)}}catch(n){throw this.emit({type:t.S.TransactionError,operation:`approveUnderlying`,error:t.B(n)}),n instanceof e.g?n:new e.t(`ERC-20 approval failed`,{cause:n instanceof Error?n:void 0})}}async delegateDecryption({delegateAddress:n,expirationDate:r}){if(r&&r.getTime()<=Date.now())throw new e.n(`Expiration date must be in the future`);let i=await this.getAclAddress(),o=r?BigInt(Math.floor(r.getTime()/1e3)):t.C;try{let e=await this.signer.writeContract(t.w(i,(0,a.getAddress)(n),this.address,o));return this.emit({type:t.S.DelegationSubmitted,txHash:e}),{txHash:e,receipt:await this.signer.waitForTransactionReceipt(e)}}catch(n){throw this.emit({type:t.S.TransactionError,operation:`delegateDecryption`,error:t.B(n)}),n instanceof e.g?n:new e.h(`Delegation transaction failed`,{cause:n instanceof Error?n:void 0})}}async revokeDelegation({delegateAddress:n}){let r=await this.getAclAddress();try{let e=await this.signer.writeContract(t.E(r,(0,a.getAddress)(n),this.address));return this.emit({type:t.S.RevokeDelegationSubmitted,txHash:e}),{txHash:e,receipt:await this.signer.waitForTransactionReceipt(e)}}catch(n){throw this.emit({type:t.S.TransactionError,operation:`revokeDelegation`,error:t.B(n)}),n instanceof e.g?n:new e.h(`Revoke delegation transaction failed`,{cause:n instanceof Error?n:void 0})}}static async batchDelegateDecryption({tokens:e,delegateAddress:t,expirationDate:r}){return n.#r(e,e=>e.delegateDecryption({delegateAddress:t,expirationDate:r}),`Delegation failed`)}static async batchRevokeDelegation({tokens:e,delegateAddress:t}){return n.#r(e,e=>e.revokeDelegation({delegateAddress:t}),`Revoke delegation failed`)}static async#r(t,n,r){let i=new Map,a=await Promise.allSettled(t.map(n));for(let n=0;n<t.length;n++){let o=a[n];if(o.status===`fulfilled`)i.set(t[n].address,o.value);else{let a=o.reason instanceof e.g?o.reason:new e.h(r,{cause:o.reason});i.set(t[n].address,a)}}return i}async#i(n,r,i){this.emit({type:t.S.UnshieldPhase1Submitted,txHash:n,operationId:i});let a;try{a=await this.signer.waitForTransactionReceipt(n)}catch(t){throw t instanceof e.g?t:new e.h(`Failed to get unshield receipt`,{cause:t})}let o=t.m(a.logs);if(!o)throw new e.h(`No UnwrapRequested event found in unshield receipt`);this.emit({type:t.S.UnshieldPhase2Started,operationId:i}),w(()=>r?.onFinalizing?.());let s=await this.finalizeUnwrap(o.encryptedAmount);return this.emit({type:t.S.UnshieldPhase2Submitted,txHash:s.txHash,operationId:i}),w(()=>r?.onFinalizeSubmitted?.(s.txHash)),s}async#a(n,r,i){let a=await this.#n(),o=await this.signer.getAddress(),s=await this.signer.readContract(t.j(a,o,this.wrapper));if(!(s>=n))try{s>0n&&await this.signer.writeContract(t.M(a,this.wrapper,0n));let e=r?2n**256n-1n:n,o=await this.signer.writeContract(t.M(a,this.wrapper,e));this.emit({type:t.S.ApproveUnderlyingSubmitted,txHash:o}),w(()=>i?.onApprovalSubmitted?.(o))}catch(t){throw t instanceof e.g?t:new e.t(`ERC-20 approval failed`,{cause:t instanceof Error?t:void 0})}}};function w(e){try{e()}catch(e){console.warn(`[zama-sdk] Callback threw:`,e)}}var T=class{relayer;signer;storage;sessionStorage;credentials;delegatedCredentials;#e;#t;#n;#r=null;#i=null;constructor(e){this.relayer=e.relayer,this.signer=e.signer,this.storage=e.storage,this.sessionStorage=e.sessionStorage??new t.b,this.#e=e.onEvent??function(){};let n={relayer:this.relayer,signer:this.signer,storage:this.storage,sessionStorage:this.sessionStorage,keypairTTL:(()=>{let t=e.keypairTTL??86400;if(t<=0)throw Error(`keypairTTL must be a positive number (seconds)`);return t})(),sessionTTL:e.sessionTTL??2592e3,onEvent:this.#e};if(this.credentials=new t.y(n),this.delegatedCredentials=new t.v(n),this.#n=this.#a(),this.signer.subscribe){let n=e.signerLifecycleCallbacks,r=(e,n)=>{n().catch(n=>{this.#e?.({type:t.S.TransactionError,operation:e,error:t.B(n),timestamp:Date.now()})})};this.#t=this.signer.subscribe({onDisconnect:()=>{r(`signerDisconnect`,async()=>{await this.#o(),this.#r=null,this.#i=null,n?.onDisconnect?.()})},onAccountChange:e=>{r(`signerAccountChange`,async()=>{await this.#o(),this.#r=(0,a.getAddress)(e);try{this.#i=await this.signer.getChainId()}catch{}n?.onAccountChange?.(e)})},onChainChange:e=>{r(`signerChainChange`,async()=>{await this.#o(),this.#i=e;try{this.#r=await this.signer.getAddress()}catch{}n?.onChainChange?.(e)})}})}}async#a(){try{let e=await this.signer.getAddress(),t=await this.signer.getChainId();this.#r=e,this.#i=t}catch{}}async#o(){if(await this.#n,this.#r===null||this.#i===null)return;let e=await t.y.computeStoreKey(this.#r,this.#i);await this.credentials.revokeByKey(e)}createReadonlyToken(e){return new t.g({relayer:this.relayer,signer:this.signer,storage:this.storage,sessionStorage:this.sessionStorage,credentials:this.credentials,delegatedCredentials:this.delegatedCredentials,address:(0,a.getAddress)(e),onEvent:this.#e})}createToken(e,t){return new C({relayer:this.relayer,signer:this.signer,storage:this.storage,sessionStorage:this.sessionStorage,credentials:this.credentials,delegatedCredentials:this.delegatedCredentials,address:(0,a.getAddress)(e),wrapper:t?(0,a.getAddress)(t):void 0,onEvent:this.#e})}async allow(...e){await this.credentials.allow(...e)}async revoke(...e){await this.credentials.revoke(...e)}async revokeSession(){await this.#n;let e=this.#r??await this.signer.getAddress(),n=this.#i??await this.signer.getChainId(),r=await t.y.computeStoreKey(e,n);await this.credentials.revokeByKey(r)}async isAllowed(){return this.credentials.isAllowed()}dispose(){this.#t?.(),this.#t=void 0}terminate(){this.dispose(),this.relayer.terminate()}},E=class{async get(e){return(await chrome.storage.session.get(e))[e]??null}async set(e,t){await chrome.storage.session.set({[e]:t})}async delete(e){await chrome.storage.session.remove(e)}};const D=new E;function O(e){return`zama:pending-unshield:${e}`}async function k(e,t,n){await e.set(O(t),n)}async function A(e,t){return e.get(O(t))}async function j(e,t){await e.delete(O(t))}exports.ApprovalFailedError=e.t,exports.ChromeSessionStorage=E,exports.ConfigurationError=e.n,exports.CredentialsManager=t.y,exports.DecryptionFailedError=e.r,exports.DelegatedCredentialsManager=t.v,exports.DelegationCooldownError=e.i,exports.DelegationExpiredError=e.a,exports.DelegationNotFoundError=e.o,exports.DelegationSelfNotAllowedError=e.s,exports.ERC7984_INTERFACE_ID=r.t,exports.ERC7984_WRAPPER_INTERFACE_ID=r.n,exports.EncryptionFailedError=e.c,exports.HardhatConfig=n.n,exports.IndexedDBStorage=b,exports.InvalidKeypairError=e.l,exports.KeypairExpiredError=e.u,exports.MainnetConfig=n.r,exports.MemoryStorage=t.b,exports.NoCiphertextError=e.d,exports.ReadonlyToken=t.g,exports.RelayerRequestFailedError=e.f,exports.RelayerWeb=S,exports.SepoliaConfig=n.i,exports.SigningFailedError=e.p,exports.SigningRejectedError=e.m,exports.TOKEN_TOPICS=t.a,exports.Token=C,exports.Topics=t.o,exports.TransactionRevertedError=e.h,exports.ZERO_HANDLE=t._,exports.ZamaError=e.g,exports.ZamaErrorCode=e._,exports.ZamaSDK=T,exports.ZamaSDKEvents=t.S,exports.allowanceContract=t.j,exports.applyDecryptedValues=t.t,exports.approveContract=t.M,exports.balanceOfContract=t.N,exports.chromeSessionStorage=D,exports.clearPendingUnshield=j,exports.confidentialBalanceOfContract=r.f,exports.confidentialBatchTransferContract=i.t,exports.confidentialTotalSupplyContract=r.p,exports.confidentialTransferContract=r.m,exports.confidentialTransferFromContract=r.h,exports.decimalsContract=t.P,exports.decodeConfidentialTransfer=t.s,exports.decodeOnChainEvent=t.c,exports.decodeOnChainEvents=t.l,exports.decodeUnwrapRequested=t.u,exports.decodeUnwrappedFinalized=t.d,exports.decodeUnwrappedStarted=t.f,exports.decodeWrapped=t.p,exports.delegateForUserDecryptionContract=t.w,exports.deploymentCoordinatorContract=r.g,exports.extractEncryptedHandles=t.n,exports.finalizeUnwrapContract=r.c,exports.findUnwrapRequested=t.m,exports.findWrapped=t.h,exports.getBatchTransferFeeContract=t.D,exports.getDelegationExpiryContract=t.T,exports.getFeeRecipientContract=t.O,exports.getUnwrapFeeContract=t.k,exports.getWrapFeeContract=t.A,exports.getWrapperContract=r.o,exports.indexedDBStorage=x,exports.isConfidentialTokenContract=r.r,exports.isConfidentialWrapperContract=r.i,exports.isFinalizeUnwrapOperatorContract=r._,exports.isOperatorContract=r.v,exports.loadPendingUnshield=A,exports.matchZamaError=e.v,exports.memoryStorage=t.x,exports.nameContract=t.F,exports.parseActivityFeed=t.r,exports.rateContract=r.y,exports.revokeDelegationContract=t.E,exports.savePendingUnshield=k,exports.setFinalizeUnwrapOperatorContract=r.b,exports.setOperatorContract=r.x,exports.sortByBlockNumber=t.i,exports.supportsInterfaceContract=r.a,exports.symbolContract=t.I,exports.totalSupplyContract=r.S,exports.underlyingContract=r.l,exports.unwrapContract=r.C,exports.unwrapFromBalanceContract=r.w,exports.wrapContract=r.u,exports.wrapETHContract=r.d,exports.wrapperExistsContract=r.s;
495
495
  //# sourceMappingURL=index.cjs.map