@zama-fhe/sdk 3.3.1-alpha.2 → 3.4.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.
Files changed (50) hide show
  1. package/dist/cjs/index.cjs +1 -1
  2. package/dist/cjs/index.cjs.map +1 -1
  3. package/dist/cjs/query/index.cjs +1 -1
  4. package/dist/cjs/query/index.cjs.map +1 -1
  5. package/dist/cjs/relayer.cjs +1 -1
  6. package/dist/cjs/relayer.cjs.map +1 -1
  7. package/dist/cjs/token.cjs +1 -1
  8. package/dist/cjs/token.cjs.map +1 -1
  9. package/dist/esm/{base-signer-CI-FYai2.js → base-signer-Co79VFwf.js} +2 -2
  10. package/dist/esm/{base-signer-CI-FYai2.js.map → base-signer-Co79VFwf.js.map} +1 -1
  11. package/dist/esm/{base-signer-Q2EJECrc.d.ts → base-signer-D5HdiBp1.d.ts} +2 -3
  12. package/dist/esm/chains/index.d.ts +1 -1
  13. package/dist/esm/cleartext/index.d.ts +2 -2
  14. package/dist/esm/cleartext/index.js +1 -1
  15. package/dist/esm/{cleartext-U6sPs_Kd.d.ts → cleartext-Bvx-0y6k.d.ts} +2 -3
  16. package/dist/esm/{cleartext-BfXTVQu-.js → cleartext-DHEMC21x.js} +2 -2
  17. package/dist/esm/{cleartext-BfXTVQu-.js.map → cleartext-DHEMC21x.js.map} +1 -1
  18. package/dist/esm/ethers/index.d.ts +4 -5
  19. package/dist/esm/ethers/index.js +1 -1
  20. package/dist/esm/{fhevm-relayer-B-lEKfPQ.js → fhevm-relayer-CyfdS4_t.js} +2 -2
  21. package/dist/esm/{fhevm-relayer-B-lEKfPQ.js.map → fhevm-relayer-CyfdS4_t.js.map} +1 -1
  22. package/dist/esm/{index-BnIp_-Ak.d.ts → index-CDJk5ZAg.d.ts} +4 -3
  23. package/dist/esm/{index-D66eC3G7.d.ts → index-doNE2KoX.d.ts} +1 -2
  24. package/dist/esm/index.d.ts +8 -9
  25. package/dist/esm/index.js +1 -1
  26. package/dist/esm/index.js.map +1 -1
  27. package/dist/esm/node/index.d.ts +4 -4
  28. package/dist/esm/node/index.js +1 -1
  29. package/dist/esm/query/index.d.ts +2 -2
  30. package/dist/esm/query/index.js +1 -1
  31. package/dist/esm/query/index.js.map +1 -1
  32. package/dist/esm/relayer-BUxKmetl.js +2 -0
  33. package/dist/esm/relayer-BUxKmetl.js.map +1 -0
  34. package/dist/esm/token-CK6XGnWp.js +2 -0
  35. package/dist/esm/token-CK6XGnWp.js.map +1 -0
  36. package/dist/esm/{types-Bov8XY36.d.ts → types-CObfaH4A.d.ts} +3 -4
  37. package/dist/esm/{types-BpvL50qX.d.ts → types-D8g0H49N.d.ts} +3 -4
  38. package/dist/esm/{types-C-WTLcHZ.d.ts → types-nwhfaUCK.d.ts} +14 -9
  39. package/dist/esm/viem/index.d.ts +4 -5
  40. package/dist/esm/viem/index.js +1 -1
  41. package/dist/esm/web/index.d.ts +1 -2
  42. package/dist/esm/web/index.js +1 -1
  43. package/dist/esm/{wrappers-registry-xZWzyAi4.js → wrappers-registry-vjouAqDk.js} +2 -2
  44. package/dist/esm/{wrappers-registry-xZWzyAi4.js.map → wrappers-registry-vjouAqDk.js.map} +1 -1
  45. package/dist/esm/{zama-sdk-q4_qt64Q.d.ts → zama-sdk-aaLl2ZlA.d.ts} +131 -107
  46. package/package.json +2 -2
  47. package/dist/esm/relayer-BYq9bLh8.js +0 -2
  48. package/dist/esm/relayer-BYq9bLh8.js.map +0 -1
  49. package/dist/esm/token-CmHTAAWW.js +0 -2
  50. package/dist/esm/token-CmHTAAWW.js.map +0 -1
@@ -1,9 +1,12 @@
1
- import { u as FheChain } from "./index-D66eC3G7.js";
2
- import { $ as TransferOptions, Bt as EncryptedValue, C as ChainRouter, Ht as FhevmRelayerOptions, K as ZamaSDKEventInput, Mt as TransactionResult, Nt as ClearValue, Pt as DecryptPublicValuesResult, R as TransactionOperation, Rt as EncryptParams, Ut as FhevmRelayerSDK, Z as ShieldOptions, c as GenericStorage, d as WalletAccount, et as UnshieldOptions, i as ZamaConfig, l as GenericProvider, n as RelayerConfig, nt as TransferCallbacks, o as ZamaConfigGeneric, p as WalletAccountListener, rt as UnshieldCallbacks, s as GenericLogger, u as GenericSigner, x as WriteContractConfig, zt as EncryptResult } from "./types-C-WTLcHZ.js";
1
+ import { u as FheChain } from "./index-doNE2KoX.js";
2
+ import { $ as TransferOptions, Bt as EncryptedValue, C as ChainRouter, Ht as FhevmRelayerOptions, K as ZamaSDKEventInput, Mt as TransactionResult, Nt as ClearValue, Pt as DecryptPublicValuesResult, R as TransactionOperation, Rt as EncryptParams, Ut as FhevmRelayerSDK, Z as ShieldOptions, c as GenericStorage, d as WalletAccount, et as UnshieldOptions, i as ZamaConfig, l as GenericProvider, n as RelayerConfig, nt as TransferCallbacks, o as ZamaConfigGeneric, p as WalletAccountListener, rt as UnshieldCallbacks, s as GenericLogger, u as GenericSigner, x as WriteContractConfig, zt as EncryptResult } from "./types-nwhfaUCK.js";
3
+ import "./cleartext-Bvx-0y6k.js";
4
+ import "./types-D8g0H49N.js";
5
+ import "./types-CObfaH4A.js";
6
+ import "./index-CDJk5ZAg.js";
3
7
  import { Address, Hex } from "viem";
4
8
  import { z } from "zod/mini";
5
9
  import { MutationFunctionContext, QueryKey, QueryObserverOptions, skipToken } from "@tanstack/query-core";
6
-
7
10
  //#region src/config/create.d.ts
8
11
  /**
9
12
  * Create a {@link ZamaConfig} from a custom {@link GenericSigner} and
@@ -19101,35 +19104,65 @@ declare function confidentialIsOperatorQueryOptions(sdk: ZamaSDK, tokenAddress:
19101
19104
  * ```
19102
19105
  */
19103
19106
  declare const ZamaErrorCode: {
19104
- /** User rejected the wallet signature prompt. */readonly SigningRejected: "SIGNING_REJECTED"; /** Wallet signature failed for a reason other than rejection. */
19105
- readonly SigningFailed: "SIGNING_FAILED"; /** FHE encryption failed. */
19106
- readonly EncryptionFailed: "ENCRYPTION_FAILED"; /** FHE decryption failed. */
19107
- readonly DecryptionFailed: "DECRYPTION_FAILED"; /** On-chain transaction reverted. */
19108
- readonly TransactionReverted: "TRANSACTION_REVERTED"; /** Transport key pair has expired and needs regeneration. */
19109
- readonly TransportKeyPairExpired: "KEYPAIR_EXPIRED"; /** Relayer rejected transport key pair (stale, expired, or malformed). */
19110
- readonly InvalidTransportKeyPair: "INVALID_KEYPAIR"; /** No FHE ciphertext exists for this account (never shielded). */
19111
- readonly NoCiphertext: "NO_CIPHERTEXT"; /** Relayer HTTP request failed. */
19112
- readonly RelayerRequestFailed: "RELAYER_REQUEST_FAILED"; /** The configured signer/account is not entitled (ACL) to decrypt this encrypted value. Don't retry — wait for a grant. */
19113
- readonly NotEntitled: "NOT_ENTITLED"; /** The consumer's RPC provider rate-limited an on-chain read (e.g. HTTP 429 / JSON-RPC -32005). Retryable. */
19114
- readonly RpcRateLimited: "RPC_RATE_LIMITED"; /** SDK configuration is invalid (e.g. forbidden chain ID, unsupported type). */
19115
- readonly Configuration: "CONFIGURATION"; /** Delegation cannot target self (delegate === msg.sender). */
19116
- readonly DelegationSelfNotAllowed: "DELEGATION_SELF_NOT_ALLOWED"; /** Only one delegate/revoke per (delegator, delegate, contract) per block. */
19117
- readonly DelegationCooldown: "DELEGATION_COOLDOWN"; /** No active delegation found for this (delegator, delegate, contract) tuple. */
19118
- readonly DelegationNotFound: "DELEGATION_NOT_FOUND"; /** The delegation has expired. */
19119
- readonly DelegationExpired: "DELEGATION_EXPIRED"; /** Confidential (cToken) balance is insufficient for the requested operation. */
19120
- readonly InsufficientConfidentialBalance: "INSUFFICIENT_CONFIDENTIAL_BALANCE"; /** ERC-20 balance is insufficient for the requested shield amount. */
19121
- readonly InsufficientERC20Balance: "INSUFFICIENT_ERC20_BALANCE"; /** Balance validation could not be performed (no cached credentials and decryption not possible). */
19122
- readonly BalanceCheckUnavailable: "BALANCE_CHECK_UNAVAILABLE"; /** Public ERC-20 read (e.g. balanceOf) failed due to a network or contract error. */
19123
- readonly ERC20ReadFailed: "ERC20_READ_FAILED"; /** The new expiration date equals the current one — no on-chain change needed. */
19124
- readonly DelegationExpiryUnchanged: "DELEGATION_EXPIRY_UNCHANGED"; /** Delegate address cannot be the contract address. */
19125
- readonly DelegationDelegateEqualsContract: "DELEGATION_DELEGATE_EQUALS_CONTRACT"; /** Contract address cannot be the sender address. */
19126
- readonly DelegationContractIsSelf: "DELEGATION_CONTRACT_IS_SELF"; /** The ACL contract is paused. */
19127
- readonly AclPaused: "ACL_PAUSED"; /** Expiration date is too soon (must be at least 1 hour in the future). */
19128
- readonly DelegationExpirationTooSoon: "DELEGATION_EXPIRATION_TOO_SOON"; /** Delegation exists on-chain but hasn't propagated to the gateway yet. */
19129
- readonly DelegationNotPropagated: "DELEGATION_NOT_PROPAGATED"; /** Signer and provider are connected to different chains. */
19130
- readonly ChainMismatch: "CHAIN_MISMATCH"; /** Operation requires a signer but none is configured. */
19131
- readonly SignerNotConfigured: "SIGNER_NOT_CONFIGURED"; /** Operation requires a connected wallet account. */
19132
- readonly WalletNotConnected: "WALLET_NOT_CONNECTED"; /** Wallet account discovery is still resolving. */
19107
+ /** User rejected the wallet signature prompt. */
19108
+ readonly SigningRejected: "SIGNING_REJECTED";
19109
+ /** Wallet signature failed for a reason other than rejection. */
19110
+ readonly SigningFailed: "SIGNING_FAILED";
19111
+ /** FHE encryption failed. */
19112
+ readonly EncryptionFailed: "ENCRYPTION_FAILED";
19113
+ /** FHE decryption failed. */
19114
+ readonly DecryptionFailed: "DECRYPTION_FAILED";
19115
+ /** On-chain transaction reverted. */
19116
+ readonly TransactionReverted: "TRANSACTION_REVERTED";
19117
+ /** Transport key pair has expired and needs regeneration. */
19118
+ readonly TransportKeyPairExpired: "KEYPAIR_EXPIRED";
19119
+ /** Relayer rejected transport key pair (stale, expired, or malformed). */
19120
+ readonly InvalidTransportKeyPair: "INVALID_KEYPAIR";
19121
+ /** No FHE ciphertext exists for this account (never shielded). */
19122
+ readonly NoCiphertext: "NO_CIPHERTEXT";
19123
+ /** Relayer HTTP request failed. */
19124
+ readonly RelayerRequestFailed: "RELAYER_REQUEST_FAILED";
19125
+ /** The configured signer/account is not entitled (ACL) to decrypt this encrypted value. Don't retry — wait for a grant. */
19126
+ readonly NotEntitled: "NOT_ENTITLED";
19127
+ /** The consumer's RPC provider rate-limited an on-chain read (e.g. HTTP 429 / JSON-RPC -32005). Retryable. */
19128
+ readonly RpcRateLimited: "RPC_RATE_LIMITED";
19129
+ /** SDK configuration is invalid (e.g. forbidden chain ID, unsupported type). */
19130
+ readonly Configuration: "CONFIGURATION";
19131
+ /** Delegation cannot target self (delegate === msg.sender). */
19132
+ readonly DelegationSelfNotAllowed: "DELEGATION_SELF_NOT_ALLOWED";
19133
+ /** Only one delegate/revoke per (delegator, delegate, contract) per block. */
19134
+ readonly DelegationCooldown: "DELEGATION_COOLDOWN";
19135
+ /** No active delegation found for this (delegator, delegate, contract) tuple. */
19136
+ readonly DelegationNotFound: "DELEGATION_NOT_FOUND";
19137
+ /** The delegation has expired. */
19138
+ readonly DelegationExpired: "DELEGATION_EXPIRED";
19139
+ /** Confidential (cToken) balance is insufficient for the requested operation. */
19140
+ readonly InsufficientConfidentialBalance: "INSUFFICIENT_CONFIDENTIAL_BALANCE";
19141
+ /** ERC-20 balance is insufficient for the requested shield amount. */
19142
+ readonly InsufficientERC20Balance: "INSUFFICIENT_ERC20_BALANCE";
19143
+ /** Balance validation could not be performed (no cached credentials and decryption not possible). */
19144
+ readonly BalanceCheckUnavailable: "BALANCE_CHECK_UNAVAILABLE";
19145
+ /** Public ERC-20 read (e.g. balanceOf) failed due to a network or contract error. */
19146
+ readonly ERC20ReadFailed: "ERC20_READ_FAILED";
19147
+ /** The new expiration date equals the current one — no on-chain change needed. */
19148
+ readonly DelegationExpiryUnchanged: "DELEGATION_EXPIRY_UNCHANGED";
19149
+ /** Delegate address cannot be the contract address. */
19150
+ readonly DelegationDelegateEqualsContract: "DELEGATION_DELEGATE_EQUALS_CONTRACT";
19151
+ /** Contract address cannot be the sender address. */
19152
+ readonly DelegationContractIsSelf: "DELEGATION_CONTRACT_IS_SELF";
19153
+ /** The ACL contract is paused. */
19154
+ readonly AclPaused: "ACL_PAUSED";
19155
+ /** Expiration date is too soon (must be at least 1 hour in the future). */
19156
+ readonly DelegationExpirationTooSoon: "DELEGATION_EXPIRATION_TOO_SOON";
19157
+ /** Delegation exists on-chain but hasn't propagated to the gateway yet. */
19158
+ readonly DelegationNotPropagated: "DELEGATION_NOT_PROPAGATED";
19159
+ /** Signer and provider are connected to different chains. */
19160
+ readonly ChainMismatch: "CHAIN_MISMATCH";
19161
+ /** Operation requires a signer but none is configured. */
19162
+ readonly SignerNotConfigured: "SIGNER_NOT_CONFIGURED";
19163
+ /** Operation requires a connected wallet account. */
19164
+ readonly WalletNotConnected: "WALLET_NOT_CONNECTED";
19165
+ /** Wallet account discovery is still resolving. */
19133
19166
  readonly WalletAccountNotReady: "WALLET_ACCOUNT_NOT_READY";
19134
19167
  };
19135
19168
  /** Union of all {@link ZamaErrorCode} string values. */
@@ -19142,8 +19175,52 @@ type ZamaErrorCode = (typeof ZamaErrorCode)[keyof typeof ZamaErrorCode];
19142
19175
  declare class ZamaError extends Error {
19143
19176
  /** Machine-readable error code. */
19144
19177
  readonly code: ZamaErrorCode;
19145
- constructor(code: ZamaErrorCode, message: string, options?: ErrorOptions);
19178
+ /**
19179
+ * Whether the operation that threw this error is safe to retry. Defaults to
19180
+ * {@link RETRYABLE_BY_CODE}'s entry for `code`; only {@link RelayerRequestFailedError}
19181
+ * overrides it per-instance (its retryability depends on the HTTP status).
19182
+ * Prefer {@link isRetryable} over reading this directly, so a new `unknown`
19183
+ * caught value doesn't need an `instanceof ZamaError` check first.
19184
+ */
19185
+ readonly retryable: boolean;
19186
+ constructor(code: ZamaErrorCode, message: string, options?: ErrorOptions & {
19187
+ retryable?: boolean;
19188
+ });
19146
19189
  }
19190
+ /**
19191
+ * True if `error` is a {@link ZamaError} whose failure is transient and safe to
19192
+ * retry (rate-limited, back-pressured, a delegation still propagating or in
19193
+ * its per-block cooldown, or a wallet account still resolving).
19194
+ * Compiler-guaranteed to stay in sync with the
19195
+ * taxonomy: every {@link ZamaError} subclass declares its own retryability via
19196
+ * {@link ZamaError.retryable}, so a consumer never has to hardcode a set of
19197
+ * retryable codes.
19198
+ *
19199
+ * @example
19200
+ * ```ts
19201
+ * try {
19202
+ * await sdk.decryption.decryptValues([{ encryptedValue, contractAddress }]);
19203
+ * } catch (e) {
19204
+ * if (isRetryable(e)) {
19205
+ * // back off and retry (see retryAfterSeconds for a server-suggested delay)
19206
+ * } else {
19207
+ * throw e; // terminal — surface it
19208
+ * }
19209
+ * }
19210
+ * ```
19211
+ */
19212
+ declare function isRetryable(error: unknown): error is ZamaError & {
19213
+ retryable: true;
19214
+ };
19215
+ /**
19216
+ * The server-suggested retry delay, in **seconds**, for a retryable
19217
+ * {@link ZamaError} — unifying the `retryAfter` field that today lives on
19218
+ * {@link RelayerRequestFailedError} and {@link RpcRateLimitError} only.
19219
+ * `undefined` when the error isn't retryable, or is retryable but carries no
19220
+ * server-driven delay (e.g. {@link DelegationNotPropagatedError} — retry that
19221
+ * with your own backoff).
19222
+ */
19223
+ declare function retryAfterSeconds(error: unknown): number | undefined;
19147
19224
  //#endregion
19148
19225
  //#region src/errors/chain.d.ts
19149
19226
  /**
@@ -19171,11 +19248,7 @@ declare class ChainMismatchError extends ZamaError {
19171
19248
  readonly operation: string;
19172
19249
  readonly signerChainId: number;
19173
19250
  readonly providerChainId: number;
19174
- constructor({
19175
- operation,
19176
- signerChainId,
19177
- providerChainId
19178
- }: {
19251
+ constructor({ operation, signerChainId, providerChainId }: {
19179
19252
  operation: string;
19180
19253
  signerChainId: number;
19181
19254
  providerChainId: number;
@@ -19315,16 +19388,9 @@ declare class RelayerRequestFailedError extends ZamaError {
19315
19388
  * Server-driven retry delay in **seconds** (the SDK's duration unit and the
19316
19389
  * header's own unit), from the relayer's `Retry-After` header. Set only on
19317
19390
  * back-pressure (HTTP 429) responses that carry the header; `undefined`
19318
- * otherwise. Implies {@link retryable}.
19391
+ * otherwise. Implies {@link ZamaError.retryable}.
19319
19392
  */
19320
19393
  readonly retryAfter: number | undefined;
19321
- /**
19322
- * Whether the request may be safely retried. `true` for relayer back-pressure
19323
- * (HTTP 429) — pair with {@link retryAfter} for the server's suggested delay —
19324
- * and for a relayer timeout (which carries no status but is safe to retry, via
19325
- * the `retryable` option). `false` for terminal failures (e.g. a 4xx/5xx).
19326
- */
19327
- readonly retryable: boolean;
19328
19394
  constructor(message: string, statusCode?: number, options?: ErrorOptions & {
19329
19395
  retryAfter?: number;
19330
19396
  retryable?: boolean;
@@ -19518,7 +19584,7 @@ type ErrorForCode = Complete<{
19518
19584
  * });
19519
19585
  * ```
19520
19586
  */
19521
- declare function matchZamaError<R>(error: unknown, handlers: { [K in ZamaErrorCode]?: (error: ErrorForCode[K]) => R } & {
19587
+ declare function matchZamaError<R>(error: unknown, handlers: { [K in ZamaErrorCode]?: (error: ErrorForCode[K]) => R; } & {
19522
19588
  _?: (error: unknown) => R;
19523
19589
  }): R | undefined;
19524
19590
  //#endregion
@@ -19637,10 +19703,7 @@ declare class Token {
19637
19703
  * });
19638
19704
  * ```
19639
19705
  */
19640
- decryptBalanceAs({
19641
- delegatorAddress,
19642
- accountAddress
19643
- }: {
19706
+ decryptBalanceAs({ delegatorAddress, accountAddress }: {
19644
19707
  delegatorAddress: Address;
19645
19708
  accountAddress?: Address;
19646
19709
  }): Promise<bigint>;
@@ -20199,7 +20262,8 @@ declare function unwrapAllMutationOptions(token: WrappedToken): MutationFactoryO
20199
20262
  //#region src/query/finalize-unwrap.d.ts
20200
20263
  /** Variables for {@link finalizeUnwrapMutationOptions}. */
20201
20264
  type FinalizeUnwrapParams = {
20202
- /** Identifier from an `UnwrapRequested` event. */unwrapRequestId: EncryptedValue;
20265
+ /** Identifier from an `UnwrapRequested` event. */
20266
+ unwrapRequestId: EncryptedValue;
20203
20267
  };
20204
20268
  declare function finalizeUnwrapMutationOptions(token: WrappedToken): MutationFactoryOptions<readonly ["zama.finalizeUnwrap", Address], FinalizeUnwrapParams, TransactionResult>;
20205
20269
  //#endregion
@@ -20396,33 +20460,19 @@ declare class CachingService {
20396
20460
  //#region src/services/delegation-service.d.ts
20397
20461
  declare class DelegationService {
20398
20462
  #private;
20399
- constructor({
20400
- provider,
20401
- router,
20402
- emitEvent,
20403
- logger
20404
- }: {
20463
+ constructor({ provider, router, emitEvent, logger }: {
20405
20464
  provider: GenericProvider;
20406
20465
  router: ChainRouter;
20407
20466
  logger: GenericLogger;
20408
20467
  emitEvent?: (input: ZamaSDKEventInput, tokenAddress?: Address) => void;
20409
20468
  });
20410
- delegateDecryption(signer: GenericSigner, {
20411
- contractAddress,
20412
- delegateAddress,
20413
- delegatorAddress,
20414
- expirationDate
20415
- }: {
20469
+ delegateDecryption(signer: GenericSigner, { contractAddress, delegateAddress, delegatorAddress, expirationDate }: {
20416
20470
  contractAddress: Address;
20417
20471
  delegateAddress: Address;
20418
20472
  delegatorAddress: Address;
20419
20473
  expirationDate?: Date;
20420
20474
  }): Promise<TransactionResult>;
20421
- revokeDelegation(signer: GenericSigner, {
20422
- contractAddress,
20423
- delegateAddress,
20424
- delegatorAddress
20425
- }: {
20475
+ revokeDelegation(signer: GenericSigner, { contractAddress, delegateAddress, delegatorAddress }: {
20426
20476
  contractAddress: Address;
20427
20477
  delegateAddress: Address;
20428
20478
  delegatorAddress: Address;
@@ -20432,11 +20482,7 @@ declare class DelegationService {
20432
20482
  delegatorAddress: Address;
20433
20483
  delegateAddress: Address;
20434
20484
  }): Promise<boolean>;
20435
- getDelegationExpiry({
20436
- contractAddress,
20437
- delegatorAddress,
20438
- delegateAddress
20439
- }: {
20485
+ getDelegationExpiry({ contractAddress, delegatorAddress, delegateAddress }: {
20440
20486
  contractAddress: Address;
20441
20487
  delegatorAddress: Address;
20442
20488
  delegateAddress: Address;
@@ -20467,13 +20513,7 @@ interface BatchDecryptResult {
20467
20513
  }
20468
20514
  declare class DecryptionService {
20469
20515
  #private;
20470
- constructor({
20471
- cache,
20472
- credentialService,
20473
- delegationService,
20474
- router,
20475
- emitEvent
20476
- }: {
20516
+ constructor({ cache, credentialService, delegationService, router, emitEvent }: {
20477
20517
  cache: CachingService;
20478
20518
  credentialService: CredentialService;
20479
20519
  delegationService: DelegationService;
@@ -20482,14 +20522,7 @@ declare class DecryptionService {
20482
20522
  });
20483
20523
  decryptValues(handles: EncryptedInput[], signerAddress: Address, opts?: Pick<FhevmRelayerOptions, "signal" | "timeout">): Promise<Record<EncryptedValue, ClearValue>>;
20484
20524
  delegatedDecryptValues(encryptedInputs: EncryptedInput[], delegatorAddress: Address, delegateAddress: Address, accountAddress: Address, opts?: DelegatedDecryptOptions): Promise<Record<EncryptedValue, ClearValue>>;
20485
- delegatedBatchDecryptHandlesAs({
20486
- encryptedInputs,
20487
- delegatorAddress,
20488
- delegateAddress,
20489
- accountAddress,
20490
- maxConcurrency,
20491
- waitForPropagation
20492
- }: {
20525
+ delegatedBatchDecryptHandlesAs({ encryptedInputs, delegatorAddress, delegateAddress, accountAddress, maxConcurrency, waitForPropagation }: {
20493
20526
  encryptedInputs: EncryptedInput[];
20494
20527
  delegatorAddress: Address;
20495
20528
  delegateAddress: Address;
@@ -20518,6 +20551,10 @@ declare class DecryptionService {
20518
20551
  * **Mixed signer requirement:** `decryptValues` and
20519
20552
  * `delegatedDecryptValues` need a configured signer; `decryptPublicValues`
20520
20553
  * does not. Each method documents its requirement in its JSDoc.
20554
+ *
20555
+ * **Request chunking:** decrypt requests are split internally to stay under
20556
+ * the relayer's 2048-cleartext-bit per-request budget — callers never need to
20557
+ * size batches themselves.
20521
20558
  */
20522
20559
  declare class Decryption {
20523
20560
  #private;
@@ -20631,13 +20668,7 @@ declare class Decryption {
20631
20668
  * }
20632
20669
  * ```
20633
20670
  */
20634
- delegatedBatchDecryptValues({
20635
- encryptedInputs,
20636
- delegatorAddress,
20637
- accountAddress,
20638
- maxConcurrency,
20639
- waitForPropagation
20640
- }: {
20671
+ delegatedBatchDecryptValues({ encryptedInputs, delegatorAddress, accountAddress, maxConcurrency, waitForPropagation }: {
20641
20672
  encryptedInputs: EncryptedInput[];
20642
20673
  delegatorAddress: Address;
20643
20674
  accountAddress?: Address;
@@ -20688,11 +20719,7 @@ declare class Delegations {
20688
20719
  * @throws if the new expiry equals the current one. {@link DelegationExpiryUnchangedError}
20689
20720
  * @throws if the delegation transaction reverts. {@link TransactionRevertedError}
20690
20721
  */
20691
- delegateDecryption({
20692
- contractAddress,
20693
- delegateAddress,
20694
- expirationDate
20695
- }: {
20722
+ delegateDecryption({ contractAddress, delegateAddress, expirationDate }: {
20696
20723
  contractAddress: Address;
20697
20724
  delegateAddress: Address;
20698
20725
  expirationDate?: Date;
@@ -20709,10 +20736,7 @@ declare class Delegations {
20709
20736
  * @throws if no delegation exists for this (delegator, delegate, contract) tuple. {@link DelegationNotFoundError}
20710
20737
  * @throws if the revocation transaction reverts. {@link TransactionRevertedError}
20711
20738
  */
20712
- revokeDelegation({
20713
- contractAddress,
20714
- delegateAddress
20715
- }: {
20739
+ revokeDelegation({ contractAddress, delegateAddress }: {
20716
20740
  contractAddress: Address;
20717
20741
  delegateAddress: Address;
20718
20742
  }): Promise<TransactionResult>;
@@ -21001,5 +21025,5 @@ declare class ZamaSDK {
21001
21025
  [Symbol.dispose](): void;
21002
21026
  }
21003
21027
  //#endregion
21004
- export { confidentialTransferMutationOptions as $, getTokenAddressContract as $n, DelegationSelfNotAllowedError as $t, encryptMutationOptions as A, QueryFilterLike as An, setOperatorContract as Ar, SignerRequiredError as At, UnshieldParams as B, invalidateWagmiBalanceQueries as Bn, InsufficientConfidentialBalanceError as Bt, grantPermitMutationOptions as C, IsConfidentialQueryConfig as Cn, confidentialTotalSupplyContract as Cr, BatchDecryptAsOptions as Ct, DecryptResult as D, TokenMetadataQueryConfig as Dn, inferredTotalSupplyContract as Dr, SigningFailedError as Dt, delegatedDecryptValuesMutationOptions as E, TokenMetadata as En, finalizeUnwrapContract as Er, TransactionRevertedError as Et, unwrapMutationOptions as F, invalidateAfterTransfer as Fn, ResolvedChainRelayer as Fr, ConfigurationError as Ft, confidentialSetOperatorMutationOptions as G, QueryFactoryOptions as Gn, DelegationContractIsSelfError as Gt, ApproveUnderlyingParams as H, zamaQueryKeys as Hn, DecryptionFailedError as Ht, ResumeUnshieldParams as I, invalidateAfterUnshield as In, resolveChainRelayers as Ir, RelayerRequestFailedError as It, ConfidentialTransferFromParams as J, hashFn as Jn, DelegationExpirationTooSoonError as Jt, ConfidentialTransferFromAndCallParams as K, StrippedQueryOptionKeys as Kn, DelegationCooldownError as Kt, resumeUnshieldMutationOptions as L, invalidateAfterUnshieldSettled as Ln, resolveStorage as Lr, BalanceCheckUnavailableError as Lt, finalizeUnwrapMutationOptions as M, invalidateAfterApproveUnderlying as Mn, unwrapContract as Mr, WalletNotConnectedError as Mt, unwrapAllMutationOptions as N, invalidateAfterSetOperator as Nn, unwrapFromBalanceContract as Nr, RpcRateLimitError as Nt, EncryptedInput as O, tokenMetadataQueryOptions as On, isOperatorContract as Or, SigningRejectedError as Ot, UnwrapParams as P, invalidateAfterShield as Pn, wrapContract as Pr, NotEntitledError as Pt, ConfidentialTransferParams as Q, getConfidentialTokenAddressContract as Qn, DelegationNotPropagatedError as Qt, UnshieldAllParams as R, invalidateAfterUnwrap as Rn, createConfig as Rr, BalanceErrorDetails as Rt, hasPermitQueryOptions as S, totalSupplyQueryOptions as Sn, confidentialBalanceOfContract as Sr, BatchBalancesResult as St, DelegatedDecryptValuesMutationParams as T, isWrapperQueryOptions as Tn, confidentialTransferFromContract as Tr, matchZamaError as Tt, approveUnderlyingMutationOptions as U, SignerQueryContext as Un, EncryptionFailedError as Ut, unshieldMutationOptions as V, invalidateWalletLifecycleQueries as Vn, InsufficientERC20BalanceError as Vt, ConfidentialSetOperatorParams as W, MutationFactoryOptions as Wn, AclPausedError as Wt, ConfidentialTransferAndCallParams as X, TokenWrapperPair as Xn, DelegationExpiryUnchangedError as Xt, confidentialTransferFromMutationOptions as Y, PaginatedResult as Yn, DelegationExpiredError as Yt, confidentialTransferAndCallMutationOptions as Z, TokenWrapperPairWithMetadata as Zn, DelegationNotFoundError as Zt, DelegateDecryptionParams as _, WrappersRegistryConfig as _n, approveContract as _r, ConfidentialBalancesQueryConfig as _t, BatchDecryptItem as a, ZamaErrorCode as an, delegateForUserDecryptionContract as ar, TokenAddressQueryConfig as at, revokePermitsMutationOptions as b, StoredTransportKeyPair as bn, nameContract as br, confidentialBalanceQueryOptions as bt, DelegationStatusData as c, PendingUnshieldQueryConfig as cn, revokeDelegationContract as cr, WrappersRegistryQueryConfig as ct, RevokeDelegationParams as d, underlyingAllowanceQueryOptions as dn, ERC7984_INTERFACE_ID as dr, listPairsQueryOptions as dt, InvalidTransportKeyPairError as en, getTokenPairContract as er, ShieldParams as et, revokeDelegationMutationOptions as f, WrapperDiscoveryQueryConfig as fn, ERC7984_WRAPPER_INTERFACE_ID as fr, tokenAddressQueryOptions as ft, decryptBalanceAsMutationOptions as g, WrappersRegistry as gn, allowanceContract as gr, tokenPairsSliceQueryOptions as gt, DecryptBalanceAsParams as h, ListPairsOptions as hn, supportsInterfaceContract as hr, tokenPairsQueryOptions as ht, Decryption as i, ZamaError as in, isConfidentialTokenValidContract as ir, ListPairsQueryConfig as it, FinalizeUnwrapParams as j, QueryLike as jn, underlyingContract as jr, WalletAccountNotReadyError as jt, decryptValuesQueryOptions as k, QueryClientLike as kn, rateContract as kr, SignerNotConfiguredError as kt, DelegationStatusQueryConfig as l, pendingUnshieldQueryOptions as ln, transferAndCallContract as lr, confidentialTokenAddressQueryOptions as lt, batchDecryptBalancesAsMutationOptions as m, DefaultRegistryAddresses as mn, isConfidentialWrapperContract as mr, tokenPairsLengthQueryOptions as mt, Permits as n, TransportKeyPairExpiredError as nn, getTokenPairsLengthContract as nr, ConfidentialTokenAddressQueryConfig as nt, BatchDecryptResult as o, ConfidentialIsOperatorQueryConfig as on, getDelegationExpiryContract as or, TokenPairQueryConfig as ot, BatchDecryptBalancesAsParams as p, wrapperDiscoveryQueryOptions as pn, isConfidentialTokenContract as pr, tokenPairQueryOptions as pt, confidentialTransferFromAndCallMutationOptions as q, filterQueryOptions as qn, DelegationDelegateEqualsContractError as qt, Delegations as r, ChainMismatchError as rn, getTokenPairsSliceContract as rr, IsConfidentialTokenValidQueryConfig as rt, DelegatedDecryptOptions as s, confidentialIsOperatorQueryOptions as sn, isHandleDelegatedContract as sr, TokenPairsSliceQueryConfig as st, ZamaSDK as t, NoCiphertextError as tn, getTokenPairsContract as tr, shieldMutationOptions as tt, delegationStatusQueryOptions as u, UnderlyingAllowanceQueryConfig as un, ERC1363_INTERFACE_ID as ur, isConfidentialTokenValidQueryOptions as ut, delegateDecryptionMutationOptions as v, Permission as vn, balanceOfContract as vr, confidentialBalancesQueryOptions as vt, decryptPublicValuesMutationOptions as w, isConfidentialQueryOptions as wn, confidentialTransferContract as wr, Token as wt, HasPermitQueryConfig as x, TotalSupplyQueryConfig as xn, symbolContract as xr, WrappedToken as xt, clearCredentialsMutationOptions as y, SerializedTransportKeyPair as yn, decimalsContract as yr, ConfidentialBalanceQueryConfig as yt, unshieldAllMutationOptions as z, invalidateBalanceQueries as zn, ERC20ReadFailedError as zt };
21005
- //# sourceMappingURL=zama-sdk-q4_qt64Q.d.ts.map
21028
+ export { confidentialTransferMutationOptions as $, TokenWrapperPairWithMetadata as $n, DelegationSelfNotAllowedError as $t, encryptMutationOptions as A, tokenMetadataQueryOptions as An, isOperatorContract as Ar, SignerRequiredError as At, UnshieldParams as B, invalidateAfterUnwrap as Bn, createConfig as Br, InsufficientConfidentialBalanceError as Bt, grantPermitMutationOptions as C, TotalSupplyQueryConfig as Cn, symbolContract as Cr, BatchDecryptAsOptions as Ct, DecryptResult as D, isWrapperQueryOptions as Dn, confidentialTransferFromContract as Dr, SigningFailedError as Dt, delegatedDecryptValuesMutationOptions as E, isConfidentialQueryOptions as En, confidentialTransferContract as Er, TransactionRevertedError as Et, unwrapMutationOptions as F, invalidateAfterSetOperator as Fn, unwrapFromBalanceContract as Fr, ConfigurationError as Ft, confidentialSetOperatorMutationOptions as G, SignerQueryContext as Gn, DelegationContractIsSelfError as Gt, ApproveUnderlyingParams as H, invalidateWagmiBalanceQueries as Hn, DecryptionFailedError as Ht, ResumeUnshieldParams as I, invalidateAfterShield as In, wrapContract as Ir, RelayerRequestFailedError as It, ConfidentialTransferFromParams as J, StrippedQueryOptionKeys as Jn, DelegationExpirationTooSoonError as Jt, ConfidentialTransferFromAndCallParams as K, MutationFactoryOptions as Kn, DelegationCooldownError as Kt, resumeUnshieldMutationOptions as L, invalidateAfterTransfer as Ln, ResolvedChainRelayer as Lr, BalanceCheckUnavailableError as Lt, finalizeUnwrapMutationOptions as M, QueryFilterLike as Mn, setOperatorContract as Mr, WalletNotConnectedError as Mt, unwrapAllMutationOptions as N, QueryLike as Nn, underlyingContract as Nr, RpcRateLimitError as Nt, EncryptedInput as O, TokenMetadata as On, finalizeUnwrapContract as Or, SigningRejectedError as Ot, UnwrapParams as P, invalidateAfterApproveUnderlying as Pn, unwrapContract as Pr, NotEntitledError as Pt, ConfidentialTransferParams as Q, TokenWrapperPair as Qn, DelegationNotPropagatedError as Qt, UnshieldAllParams as R, invalidateAfterUnshield as Rn, resolveChainRelayers as Rr, BalanceErrorDetails as Rt, hasPermitQueryOptions as S, StoredTransportKeyPair as Sn, nameContract as Sr, BatchBalancesResult as St, DelegatedDecryptValuesMutationParams as T, IsConfidentialQueryConfig as Tn, confidentialTotalSupplyContract as Tr, matchZamaError as Tt, approveUnderlyingMutationOptions as U, invalidateWalletLifecycleQueries as Un, EncryptionFailedError as Ut, unshieldMutationOptions as V, invalidateBalanceQueries as Vn, InsufficientERC20BalanceError as Vt, ConfidentialSetOperatorParams as W, zamaQueryKeys as Wn, AclPausedError as Wt, ConfidentialTransferAndCallParams as X, hashFn as Xn, DelegationExpiryUnchangedError as Xt, confidentialTransferFromMutationOptions as Y, filterQueryOptions as Yn, DelegationExpiredError as Yt, confidentialTransferAndCallMutationOptions as Z, PaginatedResult as Zn, DelegationNotFoundError as Zt, DelegateDecryptionParams as _, ListPairsOptions as _n, supportsInterfaceContract as _r, ConfidentialBalancesQueryConfig as _t, BatchDecryptItem as a, ZamaErrorCode as an, getTokenPairsSliceContract as ar, TokenAddressQueryConfig as at, revokePermitsMutationOptions as b, Permission as bn, balanceOfContract as br, confidentialBalanceQueryOptions as bt, DelegationStatusData as c, ConfidentialIsOperatorQueryConfig as cn, getDelegationExpiryContract as cr, WrappersRegistryQueryConfig as ct, RevokeDelegationParams as d, pendingUnshieldQueryOptions as dn, transferAndCallContract as dr, listPairsQueryOptions as dt, InvalidTransportKeyPairError as en, getConfidentialTokenAddressContract as er, ShieldParams as et, revokeDelegationMutationOptions as f, UnderlyingAllowanceQueryConfig as fn, ERC1363_INTERFACE_ID as fr, tokenAddressQueryOptions as ft, decryptBalanceAsMutationOptions as g, DefaultRegistryAddresses as gn, isConfidentialWrapperContract as gr, tokenPairsSliceQueryOptions as gt, DecryptBalanceAsParams as h, wrapperDiscoveryQueryOptions as hn, isConfidentialTokenContract as hr, tokenPairsQueryOptions as ht, Decryption as i, ZamaError as in, getTokenPairsLengthContract as ir, ListPairsQueryConfig as it, FinalizeUnwrapParams as j, QueryClientLike as jn, rateContract as jr, WalletAccountNotReadyError as jt, decryptValuesQueryOptions as k, TokenMetadataQueryConfig as kn, inferredTotalSupplyContract as kr, SignerNotConfiguredError as kt, DelegationStatusQueryConfig as l, confidentialIsOperatorQueryOptions as ln, isHandleDelegatedContract as lr, confidentialTokenAddressQueryOptions as lt, batchDecryptBalancesAsMutationOptions as m, WrapperDiscoveryQueryConfig as mn, ERC7984_WRAPPER_INTERFACE_ID as mr, tokenPairsLengthQueryOptions as mt, Permits as n, TransportKeyPairExpiredError as nn, getTokenPairContract as nr, ConfidentialTokenAddressQueryConfig as nt, BatchDecryptResult as o, isRetryable as on, isConfidentialTokenValidContract as or, TokenPairQueryConfig as ot, BatchDecryptBalancesAsParams as p, underlyingAllowanceQueryOptions as pn, ERC7984_INTERFACE_ID as pr, tokenPairQueryOptions as pt, confidentialTransferFromAndCallMutationOptions as q, QueryFactoryOptions as qn, DelegationDelegateEqualsContractError as qt, Delegations as r, ChainMismatchError as rn, getTokenPairsContract as rr, IsConfidentialTokenValidQueryConfig as rt, DelegatedDecryptOptions as s, retryAfterSeconds as sn, delegateForUserDecryptionContract as sr, TokenPairsSliceQueryConfig as st, ZamaSDK as t, NoCiphertextError as tn, getTokenAddressContract as tr, shieldMutationOptions as tt, delegationStatusQueryOptions as u, PendingUnshieldQueryConfig as un, revokeDelegationContract as ur, isConfidentialTokenValidQueryOptions as ut, delegateDecryptionMutationOptions as v, WrappersRegistry as vn, allowanceContract as vr, confidentialBalancesQueryOptions as vt, decryptPublicValuesMutationOptions as w, totalSupplyQueryOptions as wn, confidentialBalanceOfContract as wr, Token as wt, HasPermitQueryConfig as x, SerializedTransportKeyPair as xn, decimalsContract as xr, WrappedToken as xt, clearCredentialsMutationOptions as y, WrappersRegistryConfig as yn, approveContract as yr, ConfidentialBalanceQueryConfig as yt, unshieldAllMutationOptions as z, invalidateAfterUnshieldSettled as zn, resolveStorage as zr, ERC20ReadFailedError as zt };
21029
+ //# sourceMappingURL=zama-sdk-aaLl2ZlA.d.ts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zama-fhe/sdk",
3
- "version": "3.3.1-alpha.2",
3
+ "version": "3.4.0-alpha.2",
4
4
  "description": "TypeScript SDK for Zama fhEVM confidential smart contracts",
5
5
  "keywords": [
6
6
  "blockchain",
@@ -22,7 +22,7 @@
22
22
  "author": "Zama",
23
23
  "repository": {
24
24
  "type": "git",
25
- "url": "https://github.com/zama-ai/sdk",
25
+ "url": "git+https://github.com/zama-ai/sdk.git",
26
26
  "directory": "packages/sdk"
27
27
  },
28
28
  "files": [
@@ -1,2 +0,0 @@
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`,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=r?.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-BYq9bLh8.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"relayer-BYq9bLh8.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 /** 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 * and for a relayer timeout (which carries no status but is safe to retry, via\n * the `retryable` option). `false` for terminal failures (e.g. a 4xx/5xx).\n */\n readonly retryable: boolean;\n\n constructor(\n message: string,\n statusCode?: number,\n options?: ErrorOptions & { retryAfter?: number; retryable?: boolean },\n ) {\n super(ZamaErrorCode.RelayerRequestFailed, message, options);\n this.name = \"RelayerRequestFailedError\";\n this.statusCode = statusCode;\n // Retryable on relayer back-pressure (HTTP 429) by default, or when the\n // caller forces it (a relayer timeout has no status but is safe to retry).\n this.retryable = options?.retryable ?? statusCode === 429;\n // Keep the two fields consistent: a delay only makes sense when retryable,\n // and only a 429 actually carries a server-supplied `Retry-After`.\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,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,EC7Fa,EAAb,cAA+C,CAAU,CAEvD,WAQA,WAQA,UAEA,YACE,EACA,EACA,EACA,CACA,MAAM,EAAc,qBAAsB,EAAS,CAAO,EAC1D,KAAK,KAAO,4BACZ,KAAK,WAAa,EAGlB,KAAK,UAAY,GAAS,WAAa,IAAe,IAGtD,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,2 +0,0 @@
1
- import{i as e,r as t,t as n}from"./relayer-BYq9bLh8.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 ee,U as f,W as p,b as te,l as m,m as h,u as ne,v as re,w as ie,x as ae}from"./wrappers-registry-xZWzyAi4.js";import{getAddress as g}from"viem";var _=class extends t{constructor(t,n){super(e.EncryptionFailed,t,n),this.name=`EncryptionFailedError`}},v=class extends t{constructor(t,n){super(e.DecryptionFailed,t,n),this.name=`DecryptionFailedError`}},y=class extends t{constructor(t,n){super(e.TransactionReverted,t,n),this.name=`TransactionRevertedError`}},b=class extends t{retryAfter;constructor(t,n){let{retryAfter:r,...i}=n??{};super(e.RpcRateLimited,t,i),this.name=`RpcRateLimitError`,this.retryAfter=r}},x=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}},S=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}},C=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}},w=class extends t{constructor(t,n){super(e.BalanceCheckUnavailable,t,n),this.name=`BalanceCheckUnavailableError`}},T=class extends t{constructor(t,n){super(e.ERC20ReadFailed,t,n),this.name=`ERC20ReadFailedError`}};function E(e){return e instanceof Error?e:typeof e==`object`&&e&&`message`in e?Error(String(e.message)):Error(String(e))}function oe(e){if(!(e instanceof Error))return!1;if(e.name===`ContractFunctionExecutionError`||e.name===`ContractFunctionRevertedError`||`code`in e&&e.code===`CALL_EXCEPTION`)return!0;let t=e.message.toLowerCase();return t.includes(`execution reverted`)||t.includes(`call revert exception`)}const se=[`cause`,`error`,`info`];function D(e,t,n=6){if(n<0||typeof e!=`object`||!e)return;let r=e;if(t(r))return r;for(let e of se){let i=r[e];if(typeof i==`object`&&i){let e=D(i,t,n-1);if(e)return e}}}function O(e){if(e.code===-32005||e.status===429||e.code===429)return!0;if(e.code===`SERVER_ERROR`&&typeof e.info==`object`&&e.info!==null){let t=e.info.responseStatus;if(typeof t==`string`&&/^\s*429\b/.test(t))return!0}return!1}function k(e){if(O(e))return!0;if(typeof e.message==`string`){let t=e.message.toLowerCase();return t.includes(`too many requests`)||t.includes(`rate limit`)||t.includes(`rate-limit`)}return!1}function A(e){return D(e,e=>typeof e.name==`string`&&e.name.startsWith(`Relayer`))!==void 0}function j(e){return D(e,e=>e.name===`RelayerTimeoutError`)!==void 0}function M(e){return A(e)?!1:D(e,k)!==void 0}function N(e){return A(e)?!1:D(e,O)!==void 0}function P(e){return e.toLowerCase().includes(`is not authorized to decrypt handle`)}function F(e){return/handle (0x[0-9a-fA-F]{64})/.exec(e)?.[1]}function I(e){if(e==null)return;let t=e.trim();if(t!==``){if(/^\d+$/.test(t))return Number(t);if(/[a-zA-Z]/.test(t)){let e=Date.parse(t);if(!Number.isNaN(e))return Math.max(0,Math.round((e-Date.now())/1e3))}}}function L(e){if(typeof e!=`object`||!e)return;let t=e.get;if(typeof t==`function`)return I(t.call(e,`Retry-After`))}function R(e){let t=e.response;if(typeof t==`object`&&t)return L(t.headers)}function z(e){return typeof e.retryAfter==`number`&&Number.isFinite(e.retryAfter)&&e.retryAfter>0?e.retryAfter:R(e)}function B(e){let t=D(e,e=>z(e)!==void 0);return t?z(t):void 0}function V(e){let t=D(e,e=>typeof e.statusCode==`number`||typeof e.status==`number`);if(t)return typeof t.statusCode==`number`?t.statusCode:t.status}function H(e){return e instanceof p||e instanceof f||e instanceof n||e instanceof b}const U=[{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 W(e,t,n,r){return{address:e,abi:U,functionName:`delegateForUserDecryption`,args:[t,n,r]}}function G(e,t,n){return{address:e,abi:U,functionName:`revokeDelegationForUserDecryption`,args:[t,n]}}function ce(e,t,n,r){return{address:e,abi:U,functionName:`getUserDecryptionDelegationExpirationDate`,args:[t,n,r]}}function le(e,t,n,r,i){return{address:e,abi:U,functionName:`isHandleDelegatedForUserDecryption`,args:[t,n,r,i]}}const ue=2n**64n-1n;async function K(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 x({operation:e,signerChainId:r.chainId,providerChainId:a});return r}async function q(e,t,n){return(await K(e,t,n)).chainId}function de(e,t){if(e==null)throw TypeError(`${t} must not be null or undefined`)}function J(e,t){if(typeof e!=`bigint`)throw TypeError(`${t} must be a bigint, got ${typeof e}`)}const Y={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`},X={approveUnderlying:{submittedEvent:e=>({type:Y.ApproveUnderlyingSubmitted,txHash:e,step:`approve`})},"approveUnderlying:reset":{submittedEvent:e=>({type:Y.ApproveUnderlyingSubmitted,txHash:e,step:`reset`})},delegateDecryption:{submittedEvent:e=>({type:Y.DelegationSubmitted,txHash:e})},finalizeUnwrap:{submittedEvent:e=>({type:Y.FinalizeUnwrapSubmitted,txHash:e})},revokeDelegation:{submittedEvent:e=>({type:Y.RevokeDelegationSubmitted,txHash:e})},setOperator:{submittedEvent:e=>({type:Y.SetOperatorSubmitted,txHash:e})},"shield:transferAndCall":{submittedEvent:e=>({type:Y.ShieldSubmitted,txHash:e,shieldPath:`transferAndCall`})},"shield:approveAndWrap":{submittedEvent:e=>({type:Y.ShieldSubmitted,txHash:e,shieldPath:`approveAndWrap`})},transfer:{submittedEvent:e=>({type:Y.TransferSubmitted,txHash:e})},transferAndCall:{submittedEvent:e=>({type:Y.TransferSubmitted,txHash:e})},transferFrom:{submittedEvent:e=>({type:Y.TransferFromSubmitted,txHash:e})},transferFromAndCall:{submittedEvent:e=>({type:Y.TransferFromSubmitted,txHash:e})},unwrap:{submittedEvent:e=>({type:Y.UnwrapSubmitted,txHash:e})},unwrapAll:{submittedEvent:e=>({type:Y.UnwrapSubmitted,txHash:e})}};async function Z(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 fe=`0x0000000000000000000000000000000000000000000000000000000000000000`;function Q(e){return e===`0x0000000000000000000000000000000000000000000000000000000000000000`||e===`0x`}async function $(e){let{operation:n,signer:r,provider:i,config:a,emit:o,onSubmitted:s,logger:l}=e,u=X[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 y(`Transaction failed during ${n}`,{cause:e});throw o({type:Y.TransactionError,operation:n,error:r}),r}}var pe=class e{sdk;address;constructor(e,t){this.sdk=e,this.address=g(t)}#e(e){return s(this.sdk.signer,e)}async name(){return this.sdk.provider.readContract(te(this.address))}async symbol(){return this.sdk.provider.readContract(ae(this.address))}async decimals(){return this.sdk.provider.readContract(re(this.address))}async isConfidential(){return this.sdk.provider.readContract(h(this.address,m))}async isWrapper(){return this.sdk.provider.readContract(h(this.address,ne))}async balanceOf(e){let t=g(e),n=await this.readConfidentialBalanceOf(t),r=(await this.sdk.decryption.decryptValues([{encryptedValue:n,contractAddress:this.address}]))[n];if(r===void 0)throw new v(`Decryption returned no value for ${n}`);return J(r,`balanceOf: result[encryptedValue]`),r}async confidentialBalanceOf(e){return this.readConfidentialBalanceOf(g(e))}async decryptBalanceAs({delegatorAddress:e,accountAddress:t}){await q(`decryptBalanceAs`,this.sdk.signer,this.sdk.provider);let n=g(e),r=t?g(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 v(`Delegated decryption returned no value for ${i}`);return J(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 q(`batchBalancesOf`,o.signer,o.provider),await o.permits.grantPermit(n.map(e=>e.address));let s=await Z(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(H(e))throw e;let n=e instanceof t?e:new v(E(e).message,{cause:e});a.set(r,n)}}if(a.size===n.length)throw a.values().next().value??new v(`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?g(n.accountAddress):g(n.delegatorAddress),s=n.maxConcurrency??10;if(n.encryptedValues&&t.length!==n.encryptedValues.length)throw new v(`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 v(`Batch delegated decryption returned no value for ${n.encryptedValue} on token ${e.token.address}`));continue}J(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:E(n)})}if(e.length>0){let t=e.map(({address:e,error:t})=>`${e}: ${t.message}`).join(`; `);throw new v(`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 v(`Batch delegated decryption failed for ${a.size} token(s): ${d}`,{cause:u[0]?.[1]})}static async readBalanceHandlesBatch(e,n,r,i){let a=await Z(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(H(e.reason))throw e.reason;r.set(i.address,e.reason instanceof t?e.reason:new v(E(e.reason).message,{cause:e.reason}))}}return o}async confidentialTransfer(e,t,n){this.#e(`confidentialTransfer`);let r=await K(`confidentialTransfer`,this.sdk.signer,this.sdk.provider),{skipBalanceCheck:i=!1,onEncryptComplete:a,onTransferSubmitted:o}=n??{},s=g(e);i||await this.assertConfidentialBalance(t);let{encryptedValues:l,inputProof:u}=await this.sdk.encrypt({values:[{value:t,type:`euint64`}],contractAddress:this.address,userAddress:g(r.address)});if(c(`transfer: onEncryptComplete`,()=>a?.(),this.sdk.logger),l.length===0)throw new _(`Encryption returned no encrypted values`);return this.submitTransaction({operation:`transfer`,config:ee(this.address,s,l[0],u),onSubmitted:o})}async confidentialTransferFrom(e,t,n,r){this.#e(`confidentialTransferFrom`),await K(`confidentialTransferFrom`,this.sdk.signer,this.sdk.provider);let i=g(e),o=g(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 _(`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 K(`confidentialTransferAndCall`,this.sdk.signer,this.sdk.provider),{skipBalanceCheck:a=!1,onEncryptComplete:o,onTransferSubmitted:s}=r??{},l=g(e);a||await this.assertConfidentialBalance(t);let{encryptedValues:u,inputProof:d}=await this.sdk.encrypt({values:[{value:t,type:`euint64`}],contractAddress:this.address,userAddress:g(i.address)});if(c(`transferAndCall: onEncryptComplete`,()=>o?.(),this.sdk.logger),u.length===0)throw new _(`Encryption returned no encrypted values`);return this.submitTransaction({operation:`transferAndCall`,config:ie(this.address,l,u[0],d,n),onSubmitted:s})}async confidentialTransferFromAndCall(e,t,n,r,i){this.#e(`confidentialTransferFromAndCall`),await K(`confidentialTransferFromAndCall`,this.sdk.signer,this.sdk.provider);let a=g(e),s=g(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 _(`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 q(`setOperator`,this.sdk.signer,this.sdk.provider);let n=g(e);return this.submitTransaction({operation:`setOperator`,config:l(this.address,n,t)})}async isOperator(e,t){return this.sdk.provider.readContract(r(this.address,g(e),g(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 K(`assertConfidentialBalance`,this.sdk.signer,this.sdk.provider);n=await this.balanceOf(g(e.address))}catch(e){throw e instanceof t?e:new w(`Balance validation failed (token: ${this.address})`,{cause:e})}if(n<e)throw new S(`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 $({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{C as A,j as C,w as D,E,_ as F,b as M,y as N,T as O,v as P,A as S,F as T,V as _,Z as a,oe as b,de as c,ue as d,W as f,H as g,G as h,Q as i,x as j,S as k,K as l,le as m,$ as n,Y as o,ce as p,fe as r,J as s,pe as t,q as u,B as v,M as w,P as x,N as y};
2
- //# sourceMappingURL=token-CmHTAAWW.js.map