@zama-fhe/sdk 3.2.0 → 3.3.0-alpha.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/assertions.cjs +1 -1
- package/dist/cjs/assertions.cjs.map +1 -1
- package/dist/cjs/base-signer.cjs +1 -1
- package/dist/cjs/base-signer.cjs.map +1 -1
- package/dist/cjs/ethers/index.cjs +1 -1
- package/dist/cjs/index.cjs +1 -1
- 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/relayer-cleartext.cjs +1 -1
- package/dist/cjs/relayer-cleartext.cjs.map +1 -1
- package/dist/cjs/relayer-sdk.worker.js +134 -34
- package/dist/cjs/relayer.cjs +1 -1
- package/dist/cjs/relayer.cjs.map +1 -1
- package/dist/cjs/timeout.cjs +2 -0
- package/dist/cjs/timeout.cjs.map +1 -0
- package/dist/cjs/token.cjs +1 -1
- package/dist/cjs/token.cjs.map +1 -1
- package/dist/cjs/viem/index.cjs +1 -1
- package/dist/cjs/viem/index.cjs.map +1 -1
- package/dist/cjs/web/index.cjs +136 -36
- package/dist/cjs/web/index.cjs.map +1 -1
- package/dist/cjs/wrappers-registry.cjs +1 -1
- package/dist/cjs/wrappers-registry.cjs.map +1 -1
- package/dist/esm/assertions-zYseN5Xz.js +2 -0
- package/dist/esm/assertions-zYseN5Xz.js.map +1 -0
- package/dist/esm/{base-signer-ByGw5ReU.d.ts → base-signer-C3Wc5oi9.d.ts} +2 -2
- package/dist/esm/base-signer-DjytqPkd.js +2 -0
- package/dist/esm/base-signer-DjytqPkd.js.map +1 -0
- package/dist/esm/cleartext/index.d.ts +1 -1
- package/dist/esm/cleartext/index.js +1 -1
- package/dist/esm/{cleartext-DMW5nK1M.d.ts → cleartext-DAkOTlrE.d.ts} +2 -2
- package/dist/esm/{cleartext-CTla3A3O.js → cleartext-rTWFctyd.js} +2 -2
- package/dist/esm/{cleartext-CTla3A3O.js.map → cleartext-rTWFctyd.js.map} +1 -1
- package/dist/esm/{encryption-BGmINekJ.js → encryption-x4Z_Icqk.js} +2 -2
- package/dist/esm/{encryption-BGmINekJ.js.map → encryption-x4Z_Icqk.js.map} +1 -1
- package/dist/esm/ethers/index.d.ts +4 -4
- package/dist/esm/ethers/index.js +1 -1
- package/dist/esm/ethers/index.js.map +1 -1
- package/dist/esm/{hex-CxtyupeQ.js → hex-A72GrTf9.js} +2 -2
- package/dist/esm/{hex-CxtyupeQ.js.map → hex-A72GrTf9.js.map} +1 -1
- package/dist/esm/{index-DoVo9J1n.d.ts → index-C1Mtc8Rw.d.ts} +450 -163
- package/dist/esm/index.d.ts +17 -13
- package/dist/esm/index.js +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/node/index.d.ts +25 -7
- package/dist/esm/node/index.js +1 -1
- package/dist/esm/node/index.js.map +1 -1
- package/dist/esm/node/relayer-sdk.node-worker.js +1 -1
- package/dist/esm/node/relayer-sdk.node-worker.js.map +1 -1
- package/dist/esm/query/index.d.ts +42 -4
- package/dist/esm/query/index.js +1 -1
- package/dist/esm/query/index.js.map +1 -1
- package/dist/esm/relayer-cleartext-Bp6jtxDd.js +2 -0
- package/dist/esm/relayer-cleartext-Bp6jtxDd.js.map +1 -0
- package/dist/esm/{relayer-cleartext-DkKKjfI6.d.ts → relayer-cleartext-CSeMlmGO.d.ts} +102 -13
- package/dist/esm/relayer-eavK5bfZ.js +2 -0
- package/dist/esm/relayer-eavK5bfZ.js.map +1 -0
- package/dist/esm/relayer-sdk.worker.js +134 -34
- package/dist/esm/timeout-CNVfiaJD.js +2 -0
- package/dist/esm/timeout-CNVfiaJD.js.map +1 -0
- package/dist/esm/token-Bt33g0zQ.js +2 -0
- package/dist/esm/token-Bt33g0zQ.js.map +1 -0
- package/dist/esm/{types-BjDu-RZg.d.ts → types-Gn5MeDsr.d.ts} +14 -2
- package/dist/esm/{types-Xg_On_yY.d.ts → types-OHIaPwCy.d.ts} +2 -2
- package/dist/esm/{types-DiZhtG8i.d.ts → types-piBsdTIP.d.ts} +2 -2
- package/dist/esm/{validation-DHZ3JPOn.js → validation-DLszOweh.js} +2 -2
- package/dist/esm/{validation-DHZ3JPOn.js.map → validation-DLszOweh.js.map} +1 -1
- package/dist/esm/viem/index.d.ts +4 -4
- package/dist/esm/viem/index.js +1 -1
- package/dist/esm/viem/index.js.map +1 -1
- package/dist/esm/web/index.d.ts +2 -2
- package/dist/esm/web/index.js +135 -35
- package/dist/esm/web/index.js.map +1 -1
- package/dist/esm/worker.base-client-BVnT4yJa.js +2 -0
- package/dist/esm/worker.base-client-BVnT4yJa.js.map +1 -0
- package/dist/esm/{wrappers-registry-BWWG0aze.js → wrappers-registry-C1oK8Bi6.js} +2 -2
- package/dist/esm/wrappers-registry-C1oK8Bi6.js.map +1 -0
- package/package.json +51 -51
- package/dist/esm/assertions-CnPIS0VN.js +0 -2
- package/dist/esm/assertions-CnPIS0VN.js.map +0 -1
- package/dist/esm/base-signer-BVqcM5jt.js +0 -2
- package/dist/esm/base-signer-BVqcM5jt.js.map +0 -1
- package/dist/esm/error-W1N-FGwV.js +0 -2
- package/dist/esm/error-W1N-FGwV.js.map +0 -1
- package/dist/esm/relayer-D-nicEYJ.js +0 -2
- package/dist/esm/relayer-D-nicEYJ.js.map +0 -1
- package/dist/esm/relayer-cleartext-DGcb5qtE.js +0 -2
- package/dist/esm/relayer-cleartext-DGcb5qtE.js.map +0 -1
- package/dist/esm/token-TQ-VFHS4.js +0 -2
- package/dist/esm/token-TQ-VFHS4.js.map +0 -1
- package/dist/esm/worker.base-client-x522sMBy.js +0 -2
- package/dist/esm/worker.base-client-x522sMBy.js.map +0 -1
- package/dist/esm/wrappers-registry-BWWG0aze.js.map +0 -1
|
@@ -5,6 +5,43 @@ import { z } from "zod/mini";
|
|
|
5
5
|
import * as SDK from "@zama-fhe/relayer-sdk/bundle";
|
|
6
6
|
import { Bytes32Hex, ClearValueType, InputProofBytesType, KmsDelegatedUserDecryptEIP712Type, KmsUserDecryptEIP712Type, PublicDecryptResults, ZKProofLike } from "@zama-fhe/relayer-sdk/bundle";
|
|
7
7
|
|
|
8
|
+
//#region src/utils/error.d.ts
|
|
9
|
+
/**
|
|
10
|
+
* A plain, structured-clone-safe snapshot of an error and its cause chain.
|
|
11
|
+
*
|
|
12
|
+
* The worker boundary (`postMessage`) strips prototypes, `code`/`status`, and —
|
|
13
|
+
* critically — the `cause` chain, leaving only the message. Decryption errors
|
|
14
|
+
* are classified on the **main thread** ({@link wrapDecryptError}), so the worker
|
|
15
|
+
* only needs to faithfully hand the error across the boundary, not understand it.
|
|
16
|
+
* `serializeError` is that mechanical, taxonomy-agnostic envelope: it copies the
|
|
17
|
+
* scalar signal fields the classifier keys on and flattens the nested cause chain
|
|
18
|
+
* into a single `cause` link. {@link deserializeError} rebuilds an `Error` whose
|
|
19
|
+
* `.cause` chain mirrors the original, so the existing chain-walking detectors
|
|
20
|
+
* work on it unchanged.
|
|
21
|
+
*/
|
|
22
|
+
interface SerializedError {
|
|
23
|
+
name: string;
|
|
24
|
+
message: string;
|
|
25
|
+
/** e.g. JSON-RPC -32005, "RELAYER_FETCH_ERROR", ethers "CALL_EXCEPTION". */
|
|
26
|
+
code?: string | number;
|
|
27
|
+
/** viem-style HTTP status. */
|
|
28
|
+
status?: number;
|
|
29
|
+
/** relayer / node-fetch-style HTTP status. */
|
|
30
|
+
statusCode?: number;
|
|
31
|
+
/** Server-driven retry delay in **seconds** (numeric prop or parsed `Retry-After`). */
|
|
32
|
+
retryAfter?: number;
|
|
33
|
+
/**
|
|
34
|
+
* ethers surfaces an HTTP status only as a string on `info.responseStatus`
|
|
35
|
+
* (e.g. `"429 Too Many Requests"`), not as a numeric `status`. It lives on a
|
|
36
|
+
* nested `info` object the flattening would otherwise skip, so it is lifted
|
|
37
|
+
* onto the envelope and rebuilt onto `error.info.responseStatus`, letting the
|
|
38
|
+
* ethers rate-limit detector classify a worker-origin 429 exactly as it would
|
|
39
|
+
* the same error on the main thread.
|
|
40
|
+
*/
|
|
41
|
+
responseStatus?: string;
|
|
42
|
+
cause?: SerializedError;
|
|
43
|
+
}
|
|
44
|
+
//#endregion
|
|
8
45
|
//#region src/worker/worker.types.d.ts
|
|
9
46
|
/**
|
|
10
47
|
* Minimal four-level logger the SDK logs through.
|
|
@@ -162,12 +199,17 @@ interface SuccessResponse<T> extends BaseResponse {
|
|
|
162
199
|
success: true;
|
|
163
200
|
data: T;
|
|
164
201
|
}
|
|
165
|
-
|
|
202
|
+
/**
|
|
203
|
+
* A failed worker response. The error and its cause chain are serialized into a
|
|
204
|
+
* structured-clone-safe {@link SerializedError} (structured clone strips
|
|
205
|
+
* prototypes/codes/causes across the boundary); the main thread rebuilds it
|
|
206
|
+
* ({@link deserializeError}) and classifies it once in `wrapDecryptError`.
|
|
207
|
+
*/
|
|
208
|
+
type ErrorResponse = BaseResponse & {
|
|
166
209
|
success: false;
|
|
167
210
|
error: string;
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
}
|
|
211
|
+
serialized?: SerializedError;
|
|
212
|
+
};
|
|
171
213
|
type WorkerResponse<T> = SuccessResponse<T> | ErrorResponse;
|
|
172
214
|
type EncryptResponseData = InputProofBytesType;
|
|
173
215
|
interface UserDecryptResponseData {
|
|
@@ -443,12 +485,29 @@ interface UnshieldOptions extends UnshieldCallbacks {
|
|
|
443
485
|
}
|
|
444
486
|
//#endregion
|
|
445
487
|
//#region src/worker/worker.base-client.d.ts
|
|
488
|
+
/**
|
|
489
|
+
* Timeout / recovery knobs shared by every worker client (node + web), so the
|
|
490
|
+
* base class can read them generically off `config`.
|
|
491
|
+
*/
|
|
492
|
+
interface WorkerClientTimeoutConfig {
|
|
493
|
+
/** Per-operation timeout in **seconds**. Defaults to 30. */
|
|
494
|
+
operationTimeout?: number;
|
|
495
|
+
/** WASM-init timeout in **seconds**. Defaults to 60. */
|
|
496
|
+
initTimeout?: number;
|
|
497
|
+
/**
|
|
498
|
+
* Recycle (terminate + lazily re-init) the worker after an operation timeout,
|
|
499
|
+
* so a hung thread can't keep serving requests. Defaults to `true`.
|
|
500
|
+
*/
|
|
501
|
+
recycleWorkerOnTimeout?: boolean;
|
|
502
|
+
/** Diagnostic label surfaced on {@link WorkerTimeoutError} (e.g. `node-worker-2`). */
|
|
503
|
+
workerLabel?: string;
|
|
504
|
+
}
|
|
446
505
|
/**
|
|
447
506
|
* Abstract base class for worker clients (browser Web Worker and Node.js worker_threads).
|
|
448
507
|
* Encapsulates all shared logic: pending request tracking, timeouts, init dedup, domain methods.
|
|
449
508
|
* Subclasses implement the abstract hooks for platform-specific worker creation and messaging.
|
|
450
509
|
*/
|
|
451
|
-
declare abstract class BaseWorkerClient<TWorker, TConfig> {
|
|
510
|
+
declare abstract class BaseWorkerClient<TWorker, TConfig extends WorkerClientTimeoutConfig> {
|
|
452
511
|
#private;
|
|
453
512
|
protected readonly config: TConfig;
|
|
454
513
|
protected readonly logger: GenericLogger;
|
|
@@ -493,7 +552,7 @@ declare abstract class BaseWorkerClient<TWorker, TConfig> {
|
|
|
493
552
|
//#endregion
|
|
494
553
|
//#region src/worker/worker.client.d.ts
|
|
495
554
|
/** Configuration for the worker client */
|
|
496
|
-
interface WorkerClientConfig {
|
|
555
|
+
interface WorkerClientConfig extends WorkerClientTimeoutConfig {
|
|
497
556
|
cdnUrl: string;
|
|
498
557
|
chains: FheChain[];
|
|
499
558
|
csrfToken: string;
|
|
@@ -698,17 +757,47 @@ interface StoredTransportKeyPairWithPermits {
|
|
|
698
757
|
interface FheOperations {
|
|
699
758
|
/** Generate a transport key pair (ML-KEM public + private key) used for user-decryption. */
|
|
700
759
|
generateTransportKeyPair(): Promise<TransportKeyPair>;
|
|
701
|
-
/**
|
|
760
|
+
/**
|
|
761
|
+
* Create EIP-712 typed data for signing an FHE decrypt credential.
|
|
762
|
+
*
|
|
763
|
+
* Low-level credential builder. Prefer the high-level
|
|
764
|
+
* `sdk.decryption.decryptValues` ({@link Decryption.decryptValues}), which
|
|
765
|
+
* assembles and caches this credential for you.
|
|
766
|
+
*/
|
|
702
767
|
createEIP712(publicKey: Hex, contractAddresses: Address[], startTimestamp: number, durationDays?: number): Promise<EIP712TypedData>;
|
|
703
768
|
/** Encrypt plaintext values into FHE ciphertexts. */
|
|
704
769
|
encrypt(params: EncryptParams): Promise<EncryptResult>;
|
|
705
|
-
/**
|
|
770
|
+
/**
|
|
771
|
+
* Decrypt FHE encrypted values using the user's own credentials.
|
|
772
|
+
*
|
|
773
|
+
* Low-level: the caller assembles the credential bundle (transport key pair,
|
|
774
|
+
* EIP-712 permit) in {@link UserDecryptParams}. Prefer the high-level
|
|
775
|
+
* `sdk.decryption.decryptValues` ({@link Decryption.decryptValues}), which
|
|
776
|
+
* manages credentials, caching, and error wrapping.
|
|
777
|
+
*/
|
|
706
778
|
userDecrypt(params: UserDecryptParams): Promise<Readonly<Record<EncryptedValue, ClearValue>>>;
|
|
707
|
-
/**
|
|
779
|
+
/**
|
|
780
|
+
* Decrypt encrypted values using the network public key (no credential needed).
|
|
781
|
+
*
|
|
782
|
+
* Low-level. Prefer the high-level `sdk.decryption.decryptPublicValues`
|
|
783
|
+
* ({@link Decryption.decryptPublicValues}).
|
|
784
|
+
*/
|
|
708
785
|
publicDecrypt(encryptedValues: EncryptedValue[]): Promise<PublicDecryptResult>;
|
|
709
|
-
/**
|
|
786
|
+
/**
|
|
787
|
+
* Create EIP-712 typed data for a delegated user decrypt credential.
|
|
788
|
+
*
|
|
789
|
+
* Low-level credential builder. Prefer the high-level
|
|
790
|
+
* `sdk.decryption.delegatedDecryptValues` ({@link Decryption.delegatedDecryptValues}),
|
|
791
|
+
* which assembles and caches this credential for you.
|
|
792
|
+
*/
|
|
710
793
|
createDelegatedUserDecryptEIP712(publicKey: Hex, contractAddresses: Address[], delegatorAddress: Address, startTimestamp: number, durationDays?: number): Promise<KmsDelegatedUserDecryptEIP712Type>;
|
|
711
|
-
/**
|
|
794
|
+
/**
|
|
795
|
+
* Decrypt FHE encrypted values using delegated user credentials.
|
|
796
|
+
*
|
|
797
|
+
* Low-level: the caller assembles the delegated credential bundle in
|
|
798
|
+
* {@link DelegatedUserDecryptParams}. Prefer the high-level
|
|
799
|
+
* `sdk.decryption.delegatedDecryptValues` ({@link Decryption.delegatedDecryptValues}).
|
|
800
|
+
*/
|
|
712
801
|
delegatedUserDecrypt(params: DelegatedUserDecryptParams): Promise<Readonly<Record<EncryptedValue, ClearValue>>>;
|
|
713
802
|
/** Submit a ZK proof for on-chain verification. */
|
|
714
803
|
requestZKProofVerification(zkProof: ZKProofLike): Promise<InputProofBytesType>;
|
|
@@ -751,5 +840,5 @@ declare class RelayerCleartext implements RelayerSDK, Disposable {
|
|
|
751
840
|
[Symbol.dispose](): void;
|
|
752
841
|
}
|
|
753
842
|
//#endregion
|
|
754
|
-
export {
|
|
755
|
-
//# sourceMappingURL=relayer-cleartext-
|
|
843
|
+
export { CreateDelegatedEIP712Request as $, ShieldCallbacks as A, WorkerEnv as At, RawLog as B, BaseWorkerClient as C, RequestZKProofVerificationRequest as Ct, ShieldPath as D, UserDecryptPayload as Dt, ShieldOptions as E, UpdateCsrfRequest as Et, GenericSigner as F, ReadContractConfig as G, TransactionResult as H, WalletAccount as I, WriteContractArgs as J, ReadContractReturnType as K, WalletAccountChange as L, UnshieldCallbacks as M, WorkerRequestType as Mt, GenericStorage as N, WorkerResponse as Nt, TransferOptions as O, UserDecryptRequest as Ot, GenericProvider as P, SerializedError as Pt, CreateDelegatedEIP712Payload as Q, WalletAccountListener as R, RelayerWorkerClient as S, PublicDecryptResponseData as St, ApprovalStrategy as T, SuccessResponse as Tt, ContractAbi as U, TransactionReceipt as V, ReadContractArgs as W, WriteFunctionName as X, WriteContractConfig as Y, BaseRequest as Z, PublicParamsData as _, GetPublicParamsResponseData as _t, StoredTransportKeyPairWithPermits as a, DelegatedUserDecryptRequest as at, RelayerWebSecurityConfig as b, PublicDecryptPayload as bt, DelegatedUserDecryptParams as c, EncryptRequest as ct, EncryptParams as d, GenerateKeypairRequest as dt, CreateDelegatedEIP712ResponseData as et, EncryptResult as f, GenerateKeypairResponseData as ft, PublicDecryptResult as g, GetPublicParamsRequest as gt, NetworkType as h, GetPublicKeyResponseData as ht, StoredTransportKeyPair as i, DelegatedUserDecryptPayload as it, TransferCallbacks as j, WorkerRequest as jt, UnshieldOptions as k, UserDecryptResponseData as kt, EIP712TypedData as l, EncryptResponseData as lt, FheEncryptionKey as m, GetPublicKeyRequest as mt, RelayerSDK as n, CreateEIP712Request as nt, TransportKeyPair as o, DelegatedUserDecryptResponseData as ot, EncryptedValue as p, GenericLogger as pt, ReadFunctionName as q, Permission as r, CreateEIP712ResponseData as rt, ClearValue as s, EncryptPayload as st, RelayerCleartext as t, CreateEIP712Payload as tt, EncryptInput as u, ErrorResponse as ut, RelayerSDKStatus as v, InitPayload as vt, WorkerClientTimeoutConfig as w, RequestZKProofVerificationResponseData as wt, UserDecryptParams as x, PublicDecryptRequest as xt, RelayerWebConfig as y, InitRequest as yt, WalletAccountStore as z };
|
|
844
|
+
//# sourceMappingURL=relayer-cleartext-CSeMlmGO.d.ts.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const e={SigningRejected:`SIGNING_REJECTED`,SigningFailed:`SIGNING_FAILED`,EncryptionFailed:`ENCRYPTION_FAILED`,DecryptionFailed:`DECRYPTION_FAILED`,TransactionReverted:`TRANSACTION_REVERTED`,TransportKeyPairExpired:`KEYPAIR_EXPIRED`,InvalidTransportKeyPair:`INVALID_KEYPAIR`,NoCiphertext:`NO_CIPHERTEXT`,RelayerRequestFailed:`RELAYER_REQUEST_FAILED`,NotEntitled:`NOT_ENTITLED`,RpcRateLimited:`RPC_RATE_LIMITED`,OperationTimeout:`OPERATION_TIMEOUT`,WorkerRecycled:`WORKER_RECYCLED`,Configuration:`CONFIGURATION`,DelegationSelfNotAllowed:`DELEGATION_SELF_NOT_ALLOWED`,DelegationCooldown:`DELEGATION_COOLDOWN`,DelegationNotFound:`DELEGATION_NOT_FOUND`,DelegationExpired:`DELEGATION_EXPIRED`,InsufficientConfidentialBalance:`INSUFFICIENT_CONFIDENTIAL_BALANCE`,InsufficientERC20Balance:`INSUFFICIENT_ERC20_BALANCE`,BalanceCheckUnavailable:`BALANCE_CHECK_UNAVAILABLE`,ERC20ReadFailed:`ERC20_READ_FAILED`,DelegationExpiryUnchanged:`DELEGATION_EXPIRY_UNCHANGED`,DelegationDelegateEqualsContract:`DELEGATION_DELEGATE_EQUALS_CONTRACT`,DelegationContractIsSelf:`DELEGATION_CONTRACT_IS_SELF`,AclPaused:`ACL_PAUSED`,DelegationExpirationTooSoon:`DELEGATION_EXPIRATION_TOO_SOON`,DelegationNotPropagated:`DELEGATION_NOT_PROPAGATED`,ChainMismatch:`CHAIN_MISMATCH`,SignerNotConfigured:`SIGNER_NOT_CONFIGURED`,WalletNotConnected:`WALLET_NOT_CONNECTED`,WalletAccountNotReady:`WALLET_ACCOUNT_NOT_READY`};var t=class extends Error{code;constructor(e,t,n){super(t,n),Object.setPrototypeOf(this,new.target.prototype),this.name=`ZamaError`,this.code=e}},n=class extends t{statusCode;retryAfter;retryable;constructor(t,n,r){super(e.RelayerRequestFailed,t,r),this.name=`RelayerRequestFailedError`,this.statusCode=n,this.retryable=n===429,this.retryAfter=this.retryable?r?.retryAfter:void 0}},r=class extends t{constructor(t,n){super(e.Configuration,t,n),this.name=`ConfigurationError`}};export{e as i,n,t as r,r as t};
|
|
2
|
+
//# sourceMappingURL=relayer-eavK5bfZ.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"relayer-eavK5bfZ.js","names":[],"sources":["../../src/errors/base.ts","../../src/errors/relayer.ts"],"sourcesContent":["/**\n * Typed error codes thrown by the SDK.\n * Use `error.code` or `instanceof` to programmatically handle specific failure modes.\n *\n * @example\n * ```ts\n * try {\n * await token.confidentialTransfer(\"0xTo\", 100n);\n * } catch (e) {\n * if (e instanceof SigningRejectedError) {\n * // User rejected the wallet signature\n * }\n * }\n * ```\n */\nexport const ZamaErrorCode = {\n /** User rejected the wallet signature prompt. */\n SigningRejected: \"SIGNING_REJECTED\",\n /** Wallet signature failed for a reason other than rejection. */\n SigningFailed: \"SIGNING_FAILED\",\n /** FHE encryption failed. */\n EncryptionFailed: \"ENCRYPTION_FAILED\",\n /** FHE decryption failed. */\n DecryptionFailed: \"DECRYPTION_FAILED\",\n /** On-chain transaction reverted. */\n TransactionReverted: \"TRANSACTION_REVERTED\",\n /** Transport key pair has expired and needs regeneration. */\n TransportKeyPairExpired: \"KEYPAIR_EXPIRED\",\n /** Relayer rejected transport key pair (stale, expired, or malformed). */\n InvalidTransportKeyPair: \"INVALID_KEYPAIR\",\n /** No FHE ciphertext exists for this account (never shielded). */\n NoCiphertext: \"NO_CIPHERTEXT\",\n /** Relayer HTTP request failed. */\n RelayerRequestFailed: \"RELAYER_REQUEST_FAILED\",\n /** The configured signer/account is not entitled (ACL) to decrypt this encrypted value. Don't retry — wait for a grant. */\n NotEntitled: \"NOT_ENTITLED\",\n /** The consumer's RPC provider rate-limited an on-chain read (e.g. HTTP 429 / JSON-RPC -32005). Retryable. */\n RpcRateLimited: \"RPC_RATE_LIMITED\",\n /** A worker operation exceeded its configured timeout; the worker is recycled by default. Retryable. */\n OperationTimeout: \"OPERATION_TIMEOUT\",\n /** An in-flight worker operation was aborted as collateral of another operation's timeout recycle. Retryable. */\n WorkerRecycled: \"WORKER_RECYCLED\",\n /** SDK configuration is invalid (e.g. forbidden chain ID, unsupported type). */\n Configuration: \"CONFIGURATION\",\n /** Delegation cannot target self (delegate === msg.sender). */\n DelegationSelfNotAllowed: \"DELEGATION_SELF_NOT_ALLOWED\",\n /** Only one delegate/revoke per (delegator, delegate, contract) per block. */\n DelegationCooldown: \"DELEGATION_COOLDOWN\",\n /** No active delegation found for this (delegator, delegate, contract) tuple. */\n DelegationNotFound: \"DELEGATION_NOT_FOUND\",\n /** The delegation has expired. */\n DelegationExpired: \"DELEGATION_EXPIRED\",\n /** Confidential (cToken) balance is insufficient for the requested operation. */\n InsufficientConfidentialBalance: \"INSUFFICIENT_CONFIDENTIAL_BALANCE\",\n /** ERC-20 balance is insufficient for the requested shield amount. */\n InsufficientERC20Balance: \"INSUFFICIENT_ERC20_BALANCE\",\n /** Balance validation could not be performed (no cached credentials and decryption not possible). */\n BalanceCheckUnavailable: \"BALANCE_CHECK_UNAVAILABLE\",\n /** Public ERC-20 read (e.g. balanceOf) failed due to a network or contract error. */\n ERC20ReadFailed: \"ERC20_READ_FAILED\",\n /** The new expiration date equals the current one — no on-chain change needed. */\n DelegationExpiryUnchanged: \"DELEGATION_EXPIRY_UNCHANGED\",\n /** Delegate address cannot be the contract address. */\n DelegationDelegateEqualsContract: \"DELEGATION_DELEGATE_EQUALS_CONTRACT\",\n /** Contract address cannot be the sender address. */\n DelegationContractIsSelf: \"DELEGATION_CONTRACT_IS_SELF\",\n /** The ACL contract is paused. */\n AclPaused: \"ACL_PAUSED\",\n /** Expiration date is too soon (must be at least 1 hour in the future). */\n DelegationExpirationTooSoon: \"DELEGATION_EXPIRATION_TOO_SOON\",\n /** Delegation exists on-chain but hasn't propagated to the gateway yet. */\n DelegationNotPropagated: \"DELEGATION_NOT_PROPAGATED\",\n /** Signer and provider are connected to different chains. */\n ChainMismatch: \"CHAIN_MISMATCH\",\n /** Operation requires a signer but none is configured. */\n SignerNotConfigured: \"SIGNER_NOT_CONFIGURED\",\n /** Operation requires a connected wallet account. */\n WalletNotConnected: \"WALLET_NOT_CONNECTED\",\n /** Wallet account discovery is still resolving. */\n WalletAccountNotReady: \"WALLET_ACCOUNT_NOT_READY\",\n} as const;\n\n/** Union of all {@link ZamaErrorCode} string values. */\nexport type ZamaErrorCode = (typeof ZamaErrorCode)[keyof typeof ZamaErrorCode];\n\n/**\n * Base error thrown by all SDK operations.\n * Carries a {@link ZamaErrorCode} for programmatic error handling.\n * Prefer catching specific subclasses (e.g. {@link EncryptionFailedError}).\n */\nexport class ZamaError extends Error {\n /** Machine-readable error code. */\n readonly code: ZamaErrorCode;\n\n constructor(code: ZamaErrorCode, message: string, options?: ErrorOptions) {\n super(message, options);\n Object.setPrototypeOf(this, new.target.prototype);\n this.name = \"ZamaError\";\n this.code = code;\n }\n}\n","import { ZamaError, ZamaErrorCode } from \"./base\";\n\n/** Relayer HTTP request failed. */\nexport class RelayerRequestFailedError extends ZamaError {\n /** HTTP status code from the relayer, if available. */\n readonly statusCode: number | undefined;\n\n /**\n * Server-driven retry delay in **seconds** (the SDK's duration unit and the\n * header's own unit), from the relayer's `Retry-After` header. Set only on\n * back-pressure (HTTP 429) responses that carry the header; `undefined`\n * otherwise. Implies {@link retryable}.\n */\n readonly retryAfter: number | undefined;\n\n /**\n * Whether the request may be safely retried. `true` for relayer back-pressure\n * (HTTP 429); pair with {@link retryAfter} for the server's suggested delay.\n */\n readonly retryable: boolean;\n\n constructor(\n message: string,\n statusCode?: number,\n options?: ErrorOptions & { retryAfter?: number },\n ) {\n super(ZamaErrorCode.RelayerRequestFailed, message, options);\n this.name = \"RelayerRequestFailedError\";\n this.statusCode = statusCode;\n this.retryable = statusCode === 429;\n // Keep the two fields consistent: a delay only makes sense when retryable.\n this.retryAfter = this.retryable ? options?.retryAfter : undefined;\n }\n}\n\n/** SDK configuration is invalid (e.g. forbidden chain ID, unsupported type). */\nexport class ConfigurationError extends ZamaError {\n constructor(message: string, options?: ErrorOptions) {\n super(ZamaErrorCode.Configuration, message, options);\n this.name = \"ConfigurationError\";\n }\n}\n"],"mappings":"AAeA,MAAa,EAAgB,CAE3B,gBAAiB,mBAEjB,cAAe,iBAEf,iBAAkB,oBAElB,iBAAkB,oBAElB,oBAAqB,uBAErB,wBAAyB,kBAEzB,wBAAyB,kBAEzB,aAAc,gBAEd,qBAAsB,yBAEtB,YAAa,eAEb,eAAgB,mBAEhB,iBAAkB,oBAElB,eAAgB,kBAEhB,cAAe,gBAEf,yBAA0B,8BAE1B,mBAAoB,sBAEpB,mBAAoB,uBAEpB,kBAAmB,qBAEnB,gCAAiC,oCAEjC,yBAA0B,6BAE1B,wBAAyB,4BAEzB,gBAAiB,oBAEjB,0BAA2B,8BAE3B,iCAAkC,sCAElC,yBAA0B,8BAE1B,UAAW,aAEX,4BAA6B,iCAE7B,wBAAyB,4BAEzB,cAAe,iBAEf,oBAAqB,wBAErB,mBAAoB,uBAEpB,sBAAuB,0BACzB,EAUA,IAAa,EAAb,cAA+B,KAAM,CAEnC,KAEA,YAAY,EAAqB,EAAiB,EAAwB,CACxE,MAAM,EAAS,CAAO,EACtB,OAAO,eAAe,KAAM,IAAI,OAAO,SAAS,EAChD,KAAK,KAAO,YACZ,KAAK,KAAO,CACd,CACF,ECjGa,EAAb,cAA+C,CAAU,CAEvD,WAQA,WAMA,UAEA,YACE,EACA,EACA,EACA,CACA,MAAM,EAAc,qBAAsB,EAAS,CAAO,EAC1D,KAAK,KAAO,4BACZ,KAAK,WAAa,EAClB,KAAK,UAAY,IAAe,IAEhC,KAAK,WAAa,KAAK,UAAY,GAAS,WAAa,IAAA,EAC3D,CACF,EAGa,EAAb,cAAwC,CAAU,CAChD,YAAY,EAAiB,EAAwB,CACnD,MAAM,EAAc,cAAe,EAAS,CAAO,EACnD,KAAK,KAAO,oBACd,CACF"}
|
|
@@ -1,4 +1,121 @@
|
|
|
1
1
|
(function() {
|
|
2
|
+
//#region src/utils/error.ts
|
|
3
|
+
/** Coerce an unknown caught value to an Error instance. */
|
|
4
|
+
function toError(error) {
|
|
5
|
+
if (error instanceof Error) return error;
|
|
6
|
+
if (typeof error === "object" && error !== null && "message" in error) return new Error(String(error.message));
|
|
7
|
+
return new Error(String(error));
|
|
8
|
+
}
|
|
9
|
+
/** Properties that may nest a lower-level cause across viem / ethers / fetch. */
|
|
10
|
+
const NESTED_ERROR_KEYS = [
|
|
11
|
+
"cause",
|
|
12
|
+
"error",
|
|
13
|
+
"info"
|
|
14
|
+
];
|
|
15
|
+
/**
|
|
16
|
+
* ethers reports its HTTP status only as a string on `info.responseStatus`
|
|
17
|
+
* (e.g. `"429 Too Many Requests"`). Read it directly off the node — not via the
|
|
18
|
+
* cause-chain flattening, which descends a single branch — so it survives even
|
|
19
|
+
* when the error also carries an `error` link that would be walked first.
|
|
20
|
+
*/
|
|
21
|
+
function responseStatusFromNode(node) {
|
|
22
|
+
const info = node.info;
|
|
23
|
+
if (info !== null && typeof info === "object") {
|
|
24
|
+
const responseStatus = info.responseStatus;
|
|
25
|
+
if (typeof responseStatus === "string") return responseStatus;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Copy the scalar signal fields the classifier keys on from a raw error node
|
|
30
|
+
* onto the envelope, only where not already set — so a shallower node keeps
|
|
31
|
+
* priority. Also lifts ethers' string `info.responseStatus` and the relayer's
|
|
32
|
+
* `Retry-After` header (both destroyed by structured clone: the header lives on
|
|
33
|
+
* a non-cloneable `Headers`, the status on a nested `info` the flattening skips).
|
|
34
|
+
*/
|
|
35
|
+
function captureNodeSignals(node, into) {
|
|
36
|
+
if (into.code === void 0 && (typeof node.code === "string" || typeof node.code === "number")) into.code = node.code;
|
|
37
|
+
if (into.status === void 0 && typeof node.status === "number") into.status = node.status;
|
|
38
|
+
if (into.statusCode === void 0 && typeof node.statusCode === "number") into.statusCode = node.statusCode;
|
|
39
|
+
if (into.responseStatus === void 0) {
|
|
40
|
+
const responseStatus = responseStatusFromNode(node);
|
|
41
|
+
if (responseStatus !== void 0) into.responseStatus = responseStatus;
|
|
42
|
+
}
|
|
43
|
+
if (into.retryAfter === void 0) if (typeof node.retryAfter === "number") into.retryAfter = node.retryAfter;
|
|
44
|
+
else {
|
|
45
|
+
const fromHeader = retryAfterFromHeader(node);
|
|
46
|
+
if (fromHeader !== void 0) into.retryAfter = fromHeader;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
/** Lift any still-missing scalar signal from an already-serialized child up. */
|
|
50
|
+
function hoistMissingSignals(from, into) {
|
|
51
|
+
if (into.code === void 0 && from.code !== void 0) into.code = from.code;
|
|
52
|
+
if (into.status === void 0 && from.status !== void 0) into.status = from.status;
|
|
53
|
+
if (into.statusCode === void 0 && from.statusCode !== void 0) into.statusCode = from.statusCode;
|
|
54
|
+
if (into.responseStatus === void 0 && from.responseStatus !== void 0) into.responseStatus = from.responseStatus;
|
|
55
|
+
if (into.retryAfter === void 0 && from.retryAfter !== void 0) into.retryAfter = from.retryAfter;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Flatten an error (and its `cause` / `error` / `info` chain) into a
|
|
59
|
+
* structured-clone-safe {@link SerializedError}. Depth-bounded to mirror
|
|
60
|
+
* {@link findInErrorChain} and guard against cyclic structures.
|
|
61
|
+
*/
|
|
62
|
+
function serializeError(error, depth = 6) {
|
|
63
|
+
const coerced = toError(error);
|
|
64
|
+
const node = typeof error === "object" && error !== null ? error : coerced;
|
|
65
|
+
const serialized = {
|
|
66
|
+
name: coerced.name,
|
|
67
|
+
message: coerced.message
|
|
68
|
+
};
|
|
69
|
+
captureNodeSignals(node, serialized);
|
|
70
|
+
if (depth > 0) for (const key of NESTED_ERROR_KEYS) {
|
|
71
|
+
const next = node[key];
|
|
72
|
+
if (next !== void 0 && next !== null && typeof next === "object") {
|
|
73
|
+
const child = serializeError(next, depth - 1);
|
|
74
|
+
if (serialized.cause === void 0) serialized.cause = child;
|
|
75
|
+
hoistMissingSignals(child, serialized);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
return serialized;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Parse an HTTP `Retry-After` header value into **seconds** (the SDK's duration
|
|
82
|
+
* unit and the header's own unit), or `undefined` when absent/unparseable. Per
|
|
83
|
+
* RFC 9110 the value is either a non-negative number of seconds (`"120"`) or an
|
|
84
|
+
* HTTP-date; a past date floors to `0`.
|
|
85
|
+
*/
|
|
86
|
+
function parseRetryAfterHeader(value) {
|
|
87
|
+
if (value === null || value === void 0) return;
|
|
88
|
+
const trimmed = value.trim();
|
|
89
|
+
if (trimmed === "") return;
|
|
90
|
+
if (/^\d+$/.test(trimmed)) return Number(trimmed);
|
|
91
|
+
if (/[a-zA-Z]/.test(trimmed)) {
|
|
92
|
+
const dateMs = Date.parse(trimmed);
|
|
93
|
+
if (!Number.isNaN(dateMs)) return Math.max(0, Math.round((dateMs - Date.now()) / 1e3));
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
/** Read a `Retry-After` header (→ seconds) off a `Headers`-like object, if present. */
|
|
97
|
+
function readRetryAfterHeader(headers) {
|
|
98
|
+
if (headers === null || typeof headers !== "object") return;
|
|
99
|
+
const get = headers.get;
|
|
100
|
+
if (typeof get !== "function") return;
|
|
101
|
+
return parseRetryAfterHeader(get.call(headers, "Retry-After"));
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* A node's **relayer** `Retry-After` header (seconds), read from a wrapped fetch
|
|
105
|
+
* `Response` (the relayer SDK's `cause.response.headers`). The SDK owns the
|
|
106
|
+
* relayer fetch, so parsing the header there is legitimate.
|
|
107
|
+
*
|
|
108
|
+
* The viem/chain side (`HttpRequestError.headers`) is deliberately **not** read:
|
|
109
|
+
* for consumer RPC the integrator's viem/ethers transport already honors
|
|
110
|
+
* `Retry-After` in its own retry loop (and retries) before the error ever
|
|
111
|
+
* surfaces, so re-reading it here would re-implement a transport concern.
|
|
112
|
+
* Chain-RPC backoff is configured on the consumer's transport (`chain.network`).
|
|
113
|
+
*/
|
|
114
|
+
function retryAfterFromHeader(node) {
|
|
115
|
+
const response = node.response;
|
|
116
|
+
if (response !== null && typeof response === "object") return readRetryAfterHeader(response.headers);
|
|
117
|
+
}
|
|
118
|
+
//#endregion
|
|
2
119
|
//#region src/utils/assertions.ts
|
|
3
120
|
function assertObject(value, context) {
|
|
4
121
|
if (typeof value !== "object" || value === null || Array.isArray(value)) throw new TypeError(`${context} must be an object, got ${typeof value}`);
|
|
@@ -130,15 +247,14 @@
|
|
|
130
247
|
/**
|
|
131
248
|
* Send an error response back to the main thread.
|
|
132
249
|
*/
|
|
133
|
-
function sendError(id, type, error
|
|
134
|
-
|
|
250
|
+
function sendError(id, type, error) {
|
|
251
|
+
self.postMessage({
|
|
135
252
|
id,
|
|
136
253
|
type,
|
|
137
254
|
success: false,
|
|
138
|
-
error
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
self.postMessage(response);
|
|
255
|
+
error: error instanceof Error ? error.message : String(error),
|
|
256
|
+
serialized: serializeError(error)
|
|
257
|
+
});
|
|
142
258
|
}
|
|
143
259
|
const originalFetch = fetch;
|
|
144
260
|
/** Allowed CDN hostnames for loading the relayer SDK script. */
|
|
@@ -240,7 +356,7 @@
|
|
|
240
356
|
for (const chain of payload.chains) configs.set(chain.id, chain);
|
|
241
357
|
sendSuccess(id, type, { initialized: true });
|
|
242
358
|
} catch (error) {
|
|
243
|
-
sendError(id, type, error
|
|
359
|
+
sendError(id, type, error);
|
|
244
360
|
}
|
|
245
361
|
}
|
|
246
362
|
/** Coerce a boolean to bigint for numeric FHE types. */
|
|
@@ -295,7 +411,7 @@
|
|
|
295
411
|
inputProof: encrypted.inputProof
|
|
296
412
|
}, [encrypted.inputProof.buffer, ...encrypted.handles.map((h) => h.buffer)]);
|
|
297
413
|
} catch (error) {
|
|
298
|
-
sendError(id, type, error
|
|
414
|
+
sendError(id, type, error);
|
|
299
415
|
}
|
|
300
416
|
}
|
|
301
417
|
/**
|
|
@@ -311,22 +427,7 @@
|
|
|
311
427
|
}));
|
|
312
428
|
sendSuccess(id, type, { clearValues: await instance.userDecrypt(handleContractPairs, unprefixHex(payload.privateKey), unprefixHex(payload.publicKey), payload.signature, payload.signedContractAddresses, payload.signerAddress, payload.startTimestamp, payload.durationDays) });
|
|
313
429
|
} catch (error) {
|
|
314
|
-
sendError(id, type, error
|
|
315
|
-
}
|
|
316
|
-
}
|
|
317
|
-
/**
|
|
318
|
-
* Extract an HTTP status code from an error, if present.
|
|
319
|
-
* Relayer SDK errors may carry a `status` or `statusCode` property.
|
|
320
|
-
*/
|
|
321
|
-
function extractHttpStatus(error) {
|
|
322
|
-
if (error === null || error === void 0 || typeof error !== "object") return;
|
|
323
|
-
const e = error;
|
|
324
|
-
if (typeof e.statusCode === "number") return e.statusCode;
|
|
325
|
-
if (typeof e.status === "number") return e.status;
|
|
326
|
-
if (e.cause !== null && e.cause !== void 0 && typeof e.cause === "object") {
|
|
327
|
-
const cause = e.cause;
|
|
328
|
-
if (typeof cause.statusCode === "number") return cause.statusCode;
|
|
329
|
-
if (typeof cause.status === "number") return cause.status;
|
|
430
|
+
sendError(id, type, error);
|
|
330
431
|
}
|
|
331
432
|
}
|
|
332
433
|
/**
|
|
@@ -337,7 +438,7 @@
|
|
|
337
438
|
try {
|
|
338
439
|
sendSuccess(id, type, { ...await (await getInstance(payload.chainId)).publicDecrypt(payload.encryptedValues) });
|
|
339
440
|
} catch (error) {
|
|
340
|
-
sendError(id, type, error
|
|
441
|
+
sendError(id, type, error);
|
|
341
442
|
}
|
|
342
443
|
}
|
|
343
444
|
/**
|
|
@@ -352,7 +453,7 @@
|
|
|
352
453
|
privateKey: prefixHex(keypair.privateKey)
|
|
353
454
|
});
|
|
354
455
|
} catch (error) {
|
|
355
|
-
sendError(id, type, error
|
|
456
|
+
sendError(id, type, error);
|
|
356
457
|
}
|
|
357
458
|
}
|
|
358
459
|
/**
|
|
@@ -363,7 +464,7 @@
|
|
|
363
464
|
try {
|
|
364
465
|
sendSuccess(id, type, (await getInstance(payload.chainId)).createEIP712(unprefixHex(payload.publicKey), payload.contractAddresses, payload.startTimestamp, payload.durationDays));
|
|
365
466
|
} catch (error) {
|
|
366
|
-
sendError(id, type, error
|
|
467
|
+
sendError(id, type, error);
|
|
367
468
|
}
|
|
368
469
|
}
|
|
369
470
|
/**
|
|
@@ -374,7 +475,7 @@
|
|
|
374
475
|
try {
|
|
375
476
|
sendSuccess(id, type, (await getInstance(payload.chainId)).createDelegatedUserDecryptEIP712(unprefixHex(payload.publicKey), payload.contractAddresses, payload.delegatorAddress, payload.startTimestamp, payload.durationDays));
|
|
376
477
|
} catch (error) {
|
|
377
|
-
sendError(id, type, error
|
|
478
|
+
sendError(id, type, error);
|
|
378
479
|
}
|
|
379
480
|
}
|
|
380
481
|
/**
|
|
@@ -390,7 +491,7 @@
|
|
|
390
491
|
}));
|
|
391
492
|
sendSuccess(id, type, { clearValues: await instance.delegatedUserDecrypt(handleContractPairs, unprefixHex(payload.privateKey), unprefixHex(payload.publicKey), payload.signature, payload.signedContractAddresses, payload.delegatorAddress, payload.delegateAddress, payload.startTimestamp, payload.durationDays) });
|
|
392
493
|
} catch (error) {
|
|
393
|
-
sendError(id, type, error
|
|
494
|
+
sendError(id, type, error);
|
|
394
495
|
}
|
|
395
496
|
}
|
|
396
497
|
/**
|
|
@@ -402,7 +503,7 @@
|
|
|
402
503
|
const result = await (await getInstance(payload.chainId)).requestZKProofVerification(payload.zkProof);
|
|
403
504
|
sendSuccess(id, type, result, [result.inputProof.buffer, ...result.handles.map((h) => h.buffer)]);
|
|
404
505
|
} catch (error) {
|
|
405
|
-
sendError(id, type, error
|
|
506
|
+
sendError(id, type, error);
|
|
406
507
|
}
|
|
407
508
|
}
|
|
408
509
|
/**
|
|
@@ -413,7 +514,7 @@
|
|
|
413
514
|
try {
|
|
414
515
|
sendSuccess(id, type, { result: (await getInstance(payload.chainId)).getPublicKey() });
|
|
415
516
|
} catch (error) {
|
|
416
|
-
sendError(id, type, error
|
|
517
|
+
sendError(id, type, error);
|
|
417
518
|
}
|
|
418
519
|
}
|
|
419
520
|
/**
|
|
@@ -424,7 +525,7 @@
|
|
|
424
525
|
try {
|
|
425
526
|
sendSuccess(id, type, { result: (await getInstance(payload.chainId)).getPublicParams(payload.bits) });
|
|
426
527
|
} catch (error) {
|
|
427
|
-
sendError(id, type, error
|
|
528
|
+
sendError(id, type, error);
|
|
428
529
|
}
|
|
429
530
|
}
|
|
430
531
|
/**
|
|
@@ -481,8 +582,7 @@
|
|
|
481
582
|
default: throw new Error(`Unknown request type: ${request.type}`);
|
|
482
583
|
}
|
|
483
584
|
} catch (error) {
|
|
484
|
-
|
|
485
|
-
sendError(request?.id ?? "unknown", request?.type ?? "UNKNOWN", message);
|
|
585
|
+
sendError(request?.id ?? "unknown", request?.type ?? "UNKNOWN", error);
|
|
486
586
|
}
|
|
487
587
|
};
|
|
488
588
|
//#endregion
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{i as e,r as t}from"./relayer-eavK5bfZ.js";var n=class extends t{operation;timeout;elapsed;worker;constructor(t,n){super(e.OperationTimeout,`Worker operation ${t.operation} timed out after ${t.timeout}s`+(t.worker?` (worker ${t.worker})`:``),n),this.name=`WorkerTimeoutError`,this.operation=t.operation,this.timeout=t.timeout,this.elapsed=t.elapsed,this.worker=t.worker}},r=class extends t{operation;worker;constructor(t,n){super(e.WorkerRecycled,`Worker operation ${t.operation} was aborted because its worker was recycled after a timeout`+(t.worker?` (worker ${t.worker})`:``),n),this.name=`WorkerRecycledError`,this.operation=t.operation,this.worker=t.worker}};export{n,r as t};
|
|
2
|
+
//# sourceMappingURL=timeout-CNVfiaJD.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"timeout-CNVfiaJD.js","names":[],"sources":["../../src/errors/timeout.ts"],"sourcesContent":["import { ZamaError, ZamaErrorCode } from \"./base\";\n\n/**\n * A worker operation (encrypt / decrypt / EIP-712 / key fetch) did not complete\n * within its configured timeout — typically a stuck relayer or WASM call. On the\n * Node pool the SDK **recycles the affected worker** (terminating the hung\n * thread) so it self-heals; the operation itself is **retryable**.\n *\n * Configure the bound (seconds) via `node({ operationTimeout })`. Distinct from a\n * decryption/entitlement failure — a timeout is an infrastructure/latency\n * condition, so it no longer collapses into {@link DecryptionFailedError}.\n *\n * @example\n * ```ts\n * try {\n * await sdk.decryption.decryptValues([{ encryptedValue, contractAddress }]);\n * } catch (e) {\n * if (e instanceof WorkerTimeoutError) {\n * // retry (the worker was recycled); consider raising operationTimeout\n * }\n * }\n * ```\n */\nexport class WorkerTimeoutError extends ZamaError {\n /**\n * The worker operation that timed out. This is the internal worker op code\n * (e.g. `USER_DECRYPT`, `ENCRYPT`), not the public SDK method name.\n */\n readonly operation: string;\n /** The configured timeout that was exceeded, in **seconds** (the SDK's duration unit). */\n readonly timeout: number;\n /** Wall-clock time the operation ran before being abandoned, in **seconds** (may be fractional). */\n readonly elapsed: number;\n /** Label of the worker that stalled, when known (e.g. `node-worker-2`). */\n readonly worker: string | undefined;\n\n constructor(\n args: { operation: string; timeout: number; elapsed: number; worker?: string },\n options?: ErrorOptions,\n ) {\n super(\n ZamaErrorCode.OperationTimeout,\n `Worker operation ${args.operation} timed out after ${args.timeout}s` +\n (args.worker ? ` (worker ${args.worker})` : \"\"),\n options,\n );\n this.name = \"WorkerTimeoutError\";\n this.operation = args.operation;\n this.timeout = args.timeout;\n this.elapsed = args.elapsed;\n this.worker = args.worker;\n }\n}\n\n/**\n * An in-flight worker operation was aborted as **collateral** when its worker was\n * recycled — the worker was torn down to recover from *another* operation's\n * timeout (Node pool self-healing), not because this operation itself timed out.\n *\n * The operation never reached a verdict, so it is **retryable**: the next call\n * lazily re-inits a fresh worker. It is intentionally distinct from\n * {@link WorkerTimeoutError} (this op did not exceed its own bound) and from\n * {@link DecryptionFailedError} (nothing actually failed to decrypt) — so a\n * consumer can retry it instead of surfacing a terminal failure.\n *\n * @example\n * ```ts\n * matchZamaError(error, {\n * WORKER_RECYCLED: () => retry(), // transient: the worker was replaced\n * });\n * ```\n */\nexport class WorkerRecycledError extends ZamaError {\n /**\n * The worker operation that was aborted. This is the internal worker op code\n * (e.g. `USER_DECRYPT`, `ENCRYPT`), not the public SDK method name.\n */\n readonly operation: string;\n /** Label of the recycled worker, when known (e.g. `node-worker-2`). */\n readonly worker: string | undefined;\n\n constructor(args: { operation: string; worker?: string }, options?: ErrorOptions) {\n super(\n ZamaErrorCode.WorkerRecycled,\n `Worker operation ${args.operation} was aborted because its worker was recycled after a timeout` +\n (args.worker ? ` (worker ${args.worker})` : \"\"),\n options,\n );\n this.name = \"WorkerRecycledError\";\n this.operation = args.operation;\n this.worker = args.worker;\n }\n}\n"],"mappings":"iDAuBA,IAAa,EAAb,cAAwC,CAAU,CAKhD,UAEA,QAEA,QAEA,OAEA,YACE,EACA,EACA,CACA,MACE,EAAc,iBACd,oBAAoB,EAAK,UAAU,mBAAmB,EAAK,QAAQ,IAChE,EAAK,OAAS,YAAY,EAAK,OAAO,GAAK,IAC9C,CACF,EACA,KAAK,KAAO,qBACZ,KAAK,UAAY,EAAK,UACtB,KAAK,QAAU,EAAK,QACpB,KAAK,QAAU,EAAK,QACpB,KAAK,OAAS,EAAK,MACrB,CACF,EAoBa,EAAb,cAAyC,CAAU,CAKjD,UAEA,OAEA,YAAY,EAA8C,EAAwB,CAChF,MACE,EAAc,eACd,oBAAoB,EAAK,UAAU,+DAChC,EAAK,OAAS,YAAY,EAAK,OAAO,GAAK,IAC9C,CACF,EACA,KAAK,KAAO,sBACZ,KAAK,UAAY,EAAK,UACtB,KAAK,OAAS,EAAK,MACrB,CACF"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{i as e,r as t,t as n}from"./relayer-eavK5bfZ.js";import{A as r,B as i,D as a,E as o,H as s,L as c,M as l,R as u,S as d,T as f,U as p,W as m,b as h,l as g,m as _,u as v,v as y,w as b,x}from"./wrappers-registry-C1oK8Bi6.js";import{n as S,t as C}from"./encryption-x4Z_Icqk.js";import{_ as w,t as T}from"./assertions-zYseN5Xz.js";import{getAddress as E}from"viem";var D=class extends t{constructor(t,n){super(e.TransactionReverted,t,n),this.name=`TransactionRevertedError`}},O=class extends t{retryAfter;constructor(t,n){let{retryAfter:r,...i}=n??{};super(e.RpcRateLimited,t,i),this.name=`RpcRateLimitError`,this.retryAfter=r}},k=class extends t{operation;signerChainId;providerChainId;constructor({operation:t,signerChainId:n,providerChainId:r},i){super(e.ChainMismatch,`Operation "${t}" requires signer and provider to be on the same chain, but signer is on chain ${n} and provider is on chain ${r}.`,i),this.name=`ChainMismatchError`,this.operation=t,this.signerChainId=n,this.providerChainId=r}},A=class extends t{requested;available;token;constructor(t,n,r){super(e.InsufficientConfidentialBalance,t,r),this.name=`InsufficientConfidentialBalanceError`,this.requested=n.requested,this.available=n.available,this.token=n.token}},j=class extends t{requested;available;token;constructor(t,n,r){super(e.InsufficientERC20Balance,t,r),this.name=`InsufficientERC20BalanceError`,this.requested=n.requested,this.available=n.available,this.token=n.token}},M=class extends t{constructor(t,n){super(e.BalanceCheckUnavailable,t,n),this.name=`BalanceCheckUnavailableError`}},N=class extends t{constructor(t,n){super(e.ERC20ReadFailed,t,n),this.name=`ERC20ReadFailedError`}};function P(e){return e instanceof m||e instanceof p||e instanceof n||e instanceof O}const F=[{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 I(e,t,n,r){return{address:e,abi:F,functionName:`delegateForUserDecryption`,args:[t,n,r]}}function L(e,t,n){return{address:e,abi:F,functionName:`revokeDelegationForUserDecryption`,args:[t,n]}}function R(e,t,n,r){return{address:e,abi:F,functionName:`getUserDecryptionDelegationExpirationDate`,args:[t,n,r]}}function z(e,t,n,r,i){return{address:e,abi:F,functionName:`isHandleDelegatedForUserDecryption`,args:[t,n,r,i]}}const B=2n**64n-1n;async function V(e,t,n){if(!t)throw new u(e);let r;try{r=t.requireWalletAccount(e)}catch(n){if(!(n instanceof i)||!t.refreshWalletAccount)throw n;await t.refreshWalletAccount(),r=t.requireWalletAccount(e)}let a=await n.getChainId();if(r.chainId!==a)throw new k({operation:e,signerChainId:r.chainId,providerChainId:a});return r}async function H(e,t,n){return(await V(e,t,n)).chainId}const U={EncryptStart:`encrypt:start`,EncryptEnd:`encrypt:end`,EncryptError:`encrypt:error`,DecryptStart:`decrypt:start`,DecryptEnd:`decrypt:end`,DecryptError:`decrypt:error`,TransactionError:`transaction:error`,ShieldSubmitted:`shield:submitted`,TransferSubmitted:`transfer:submitted`,TransferFromSubmitted:`transferFrom:submitted`,SetOperatorSubmitted:`setOperator:submitted`,ApproveUnderlyingSubmitted:`approveUnderlying:submitted`,UnwrapSubmitted:`unwrap:submitted`,FinalizeUnwrapSubmitted:`finalizeUnwrap:submitted`,DelegationSubmitted:`delegation:submitted`,RevokeDelegationSubmitted:`revokeDelegation:submitted`,UnshieldPhase1Submitted:`unshield:phase1_submitted`,UnshieldPhase2Started:`unshield:phase2_started`,UnshieldPhase2Submitted:`unshield:phase2_submitted`},W={approveUnderlying:{submittedEvent:e=>({type:U.ApproveUnderlyingSubmitted,txHash:e,step:`approve`})},"approveUnderlying:reset":{submittedEvent:e=>({type:U.ApproveUnderlyingSubmitted,txHash:e,step:`reset`})},delegateDecryption:{submittedEvent:e=>({type:U.DelegationSubmitted,txHash:e})},finalizeUnwrap:{submittedEvent:e=>({type:U.FinalizeUnwrapSubmitted,txHash:e})},revokeDelegation:{submittedEvent:e=>({type:U.RevokeDelegationSubmitted,txHash:e})},setOperator:{submittedEvent:e=>({type:U.SetOperatorSubmitted,txHash:e})},"shield:transferAndCall":{submittedEvent:e=>({type:U.ShieldSubmitted,txHash:e,shieldPath:`transferAndCall`})},"shield:approveAndWrap":{submittedEvent:e=>({type:U.ShieldSubmitted,txHash:e,shieldPath:`approveAndWrap`})},transfer:{submittedEvent:e=>({type:U.TransferSubmitted,txHash:e})},transferAndCall:{submittedEvent:e=>({type:U.TransferSubmitted,txHash:e})},transferFrom:{submittedEvent:e=>({type:U.TransferFromSubmitted,txHash:e})},transferFromAndCall:{submittedEvent:e=>({type:U.TransferFromSubmitted,txHash:e})},unwrap:{submittedEvent:e=>({type:U.UnwrapSubmitted,txHash:e})},unwrapAll:{submittedEvent:e=>({type:U.UnwrapSubmitted,txHash:e})}};async function G(e,t=1/0){if(Number.isFinite(t)&&t<=0)throw Error(`maxConcurrency must be a positive number`);if(!Number.isFinite(t)||t>=e.length)return Promise.all(e.map(e=>e()));let n=Array.from({length:e.length}),r=0;async function i(){for(;r<e.length;){let t=r++;e[t]&&(n[t]=await e[t]())}}return await Promise.all(Array.from({length:t},i)),n}const K=`0x0000000000000000000000000000000000000000000000000000000000000000`;function q(e){return e===`0x0000000000000000000000000000000000000000000000000000000000000000`||e===`0x`}async function J(e){let{operation:n,signer:r,provider:i,config:a,emit:o,onSubmitted:s,logger:l}=e,u=W[n];try{let e=await r.writeContract(a);return o(u.submittedEvent(e)),c(`${n}: onSubmitted`,()=>s?.(e),l),{txHash:e,receipt:await i.waitForTransactionReceipt(e)}}catch(e){let r=e instanceof t?e:new D(`Transaction failed during ${n}`,{cause:e});throw o({type:U.TransactionError,operation:n,error:r}),r}}var Y=class e{sdk;address;constructor(e,t){this.sdk=e,this.address=E(t)}#e(e){return s(this.sdk.signer,e)}async name(){return this.sdk.provider.readContract(h(this.address))}async symbol(){return this.sdk.provider.readContract(x(this.address))}async decimals(){return this.sdk.provider.readContract(y(this.address))}async isConfidential(){return this.sdk.provider.readContract(_(this.address,g))}async isWrapper(){return this.sdk.provider.readContract(_(this.address,v))}async balanceOf(e){let t=E(e),n=await this.readConfidentialBalanceOf(t),r=(await this.sdk.decryption.decryptValues([{encryptedValue:n,contractAddress:this.address}]))[n];if(r===void 0)throw new C(`Decryption returned no value for ${n}`);return T(r,`balanceOf: result[encryptedValue]`),r}async confidentialBalanceOf(e){return this.readConfidentialBalanceOf(E(e))}async decryptBalanceAs({delegatorAddress:e,accountAddress:t}){await H(`decryptBalanceAs`,this.sdk.signer,this.sdk.provider);let n=E(e),r=t?E(t):n,i=await this.readConfidentialBalanceOf(r);if(q(i))return 0n;let a=(await this.sdk.decryption.delegatedDecryptValues([{encryptedValue:i,contractAddress:this.address}],n,r))[i];if(a===void 0)throw new C(`Delegated decryption returned no value for ${i}`);return T(a,`decryptBalanceAs: result[encryptedValue]`),a}static async batchBalancesOf(n,r){let i=new Map,a=new Map;if(n.length===0)return{results:i,errors:a};let o=e.assertSameSdk(n);await H(`batchBalancesOf`,o.signer,o.provider),await o.permits.grantPermit(n.map(e=>e.address));let s=await G(n.map(e=>async()=>{try{return{status:`fulfilled`,value:await e.balanceOf(r)}}catch(e){return{status:`rejected`,reason:e}}}),5);for(let e=0;e<n.length;e++){let r=n[e].address,o=s[e];if(o.status===`fulfilled`)i.set(r,o.value);else{let e=o.reason;if(P(e))throw e;let n=e instanceof t?e:new C(w(e).message,{cause:e});a.set(r,n)}}if(a.size===n.length)throw a.values().next().value??new C(`All token balance decryptions failed`);return{results:i,errors:a}}static async batchDecryptBalancesAs(t,n){if(t.length===0)return new Map;let r=e.assertSameSdk(t),i=new Map,a=new Map,o=n.accountAddress?E(n.accountAddress):E(n.delegatorAddress),s=n.maxConcurrency??10;if(n.encryptedValues&&t.length!==n.encryptedValues.length)throw new C(`tokens.length (${t.length}) must equal encryptedValues.length (${n.encryptedValues.length})`);let c=n.encryptedValues??await e.readBalanceHandlesBatch(t,o,a,s),l=[];for(let[e,n]of t.entries()){let t=c[e];!t||a.has(n.address)||(q(t)?i.set(n.address,0n):l.push({token:n,encryptedValue:t}))}if(l.length>0){let e=await r.decryption.delegatedBatchDecryptValues({encryptedInputs:l.map(({token:e,encryptedValue:t})=>({encryptedValue:t,contractAddress:e.address})),delegatorAddress:n.delegatorAddress,accountAddress:n.accountAddress,maxConcurrency:s});for(let[t,n]of e.items.entries()){let e=l[t];if(!e)continue;if(n.error){a.set(e.token.address,n.error);continue}let r=n.value;if(r===void 0){a.set(e.token.address,new C(`Batch delegated decryption returned no value for ${n.encryptedValue} on token ${e.token.address}`));continue}T(r,`batchDecryptBalancesAs: result[encryptedValue]`),i.set(e.token.address,r)}}if(a.size===0)return i;if(n.onError){let e=[];for(let[t,r]of a)try{i.set(t,n.onError(r,t))}catch(n){e.push({address:t,error:w(n)})}if(e.length>0){let t=e.map(({address:e,error:t})=>`${e}: ${t.message}`).join(`; `);throw new C(`Batch delegated decryption onError callback failed for ${e.length} token(s): ${t}`,{cause:e[0]?.error})}return i}let u=Array.from(a.entries()),d=u.map(([e,t])=>`${e}: ${t.message}`).join(`; `);throw new C(`Batch delegated decryption failed for ${a.size} token(s): ${d}`,{cause:u[0]?.[1]})}static async readBalanceHandlesBatch(e,n,r,i){let a=await G(e.map(e=>async()=>{try{return{status:`fulfilled`,value:await e.readConfidentialBalanceOf(n)}}catch(e){return{status:`rejected`,reason:e}}}),i),o=[];for(let[n,i]of e.entries()){let e=a[n];if(e){if(e.status===`fulfilled`){o[n]=e.value;continue}if(P(e.reason))throw e.reason;r.set(i.address,e.reason instanceof t?e.reason:new C(w(e.reason).message,{cause:e.reason}))}}return o}async confidentialTransfer(e,t,n){this.#e(`confidentialTransfer`);let r=await V(`confidentialTransfer`,this.sdk.signer,this.sdk.provider),{skipBalanceCheck:i=!1,onEncryptComplete:a,onTransferSubmitted:o}=n??{},s=E(e);i||await this.assertConfidentialBalance(t);let{encryptedValues:l,inputProof:u}=await this.sdk.encrypt({values:[{value:t,type:`euint64`}],contractAddress:this.address,userAddress:E(r.address)});if(c(`transfer: onEncryptComplete`,()=>a?.(),this.sdk.logger),l.length===0)throw new S(`Encryption returned no encrypted values`);return this.submitTransaction({operation:`transfer`,config:f(this.address,s,l[0],u),onSubmitted:o})}async confidentialTransferFrom(e,t,n,r){this.#e(`confidentialTransferFrom`),await V(`confidentialTransferFrom`,this.sdk.signer,this.sdk.provider);let i=E(e),o=E(t),{encryptedValues:s,inputProof:l}=await this.sdk.encrypt({values:[{value:n,type:`euint64`}],contractAddress:this.address,userAddress:i});if(c(`transferFrom: onEncryptComplete`,()=>r?.onEncryptComplete?.(),this.sdk.logger),s.length===0)throw new S(`Encryption returned no encrypted values`);return this.submitTransaction({operation:`transferFrom`,config:a(this.address,i,o,s[0],l),onSubmitted:r?.onTransferSubmitted})}async confidentialTransferAndCall(e,t,n,r){this.#e(`confidentialTransferAndCall`);let i=await V(`confidentialTransferAndCall`,this.sdk.signer,this.sdk.provider),{skipBalanceCheck:a=!1,onEncryptComplete:o,onTransferSubmitted:s}=r??{},l=E(e);a||await this.assertConfidentialBalance(t);let{encryptedValues:u,inputProof:d}=await this.sdk.encrypt({values:[{value:t,type:`euint64`}],contractAddress:this.address,userAddress:E(i.address)});if(c(`transferAndCall: onEncryptComplete`,()=>o?.(),this.sdk.logger),u.length===0)throw new S(`Encryption returned no encrypted values`);return this.submitTransaction({operation:`transferAndCall`,config:b(this.address,l,u[0],d,n),onSubmitted:s})}async confidentialTransferFromAndCall(e,t,n,r,i){this.#e(`confidentialTransferFromAndCall`),await V(`confidentialTransferFromAndCall`,this.sdk.signer,this.sdk.provider);let a=E(e),s=E(t),{encryptedValues:l,inputProof:u}=await this.sdk.encrypt({values:[{value:n,type:`euint64`}],contractAddress:this.address,userAddress:a});if(c(`transferFromAndCall: onEncryptComplete`,()=>i?.onEncryptComplete?.(),this.sdk.logger),l.length===0)throw new S(`Encryption returned no encrypted values`);return this.submitTransaction({operation:`transferFromAndCall`,config:o(this.address,a,s,l[0],u,r),onSubmitted:i?.onTransferSubmitted})}async setOperator(e,t){this.#e(`setOperator`),await H(`setOperator`,this.sdk.signer,this.sdk.provider);let n=E(e);return this.submitTransaction({operation:`setOperator`,config:l(this.address,n,t)})}async isOperator(e,t){return this.sdk.provider.readContract(r(this.address,E(e),E(t)))}async readConfidentialBalanceOf(e){return await this.sdk.provider.readContract(d(this.address,e))}async assertConfidentialBalance(e){if(e===0n)return;let n;try{let e=await V(`assertConfidentialBalance`,this.sdk.signer,this.sdk.provider);n=await this.balanceOf(E(e.address))}catch(e){throw e instanceof t?e:new M(`Balance validation failed (token: ${this.address})`,{cause:e})}if(n<e)throw new A(`Insufficient confidential balance: requested ${e}, available ${n} (token: ${this.address})`,{requested:e,available:n,token:this.address})}emit(e){this.sdk.emitEvent(e,this.address)}async submitTransaction(e){let{operation:t,config:n,onSubmitted:r}=e;return J({operation:t,signer:this.#e(t),provider:this.sdk.provider,config:n,emit:e=>this.emit(e),onSubmitted:r,logger:this.sdk.logger})}static assertSameSdk(e){let t=e[0].sdk;for(let r=1;r<e.length;r++)if(e[r].sdk!==t)throw new n(`All tokens in a batch operation must share the same ZamaSDK instance`);return t}};export{A as _,G as a,O as b,H as c,R as d,z as f,N as g,M as h,q as i,B as l,P as m,J as n,U as o,L as p,K as r,V as s,Y as t,I as u,j as v,D as x,k as y};
|
|
2
|
+
//# sourceMappingURL=token-Bt33g0zQ.js.map
|