@zama-fhe/sdk 2.1.1-alpha.2 → 2.2.0-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -4
- package/dist/cjs/activity.cjs +1 -1
- package/dist/cjs/activity.cjs.map +1 -1
- package/dist/cjs/cleartext/index.cjs +1 -2
- package/dist/cjs/cleartext.cjs +2 -0
- package/dist/cjs/{cleartext/index.cjs.map → cleartext.cjs.map} +1 -1
- package/dist/cjs/ethers/index.cjs +1 -1
- package/dist/cjs/ethers/index.cjs.map +1 -1
- package/dist/cjs/index.cjs +2 -2
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/query/index.cjs +1 -1
- package/dist/cjs/query/index.cjs.map +1 -1
- package/dist/cjs/transfer-batcher.cjs +1 -1
- package/dist/cjs/transfer-batcher.cjs.map +1 -1
- package/dist/cjs/viem/index.cjs +1 -1
- package/dist/cjs/viem/index.cjs.map +1 -1
- package/dist/cjs/{erc165.cjs → wrappers-registry.cjs} +2 -2
- package/dist/cjs/wrappers-registry.cjs.map +1 -0
- package/dist/esm/{activity-B4coeVs1.d.ts → activity-BRrEPcPO.d.ts} +256 -27
- package/dist/esm/activity-ChJnF5yd.js +2 -0
- package/dist/esm/activity-ChJnF5yd.js.map +1 -0
- package/dist/esm/cleartext/index.d.ts +5 -2
- package/dist/esm/cleartext/index.js +1 -2
- package/dist/esm/cleartext-CxGEREks.js +2 -0
- package/dist/esm/cleartext-CxGEREks.js.map +1 -0
- package/dist/esm/{eip1193-subscribe-Cl_wlVuQ.js → eip1193-subscribe-Cp2QVN0m.js} +1 -1
- package/dist/esm/{eip1193-subscribe-Cl_wlVuQ.js.map → eip1193-subscribe-Cp2QVN0m.js.map} +1 -1
- package/dist/esm/ethers/index.d.ts +12 -5
- package/dist/esm/ethers/index.js +1 -1
- package/dist/esm/ethers/index.js.map +1 -1
- package/dist/esm/fhe-artifact-cache-vzh7Xn9G.js.map +1 -1
- package/dist/esm/{index-BaBH5_l6.d.ts → index-IhsduS7h.d.ts} +1134 -7
- package/dist/esm/index.d.ts +6 -6
- package/dist/esm/index.js +2 -2
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/node/index.d.ts +3 -3
- package/dist/esm/node/index.js +1 -1
- package/dist/esm/query/index.d.ts +124 -8
- package/dist/esm/query/index.js +1 -1
- package/dist/esm/query/index.js.map +1 -1
- package/dist/esm/{relayer-sdk-mcgawhDN.d.ts → relayer-sdk-CcIghrEq.d.ts} +2 -2
- package/dist/esm/{relayer-sdk.types--cY3a2ni.d.ts → relayer-sdk.types-D7rylLS4.d.ts} +1 -1
- package/dist/esm/{relayer-utils-DgRkaB8f.d.ts → relayer-utils-BcTAyZOr.d.ts} +14 -3
- package/dist/esm/relayer-utils-BeoTNDM4.js +2 -0
- package/dist/esm/relayer-utils-BeoTNDM4.js.map +1 -0
- package/dist/esm/transfer-batcher-BXIo7hnu.js +2 -0
- package/dist/esm/transfer-batcher-BXIo7hnu.js.map +1 -0
- package/dist/esm/viem/index.d.ts +24 -5
- package/dist/esm/viem/index.js +1 -1
- package/dist/esm/viem/index.js.map +1 -1
- package/dist/esm/{erc165-GmIEu75Z.js → wrappers-registry-DqPr_JG2.js} +2 -2
- package/dist/esm/wrappers-registry-DqPr_JG2.js.map +1 -0
- package/package.json +1 -1
- package/dist/cjs/erc165.cjs.map +0 -1
- package/dist/cjs/relayer-utils.cjs +0 -2
- package/dist/cjs/relayer-utils.cjs.map +0 -1
- package/dist/esm/activity-q5o6CCaY.js +0 -2
- package/dist/esm/activity-q5o6CCaY.js.map +0 -1
- package/dist/esm/cleartext/index.js.map +0 -1
- package/dist/esm/erc165-GmIEu75Z.js.map +0 -1
- package/dist/esm/relayer-utils--TV3NTMg.js +0 -2
- package/dist/esm/relayer-utils--TV3NTMg.js.map +0 -1
- package/dist/esm/transfer-batcher-C8gp7S82.js +0 -2
- package/dist/esm/transfer-batcher-C8gp7S82.js.map +0 -1
package/dist/esm/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { A as WriteContractConfig, C as TransactionResult, D as ReadContractReturnType, E as ReadContractConfig, J as GenericLogger, O as ReadFunctionName, S as TransactionReceipt, T as ReadContractArgs, _ as StoredCredentials, a as EncryptResult, b as SignerLifecycleCallbacks, c as PublicDecryptResult, d as RelayerWebSecurityConfig, f as UserDecryptParams, g as DelegatedStoredCredentials, h as UnshieldCallbacks, i as EncryptParams, j as WriteFunctionName, k as WriteContractArgs, l as RelayerSDKStatus, m as TransferCallbacks, n as EIP712TypedData, o as Handle, p as ShieldCallbacks, r as EncryptInput, s as NetworkType, t as DelegatedUserDecryptParams, u as RelayerWebConfig, v as GenericStorage, w as ContractAbi, x as RawLog, y as GenericSigner } from "./relayer-sdk.types
|
|
2
|
-
import { A as confidentialTransferFromContract, C as
|
|
3
|
-
import { t as RelayerSDK } from "./relayer-sdk-
|
|
4
|
-
import { n as MainnetConfig, r as SepoliaConfig, t as HardhatConfig } from "./relayer-utils-
|
|
5
|
-
import { $ as
|
|
1
|
+
import { A as WriteContractConfig, C as TransactionResult, D as ReadContractReturnType, E as ReadContractConfig, J as GenericLogger, O as ReadFunctionName, S as TransactionReceipt, T as ReadContractArgs, _ as StoredCredentials, a as EncryptResult, b as SignerLifecycleCallbacks, c as PublicDecryptResult, d as RelayerWebSecurityConfig, f as UserDecryptParams, g as DelegatedStoredCredentials, h as UnshieldCallbacks, i as EncryptParams, j as WriteFunctionName, k as WriteContractArgs, l as RelayerSDKStatus, m as TransferCallbacks, n as EIP712TypedData, o as Handle, p as ShieldCallbacks, r as EncryptInput, s as NetworkType, t as DelegatedUserDecryptParams, u as RelayerWebConfig, v as GenericStorage, w as ContractAbi, x as RawLog, y as GenericSigner } from "./relayer-sdk.types-D7rylLS4.js";
|
|
2
|
+
import { A as decimalsContract, B as confidentialTransferFromContract, C as isConfidentialWrapperContract, D as allowanceContract, E as wrapperExistsContract, F as wrapContract, G as setFinalizeUnwrapOperatorContract, H as isFinalizeUnwrapOperatorContract, I as wrapETHContract, J as unwrapContract, K as setOperatorContract, L as confidentialBalanceOfContract, M as symbolContract, N as finalizeUnwrapContract, O as approveContract, P as underlyingContract, R as confidentialTotalSupplyContract, S as isConfidentialTokenContract, T as getWrapperContract, U as isOperatorContract, V as deploymentCoordinatorContract, W as rateContract, Y as unwrapFromBalanceContract, _ as getFeeRecipientContract, a as getTokenAddressContract, b as ERC7984_INTERFACE_ID, c as getTokenPairsLengthContract, d as delegateForUserDecryptionContract, f as getDelegationExpiryContract, g as getBatchTransferFeeContract, h as confidentialBatchTransferContract, i as getConfidentialTokenAddressContract, j as nameContract, k as balanceOfContract, l as getTokenPairsSliceContract, m as BatchTransferData, n as TokenWrapperPair, o as getTokenPairContract, p as revokeDelegationContract, q as totalSupplyContract, r as TokenWrapperPairWithMetadata, s as getTokenPairsContract, t as PaginatedResult, u as isConfidentialTokenValidContract, v as getUnwrapFeeContract, w as supportsInterfaceContract, x as ERC7984_WRAPPER_INTERFACE_ID, y as getWrapFeeContract, z as confidentialTransferContract } from "./index-IhsduS7h.js";
|
|
3
|
+
import { t as RelayerSDK } from "./relayer-sdk-CcIghrEq.js";
|
|
4
|
+
import { n as MainnetConfig, r as SepoliaConfig, t as HardhatConfig } from "./relayer-utils-BcTAyZOr.js";
|
|
5
|
+
import { $ as CredentialsCreatedEvent, A as ListPairsOptions, B as ReadonlyToken, C as decodeUnwrappedStarted, Ct as ZamaSDKEvent, D as ZamaSDK, Dt as ZamaSDKEvents, E as findWrapped, Et as ZamaSDKEventType, F as ZamaError, G as CredentialsManager, H as ZERO_HANDLE, I as ZamaErrorCode, J as ApproveUnderlyingSubmittedEvent, K as CredentialsManagerConfig, L as matchZamaError, M as WrappersRegistryConfig, N as Token, O as ZamaSDKConfig, P as TokenConfig, Q as CredentialsCorruptedEvent, R as BatchDecryptAsOptions, S as decodeUnwrappedFinalized, St as UnwrapSubmittedEvent, T as findUnwrapRequested, Tt as ZamaSDKEventListener, U as DelegatedCredentialsManager, V as ReadonlyTokenConfig, W as DelegatedCredentialsManagerConfig, X as CredentialsAllowedEvent, Y as BaseEvent, Z as CredentialsCachedEvent, _ as WrappedEvent, _t as TransferFromSubmittedEvent, a as ActivityType, at as DecryptEndEvent, b as decodeOnChainEvents, bt as UnshieldPhase2StartedEvent, c as parseActivityFeed, ct as DelegationSubmittedEvent, d as OnChainEvent, dt as EncryptStartEvent, et as CredentialsCreatingEvent, f as TOKEN_TOPICS, ft as FinalizeUnwrapSubmittedEvent, g as UnwrappedStartedEvent, gt as TransactionErrorEvent, h as UnwrappedFinalizedEvent, ht as ShieldSubmittedEvent, i as ActivityLogMetadata, it as CredentialsRevokedEvent, j as WrappersRegistry, k as DefaultRegistryAddresses, l as sortByBlockNumber, lt as EncryptEndEvent, m as UnwrapRequestedEvent, mt as SessionExpiredEvent, n as ActivityDirection, nt as CredentialsLoadingEvent, o as applyDecryptedValues, ot as DecryptErrorEvent, p as Topics, pt as RevokeDelegationSubmittedEvent, q as ApproveSubmittedEvent, r as ActivityItem, rt as CredentialsPersistFailedEvent, s as extractEncryptedHandles, st as DecryptStartEvent, t as ActivityAmount, tt as CredentialsExpiredEvent, u as ConfidentialTransferEvent, ut as EncryptErrorEvent, v as decodeConfidentialTransfer, vt as TransferSubmittedEvent, w as decodeWrapped, wt as ZamaSDKEventInput, x as decodeUnwrapRequested, xt as UnshieldPhase2SubmittedEvent, y as decodeOnChainEvent, yt as UnshieldPhase1SubmittedEvent, z as BatchDecryptOptions } from "./activity-BRrEPcPO.js";
|
|
6
6
|
import { Address, Address as Address$1, Hex, Hex as Hex$1 } from "viem";
|
|
7
7
|
import { ClearValueType, ClearValueType as ClearValueType$1, FheTypeName, FhevmInstanceConfig, InputProofBytesType, InputProofBytesType as InputProofBytesType$1, KeypairType, KeypairType as KeypairType$1, KmsDelegatedUserDecryptEIP712Type, KmsDelegatedUserDecryptEIP712Type as KmsDelegatedUserDecryptEIP712Type$1, ZKProofLike, ZKProofLike as ZKProofLike$1 } from "@zama-fhe/relayer-sdk/bundle";
|
|
8
8
|
|
|
@@ -245,5 +245,5 @@ declare class ChromeSessionStorage implements GenericStorage {
|
|
|
245
245
|
/** Default singleton for application-wide use. */
|
|
246
246
|
declare const chromeSessionStorage: ChromeSessionStorage;
|
|
247
247
|
//#endregion
|
|
248
|
-
export { type ActivityAmount, type ActivityDirection, type ActivityItem, type ActivityLogMetadata, type ActivityType, type Address, ApprovalFailedError, type ApproveSubmittedEvent, type ApproveUnderlyingSubmittedEvent, type BaseEvent, type BatchDecryptAsOptions, type BatchDecryptOptions, type BatchTransferData, ChromeSessionStorage, type ClearValueType, type ConfidentialTransferEvent, ConfigurationError, type ContractAbi, type CredentialsAllowedEvent, type CredentialsCachedEvent, type CredentialsCorruptedEvent, type CredentialsCreatedEvent, type CredentialsCreatingEvent, type CredentialsExpiredEvent, type CredentialsLoadingEvent, CredentialsManager, type CredentialsManagerConfig, type CredentialsPersistFailedEvent, type CredentialsRevokedEvent, type DecryptEndEvent, type DecryptErrorEvent, type DecryptStartEvent, DecryptionFailedError, DelegatedCredentialsManager, type DelegatedCredentialsManagerConfig, type DelegatedStoredCredentials, type DelegatedUserDecryptParams, DelegationCooldownError, DelegationExpiredError, DelegationNotFoundError, DelegationSelfNotAllowedError, type DelegationSubmittedEvent, type EIP712TypedData, ERC7984_INTERFACE_ID, ERC7984_WRAPPER_INTERFACE_ID, type EncryptEndEvent, type EncryptErrorEvent, type EncryptInput, type EncryptParams, type EncryptResult, type EncryptStartEvent, EncryptionFailedError, type FheTypeName, type FhevmInstanceConfig, type FinalizeUnwrapSubmittedEvent, type GenericLogger, type GenericSigner, type GenericStorage, type Handle, HardhatConfig, type Hex, IndexedDBStorage, type InputProofBytesType, InvalidKeypairError, KeypairExpiredError, type KeypairType, type KmsDelegatedUserDecryptEIP712Type, MainnetConfig, MemoryStorage, type NetworkType, NoCiphertextError, type OnChainEvent, type PublicDecryptResult, type RawLog, type ReadContractArgs, type ReadContractConfig, type ReadContractReturnType, type ReadFunctionName, ReadonlyToken, type ReadonlyTokenConfig, RelayerRequestFailedError, type RelayerSDK, type RelayerSDKStatus, RelayerWeb, type RelayerWebConfig, type RelayerWebSecurityConfig, type RevokeDelegationSubmittedEvent, SepoliaConfig, type SessionExpiredEvent, type ShieldCallbacks, type ShieldSubmittedEvent, type SignerLifecycleCallbacks, SigningFailedError, SigningRejectedError, type StoredCredentials, TOKEN_TOPICS, Token, type TokenConfig, Topics, type TransactionErrorEvent, type TransactionReceipt, type TransactionResult, TransactionRevertedError, type TransferCallbacks, type TransferFromSubmittedEvent, type TransferSubmittedEvent, type UnshieldCallbacks, type UnshieldPhase1SubmittedEvent, type UnshieldPhase2StartedEvent, type UnshieldPhase2SubmittedEvent, type UnwrapRequestedEvent, type UnwrapSubmittedEvent, type UnwrappedFinalizedEvent, type UnwrappedStartedEvent, type UserDecryptParams, type WrappedEvent, type WriteContractArgs, type WriteContractConfig, type WriteFunctionName, ZERO_HANDLE, type ZKProofLike, ZamaError, ZamaErrorCode, ZamaSDK, type ZamaSDKConfig, type ZamaSDKEvent, type ZamaSDKEventInput, type ZamaSDKEventListener, type ZamaSDKEventType, ZamaSDKEvents, allowanceContract, applyDecryptedValues, approveContract, balanceOfContract, chromeSessionStorage, clearPendingUnshield, confidentialBalanceOfContract, confidentialBatchTransferContract, confidentialTotalSupplyContract, confidentialTransferContract, confidentialTransferFromContract, decimalsContract, decodeConfidentialTransfer, decodeOnChainEvent, decodeOnChainEvents, decodeUnwrapRequested, decodeUnwrappedFinalized, decodeUnwrappedStarted, decodeWrapped, delegateForUserDecryptionContract, deploymentCoordinatorContract, extractEncryptedHandles, finalizeUnwrapContract, findUnwrapRequested, findWrapped, getBatchTransferFeeContract, getDelegationExpiryContract, getFeeRecipientContract, getUnwrapFeeContract, getWrapFeeContract, getWrapperContract, indexedDBStorage, isConfidentialTokenContract, isConfidentialWrapperContract, isFinalizeUnwrapOperatorContract, isOperatorContract, loadPendingUnshield, matchZamaError, memoryStorage, nameContract, parseActivityFeed, rateContract, revokeDelegationContract, savePendingUnshield, setFinalizeUnwrapOperatorContract, setOperatorContract, sortByBlockNumber, supportsInterfaceContract, symbolContract, totalSupplyContract, underlyingContract, unwrapContract, unwrapFromBalanceContract, wrapContract, wrapETHContract, wrapperExistsContract };
|
|
248
|
+
export { type ActivityAmount, type ActivityDirection, type ActivityItem, type ActivityLogMetadata, type ActivityType, type Address, ApprovalFailedError, type ApproveSubmittedEvent, type ApproveUnderlyingSubmittedEvent, type BaseEvent, type BatchDecryptAsOptions, type BatchDecryptOptions, type BatchTransferData, ChromeSessionStorage, type ClearValueType, type ConfidentialTransferEvent, ConfigurationError, type ContractAbi, type CredentialsAllowedEvent, type CredentialsCachedEvent, type CredentialsCorruptedEvent, type CredentialsCreatedEvent, type CredentialsCreatingEvent, type CredentialsExpiredEvent, type CredentialsLoadingEvent, CredentialsManager, type CredentialsManagerConfig, type CredentialsPersistFailedEvent, type CredentialsRevokedEvent, type DecryptEndEvent, type DecryptErrorEvent, type DecryptStartEvent, DecryptionFailedError, DefaultRegistryAddresses, DelegatedCredentialsManager, type DelegatedCredentialsManagerConfig, type DelegatedStoredCredentials, type DelegatedUserDecryptParams, DelegationCooldownError, DelegationExpiredError, DelegationNotFoundError, DelegationSelfNotAllowedError, type DelegationSubmittedEvent, type EIP712TypedData, ERC7984_INTERFACE_ID, ERC7984_WRAPPER_INTERFACE_ID, type EncryptEndEvent, type EncryptErrorEvent, type EncryptInput, type EncryptParams, type EncryptResult, type EncryptStartEvent, EncryptionFailedError, type FheTypeName, type FhevmInstanceConfig, type FinalizeUnwrapSubmittedEvent, type GenericLogger, type GenericSigner, type GenericStorage, type Handle, HardhatConfig, type Hex, IndexedDBStorage, type InputProofBytesType, InvalidKeypairError, KeypairExpiredError, type KeypairType, type KmsDelegatedUserDecryptEIP712Type, type ListPairsOptions, MainnetConfig, MemoryStorage, type NetworkType, NoCiphertextError, type OnChainEvent, type PaginatedResult, type PublicDecryptResult, type RawLog, type ReadContractArgs, type ReadContractConfig, type ReadContractReturnType, type ReadFunctionName, ReadonlyToken, type ReadonlyTokenConfig, RelayerRequestFailedError, type RelayerSDK, type RelayerSDKStatus, RelayerWeb, type RelayerWebConfig, type RelayerWebSecurityConfig, type RevokeDelegationSubmittedEvent, SepoliaConfig, type SessionExpiredEvent, type ShieldCallbacks, type ShieldSubmittedEvent, type SignerLifecycleCallbacks, SigningFailedError, SigningRejectedError, type StoredCredentials, TOKEN_TOPICS, Token, type TokenConfig, type TokenWrapperPair, type TokenWrapperPairWithMetadata, Topics, type TransactionErrorEvent, type TransactionReceipt, type TransactionResult, TransactionRevertedError, type TransferCallbacks, type TransferFromSubmittedEvent, type TransferSubmittedEvent, type UnshieldCallbacks, type UnshieldPhase1SubmittedEvent, type UnshieldPhase2StartedEvent, type UnshieldPhase2SubmittedEvent, type UnwrapRequestedEvent, type UnwrapSubmittedEvent, type UnwrappedFinalizedEvent, type UnwrappedStartedEvent, type UserDecryptParams, type WrappedEvent, WrappersRegistry, type WrappersRegistryConfig, type WriteContractArgs, type WriteContractConfig, type WriteFunctionName, ZERO_HANDLE, type ZKProofLike, ZamaError, ZamaErrorCode, ZamaSDK, type ZamaSDKConfig, type ZamaSDKEvent, type ZamaSDKEventInput, type ZamaSDKEventListener, type ZamaSDKEventType, ZamaSDKEvents, allowanceContract, applyDecryptedValues, approveContract, balanceOfContract, chromeSessionStorage, clearPendingUnshield, confidentialBalanceOfContract, confidentialBatchTransferContract, confidentialTotalSupplyContract, confidentialTransferContract, confidentialTransferFromContract, decimalsContract, decodeConfidentialTransfer, decodeOnChainEvent, decodeOnChainEvents, decodeUnwrapRequested, decodeUnwrappedFinalized, decodeUnwrappedStarted, decodeWrapped, delegateForUserDecryptionContract, deploymentCoordinatorContract, extractEncryptedHandles, finalizeUnwrapContract, findUnwrapRequested, findWrapped, getBatchTransferFeeContract, getConfidentialTokenAddressContract, getDelegationExpiryContract, getFeeRecipientContract, getTokenAddressContract, getTokenPairContract, getTokenPairsContract, getTokenPairsLengthContract, getTokenPairsSliceContract, getUnwrapFeeContract, getWrapFeeContract, getWrapperContract, indexedDBStorage, isConfidentialTokenContract, isConfidentialTokenValidContract, isConfidentialWrapperContract, isFinalizeUnwrapOperatorContract, isOperatorContract, loadPendingUnshield, matchZamaError, memoryStorage, nameContract, parseActivityFeed, rateContract, revokeDelegationContract, savePendingUnshield, setFinalizeUnwrapOperatorContract, setOperatorContract, sortByBlockNumber, supportsInterfaceContract, symbolContract, totalSupplyContract, underlyingContract, unwrapContract, unwrapFromBalanceContract, wrapContract, wrapETHContract, wrapperExistsContract };
|
|
249
249
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/esm/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as e,i as t,n,r,t as i}from"./relayer-BwP0WtkF.js";import{A as a,B as o,C as s,D as c,E as l,F as u,H as
|
|
1
|
+
import{a as e,i as t,n,r,t as i}from"./relayer-BwP0WtkF.js";import{A as a,B as o,C as s,D as c,E as l,F as u,H as d,I as f,L as p,M as m,N as ee,O as te,P as h,R as ne,S as g,T as re,U as ie,V as ae,W as oe,_ as se,a as ce,b as _,c as le,d as ue,f as de,g as v,h as fe,i as pe,j as me,k as y,l as he,m as ge,n as _e,o as ve,p as ye,r as be,s as xe,t as Se,u as Ce,v as b,w as x,x as we,y as S,z as Te}from"./activity-ChJnF5yd.js";import{n as C,t as w}from"./encryption-cqcqcQQB.js";import{n as Ee,t as De}from"./fhe-artifact-cache-vzh7Xn9G.js";import{n as Oe,r as T,t as E}from"./memory-storage-DNvc-6oK.js";import{a as ke,r as D}from"./assertions-BNzM20oj.js";import{a as Ae,i as O,n as je,o as k,r as A,t as j}from"./relayer-utils-BeoTNDM4.js";import{C as M,D as Me,E as N,O as P,S as Ne,T as Pe,_ as Fe,a as F,b as I,c as Ie,d as Le,f as Re,g as L,h as R,i as z,k as ze,l as Be,m as Ve,n as B,o as V,p as He,r as Ue,s as H,t as U,u as We,v as Ge,w as Ke,x as qe,y as Je}from"./wrappers-registry-DqPr_JG2.js";import{n as Ye,r as Xe,t as Ze}from"./transfer-batcher-BXIo7hnu.js";import{n as Qe}from"./cleartext-CxGEREks.js";import{getAddress as W,hexToBigInt as $e}from"viem";var G=class extends r{constructor(e,n){super(t.ApprovalFailed,e,n),this.name=`ApprovalFailedError`}},K=class extends r{constructor(e,n){super(t.TransactionReverted,e,n),this.name=`TransactionRevertedError`}},q=class{#e=null;#t=null;#n;#r;#i;constructor(e=`CredentialStore`,t=1,n=`credentials`){this.#n=e,this.#r=t,this.#i=n}#a(){return this.#e?Promise.resolve(this.#e):(this.#t||=new Promise((e,t)=>{let n=indexedDB.open(this.#n,this.#r);n.onupgradeneeded=()=>{let e=n.result;e.objectStoreNames.contains(this.#i)||e.createObjectStore(this.#i,{keyPath:`key`})},n.onsuccess=()=>{this.#e=n.result,this.#t=null,this.#e.onversionchange=()=>{console.warn(`IndexedDB "${this.#n}" closing due to version change from another tab`),this.#e?.close(),this.#e=null,this.#t=null},this.#e.onclose=()=>{this.#e=null,this.#t=null},e(this.#e)},n.onerror=()=>{this.#e=null,this.#t=null,t(n.error)}}),this.#t)}async#o(e,t){let n=await this.#a();return new Promise((r,i)=>{let a=n.transaction(this.#i,e);a.onabort=()=>i(a.error??Error(`Transaction aborted`));let o=t(a.objectStore(this.#i));e===`readonly`?o.onsuccess=()=>r(o.result):a.oncomplete=()=>r(o.result),o.onerror=()=>i(o.error)})}async get(e){return(await this.#o(`readonly`,t=>t.get(e)))?.value??null}async set(e,t){await this.#o(`readwrite`,n=>n.put({key:e,value:t}))}async delete(e){await this.#o(`readwrite`,t=>t.delete(e))}async clear(){await this.#o(`readwrite`,e=>e.clear())}};const et=new q;function tt(e,t){if(typeof e!=`function`)throw TypeError(`${t} must be a function, got ${typeof e}`)}function nt(e,t,n){tt(e[t],n)}function rt(){let e=globalThis;for(let t of[e.chrome,e.browser])try{D(t,`ns`);let{runtime:e}=t;return D(e,`runtime`),ke(e,`id`,`runtime.id`),nt(e,`getURL`,`runtime.getURL`),e}catch{continue}}var it=`(function() {
|
|
2
2
|
//#region src/utils/assertions.ts
|
|
3
3
|
function assertObject(value, context) {
|
|
4
4
|
if (typeof value !== "object" || value === null || Array.isArray(value)) throw new TypeError(\`\${context} must be an object, got \${typeof value}\`);
|
|
@@ -494,5 +494,5 @@ import{a as e,i as t,n,r,t as i}from"./relayer-BwP0WtkF.js";import{A as a,B as o
|
|
|
494
494
|
};
|
|
495
495
|
//#endregion
|
|
496
496
|
})();
|
|
497
|
-
`,Y=class extends D{constructor(e){super(e,e.logger)}createWorker(){let e=qe();if(e)return new Worker(e.getURL(`relayer-sdk.worker.js`));let t=URL.createObjectURL(new Blob([Je],{type:`application/javascript`}));try{return new Worker(t)}finally{URL.revokeObjectURL(t)}}wireEvents(e){e.onmessage=e=>this.handleResponse(e.data),e.onerror=e=>this.handleWorkerError(e.message),e.onmessageerror=()=>this.handleWorkerMessageError()}postMessage(e,t){e.postMessage(t)}terminateWorker(e){e.terminate()}generateRequestId(){return crypto.randomUUID()}getInitPayload(){let{cdnUrl:e,fhevmConfig:t,csrfToken:n,integrity:r,thread:i}=this.config;return{type:`INIT`,payload:{cdnUrl:e,fhevmConfig:t,csrfToken:n,integrity:r,thread:i}}}async updateCsrf(e){await this.sendRequest(`UPDATE_CSRF`,{csrfToken:e})}},Ye=class{#e=null;#t=null;#n=null;#r=!1;#i=null;#a=null;#o=null;#s=`idle`;#c;#l;constructor(e){this.#l=e}get status(){return this.#s}get initError(){return this.#c}#u(e,t){this.#s=e,this.#c=t,this.#l.onStatusChange?.(e,t)}async#d(){let e=await this.#l.getChainId(),{transports:t,security:n,threads:r}=this.#l;if(r!==void 0&&(!Number.isInteger(r)||r<1))throw Error(`Invalid thread count: ${r}. Must be a positive integer.`);return r!==void 0&&globalThis.SharedArrayBuffer===void 0&&this.#l.logger?.warn(`threads option requires SharedArrayBuffer (COOP/COEP headers). Falling back to single-threaded.`),{cdnUrl:`https://cdn.zama.org/relayer-sdk-js/0.4.2/relayer-sdk-js.umd.cjs`,fhevmConfig:Object.assign({},P[e],t[e]),csrfToken:n?.getCsrfToken?.()??``,integrity:n?.integrityCheck===!1?void 0:`114438b01d518b53a447fa3e8bfbe6e71031cb42ac43219bb9f53488456fdfa4bbc8989628366d436e68f6526c7647eb`,logger:this.#l.logger,thread:r}}async#f(){if(this.#n)return this.#n;this.#n=this.#m();try{return await this.#n}finally{this.#n=null}}#p(){this.#e?.terminate(),this.#e=null,this.#t=null,this.#a=null}async#m(){this.#r&&(this.#r=!1,this.#e=null,this.#t=null,this.#i=null);let e=await this.#l.getChainId();if(this.#i!==null&&e!==this.#i&&this.#p(),this.#i=e,this.#o||=this.#l.fheArtifactStorage??new J(`FheArtifactCache`,1,`artifacts`),!this.#a){let t=Object.assign({},P[e],this.#l.transports[e]);this.#a=new O({storage:this.#o,chainId:e,relayerUrl:t.relayerUrl,ttl:this.#l.fheArtifactCacheTTL,logger:this.#l.logger})}if(this.#a){let e=!1;try{e=await this.#a.revalidateIfDue()}catch(e){this.#l.logger?.warn(`Artifact revalidation failed, proceeding with potentially stale cache`,{error:e instanceof Error?e.message:String(e)})}e&&(this.#l.logger?.info(`Cached FHE artifacts are stale — reinitializing`),this.#p())}return this.#t||=(this.#u(`initializing`),this.#h().then(e=>(this.#u(`ready`),e)).catch(e=>{this.#t=null;let t=e instanceof r?e:new i(`Failed to initialize FHE worker`,{cause:e});throw this.#u(`error`,t),t})),this.#t}async#h(){let e=new Y(await this.#d());if(await e.initWorker(),this.#r)throw e.terminate(),Error(`RelayerWeb was terminated during initialization`);return this.#e=e,e}terminate(){this.#r=!0,this.#e&&=(this.#e.terminate(),null),this.#t=null,this.#n=null}async#g(){if(this.#e){let e=this.#l.security?.getCsrfToken?.()??``;e&&await this.#e.updateCsrf(e)}}async generateKeypair(){let e=await(await this.#f()).generateKeypair();return{publicKey:e.publicKey,privateKey:e.privateKey}}async createEIP712(e,t,n,r=7){let i=await(await this.#f()).createEIP712({publicKey:e,contractAddresses:t,startTimestamp:n,durationDays:r}),a={name:i.domain.name,version:i.domain.version,chainId:i.domain.chainId,verifyingContract:i.domain.verifyingContract};return{domain:a,types:{EIP712Domain:we(a),UserDecryptRequestVerification:i.types.UserDecryptRequestVerification},message:{publicKey:i.message.publicKey,contractAddresses:i.message.contractAddresses,startTimestamp:i.message.startTimestamp,durationDays:i.message.durationDays,extraData:i.message.extraData}}}async encrypt(e){let{values:t,contractAddress:n,userAddress:r}=e;return N(async()=>{let e=await this.#f();await this.#g();let i=await e.encrypt({values:t,contractAddress:n,userAddress:r});return{handles:i.handles,inputProof:i.inputProof}})}async userDecrypt(e){return N(async()=>{let t=await this.#f();return await this.#g(),(await t.userDecrypt(e)).clearValues})}async publicDecrypt(e){return N(async()=>{let t=await this.#f();await this.#g();let n=await t.publicDecrypt(e);return{clearValues:n.clearValues,abiEncodedClearValues:n.abiEncodedClearValues,decryptionProof:n.decryptionProof}})}async createDelegatedUserDecryptEIP712(e,t,n,r,i=7){return(await this.#f()).createDelegatedUserDecryptEIP712({publicKey:e,contractAddresses:t,delegatorAddress:n,startTimestamp:r,durationDays:i})}async delegatedUserDecrypt(e){return N(async()=>{let t=await this.#f();return await this.#g(),(await t.delegatedUserDecrypt(e)).clearValues})}async requestZKProofVerification(e){return N(async()=>{let t=await this.#f();return await this.#g(),t.requestZKProofVerification(e)})}async getPublicKey(){let e=await this.#f();return this.#a?this.#a.getPublicKey(async()=>(await e.getPublicKey()).result):(await e.getPublicKey()).result}async getPublicParams(e){let t=await this.#f();return this.#a?this.#a.getPublicParams(e,async()=>(await t.getPublicParams(e)).result):(await t.getPublicParams(e)).result}async getAclAddress(){let e=await this.#l.getChainId(),t=Object.assign({},P[e],this.#l.transports[e]);if(!t.aclContractAddress)throw new i(`No ACL address configured for chain ${e}`);return t.aclContractAddress}},X=class e extends _{static ZERO_ADDRESS=`0x0000000000000000000000000000000000000000`;wrapper;#e;#t=null;constructor(e){super(e),this.wrapper=e.wrapper?G(e.wrapper):this.address}async#n(){return this.#e===void 0?(this.#t||=this.signer.readContract(z(this.wrapper)).then(e=>(this.#e=e,this.#t=null,e)).catch(e=>{throw this.#t=null,e}),this.#t):this.#e}async confidentialTransfer(e,t,n){let i=G(e),a,o,s=Date.now();try{this.emit({type:g.EncryptStart}),{handles:a,inputProof:o}=await this.relayer.encrypt({values:[{value:t,type:`euint64`}],contractAddress:this.address,userAddress:await this.signer.getAddress()}),this.emit({type:g.EncryptEnd,durationMs:Date.now()-s}),Z(()=>n?.onEncryptComplete?.())}catch(e){throw this.emit({type:g.EncryptError,error:A(e),durationMs:Date.now()-s}),e instanceof r?e:new T(`Failed to encrypt transfer amount`,{cause:e})}if(a.length===0)throw new T(`Encryption returned no handles`);try{let e=await this.signer.writeContract(B(this.address,i,a[0],o));return this.emit({type:g.TransferSubmitted,txHash:e}),Z(()=>n?.onTransferSubmitted?.(e)),{txHash:e,receipt:await this.signer.waitForTransactionReceipt(e)}}catch(e){throw this.emit({type:g.TransactionError,operation:`transfer`,error:A(e)}),e instanceof r?e:new q(`Transfer transaction failed`,{cause:e})}}async confidentialTransferFrom(e,t,n,i){let a=G(e),o=G(t),s,c,l=Date.now();try{this.emit({type:g.EncryptStart}),{handles:s,inputProof:c}=await this.relayer.encrypt({values:[{value:n,type:`euint64`}],contractAddress:this.address,userAddress:a}),this.emit({type:g.EncryptEnd,durationMs:Date.now()-l}),Z(()=>i?.onEncryptComplete?.())}catch(e){throw this.emit({type:g.EncryptError,error:A(e),durationMs:Date.now()-l}),e instanceof r?e:new T(`Failed to encrypt transferFrom amount`,{cause:e})}if(s.length===0)throw new T(`Encryption returned no handles`);try{let e=await this.signer.writeContract(R(this.address,a,o,s[0],c));return this.emit({type:g.TransferFromSubmitted,txHash:e}),Z(()=>i?.onTransferSubmitted?.(e)),{txHash:e,receipt:await this.signer.waitForTransactionReceipt(e)}}catch(e){throw this.emit({type:g.TransactionError,operation:`transferFrom`,error:A(e)}),e instanceof r?e:new q(`TransferFrom transaction failed`,{cause:e})}}async approve(e,t){let n=G(e);try{let e=await this.signer.writeContract(W(this.address,n,t));return this.emit({type:g.ApproveSubmitted,txHash:e}),{txHash:e,receipt:await this.signer.waitForTransactionReceipt(e)}}catch(e){throw this.emit({type:g.TransactionError,operation:`approve`,error:A(e)}),e instanceof r?e:new K(`Operator approval failed`,{cause:e})}}async isApproved(e,t){let n=G(e),r=t?G(t):await this.signer.getAddress();return this.signer.readContract(H(this.address,r,n))}async shield(t,n){if(await this.#n()===e.ZERO_ADDRESS)return this.shieldETH(t,t+(n?.fees??0n));let i=n?.approvalStrategy??`exact`;i!==`skip`&&await this.#a(t,i===`max`,n?.callbacks);try{let e=n?.to?G(n.to):await this.signer.getAddress(),r=await this.signer.writeContract(V(this.wrapper,e,t));return this.emit({type:g.ShieldSubmitted,txHash:r}),Z(()=>n?.callbacks?.onShieldSubmitted?.(r)),{txHash:r,receipt:await this.signer.waitForTransactionReceipt(r)}}catch(e){throw this.emit({type:g.TransactionError,operation:`shield`,error:A(e)}),e instanceof r?e:new q(`Shield transaction failed`,{cause:e})}}async shieldETH(e,t){try{let n=await this.signer.getAddress(),r=await this.signer.writeContract(L(this.wrapper,n,e,t??e));return this.emit({type:g.ShieldSubmitted,txHash:r}),{txHash:r,receipt:await this.signer.waitForTransactionReceipt(r)}}catch(e){throw this.emit({type:g.TransactionError,operation:`shieldETH`,error:A(e)}),e instanceof r?e:new q(`Shield ETH transaction failed`,{cause:e})}}async unwrap(e){let t=await this.signer.getAddress(),n,i,a=Date.now();try{this.emit({type:g.EncryptStart}),{handles:n,inputProof:i}=await this.relayer.encrypt({values:[{value:e,type:`euint64`}],contractAddress:this.wrapper,userAddress:t}),this.emit({type:g.EncryptEnd,durationMs:Date.now()-a})}catch(e){throw this.emit({type:g.EncryptError,error:A(e),durationMs:Date.now()-a}),e instanceof r?e:new T(`Failed to encrypt unshield amount`,{cause:e})}if(n.length===0)throw new T(`Encryption returned no handles`);try{let e=await this.signer.writeContract(F(this.address,t,t,n[0],i));return this.emit({type:g.UnwrapSubmitted,txHash:e}),{txHash:e,receipt:await this.signer.waitForTransactionReceipt(e)}}catch(e){throw this.emit({type:g.TransactionError,operation:`unwrap`,error:A(e)}),e instanceof r?e:new q(`Unshield transaction failed`,{cause:e})}}async unwrapAll(){let e=await this.signer.getAddress(),t=await this.readConfidentialBalanceOf(e);if(this.isZeroHandle(t))throw new E(`Cannot unshield: balance is zero`);try{let n=await this.signer.writeContract(U(this.address,e,e,t));return this.emit({type:g.UnwrapSubmitted,txHash:n}),{txHash:n,receipt:await this.signer.waitForTransactionReceipt(n)}}catch(e){throw this.emit({type:g.TransactionError,operation:`unwrap`,error:A(e)}),e instanceof r?e:new q(`Unshield-all transaction failed`,{cause:e})}}async unshield(e,t){let n=crypto.randomUUID(),r=await this.unwrap(e);return Z(()=>t?.onUnwrapSubmitted?.(r.txHash)),this.#i(r.txHash,t,n)}async unshieldAll(e){let t=crypto.randomUUID(),n=await this.unwrapAll();return Z(()=>e?.onUnwrapSubmitted?.(n.txHash)),this.#i(n.txHash,e,t)}async resumeUnshield(e,t){return this.#i(e,t,crypto.randomUUID())}async finalizeUnwrap(e){let t,n,i=Date.now();try{this.emit({type:g.DecryptStart});let r=await this.relayer.publicDecrypt([e]);this.emit({type:g.DecryptEnd,durationMs:Date.now()-i}),n=r.decryptionProof;try{t=Ue(r.abiEncodedClearValues)}catch{throw new E(`Cannot parse decrypted value: ${r.abiEncodedClearValues}`)}}catch(e){throw this.emit({type:g.DecryptError,error:A(e),durationMs:Date.now()-i}),e instanceof r?e:new E(`Failed to finalize unshield`,{cause:e})}try{let r=await this.signer.writeContract(I(this.wrapper,e,t,n));return this.emit({type:g.FinalizeUnwrapSubmitted,txHash:r}),{txHash:r,receipt:await this.signer.waitForTransactionReceipt(r)}}catch(e){throw this.emit({type:g.TransactionError,operation:`finalizeUnwrap`,error:A(e)}),e instanceof r?e:new q(`Failed to finalize unshield`,{cause:e})}}async approveUnderlying(e){let t=await this.#n(),n=e??2n**256n-1n;try{if(n>0n){let e=await this.signer.getAddress();await this.signer.readContract(v(t,e,this.wrapper))>0n&&await this.signer.writeContract(a(t,this.wrapper,0n))}let e=await this.signer.writeContract(a(t,this.wrapper,n));return this.emit({type:g.ApproveUnderlyingSubmitted,txHash:e}),{txHash:e,receipt:await this.signer.waitForTransactionReceipt(e)}}catch(e){throw this.emit({type:g.TransactionError,operation:`approveUnderlying`,error:A(e)}),e instanceof r?e:new K(`ERC-20 approval failed`,{cause:e})}}async delegateDecryption({delegateAddress:e,expirationDate:t}){if(t&&t.getTime()<=Date.now())throw new i(`Expiration date must be in the future`);let n=await this.getAclAddress(),a=t?BigInt(Math.floor(t.getTime()/1e3)):S;try{let t=await this.signer.writeContract(p(n,G(e),this.address,a));return this.emit({type:g.DelegationSubmitted,txHash:t}),{txHash:t,receipt:await this.signer.waitForTransactionReceipt(t)}}catch(e){throw this.emit({type:g.TransactionError,operation:`delegateDecryption`,error:A(e)}),e instanceof r?e:new q(`Delegation transaction failed`,{cause:e})}}async revokeDelegation({delegateAddress:e}){let t=await this.getAclAddress();try{let n=await this.signer.writeContract(x(t,G(e),this.address));return this.emit({type:g.RevokeDelegationSubmitted,txHash:n}),{txHash:n,receipt:await this.signer.waitForTransactionReceipt(n)}}catch(e){throw this.emit({type:g.TransactionError,operation:`revokeDelegation`,error:A(e)}),e instanceof r?e:new q(`Revoke delegation transaction failed`,{cause:e})}}static async batchDelegateDecryption({tokens:t,delegateAddress:n,expirationDate:r}){return e.#r(t,e=>e.delegateDecryption({delegateAddress:n,expirationDate:r}),`Delegation failed`)}static async batchRevokeDelegation({tokens:t,delegateAddress:n}){return e.#r(t,e=>e.revokeDelegation({delegateAddress:n}),`Revoke delegation failed`)}static async#r(e,t,n){let i=new Map,a=await Promise.allSettled(e.map(t));for(let t=0;t<e.length;t++){let o=a[t];if(o.status===`fulfilled`)i.set(e[t].address,o.value);else{let a=o.reason instanceof r?o.reason:new q(n,{cause:o.reason});i.set(e[t].address,a)}}return i}async#i(e,t,n){this.emit({type:g.UnshieldPhase1Submitted,txHash:e,operationId:n});let i;try{i=await this.signer.waitForTransactionReceipt(e)}catch(e){throw e instanceof r?e:new q(`Failed to get unshield receipt`,{cause:e})}let a=y(i.logs);if(!a)throw new q(`No UnwrapRequested event found in unshield receipt`);this.emit({type:g.UnshieldPhase2Started,operationId:n}),Z(()=>t?.onFinalizing?.());let o=await this.finalizeUnwrap(a.encryptedAmount);return this.emit({type:g.UnshieldPhase2Submitted,txHash:o.txHash,operationId:n}),Z(()=>t?.onFinalizeSubmitted?.(o.txHash)),o}async#a(e,t,n){let i=await this.#n(),o=await this.signer.getAddress(),s=await this.signer.readContract(v(i,o,this.wrapper));if(!(s>=e))try{s>0n&&await this.signer.writeContract(a(i,this.wrapper,0n));let r=t?2n**256n-1n:e,o=await this.signer.writeContract(a(i,this.wrapper,r));this.emit({type:g.ApproveUnderlyingSubmitted,txHash:o}),Z(()=>n?.onApprovalSubmitted?.(o))}catch(e){throw e instanceof r?e:new K(`ERC-20 approval failed`,{cause:e})}}};function Z(e){try{e()}catch(e){console.warn(`[zama-sdk] Callback threw:`,e)}}var Xe=class{relayer;signer;storage;sessionStorage;credentials;delegatedCredentials;#e;#t;#n;#r=null;#i=null;constructor(e){this.relayer=e.relayer,this.signer=e.signer,this.storage=e.storage,this.sessionStorage=e.sessionStorage??new j,this.#e=e.onEvent??function(){};let t={relayer:this.relayer,signer:this.signer,storage:this.storage,sessionStorage:this.sessionStorage,keypairTTL:(()=>{let t=e.keypairTTL??86400;if(t<=0)throw Error(`keypairTTL must be a positive number (seconds)`);return t})(),sessionTTL:e.sessionTTL??2592e3,onEvent:this.#e};if(this.credentials=new C(t),this.delegatedCredentials=new b(t),this.#n=this.#a(),this.signer.subscribe){let t=e.signerLifecycleCallbacks,n=(e,t)=>{t().catch(t=>{this.#e?.({type:g.TransactionError,operation:e,error:A(t),timestamp:Date.now()})})};this.#t=this.signer.subscribe({onDisconnect:()=>{n(`signerDisconnect`,async()=>{await this.#o(),this.#r=null,this.#i=null,t?.onDisconnect?.()})},onAccountChange:e=>{n(`signerAccountChange`,async()=>{await this.#o(),this.#r=G(e);try{this.#i=await this.signer.getChainId()}catch{}t?.onAccountChange?.(e)})},onChainChange:e=>{n(`signerChainChange`,async()=>{await this.#o(),this.#i=e;try{this.#r=await this.signer.getAddress()}catch{}t?.onChainChange?.(e)})}})}}async#a(){try{let e=await this.signer.getAddress(),t=await this.signer.getChainId();this.#r=e,this.#i=t}catch{}}async#o(){if(await this.#n,this.#r===null||this.#i===null)return;let e=await C.computeStoreKey(this.#r,this.#i);await this.credentials.revokeByKey(e)}createReadonlyToken(e){return new _({relayer:this.relayer,signer:this.signer,storage:this.storage,sessionStorage:this.sessionStorage,credentials:this.credentials,delegatedCredentials:this.delegatedCredentials,address:G(e),onEvent:this.#e})}createToken(e,t){return new X({relayer:this.relayer,signer:this.signer,storage:this.storage,sessionStorage:this.sessionStorage,credentials:this.credentials,delegatedCredentials:this.delegatedCredentials,address:G(e),wrapper:t?G(t):void 0,onEvent:this.#e})}async allow(...e){await this.credentials.allow(...e)}async revoke(...e){await this.credentials.revoke(...e)}async revokeSession(){await this.#n;let e=this.#r??await this.signer.getAddress(),t=this.#i??await this.signer.getChainId(),n=await C.computeStoreKey(e,t);await this.credentials.revokeByKey(n)}async isAllowed(){return this.credentials.isAllowed()}dispose(){this.#t?.(),this.#t=void 0}terminate(){this.dispose(),this.relayer.terminate()}};function Q(e){return`zama:pending-unshield:${e}`}async function Ze(e,t,n){await e.set(Q(t),n)}async function Qe(e,t){return e.get(Q(t))}async function $e(e,t){await e.delete(Q(t))}var $=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 et=new $;export{K as ApprovalFailedError,$ as ChromeSessionStorage,i as ConfigurationError,C as CredentialsManager,E as DecryptionFailedError,b as DelegatedCredentialsManager,u as DelegationCooldownError,te as DelegationExpiredError,ne as DelegationNotFoundError,f as DelegationSelfNotAllowedError,Be as ERC7984_INTERFACE_ID,Fe as ERC7984_WRAPPER_INTERFACE_ID,T as EncryptionFailedError,Ee as HardhatConfig,J as IndexedDBStorage,w as InvalidKeypairError,o as KeypairExpiredError,De as MainnetConfig,j as MemoryStorage,oe as NoCiphertextError,_ as ReadonlyToken,n as RelayerRequestFailedError,Ye as RelayerWeb,Te as SepoliaConfig,ee as SigningFailedError,h as SigningRejectedError,ce as TOKEN_TOPICS,X as Token,_e as Topics,q as TransactionRevertedError,se as ZERO_HANDLE,r as ZamaError,t as ZamaErrorCode,Xe as ZamaSDK,g as ZamaSDKEvents,v as allowanceContract,xe as applyDecryptedValues,a as approveContract,me as balanceOfContract,et as chromeSessionStorage,$e as clearPendingUnshield,Me as confidentialBalanceOfContract,He as confidentialBatchTransferContract,Le as confidentialTotalSupplyContract,B as confidentialTransferContract,R as confidentialTransferFromContract,re as decimalsContract,be as decodeConfidentialTransfer,le as decodeOnChainEvent,he as decodeOnChainEvents,Se as decodeUnwrapRequested,ue as decodeUnwrappedFinalized,de as decodeUnwrappedStarted,ve as decodeWrapped,p as delegateForUserDecryptionContract,Ne as deploymentCoordinatorContract,ge as extractEncryptedHandles,I as finalizeUnwrapContract,y as findUnwrapRequested,fe as findWrapped,m as getBatchTransferFeeContract,s as getDelegationExpiryContract,l as getFeeRecipientContract,c as getUnwrapFeeContract,ae as getWrapFeeContract,Ie as getWrapperContract,We as indexedDBStorage,Re as isConfidentialTokenContract,Pe as isConfidentialWrapperContract,ke as isFinalizeUnwrapOperatorContract,H as isOperatorContract,Qe as loadPendingUnshield,e as matchZamaError,k as memoryStorage,ie as nameContract,ye as parseActivityFeed,Ve as rateContract,x as revokeDelegationContract,Ze as savePendingUnshield,je as setFinalizeUnwrapOperatorContract,W as setOperatorContract,pe as sortByBlockNumber,Ae as supportsInterfaceContract,d as symbolContract,Oe as totalSupplyContract,z as underlyingContract,F as unwrapContract,U as unwrapFromBalanceContract,V as wrapContract,L as wrapETHContract,ze as wrapperExistsContract};
|
|
497
|
+
`,at=class extends Ee{constructor(e){super(e,e.logger)}createWorker(){let e=rt();if(e)return new Worker(e.getURL(`relayer-sdk.worker.js`));let t=URL.createObjectURL(new Blob([it],{type:`application/javascript`}));try{return new Worker(t)}finally{URL.revokeObjectURL(t)}}wireEvents(e){e.onmessage=e=>this.handleResponse(e.data),e.onerror=e=>this.handleWorkerError(e.message),e.onmessageerror=()=>this.handleWorkerMessageError()}postMessage(e,t){e.postMessage(t)}terminateWorker(e){e.terminate()}generateRequestId(){return crypto.randomUUID()}getInitPayload(){let{cdnUrl:e,fhevmConfig:t,csrfToken:n,integrity:r,thread:i}=this.config;return{type:`INIT`,payload:{cdnUrl:e,fhevmConfig:t,csrfToken:n,integrity:r,thread:i}}}async updateCsrf(e){await this.sendRequest(`UPDATE_CSRF`,{csrfToken:e})}},ot=class{#e=null;#t=null;#n=null;#r=!1;#i=null;#a=null;#o=null;#s=`idle`;#c;#l;constructor(e){this.#l=e}get status(){return this.#s}get initError(){return this.#c}#u(e,t){this.#s=e,this.#c=t,this.#l.onStatusChange?.(e,t)}async#d(){let e=await this.#l.getChainId(),{transports:t,security:n,threads:r}=this.#l;if(r!==void 0&&(!Number.isInteger(r)||r<1))throw Error(`Invalid thread count: ${r}. Must be a positive integer.`);return r!==void 0&&globalThis.SharedArrayBuffer===void 0&&this.#l.logger?.warn(`threads option requires SharedArrayBuffer (COOP/COEP headers). Falling back to single-threaded.`),{cdnUrl:`https://cdn.zama.org/relayer-sdk-js/0.4.2/relayer-sdk-js.umd.cjs`,fhevmConfig:Object.assign({},j[e],t[e]),csrfToken:n?.getCsrfToken?.()??``,integrity:n?.integrityCheck===!1?void 0:`114438b01d518b53a447fa3e8bfbe6e71031cb42ac43219bb9f53488456fdfa4bbc8989628366d436e68f6526c7647eb`,logger:this.#l.logger,thread:r}}async#f(){if(this.#n)return this.#n;this.#n=this.#m();try{return await this.#n}finally{this.#n=null}}#p(){this.#e?.terminate(),this.#e=null,this.#t=null,this.#a=null}async#m(){this.#r&&(this.#r=!1,this.#e=null,this.#t=null,this.#i=null);let e=await this.#l.getChainId();if(this.#i!==null&&e!==this.#i&&this.#p(),this.#i=e,this.#o||=this.#l.fheArtifactStorage??new q(`FheArtifactCache`,1,`artifacts`),!this.#a){let t=Object.assign({},j[e],this.#l.transports[e]);this.#a=new De({storage:this.#o,chainId:e,relayerUrl:t.relayerUrl,ttl:this.#l.fheArtifactCacheTTL,logger:this.#l.logger})}if(this.#a){let e=!1;try{e=await this.#a.revalidateIfDue()}catch(e){this.#l.logger?.warn(`Artifact revalidation failed, proceeding with potentially stale cache`,{error:e instanceof Error?e.message:String(e)})}e&&(this.#l.logger?.info(`Cached FHE artifacts are stale — reinitializing`),this.#p())}return this.#t||=(this.#u(`initializing`),this.#h().then(e=>(this.#u(`ready`),e)).catch(e=>{this.#t=null;let t=e instanceof r?e:new i(`Failed to initialize FHE worker`,{cause:e});throw this.#u(`error`,t),t})),this.#t}async#h(){let e=new at(await this.#d());if(await e.initWorker(),this.#r)throw e.terminate(),Error(`RelayerWeb was terminated during initialization`);return this.#e=e,e}terminate(){this.#r=!0,this.#e&&=(this.#e.terminate(),null),this.#t=null,this.#n=null}async#g(){if(this.#e){let e=this.#l.security?.getCsrfToken?.()??``;e&&await this.#e.updateCsrf(e)}}async generateKeypair(){let e=await(await this.#f()).generateKeypair();return{publicKey:e.publicKey,privateKey:e.privateKey}}async createEIP712(e,t,n,r=7){let i=await(await this.#f()).createEIP712({publicKey:e,contractAddresses:t,startTimestamp:n,durationDays:r}),a={name:i.domain.name,version:i.domain.version,chainId:i.domain.chainId,verifyingContract:i.domain.verifyingContract};return{domain:a,types:{EIP712Domain:Ae(a),UserDecryptRequestVerification:i.types.UserDecryptRequestVerification},message:{publicKey:i.message.publicKey,contractAddresses:i.message.contractAddresses,startTimestamp:i.message.startTimestamp,durationDays:i.message.durationDays,extraData:i.message.extraData}}}async encrypt(e){let{values:t,contractAddress:n,userAddress:r}=e;return k(async()=>{let e=await this.#f();await this.#g();let i=await e.encrypt({values:t,contractAddress:n,userAddress:r});return{handles:i.handles,inputProof:i.inputProof}})}async userDecrypt(e){return k(async()=>{let t=await this.#f();return await this.#g(),(await t.userDecrypt(e)).clearValues})}async publicDecrypt(e){return k(async()=>{let t=await this.#f();await this.#g();let n=await t.publicDecrypt(e);return{clearValues:n.clearValues,abiEncodedClearValues:n.abiEncodedClearValues,decryptionProof:n.decryptionProof}})}async createDelegatedUserDecryptEIP712(e,t,n,r,i=7){return(await this.#f()).createDelegatedUserDecryptEIP712({publicKey:e,contractAddresses:t,delegatorAddress:n,startTimestamp:r,durationDays:i})}async delegatedUserDecrypt(e){return k(async()=>{let t=await this.#f();return await this.#g(),(await t.delegatedUserDecrypt(e)).clearValues})}async requestZKProofVerification(e){return k(async()=>{let t=await this.#f();return await this.#g(),t.requestZKProofVerification(e)})}async getPublicKey(){let e=await this.#f();return this.#a?this.#a.getPublicKey(async()=>(await e.getPublicKey()).result):(await e.getPublicKey()).result}async getPublicParams(e){let t=await this.#f();return this.#a?this.#a.getPublicParams(e,async()=>(await t.getPublicParams(e)).result):(await t.getPublicParams(e)).result}async getAclAddress(){let e=await this.#l.getChainId(),t=Object.assign({},j[e],this.#l.transports[e]);if(!t.aclContractAddress)throw new i(`No ACL address configured for chain ${e}`);return t.aclContractAddress}},J=class e extends v{static ZERO_ADDRESS=`0x0000000000000000000000000000000000000000`;wrapper;#e;#t=null;constructor(e){super(e),this.wrapper=e.wrapper?W(e.wrapper):this.address}async#n(){return this.#e===void 0?(this.#t||=this.signer.readContract(Ve(this.wrapper)).then(e=>(this.#e=e,this.#t=null,e)).catch(e=>{throw this.#t=null,e}),this.#t):this.#e}async confidentialTransfer(e,t,n){let i=W(e),a,o,s=Date.now();try{this.emit({type:_.EncryptStart}),{handles:a,inputProof:o}=await this.relayer.encrypt({values:[{value:t,type:`euint64`}],contractAddress:this.address,userAddress:await this.signer.getAddress()}),this.emit({type:_.EncryptEnd,durationMs:Date.now()-s}),Y(()=>n?.onEncryptComplete?.())}catch(e){throw this.emit({type:_.EncryptError,error:T(e),durationMs:Date.now()-s}),e instanceof r?e:new C(`Failed to encrypt transfer amount`,{cause:e})}if(a.length===0)throw new C(`Encryption returned no handles`);try{let e=await this.signer.writeContract(Je(this.address,i,a[0],o));return this.emit({type:_.TransferSubmitted,txHash:e}),Y(()=>n?.onTransferSubmitted?.(e)),{txHash:e,receipt:await this.signer.waitForTransactionReceipt(e)}}catch(e){throw this.emit({type:_.TransactionError,operation:`transfer`,error:T(e)}),e instanceof r?e:new K(`Transfer transaction failed`,{cause:e})}}async confidentialTransferFrom(e,t,n,i){let a=W(e),o=W(t),s,c,l=Date.now();try{this.emit({type:_.EncryptStart}),{handles:s,inputProof:c}=await this.relayer.encrypt({values:[{value:n,type:`euint64`}],contractAddress:this.address,userAddress:a}),this.emit({type:_.EncryptEnd,durationMs:Date.now()-l}),Y(()=>i?.onEncryptComplete?.())}catch(e){throw this.emit({type:_.EncryptError,error:T(e),durationMs:Date.now()-l}),e instanceof r?e:new C(`Failed to encrypt transferFrom amount`,{cause:e})}if(s.length===0)throw new C(`Encryption returned no handles`);try{let e=await this.signer.writeContract(I(this.address,a,o,s[0],c));return this.emit({type:_.TransferFromSubmitted,txHash:e}),Y(()=>i?.onTransferSubmitted?.(e)),{txHash:e,receipt:await this.signer.waitForTransactionReceipt(e)}}catch(e){throw this.emit({type:_.TransactionError,operation:`transferFrom`,error:T(e)}),e instanceof r?e:new K(`TransferFrom transaction failed`,{cause:e})}}async approve(e,t){let n=W(e);try{let e=await this.signer.writeContract(N(this.address,n,t));return this.emit({type:_.ApproveSubmitted,txHash:e}),{txHash:e,receipt:await this.signer.waitForTransactionReceipt(e)}}catch(e){throw this.emit({type:_.TransactionError,operation:`approve`,error:T(e)}),e instanceof r?e:new G(`Operator approval failed`,{cause:e})}}async isApproved(e,t){let n=W(e),r=t?W(t):await this.signer.getAddress();return this.signer.readContract(M(this.address,r,n))}async shield(t,n){if(await this.#n()===e.ZERO_ADDRESS)return this.shieldETH(t,t+(n?.fees??0n));let i=n?.approvalStrategy??`exact`;i!==`skip`&&await this.#a(t,i===`max`,n?.callbacks);try{let e=n?.to?W(n.to):await this.signer.getAddress(),r=await this.signer.writeContract(R(this.wrapper,e,t));return this.emit({type:_.ShieldSubmitted,txHash:r}),Y(()=>n?.callbacks?.onShieldSubmitted?.(r)),{txHash:r,receipt:await this.signer.waitForTransactionReceipt(r)}}catch(e){throw this.emit({type:_.TransactionError,operation:`shield`,error:T(e)}),e instanceof r?e:new K(`Shield transaction failed`,{cause:e})}}async shieldETH(e,t){try{let n=await this.signer.getAddress(),r=await this.signer.writeContract(L(this.wrapper,n,e,t??e));return this.emit({type:_.ShieldSubmitted,txHash:r}),{txHash:r,receipt:await this.signer.waitForTransactionReceipt(r)}}catch(e){throw this.emit({type:_.TransactionError,operation:`shieldETH`,error:T(e)}),e instanceof r?e:new K(`Shield ETH transaction failed`,{cause:e})}}async unwrap(e){let t=await this.signer.getAddress(),n,i,a=Date.now();try{this.emit({type:_.EncryptStart}),{handles:n,inputProof:i}=await this.relayer.encrypt({values:[{value:e,type:`euint64`}],contractAddress:this.wrapper,userAddress:t}),this.emit({type:_.EncryptEnd,durationMs:Date.now()-a})}catch(e){throw this.emit({type:_.EncryptError,error:T(e),durationMs:Date.now()-a}),e instanceof r?e:new C(`Failed to encrypt unshield amount`,{cause:e})}if(n.length===0)throw new C(`Encryption returned no handles`);try{let e=await this.signer.writeContract(P(this.address,t,t,n[0],i));return this.emit({type:_.UnwrapSubmitted,txHash:e}),{txHash:e,receipt:await this.signer.waitForTransactionReceipt(e)}}catch(e){throw this.emit({type:_.TransactionError,operation:`unwrap`,error:T(e)}),e instanceof r?e:new K(`Unshield transaction failed`,{cause:e})}}async unwrapAll(){let e=await this.signer.getAddress(),t=await this.readConfidentialBalanceOf(e);if(this.isZeroHandle(t))throw new w(`Cannot unshield: balance is zero`);try{let n=await this.signer.writeContract(ze(this.address,e,e,t));return this.emit({type:_.UnwrapSubmitted,txHash:n}),{txHash:n,receipt:await this.signer.waitForTransactionReceipt(n)}}catch(e){throw this.emit({type:_.TransactionError,operation:`unwrap`,error:T(e)}),e instanceof r?e:new K(`Unshield-all transaction failed`,{cause:e})}}async unshield(e,t){let n=crypto.randomUUID(),r=await this.unwrap(e);return Y(()=>t?.onUnwrapSubmitted?.(r.txHash)),this.#i(r.txHash,t,n)}async unshieldAll(e){let t=crypto.randomUUID(),n=await this.unwrapAll();return Y(()=>e?.onUnwrapSubmitted?.(n.txHash)),this.#i(n.txHash,e,t)}async resumeUnshield(e,t){return this.#i(e,t,crypto.randomUUID())}async finalizeUnwrap(e){let t,n,i=Date.now();try{this.emit({type:_.DecryptStart});let r=await this.relayer.publicDecrypt([e]);this.emit({type:_.DecryptEnd,durationMs:Date.now()-i}),n=r.decryptionProof;try{t=$e(r.abiEncodedClearValues)}catch{throw new w(`Cannot parse decrypted value: ${r.abiEncodedClearValues}`)}}catch(e){throw this.emit({type:_.DecryptError,error:T(e),durationMs:Date.now()-i}),e instanceof r?e:new w(`Failed to finalize unshield`,{cause:e})}try{let r=await this.signer.writeContract(He(this.wrapper,e,t,n));return this.emit({type:_.FinalizeUnwrapSubmitted,txHash:r}),{txHash:r,receipt:await this.signer.waitForTransactionReceipt(r)}}catch(e){throw this.emit({type:_.TransactionError,operation:`finalizeUnwrap`,error:T(e)}),e instanceof r?e:new K(`Failed to finalize unshield`,{cause:e})}}async approveUnderlying(e){let t=await this.#n(),n=e??2n**256n-1n;try{if(n>0n){let e=await this.signer.getAddress();await this.signer.readContract(y(t,e,this.wrapper))>0n&&await this.signer.writeContract(a(t,this.wrapper,0n))}let e=await this.signer.writeContract(a(t,this.wrapper,n));return this.emit({type:_.ApproveUnderlyingSubmitted,txHash:e}),{txHash:e,receipt:await this.signer.waitForTransactionReceipt(e)}}catch(e){throw this.emit({type:_.TransactionError,operation:`approveUnderlying`,error:T(e)}),e instanceof r?e:new G(`ERC-20 approval failed`,{cause:e})}}async delegateDecryption({delegateAddress:e,expirationDate:t}){if(t&&t.getTime()<=Date.now())throw new i(`Expiration date must be in the future`);let n=await this.getAclAddress(),a=t?BigInt(Math.floor(t.getTime()/1e3)):we;try{let t=await this.signer.writeContract(g(n,W(e),this.address,a));return this.emit({type:_.DelegationSubmitted,txHash:t}),{txHash:t,receipt:await this.signer.waitForTransactionReceipt(t)}}catch(e){throw this.emit({type:_.TransactionError,operation:`delegateDecryption`,error:T(e)}),e instanceof r?e:new K(`Delegation transaction failed`,{cause:e})}}async revokeDelegation({delegateAddress:e}){let t=await this.getAclAddress();try{let n=await this.signer.writeContract(x(t,W(e),this.address));return this.emit({type:_.RevokeDelegationSubmitted,txHash:n}),{txHash:n,receipt:await this.signer.waitForTransactionReceipt(n)}}catch(e){throw this.emit({type:_.TransactionError,operation:`revokeDelegation`,error:T(e)}),e instanceof r?e:new K(`Revoke delegation transaction failed`,{cause:e})}}static async batchDelegateDecryption({tokens:t,delegateAddress:n,expirationDate:r}){return e.#r(t,e=>e.delegateDecryption({delegateAddress:n,expirationDate:r}),`Delegation failed`)}static async batchRevokeDelegation({tokens:t,delegateAddress:n}){return e.#r(t,e=>e.revokeDelegation({delegateAddress:n}),`Revoke delegation failed`)}static async#r(e,t,n){let i=new Map,a=await Promise.allSettled(e.map(t));for(let t=0;t<e.length;t++){let o=a[t];if(o.status===`fulfilled`)i.set(e[t].address,o.value);else{let a=o.reason instanceof r?o.reason:new K(n,{cause:o.reason});i.set(e[t].address,a)}}return i}async#i(e,t,n){this.emit({type:_.UnshieldPhase1Submitted,txHash:e,operationId:n});let i;try{i=await this.signer.waitForTransactionReceipt(e)}catch(e){throw e instanceof r?e:new K(`Failed to get unshield receipt`,{cause:e})}let a=ge(i.logs);if(!a)throw new K(`No UnwrapRequested event found in unshield receipt`);this.emit({type:_.UnshieldPhase2Started,operationId:n}),Y(()=>t?.onFinalizing?.());let o=await this.finalizeUnwrap(a.encryptedAmount);return this.emit({type:_.UnshieldPhase2Submitted,txHash:o.txHash,operationId:n}),Y(()=>t?.onFinalizeSubmitted?.(o.txHash)),o}async#a(e,t,n){let i=await this.#n(),o=await this.signer.getAddress(),s=await this.signer.readContract(y(i,o,this.wrapper));if(!(s>=e))try{s>0n&&await this.signer.writeContract(a(i,this.wrapper,0n));let r=t?2n**256n-1n:e,o=await this.signer.writeContract(a(i,this.wrapper,r));this.emit({type:_.ApproveUnderlyingSubmitted,txHash:o}),Y(()=>n?.onApprovalSubmitted?.(o))}catch(e){throw e instanceof r?e:new G(`ERC-20 approval failed`,{cause:e})}}};function Y(e){try{e()}catch(e){console.warn(`[zama-sdk] Callback threw:`,e)}}const st={[A.chainId]:A.registryAddress,[O.chainId]:O.registryAddress,[Qe.chainId]:Qe.registryAddress},X=300*1e3;var Z=class{signer;#e;#t;#n=new Map;constructor(e){this.signer=e.signer,this.#e=Object.assign({},st,e.registryAddresses),this.#t=(e.registryTTL??86400)*1e3}getAddress(e){return this.#e[e]}#r(e){let t=this.#n.get(e);if(t){if(Date.now()>=t.expiresAt){this.#n.delete(e);return}return t.data}}#i(e,t,n=this.#t){return this.#n.set(e,{data:t,expiresAt:Date.now()+n}),t}refresh(){this.#n.clear()}get ttlMs(){return this.#t}async getRegistryAddress(){let e=await this.signer.getChainId(),t=this.#e[e];if(!t)throw new i(`No wrappers registry address configured for chain ${e}.\nPass a registryAddresses entry for this chain.`);return W(t)}async listPairs(e={}){let t=e.page??1,n=e.pageSize??100,r=e.metadata??!1;if(t<1)throw new i(`page must be >= 1, got ${t}`);if(n<1)throw new i(`pageSize must be >= 1, got ${n}`);let a=await this.getRegistryAddress(),o=`total:${a}`,s=this.#r(o);if(s===void 0){let e=await this.signer.readContract(F(a));s=this.#i(o,Number(e))}let c=BigInt((t-1)*n),l=c+BigInt(n)>BigInt(s)?BigInt(s):c+BigInt(n);if(c>=BigInt(s))return{items:[],total:s,page:t,pageSize:n};let u=`slice:${a}:${c}:${l}`,d=this.#r(u);if(d===void 0){let e=await this.signer.readContract(V(a,c,l));d=this.#i(u,[...e])}if(!r)return{items:d,total:s,page:t,pageSize:n};let f=`metadata:${a}:${c}:${l}`,p=this.#r(f);if(p===void 0){let e=await Promise.allSettled(d.map(e=>this.#a(e))),t=e.some(e=>e.status===`rejected`),n=e.map((e,t)=>e.status===`fulfilled`?e.value:Object.assign({},d[t],{metadataFailed:!0,underlying:{name:`Unknown`,symbol:`???`,decimals:0,totalSupply:0n},confidential:{name:`Unknown`,symbol:`???`,decimals:0}}));p=this.#i(f,n,t?X:void 0)}return{items:p,total:s,page:t,pageSize:n}}async#a(e){let[t,n,r,i,a,o,s]=await Promise.all([this.signer.readContract(h(e.tokenAddress)),this.signer.readContract(u(e.tokenAddress)),this.signer.readContract(m(e.tokenAddress)),this.signer.readContract(ee(e.tokenAddress)),this.signer.readContract(h(e.confidentialTokenAddress)),this.signer.readContract(u(e.confidentialTokenAddress)),this.signer.readContract(m(e.confidentialTokenAddress))]);return{...e,underlying:{name:t,symbol:n,decimals:r,totalSupply:i},confidential:{name:a,symbol:o,decimals:s}}}async getConfidentialToken(e){let t=await this.getRegistryAddress(),n=W(e),r=`ct:${t}:${n}`,i=this.#r(r);if(i!==void 0)return i;let[a,o]=await this.signer.readContract(U(t,n));if(!a)return this.#i(r,null,X);let s=await this.signer.readContract(H(t,o));return this.#i(r,{confidentialTokenAddress:o,isValid:s})}async getUnderlyingToken(e){let t=await this.getRegistryAddress(),n=W(e),r=`ut:${t}:${n}`,i=this.#r(r);if(i!==void 0)return i;let[a,o]=await this.signer.readContract(B(t,n));if(!a)return this.#i(r,null,X);let s=await this.signer.readContract(H(t,n));return this.#i(r,{tokenAddress:o,isValid:s})}async getTokenPairs(){let e=await this.getRegistryAddress();return this.signer.readContract(z(e))}async getTokenPairsLength(){let e=await this.getRegistryAddress();return this.signer.readContract(F(e))}async getTokenPairsSlice(e,t){let n=await this.getRegistryAddress();return this.signer.readContract(V(n,e,t))}async getTokenPair(e){let t=await this.getRegistryAddress();return this.signer.readContract(Ue(t,e))}async getConfidentialTokenAddress(e){let t=await this.getRegistryAddress();return this.signer.readContract(U(t,W(e)))}async getTokenAddress(e){let t=await this.getRegistryAddress();return this.signer.readContract(B(t,W(e)))}async isConfidentialTokenValid(e){let t=await this.getRegistryAddress();return this.signer.readContract(H(t,W(e)))}},ct=class{relayer;signer;storage;sessionStorage;credentials;delegatedCredentials;registry;#e;#t;#n;#r;#i=null;#a=null;constructor(e){this.relayer=e.relayer,this.signer=e.signer,this.storage=e.storage,this.sessionStorage=e.sessionStorage??new E,this.#t=e.onEvent??function(){},this.registry=new Z({signer:this.signer,registryAddresses:e.registryAddresses,registryTTL:e.registryTTL}),this.#e=e.registryTTL;let t={relayer:this.relayer,signer:this.signer,storage:this.storage,sessionStorage:this.sessionStorage,keypairTTL:(()=>{let t=e.keypairTTL??86400;if(t<=0)throw Error(`keypairTTL must be a positive number (seconds)`);return t})(),sessionTTL:e.sessionTTL??2592e3,onEvent:this.#t};if(this.credentials=new S(t),this.delegatedCredentials=new b(t),this.#r=this.#o(),this.signer.subscribe){let t=e.signerLifecycleCallbacks,n=(e,t)=>{t().catch(t=>{this.#t?.({type:_.TransactionError,operation:e,error:T(t),timestamp:Date.now()})})};this.#n=this.signer.subscribe({onDisconnect:()=>{n(`signerDisconnect`,async()=>{await this.#s(),this.#i=null,this.#a=null,t?.onDisconnect?.()})},onAccountChange:e=>{n(`signerAccountChange`,async()=>{await this.#s(),this.#i=W(e);try{this.#a=await this.signer.getChainId()}catch{}t?.onAccountChange?.(e)})},onChainChange:e=>{n(`signerChainChange`,async()=>{await this.#s(),this.#a=e;try{this.#i=await this.signer.getAddress()}catch{}t?.onChainChange?.(e)})}})}}async#o(){try{let e=await this.signer.getAddress(),t=await this.signer.getChainId();this.#i=e,this.#a=t}catch{}}async#s(){if(await this.#r,this.#i===null||this.#a===null)return;let e=await S.computeStoreKey(this.#i,this.#a);await this.credentials.revokeByKey(e)}createReadonlyToken(e){return new v({relayer:this.relayer,signer:this.signer,storage:this.storage,sessionStorage:this.sessionStorage,credentials:this.credentials,delegatedCredentials:this.delegatedCredentials,address:W(e),onEvent:this.#t})}createToken(e,t){return new J({relayer:this.relayer,signer:this.signer,storage:this.storage,sessionStorage:this.sessionStorage,credentials:this.credentials,delegatedCredentials:this.delegatedCredentials,address:W(e),wrapper:t?W(t):void 0,onEvent:this.#t})}createWrappersRegistry(e){return new Z({signer:this.signer,registryAddresses:e,registryTTL:this.#e})}async allow(...e){await this.credentials.allow(...e)}async revoke(...e){await this.credentials.revoke(...e)}async revokeSession(){await this.#r;let e=this.#i??await this.signer.getAddress(),t=this.#a??await this.signer.getChainId(),n=await S.computeStoreKey(e,t);await this.credentials.revokeByKey(n)}async isAllowed(){return this.credentials.isAllowed()}dispose(){this.#n?.(),this.#n=void 0}terminate(){this.dispose(),this.relayer.terminate()}};function Q(e){return`zama:pending-unshield:${e}`}async function lt(e,t,n){await e.set(Q(t),n)}async function ut(e,t){return e.get(Q(t))}async function dt(e,t){await e.delete(Q(t))}var $=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 ft=new $;export{G as ApprovalFailedError,$ as ChromeSessionStorage,i as ConfigurationError,S as CredentialsManager,w as DecryptionFailedError,st as DefaultRegistryAddresses,b as DelegatedCredentialsManager,f as DelegationCooldownError,p as DelegationExpiredError,ne as DelegationNotFoundError,Te as DelegationSelfNotAllowedError,Ie as ERC7984_INTERFACE_ID,Be as ERC7984_WRAPPER_INTERFACE_ID,C as EncryptionFailedError,je as HardhatConfig,q as IndexedDBStorage,o as InvalidKeypairError,ae as KeypairExpiredError,A as MainnetConfig,E as MemoryStorage,d as NoCiphertextError,v as ReadonlyToken,n as RelayerRequestFailedError,ot as RelayerWeb,O as SepoliaConfig,ie as SigningFailedError,oe as SigningRejectedError,ce as TOKEN_TOPICS,J as Token,ve as Topics,K as TransactionRevertedError,Z as WrappersRegistry,se as ZERO_HANDLE,r as ZamaError,t as ZamaErrorCode,ct as ZamaSDK,_ as ZamaSDKEvents,y as allowanceContract,Se as applyDecryptedValues,a as approveContract,me as balanceOfContract,ft as chromeSessionStorage,dt as clearPendingUnshield,Fe as confidentialBalanceOfContract,Ze as confidentialBatchTransferContract,Ge as confidentialTotalSupplyContract,Je as confidentialTransferContract,I as confidentialTransferFromContract,m as decimalsContract,xe as decodeConfidentialTransfer,le as decodeOnChainEvent,he as decodeOnChainEvents,Ce as decodeUnwrapRequested,ue as decodeUnwrappedFinalized,de as decodeUnwrappedStarted,ye as decodeWrapped,g as delegateForUserDecryptionContract,qe as deploymentCoordinatorContract,_e as extractEncryptedHandles,He as finalizeUnwrapContract,ge as findUnwrapRequested,fe as findWrapped,re as getBatchTransferFeeContract,U as getConfidentialTokenAddressContract,s as getDelegationExpiryContract,l as getFeeRecipientContract,B as getTokenAddressContract,Ue as getTokenPairContract,z as getTokenPairsContract,F as getTokenPairsLengthContract,V as getTokenPairsSliceContract,c as getUnwrapFeeContract,te as getWrapFeeContract,Ye as getWrapperContract,et as indexedDBStorage,We as isConfidentialTokenContract,H as isConfidentialTokenValidContract,Le as isConfidentialWrapperContract,Ne as isFinalizeUnwrapOperatorContract,M as isOperatorContract,ut as loadPendingUnshield,e as matchZamaError,Oe as memoryStorage,h as nameContract,be as parseActivityFeed,Ke as rateContract,x as revokeDelegationContract,lt as savePendingUnshield,Pe as setFinalizeUnwrapOperatorContract,N as setOperatorContract,pe as sortByBlockNumber,Re as supportsInterfaceContract,u as symbolContract,Me as totalSupplyContract,Ve as underlyingContract,P as unwrapContract,ze as unwrapFromBalanceContract,R as wrapContract,L as wrapETHContract,Xe as wrapperExistsContract};
|
|
498
498
|
//# sourceMappingURL=index.js.map
|