@zama-fhe/sdk 3.4.0 → 3.5.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- 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-BGEnALwn.js +2 -0
- package/dist/esm/{base-signer-YpkEmlp2.js.map → base-signer-BGEnALwn.js.map} +1 -1
- package/dist/esm/{base-signer-BvL-jMNO.d.ts → base-signer-rvOfr9wl.d.ts} +2 -2
- package/dist/esm/chains/index.d.ts +2 -2
- package/dist/esm/chains/index.js +1 -1
- package/dist/esm/chains-BoqPSzrs.js +2 -0
- package/dist/esm/chains-BoqPSzrs.js.map +1 -0
- package/dist/esm/cleartext/index.d.ts +2 -2
- package/dist/esm/{cleartext-CxlICeUh.d.ts → cleartext-CT4qh3Ra.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-DNofJMCK.d.ts → index-BYF_r0pl.d.ts} +4 -4
- package/dist/esm/{index-S6_V7aAH.d.ts → index-SfbUoPTf.d.ts} +19 -4
- package/dist/esm/{index-DLaQtvYu.d.ts → index-bro9lghR.d.ts} +7 -7
- package/dist/esm/index.d.ts +8 -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 -4
- package/dist/esm/{types-CWPSTRF6.d.ts → types-BiA5rWAw.d.ts} +2 -2
- package/dist/esm/{types-BEz-VgR_.d.ts → types-C24EbhTi.d.ts} +3 -3
- package/dist/esm/{types-Dr7AmEs1.d.ts → types-CPJdosAz.d.ts} +3 -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-YpkEmlp2.js +0 -2
- package/dist/esm/chains-CLv9HEJ_.js +0 -2
- package/dist/esm/chains-CLv9HEJ_.js.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Kt as RelayerOptions, t as CleartextRelayerConfig } from "./types-
|
|
1
|
+
import { Kt as RelayerOptions, t as CleartextRelayerConfig } from "./types-BiA5rWAw.js";
|
|
2
2
|
//#region src/config/cleartext.d.ts
|
|
3
3
|
/**
|
|
4
4
|
* Cleartext relayer — drives the FHE backend in cleartext mode (no FHE infrastructure).
|
|
@@ -15,4 +15,4 @@ import { Kt as RelayerOptions, t as CleartextRelayerConfig } from "./types-CWPST
|
|
|
15
15
|
declare function cleartext(options?: RelayerOptions): CleartextRelayerConfig;
|
|
16
16
|
//#endregion
|
|
17
17
|
export { cleartext as t };
|
|
18
|
-
//# sourceMappingURL=cleartext-
|
|
18
|
+
//# sourceMappingURL=cleartext-CT4qh3Ra.d.ts.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { d as
|
|
2
|
-
import { A as EncryptErrorEvent, B as UnshieldPhase1SubmittedEvent, C as ApproveUnderlyingSubmittedEvent, D as DecryptStartEvent, E as DecryptErrorEvent, F as ShieldSubmittedEvent, G as ZamaSDKEvent, Gt as FhevmRuntimeConfig, H as UnshieldPhase2SubmittedEvent, I as TransactionErrorEvent, J as ZamaSDKEvents, K as ZamaSDKEventListener, L as TransactionOperation, Lt as EIP712TypedData, M as FinalizeUnwrapSubmittedEvent, Mt as TransactionReceipt, N as RevokeDelegationSubmittedEvent, O as DelegationSubmittedEvent, P as SetOperatorSubmittedEvent, Pt as ClearValue, R as TransferFromSubmittedEvent, S as WriteFunctionName, T as DecryptEndEvent, U as UnwrapSubmittedEvent, V as UnshieldPhase2StartedEvent, Vt as EncryptedValue, W as WrapSubmittedEvent, Z as ShieldPath, _ as ReadContractConfig, a as ZamaConfigBase, b as WriteContractArgs, c as GenericStorage, d as WalletAccount, f as WalletAccountChange, g as ReadContractArgs, h as ContractAbi, i as ZamaConfig, j as EncryptStartEvent, jt as RawLog, k as EncryptEndEvent, l as GenericProvider, m as WalletAccountStore, n as RelayerConfig, p as WalletAccountListener, q as ZamaSDKEventType, s as GenericLogger, u as GenericSigner, v as ReadContractReturnType, w as BaseEvent, x as WriteContractConfig, y as ReadFunctionName, z as TransferSubmittedEvent } from "../types-
|
|
3
|
-
import { t as ZamaConfigEthers } from "../types-
|
|
4
|
-
import { n as MutableWalletAccountStore, t as BaseSigner } from "../base-signer-
|
|
1
|
+
import { d as FheChain, f as FheChainAuth, u as AtLeastOneChain } from "../index-SfbUoPTf.js";
|
|
2
|
+
import { A as EncryptErrorEvent, B as UnshieldPhase1SubmittedEvent, C as ApproveUnderlyingSubmittedEvent, D as DecryptStartEvent, E as DecryptErrorEvent, F as ShieldSubmittedEvent, G as ZamaSDKEvent, Gt as FhevmRuntimeConfig, H as UnshieldPhase2SubmittedEvent, I as TransactionErrorEvent, J as ZamaSDKEvents, K as ZamaSDKEventListener, L as TransactionOperation, Lt as EIP712TypedData, M as FinalizeUnwrapSubmittedEvent, Mt as TransactionReceipt, N as RevokeDelegationSubmittedEvent, O as DelegationSubmittedEvent, P as SetOperatorSubmittedEvent, Pt as ClearValue, R as TransferFromSubmittedEvent, S as WriteFunctionName, T as DecryptEndEvent, U as UnwrapSubmittedEvent, V as UnshieldPhase2StartedEvent, Vt as EncryptedValue, W as WrapSubmittedEvent, Z as ShieldPath, _ as ReadContractConfig, a as ZamaConfigBase, b as WriteContractArgs, c as GenericStorage, d as WalletAccount, f as WalletAccountChange, g as ReadContractArgs, h as ContractAbi, i as ZamaConfig, j as EncryptStartEvent, jt as RawLog, k as EncryptEndEvent, l as GenericProvider, m as WalletAccountStore, n as RelayerConfig, p as WalletAccountListener, q as ZamaSDKEventType, s as GenericLogger, u as GenericSigner, v as ReadContractReturnType, w as BaseEvent, x as WriteContractConfig, y as ReadFunctionName, z as TransferSubmittedEvent } from "../types-BiA5rWAw.js";
|
|
3
|
+
import { t as ZamaConfigEthers } from "../types-CPJdosAz.js";
|
|
4
|
+
import { n as MutableWalletAccountStore, t as BaseSigner } from "../base-signer-rvOfr9wl.js";
|
|
5
5
|
import { Abi, Address, ContractFunctionArgs, ContractFunctionName, ContractFunctionReturnType, EIP1193EventMap, EIP1193Events, EIP1193Provider, EIP1193Provider as EIP1193Provider$1, Hex, Hex as Hex$1, ProviderConnectInfo, ProviderMessage, ProviderRpcError } from "viem";
|
|
6
6
|
import { Signer, ethers } from "ethers";
|
|
7
7
|
//#region src/ethers/config.d.ts
|
package/dist/esm/ethers/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{A as e,B as t,D as n,F as r,H as i,I as a,L as o,P as s,R as c,U as l,a as u,c as d,g as f,i as p,l as m,o as h,r as g,s as _,t as v,w as y,z as b}from"../sdk-events-D68bJ5jT.js";import{i as x,t as S}from"../base-signer-
|
|
1
|
+
import{A as e,B as t,D as n,F as r,H as i,I as a,L as o,P as s,R as c,U as l,a as u,c as d,g as f,i as p,l as m,o as h,r as g,s as _,t as v,w as y,z as b}from"../sdk-events-D68bJ5jT.js";import{i as x,t as S}from"../base-signer-BGEnALwn.js";import{t as C}from"../eip1193-subscribe-CNxVHW6y.js";import{ProviderRpcError as w,decodeFunctionResult as T,encodeFunctionData as E,getAddress as D,isHex as O}from"viem";import{BrowserProvider as k,Contract as A}from"ethers";function j(e){return{to:e.address,data:E({abi:e.abi,functionName:e.functionName,args:e.args}),...e.gas===void 0?{}:{gasLimit:e.gas},...e.value===void 0?{}:{value:e.value}}}async function M(e,t){let n=await e.call(j(t));if(!O(n))throw TypeError(`Expected hex string, got: ${n}`);return T({abi:t.abi,functionName:t.functionName,data:n})}async function N(e,t){let n=await e.sendTransaction(j(t));if(!O(n.hash))throw TypeError(`Expected hex string, got: ${n.hash}`);return n.hash}function P(e,t,n){return M(e,y(t,n))}function F(e,t){return M(e,r(t))}function I(e,t,n){return M(e,f(t,n))}function L(e,t,r,i,a){return N(e,n(t,r,i,a))}function R(e,t,n,r,i,o){return N(e,a(t,n,r,i,o))}function z(e,t,n,r,i){return N(e,o(t,n,r,i))}function B(t,n,r,i,a){return N(t,e(n,r,i,a))}function V(e,t,n,r){return N(e,s(t,n,r))}function H(e,t,n,r){return N(e,c(t,n,r))}function U(e,t){return M(e,h(t))}function W(e,t){return M(e,_(t))}function G(e,t,n,r){return M(e,d(t,n,r))}function K(e,t,n){return M(e,u(t,n))}function q(e,t,n){return M(e,g(t,n))}function J(e,t,n){return M(e,p(t,n))}function Y(e,t,n){return M(e,m(t,n))}var X=class{#e;constructor(e){`ethereum`in e?this.#e=new k(e.ethereum):this.#e=e.provider}async getChainId(){let e=await this.#e.getNetwork();return Number(e.chainId)}async readContract(e){return M(this.#e,{address:e.address,abi:e.abi,functionName:e.functionName,args:e.args})}async getBlockTimestamp(){let e=await this.#e.getBlock(`latest`);if(!e)throw Error(`Failed to fetch latest block`);if(e.timestamp===null)throw Error(`Latest block has no timestamp`);return BigInt(e.timestamp)}async waitForTransactionReceipt(e){let t=await this.#e.waitForTransaction(e);if(!t)throw Error(`Transaction receipt not found`);return{logs:t.logs.map(e=>({topics:e.topics.filter(e=>e!==null),data:e.data}))}}},Z=class extends S{#e;#t;#n;#r;#i;constructor(e){super(),`ethereum`in e?(this.#e=new k(e.ethereum),this.#n=e.ethereum,this.#r=C({provider:e.ethereum,getInitialWalletAccount:()=>this.#l(),onWalletAccountChange:({next:e})=>{this.walletAccount.setSnapshot(e)}})):(this.#t=e.signer,this.#r=()=>{},b(`refresh wallet account`,async()=>{await this.refreshWalletAccount()}))}requireWalletAccount(e){let t=this.walletAccount.getSnapshot();if(!t&&!this.walletAccount.isReady())throw new i(e);if(!t)throw new l(e);return t}refreshWalletAccount(){return this.#n?this.#c():this.#t?this.#s(this.#t):Promise.resolve(void 0)}onDispose(){this.#r()}async#a(){if(this.#t)return this.#t;if(!this.#e)throw new t(`resolveSigner`);return this.#e.getSigner()}async#o(e){let t=e.provider;if(!t)return;let[n,r]=await Promise.all([e.getAddress(),t.getNetwork()]);return{address:D(n),chainId:Number(r.chainId)}}async signTypedData(e){let t=await this.#a(),{domain:n,types:r,message:i}=e,{EIP712Domain:a,...o}=r,s=Object.fromEntries(Object.entries(o).map(([e,t])=>[e,[...t]])),c=await t.signTypedData(n,s,i);if(!O(c))throw TypeError(`Expected hex string, got: ${c}`);return c}async writeContract(e){let t=await this.#a(),n=new A(e.address,e.abi,t),r={};e.value!==void 0&&(r.value=e.value),e.gas!==void 0&&(r.gasLimit=e.gas);let i=await n.getFunction(e.functionName)(...e.args,r);if(!O(i.hash))throw TypeError(`Expected hex string, got: ${i.hash}`);return i.hash}async#s(e){return this.#i??=this.#o(e).then(e=>(this.walletAccount.setSnapshot(e),e)).finally(()=>{this.#i=void 0}),this.#i}async#c(){let e=await this.#l();return this.walletAccount.setSnapshot(e),e}async#l(){let e=this.#n;if(!e)return;let[t,n]=await Promise.all([e.request({method:`eth_accounts`}),e.request({method:`eth_chainId`})]);if(!Array.isArray(t)||typeof t[0]!=`string`)return;let r=Number(n);if(!(!Number.isSafeInteger(r)||r<=0))return{address:D(t[0]),chainId:r}}};function Q(e){if(`signer`in e&&e.signer){let t=new Z({signer:e.signer});if(!e.signer.provider)throw Error(`createConfig requires a Signer with an attached provider for chain reads`);return x(t,new X({provider:e.signer.provider}),e)}return x(new Z({ethereum:e.ethereum}),`provider`in e&&e.provider?new X({provider:e.provider}):new X({ethereum:e.ethereum}),e)}export{S as BaseSigner,X as EthersProvider,Z as EthersSigner,w as ProviderRpcError,v as ZamaSDKEvents,Q as createConfig,P as readConfidentialBalanceOfContract,q as readConfidentialTokenAddressContract,Y as readIsConfidentialTokenValidContract,I as readSupportsInterfaceContract,J as readTokenAddressContract,K as readTokenPairContract,U as readTokenPairsContract,W as readTokenPairsLengthContract,G as readTokenPairsSliceContract,F as readUnderlyingTokenContract,L as writeConfidentialTransferContract,B as writeFinalizeUnwrapContract,V as writeSetOperatorContract,R as writeUnwrapContract,z as writeUnwrapFromBalanceContract,H as writeWrapContract};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import "./index-
|
|
2
|
-
import { Kt as RelayerOptions, c as GenericStorage, n as RelayerConfig } from "./types-
|
|
3
|
-
import "./cleartext-
|
|
1
|
+
import "./index-SfbUoPTf.js";
|
|
2
|
+
import { Kt as RelayerOptions, c as GenericStorage, n as RelayerConfig } from "./types-BiA5rWAw.js";
|
|
3
|
+
import "./cleartext-CT4qh3Ra.js";
|
|
4
4
|
//#region src/node/config.d.ts
|
|
5
5
|
/** Node transport — drives the FHE backend directly on the calling thread. */
|
|
6
6
|
interface NodeRelayerConfig extends RelayerConfig {
|
|
@@ -58,4 +58,4 @@ declare class AsyncLocalMapStorage implements GenericStorage {
|
|
|
58
58
|
declare const asyncLocalStorage: AsyncLocalMapStorage;
|
|
59
59
|
//#endregion
|
|
60
60
|
export { node as i, asyncLocalStorage as n, NodeRelayerConfig as r, AsyncLocalMapStorage as t };
|
|
61
|
-
//# sourceMappingURL=index-
|
|
61
|
+
//# sourceMappingURL=index-BYF_r0pl.d.ts.map
|
|
@@ -17,8 +17,8 @@ type FheChainAuth = {
|
|
|
17
17
|
* Complete chain configuration — the single source of truth for
|
|
18
18
|
* per-chain FHE contract addresses and network settings.
|
|
19
19
|
*
|
|
20
|
-
* All built-in presets (`mainnet`, `sepolia`, `
|
|
21
|
-
* `bscTestnet`, `hardhat`) are `FheChain` objects exported from
|
|
20
|
+
* All built-in presets (`mainnet`, `sepolia`, `polygonAmoy`, `hoodi`,
|
|
21
|
+
* `ingenTestnet`, `bscTestnet`, `hardhat`) are `FheChain` objects exported from
|
|
22
22
|
* `@zama-fhe/sdk/chains`.
|
|
23
23
|
*/
|
|
24
24
|
interface FheChain<TId extends number = number> {
|
|
@@ -92,6 +92,21 @@ declare const sepolia: {
|
|
|
92
92
|
readonly verifyingContractAddressInputVerification: "0x483b9dE06E4E4C7D35CCf5837A1668487406D955";
|
|
93
93
|
readonly registryAddress: "0x2f0750Bbb0A246059d80e94c454586a7F27a128e";
|
|
94
94
|
};
|
|
95
|
+
/**
|
|
96
|
+
* Polygon Amoy testnet network configuration (chainId 80002).
|
|
97
|
+
*/
|
|
98
|
+
declare const polygonAmoy: {
|
|
99
|
+
readonly id: 80002;
|
|
100
|
+
readonly gatewayChainId: 10901;
|
|
101
|
+
readonly relayerUrl: "https://relayer.testnet.zama.org";
|
|
102
|
+
readonly network: "https://polygon-amoy-bor-rpc.publicnode.com";
|
|
103
|
+
readonly aclContractAddress: "0xD99Cb9Fc3c42c87f2A4A12e8Fd60318d6bDdf985";
|
|
104
|
+
readonly kmsContractAddress: "0xCD1D89E311bce4C8DEa9a0857a0c9A4E153D4041";
|
|
105
|
+
readonly inputVerifierContractAddress: "0x6e5A7D8b0c645467Cba7e62D6624917085118631";
|
|
106
|
+
readonly verifyingContractAddressDecryption: "0x5D8BD78e2ea6bbE41f26dFe9fdaEAa349e077478";
|
|
107
|
+
readonly verifyingContractAddressInputVerification: "0x483b9dE06E4E4C7D35CCf5837A1668487406D955";
|
|
108
|
+
readonly registryAddress: "0xF486c3D4F4562760A43883e72E8D6f6Cf2EFdA94";
|
|
109
|
+
};
|
|
95
110
|
/**
|
|
96
111
|
* Hoodi testnet configuration (chainId 560048).
|
|
97
112
|
*
|
|
@@ -186,5 +201,5 @@ declare const anvil: {
|
|
|
186
201
|
*/
|
|
187
202
|
declare const chains: Record<number, FheChain>;
|
|
188
203
|
//#endregion
|
|
189
|
-
export { hoodi as a,
|
|
190
|
-
//# sourceMappingURL=index-
|
|
204
|
+
export { hoodi as a, polygonAmoy as c, FheChain as d, FheChainAuth as f, hardhat as i, sepolia as l, bscTestnet as n, ingenTestnet as o, chains as r, mainnet as s, anvil as t, AtLeastOneChain as u };
|
|
205
|
+
//# sourceMappingURL=index-SfbUoPTf.d.ts.map
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { $ as UnshieldOptions, Bt as EncryptResult, Ft as DecryptPublicValuesResult, Nt as TransactionResult, Pt as ClearValue, Q as TransferOptions, Vt as EncryptedValue, Wt as FhevmRelayerOptions, X as ShieldOptions, c as GenericStorage, d as WalletAccount, et as UnwrapResult, i as ZamaConfig, it as UnshieldCallbacks, l as GenericProvider, o as ZamaConfigGeneric, qt as RelayerSDK, rt as TransferCallbacks, tt as WrapOptions, u as GenericSigner, zt as EncryptParams } from "./types-
|
|
3
|
-
import "./cleartext-
|
|
4
|
-
import "./types-
|
|
5
|
-
import "./base-signer-
|
|
6
|
-
import "./types-
|
|
1
|
+
import { d as FheChain } from "./index-SfbUoPTf.js";
|
|
2
|
+
import { $ as UnshieldOptions, Bt as EncryptResult, Ft as DecryptPublicValuesResult, Nt as TransactionResult, Pt as ClearValue, Q as TransferOptions, Vt as EncryptedValue, Wt as FhevmRelayerOptions, X as ShieldOptions, c as GenericStorage, d as WalletAccount, et as UnwrapResult, i as ZamaConfig, it as UnshieldCallbacks, l as GenericProvider, o as ZamaConfigGeneric, qt as RelayerSDK, rt as TransferCallbacks, tt as WrapOptions, u as GenericSigner, zt as EncryptParams } from "./types-BiA5rWAw.js";
|
|
3
|
+
import "./cleartext-CT4qh3Ra.js";
|
|
4
|
+
import "./types-CPJdosAz.js";
|
|
5
|
+
import "./base-signer-rvOfr9wl.js";
|
|
6
|
+
import "./types-C24EbhTi.js";
|
|
7
7
|
import { Address, Address as Address$1, Hex, Hex as Hex$1 } from "viem";
|
|
8
8
|
import { z } from "zod/mini";
|
|
9
9
|
import { MutationFunctionContext, QueryKey, QueryObserverOptions, skipToken } from "@tanstack/query-core";
|
|
@@ -20685,4 +20685,4 @@ declare class ChromeSessionStorage implements GenericStorage {
|
|
|
20685
20685
|
declare const chromeSessionStorage: ChromeSessionStorage;
|
|
20686
20686
|
//#endregion
|
|
20687
20687
|
export { AclPausedError as $, confidentialTransferContract as $t, BatchDecryptResult as A, getTokenPairsContract as At, WalletNotConnectedError as B, ERC7984_INTERFACE_ID as Bt, BatchDecryptAsOptions as C, QueryFactoryOptions as Ct, DelegationStatus as D, getConfidentialTokenAddressContract as Dt, Delegations as E, TokenWrapperPairWithMetadata as Et, SigningFailedError as F, getDelegationExpiryContract as Ft, BalanceCheckUnavailableError as G, allowanceContract as Gt, NotEntitledError as H, isConfidentialTokenContract as Ht, SigningRejectedError as I, isHandleDelegatedContract as It, InsufficientAllowanceError as J, decimalsContract as Jt, BalanceErrorDetails as K, approveContract as Kt, SignerNotConfiguredError as L, revokeDelegationContract as Lt, ErrorForCode as M, getTokenPairsSliceContract as Mt, matchZamaError as N, isConfidentialTokenValidContract as Nt, Decryption as O, getTokenAddressContract as Ot, TransactionRevertedError as P, delegateForUserDecryptionContract as Pt, EncryptionFailedError as Q, confidentialTotalSupplyContract as Qt, SignerRequiredError as R, transferAndCallContract as Rt, BatchBalancesResult as S, MutationFactoryOptions as St, Permits as T, TokenWrapperPair as Tt, ConfigurationError as U, isConfidentialWrapperContract as Ut, RpcRateLimitError as V, ERC7984_WRAPPER_INTERFACE_ID as Vt, RelayerRequestFailedError as W, supportsInterfaceContract as Wt, InsufficientERC20BalanceError as X, symbolContract as Xt, InsufficientConfidentialBalanceError as Y, nameContract as Yt, DecryptionFailedError as Z, confidentialBalanceOfContract as Zt, SerializedPermit as _, DecryptResult as _t, IndexedDBStorage as a, setOperatorContract as an, DelegationExpiryUnchangedError as at, ChecksummedAddress as b, SignerQueryContext as bt, memoryStorage as c, unwrapFromBalanceContract as cn, DelegationSelfNotAllowedError as ct, ZamaSDK as d, TransportKeyPairExpiredError as dt, confidentialTransferFromContract as en, DelegationContractIsSelfError as et, DefaultRegistryAddresses as f, ChainMismatchError as ft, Permission as g, retryAfterSeconds as gt, WrappersRegistryConfig as h, isRetryable as ht, chromeSessionStorage as i, rateContract as in, DelegationExpiredError as it, DelegatedDecryptOptions as j, getTokenPairsLengthContract as jt, BatchDecryptItem as k, getTokenPairContract as kt, ZERO_ENCRYPTED_VALUE as l, wrapContract as ln, InvalidTransportKeyPairError as lt, WrappersRegistry as m, ZamaErrorCode as mt, Hex$1 as n, inferredTotalSupplyContract as nn, DelegationDelegateEqualsContractError as nt, indexedDBStorage as o, underlyingContract as on, DelegationNotFoundError as ot, ListPairsOptions as p, ZamaError as pt, ERC20ReadFailedError as q, balanceOfContract as qt, ChromeSessionStorage as r, isOperatorContract as rn, DelegationExpirationTooSoonError as rt, MemoryStorage as s, unwrapContract as sn, DelegationNotPropagatedError as st, Address$1 as t, finalizeUnwrapContract as tn, DelegationCooldownError as tt, isEncryptedValueZero as u, createConfig as un, NoCiphertextError as ut, SerializedPermitEip712 as v, EncryptedInput as vt, Token as w, PaginatedResult as wt, WrappedToken as x, zamaQueryKeys as xt, SerializedTransportKeyPair as y, decryptValuesQueryOptions as yt, WalletAccountNotReadyError as z, ERC1363_INTERFACE_ID as zt };
|
|
20688
|
-
//# sourceMappingURL=index-
|
|
20688
|
+
//# sourceMappingURL=index-bro9lghR.d.ts.map
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { a as hoodi, c as
|
|
2
|
-
import { $ as UnshieldOptions, A as EncryptErrorEvent, At as findWrap, B as UnshieldPhase1SubmittedEvent, Bt as EncryptResult, C as ApproveUnderlyingSubmittedEvent, Ct as decodeRevokedDelegationForUserDecryption, D as DecryptStartEvent, Dt as findDelegatedForUserDecryption, E as DecryptErrorEvent, Et as decodeWrap, F as ShieldSubmittedEvent, Ft as DecryptPublicValuesResult, G as ZamaSDKEvent, Gt as FhevmRuntimeConfig, H as UnshieldPhase2SubmittedEvent, Ht as FhevmClient, I as TransactionErrorEvent, It as DecryptValuesParameters, J as ZamaSDKEvents, Jt as TypedValue, K as ZamaSDKEventListener, Kt as RelayerOptions, L as TransactionOperation, Lt as EIP712TypedData, M as FinalizeUnwrapSubmittedEvent, Mt as TransactionReceipt, N as RevokeDelegationSubmittedEvent, Nt as TransactionResult, O as DelegationSubmittedEvent, Ot as findRevokedDelegationForUserDecryption, P as SetOperatorSubmittedEvent, Pt as ClearValue, Q as TransferOptions, R as TransferFromSubmittedEvent, Rt as EncryptInput, S as WriteFunctionName, St as decodeOnChainEvents, T as DecryptEndEvent, Tt as decodeUnwrapRequested, U as UnwrapSubmittedEvent, Ut as FhevmClientOptions, V as UnshieldPhase2StartedEvent, Vt as EncryptedValue, W as WrapSubmittedEvent, Wt as FhevmRelayerOptions, X as ShieldOptions, Y as ApprovalStrategy, Z as ShieldPath, _ as ReadContractConfig, _t as decodeAclEvent, a as ZamaConfigBase, at as ACL_TOPICS, b as WriteContractArgs, bt as decodeDelegatedForUserDecryption, c as GenericStorage, ct as ConfidentialTransferEvent, d as WalletAccount, dt as RevokedDelegationForUserDecryptionEvent, et as UnwrapResult, f as WalletAccountChange, ft as TOKEN_TOPICS, g as ReadContractArgs, gt as WrapEvent, h as ContractAbi, ht as UnwrapRequestedEvent, i as ZamaConfig, it as UnshieldCallbacks, j as EncryptStartEvent, jt as RawLog, k as EncryptEndEvent, kt as findUnwrapRequested, l as GenericProvider, lt as DelegatedForUserDecryptionEvent, m as WalletAccountStore, mt as UnwrapFinalizedEvent, n as RelayerConfig, nt as ShieldCallbacks, o as ZamaConfigGeneric, ot as AclEvent, p as WalletAccountListener, pt as Topics, q as ZamaSDKEventType, qt as RelayerSDK, rt as TransferCallbacks, s as GenericLogger, st as AclTopics, t as CleartextRelayerConfig, tt as WrapOptions, u as GenericSigner, ut as OnChainEvent, v as ReadContractReturnType, vt as decodeAclEvents, w as BaseEvent, wt as decodeUnwrapFinalized, x as WriteContractConfig, xt as decodeOnChainEvent, y as ReadFunctionName, yt as decodeConfidentialTransfer, z as TransferSubmittedEvent, zt as EncryptParams } from "./types-
|
|
3
|
-
import { t as cleartext } from "./cleartext-
|
|
4
|
-
import { t as ZamaConfigEthers } from "./types-
|
|
5
|
-
import { n as MutableWalletAccountStore, r as createWalletAccountStore, t as BaseSigner } from "./base-signer-
|
|
6
|
-
import { $ as AclPausedError, $t as confidentialTransferContract, A as BatchDecryptResult, At as getTokenPairsContract, B as WalletNotConnectedError, Bt as ERC7984_INTERFACE_ID, C as BatchDecryptAsOptions, D as DelegationStatus, Dt as getConfidentialTokenAddressContract, E as Delegations, Et as TokenWrapperPairWithMetadata, F as SigningFailedError, Ft as getDelegationExpiryContract, G as BalanceCheckUnavailableError, Gt as allowanceContract, H as NotEntitledError, Ht as isConfidentialTokenContract, I as SigningRejectedError, It as isHandleDelegatedContract, J as InsufficientAllowanceError, Jt as decimalsContract, K as BalanceErrorDetails, Kt as approveContract, L as SignerNotConfiguredError, Lt as revokeDelegationContract, M as ErrorForCode, Mt as getTokenPairsSliceContract, N as matchZamaError, Nt as isConfidentialTokenValidContract, O as Decryption, Ot as getTokenAddressContract, P as TransactionRevertedError, Pt as delegateForUserDecryptionContract, Q as EncryptionFailedError, Qt as confidentialTotalSupplyContract, R as SignerRequiredError, Rt as transferAndCallContract, S as BatchBalancesResult, T as Permits, Tt as TokenWrapperPair, U as ConfigurationError, Ut as isConfidentialWrapperContract, V as RpcRateLimitError, Vt as ERC7984_WRAPPER_INTERFACE_ID, W as RelayerRequestFailedError, Wt as supportsInterfaceContract, X as InsufficientERC20BalanceError, Xt as symbolContract, Y as InsufficientConfidentialBalanceError, Yt as nameContract, Z as DecryptionFailedError, Zt as confidentialBalanceOfContract, _ as SerializedPermit, _t as DecryptResult, a as IndexedDBStorage, an as setOperatorContract, at as DelegationExpiryUnchangedError, b as ChecksummedAddress, c as memoryStorage, cn as unwrapFromBalanceContract, ct as DelegationSelfNotAllowedError, d as ZamaSDK, dt as TransportKeyPairExpiredError, en as confidentialTransferFromContract, et as DelegationContractIsSelfError, f as DefaultRegistryAddresses, ft as ChainMismatchError, g as Permission, gt as retryAfterSeconds, h as WrappersRegistryConfig, ht as isRetryable, i as chromeSessionStorage, in as rateContract, it as DelegationExpiredError, j as DelegatedDecryptOptions, jt as getTokenPairsLengthContract, k as BatchDecryptItem, kt as getTokenPairContract, l as ZERO_ENCRYPTED_VALUE, ln as wrapContract, lt as InvalidTransportKeyPairError, m as WrappersRegistry, mt as ZamaErrorCode, n as Hex, nn as inferredTotalSupplyContract, nt as DelegationDelegateEqualsContractError, o as indexedDBStorage, on as underlyingContract, ot as DelegationNotFoundError, p as ListPairsOptions, pt as ZamaError, q as ERC20ReadFailedError, qt as balanceOfContract, r as ChromeSessionStorage, rn as isOperatorContract, rt as DelegationExpirationTooSoonError, s as MemoryStorage, sn as unwrapContract, st as DelegationNotPropagatedError, t as Address, tn as finalizeUnwrapContract, tt as DelegationCooldownError, u as isEncryptedValueZero, un as createConfig, ut as NoCiphertextError, v as SerializedPermitEip712, vt as EncryptedInput, w as Token, wt as PaginatedResult, x as WrappedToken, y as SerializedTransportKeyPair, z as WalletAccountNotReadyError, zt as ERC1363_INTERFACE_ID } from "./index-
|
|
7
|
-
import { t as ZamaConfigViem } from "./types-
|
|
8
|
-
export { ACL_TOPICS, type AclEvent, AclPausedError, AclTopics, type Address, type ApprovalStrategy, type ApproveUnderlyingSubmittedEvent, type AtLeastOneChain, BalanceCheckUnavailableError, type BalanceErrorDetails, type BaseEvent, BaseSigner, type BatchBalancesResult, type BatchDecryptAsOptions, type BatchDecryptItem, type BatchDecryptResult, ChainMismatchError, type ChecksummedAddress, ChromeSessionStorage, type ClearValue, type CleartextRelayerConfig, type ConfidentialTransferEvent, ConfigurationError, type ContractAbi, type DecryptEndEvent, type DecryptErrorEvent, type EncryptedInput as DecryptInput, type DecryptPublicValuesResult, type DecryptResult, type DecryptStartEvent, type DecryptValuesParameters, Decryption, DecryptionFailedError, DefaultRegistryAddresses, type DelegatedDecryptOptions, type DelegatedForUserDecryptionEvent, DelegationContractIsSelfError, DelegationCooldownError, DelegationDelegateEqualsContractError, DelegationExpirationTooSoonError, DelegationExpiredError, DelegationExpiryUnchangedError, DelegationNotFoundError, DelegationNotPropagatedError, DelegationSelfNotAllowedError, type DelegationStatus, type DelegationSubmittedEvent, Delegations, type EIP712TypedData, ERC1363_INTERFACE_ID, ERC20ReadFailedError, ERC7984_INTERFACE_ID, ERC7984_WRAPPER_INTERFACE_ID, type EncryptEndEvent, type EncryptErrorEvent, type EncryptInput, type EncryptParams, type EncryptResult, type EncryptStartEvent, type EncryptedValue, EncryptionFailedError, type ErrorForCode, type FheChain, type FheChainAuth, type FhevmClient, type FhevmClientOptions, type FhevmRelayerOptions, type FhevmRuntimeConfig, type FinalizeUnwrapSubmittedEvent, type GenericLogger, type GenericProvider, type GenericSigner, type GenericStorage, type Hex, IndexedDBStorage, InsufficientAllowanceError, InsufficientConfidentialBalanceError, InsufficientERC20BalanceError, InvalidTransportKeyPairError, type ListPairsOptions, MemoryStorage, MutableWalletAccountStore, NoCiphertextError, NotEntitledError, type OnChainEvent, type PaginatedResult, type Permission, Permits, type RawLog, type ReadContractArgs, type ReadContractConfig, type ReadContractReturnType, type ReadFunctionName, type RelayerConfig, type RelayerOptions, RelayerRequestFailedError, type RelayerSDK, type RevokeDelegationSubmittedEvent, type RevokedDelegationForUserDecryptionEvent, RpcRateLimitError, type SerializedPermit, type SerializedPermitEip712, type SerializedTransportKeyPair, type SetOperatorSubmittedEvent, type ShieldCallbacks, type ShieldOptions, type ShieldPath, type ShieldSubmittedEvent, SignerNotConfiguredError, SignerRequiredError, SigningFailedError, SigningRejectedError, TOKEN_TOPICS, Token, type TokenWrapperPair, type TokenWrapperPairWithMetadata, Topics, type TransactionErrorEvent, type TransactionOperation, type TransactionReceipt, type TransactionResult, TransactionRevertedError, type TransferCallbacks, type TransferFromSubmittedEvent, type TransferOptions, type TransferSubmittedEvent, TransportKeyPairExpiredError, type TypedValue, type UnshieldCallbacks, type UnshieldOptions, type UnshieldPhase1SubmittedEvent, type UnshieldPhase2StartedEvent, type UnshieldPhase2SubmittedEvent, type UnwrapFinalizedEvent, type UnwrapRequestedEvent, type UnwrapResult, type UnwrapSubmittedEvent, type WalletAccount, type WalletAccountChange, type WalletAccountListener, WalletAccountNotReadyError, type WalletAccountStore, WalletNotConnectedError, type WrapEvent, type WrapOptions, type WrapSubmittedEvent, WrappedToken, WrappersRegistry, type WrappersRegistryConfig, type WriteContractArgs, type WriteContractConfig, type WriteFunctionName, ZERO_ENCRYPTED_VALUE, type ZamaConfig, type ZamaConfigBase, type ZamaConfigEthers, type ZamaConfigGeneric, type ZamaConfigViem, ZamaError, ZamaErrorCode, ZamaSDK, type ZamaSDKEvent, type ZamaSDKEventListener, type ZamaSDKEventType, ZamaSDKEvents, allowanceContract, anvil, approveContract, balanceOfContract, bscTestnet, chains, chromeSessionStorage, cleartext, confidentialBalanceOfContract, confidentialTotalSupplyContract, confidentialTransferContract, confidentialTransferFromContract, createConfig, createWalletAccountStore, decimalsContract, decodeAclEvent, decodeAclEvents, decodeConfidentialTransfer, decodeDelegatedForUserDecryption, decodeOnChainEvent, decodeOnChainEvents, decodeRevokedDelegationForUserDecryption, decodeUnwrapFinalized, decodeUnwrapRequested, decodeWrap, delegateForUserDecryptionContract, finalizeUnwrapContract, findDelegatedForUserDecryption, findRevokedDelegationForUserDecryption, findUnwrapRequested, findWrap, getConfidentialTokenAddressContract, getDelegationExpiryContract, getTokenAddressContract, getTokenPairContract, getTokenPairsContract, getTokenPairsLengthContract, getTokenPairsSliceContract, hardhat, hoodi, indexedDBStorage, inferredTotalSupplyContract, ingenTestnet, isConfidentialTokenContract, isConfidentialTokenValidContract, isConfidentialWrapperContract, isEncryptedValueZero, isHandleDelegatedContract, isOperatorContract, isRetryable, mainnet, matchZamaError, memoryStorage, nameContract, rateContract, retryAfterSeconds, revokeDelegationContract, sepolia, setOperatorContract, supportsInterfaceContract, symbolContract, transferAndCallContract, underlyingContract, unwrapContract, unwrapFromBalanceContract, wrapContract };
|
|
1
|
+
import { a as hoodi, c as polygonAmoy, d as FheChain, f as FheChainAuth, i as hardhat, l as sepolia, n as bscTestnet, o as ingenTestnet, r as chains, s as mainnet, t as anvil, u as AtLeastOneChain } from "./index-SfbUoPTf.js";
|
|
2
|
+
import { $ as UnshieldOptions, A as EncryptErrorEvent, At as findWrap, B as UnshieldPhase1SubmittedEvent, Bt as EncryptResult, C as ApproveUnderlyingSubmittedEvent, Ct as decodeRevokedDelegationForUserDecryption, D as DecryptStartEvent, Dt as findDelegatedForUserDecryption, E as DecryptErrorEvent, Et as decodeWrap, F as ShieldSubmittedEvent, Ft as DecryptPublicValuesResult, G as ZamaSDKEvent, Gt as FhevmRuntimeConfig, H as UnshieldPhase2SubmittedEvent, Ht as FhevmClient, I as TransactionErrorEvent, It as DecryptValuesParameters, J as ZamaSDKEvents, Jt as TypedValue, K as ZamaSDKEventListener, Kt as RelayerOptions, L as TransactionOperation, Lt as EIP712TypedData, M as FinalizeUnwrapSubmittedEvent, Mt as TransactionReceipt, N as RevokeDelegationSubmittedEvent, Nt as TransactionResult, O as DelegationSubmittedEvent, Ot as findRevokedDelegationForUserDecryption, P as SetOperatorSubmittedEvent, Pt as ClearValue, Q as TransferOptions, R as TransferFromSubmittedEvent, Rt as EncryptInput, S as WriteFunctionName, St as decodeOnChainEvents, T as DecryptEndEvent, Tt as decodeUnwrapRequested, U as UnwrapSubmittedEvent, Ut as FhevmClientOptions, V as UnshieldPhase2StartedEvent, Vt as EncryptedValue, W as WrapSubmittedEvent, Wt as FhevmRelayerOptions, X as ShieldOptions, Y as ApprovalStrategy, Z as ShieldPath, _ as ReadContractConfig, _t as decodeAclEvent, a as ZamaConfigBase, at as ACL_TOPICS, b as WriteContractArgs, bt as decodeDelegatedForUserDecryption, c as GenericStorage, ct as ConfidentialTransferEvent, d as WalletAccount, dt as RevokedDelegationForUserDecryptionEvent, et as UnwrapResult, f as WalletAccountChange, ft as TOKEN_TOPICS, g as ReadContractArgs, gt as WrapEvent, h as ContractAbi, ht as UnwrapRequestedEvent, i as ZamaConfig, it as UnshieldCallbacks, j as EncryptStartEvent, jt as RawLog, k as EncryptEndEvent, kt as findUnwrapRequested, l as GenericProvider, lt as DelegatedForUserDecryptionEvent, m as WalletAccountStore, mt as UnwrapFinalizedEvent, n as RelayerConfig, nt as ShieldCallbacks, o as ZamaConfigGeneric, ot as AclEvent, p as WalletAccountListener, pt as Topics, q as ZamaSDKEventType, qt as RelayerSDK, rt as TransferCallbacks, s as GenericLogger, st as AclTopics, t as CleartextRelayerConfig, tt as WrapOptions, u as GenericSigner, ut as OnChainEvent, v as ReadContractReturnType, vt as decodeAclEvents, w as BaseEvent, wt as decodeUnwrapFinalized, x as WriteContractConfig, xt as decodeOnChainEvent, y as ReadFunctionName, yt as decodeConfidentialTransfer, z as TransferSubmittedEvent, zt as EncryptParams } from "./types-BiA5rWAw.js";
|
|
3
|
+
import { t as cleartext } from "./cleartext-CT4qh3Ra.js";
|
|
4
|
+
import { t as ZamaConfigEthers } from "./types-CPJdosAz.js";
|
|
5
|
+
import { n as MutableWalletAccountStore, r as createWalletAccountStore, t as BaseSigner } from "./base-signer-rvOfr9wl.js";
|
|
6
|
+
import { $ as AclPausedError, $t as confidentialTransferContract, A as BatchDecryptResult, At as getTokenPairsContract, B as WalletNotConnectedError, Bt as ERC7984_INTERFACE_ID, C as BatchDecryptAsOptions, D as DelegationStatus, Dt as getConfidentialTokenAddressContract, E as Delegations, Et as TokenWrapperPairWithMetadata, F as SigningFailedError, Ft as getDelegationExpiryContract, G as BalanceCheckUnavailableError, Gt as allowanceContract, H as NotEntitledError, Ht as isConfidentialTokenContract, I as SigningRejectedError, It as isHandleDelegatedContract, J as InsufficientAllowanceError, Jt as decimalsContract, K as BalanceErrorDetails, Kt as approveContract, L as SignerNotConfiguredError, Lt as revokeDelegationContract, M as ErrorForCode, Mt as getTokenPairsSliceContract, N as matchZamaError, Nt as isConfidentialTokenValidContract, O as Decryption, Ot as getTokenAddressContract, P as TransactionRevertedError, Pt as delegateForUserDecryptionContract, Q as EncryptionFailedError, Qt as confidentialTotalSupplyContract, R as SignerRequiredError, Rt as transferAndCallContract, S as BatchBalancesResult, T as Permits, Tt as TokenWrapperPair, U as ConfigurationError, Ut as isConfidentialWrapperContract, V as RpcRateLimitError, Vt as ERC7984_WRAPPER_INTERFACE_ID, W as RelayerRequestFailedError, Wt as supportsInterfaceContract, X as InsufficientERC20BalanceError, Xt as symbolContract, Y as InsufficientConfidentialBalanceError, Yt as nameContract, Z as DecryptionFailedError, Zt as confidentialBalanceOfContract, _ as SerializedPermit, _t as DecryptResult, a as IndexedDBStorage, an as setOperatorContract, at as DelegationExpiryUnchangedError, b as ChecksummedAddress, c as memoryStorage, cn as unwrapFromBalanceContract, ct as DelegationSelfNotAllowedError, d as ZamaSDK, dt as TransportKeyPairExpiredError, en as confidentialTransferFromContract, et as DelegationContractIsSelfError, f as DefaultRegistryAddresses, ft as ChainMismatchError, g as Permission, gt as retryAfterSeconds, h as WrappersRegistryConfig, ht as isRetryable, i as chromeSessionStorage, in as rateContract, it as DelegationExpiredError, j as DelegatedDecryptOptions, jt as getTokenPairsLengthContract, k as BatchDecryptItem, kt as getTokenPairContract, l as ZERO_ENCRYPTED_VALUE, ln as wrapContract, lt as InvalidTransportKeyPairError, m as WrappersRegistry, mt as ZamaErrorCode, n as Hex, nn as inferredTotalSupplyContract, nt as DelegationDelegateEqualsContractError, o as indexedDBStorage, on as underlyingContract, ot as DelegationNotFoundError, p as ListPairsOptions, pt as ZamaError, q as ERC20ReadFailedError, qt as balanceOfContract, r as ChromeSessionStorage, rn as isOperatorContract, rt as DelegationExpirationTooSoonError, s as MemoryStorage, sn as unwrapContract, st as DelegationNotPropagatedError, t as Address, tn as finalizeUnwrapContract, tt as DelegationCooldownError, u as isEncryptedValueZero, un as createConfig, ut as NoCiphertextError, v as SerializedPermitEip712, vt as EncryptedInput, w as Token, wt as PaginatedResult, x as WrappedToken, y as SerializedTransportKeyPair, z as WalletAccountNotReadyError, zt as ERC1363_INTERFACE_ID } from "./index-bro9lghR.js";
|
|
7
|
+
import { t as ZamaConfigViem } from "./types-C24EbhTi.js";
|
|
8
|
+
export { ACL_TOPICS, type AclEvent, AclPausedError, AclTopics, type Address, type ApprovalStrategy, type ApproveUnderlyingSubmittedEvent, type AtLeastOneChain, BalanceCheckUnavailableError, type BalanceErrorDetails, type BaseEvent, BaseSigner, type BatchBalancesResult, type BatchDecryptAsOptions, type BatchDecryptItem, type BatchDecryptResult, ChainMismatchError, type ChecksummedAddress, ChromeSessionStorage, type ClearValue, type CleartextRelayerConfig, type ConfidentialTransferEvent, ConfigurationError, type ContractAbi, type DecryptEndEvent, type DecryptErrorEvent, type EncryptedInput as DecryptInput, type DecryptPublicValuesResult, type DecryptResult, type DecryptStartEvent, type DecryptValuesParameters, Decryption, DecryptionFailedError, DefaultRegistryAddresses, type DelegatedDecryptOptions, type DelegatedForUserDecryptionEvent, DelegationContractIsSelfError, DelegationCooldownError, DelegationDelegateEqualsContractError, DelegationExpirationTooSoonError, DelegationExpiredError, DelegationExpiryUnchangedError, DelegationNotFoundError, DelegationNotPropagatedError, DelegationSelfNotAllowedError, type DelegationStatus, type DelegationSubmittedEvent, Delegations, type EIP712TypedData, ERC1363_INTERFACE_ID, ERC20ReadFailedError, ERC7984_INTERFACE_ID, ERC7984_WRAPPER_INTERFACE_ID, type EncryptEndEvent, type EncryptErrorEvent, type EncryptInput, type EncryptParams, type EncryptResult, type EncryptStartEvent, type EncryptedValue, EncryptionFailedError, type ErrorForCode, type FheChain, type FheChainAuth, type FhevmClient, type FhevmClientOptions, type FhevmRelayerOptions, type FhevmRuntimeConfig, type FinalizeUnwrapSubmittedEvent, type GenericLogger, type GenericProvider, type GenericSigner, type GenericStorage, type Hex, IndexedDBStorage, InsufficientAllowanceError, InsufficientConfidentialBalanceError, InsufficientERC20BalanceError, InvalidTransportKeyPairError, type ListPairsOptions, MemoryStorage, MutableWalletAccountStore, NoCiphertextError, NotEntitledError, type OnChainEvent, type PaginatedResult, type Permission, Permits, type RawLog, type ReadContractArgs, type ReadContractConfig, type ReadContractReturnType, type ReadFunctionName, type RelayerConfig, type RelayerOptions, RelayerRequestFailedError, type RelayerSDK, type RevokeDelegationSubmittedEvent, type RevokedDelegationForUserDecryptionEvent, RpcRateLimitError, type SerializedPermit, type SerializedPermitEip712, type SerializedTransportKeyPair, type SetOperatorSubmittedEvent, type ShieldCallbacks, type ShieldOptions, type ShieldPath, type ShieldSubmittedEvent, SignerNotConfiguredError, SignerRequiredError, SigningFailedError, SigningRejectedError, TOKEN_TOPICS, Token, type TokenWrapperPair, type TokenWrapperPairWithMetadata, Topics, type TransactionErrorEvent, type TransactionOperation, type TransactionReceipt, type TransactionResult, TransactionRevertedError, type TransferCallbacks, type TransferFromSubmittedEvent, type TransferOptions, type TransferSubmittedEvent, TransportKeyPairExpiredError, type TypedValue, type UnshieldCallbacks, type UnshieldOptions, type UnshieldPhase1SubmittedEvent, type UnshieldPhase2StartedEvent, type UnshieldPhase2SubmittedEvent, type UnwrapFinalizedEvent, type UnwrapRequestedEvent, type UnwrapResult, type UnwrapSubmittedEvent, type WalletAccount, type WalletAccountChange, type WalletAccountListener, WalletAccountNotReadyError, type WalletAccountStore, WalletNotConnectedError, type WrapEvent, type WrapOptions, type WrapSubmittedEvent, WrappedToken, WrappersRegistry, type WrappersRegistryConfig, type WriteContractArgs, type WriteContractConfig, type WriteFunctionName, ZERO_ENCRYPTED_VALUE, type ZamaConfig, type ZamaConfigBase, type ZamaConfigEthers, type ZamaConfigGeneric, type ZamaConfigViem, ZamaError, ZamaErrorCode, ZamaSDK, type ZamaSDKEvent, type ZamaSDKEventListener, type ZamaSDKEventType, ZamaSDKEvents, allowanceContract, anvil, approveContract, balanceOfContract, bscTestnet, chains, chromeSessionStorage, cleartext, confidentialBalanceOfContract, confidentialTotalSupplyContract, confidentialTransferContract, confidentialTransferFromContract, createConfig, createWalletAccountStore, decimalsContract, decodeAclEvent, decodeAclEvents, decodeConfidentialTransfer, decodeDelegatedForUserDecryption, decodeOnChainEvent, decodeOnChainEvents, decodeRevokedDelegationForUserDecryption, decodeUnwrapFinalized, decodeUnwrapRequested, decodeWrap, delegateForUserDecryptionContract, finalizeUnwrapContract, findDelegatedForUserDecryption, findRevokedDelegationForUserDecryption, findUnwrapRequested, findWrap, getConfidentialTokenAddressContract, getDelegationExpiryContract, getTokenAddressContract, getTokenPairContract, getTokenPairsContract, getTokenPairsLengthContract, getTokenPairsSliceContract, hardhat, hoodi, indexedDBStorage, inferredTotalSupplyContract, ingenTestnet, isConfidentialTokenContract, isConfidentialTokenValidContract, isConfidentialWrapperContract, isEncryptedValueZero, isHandleDelegatedContract, isOperatorContract, isRetryable, mainnet, matchZamaError, memoryStorage, nameContract, polygonAmoy, rateContract, retryAfterSeconds, revokeDelegationContract, sepolia, setOperatorContract, supportsInterfaceContract, symbolContract, transferAndCallContract, underlyingContract, unwrapContract, unwrapFromBalanceContract, wrapContract };
|
package/dist/esm/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{_ as e,a as t,c as n,d as r,f as i,g as a,h as o,i as s,l as c,m as l,n as u,o as d,p as f,r as p,s as m,t as ee}from"./relayer-BWHOLVcG.js";import{A as h,B as te,C as ne,D as re,F as ie,G as ae,H as oe,I as se,J as g,K as ce,L as le,M as ue,N as de,P as fe,R as pe,S as me,T as he,U as ge,V as _e,W as ve,X as ye,Y as _,_ as v,a as be,b as xe,c as Se,d as Ce,f as we,g as Te,h as Ee,i as De,j as Oe,k as ke,l as Ae,m as je,o as Me,p as Ne,r as Pe,s as Fe,t as y,u as Ie,v as b,w as Le,y as x,z as S}from"./sdk-events-D68bJ5jT.js";import{_ as Re,a as ze,b as C,c as Be,d as Ve,f as He,g as w,h as Ue,i as We,l as T,m as Ge,n as Ke,o as E,p as D,r as qe,s as Je,t as O,u as k,v as A,x as j,y as M}from"./token-Bn8I7xAu.js";import{t as Ye}from"./cleartext-Qqh5JohW.js";import{a as Xe,c as Ze,d as Qe,f as $e,i as et,l as tt,m as nt,n as rt,o as N,p as it,r as at,s as ot,t as st,u as P}from"./base-signer-YpkEmlp2.js";import{a as ct,c as lt,i as ut,n as dt,o as ft,r as pt,s as mt,t as ht}from"./chains-CLv9HEJ_.js";import{getAddress as F,keccak256 as gt,toBytes as _t}from"viem";import{z as I}from"zod/mini";function vt(e,t){if(e instanceof p){let n=t[e.code];if(n)return n(e)}return t._?.(e)}var L=class extends p{encryptedValue;contractAddress;account;constructor(e,t){super(s.NotEntitled,`Account ${e.account} is not entitled to decrypt encrypted value ${e.encryptedValue} on contract ${e.contractAddress}. This is not a transient failure — the account needs an on-chain ACL grant before it can decrypt this encrypted value.`,t),this.name=`NotEntitledError`,this.encryptedValue=e.encryptedValue,this.contractAddress=e.contractAddress,this.account=e.account}},R=class extends p{constructor(e,t){super(s.DelegationSelfNotAllowed,e,t),this.name=`DelegationSelfNotAllowedError`}},yt=class extends p{constructor(e,t){super(s.DelegationCooldown,e,t),this.name=`DelegationCooldownError`}},z=class extends p{constructor(e,t){super(s.DelegationNotFound,e,t),this.name=`DelegationNotFoundError`}},B=class extends p{constructor(e,t){super(s.DelegationExpired,e,t),this.name=`DelegationExpiredError`}},V=class extends p{constructor(e,t){super(s.DelegationExpiryUnchanged,e,t),this.name=`DelegationExpiryUnchangedError`}},H=class extends p{constructor(e,t){super(s.DelegationDelegateEqualsContract,e,t),this.name=`DelegationDelegateEqualsContractError`}},bt=class extends p{constructor(e,t){super(s.DelegationContractIsSelf,e,t),this.name=`DelegationContractIsSelfError`}},xt=class extends p{constructor(e,t){super(s.AclPaused,e,t),this.name=`AclPausedError`}},U=class extends p{constructor(e,t){super(s.DelegationExpirationTooSoon,e,t),this.name=`DelegationExpirationTooSoonError`}},W=class extends p{constructor(e,t){super(s.DelegationNotPropagated,e,t),this.name=`DelegationNotPropagatedError`}};const St=[C,_,u,W,ce,ae,L,A,g];function G(e,t,s={}){if(St.some(t=>e instanceof t))return e;let d=e instanceof Error?e.message:t;if(e instanceof Error&&r(e.message))return new g(e.message,{cause:e});if(e instanceof Error&&i(e.message))return s.isDelegated?new W(`Delegated decryption was denied by the on-chain ACL check. This is most commonly caused by the delegation not having propagated yet, or by the RPC node serving a stale block. Propagation usually completes within ~10 blocks (a few seconds) and the SDK retries across that window; seeing this means it did not sync in time. Retry shortly (and prefer a fresh, low-lag RPC endpoint). If it persists, the delegator may genuinely lack the on-chain ACL grant.`,{cause:e}):new L({encryptedValue:a(e.message)??``,contractAddress:s.contractAddress??``,account:s.account??``},{cause:e});if(c(e))return new A(d,{cause:e,retryAfter:n(e)});let p=m(e);return p===void 0&&o(e)?new A(d,{cause:e,retryAfter:n(e)}):p===400?new _(e instanceof Error?e.message:`No ciphertext for this account`,{cause:e}):s.isDelegated&&p===500?new W(`Delegated decryption failed with a server error. This is most commonly caused by the delegation not having propagated to the gateway yet. Cross-chain sync usually completes within ~10 blocks (a few seconds) and the SDK retries across that window; seeing this means it did not sync in time — retry shortly. If the error persists, the gateway or relayer may be experiencing an unrelated issue.`,{cause:e}):f(e)||p!==void 0?new u(d,p,{cause:e,retryAfter:n(e),retryable:l(e)||void 0}):new C(t,{cause:e})}function Ct(e,t){if(e instanceof p)return e;let r=m(e),i=l(e);return r!==void 0||f(e)?new u(e instanceof Error?e.message:t,r,{cause:e,retryAfter:n(e),retryable:i||void 0}):new j(t,{cause:e})}const wt=[{type:`function`,name:`allowance`,inputs:[{name:`owner`,type:`address`,internalType:`address`},{name:`spender`,type:`address`,internalType:`address`}],outputs:[{name:``,type:`uint256`,internalType:`uint256`}],stateMutability:`view`},{type:`function`,name:`approve`,inputs:[{name:`spender`,type:`address`,internalType:`address`},{name:`value`,type:`uint256`,internalType:`uint256`}],outputs:[{name:``,type:`bool`,internalType:`bool`}],stateMutability:`nonpayable`},{type:`function`,name:`approveAndCall`,inputs:[{name:`spender`,type:`address`,internalType:`address`},{name:`value`,type:`uint256`,internalType:`uint256`}],outputs:[{name:``,type:`bool`,internalType:`bool`}],stateMutability:`nonpayable`},{type:`function`,name:`approveAndCall`,inputs:[{name:`spender`,type:`address`,internalType:`address`},{name:`value`,type:`uint256`,internalType:`uint256`},{name:`data`,type:`bytes`,internalType:`bytes`}],outputs:[{name:``,type:`bool`,internalType:`bool`}],stateMutability:`nonpayable`},{type:`function`,name:`balanceOf`,inputs:[{name:`account`,type:`address`,internalType:`address`}],outputs:[{name:``,type:`uint256`,internalType:`uint256`}],stateMutability:`view`},{type:`function`,name:`supportsInterface`,inputs:[{name:`interfaceId`,type:`bytes4`,internalType:`bytes4`}],outputs:[{name:``,type:`bool`,internalType:`bool`}],stateMutability:`view`},{type:`function`,name:`totalSupply`,inputs:[],outputs:[{name:``,type:`uint256`,internalType:`uint256`}],stateMutability:`view`},{type:`function`,name:`transfer`,inputs:[{name:`to`,type:`address`,internalType:`address`},{name:`value`,type:`uint256`,internalType:`uint256`}],outputs:[{name:``,type:`bool`,internalType:`bool`}],stateMutability:`nonpayable`},{type:`function`,name:`transferAndCall`,inputs:[{name:`to`,type:`address`,internalType:`address`},{name:`value`,type:`uint256`,internalType:`uint256`}],outputs:[{name:``,type:`bool`,internalType:`bool`}],stateMutability:`nonpayable`},{type:`function`,name:`transferAndCall`,inputs:[{name:`to`,type:`address`,internalType:`address`},{name:`value`,type:`uint256`,internalType:`uint256`},{name:`data`,type:`bytes`,internalType:`bytes`}],outputs:[{name:``,type:`bool`,internalType:`bool`}],stateMutability:`nonpayable`},{type:`function`,name:`transferFrom`,inputs:[{name:`from`,type:`address`,internalType:`address`},{name:`to`,type:`address`,internalType:`address`},{name:`value`,type:`uint256`,internalType:`uint256`}],outputs:[{name:``,type:`bool`,internalType:`bool`}],stateMutability:`nonpayable`},{type:`function`,name:`transferFromAndCall`,inputs:[{name:`from`,type:`address`,internalType:`address`},{name:`to`,type:`address`,internalType:`address`},{name:`value`,type:`uint256`,internalType:`uint256`},{name:`data`,type:`bytes`,internalType:`bytes`}],outputs:[{name:``,type:`bool`,internalType:`bool`}],stateMutability:`nonpayable`},{type:`function`,name:`transferFromAndCall`,inputs:[{name:`from`,type:`address`,internalType:`address`},{name:`to`,type:`address`,internalType:`address`},{name:`value`,type:`uint256`,internalType:`uint256`}],outputs:[{name:``,type:`bool`,internalType:`bool`}],stateMutability:`nonpayable`},{type:`event`,name:`Approval`,inputs:[{name:`owner`,type:`address`,indexed:!0,internalType:`address`},{name:`spender`,type:`address`,indexed:!0,internalType:`address`},{name:`value`,type:`uint256`,indexed:!1,internalType:`uint256`}],anonymous:!1},{type:`event`,name:`Transfer`,inputs:[{name:`from`,type:`address`,indexed:!0,internalType:`address`},{name:`to`,type:`address`,indexed:!0,internalType:`address`},{name:`value`,type:`uint256`,indexed:!1,internalType:`uint256`}],anonymous:!1}];function Tt(e,t,n,r=`0x`){return{address:e,abi:wt,functionName:`transferAndCall`,args:[t,n,r]}}const K=[{type:`function`,name:`allow`,inputs:[{name:`handle`,type:`bytes32`,internalType:`bytes32`},{name:`account`,type:`address`,internalType:`address`}],outputs:[],stateMutability:`nonpayable`},{type:`function`,name:`allowForDecryption`,inputs:[{name:`handlesList`,type:`bytes32[]`,internalType:`bytes32[]`}],outputs:[],stateMutability:`nonpayable`},{type:`function`,name:`allowTransient`,inputs:[{name:`ciphertext`,type:`bytes32`,internalType:`bytes32`},{name:`account`,type:`address`,internalType:`address`}],outputs:[],stateMutability:`nonpayable`},{type:`function`,name:`cleanTransientStorage`,inputs:[],outputs:[],stateMutability:`nonpayable`},{type:`function`,name:`delegateForUserDecryption`,inputs:[{name:`delegate`,type:`address`,internalType:`address`},{name:`contractAddress`,type:`address`,internalType:`address`},{name:`expirationDate`,type:`uint64`,internalType:`uint64`}],outputs:[],stateMutability:`nonpayable`},{type:`function`,name:`getUserDecryptionDelegationExpirationDate`,inputs:[{name:`delegator`,type:`address`,internalType:`address`},{name:`delegate`,type:`address`,internalType:`address`},{name:`contractAddress`,type:`address`,internalType:`address`}],outputs:[{name:``,type:`uint64`,internalType:`uint64`}],stateMutability:`view`},{type:`function`,name:`isAccountDenied`,inputs:[{name:`account`,type:`address`,internalType:`address`}],outputs:[{name:``,type:`bool`,internalType:`bool`}],stateMutability:`view`},{type:`function`,name:`isAllowed`,inputs:[{name:`handle`,type:`bytes32`,internalType:`bytes32`},{name:`account`,type:`address`,internalType:`address`}],outputs:[{name:``,type:`bool`,internalType:`bool`}],stateMutability:`view`},{type:`function`,name:`isAllowedForDecryption`,inputs:[{name:`handle`,type:`bytes32`,internalType:`bytes32`}],outputs:[{name:``,type:`bool`,internalType:`bool`}],stateMutability:`view`},{type:`function`,name:`isHandleDelegatedForUserDecryption`,inputs:[{name:`delegator`,type:`address`,internalType:`address`},{name:`delegate`,type:`address`,internalType:`address`},{name:`contractAddress`,type:`address`,internalType:`address`},{name:`handle`,type:`bytes32`,internalType:`bytes32`}],outputs:[{name:``,type:`bool`,internalType:`bool`}],stateMutability:`view`},{type:`function`,name:`multicall`,inputs:[{name:`data`,type:`bytes[]`,internalType:`bytes[]`}],outputs:[{name:`results`,type:`bytes[]`,internalType:`bytes[]`}],stateMutability:`payable`},{type:`function`,name:`persistAllowed`,inputs:[{name:`handle`,type:`bytes32`,internalType:`bytes32`},{name:`account`,type:`address`,internalType:`address`}],outputs:[{name:``,type:`bool`,internalType:`bool`}],stateMutability:`view`},{type:`function`,name:`revokeDelegationForUserDecryption`,inputs:[{name:`delegate`,type:`address`,internalType:`address`},{name:`contractAddress`,type:`address`,internalType:`address`}],outputs:[],stateMutability:`nonpayable`}];function Et(e,t,n,r){return{address:e,abi:K,functionName:`delegateForUserDecryption`,args:[t,n,r]}}function Dt(e,t,n){return{address:e,abi:K,functionName:`revokeDelegationForUserDecryption`,args:[t,n]}}function Ot(e,t,n,r){return{address:e,abi:K,functionName:`getUserDecryptionDelegationExpirationDate`,args:[t,n,r]}}function kt(e,t,n,r,i){return{address:e,abi:K,functionName:`isHandleDelegatedForUserDecryption`,args:[t,n,r,i]}}const At=2n**64n-1n;function jt(e){return et(e.signer,e.provider,e)}function Mt(e){return e.startsWith(`0x`)?e:`0x${e}`}var Nt=class{#e;#t;#n;#r;constructor(e){this.#e=e.signer,this.#t=e.provider,this.#n=e.router,this.#r=e.decryptionService}#i(e){return ve(this.#r,e)}async decryptValues(e,t){let n=this.#i(`decryptValues`),r=await T(`decryptValues`,this.#e,this.#t);return n.decryptValues(e,r.address,t)}async delegatedDecryptValues(e,t,n=t,r){let i=this.#i(`delegatedDecryptValues`),a=await T(`delegatedDecryptValues`,this.#e,this.#t);return i.delegatedDecryptValues(e,t,a.address,n,r)}async decryptPublicValues(e,t){if(e.length===0)return{clearValues:{},decryptionProof:`0x`,abiEncodedClearValues:`0x`};try{let n=await this.#n.relayer.decryptPublicValuesWithSignatures({encryptedValues:e,options:t}),r={};return n.checkSignaturesArgs.handlesList.forEach((e,t)=>{Be(n.clearValues[t],`result.clearValues[${t}]`),r[e]=n.clearValues[t].value}),{clearValues:r,abiEncodedClearValues:n.checkSignaturesArgs.abiEncodedCleartexts,decryptionProof:n.checkSignaturesArgs.decryptionProof}}catch(e){throw G(e,`Public decryption failed`)}}async delegatedBatchDecryptValues({encryptedInputs:e,delegatorAddress:t,accountAddress:n=t,maxConcurrency:r,waitForPropagation:i}){let a=this.#i(`delegatedBatchDecryptValues`),o=await T(`delegatedBatchDecryptValues`,this.#e,this.#t);return a.delegatedBatchDecryptHandlesAs({encryptedInputs:e,delegatorAddress:t,delegateAddress:o.address,accountAddress:n,maxConcurrency:r,waitForPropagation:i})}},Pt=class{#e;#t;#n;constructor(e){this.#e=e.signer,this.#t=e.provider,this.#n=e.delegationService}#r(e){return ve(this.#e,e)}async delegateDecryption({contractAddress:e,delegateAddress:t,expirationDate:n}){let r=this.#r(`delegateDecryption`),i=await T(`delegateDecryption`,this.#e,this.#t);return this.#n.delegateDecryption(r,{contractAddress:e,delegateAddress:t,delegatorAddress:i.address,expirationDate:n})}async revokeDelegation({contractAddress:e,delegateAddress:t}){let n=this.#r(`revokeDelegation`),r=await T(`revokeDelegation`,this.#e,this.#t);return this.#n.revokeDelegation(n,{contractAddress:e,delegateAddress:t,delegatorAddress:r.address})}async isActive(e){return this.#n.isDelegated(e)}async getExpiry(e){return this.#n.getDelegationExpiry(e)}async getStatus(e){return this.#n.getStatus(e)}},Ft=class{#e;#t;#n;#r;#i;constructor(e){this.#e=e.signer,this.#t=e.provider,this.#n=e.cachingService,this.#r=e.credentialService,this.#i=e.logger}#a(e){return ve(this.#r,e)}async grantPermit(e){if(e.length===0)return;let t=this.#a(`grantPermit`);await k(`grantPermit`,this.#e,this.#t),await t.grantPermit(e)}async grantDelegationPermit(e,t){if(t.length===0)return;let n=this.#a(`grantDelegationPermit`);await k(`grantDelegationPermit`,this.#e,this.#t),await n.grantPermit(t,e)}async hasPermit(e){return this.#r?this.#r.hasPermit(e):!1}async hasDelegationPermit(e,t){return this.#r?this.#r.hasPermit(t,e):!1}async warmTransportKeyPair(){let e=this.#r;if(!e)return;let t=this.#e?.walletAccount.getSnapshot();t&&await e.warmTransportKeyPair(t.address)}async revokePermits(e){let t=this.#a(`revokePermits`),n=F((await T(`revokePermits`,this.#e,this.#t)).address);try{await t.revokePermits(e)}finally{await this.#o(n)}}async clear(){let e=this.#a(`clear`),t=F((await T(`clear`,this.#e,this.#t)).address);try{await e.clearCredentials()}finally{await this.#o(t)}}async#o(e){await S(`clear decrypt cache`,()=>this.#n.clearForRequester(e),this.#i)}async revokeTransportKeyPair(e){await this.#a(`revokeTransportKeyPair`).revokeTransportKeyPair(e)}async warmTransportKeyPairScope(e){await this.#a(`warmTransportKeyPairScope`).warmTransportKeyPairScope(e)}};const It=I.union([I.bigint(),I.boolean(),tt]),Lt=I.array(I.string());var Rt=class{#e;#t;#n=`zama:decrypt`;#r=`${this.#n}:keys`;#i=Promise.resolve();constructor(e,t){this.#e=e,this.#t=t}async get(e,t,n){try{let r=this.#c(e,t,n),i=await this.#e.get(r);if(i===null)return null;let a=It.safeParse(i);return a.success?a.data:(await this.delete(e,t,n),null)}catch(e){return this.#t.warn(`CachingService.get failed`,{error:e}),null}}async set(e,t,n,r){try{let i=this.#c(e,t,n);await this.#e.set(i,r),this.#i=this.#i.then(()=>this.#u(i).catch(e=>{this.#t.warn(`CachingService index write failed`,{error:e})})),await this.#i}catch(e){this.#t.warn(`CachingService.set failed`,{error:e})}}async delete(e,t,n){let r=this.#c(e,t,n);this.#i=this.#i.then(()=>this.#a(r).catch(e=>{this.#t.warn(`CachingService.delete failed`,{error:e})})),await this.#i}async clearForRequester(e){this.#i=this.#i.then(()=>this.#o(e).catch(e=>{this.#t.warn(`CachingService.clearForRequester failed`,{error:e})})),await this.#i}async clearAll(){this.#i=this.#i.then(()=>this.#s().catch(e=>{this.#t.warn(`CachingService.clearAll failed`,{error:e})})),await this.#i}async#a(e){await this.#e.delete(e).catch(()=>{});let t=await this.#l(),n=t.filter(t=>t!==e);n.length!==t.length&&await this.#e.set(this.#r,n)}async#o(e){let t=F(e),n=`${this.#n}:${t}:`,r=await this.#l(),i=[],a=[];for(let e of r)e.startsWith(n)?i.push(e):a.push(e);await Promise.all(i.map(e=>this.#e.delete(e).catch(()=>{}))),await this.#e.set(this.#r,a)}async#s(){let e=await this.#l();await Promise.all(e.map(e=>this.#e.delete(e).catch(()=>{}))),await this.#e.delete(this.#r)}#c(e,t,n){return`${this.#n}:${F(e)}:${F(t)}:${n.toLowerCase()}`}async#l(){let e=await this.#e.get(this.#r);if(e===null)return[];let t=Lt.safeParse(e);return t.success?t.data:(await this.#e.delete(this.#r).catch(()=>{}),[])}async#u(e){let t=await this.#l();t.includes(e)||(t.push(e),await this.#e.set(this.#r,t))}};function zt(e,t){let n=Bt(e,t);if(!n)throw new C(`No permit covers contract ${t} after allow()`);return{privateKey:e.keypair.privateKey,publicKey:e.keypair.publicKey,serializedPermit:n.serializedPermit}}function Bt(e,t){let n=Ze(t);return e.permissions.find(e=>e.contractAddresses.includes(n))}const Vt=e=>new Promise(t=>setTimeout(t,e));var Ht=class{#e;#t;#n;#r;#i;constructor({cache:e,credentialService:t,delegationService:n,router:r,emitEvent:i}){this.#e=e,this.#t=t,this.#n=n,this.#r=r,this.#i=i}async decryptValues(e,t,n){let r=F(t);return this.#s(e,{requesterAddress:r,aclActorAddress:r,resolveCredentials:e=>this.#t.grantPermit(e),decryptContract:({credentials:e,contractAddress:t,encryptedValues:n,options:r})=>this.#o(e,t,n,r),errorMessage:`Failed to decrypt encrypted values`},n)}async delegatedDecryptValues(e,t,n,r,i){let a=F(t),o=F(n);return this.#a(i?.waitForPropagation??!0,()=>this.#s(e,{requesterAddress:F(r),aclActorAddress:a,resolveCredentials:e=>this.#t.grantPermit(e,a),validate:e=>this.#f(e,{delegatorAddress:a,delegateAddress:o}),decryptContract:({credentials:e,contractAddress:t,encryptedValues:n,options:r})=>this.#o(e,t,n,r),errorMessage:`Failed to decrypt delegated encrypted values`,delegated:!0}))}async#a(e,t){let n;for(let r=0;r<16;r++)try{return await t()}catch(t){if(n=t,!(r<15&&e&&t instanceof W))throw t;await Vt(2e3)}throw n}async delegatedBatchDecryptHandlesAs({encryptedInputs:e,delegatorAddress:t,delegateAddress:n,accountAddress:r,maxConcurrency:i=5,waitForPropagation:a=!0}){let o=e.map(e=>({encryptedValue:e.encryptedValue,contractAddress:F(e.contractAddress)}));if(o.length===0)return{items:o};let s=F(r);try{let e=await this.delegatedDecryptValues(o.map(({encryptedValue:e,contractAddress:t})=>({encryptedValue:e,contractAddress:t})),t,n,s,{waitForPropagation:a});for(let t of o)this.#l(t,e);return{items:o}}catch(e){if(Ve(e))throw e;if(o.length===1){let[n=this.#d()]=o;return n.error=this.#u(e,`Failed to decrypt delegated encrypted values`,{isDelegated:!0,contractAddress:n.contractAddress,account:F(t)}),{items:o}}}let c=!1;return await qe(o.map(e=>async()=>{if(!c)try{let r=await this.delegatedDecryptValues([{encryptedValue:e.encryptedValue,contractAddress:e.contractAddress}],t,n,s,{waitForPropagation:!1});this.#l(e,r)}catch(n){if(Ve(n))throw c=!0,n;e.error=this.#u(n,`Failed to decrypt delegated encrypted values`,{isDelegated:!0,contractAddress:e.contractAddress,account:F(t)})}}),i),{items:o}}async#o(e,t,n,i){let a=zt(e,t),o;try{o=await this.#r.relayer.parseTransportKeyPair({publicKey:a.publicKey,privateKey:a.privateKey,tkmsVersion:e.keypair.tkmsVersion})}catch(e){throw e instanceof Error&&r(e.message)&&await this.#t.evictTransportKeyPair(),e}let s=await this.#r.relayer.parseSignedDecryptionPermit({transportKeyPair:o,serializedPermit:a.serializedPermit});return this.#r.relayer.decryptValues({transportKeyPair:o,signedPermit:s,encryptedValues:n,contractAddress:t,options:i})}async#s(t,n,r){if(t.length===0)return{};let i=t.map(e=>({encryptedValue:e.encryptedValue,contractAddress:F(e.contractAddress)})),a={},s=[];for(let e of i)E(e.encryptedValue)?a[e.encryptedValue]=0n:s.push(e);if(s.length===0)return a;let c=Array.from(new Set(i.map(e=>e.contractAddress))),l=Array.from(new Set(s.map(e=>e.contractAddress)));if(n.validate)try{await n.validate(l)}catch(e){throw o(e)?this.#c(e,`the delegation pre-check`):e}let u=[];for(let e of s){let t=await this.#e.get(n.requesterAddress,e.contractAddress,e.encryptedValue);t===null?u.push(e):a[e.encryptedValue]=t}if(u.length===0)return a;let d=await n.resolveCredentials(c),f=new Map;for(let e of u){let t=f.get(e.contractAddress);t?t.push(e.encryptedValue):f.set(e.contractAddress,[e.encryptedValue])}let m=[];for(let[e,t]of f)for(let n of ze(t))m.push({contractAddress:e,encryptedValues:n});let ee=Date.now(),h=u.map(e=>e.encryptedValue);try{this.#i({type:y.DecryptStart,encryptedValues:h}),await qe(m.map(({contractAddress:e,encryptedValues:t})=>async()=>{let i;try{i=await n.decryptContract({credentials:d,contractAddress:e,encryptedValues:t,options:r})}catch(t){throw G(t,n.errorMessage,{isDelegated:n.delegated,contractAddress:e,account:n.aclActorAddress})}for(let r=0;r<t.length;r++){let o=t[r],s=i[r]?.value;o!==void 0&&s!==void 0&&(a[o]=s,await this.#e.set(n.requesterAddress,e,o,s))}let o=t.filter(e=>a[e]===void 0);if(o.length>0)throw new C(`${n.errorMessage}: relayer returned no clear value for ${o.length} of ${t.length} handle(s) on ${e}`,{cause:AggregateError(o.map(t=>new C(`No clear value for handle ${t} on ${e}`)),`${o.length} handle(s) missing a clear value on ${e}`)})}),5);let e={};for(let t of h){let n=a[t];n!==void 0&&(e[t]=n)}return this.#i({type:y.DecryptEnd,durationMs:Date.now()-ee,encryptedValues:h,result:e}),a}catch(t){let r=t instanceof p&&t.cause instanceof Error?t.cause:t;throw this.#i({type:y.DecryptError,error:e(r),durationMs:Date.now()-ee,encryptedValues:h}),G(t,n.errorMessage,{isDelegated:n.delegated})}}#c(e,t){return new A(`RPC provider rate-limited ${t}; retry with backoff.`,{cause:e,retryAfter:n(e)})}#l(e,t){let n=t[e.encryptedValue];if(n===void 0){e.error=new C(`Batch delegated decryption returned no value for encrypted value ${e.encryptedValue} on contract ${e.contractAddress}`);return}e.value=n}#u(e,t,n){return e instanceof p?e:G(e,t,n)}#d(){throw new C(`Batch delegated decryption invariant failed: missing item`)}async#f(e,{delegatorAddress:t,delegateAddress:n}){let r=await this.#n.findInactiveDelegations(e,t,n);if(r.size!==0)for(let e of r.values())throw e}};function Ut(e){if(!(e instanceof Error))return null;let t=e.cause;if(typeof t!=`object`||!t||!(`data`in t))return null;let{data:n}=t;return typeof n!=`object`||!n||!(`errorName`in n)?null:typeof n.errorName==`string`?n.errorName:null}const Wt={AlreadyDelegatedOrRevokedInSameBlock:e=>new yt(`Only one delegate/revoke per (delegator, delegate, contract) per block. Wait for the next block before retrying.`,{cause:e}),SenderCannotBeContractAddress:e=>new bt(`The contract address cannot be the caller address.`,{cause:e}),EnforcedPause:e=>new xt(`The ACL contract is paused. Delegation operations are temporarily disabled.`,{cause:e}),SenderCannotBeDelegate:e=>new R(`Cannot delegate to yourself (delegate === msg.sender).`,{cause:e}),DelegateCannotBeContractAddress:e=>new H(`Delegate address cannot be the same as the contract address.`,{cause:e}),ExpirationDateBeforeOneHour:e=>new U(`Expiration date must be at least 1 hour in the future.`,{cause:e}),ExpirationDateAlreadySetToSameValue:e=>new V(`The new expiration date is the same as the current one.`,{cause:e}),NotDelegatedYet:e=>new z(`Cannot revoke: no active delegation exists.`,{cause:e})};function Gt(e){return e in Wt}function Kt(e,t){let n=Ut(e);if(n&&Gt(n))return Wt[n](t);let r=e instanceof Error?e.message:String(e);for(let[e,n]of Object.entries(Wt))if(r.includes(e))return n(t);return null}var qt=class{#e;#t;#n;#r;constructor({provider:e,router:t,emitEvent:n=()=>{},logger:r}){this.#t=e,this.#e=t,this.#r=r,this.#n=n}async delegateDecryption(e,{contractAddress:t,delegateAddress:n,delegatorAddress:r,expirationDate:i}){if(i&&i.getTime()<Date.now()+36e5)throw new U(`Expiration date must be at least 1 hour in the future`);let a=F(t),o=F(n),s=F(r);if(o===s)throw new R(`Cannot delegate to yourself (delegate === msg.sender).`);if(o===a)throw new H(`Delegate address cannot be the same as the contract address (${a}).`);let c=this.#e.relayer.chain.aclContractAddress,l=i?BigInt(Math.floor(i.getTime()/1e3)):At,u;try{u=await this.getDelegationExpiry({contractAddress:a,delegatorAddress:s,delegateAddress:o})}catch(e){this.#r.warn(`delegateDecryption: pre-flight expiry check failed`,{error:e}),u=-1n}if(u===l)throw new V(`The new expiration date (${l}) is the same as the current one. No on-chain change needed.`);return this.#i({operation:`delegateDecryption`,signer:e,contractAddress:t,config:Et(c,o,a,l)})}async revokeDelegation(e,{contractAddress:t,delegateAddress:n,delegatorAddress:r}){let i=F(t),a=F(n),o=F(r),s=this.#e.relayer.chain.aclContractAddress,c;try{c=await this.getDelegationExpiry({contractAddress:i,delegatorAddress:o,delegateAddress:a})}catch(e){this.#r.warn(`revokeDelegation: pre-flight expiry check failed`,{error:e}),c=1n}if(c===0n)throw new z(`No active delegation found for delegate ${a} on contract ${i}.`);return this.#i({operation:`revokeDelegation`,signer:e,contractAddress:t,config:Dt(s,a,i)})}async isDelegated(e){return(await this.getStatus(e)).isActive}async getStatus(e){let t=await this.getDelegationExpiry(e);return t===0n?{isActive:!1,expiryTimestamp:t}:t===At?{isActive:!0,expiryTimestamp:t}:{isActive:t>await this.#t.getBlockTimestamp(),expiryTimestamp:t}}async getDelegationExpiry({contractAddress:e,delegatorAddress:t,delegateAddress:n}){let r=this.#e.relayer.chain.aclContractAddress;return this.#t.readContract(Ot(r,F(t),F(n),F(e)))}async#i({operation:e,signer:t,contractAddress:n,config:r}){try{return await Ke({operation:e,signer:t,provider:this.#t,config:r,emit:e=>this.#n(e,n),logger:this.#r})}catch(e){throw this.#a(e),e}}#a(e){if(!(e instanceof M))return;let t=Kt(e.cause??e,e);if(t)throw t}async findInactiveDelegations(e,t,n){let r=new Map;return await Promise.all(e.map(async e=>{try{await this.assertDelegationActive(e,t,n)}catch(t){if(t instanceof z||t instanceof B){let n=F(e);r.set(n,t);return}throw t}})),r}async assertDelegationActive(e,t,n){let r=F(e),i=F(t),a=F(n),{isActive:o,expiryTimestamp:s}=await this.getStatus({contractAddress:r,delegatorAddress:i,delegateAddress:a});if(!o)throw s===0n?new z(`No active delegation from ${i} to ${a} for ${r}`):new B(`Delegation from ${i} to ${a} for ${r} has expired`)}},Jt=class{#e;#t;constructor({router:e,emitEvent:t}){this.#e=e,this.#t=t}async encryptValues(t,n){let r=Date.now(),i=F(t.contractAddress);try{this.#t({type:y.EncryptStart},i);let e=await this.#e.relayer.encryptValues({...t,options:n});return this.#t({type:y.EncryptEnd,durationMs:Date.now()-r},i),e}catch(t){throw this.#t({type:y.EncryptError,error:e(t),durationMs:Date.now()-r},i),Ct(t,`Encryption failed`)}}},Yt=class{#e;#t;#n;#r;#i;#a=new Set;#o;constructor(e){this.#e=e.signer,this.#t=e.router,this.#n=e.cachingService,this.#r=e.credentialService,this.#i=e.logger,this.#e&&(this.#o=this.#e.walletAccount.subscribe(e=>{this.#s(e).catch(e=>{this.#i.warn(`wallet account handler failed`,{error:e})})}))}onWalletAccountChange(e){return this.#a.add(e),()=>{this.#a.delete(e)}}dispose(){this.#o?.(),this.#o=void 0,this.#a.clear()}async#s(e){let t=e.previous,n=e.next,r=n?.chainId;r!==void 0&&await S(`switch relayer chain`,()=>this.#t.switchChain(r),this.#i);let i=this.#r;i&&await S(`credential wallet account change`,()=>i.handleWalletAccountChange(t,n),this.#i),t&&await S(`clear decrypt cache`,()=>this.#n.clearForRequester(t.address),this.#i),await Promise.all(Array.from(this.#a,t=>S(`wallet account listener`,()=>t(e),this.#i)))}};function q(e){return gt(_t(e))}const J={ConfidentialTransfer:q(`ConfidentialTransfer(address,address,bytes32)`),Wrap:q(`Wrap(address,uint256,bytes32)`),UnwrapRequested:q(`UnwrapRequested(address,bytes32,bytes32)`),UnwrapFinalized:q(`UnwrapFinalized(address,bytes32,bytes32,uint64)`)};function Y(e){return F(Mt(e.slice(-40)))}function Xt(e){return e}function Zt(e,t){let n=2+t*64,r=e.slice(n,n+64);return r.length===64?r:r.padEnd(64,`0`)}function Qt(e,t){return F(Mt(Zt(e,t).slice(-40)))}function X(e,t){return BigInt(`0x`+Zt(e,t))}function $t(e,t){return Mt(Zt(e,t))}function en(e){return e.topics[0]!==J.ConfidentialTransfer||e.topics.length<4?null:{eventName:`ConfidentialTransfer`,from:Y(e.topics[1]),to:Y(e.topics[2]),encryptedAmount:Xt(e.topics[3])}}function tn(e){return e.topics[0]!==J.Wrap||e.topics.length<2?null:{eventName:`Wrap`,to:Y(e.topics[1]),roundedAmount:X(e.data,0),encryptedWrappedAmount:$t(e.data,1)}}function Z(e){return e.topics[0]!==J.UnwrapRequested||e.topics.length<3?null:{eventName:`UnwrapRequested`,receiver:Y(e.topics[1]),unwrapRequestId:Xt(e.topics[2]),encryptedAmount:$t(e.data,0)}}function nn(e){return e.topics[0]!==J.UnwrapFinalized||e.topics.length<3?null:{eventName:`UnwrapFinalized`,receiver:Y(e.topics[1]),unwrapRequestId:Xt(e.topics[2]),encryptedAmount:$t(e.data,0),cleartextAmount:X(e.data,1)}}function rn(e){return en(e)??tn(e)??Z(e)??nn(e)}function an(e){let t=[];for(let n of e){let e=rn(n);e&&t.push(e)}return t}function on(e){for(let t of e){let e=Z(t);if(e)return e}return null}function sn(e){for(let t of e){let e=tn(t);if(e)return e}return null}const cn=[J.ConfidentialTransfer,J.Wrap,J.UnwrapRequested,J.UnwrapFinalized],Q={DelegatedForUserDecryption:q(`DelegatedForUserDecryption(address,address,address,uint64,uint64,uint64)`),RevokedDelegationForUserDecryption:q(`RevokedDelegationForUserDecryption(address,address,address,uint64,uint64)`)};function ln(e){return e.topics[0]!==Q.DelegatedForUserDecryption||e.topics.length<3?null:{eventName:`DelegatedForUserDecryption`,delegator:Y(e.topics[1]),delegate:Y(e.topics[2]),contractAddress:Qt(e.data,0),delegationCounter:X(e.data,1),oldExpirationDate:X(e.data,2),newExpirationDate:X(e.data,3)}}function un(e){return e.topics[0]!==Q.RevokedDelegationForUserDecryption||e.topics.length<3?null:{eventName:`RevokedDelegationForUserDecryption`,delegator:Y(e.topics[1]),delegate:Y(e.topics[2]),contractAddress:Qt(e.data,0),delegationCounter:X(e.data,1),oldExpirationDate:X(e.data,2)}}function dn(e){return ln(e)??un(e)}function fn(e){let t=[];for(let n of e){let e=dn(n);e&&t.push(e)}return t}function pn(e){for(let t of e){let e=ln(t);if(e)return e}return null}function mn(e){for(let t of e){let e=un(t);if(e)return e}return null}const hn=[Q.DelegatedForUserDecryption,Q.RevokedDelegationForUserDecryption];function $(e){return`zama:pending-unshield:${Ze(e)}`}const gn=I.union([I.pipe(P,I.transform(e=>({unwrapTxHash:e}))),I.pipe(I.object({version:I.literal(1),unwrapTxHash:P,unwrapRequestId:I.optional(P)}),I.transform(({unwrapTxHash:e,unwrapRequestId:t})=>({unwrapTxHash:e,unwrapRequestId:t})))]);async function _n(e,t,n,r){if(r===void 0){await e.set($(t),n);return}await e.set($(t),{version:1,unwrapTxHash:n,unwrapRequestId:r})}async function vn(e,t){return(await yn(e,t))?.unwrapTxHash??null}async function yn(e,t){let n=$(t),r=await e.get(n);if(r==null)return null;let i=gn.safeParse(r);return i.success?i.data:(await e.delete(n),null)}async function bn(e,t){await e.delete($(t))}var xn=class extends O{#e;#t=null;#n=null;#r(e){try{return Be(this.sdk.signer,`WrappedToken.sdk.signer`),this.sdk.signer}catch(t){throw new te(e,{cause:t})}}async underlying(){return this.#s()}async isPayable(){if(this.#n!==null)return this.#n;try{let e=await this.#s();this.#n=await this.sdk.provider.readContract(Ee(e))}catch{this.#n=!1}return this.#n}async allowance(e){let t=await this.#s();return this.sdk.provider.readContract(v(t,F(e),this.address))}async shield(t,n){let r=await T(`shield`,this.sdk.signer,this.sdk.provider),i=await this.isPayable(),a=await this.#s(),o=F(r.address),s;try{s=await this.sdk.provider.readContract(x(a,o))}catch(t){throw t instanceof p?t:new D(`Could not read ERC-20 balance for shield validation (token: ${a})`,{cause:e(t)})}if(s<t)throw new w(`Insufficient ERC-20 balance: requested ${t}, available ${s} (token: ${a})`,{requested:t,available:s,token:a});return i?this.#i(t,a,o,n):this.#a(t,o,n)}async#i(e,t,n,r){this.#r(`shield`);let i=r?.to?F(r.to):n,a=i===n?`0x`:i;return this.submitTransaction({operation:`shield:transferAndCall`,config:Tt(t,this.address,e,a),onSubmitted:r?.onShieldSubmitted})}async wrap(t,n){this.#r(`wrap`);let r=await T(`wrap`,this.sdk.signer,this.sdk.provider),i=await this.#s(),a=F(r.address),o;try{o=await this.sdk.provider.readContract(x(i,a))}catch(t){throw t instanceof p?t:new D(`Could not read ERC-20 balance for wrap validation (token: ${i})`,{cause:e(t)})}if(o<t)throw new w(`Insufficient ERC-20 balance: requested ${t}, available ${o} (token: ${i})`,{requested:t,available:o,token:i});let s;try{s=await this.sdk.provider.readContract(v(i,a,this.address))}catch(t){throw t instanceof p?t:new D(`Could not read ERC-20 allowance for wrap validation (token: ${i})`,{cause:e(t)})}if(s<t)throw new Ge(`Insufficient allowance for wrap: requested ${t}, approved ${s}. Call approveUnderlying() first (token: ${i}).`,{requested:t,available:s,token:i});let c=n?.to?F(n.to):a;return this.submitTransaction({operation:`wrap`,config:pe(this.address,c,t),onSubmitted:n?.onWrapSubmitted})}async#a(e,t,n){this.#r(`shield`);let r=n?.approvalStrategy??`exact`;r!==`skip`&&await this.#l(e,r===`max`,n);let i=n?.to?F(n.to):t;return this.submitTransaction({operation:`shield:approveAndWrap`,config:pe(this.address,i,e),onSubmitted:n?.onShieldSubmitted})}async approveUnderlying(e){this.#r(`approveUnderlying`);let t=await T(`approveUnderlying`,this.sdk.signer,this.sdk.provider),n=await this.#s(),r=F(t.address),i=e??2n**256n-1n;return i>0n&&await this.sdk.provider.readContract(v(n,r,this.address))>0n&&await this.submitTransaction({operation:`approveUnderlying:reset`,config:b(n,this.address,0n)}),this.submitTransaction({operation:`approveUnderlying`,config:b(n,this.address,i)})}async unshield(e,t){let{skipBalanceCheck:n=!1,onUnwrapSubmitted:r,onFinalizing:i,onFinalizeSubmitted:a}=t??{};n||await this.assertConfidentialBalance(e);let o={onFinalizing:i,onFinalizeSubmitted:a},s=crypto.randomUUID(),c=await this.unwrap(e);return S(`unshield: onUnwrapSubmitted`,()=>r?.(c.txHash),this.sdk.logger),this.#c(c.unwrapRequestId,c.txHash,s,o)}async unshieldAll(e){let t=crypto.randomUUID(),n=await this.unwrapAll();return S(`unshieldAll: onUnwrapSubmitted`,()=>e?.onUnwrapSubmitted?.(n.txHash),this.sdk.logger),this.#c(n.unwrapRequestId,n.txHash,t,e)}async resumeUnshield(e,t){let n;try{n=await this.sdk.provider.waitForTransactionReceipt(e)}catch(e){throw e instanceof p?e:new M(`Failed to get unwrap receipt`,{cause:e})}let r=this.#o(n.logs);return this.#c(r,e,crypto.randomUUID(),t)}async getPendingUnshield(){return vn(this.sdk.storage,this.address)}async unwrap(e){this.#r(`unwrap`);let t=F((await T(`unwrap`,this.sdk.signer,this.sdk.provider)).address),{encryptedValues:n,inputProof:r}=await this.sdk.encrypt({values:[{value:e,type:`euint64`}],contractAddress:this.address,userAddress:t}),[i]=n;if(!i)throw new j(`Encryption returned no encrypted values`);let a=await this.submitTransaction({operation:`unwrap`,config:se(this.address,t,t,i,r)});return{...a,unwrapRequestId:this.#o(a.receipt.logs)}}async unwrapAll(){this.#r(`unwrapAll`);let e=F((await T(`unwrapAll`,this.sdk.signer,this.sdk.provider)).address),t=await this.readConfidentialBalanceOf(e);if(E(t))throw new C(`Cannot unshield: balance is zero`);let n=await this.submitTransaction({operation:`unwrapAll`,config:le(this.address,e,e,t)});return{...n,unwrapRequestId:this.#o(n.receipt.logs)}}async finalizeUnwrap(e){this.#r(`finalizeUnwrap`),await k(`finalizeUnwrap`,this.sdk.signer,this.sdk.provider);let t=await this.sdk.decryption.decryptPublicValues([e]),n=t.clearValues[e];return Je(n,`finalizeUnwrap: clearValue`),this.submitTransaction({operation:`finalizeUnwrap`,config:h(this.address,e,n,t.decryptionProof)})}#o(e){let t=on(e);if(!t)throw new M(`No UnwrapRequested event found in unwrap receipt`);return t.unwrapRequestId}async#s(){return this.#e===void 0?(this.#t||=this.sdk.provider.readContract(ie(this.address)).then(e=>(this.#e=e,this.#t=null,e)).catch(e=>{throw this.#t=null,e}),this.#t):this.#e}async#c(e,t,n,r){this.emit({type:y.UnshieldPhase1Submitted,txHash:t,operationId:n}),await S(`unshield: savePendingUnshield`,()=>_n(this.sdk.storage,this.address,t),this.sdk.logger),this.emit({type:y.UnshieldPhase2Started,operationId:n}),S(`unshield: onFinalizing`,()=>r?.onFinalizing?.(),this.sdk.logger);let i=await this.finalizeUnwrap(e);return this.emit({type:y.UnshieldPhase2Submitted,txHash:i.txHash,operationId:n}),S(`unshield: onFinalizeSubmitted`,()=>r?.onFinalizeSubmitted?.(i.txHash),this.sdk.logger),await S(`unshield: clearPendingUnshield`,()=>bn(this.sdk.storage,this.address),this.sdk.logger),i}async#l(e,t,n){this.#r(`approveUnderlying`);let r=await this.#s(),i=F((await T(`approveUnderlying`,this.sdk.signer,this.sdk.provider)).address),a=await this.sdk.provider.readContract(v(r,i,this.address));if(a>=e)return;a>0n&&await this.submitTransaction({operation:`approveUnderlying:reset`,config:b(r,this.address,0n)});let o=t?2n**256n-1n:e;await this.submitTransaction({operation:`approveUnderlying`,config:b(r,this.address,o),onSubmitted:n?.onApprovalSubmitted})}},Sn=class{#e;provider;signer;storage;registry;permits;delegations;decryption;#t;#n;#r;#i;#a;#o;#s;#c;#l;#u;constructor(e){this.#e=e.router,this.provider=e.provider,this.signer=e.signer,this.storage=e.storage,this.#r=e.onEvent??function(){},this.#i=e.logger,this.#a=new Rt(e.storage,this.#i),this.#u=new qt({provider:this.provider,router:e.router,emitEvent:this.emitEvent.bind(this),logger:this.#i});let t={};for(let n of e.chains)n.registryAddress&&(t[n.id]=n.registryAddress);this.registry=new N({provider:this.provider,registryAddresses:t,registryTTL:e.registryTTL}),this.#n=t,this.#t=e.registryTTL,e.signer&&(this.#l=new ot({router:e.router,signer:e.signer,transportKeyPairTTL:e.transportKeyPairTTL,permitTTL:e.permitTTL,scope:e.transportKeyPairScope,storage:this.storage,permitStorage:e.permitStorage,logger:this.#i}),this.#c=new Ht({cache:this.#a,credentialService:this.#l,delegationService:this.#u,router:e.router,emitEvent:this.emitEvent.bind(this)})),this.#s=new Jt({router:e.router,emitEvent:this.emitEvent.bind(this)}),this.#o=new Yt({signer:e.signer,router:e.router,cachingService:this.#a,credentialService:this.#l,logger:this.#i}),this.permits=new Ft({signer:this.signer,provider:this.provider,cachingService:this.#a,credentialService:this.#l,logger:this.#i}),this.delegations=new Pt({signer:this.signer,provider:this.provider,delegationService:this.#u}),this.decryption=new Nt({signer:this.signer,provider:this.provider,router:e.router,decryptionService:this.#c})}onWalletAccountChange(e){return this.#o.onWalletAccountChange(e)}get logger(){return this.#i}get relayer(){return this.#e.relayer}emitEvent(e,t){try{this.#r({...e,tokenAddress:t,timestamp:Date.now()})}catch(t){this.#i.warn(`${e.type} event listener silently failed`,{error:t})}}createWrappersRegistry(e){return new N({provider:this.provider,registryAddresses:{...this.#n,...e},registryTTL:this.#t})}async encrypt(e,t){return this.#s.encryptValues(e,t)}createToken(e){return new O(this,e)}createWrappedToken(e){return new xn(this,e)}dispose(){this.#o.dispose()}terminate(){this.dispose(),this.signer?.dispose?.()}[Symbol.dispose](){this.terminate()}},Cn=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 wn=new Cn;export{hn as ACL_TOPICS,xt as AclPausedError,Q as AclTopics,He as BalanceCheckUnavailableError,st as BaseSigner,Re as ChainMismatchError,Cn as ChromeSessionStorage,ee as ConfigurationError,Nt as Decryption,C as DecryptionFailedError,Xe as DefaultRegistryAddresses,bt as DelegationContractIsSelfError,yt as DelegationCooldownError,H as DelegationDelegateEqualsContractError,U as DelegationExpirationTooSoonError,B as DelegationExpiredError,V as DelegationExpiryUnchangedError,z as DelegationNotFoundError,W as DelegationNotPropagatedError,R as DelegationSelfNotAllowedError,Pt as Delegations,Ie as ERC1363_INTERFACE_ID,D as ERC20ReadFailedError,Ce as ERC7984_INTERFACE_ID,we as ERC7984_WRAPPER_INTERFACE_ID,j as EncryptionFailedError,it as IndexedDBStorage,Ge as InsufficientAllowanceError,Ue as InsufficientConfidentialBalanceError,w as InsufficientERC20BalanceError,g as InvalidTransportKeyPairError,Qe as MemoryStorage,rt as MutableWalletAccountStore,_ as NoCiphertextError,L as NotEntitledError,Ft as Permits,u as RelayerRequestFailedError,A as RpcRateLimitError,te as SignerNotConfiguredError,_e as SignerRequiredError,ae as SigningFailedError,ce as SigningRejectedError,cn as TOKEN_TOPICS,O as Token,J as Topics,M as TransactionRevertedError,ye as TransportKeyPairExpiredError,oe as WalletAccountNotReadyError,ge as WalletNotConnectedError,xn as WrappedToken,N as WrappersRegistry,We as ZERO_ENCRYPTED_VALUE,p as ZamaError,s as ZamaErrorCode,Sn as ZamaSDK,y as ZamaSDKEvents,v as allowanceContract,ht as anvil,b as approveContract,x as balanceOfContract,dt as bscTestnet,pt as chains,wn as chromeSessionStorage,Ye as cleartext,Le as confidentialBalanceOfContract,he as confidentialTotalSupplyContract,re as confidentialTransferContract,ke as confidentialTransferFromContract,jt as createConfig,at as createWalletAccountStore,xe as decimalsContract,dn as decodeAclEvent,fn as decodeAclEvents,en as decodeConfidentialTransfer,ln as decodeDelegatedForUserDecryption,rn as decodeOnChainEvent,an as decodeOnChainEvents,un as decodeRevokedDelegationForUserDecryption,nn as decodeUnwrapFinalized,Z as decodeUnwrapRequested,tn as decodeWrap,Et as delegateForUserDecryptionContract,h as finalizeUnwrapContract,pn as findDelegatedForUserDecryption,mn as findRevokedDelegationForUserDecryption,on as findUnwrapRequested,sn as findWrap,Pe as getConfidentialTokenAddressContract,Ot as getDelegationExpiryContract,De as getTokenAddressContract,be as getTokenPairContract,Me as getTokenPairsContract,Fe as getTokenPairsLengthContract,Se as getTokenPairsSliceContract,ut as hardhat,ct as hoodi,nt as indexedDBStorage,Oe as inferredTotalSupplyContract,ft as ingenTestnet,Ne as isConfidentialTokenContract,Ae as isConfidentialTokenValidContract,je as isConfidentialWrapperContract,E as isEncryptedValueZero,kt as isHandleDelegatedContract,ue as isOperatorContract,t as isRetryable,mt as mainnet,vt as matchZamaError,$e as memoryStorage,me as nameContract,de as rateContract,d as retryAfterSeconds,Dt as revokeDelegationContract,lt as sepolia,fe as setOperatorContract,Te as supportsInterfaceContract,ne as symbolContract,Tt as transferAndCallContract,ie as underlyingContract,se as unwrapContract,le as unwrapFromBalanceContract,pe as wrapContract};
|
|
1
|
+
import{_ as e,a as t,c as n,d as r,f as i,g as a,h as o,i as s,l as c,m as l,n as u,o as d,p as f,r as p,s as m,t as ee}from"./relayer-BWHOLVcG.js";import{A as h,B as te,C as ne,D as re,F as ie,G as ae,H as oe,I as se,J as g,K as ce,L as le,M as ue,N as de,P as fe,R as pe,S as me,T as he,U as ge,V as _e,W as ve,X as ye,Y as _,_ as v,a as be,b as xe,c as Se,d as Ce,f as we,g as Te,h as Ee,i as De,j as Oe,k as ke,l as Ae,m as je,o as Me,p as Ne,r as Pe,s as Fe,t as y,u as Ie,v as b,w as Le,y as x,z as S}from"./sdk-events-D68bJ5jT.js";import{_ as Re,a as ze,b as C,c as Be,d as Ve,f as He,g as w,h as Ue,i as We,l as T,m as Ge,n as Ke,o as E,p as D,r as qe,s as Je,t as O,u as k,v as A,x as j,y as M}from"./token-Bn8I7xAu.js";import{t as Ye}from"./cleartext-Qqh5JohW.js";import{a as Xe,c as Ze,d as Qe,f as $e,i as et,l as tt,m as nt,n as rt,o as N,p as it,r as at,s as ot,t as st,u as P}from"./base-signer-BGEnALwn.js";import{a as ct,c as lt,i as ut,l as dt,n as ft,o as pt,r as mt,s as ht,t as gt}from"./chains-BoqPSzrs.js";import{getAddress as F,keccak256 as _t,toBytes as vt}from"viem";import{z as I}from"zod/mini";function yt(e,t){if(e instanceof p){let n=t[e.code];if(n)return n(e)}return t._?.(e)}var L=class extends p{encryptedValue;contractAddress;account;constructor(e,t){super(s.NotEntitled,`Account ${e.account} is not entitled to decrypt encrypted value ${e.encryptedValue} on contract ${e.contractAddress}. This is not a transient failure — the account needs an on-chain ACL grant before it can decrypt this encrypted value.`,t),this.name=`NotEntitledError`,this.encryptedValue=e.encryptedValue,this.contractAddress=e.contractAddress,this.account=e.account}},R=class extends p{constructor(e,t){super(s.DelegationSelfNotAllowed,e,t),this.name=`DelegationSelfNotAllowedError`}},bt=class extends p{constructor(e,t){super(s.DelegationCooldown,e,t),this.name=`DelegationCooldownError`}},z=class extends p{constructor(e,t){super(s.DelegationNotFound,e,t),this.name=`DelegationNotFoundError`}},B=class extends p{constructor(e,t){super(s.DelegationExpired,e,t),this.name=`DelegationExpiredError`}},V=class extends p{constructor(e,t){super(s.DelegationExpiryUnchanged,e,t),this.name=`DelegationExpiryUnchangedError`}},H=class extends p{constructor(e,t){super(s.DelegationDelegateEqualsContract,e,t),this.name=`DelegationDelegateEqualsContractError`}},xt=class extends p{constructor(e,t){super(s.DelegationContractIsSelf,e,t),this.name=`DelegationContractIsSelfError`}},St=class extends p{constructor(e,t){super(s.AclPaused,e,t),this.name=`AclPausedError`}},U=class extends p{constructor(e,t){super(s.DelegationExpirationTooSoon,e,t),this.name=`DelegationExpirationTooSoonError`}},W=class extends p{constructor(e,t){super(s.DelegationNotPropagated,e,t),this.name=`DelegationNotPropagatedError`}};const Ct=[C,_,u,W,ce,ae,L,A,g];function G(e,t,s={}){if(Ct.some(t=>e instanceof t))return e;let d=e instanceof Error?e.message:t;if(e instanceof Error&&r(e.message))return new g(e.message,{cause:e});if(e instanceof Error&&i(e.message))return s.isDelegated?new W(`Delegated decryption was denied by the on-chain ACL check. This is most commonly caused by the delegation not having propagated yet, or by the RPC node serving a stale block. Propagation usually completes within ~10 blocks (a few seconds) and the SDK retries across that window; seeing this means it did not sync in time. Retry shortly (and prefer a fresh, low-lag RPC endpoint). If it persists, the delegator may genuinely lack the on-chain ACL grant.`,{cause:e}):new L({encryptedValue:a(e.message)??``,contractAddress:s.contractAddress??``,account:s.account??``},{cause:e});if(c(e))return new A(d,{cause:e,retryAfter:n(e)});let p=m(e);return p===void 0&&o(e)?new A(d,{cause:e,retryAfter:n(e)}):p===400?new _(e instanceof Error?e.message:`No ciphertext for this account`,{cause:e}):s.isDelegated&&p===500?new W(`Delegated decryption failed with a server error. This is most commonly caused by the delegation not having propagated to the gateway yet. Cross-chain sync usually completes within ~10 blocks (a few seconds) and the SDK retries across that window; seeing this means it did not sync in time — retry shortly. If the error persists, the gateway or relayer may be experiencing an unrelated issue.`,{cause:e}):f(e)||p!==void 0?new u(d,p,{cause:e,retryAfter:n(e),retryable:l(e)||void 0}):new C(t,{cause:e})}function wt(e,t){if(e instanceof p)return e;let r=m(e),i=l(e);return r!==void 0||f(e)?new u(e instanceof Error?e.message:t,r,{cause:e,retryAfter:n(e),retryable:i||void 0}):new j(t,{cause:e})}const Tt=[{type:`function`,name:`allowance`,inputs:[{name:`owner`,type:`address`,internalType:`address`},{name:`spender`,type:`address`,internalType:`address`}],outputs:[{name:``,type:`uint256`,internalType:`uint256`}],stateMutability:`view`},{type:`function`,name:`approve`,inputs:[{name:`spender`,type:`address`,internalType:`address`},{name:`value`,type:`uint256`,internalType:`uint256`}],outputs:[{name:``,type:`bool`,internalType:`bool`}],stateMutability:`nonpayable`},{type:`function`,name:`approveAndCall`,inputs:[{name:`spender`,type:`address`,internalType:`address`},{name:`value`,type:`uint256`,internalType:`uint256`}],outputs:[{name:``,type:`bool`,internalType:`bool`}],stateMutability:`nonpayable`},{type:`function`,name:`approveAndCall`,inputs:[{name:`spender`,type:`address`,internalType:`address`},{name:`value`,type:`uint256`,internalType:`uint256`},{name:`data`,type:`bytes`,internalType:`bytes`}],outputs:[{name:``,type:`bool`,internalType:`bool`}],stateMutability:`nonpayable`},{type:`function`,name:`balanceOf`,inputs:[{name:`account`,type:`address`,internalType:`address`}],outputs:[{name:``,type:`uint256`,internalType:`uint256`}],stateMutability:`view`},{type:`function`,name:`supportsInterface`,inputs:[{name:`interfaceId`,type:`bytes4`,internalType:`bytes4`}],outputs:[{name:``,type:`bool`,internalType:`bool`}],stateMutability:`view`},{type:`function`,name:`totalSupply`,inputs:[],outputs:[{name:``,type:`uint256`,internalType:`uint256`}],stateMutability:`view`},{type:`function`,name:`transfer`,inputs:[{name:`to`,type:`address`,internalType:`address`},{name:`value`,type:`uint256`,internalType:`uint256`}],outputs:[{name:``,type:`bool`,internalType:`bool`}],stateMutability:`nonpayable`},{type:`function`,name:`transferAndCall`,inputs:[{name:`to`,type:`address`,internalType:`address`},{name:`value`,type:`uint256`,internalType:`uint256`}],outputs:[{name:``,type:`bool`,internalType:`bool`}],stateMutability:`nonpayable`},{type:`function`,name:`transferAndCall`,inputs:[{name:`to`,type:`address`,internalType:`address`},{name:`value`,type:`uint256`,internalType:`uint256`},{name:`data`,type:`bytes`,internalType:`bytes`}],outputs:[{name:``,type:`bool`,internalType:`bool`}],stateMutability:`nonpayable`},{type:`function`,name:`transferFrom`,inputs:[{name:`from`,type:`address`,internalType:`address`},{name:`to`,type:`address`,internalType:`address`},{name:`value`,type:`uint256`,internalType:`uint256`}],outputs:[{name:``,type:`bool`,internalType:`bool`}],stateMutability:`nonpayable`},{type:`function`,name:`transferFromAndCall`,inputs:[{name:`from`,type:`address`,internalType:`address`},{name:`to`,type:`address`,internalType:`address`},{name:`value`,type:`uint256`,internalType:`uint256`},{name:`data`,type:`bytes`,internalType:`bytes`}],outputs:[{name:``,type:`bool`,internalType:`bool`}],stateMutability:`nonpayable`},{type:`function`,name:`transferFromAndCall`,inputs:[{name:`from`,type:`address`,internalType:`address`},{name:`to`,type:`address`,internalType:`address`},{name:`value`,type:`uint256`,internalType:`uint256`}],outputs:[{name:``,type:`bool`,internalType:`bool`}],stateMutability:`nonpayable`},{type:`event`,name:`Approval`,inputs:[{name:`owner`,type:`address`,indexed:!0,internalType:`address`},{name:`spender`,type:`address`,indexed:!0,internalType:`address`},{name:`value`,type:`uint256`,indexed:!1,internalType:`uint256`}],anonymous:!1},{type:`event`,name:`Transfer`,inputs:[{name:`from`,type:`address`,indexed:!0,internalType:`address`},{name:`to`,type:`address`,indexed:!0,internalType:`address`},{name:`value`,type:`uint256`,indexed:!1,internalType:`uint256`}],anonymous:!1}];function Et(e,t,n,r=`0x`){return{address:e,abi:Tt,functionName:`transferAndCall`,args:[t,n,r]}}const K=[{type:`function`,name:`allow`,inputs:[{name:`handle`,type:`bytes32`,internalType:`bytes32`},{name:`account`,type:`address`,internalType:`address`}],outputs:[],stateMutability:`nonpayable`},{type:`function`,name:`allowForDecryption`,inputs:[{name:`handlesList`,type:`bytes32[]`,internalType:`bytes32[]`}],outputs:[],stateMutability:`nonpayable`},{type:`function`,name:`allowTransient`,inputs:[{name:`ciphertext`,type:`bytes32`,internalType:`bytes32`},{name:`account`,type:`address`,internalType:`address`}],outputs:[],stateMutability:`nonpayable`},{type:`function`,name:`cleanTransientStorage`,inputs:[],outputs:[],stateMutability:`nonpayable`},{type:`function`,name:`delegateForUserDecryption`,inputs:[{name:`delegate`,type:`address`,internalType:`address`},{name:`contractAddress`,type:`address`,internalType:`address`},{name:`expirationDate`,type:`uint64`,internalType:`uint64`}],outputs:[],stateMutability:`nonpayable`},{type:`function`,name:`getUserDecryptionDelegationExpirationDate`,inputs:[{name:`delegator`,type:`address`,internalType:`address`},{name:`delegate`,type:`address`,internalType:`address`},{name:`contractAddress`,type:`address`,internalType:`address`}],outputs:[{name:``,type:`uint64`,internalType:`uint64`}],stateMutability:`view`},{type:`function`,name:`isAccountDenied`,inputs:[{name:`account`,type:`address`,internalType:`address`}],outputs:[{name:``,type:`bool`,internalType:`bool`}],stateMutability:`view`},{type:`function`,name:`isAllowed`,inputs:[{name:`handle`,type:`bytes32`,internalType:`bytes32`},{name:`account`,type:`address`,internalType:`address`}],outputs:[{name:``,type:`bool`,internalType:`bool`}],stateMutability:`view`},{type:`function`,name:`isAllowedForDecryption`,inputs:[{name:`handle`,type:`bytes32`,internalType:`bytes32`}],outputs:[{name:``,type:`bool`,internalType:`bool`}],stateMutability:`view`},{type:`function`,name:`isHandleDelegatedForUserDecryption`,inputs:[{name:`delegator`,type:`address`,internalType:`address`},{name:`delegate`,type:`address`,internalType:`address`},{name:`contractAddress`,type:`address`,internalType:`address`},{name:`handle`,type:`bytes32`,internalType:`bytes32`}],outputs:[{name:``,type:`bool`,internalType:`bool`}],stateMutability:`view`},{type:`function`,name:`multicall`,inputs:[{name:`data`,type:`bytes[]`,internalType:`bytes[]`}],outputs:[{name:`results`,type:`bytes[]`,internalType:`bytes[]`}],stateMutability:`payable`},{type:`function`,name:`persistAllowed`,inputs:[{name:`handle`,type:`bytes32`,internalType:`bytes32`},{name:`account`,type:`address`,internalType:`address`}],outputs:[{name:``,type:`bool`,internalType:`bool`}],stateMutability:`view`},{type:`function`,name:`revokeDelegationForUserDecryption`,inputs:[{name:`delegate`,type:`address`,internalType:`address`},{name:`contractAddress`,type:`address`,internalType:`address`}],outputs:[],stateMutability:`nonpayable`}];function Dt(e,t,n,r){return{address:e,abi:K,functionName:`delegateForUserDecryption`,args:[t,n,r]}}function Ot(e,t,n){return{address:e,abi:K,functionName:`revokeDelegationForUserDecryption`,args:[t,n]}}function kt(e,t,n,r){return{address:e,abi:K,functionName:`getUserDecryptionDelegationExpirationDate`,args:[t,n,r]}}function At(e,t,n,r,i){return{address:e,abi:K,functionName:`isHandleDelegatedForUserDecryption`,args:[t,n,r,i]}}const jt=2n**64n-1n;function Mt(e){return et(e.signer,e.provider,e)}function Nt(e){return e.startsWith(`0x`)?e:`0x${e}`}var Pt=class{#e;#t;#n;#r;constructor(e){this.#e=e.signer,this.#t=e.provider,this.#n=e.router,this.#r=e.decryptionService}#i(e){return ve(this.#r,e)}async decryptValues(e,t){let n=this.#i(`decryptValues`),r=await T(`decryptValues`,this.#e,this.#t);return n.decryptValues(e,r.address,t)}async delegatedDecryptValues(e,t,n=t,r){let i=this.#i(`delegatedDecryptValues`),a=await T(`delegatedDecryptValues`,this.#e,this.#t);return i.delegatedDecryptValues(e,t,a.address,n,r)}async decryptPublicValues(e,t){if(e.length===0)return{clearValues:{},decryptionProof:`0x`,abiEncodedClearValues:`0x`};try{let n=await this.#n.relayer.decryptPublicValuesWithSignatures({encryptedValues:e,options:t}),r={};return n.checkSignaturesArgs.handlesList.forEach((e,t)=>{Be(n.clearValues[t],`result.clearValues[${t}]`),r[e]=n.clearValues[t].value}),{clearValues:r,abiEncodedClearValues:n.checkSignaturesArgs.abiEncodedCleartexts,decryptionProof:n.checkSignaturesArgs.decryptionProof}}catch(e){throw G(e,`Public decryption failed`)}}async delegatedBatchDecryptValues({encryptedInputs:e,delegatorAddress:t,accountAddress:n=t,maxConcurrency:r,waitForPropagation:i}){let a=this.#i(`delegatedBatchDecryptValues`),o=await T(`delegatedBatchDecryptValues`,this.#e,this.#t);return a.delegatedBatchDecryptHandlesAs({encryptedInputs:e,delegatorAddress:t,delegateAddress:o.address,accountAddress:n,maxConcurrency:r,waitForPropagation:i})}},Ft=class{#e;#t;#n;constructor(e){this.#e=e.signer,this.#t=e.provider,this.#n=e.delegationService}#r(e){return ve(this.#e,e)}async delegateDecryption({contractAddress:e,delegateAddress:t,expirationDate:n}){let r=this.#r(`delegateDecryption`),i=await T(`delegateDecryption`,this.#e,this.#t);return this.#n.delegateDecryption(r,{contractAddress:e,delegateAddress:t,delegatorAddress:i.address,expirationDate:n})}async revokeDelegation({contractAddress:e,delegateAddress:t}){let n=this.#r(`revokeDelegation`),r=await T(`revokeDelegation`,this.#e,this.#t);return this.#n.revokeDelegation(n,{contractAddress:e,delegateAddress:t,delegatorAddress:r.address})}async isActive(e){return this.#n.isDelegated(e)}async getExpiry(e){return this.#n.getDelegationExpiry(e)}async getStatus(e){return this.#n.getStatus(e)}},It=class{#e;#t;#n;#r;#i;constructor(e){this.#e=e.signer,this.#t=e.provider,this.#n=e.cachingService,this.#r=e.credentialService,this.#i=e.logger}#a(e){return ve(this.#r,e)}async grantPermit(e){if(e.length===0)return;let t=this.#a(`grantPermit`);await k(`grantPermit`,this.#e,this.#t),await t.grantPermit(e)}async grantDelegationPermit(e,t){if(t.length===0)return;let n=this.#a(`grantDelegationPermit`);await k(`grantDelegationPermit`,this.#e,this.#t),await n.grantPermit(t,e)}async hasPermit(e){return this.#r?this.#r.hasPermit(e):!1}async hasDelegationPermit(e,t){return this.#r?this.#r.hasPermit(t,e):!1}async warmTransportKeyPair(){let e=this.#r;if(!e)return;let t=this.#e?.walletAccount.getSnapshot();t&&await e.warmTransportKeyPair(t.address)}async revokePermits(e){let t=this.#a(`revokePermits`),n=F((await T(`revokePermits`,this.#e,this.#t)).address);try{await t.revokePermits(e)}finally{await this.#o(n)}}async clear(){let e=this.#a(`clear`),t=F((await T(`clear`,this.#e,this.#t)).address);try{await e.clearCredentials()}finally{await this.#o(t)}}async#o(e){await S(`clear decrypt cache`,()=>this.#n.clearForRequester(e),this.#i)}async revokeTransportKeyPair(e){await this.#a(`revokeTransportKeyPair`).revokeTransportKeyPair(e)}async warmTransportKeyPairScope(e){await this.#a(`warmTransportKeyPairScope`).warmTransportKeyPairScope(e)}};const Lt=I.union([I.bigint(),I.boolean(),tt]),Rt=I.array(I.string());var zt=class{#e;#t;#n=`zama:decrypt`;#r=`${this.#n}:keys`;#i=Promise.resolve();constructor(e,t){this.#e=e,this.#t=t}async get(e,t,n){try{let r=this.#c(e,t,n),i=await this.#e.get(r);if(i===null)return null;let a=Lt.safeParse(i);return a.success?a.data:(await this.delete(e,t,n),null)}catch(e){return this.#t.warn(`CachingService.get failed`,{error:e}),null}}async set(e,t,n,r){try{let i=this.#c(e,t,n);await this.#e.set(i,r),this.#i=this.#i.then(()=>this.#u(i).catch(e=>{this.#t.warn(`CachingService index write failed`,{error:e})})),await this.#i}catch(e){this.#t.warn(`CachingService.set failed`,{error:e})}}async delete(e,t,n){let r=this.#c(e,t,n);this.#i=this.#i.then(()=>this.#a(r).catch(e=>{this.#t.warn(`CachingService.delete failed`,{error:e})})),await this.#i}async clearForRequester(e){this.#i=this.#i.then(()=>this.#o(e).catch(e=>{this.#t.warn(`CachingService.clearForRequester failed`,{error:e})})),await this.#i}async clearAll(){this.#i=this.#i.then(()=>this.#s().catch(e=>{this.#t.warn(`CachingService.clearAll failed`,{error:e})})),await this.#i}async#a(e){await this.#e.delete(e).catch(()=>{});let t=await this.#l(),n=t.filter(t=>t!==e);n.length!==t.length&&await this.#e.set(this.#r,n)}async#o(e){let t=F(e),n=`${this.#n}:${t}:`,r=await this.#l(),i=[],a=[];for(let e of r)e.startsWith(n)?i.push(e):a.push(e);await Promise.all(i.map(e=>this.#e.delete(e).catch(()=>{}))),await this.#e.set(this.#r,a)}async#s(){let e=await this.#l();await Promise.all(e.map(e=>this.#e.delete(e).catch(()=>{}))),await this.#e.delete(this.#r)}#c(e,t,n){return`${this.#n}:${F(e)}:${F(t)}:${n.toLowerCase()}`}async#l(){let e=await this.#e.get(this.#r);if(e===null)return[];let t=Rt.safeParse(e);return t.success?t.data:(await this.#e.delete(this.#r).catch(()=>{}),[])}async#u(e){let t=await this.#l();t.includes(e)||(t.push(e),await this.#e.set(this.#r,t))}};function Bt(e,t){let n=Vt(e,t);if(!n)throw new C(`No permit covers contract ${t} after allow()`);return{privateKey:e.keypair.privateKey,publicKey:e.keypair.publicKey,serializedPermit:n.serializedPermit}}function Vt(e,t){let n=Ze(t);return e.permissions.find(e=>e.contractAddresses.includes(n))}const Ht=e=>new Promise(t=>setTimeout(t,e));var Ut=class{#e;#t;#n;#r;#i;constructor({cache:e,credentialService:t,delegationService:n,router:r,emitEvent:i}){this.#e=e,this.#t=t,this.#n=n,this.#r=r,this.#i=i}async decryptValues(e,t,n){let r=F(t);return this.#s(e,{requesterAddress:r,aclActorAddress:r,resolveCredentials:e=>this.#t.grantPermit(e),decryptContract:({credentials:e,contractAddress:t,encryptedValues:n,options:r})=>this.#o(e,t,n,r),errorMessage:`Failed to decrypt encrypted values`},n)}async delegatedDecryptValues(e,t,n,r,i){let a=F(t),o=F(n);return this.#a(i?.waitForPropagation??!0,()=>this.#s(e,{requesterAddress:F(r),aclActorAddress:a,resolveCredentials:e=>this.#t.grantPermit(e,a),validate:e=>this.#f(e,{delegatorAddress:a,delegateAddress:o}),decryptContract:({credentials:e,contractAddress:t,encryptedValues:n,options:r})=>this.#o(e,t,n,r),errorMessage:`Failed to decrypt delegated encrypted values`,delegated:!0}))}async#a(e,t){let n;for(let r=0;r<16;r++)try{return await t()}catch(t){if(n=t,!(r<15&&e&&t instanceof W))throw t;await Ht(2e3)}throw n}async delegatedBatchDecryptHandlesAs({encryptedInputs:e,delegatorAddress:t,delegateAddress:n,accountAddress:r,maxConcurrency:i=5,waitForPropagation:a=!0}){let o=e.map(e=>({encryptedValue:e.encryptedValue,contractAddress:F(e.contractAddress)}));if(o.length===0)return{items:o};let s=F(r);try{let e=await this.delegatedDecryptValues(o.map(({encryptedValue:e,contractAddress:t})=>({encryptedValue:e,contractAddress:t})),t,n,s,{waitForPropagation:a});for(let t of o)this.#l(t,e);return{items:o}}catch(e){if(Ve(e))throw e;if(o.length===1){let[n=this.#d()]=o;return n.error=this.#u(e,`Failed to decrypt delegated encrypted values`,{isDelegated:!0,contractAddress:n.contractAddress,account:F(t)}),{items:o}}}let c=!1;return await qe(o.map(e=>async()=>{if(!c)try{let r=await this.delegatedDecryptValues([{encryptedValue:e.encryptedValue,contractAddress:e.contractAddress}],t,n,s,{waitForPropagation:!1});this.#l(e,r)}catch(n){if(Ve(n))throw c=!0,n;e.error=this.#u(n,`Failed to decrypt delegated encrypted values`,{isDelegated:!0,contractAddress:e.contractAddress,account:F(t)})}}),i),{items:o}}async#o(e,t,n,i){let a=Bt(e,t),o;try{o=await this.#r.relayer.parseTransportKeyPair({publicKey:a.publicKey,privateKey:a.privateKey,tkmsVersion:e.keypair.tkmsVersion})}catch(e){throw e instanceof Error&&r(e.message)&&await this.#t.evictTransportKeyPair(),e}let s=await this.#r.relayer.parseSignedDecryptionPermit({transportKeyPair:o,serializedPermit:a.serializedPermit});return this.#r.relayer.decryptValues({transportKeyPair:o,signedPermit:s,encryptedValues:n,contractAddress:t,options:i})}async#s(t,n,r){if(t.length===0)return{};let i=t.map(e=>({encryptedValue:e.encryptedValue,contractAddress:F(e.contractAddress)})),a={},s=[];for(let e of i)E(e.encryptedValue)?a[e.encryptedValue]=0n:s.push(e);if(s.length===0)return a;let c=Array.from(new Set(i.map(e=>e.contractAddress))),l=Array.from(new Set(s.map(e=>e.contractAddress)));if(n.validate)try{await n.validate(l)}catch(e){throw o(e)?this.#c(e,`the delegation pre-check`):e}let u=[];for(let e of s){let t=await this.#e.get(n.requesterAddress,e.contractAddress,e.encryptedValue);t===null?u.push(e):a[e.encryptedValue]=t}if(u.length===0)return a;let d=await n.resolveCredentials(c),f=new Map;for(let e of u){let t=f.get(e.contractAddress);t?t.push(e.encryptedValue):f.set(e.contractAddress,[e.encryptedValue])}let m=[];for(let[e,t]of f)for(let n of ze(t))m.push({contractAddress:e,encryptedValues:n});let ee=Date.now(),h=u.map(e=>e.encryptedValue);try{this.#i({type:y.DecryptStart,encryptedValues:h}),await qe(m.map(({contractAddress:e,encryptedValues:t})=>async()=>{let i;try{i=await n.decryptContract({credentials:d,contractAddress:e,encryptedValues:t,options:r})}catch(t){throw G(t,n.errorMessage,{isDelegated:n.delegated,contractAddress:e,account:n.aclActorAddress})}for(let r=0;r<t.length;r++){let o=t[r],s=i[r]?.value;o!==void 0&&s!==void 0&&(a[o]=s,await this.#e.set(n.requesterAddress,e,o,s))}let o=t.filter(e=>a[e]===void 0);if(o.length>0)throw new C(`${n.errorMessage}: relayer returned no clear value for ${o.length} of ${t.length} handle(s) on ${e}`,{cause:AggregateError(o.map(t=>new C(`No clear value for handle ${t} on ${e}`)),`${o.length} handle(s) missing a clear value on ${e}`)})}),5);let e={};for(let t of h){let n=a[t];n!==void 0&&(e[t]=n)}return this.#i({type:y.DecryptEnd,durationMs:Date.now()-ee,encryptedValues:h,result:e}),a}catch(t){let r=t instanceof p&&t.cause instanceof Error?t.cause:t;throw this.#i({type:y.DecryptError,error:e(r),durationMs:Date.now()-ee,encryptedValues:h}),G(t,n.errorMessage,{isDelegated:n.delegated})}}#c(e,t){return new A(`RPC provider rate-limited ${t}; retry with backoff.`,{cause:e,retryAfter:n(e)})}#l(e,t){let n=t[e.encryptedValue];if(n===void 0){e.error=new C(`Batch delegated decryption returned no value for encrypted value ${e.encryptedValue} on contract ${e.contractAddress}`);return}e.value=n}#u(e,t,n){return e instanceof p?e:G(e,t,n)}#d(){throw new C(`Batch delegated decryption invariant failed: missing item`)}async#f(e,{delegatorAddress:t,delegateAddress:n}){let r=await this.#n.findInactiveDelegations(e,t,n);if(r.size!==0)for(let e of r.values())throw e}};function Wt(e){if(!(e instanceof Error))return null;let t=e.cause;if(typeof t!=`object`||!t||!(`data`in t))return null;let{data:n}=t;return typeof n!=`object`||!n||!(`errorName`in n)?null:typeof n.errorName==`string`?n.errorName:null}const Gt={AlreadyDelegatedOrRevokedInSameBlock:e=>new bt(`Only one delegate/revoke per (delegator, delegate, contract) per block. Wait for the next block before retrying.`,{cause:e}),SenderCannotBeContractAddress:e=>new xt(`The contract address cannot be the caller address.`,{cause:e}),EnforcedPause:e=>new St(`The ACL contract is paused. Delegation operations are temporarily disabled.`,{cause:e}),SenderCannotBeDelegate:e=>new R(`Cannot delegate to yourself (delegate === msg.sender).`,{cause:e}),DelegateCannotBeContractAddress:e=>new H(`Delegate address cannot be the same as the contract address.`,{cause:e}),ExpirationDateBeforeOneHour:e=>new U(`Expiration date must be at least 1 hour in the future.`,{cause:e}),ExpirationDateAlreadySetToSameValue:e=>new V(`The new expiration date is the same as the current one.`,{cause:e}),NotDelegatedYet:e=>new z(`Cannot revoke: no active delegation exists.`,{cause:e})};function Kt(e){return e in Gt}function qt(e,t){let n=Wt(e);if(n&&Kt(n))return Gt[n](t);let r=e instanceof Error?e.message:String(e);for(let[e,n]of Object.entries(Gt))if(r.includes(e))return n(t);return null}var Jt=class{#e;#t;#n;#r;constructor({provider:e,router:t,emitEvent:n=()=>{},logger:r}){this.#t=e,this.#e=t,this.#r=r,this.#n=n}async delegateDecryption(e,{contractAddress:t,delegateAddress:n,delegatorAddress:r,expirationDate:i}){if(i&&i.getTime()<Date.now()+36e5)throw new U(`Expiration date must be at least 1 hour in the future`);let a=F(t),o=F(n),s=F(r);if(o===s)throw new R(`Cannot delegate to yourself (delegate === msg.sender).`);if(o===a)throw new H(`Delegate address cannot be the same as the contract address (${a}).`);let c=this.#e.relayer.chain.aclContractAddress,l=i?BigInt(Math.floor(i.getTime()/1e3)):jt,u;try{u=await this.getDelegationExpiry({contractAddress:a,delegatorAddress:s,delegateAddress:o})}catch(e){this.#r.warn(`delegateDecryption: pre-flight expiry check failed`,{error:e}),u=-1n}if(u===l)throw new V(`The new expiration date (${l}) is the same as the current one. No on-chain change needed.`);return this.#i({operation:`delegateDecryption`,signer:e,contractAddress:t,config:Dt(c,o,a,l)})}async revokeDelegation(e,{contractAddress:t,delegateAddress:n,delegatorAddress:r}){let i=F(t),a=F(n),o=F(r),s=this.#e.relayer.chain.aclContractAddress,c;try{c=await this.getDelegationExpiry({contractAddress:i,delegatorAddress:o,delegateAddress:a})}catch(e){this.#r.warn(`revokeDelegation: pre-flight expiry check failed`,{error:e}),c=1n}if(c===0n)throw new z(`No active delegation found for delegate ${a} on contract ${i}.`);return this.#i({operation:`revokeDelegation`,signer:e,contractAddress:t,config:Ot(s,a,i)})}async isDelegated(e){return(await this.getStatus(e)).isActive}async getStatus(e){let t=await this.getDelegationExpiry(e);return t===0n?{isActive:!1,expiryTimestamp:t}:t===jt?{isActive:!0,expiryTimestamp:t}:{isActive:t>await this.#t.getBlockTimestamp(),expiryTimestamp:t}}async getDelegationExpiry({contractAddress:e,delegatorAddress:t,delegateAddress:n}){let r=this.#e.relayer.chain.aclContractAddress;return this.#t.readContract(kt(r,F(t),F(n),F(e)))}async#i({operation:e,signer:t,contractAddress:n,config:r}){try{return await Ke({operation:e,signer:t,provider:this.#t,config:r,emit:e=>this.#n(e,n),logger:this.#r})}catch(e){throw this.#a(e),e}}#a(e){if(!(e instanceof M))return;let t=qt(e.cause??e,e);if(t)throw t}async findInactiveDelegations(e,t,n){let r=new Map;return await Promise.all(e.map(async e=>{try{await this.assertDelegationActive(e,t,n)}catch(t){if(t instanceof z||t instanceof B){let n=F(e);r.set(n,t);return}throw t}})),r}async assertDelegationActive(e,t,n){let r=F(e),i=F(t),a=F(n),{isActive:o,expiryTimestamp:s}=await this.getStatus({contractAddress:r,delegatorAddress:i,delegateAddress:a});if(!o)throw s===0n?new z(`No active delegation from ${i} to ${a} for ${r}`):new B(`Delegation from ${i} to ${a} for ${r} has expired`)}},Yt=class{#e;#t;constructor({router:e,emitEvent:t}){this.#e=e,this.#t=t}async encryptValues(t,n){let r=Date.now(),i=F(t.contractAddress);try{this.#t({type:y.EncryptStart},i);let e=await this.#e.relayer.encryptValues({...t,options:n});return this.#t({type:y.EncryptEnd,durationMs:Date.now()-r},i),e}catch(t){throw this.#t({type:y.EncryptError,error:e(t),durationMs:Date.now()-r},i),wt(t,`Encryption failed`)}}},Xt=class{#e;#t;#n;#r;#i;#a=new Set;#o;constructor(e){this.#e=e.signer,this.#t=e.router,this.#n=e.cachingService,this.#r=e.credentialService,this.#i=e.logger,this.#e&&(this.#o=this.#e.walletAccount.subscribe(e=>{this.#s(e).catch(e=>{this.#i.warn(`wallet account handler failed`,{error:e})})}))}onWalletAccountChange(e){return this.#a.add(e),()=>{this.#a.delete(e)}}dispose(){this.#o?.(),this.#o=void 0,this.#a.clear()}async#s(e){let t=e.previous,n=e.next,r=n?.chainId;r!==void 0&&await S(`switch relayer chain`,()=>this.#t.switchChain(r),this.#i);let i=this.#r;i&&await S(`credential wallet account change`,()=>i.handleWalletAccountChange(t,n),this.#i),t&&await S(`clear decrypt cache`,()=>this.#n.clearForRequester(t.address),this.#i),await Promise.all(Array.from(this.#a,t=>S(`wallet account listener`,()=>t(e),this.#i)))}};function q(e){return _t(vt(e))}const J={ConfidentialTransfer:q(`ConfidentialTransfer(address,address,bytes32)`),Wrap:q(`Wrap(address,uint256,bytes32)`),UnwrapRequested:q(`UnwrapRequested(address,bytes32,bytes32)`),UnwrapFinalized:q(`UnwrapFinalized(address,bytes32,bytes32,uint64)`)};function Y(e){return F(Nt(e.slice(-40)))}function Zt(e){return e}function Qt(e,t){let n=2+t*64,r=e.slice(n,n+64);return r.length===64?r:r.padEnd(64,`0`)}function $t(e,t){return F(Nt(Qt(e,t).slice(-40)))}function X(e,t){return BigInt(`0x`+Qt(e,t))}function en(e,t){return Nt(Qt(e,t))}function tn(e){return e.topics[0]!==J.ConfidentialTransfer||e.topics.length<4?null:{eventName:`ConfidentialTransfer`,from:Y(e.topics[1]),to:Y(e.topics[2]),encryptedAmount:Zt(e.topics[3])}}function Z(e){return e.topics[0]!==J.Wrap||e.topics.length<2?null:{eventName:`Wrap`,to:Y(e.topics[1]),roundedAmount:X(e.data,0),encryptedWrappedAmount:en(e.data,1)}}function nn(e){return e.topics[0]!==J.UnwrapRequested||e.topics.length<3?null:{eventName:`UnwrapRequested`,receiver:Y(e.topics[1]),unwrapRequestId:Zt(e.topics[2]),encryptedAmount:en(e.data,0)}}function rn(e){return e.topics[0]!==J.UnwrapFinalized||e.topics.length<3?null:{eventName:`UnwrapFinalized`,receiver:Y(e.topics[1]),unwrapRequestId:Zt(e.topics[2]),encryptedAmount:en(e.data,0),cleartextAmount:X(e.data,1)}}function an(e){return tn(e)??Z(e)??nn(e)??rn(e)}function on(e){let t=[];for(let n of e){let e=an(n);e&&t.push(e)}return t}function sn(e){for(let t of e){let e=nn(t);if(e)return e}return null}function cn(e){for(let t of e){let e=Z(t);if(e)return e}return null}const ln=[J.ConfidentialTransfer,J.Wrap,J.UnwrapRequested,J.UnwrapFinalized],Q={DelegatedForUserDecryption:q(`DelegatedForUserDecryption(address,address,address,uint64,uint64,uint64)`),RevokedDelegationForUserDecryption:q(`RevokedDelegationForUserDecryption(address,address,address,uint64,uint64)`)};function un(e){return e.topics[0]!==Q.DelegatedForUserDecryption||e.topics.length<3?null:{eventName:`DelegatedForUserDecryption`,delegator:Y(e.topics[1]),delegate:Y(e.topics[2]),contractAddress:$t(e.data,0),delegationCounter:X(e.data,1),oldExpirationDate:X(e.data,2),newExpirationDate:X(e.data,3)}}function dn(e){return e.topics[0]!==Q.RevokedDelegationForUserDecryption||e.topics.length<3?null:{eventName:`RevokedDelegationForUserDecryption`,delegator:Y(e.topics[1]),delegate:Y(e.topics[2]),contractAddress:$t(e.data,0),delegationCounter:X(e.data,1),oldExpirationDate:X(e.data,2)}}function fn(e){return un(e)??dn(e)}function pn(e){let t=[];for(let n of e){let e=fn(n);e&&t.push(e)}return t}function mn(e){for(let t of e){let e=un(t);if(e)return e}return null}function hn(e){for(let t of e){let e=dn(t);if(e)return e}return null}const gn=[Q.DelegatedForUserDecryption,Q.RevokedDelegationForUserDecryption];function $(e){return`zama:pending-unshield:${Ze(e)}`}const _n=I.union([I.pipe(P,I.transform(e=>({unwrapTxHash:e}))),I.pipe(I.object({version:I.literal(1),unwrapTxHash:P,unwrapRequestId:I.optional(P)}),I.transform(({unwrapTxHash:e,unwrapRequestId:t})=>({unwrapTxHash:e,unwrapRequestId:t})))]);async function vn(e,t,n,r){if(r===void 0){await e.set($(t),n);return}await e.set($(t),{version:1,unwrapTxHash:n,unwrapRequestId:r})}async function yn(e,t){return(await bn(e,t))?.unwrapTxHash??null}async function bn(e,t){let n=$(t),r=await e.get(n);if(r==null)return null;let i=_n.safeParse(r);return i.success?i.data:(await e.delete(n),null)}async function xn(e,t){await e.delete($(t))}var Sn=class extends O{#e;#t=null;#n=null;#r(e){try{return Be(this.sdk.signer,`WrappedToken.sdk.signer`),this.sdk.signer}catch(t){throw new te(e,{cause:t})}}async underlying(){return this.#s()}async isPayable(){if(this.#n!==null)return this.#n;try{let e=await this.#s();this.#n=await this.sdk.provider.readContract(Ee(e))}catch{this.#n=!1}return this.#n}async allowance(e){let t=await this.#s();return this.sdk.provider.readContract(v(t,F(e),this.address))}async shield(t,n){let r=await T(`shield`,this.sdk.signer,this.sdk.provider),i=await this.isPayable(),a=await this.#s(),o=F(r.address),s;try{s=await this.sdk.provider.readContract(x(a,o))}catch(t){throw t instanceof p?t:new D(`Could not read ERC-20 balance for shield validation (token: ${a})`,{cause:e(t)})}if(s<t)throw new w(`Insufficient ERC-20 balance: requested ${t}, available ${s} (token: ${a})`,{requested:t,available:s,token:a});return i?this.#i(t,a,o,n):this.#a(t,o,n)}async#i(e,t,n,r){this.#r(`shield`);let i=r?.to?F(r.to):n,a=i===n?`0x`:i;return this.submitTransaction({operation:`shield:transferAndCall`,config:Et(t,this.address,e,a),onSubmitted:r?.onShieldSubmitted})}async wrap(t,n){this.#r(`wrap`);let r=await T(`wrap`,this.sdk.signer,this.sdk.provider),i=await this.#s(),a=F(r.address),o;try{o=await this.sdk.provider.readContract(x(i,a))}catch(t){throw t instanceof p?t:new D(`Could not read ERC-20 balance for wrap validation (token: ${i})`,{cause:e(t)})}if(o<t)throw new w(`Insufficient ERC-20 balance: requested ${t}, available ${o} (token: ${i})`,{requested:t,available:o,token:i});let s;try{s=await this.sdk.provider.readContract(v(i,a,this.address))}catch(t){throw t instanceof p?t:new D(`Could not read ERC-20 allowance for wrap validation (token: ${i})`,{cause:e(t)})}if(s<t)throw new Ge(`Insufficient allowance for wrap: requested ${t}, approved ${s}. Call approveUnderlying() first (token: ${i}).`,{requested:t,available:s,token:i});let c=n?.to?F(n.to):a;return this.submitTransaction({operation:`wrap`,config:pe(this.address,c,t),onSubmitted:n?.onWrapSubmitted})}async#a(e,t,n){this.#r(`shield`);let r=n?.approvalStrategy??`exact`;r!==`skip`&&await this.#l(e,r===`max`,n);let i=n?.to?F(n.to):t;return this.submitTransaction({operation:`shield:approveAndWrap`,config:pe(this.address,i,e),onSubmitted:n?.onShieldSubmitted})}async approveUnderlying(e){this.#r(`approveUnderlying`);let t=await T(`approveUnderlying`,this.sdk.signer,this.sdk.provider),n=await this.#s(),r=F(t.address),i=e??2n**256n-1n;return i>0n&&await this.sdk.provider.readContract(v(n,r,this.address))>0n&&await this.submitTransaction({operation:`approveUnderlying:reset`,config:b(n,this.address,0n)}),this.submitTransaction({operation:`approveUnderlying`,config:b(n,this.address,i)})}async unshield(e,t){let{skipBalanceCheck:n=!1,onUnwrapSubmitted:r,onFinalizing:i,onFinalizeSubmitted:a}=t??{};n||await this.assertConfidentialBalance(e);let o={onFinalizing:i,onFinalizeSubmitted:a},s=crypto.randomUUID(),c=await this.unwrap(e);return S(`unshield: onUnwrapSubmitted`,()=>r?.(c.txHash),this.sdk.logger),this.#c(c.unwrapRequestId,c.txHash,s,o)}async unshieldAll(e){let t=crypto.randomUUID(),n=await this.unwrapAll();return S(`unshieldAll: onUnwrapSubmitted`,()=>e?.onUnwrapSubmitted?.(n.txHash),this.sdk.logger),this.#c(n.unwrapRequestId,n.txHash,t,e)}async resumeUnshield(e,t){let n;try{n=await this.sdk.provider.waitForTransactionReceipt(e)}catch(e){throw e instanceof p?e:new M(`Failed to get unwrap receipt`,{cause:e})}let r=this.#o(n.logs);return this.#c(r,e,crypto.randomUUID(),t)}async getPendingUnshield(){return yn(this.sdk.storage,this.address)}async unwrap(e){this.#r(`unwrap`);let t=F((await T(`unwrap`,this.sdk.signer,this.sdk.provider)).address),{encryptedValues:n,inputProof:r}=await this.sdk.encrypt({values:[{value:e,type:`euint64`}],contractAddress:this.address,userAddress:t}),[i]=n;if(!i)throw new j(`Encryption returned no encrypted values`);let a=await this.submitTransaction({operation:`unwrap`,config:se(this.address,t,t,i,r)});return{...a,unwrapRequestId:this.#o(a.receipt.logs)}}async unwrapAll(){this.#r(`unwrapAll`);let e=F((await T(`unwrapAll`,this.sdk.signer,this.sdk.provider)).address),t=await this.readConfidentialBalanceOf(e);if(E(t))throw new C(`Cannot unshield: balance is zero`);let n=await this.submitTransaction({operation:`unwrapAll`,config:le(this.address,e,e,t)});return{...n,unwrapRequestId:this.#o(n.receipt.logs)}}async finalizeUnwrap(e){this.#r(`finalizeUnwrap`),await k(`finalizeUnwrap`,this.sdk.signer,this.sdk.provider);let t=await this.sdk.decryption.decryptPublicValues([e]),n=t.clearValues[e];return Je(n,`finalizeUnwrap: clearValue`),this.submitTransaction({operation:`finalizeUnwrap`,config:h(this.address,e,n,t.decryptionProof)})}#o(e){let t=sn(e);if(!t)throw new M(`No UnwrapRequested event found in unwrap receipt`);return t.unwrapRequestId}async#s(){return this.#e===void 0?(this.#t||=this.sdk.provider.readContract(ie(this.address)).then(e=>(this.#e=e,this.#t=null,e)).catch(e=>{throw this.#t=null,e}),this.#t):this.#e}async#c(e,t,n,r){this.emit({type:y.UnshieldPhase1Submitted,txHash:t,operationId:n}),await S(`unshield: savePendingUnshield`,()=>vn(this.sdk.storage,this.address,t),this.sdk.logger),this.emit({type:y.UnshieldPhase2Started,operationId:n}),S(`unshield: onFinalizing`,()=>r?.onFinalizing?.(),this.sdk.logger);let i=await this.finalizeUnwrap(e);return this.emit({type:y.UnshieldPhase2Submitted,txHash:i.txHash,operationId:n}),S(`unshield: onFinalizeSubmitted`,()=>r?.onFinalizeSubmitted?.(i.txHash),this.sdk.logger),await S(`unshield: clearPendingUnshield`,()=>xn(this.sdk.storage,this.address),this.sdk.logger),i}async#l(e,t,n){this.#r(`approveUnderlying`);let r=await this.#s(),i=F((await T(`approveUnderlying`,this.sdk.signer,this.sdk.provider)).address),a=await this.sdk.provider.readContract(v(r,i,this.address));if(a>=e)return;a>0n&&await this.submitTransaction({operation:`approveUnderlying:reset`,config:b(r,this.address,0n)});let o=t?2n**256n-1n:e;await this.submitTransaction({operation:`approveUnderlying`,config:b(r,this.address,o),onSubmitted:n?.onApprovalSubmitted})}},Cn=class{#e;provider;signer;storage;registry;permits;delegations;decryption;#t;#n;#r;#i;#a;#o;#s;#c;#l;#u;constructor(e){this.#e=e.router,this.provider=e.provider,this.signer=e.signer,this.storage=e.storage,this.#r=e.onEvent??function(){},this.#i=e.logger,this.#a=new zt(e.storage,this.#i),this.#u=new Jt({provider:this.provider,router:e.router,emitEvent:this.emitEvent.bind(this),logger:this.#i});let t={};for(let n of e.chains)n.registryAddress&&(t[n.id]=n.registryAddress);this.registry=new N({provider:this.provider,registryAddresses:t,registryTTL:e.registryTTL}),this.#n=t,this.#t=e.registryTTL,e.signer&&(this.#l=new ot({router:e.router,signer:e.signer,transportKeyPairTTL:e.transportKeyPairTTL,permitTTL:e.permitTTL,scope:e.transportKeyPairScope,storage:this.storage,permitStorage:e.permitStorage,logger:this.#i}),this.#c=new Ut({cache:this.#a,credentialService:this.#l,delegationService:this.#u,router:e.router,emitEvent:this.emitEvent.bind(this)})),this.#s=new Yt({router:e.router,emitEvent:this.emitEvent.bind(this)}),this.#o=new Xt({signer:e.signer,router:e.router,cachingService:this.#a,credentialService:this.#l,logger:this.#i}),this.permits=new It({signer:this.signer,provider:this.provider,cachingService:this.#a,credentialService:this.#l,logger:this.#i}),this.delegations=new Ft({signer:this.signer,provider:this.provider,delegationService:this.#u}),this.decryption=new Pt({signer:this.signer,provider:this.provider,router:e.router,decryptionService:this.#c})}onWalletAccountChange(e){return this.#o.onWalletAccountChange(e)}get logger(){return this.#i}get relayer(){return this.#e.relayer}emitEvent(e,t){try{this.#r({...e,tokenAddress:t,timestamp:Date.now()})}catch(t){this.#i.warn(`${e.type} event listener silently failed`,{error:t})}}createWrappersRegistry(e){return new N({provider:this.provider,registryAddresses:{...this.#n,...e},registryTTL:this.#t})}async encrypt(e,t){return this.#s.encryptValues(e,t)}createToken(e){return new O(this,e)}createWrappedToken(e){return new Sn(this,e)}dispose(){this.#o.dispose()}terminate(){this.dispose(),this.signer?.dispose?.()}[Symbol.dispose](){this.terminate()}},wn=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 Tn=new wn;export{gn as ACL_TOPICS,St as AclPausedError,Q as AclTopics,He as BalanceCheckUnavailableError,st as BaseSigner,Re as ChainMismatchError,wn as ChromeSessionStorage,ee as ConfigurationError,Pt as Decryption,C as DecryptionFailedError,Xe as DefaultRegistryAddresses,xt as DelegationContractIsSelfError,bt as DelegationCooldownError,H as DelegationDelegateEqualsContractError,U as DelegationExpirationTooSoonError,B as DelegationExpiredError,V as DelegationExpiryUnchangedError,z as DelegationNotFoundError,W as DelegationNotPropagatedError,R as DelegationSelfNotAllowedError,Ft as Delegations,Ie as ERC1363_INTERFACE_ID,D as ERC20ReadFailedError,Ce as ERC7984_INTERFACE_ID,we as ERC7984_WRAPPER_INTERFACE_ID,j as EncryptionFailedError,it as IndexedDBStorage,Ge as InsufficientAllowanceError,Ue as InsufficientConfidentialBalanceError,w as InsufficientERC20BalanceError,g as InvalidTransportKeyPairError,Qe as MemoryStorage,rt as MutableWalletAccountStore,_ as NoCiphertextError,L as NotEntitledError,It as Permits,u as RelayerRequestFailedError,A as RpcRateLimitError,te as SignerNotConfiguredError,_e as SignerRequiredError,ae as SigningFailedError,ce as SigningRejectedError,ln as TOKEN_TOPICS,O as Token,J as Topics,M as TransactionRevertedError,ye as TransportKeyPairExpiredError,oe as WalletAccountNotReadyError,ge as WalletNotConnectedError,Sn as WrappedToken,N as WrappersRegistry,We as ZERO_ENCRYPTED_VALUE,p as ZamaError,s as ZamaErrorCode,Cn as ZamaSDK,y as ZamaSDKEvents,v as allowanceContract,gt as anvil,b as approveContract,x as balanceOfContract,ft as bscTestnet,mt as chains,Tn as chromeSessionStorage,Ye as cleartext,Le as confidentialBalanceOfContract,he as confidentialTotalSupplyContract,re as confidentialTransferContract,ke as confidentialTransferFromContract,Mt as createConfig,at as createWalletAccountStore,xe as decimalsContract,fn as decodeAclEvent,pn as decodeAclEvents,tn as decodeConfidentialTransfer,un as decodeDelegatedForUserDecryption,an as decodeOnChainEvent,on as decodeOnChainEvents,dn as decodeRevokedDelegationForUserDecryption,rn as decodeUnwrapFinalized,nn as decodeUnwrapRequested,Z as decodeWrap,Dt as delegateForUserDecryptionContract,h as finalizeUnwrapContract,mn as findDelegatedForUserDecryption,hn as findRevokedDelegationForUserDecryption,sn as findUnwrapRequested,cn as findWrap,Pe as getConfidentialTokenAddressContract,kt as getDelegationExpiryContract,De as getTokenAddressContract,be as getTokenPairContract,Me as getTokenPairsContract,Fe as getTokenPairsLengthContract,Se as getTokenPairsSliceContract,ut as hardhat,ct as hoodi,nt as indexedDBStorage,Oe as inferredTotalSupplyContract,pt as ingenTestnet,Ne as isConfidentialTokenContract,Ae as isConfidentialTokenValidContract,je as isConfidentialWrapperContract,E as isEncryptedValueZero,At as isHandleDelegatedContract,ue as isOperatorContract,t as isRetryable,ht as mainnet,yt as matchZamaError,$e as memoryStorage,me as nameContract,lt as polygonAmoy,de as rateContract,d as retryAfterSeconds,Ot as revokeDelegationContract,dt as sepolia,fe as setOperatorContract,Te as supportsInterfaceContract,ne as symbolContract,Et as transferAndCallContract,ie as underlyingContract,se as unwrapContract,le as unwrapFromBalanceContract,pe as wrapContract};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|