@zama-fhe/sdk 3.9.0-beta.3 → 3.9.0-beta.4

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 (55) hide show
  1. package/dist/cjs/index.cjs +1 -1
  2. package/dist/cjs/index.cjs.map +1 -1
  3. package/dist/cjs/log-decoding.cjs +1 -1
  4. package/dist/cjs/log-decoding.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/telemetry.cjs +1 -1
  8. package/dist/cjs/vaults/index.cjs +1 -1
  9. package/dist/cjs/vaults/index.cjs.map +1 -1
  10. package/dist/esm/{alignment-o-YIndFR.js → alignment-CLfJMQqN.js} +2 -2
  11. package/dist/esm/{alignment-o-YIndFR.js.map → alignment-CLfJMQqN.js.map} +1 -1
  12. package/dist/esm/{base-signer-Bst8sJcc.js → base-signer-D6Xtjbg3.js} +2 -2
  13. package/dist/esm/{base-signer-Bst8sJcc.js.map → base-signer-D6Xtjbg3.js.map} +1 -1
  14. package/dist/esm/cleartext/index.js +1 -1
  15. package/dist/esm/{cleartext-DcCwbO5i.js → cleartext-Na06vUVn.js} +2 -2
  16. package/dist/esm/{cleartext-DcCwbO5i.js.map → cleartext-Na06vUVn.js.map} +1 -1
  17. package/dist/esm/{decryption-Cp8calaa.d.ts → decryption-_KeIzen9.d.ts} +34 -10
  18. package/dist/esm/{encryption-BT886Jlj.js → encryption-B-uikunQ.js} +2 -2
  19. package/dist/esm/{encryption-BT886Jlj.js.map → encryption-B-uikunQ.js.map} +1 -1
  20. package/dist/esm/ethers/index.js +1 -1
  21. package/dist/esm/{fatal-batch-BYeHrf0V.js → fatal-batch-CWhfEMv9.js} +2 -2
  22. package/dist/esm/{fatal-batch-BYeHrf0V.js.map → fatal-batch-CWhfEMv9.js.map} +1 -1
  23. package/dist/esm/{fhevm-relayer-Da6yGHJQ.js → fhevm-relayer-D_T116vA.js} +2 -2
  24. package/dist/esm/{fhevm-relayer-Da6yGHJQ.js.map → fhevm-relayer-D_T116vA.js.map} +1 -1
  25. package/dist/esm/{index-CI6f4jxt.d.ts → index-D3eHf-xC.d.ts} +1 -1
  26. package/dist/esm/index.d.ts +3 -3
  27. package/dist/esm/index.js +1 -1
  28. package/dist/esm/index.js.map +1 -1
  29. package/dist/esm/internal/index.d.ts +1 -1
  30. package/dist/esm/internal/index.js +1 -1
  31. package/dist/esm/log-decoding-OI42RdDN.js +2 -0
  32. package/dist/esm/log-decoding-OI42RdDN.js.map +1 -0
  33. package/dist/esm/node/index.js +1 -1
  34. package/dist/esm/query/index.d.ts +2 -2
  35. package/dist/esm/query/index.js +1 -1
  36. package/dist/esm/relayer-BuZxFm5d.js +2 -0
  37. package/dist/esm/relayer-BuZxFm5d.js.map +1 -0
  38. package/dist/esm/{signing-CVEOw21I.js → signing-CJBcqlEl.js} +2 -2
  39. package/dist/esm/{signing-CVEOw21I.js.map → signing-CJBcqlEl.js.map} +1 -1
  40. package/dist/esm/{telemetry-DZs0eTBf.js → telemetry-DDxj4jDq.js} +2 -2
  41. package/dist/esm/{telemetry-DZs0eTBf.js.map → telemetry-DDxj4jDq.js.map} +1 -1
  42. package/dist/esm/{token-AXsOIUDB.js → token-4vv7uAoV.js} +2 -2
  43. package/dist/esm/{token-AXsOIUDB.js.map → token-4vv7uAoV.js.map} +1 -1
  44. package/dist/esm/{validation-CZfDLOUh.js → validation-dG3aQPUa.js} +2 -2
  45. package/dist/esm/{validation-CZfDLOUh.js.map → validation-dG3aQPUa.js.map} +1 -1
  46. package/dist/esm/vaults/index.d.ts +52 -17
  47. package/dist/esm/vaults/index.js +1 -1
  48. package/dist/esm/vaults/index.js.map +1 -1
  49. package/dist/esm/viem/index.js +1 -1
  50. package/dist/esm/web/index.js +1 -1
  51. package/package.json +1 -1
  52. package/dist/esm/log-decoding-ZthqwHOv.js +0 -2
  53. package/dist/esm/log-decoding-ZthqwHOv.js.map +0 -1
  54. package/dist/esm/relayer-nWfQAlo7.js +0 -2
  55. package/dist/esm/relayer-nWfQAlo7.js.map +0 -1
@@ -1 +1 @@
1
- export{t as cleartext}from"../cleartext-DcCwbO5i.js";
1
+ export{t as cleartext}from"../cleartext-Na06vUVn.js";
@@ -1,2 +1,2 @@
1
- import{t as e}from"./relayer-nWfQAlo7.js";import{t}from"./fhevm-relayer-Da6yGHJQ.js";function n(n){return{type:`cleartext`,createRelayer:(r,i)=>{if(!r.executorAddress)throw new e(`Cleartext relayer requires an executorAddress. Either use a chain preset that includes it (e.g. hardhat, hoodi) or set it on the chain definition.`);return new t({chain:r,options:n,cleartext:!0,logger:i})}}}export{n as t};
2
- //# sourceMappingURL=cleartext-DcCwbO5i.js.map
1
+ import{t as e}from"./relayer-BuZxFm5d.js";import{t}from"./fhevm-relayer-D_T116vA.js";function n(n){return{type:`cleartext`,createRelayer:(r,i)=>{if(!r.executorAddress)throw new e(`Cleartext relayer requires an executorAddress. Either use a chain preset that includes it (e.g. hardhat, hoodi) or set it on the chain definition.`);return new t({chain:r,options:n,cleartext:!0,logger:i})}}}export{n as t};
2
+ //# sourceMappingURL=cleartext-Na06vUVn.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"cleartext-DcCwbO5i.js","names":["ConfigurationError","cleartext","chain","FhevmRelayer"],"sources":["../../src/config/cleartext.ts"],"sourcesContent":["import { ConfigurationError } from \"../errors\";\nimport { FhevmRelayer } from \"../relayer/fhevm-relayer\";\nimport type { RelayerOptions } from \"../relayer/types\";\nimport type { CleartextRelayerConfig } from \"./types\";\n\n/**\n * Cleartext relayer — drives the FHE backend in cleartext mode (no FHE infrastructure).\n *\n * When `executorAddress` is set on the chain definition (e.g. `hardhat`, `hoodi`),\n * it is picked up automatically.\n *\n * @example\n * ```ts\n * // executorAddress comes from the chain preset:\n * relayers: { [hardhat.id]: cleartext({ batchRpcCalls: true }) }\n * ```\n */\nexport function cleartext(options?: RelayerOptions): CleartextRelayerConfig {\n return {\n type: \"cleartext\",\n createRelayer: (chain, logger) => {\n if (!chain.executorAddress) {\n throw new ConfigurationError(\n `Cleartext relayer requires an executorAddress. ` +\n `Either use a chain preset that includes it (e.g. hardhat, hoodi) ` +\n `or set it on the chain definition.`,\n );\n }\n return new FhevmRelayer({ chain, options, cleartext: true, logger });\n },\n };\n}\n"],"mappings":"A,qFAiBA,SAAgBC,EAAU,EAAkD,CAC1E,MAAO,CACL,KAAM,YACN,eAAgB,EAAO,IAAW,CAChC,GAAI,CAACC,EAAM,gBACT,MAAM,IAAIF,EACR,oJAGF,EAEF,OAAO,IAAIG,EAAa,CAAE,QAAO,UAAS,UAAW,GAAM,QAAO,CAAC,CACrE,CACF,CACF,C"}
1
+ {"version":3,"file":"cleartext-Na06vUVn.js","names":["ConfigurationError","cleartext","chain","FhevmRelayer"],"sources":["../../src/config/cleartext.ts"],"sourcesContent":["import { ConfigurationError } from \"../errors\";\nimport { FhevmRelayer } from \"../relayer/fhevm-relayer\";\nimport type { RelayerOptions } from \"../relayer/types\";\nimport type { CleartextRelayerConfig } from \"./types\";\n\n/**\n * Cleartext relayer — drives the FHE backend in cleartext mode (no FHE infrastructure).\n *\n * When `executorAddress` is set on the chain definition (e.g. `hardhat`, `hoodi`),\n * it is picked up automatically.\n *\n * @example\n * ```ts\n * // executorAddress comes from the chain preset:\n * relayers: { [hardhat.id]: cleartext({ batchRpcCalls: true }) }\n * ```\n */\nexport function cleartext(options?: RelayerOptions): CleartextRelayerConfig {\n return {\n type: \"cleartext\",\n createRelayer: (chain, logger) => {\n if (!chain.executorAddress) {\n throw new ConfigurationError(\n `Cleartext relayer requires an executorAddress. ` +\n `Either use a chain preset that includes it (e.g. hardhat, hoodi) ` +\n `or set it on the chain definition.`,\n );\n }\n return new FhevmRelayer({ chain, options, cleartext: true, logger });\n },\n };\n}\n"],"mappings":"A,qFAiBA,SAAgBC,EAAU,EAAkD,CAC1E,MAAO,CACL,KAAM,YACN,eAAgB,EAAO,IAAW,CAChC,GAAI,CAACC,EAAM,gBACT,MAAM,IAAIF,EACR,oJAGF,EAEF,OAAO,IAAIG,EAAa,CAAE,QAAO,UAAS,UAAW,GAAM,QAAO,CAAC,CACrE,CACF,CACF,C"}
@@ -23233,8 +23233,10 @@ declare const ZamaErrorCode: {
23233
23233
  readonly PreparedPermitExpired: "PREPARED_PERMIT_EXPIRED";
23234
23234
  /** The unwrap request was already finalized on-chain; there is nothing left to resume. */
23235
23235
  readonly UnshieldAlreadyFinalized: "UNSHIELD_ALREADY_FINALIZED";
23236
- /** A batcher a vault join needs is paused. */
23236
+ /** No batcher of a vault is open: each one is paused or closed. */
23237
23237
  readonly VaultBatcherPaused: "VAULT_BATCHER_PAUSED";
23238
+ /** A batcher of a vault could not be read, so the batch a join reaches is unknown. */
23239
+ readonly VaultBatcherReadFailed: "VAULT_BATCHER_READ_FAILED";
23238
23240
  /** A batch to be finalized is not dispatched. */
23239
23241
  readonly VaultBatchNotDispatched: "VAULT_BATCH_NOT_DISPATCHED";
23240
23242
  /** A vault join was mined, but its receipt does not confirm every leg. */
@@ -23252,8 +23254,8 @@ declare class ZamaError extends Error {
23252
23254
  readonly code: ZamaErrorCode;
23253
23255
  /**
23254
23256
  * Whether the operation that threw this error is safe to retry. Defaults to
23255
- * {@link RETRYABLE_BY_CODE}'s entry for `code`; only {@link RelayerRequestFailedError}
23256
- * overrides it per-instance (its retryability depends on the HTTP status).
23257
+ * {@link RETRYABLE_BY_CODE}'s entry for `code`; {@link RelayerRequestFailedError}
23258
+ * and `VaultBatcherReadFailedError` override it per instance.
23257
23259
  * Prefer {@link isRetryable} over reading this directly, so a new `unknown`
23258
23260
  * caught value doesn't need an `instanceof ZamaError` check first.
23259
23261
  */
@@ -23739,7 +23741,7 @@ interface Call {
23739
23741
  interface VaultLeg {
23740
23742
  /** The vault this leg joins. */
23741
23743
  readonly vaultId: string;
23742
- /** The vault's active batcher when the join was prepared. */
23744
+ /** The vault's batcher whose open batch the join reaches, chosen when the join was prepared. */
23743
23745
  readonly batcher: Address;
23744
23746
  /** The confidential token the leg spends: the asset for a deposit, the vault's share for a redeem. */
23745
23747
  readonly token: Address;
@@ -23883,13 +23885,13 @@ type Batch = (BatchBase & {
23883
23885
  readonly decimals: number;
23884
23886
  };
23885
23887
  });
23886
- /** The open batch of one vault's active batcher. */
23888
+ /** The batch a join into one vault reaches now. */
23887
23889
  interface OpenBatch extends BatchRef {
23888
23890
  /** The vault whose open batch this is. */
23889
23891
  readonly vaultId: string;
23890
23892
  /** The time from which anyone may dispatch the batch, in chain seconds. */
23891
23893
  readonly dispatchableAt: bigint;
23892
- /** Whether the batcher is paused. */
23894
+ /** Whether every batcher of the vault is paused or closed, so no join can be sent. */
23893
23895
  readonly paused: boolean;
23894
23896
  /** The block timestamp the read was made at. */
23895
23897
  readonly observedAt: bigint;
@@ -23905,19 +23907,39 @@ interface JoinOutcome {
23905
23907
  }
23906
23908
  /** What a {@link VaultBatcherPausedError} carries. */
23907
23909
  interface VaultBatcherPausedDetails {
23908
- /** The batcher that reported `paused()`. */
23910
+ /** A paused or closed batcher of the vault. */
23909
23911
  readonly batcher: Address;
23910
23912
  /** The vault whose leg needs the batcher. */
23911
23913
  readonly vaultId: string;
23912
23914
  }
23913
- /** A batcher that a join needs is paused. */
23915
+ /** No batcher of a vault is open: each one is paused or closed. */
23914
23916
  declare class VaultBatcherPausedError extends ZamaError {
23915
- /** The batcher that reported `paused()`. */
23917
+ /** A paused or closed batcher of the vault. */
23916
23918
  readonly batcher: Address;
23917
23919
  /** The vault whose leg needs the batcher. */
23918
23920
  readonly vaultId: string;
23919
23921
  constructor(message: string, details: VaultBatcherPausedDetails, options?: ErrorOptions);
23920
23922
  }
23923
+ /** What a {@link VaultBatcherReadFailedError} carries. */
23924
+ interface VaultBatcherReadFailedDetails {
23925
+ /** The batcher that could not be read. */
23926
+ readonly batcher: Address;
23927
+ /** The vault that lists the batcher. */
23928
+ readonly vaultId: string;
23929
+ }
23930
+ /**
23931
+ * A batcher of a vault could not be read, so the SDK cannot tell which batch a join reaches.
23932
+ * Retryable when its `cause` is, or when RPC nodes returned reads from different blocks.
23933
+ */
23934
+ declare class VaultBatcherReadFailedError extends ZamaError {
23935
+ /** The batcher that could not be read. */
23936
+ readonly batcher: Address;
23937
+ /** The vault that lists the batcher. */
23938
+ readonly vaultId: string;
23939
+ constructor(message: string, details: VaultBatcherReadFailedDetails, options?: ErrorOptions & {
23940
+ retryable?: boolean;
23941
+ });
23942
+ }
23921
23943
  /** What a {@link VaultBatchNotDispatchedError} carries. */
23922
23944
  interface VaultBatchNotDispatchedDetails {
23923
23945
  /** The batcher the batch belongs to. */
@@ -24048,6 +24070,8 @@ interface ErrorForCode {
24048
24070
  [ZamaErrorCode.UnshieldAlreadyFinalized]: UnshieldAlreadyFinalizedError;
24049
24071
  /** Thrown for {@link ZamaErrorCode.VaultBatcherPaused}. */
24050
24072
  [ZamaErrorCode.VaultBatcherPaused]: VaultBatcherPausedError;
24073
+ /** Thrown for {@link ZamaErrorCode.VaultBatcherReadFailed}. */
24074
+ [ZamaErrorCode.VaultBatcherReadFailed]: VaultBatcherReadFailedError;
24051
24075
  /** Thrown for {@link ZamaErrorCode.VaultBatchNotDispatched}. */
24052
24076
  [ZamaErrorCode.VaultBatchNotDispatched]: VaultBatchNotDispatchedError;
24053
24077
  /** Thrown for {@link ZamaErrorCode.VaultJoinUnconfirmed}. */
@@ -25710,4 +25734,4 @@ declare class Decryption {
25710
25734
  maxConcurrency?: number;
25711
25735
  } & DelegatedDecryptOptions): Promise<BatchDecryptResult>;
25712
25736
  }
25713
- export { VaultCall as $, PreparedPermit as $t, VaultBatcherPausedDetails as A, nameContract as An, DelegationDelegateEqualsContractError as At, GroupJoinInput as B, isOperatorContract as Bn, PreparedPermitChainMismatchError as Bt, Delegations as C, isConfidentialTokenContract as Cn, DecryptionFailedError as Ct, matchZamaError as D, approveContract as Dn, DelegationContractIsSelfError as Dt, ErrorForCode as E, allowanceContract as En, AclPausedError as Et, BatchAction as F, confidentialTransferContract as Fn, DelegationNotPropagatedError as Ft, JoinOptions as G, unwrapContract as Gn, ChainMismatchError as Gt, JoinCall as H, setOperatorContract as Hn, RevokedKmsContextError as Ht, BatchRef as I, confidentialTransferFromAndCallContract as In, DelegationSelfNotAllowedError as It, OpenBatch as J, wrapContract as Jn, isRetryable as Jt, JoinOutcome as K, unwrapFromBalanceContract as Kn, ZamaError as Kt, BatchState as L, confidentialTransferFromContract as Ln, InvalidTransportKeyPairError as Lt, VaultJoinUnconfirmedDetails as M, confidentialBalanceOfContract as Mn, DelegationExpiredError as Mt, VaultJoinUnconfirmedError as N, confidentialTotalSupplyContract as Nn, DelegationExpiryUnchangedError as Nt, VaultBatchNotDispatchedDetails as O, balanceOfContract as On, DelegationCooldownError as Ot, Batch as P, confidentialTransferAndCallContract as Pn, DelegationNotFoundError as Pt, SendJoinOptions as Q, PreparePermitRequest as Qt, BatcherRef as R, finalizeUnwrapContract as Rn, KeyWrappingError as Rt, Offline as S, ERC7984_WRAPPER_INTERFACE_ID as Sn, InsufficientERC20BalanceError as St, Permits as T, supportsInterfaceContract as Tn, EncryptionFailedError as Tt, JoinDirection as U, underlyingContract as Un, TransportKeyPairChangedError as Ut, GroupJoinOptions as V, rateContract as Vn, PreparedPermitExpiredError as Vt, JoinInput as W, unwrapAmountContract as Wn, TransportKeyPairExpiredError as Wt, PreparedFinalize as X, parsePreparedPermit as Xt, OperatorApprovalCall as Y, retryAfterSeconds as Yt, PreparedJoin as Z, Permission as Zt, WrappersRegistryConfig as _, isHandleDelegatedContract as _n, BalanceCheckUnavailableError as _t, DecryptResult as a, PaginatedResult as an, TransactionRevertedError as at, BatchDecryptAsOptions as b, ERC1363_INTERFACE_ID as bn, InsufficientAllowanceError as bt, SignerQueryContext as c, getConfidentialTokenAddressContract as cn, SigningRejectedError as ct, QueryFactoryOptions as d, getTokenPairsContract as dn, WalletAccountNotReadyError as dt, SerializedPermit as en, VaultLeg as et, ZamaSDK as f, getTokenPairsLengthContract as fn, WalletNotConnectedError as ft, WrappersRegistry as g, getDelegationExpiryContract as gn, RelayerRequestFailedError as gt, ListPairsOptions as h, delegateForUserDecryptionContract as hn, ConfigurationError as ht, DelegatedDecryptOptions as i, ChecksummedAddress as in, HcuTransactionLimitExceededError as it, VaultBatcherPausedError as j, symbolContract as jn, DelegationExpirationTooSoonError as jt, VaultBatchNotDispatchedError as k, decimalsContract as kn, DelegationDelegateCannotBeWildcardError as kt, zamaQueryKeys as l, getTokenAddressContract as ln, SignerNotConfiguredError as lt, DefaultRegistryAddresses as m, isConfidentialTokenValidContract as mn, NotEntitledError as mt, BatchDecryptItem as n, SerializedTransportKeyPair as nn, UnshieldAlreadyFinalizedError as nt, EncryptedInput as o, TokenWrapperPair as on, SigningErrorMetadata as ot, ZamaSDKOptions as p, getTokenPairsSliceContract as pn, RpcRateLimitError as pt, JoinRoute as q, unwrapRequesterContract as qn, ZamaErrorCode as qt, BatchDecryptResult as r, SignedPreparedPermit as rn, HcuBlockLimitExceededError as rt, decryptValuesQueryOptions as s, TokenWrapperPairWithMetadata as sn, SigningFailedError as st, Decryption as t, SerializedPermitEip712 as tn, UnshieldAlreadyFinalizedDetails as tt, MutationFactoryOptions as u, getTokenPairContract as un, SignerRequiredError as ut, WrappedToken as v, revokeDelegationContract as vn, BalanceErrorDetails as vt, DelegationStatus as w, isConfidentialWrapperContract as wn, EncryptOffloadUnavailableError as wt, Token as x, ERC7984_INTERFACE_ID as xn, InsufficientConfidentialBalanceError as xt, BatchBalancesResult as y, transferAndCallContract as yn, ERC20ReadFailedError as yt, Call as z, inferredTotalSupplyContract as zn, NoCiphertextError as zt };
25737
+ export { PreparedJoin as $, Permission as $t, VaultBatcherPausedDetails as A, balanceOfContract as An, DelegationCooldownError as At, BatcherRef as B, finalizeUnwrapContract as Bn, KeyWrappingError as Bt, Delegations as C, ERC7984_INTERFACE_ID as Cn, InsufficientConfidentialBalanceError as Ct, matchZamaError as D, supportsInterfaceContract as Dn, EncryptionFailedError as Dt, ErrorForCode as E, isConfidentialWrapperContract as En, EncryptOffloadUnavailableError as Et, VaultJoinUnconfirmedError as F, confidentialTotalSupplyContract as Fn, DelegationExpiryUnchangedError as Ft, JoinDirection as G, underlyingContract as Gn, TransportKeyPairChangedError as Gt, GroupJoinInput as H, isOperatorContract as Hn, PreparedPermitChainMismatchError as Ht, Batch as I, confidentialTransferAndCallContract as In, DelegationNotFoundError as It, JoinOutcome as J, unwrapFromBalanceContract as Jn, ZamaError as Jt, JoinInput as K, unwrapAmountContract as Kn, TransportKeyPairExpiredError as Kt, BatchAction as L, confidentialTransferContract as Ln, DelegationNotPropagatedError as Lt, VaultBatcherReadFailedDetails as M, nameContract as Mn, DelegationDelegateEqualsContractError as Mt, VaultBatcherReadFailedError as N, symbolContract as Nn, DelegationExpirationTooSoonError as Nt, VaultBatchNotDispatchedDetails as O, allowanceContract as On, AclPausedError as Ot, VaultJoinUnconfirmedDetails as P, confidentialBalanceOfContract as Pn, DelegationExpiredError as Pt, PreparedFinalize as Q, parsePreparedPermit as Qt, BatchRef as R, confidentialTransferFromAndCallContract as Rn, DelegationSelfNotAllowedError as Rt, Offline as S, ERC1363_INTERFACE_ID as Sn, InsufficientAllowanceError as St, Permits as T, isConfidentialTokenContract as Tn, DecryptionFailedError as Tt, GroupJoinOptions as U, rateContract as Un, PreparedPermitExpiredError as Ut, Call as V, inferredTotalSupplyContract as Vn, NoCiphertextError as Vt, JoinCall as W, setOperatorContract as Wn, RevokedKmsContextError as Wt, OpenBatch as X, wrapContract as Xn, isRetryable as Xt, JoinRoute as Y, unwrapRequesterContract as Yn, ZamaErrorCode as Yt, OperatorApprovalCall as Z, retryAfterSeconds as Zt, WrappersRegistryConfig as _, delegateForUserDecryptionContract as _n, ConfigurationError as _t, DecryptResult as a, SignedPreparedPermit as an, HcuBlockLimitExceededError as at, BatchDecryptAsOptions as b, revokeDelegationContract as bn, BalanceErrorDetails as bt, SignerQueryContext as c, TokenWrapperPair as cn, SigningErrorMetadata as ct, QueryFactoryOptions as d, getTokenAddressContract as dn, SignerNotConfiguredError as dt, PreparePermitRequest as en, SendJoinOptions as et, ZamaSDK as f, getTokenPairContract as fn, SignerRequiredError as ft, WrappersRegistry as g, isConfidentialTokenValidContract as gn, NotEntitledError as gt, ListPairsOptions as h, getTokenPairsSliceContract as hn, RpcRateLimitError as ht, DelegatedDecryptOptions as i, SerializedTransportKeyPair as in, UnshieldAlreadyFinalizedError as it, VaultBatcherPausedError as j, decimalsContract as jn, DelegationDelegateCannotBeWildcardError as jt, VaultBatchNotDispatchedError as k, approveContract as kn, DelegationContractIsSelfError as kt, zamaQueryKeys as l, TokenWrapperPairWithMetadata as ln, SigningFailedError as lt, DefaultRegistryAddresses as m, getTokenPairsLengthContract as mn, WalletNotConnectedError as mt, BatchDecryptItem as n, SerializedPermit as nn, VaultLeg as nt, EncryptedInput as o, ChecksummedAddress as on, HcuTransactionLimitExceededError as ot, ZamaSDKOptions as p, getTokenPairsContract as pn, WalletAccountNotReadyError as pt, JoinOptions as q, unwrapContract as qn, ChainMismatchError as qt, BatchDecryptResult as r, SerializedPermitEip712 as rn, UnshieldAlreadyFinalizedDetails as rt, decryptValuesQueryOptions as s, PaginatedResult as sn, TransactionRevertedError as st, Decryption as t, PreparedPermit as tn, VaultCall as tt, MutationFactoryOptions as u, getConfidentialTokenAddressContract as un, SigningRejectedError as ut, WrappedToken as v, getDelegationExpiryContract as vn, RelayerRequestFailedError as vt, DelegationStatus as w, ERC7984_WRAPPER_INTERFACE_ID as wn, InsufficientERC20BalanceError as wt, Token as x, transferAndCallContract as xn, ERC20ReadFailedError as xt, BatchBalancesResult as y, isHandleDelegatedContract as yn, BalanceCheckUnavailableError as yt, BatchState as z, confidentialTransferFromContract as zn, InvalidTransportKeyPairError as zt };
@@ -1,2 +1,2 @@
1
- import{i as e,r as t}from"./relayer-nWfQAlo7.js";var n=class extends t{constructor(t,n){super(e.EncryptionFailed,t,n),this.name=`EncryptionFailedError`}},r=class extends t{constructor(t,n){super(e.EncryptOffloadUnavailable,t,n),this.name=`EncryptOffloadUnavailableError`}},i=class extends t{constructor(t,n){super(e.DecryptionFailed,t,n),this.name=`DecryptionFailedError`}};export{r as n,n as r,i as t};
2
- //# sourceMappingURL=encryption-BT886Jlj.js.map
1
+ import{i as e,r as t}from"./relayer-BuZxFm5d.js";var n=class extends t{constructor(t,n){super(e.EncryptionFailed,t,n),this.name=`EncryptionFailedError`}},r=class extends t{constructor(t,n){super(e.EncryptOffloadUnavailable,t,n),this.name=`EncryptOffloadUnavailableError`}},i=class extends t{constructor(t,n){super(e.DecryptionFailed,t,n),this.name=`DecryptionFailedError`}};export{r as n,n as r,i as t};
2
+ //# sourceMappingURL=encryption-B-uikunQ.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"encryption-BT886Jlj.js","names":["ZamaErrorCode","ZamaError","EncryptionFailedError","message","options","EncryptOffloadUnavailableError","DecryptionFailedError"],"sources":["../../src/errors/encryption.ts"],"sourcesContent":["import { ZamaError, ZamaErrorCode } from \"./base\";\n\n/** FHE encryption failed. */\nexport class EncryptionFailedError extends ZamaError {\n constructor(message: string, options?: ErrorOptions) {\n super(ZamaErrorCode.EncryptionFailed, message, options);\n this.name = \"EncryptionFailedError\";\n }\n}\n\n/**\n * Encryption offload was required but the worker could not be used.\n *\n * Only `web({ offloadEncrypt: true })` throws this: the strict mode refuses to\n * silently finish the operation on the calling thread. With `\"auto\"` the same\n * conditions warn and fall back instead.\n */\nexport class EncryptOffloadUnavailableError extends ZamaError {\n constructor(message: string, options?: ErrorOptions) {\n super(ZamaErrorCode.EncryptOffloadUnavailable, message, options);\n this.name = \"EncryptOffloadUnavailableError\";\n }\n}\n\n/** FHE decryption failed. */\nexport class DecryptionFailedError extends ZamaError {\n constructor(message: string, options?: ErrorOptions) {\n super(ZamaErrorCode.DecryptionFailed, message, options);\n this.name = \"DecryptionFailedError\";\n }\n}\n"],"mappings":"A,iDAGA,IAAaE,EAAb,cAA2CD,CAAU,CACnD,YAAY,EAAiB,EAAwB,CACnD,MAAMD,EAAc,iBAAkBG,EAASC,CAAO,EACtD,KAAK,KAAO,uBACd,CACF,EASaC,EAAb,cAAoDJ,CAAU,CAC5D,YAAY,EAAiB,EAAwB,CACnD,MAAMD,EAAc,0BAA2BG,EAASC,CAAO,EAC/D,KAAK,KAAO,gCACd,CACF,EAGaE,EAAb,cAA2CL,CAAU,CACnD,YAAY,EAAiB,EAAwB,CACnD,MAAMD,EAAc,iBAAkBG,EAASC,CAAO,EACtD,KAAK,KAAO,uBACd,CACF,E"}
1
+ {"version":3,"file":"encryption-B-uikunQ.js","names":["ZamaErrorCode","ZamaError","EncryptionFailedError","message","options","EncryptOffloadUnavailableError","DecryptionFailedError"],"sources":["../../src/errors/encryption.ts"],"sourcesContent":["import { ZamaError, ZamaErrorCode } from \"./base\";\n\n/** FHE encryption failed. */\nexport class EncryptionFailedError extends ZamaError {\n constructor(message: string, options?: ErrorOptions) {\n super(ZamaErrorCode.EncryptionFailed, message, options);\n this.name = \"EncryptionFailedError\";\n }\n}\n\n/**\n * Encryption offload was required but the worker could not be used.\n *\n * Only `web({ offloadEncrypt: true })` throws this: the strict mode refuses to\n * silently finish the operation on the calling thread. With `\"auto\"` the same\n * conditions warn and fall back instead.\n */\nexport class EncryptOffloadUnavailableError extends ZamaError {\n constructor(message: string, options?: ErrorOptions) {\n super(ZamaErrorCode.EncryptOffloadUnavailable, message, options);\n this.name = \"EncryptOffloadUnavailableError\";\n }\n}\n\n/** FHE decryption failed. */\nexport class DecryptionFailedError extends ZamaError {\n constructor(message: string, options?: ErrorOptions) {\n super(ZamaErrorCode.DecryptionFailed, message, options);\n this.name = \"DecryptionFailedError\";\n }\n}\n"],"mappings":"A,iDAGA,IAAaE,EAAb,cAA2CD,CAAU,CACnD,YAAY,EAAiB,EAAwB,CACnD,MAAMD,EAAc,iBAAkBG,EAASC,CAAO,EACtD,KAAK,KAAO,uBACd,CACF,EASaC,EAAb,cAAoDJ,CAAU,CAC5D,YAAY,EAAiB,EAAwB,CACnD,MAAMD,EAAc,0BAA2BG,EAASC,CAAO,EAC/D,KAAK,KAAO,gCACd,CACF,EAGaE,EAAb,cAA2CL,CAAU,CACnD,YAAY,EAAiB,EAAwB,CACnD,MAAMD,EAAc,iBAAkBG,EAASC,CAAO,EACtD,KAAK,KAAO,uBACd,CACF,E"}
@@ -1,2 +1,2 @@
1
- import{i as e,t}from"../base-signer-Bst8sJcc.js";import{t as n}from"../relayer-nWfQAlo7.js";import{A as r,B as i,F as a,G as o,H as s,I as c,M as l,N as u,R as d,S as f,T as p,W as m,X as h,d as g,k as _,r as v,y}from"../alignment-o-YIndFR.js";import{a as b,i as x,n as S,o as C,r as w,s as T,t as E}from"../wrappers-registry-Cm3JJeqx.js";import{t as D}from"../eip1193-subscribe-DxAQh8dY.js";import{ProviderRpcError as ee,createClient as te,custom as O,decodeFunctionResult as k,encodeFunctionData as A,getAddress as j,isHex as M}from"viem";import{BrowserProvider as N,Contract as P,Transaction as F,ethers as I}from"ethers";import{multicall as L}from"viem/actions";function R(e){return{to:e.address,data:A({abi:e.abi,functionName:e.functionName,args:e.args}),...e.gas===void 0?{}:{gasLimit:e.gas},...e.value===void 0?{}:{value:e.value}}}async function z(e,t){let n=await e.call(R(t));if(!M(n))throw TypeError(`Expected hex string, got: ${n}`);return k({abi:t.abi,functionName:t.functionName,data:n})}async function B(e,t){let n=await e.sendTransaction(R(t));if(!M(n.hash))throw TypeError(`Expected hex string, got: ${n.hash}`);return n.hash}function V(e,t,n){return z(e,y(t,n))}function H(e,t){return z(e,r(t))}function U(e,t,n){return z(e,g(t,n))}function W(e,t,n,r,i){return B(e,f(t,n,r,i))}function G(e,t,n,r,i,a){return B(e,l(t,n,r,i,a))}function K(e,t,n,r,i){return B(e,u(t,n,r,i))}function q(e,t,n,r,i){return B(e,p(t,n,r,i))}function J(e,t,n,r){return B(e,_(t,n,r))}function Y(e,t,n,r){return B(e,a(t,n,r))}function X(e,t){return z(e,x(t))}function Z(e,t){return z(e,b(t))}function ne(e,t,n,r){return z(e,C(t,n,r))}function re(e,t,n){return z(e,w(t,n))}function ie(e,t,n){return z(e,E(t,n))}function ae(e,t,n){return z(e,S(t,n))}function oe(e,t,n){return z(e,T(t,n))}var Q=class{#e;#t=te({transport:O({request:async({method:e,params:t})=>{if(e!==`eth_call`)throw Error(`EthersProvider.multicall does not send ${e}`);let[n,r]=t;return this.#e.call({to:n.to,data:n.data,blockTag:r})}})});constructor(e){this.#e=`ethereum`in e?new N(e.ethereum):e.provider}async getChainId(){let e=await this.#e.getNetwork();return Number(e.chainId)}async readContract(e){return await v(`EthersProvider`,e.chainId,()=>this.getChainId()),z(this.#e,{address:e.address,abi:e.abi,functionName:e.functionName,args:e.args})}async multicall(e){await v(`EthersProvider`,e.chainId,()=>this.getChainId());let t=await L(this.#t,{contracts:e.calls.map(({chainId:e,...t})=>t),deployless:!0});return await Promise.all(e.calls.map((e,n)=>{let r=t[n];return r?.status===`success`?r.result:this.readContract({...e,chainId:void 0})}))}async getBlockTimestamp(e){await v(`EthersProvider`,e,()=>this.getChainId());let t=await this.#e.getBlock(`latest`);if(!t)throw new n(`EthersProvider.getBlockTimestamp: failed to fetch latest block`);if(t.timestamp===null)throw new n(`EthersProvider.getBlockTimestamp: latest block has no timestamp`);return BigInt(t.timestamp)}async waitForTransactionReceipt(e){let t=await this.#e.waitForTransaction(e);if(!t)throw new h(`EthersProvider.waitForTransactionReceipt: no receipt found for tx ${e}. The transaction may have been dropped from the mempool, or the RPC's wait timeout elapsed.`);let n=t.status===null?void 0:t.status===1?`success`:`reverted`;return{logs:t.logs.map(e=>({address:e.address,topics:e.topics.filter(e=>e!==null),data:e.data})),...n&&{status:n}}}async prepareTransaction(e){let{from:t,calldata:r}=e,i=new I.Interface(r.abi),a=[];i.forEachFunction(e=>{e.name===r.functionName&&a.push(e)});let o=r.args.length,s=a.length===1?a[0]:a.find(e=>e.inputs.length===o);if(!s)throw Error(`Function ${r.functionName}(${o} args) not found in ABI`);let c=i.encodeFunctionData(s,r.args);d(c,`data`);let l=r.value??0n,u=this.#e.getNetwork(),f=e.nonce===void 0?this.#e.getTransactionCount(t,`pending`):Promise.resolve(e.nonce),p=e.gasLimit===void 0?r.gas??this.#e.estimateGas({from:t,to:r.address,data:c,value:l}).catch(e=>{throw new h(`EthersProvider.prepareTransaction: gas estimation reverted for ${r.functionName} on ${r.address}`,{cause:e})}):Promise.resolve(e.gasLimit),m=e.fees??this.#e.getFeeData(),[g,_,v,y]=await Promise.all([u,f,p,m]),b=y.maxFeePerGas,x=y.maxPriorityFeePerGas;if(b===null||x===null)throw new n(`EthersProvider.prepareTransaction: EIP-1559 fee data unavailable (provider returned null maxFeePerGas). The connected chain may not support EIP-1559 type-2 transactions.`);return F.from({type:2,chainId:Number(g.chainId),nonce:_,to:r.address,data:c,value:l,gasLimit:v,maxFeePerGas:b,maxPriorityFeePerGas:x}).unsignedSerialized}},$=class extends t{#e;#t;#n;#r;#i;constructor(e){super(),`ethereum`in e?(this.#e=new N(e.ethereum),this.#n=e.ethereum,this.#r=D({provider:e.ethereum,getInitialWalletAccount:()=>this.#l(),onWalletAccountChange:({next:e})=>{this.walletAccount.setSnapshot(e)}})):(this.#t=e.signer,this.#r=()=>{},c(`refresh wallet account`,async()=>{await this.refreshWalletAccount()}))}requireWalletAccount(e){let t=this.walletAccount.getSnapshot();if(!t&&!this.walletAccount.isReady())throw new m(e);if(!t)throw new o(e);return t}refreshWalletAccount(){return this.#n?this.#c():this.#t?this.#s(this.#t):Promise.resolve(void 0)}onDispose(){this.#r()}async#a(){if(this.#t)return this.#t;if(!this.#e)throw new s(`resolveSigner`);return this.#e.getSigner()}async#o(e){let t=e.provider;if(!t)return;let[n,r]=await Promise.all([e.getAddress(),t.getNetwork()]);return{address:j(n),chainId:Number(r.chainId)}}async signTypedData(e){let t=await this.#a(),{domain:n,types:r,message:i}=e,{EIP712Domain:a,...o}=r,s=Object.fromEntries(Object.entries(o).map(([e,t])=>[e,[...t]])),c=await t.signTypedData(n,s,i);if(!M(c))throw TypeError(`Expected hex string, got: ${c}`);return c}async writeContract(e){let t=await this.#a(),n=new P(e.address,e.abi,t),r={};e.value!==void 0&&(r.value=e.value),e.gas!==void 0&&(r.gasLimit=e.gas);let i=await n.getFunction(e.functionName)(...e.args,r);if(!M(i.hash))throw TypeError(`Expected hex string, got: ${i.hash}`);return i.hash}async#s(e){return this.#i??=this.#o(e).then(e=>(this.walletAccount.setSnapshot(e),e)).finally(()=>{this.#i=void 0}),this.#i}async#c(){let e=await this.#l();return this.walletAccount.setSnapshot(e),e}async#l(){let e=this.#n;if(!e)return;let[t,n]=await Promise.all([e.request({method:`eth_accounts`}),e.request({method:`eth_chainId`})]);if(!Array.isArray(t)||typeof t[0]!=`string`)return;let r=Number(n);if(!(!Number.isSafeInteger(r)||r<=0))return{address:j(t[0]),chainId:r}}};function se(t){if(`signer`in t&&t.signer){let n=new $({signer:t.signer});if(!t.signer.provider)throw Error(`createConfig requires a Signer with an attached provider for chain reads`);let r=new Q({provider:t.signer.provider});return e(n,r,t)}let n=new $({ethereum:t.ethereum}),r=`provider`in t&&t.provider?new Q({provider:t.provider}):new Q({ethereum:t.ethereum});return e(n,r,t)}export{t as BaseSigner,Q as EthersProvider,$ as EthersSigner,ee as ProviderRpcError,i as ZamaSDKEvents,se as createConfig,V as readConfidentialBalanceOfContract,ie as readConfidentialTokenAddressContract,oe as readIsConfidentialTokenValidContract,U as readSupportsInterfaceContract,ae as readTokenAddressContract,re as readTokenPairContract,X as readTokenPairsContract,Z as readTokenPairsLengthContract,ne as readTokenPairsSliceContract,H as readUnderlyingTokenContract,W as writeConfidentialTransferContract,q as writeFinalizeUnwrapContract,J as writeSetOperatorContract,G as writeUnwrapContract,K as writeUnwrapFromBalanceContract,Y as writeWrapContract};
1
+ import{i as e,t}from"../base-signer-D6Xtjbg3.js";import{t as n}from"../relayer-BuZxFm5d.js";import{A as r,B as i,F as a,G as o,H as s,I as c,M as l,N as u,R as d,S as f,T as p,W as m,X as h,d as g,k as _,r as v,y}from"../alignment-CLfJMQqN.js";import{a as b,i as x,n as S,o as C,r as w,s as T,t as E}from"../wrappers-registry-Cm3JJeqx.js";import{t as D}from"../eip1193-subscribe-DxAQh8dY.js";import{ProviderRpcError as ee,createClient as te,custom as O,decodeFunctionResult as k,encodeFunctionData as A,getAddress as j,isHex as M}from"viem";import{BrowserProvider as N,Contract as P,Transaction as F,ethers as I}from"ethers";import{multicall as L}from"viem/actions";function R(e){return{to:e.address,data:A({abi:e.abi,functionName:e.functionName,args:e.args}),...e.gas===void 0?{}:{gasLimit:e.gas},...e.value===void 0?{}:{value:e.value}}}async function z(e,t){let n=await e.call(R(t));if(!M(n))throw TypeError(`Expected hex string, got: ${n}`);return k({abi:t.abi,functionName:t.functionName,data:n})}async function B(e,t){let n=await e.sendTransaction(R(t));if(!M(n.hash))throw TypeError(`Expected hex string, got: ${n.hash}`);return n.hash}function V(e,t,n){return z(e,y(t,n))}function H(e,t){return z(e,r(t))}function U(e,t,n){return z(e,g(t,n))}function W(e,t,n,r,i){return B(e,f(t,n,r,i))}function G(e,t,n,r,i,a){return B(e,l(t,n,r,i,a))}function K(e,t,n,r,i){return B(e,u(t,n,r,i))}function q(e,t,n,r,i){return B(e,p(t,n,r,i))}function J(e,t,n,r){return B(e,_(t,n,r))}function Y(e,t,n,r){return B(e,a(t,n,r))}function X(e,t){return z(e,x(t))}function Z(e,t){return z(e,b(t))}function ne(e,t,n,r){return z(e,C(t,n,r))}function re(e,t,n){return z(e,w(t,n))}function ie(e,t,n){return z(e,E(t,n))}function ae(e,t,n){return z(e,S(t,n))}function oe(e,t,n){return z(e,T(t,n))}var Q=class{#e;#t=te({transport:O({request:async({method:e,params:t})=>{if(e!==`eth_call`)throw Error(`EthersProvider.multicall does not send ${e}`);let[n,r]=t;return this.#e.call({to:n.to,data:n.data,blockTag:r})}})});constructor(e){this.#e=`ethereum`in e?new N(e.ethereum):e.provider}async getChainId(){let e=await this.#e.getNetwork();return Number(e.chainId)}async readContract(e){return await v(`EthersProvider`,e.chainId,()=>this.getChainId()),z(this.#e,{address:e.address,abi:e.abi,functionName:e.functionName,args:e.args})}async multicall(e){await v(`EthersProvider`,e.chainId,()=>this.getChainId());let t=await L(this.#t,{contracts:e.calls.map(({chainId:e,...t})=>t),deployless:!0});return await Promise.all(e.calls.map((e,n)=>{let r=t[n];return r?.status===`success`?r.result:this.readContract({...e,chainId:void 0})}))}async getBlockTimestamp(e){await v(`EthersProvider`,e,()=>this.getChainId());let t=await this.#e.getBlock(`latest`);if(!t)throw new n(`EthersProvider.getBlockTimestamp: failed to fetch latest block`);if(t.timestamp===null)throw new n(`EthersProvider.getBlockTimestamp: latest block has no timestamp`);return BigInt(t.timestamp)}async waitForTransactionReceipt(e){let t=await this.#e.waitForTransaction(e);if(!t)throw new h(`EthersProvider.waitForTransactionReceipt: no receipt found for tx ${e}. The transaction may have been dropped from the mempool, or the RPC's wait timeout elapsed.`);let n=t.status===null?void 0:t.status===1?`success`:`reverted`;return{logs:t.logs.map(e=>({address:e.address,topics:e.topics.filter(e=>e!==null),data:e.data})),...n&&{status:n}}}async prepareTransaction(e){let{from:t,calldata:r}=e,i=new I.Interface(r.abi),a=[];i.forEachFunction(e=>{e.name===r.functionName&&a.push(e)});let o=r.args.length,s=a.length===1?a[0]:a.find(e=>e.inputs.length===o);if(!s)throw Error(`Function ${r.functionName}(${o} args) not found in ABI`);let c=i.encodeFunctionData(s,r.args);d(c,`data`);let l=r.value??0n,u=this.#e.getNetwork(),f=e.nonce===void 0?this.#e.getTransactionCount(t,`pending`):Promise.resolve(e.nonce),p=e.gasLimit===void 0?r.gas??this.#e.estimateGas({from:t,to:r.address,data:c,value:l}).catch(e=>{throw new h(`EthersProvider.prepareTransaction: gas estimation reverted for ${r.functionName} on ${r.address}`,{cause:e})}):Promise.resolve(e.gasLimit),m=e.fees??this.#e.getFeeData(),[g,_,v,y]=await Promise.all([u,f,p,m]),b=y.maxFeePerGas,x=y.maxPriorityFeePerGas;if(b===null||x===null)throw new n(`EthersProvider.prepareTransaction: EIP-1559 fee data unavailable (provider returned null maxFeePerGas). The connected chain may not support EIP-1559 type-2 transactions.`);return F.from({type:2,chainId:Number(g.chainId),nonce:_,to:r.address,data:c,value:l,gasLimit:v,maxFeePerGas:b,maxPriorityFeePerGas:x}).unsignedSerialized}},$=class extends t{#e;#t;#n;#r;#i;constructor(e){super(),`ethereum`in e?(this.#e=new N(e.ethereum),this.#n=e.ethereum,this.#r=D({provider:e.ethereum,getInitialWalletAccount:()=>this.#l(),onWalletAccountChange:({next:e})=>{this.walletAccount.setSnapshot(e)}})):(this.#t=e.signer,this.#r=()=>{},c(`refresh wallet account`,async()=>{await this.refreshWalletAccount()}))}requireWalletAccount(e){let t=this.walletAccount.getSnapshot();if(!t&&!this.walletAccount.isReady())throw new m(e);if(!t)throw new o(e);return t}refreshWalletAccount(){return this.#n?this.#c():this.#t?this.#s(this.#t):Promise.resolve(void 0)}onDispose(){this.#r()}async#a(){if(this.#t)return this.#t;if(!this.#e)throw new s(`resolveSigner`);return this.#e.getSigner()}async#o(e){let t=e.provider;if(!t)return;let[n,r]=await Promise.all([e.getAddress(),t.getNetwork()]);return{address:j(n),chainId:Number(r.chainId)}}async signTypedData(e){let t=await this.#a(),{domain:n,types:r,message:i}=e,{EIP712Domain:a,...o}=r,s=Object.fromEntries(Object.entries(o).map(([e,t])=>[e,[...t]])),c=await t.signTypedData(n,s,i);if(!M(c))throw TypeError(`Expected hex string, got: ${c}`);return c}async writeContract(e){let t=await this.#a(),n=new P(e.address,e.abi,t),r={};e.value!==void 0&&(r.value=e.value),e.gas!==void 0&&(r.gasLimit=e.gas);let i=await n.getFunction(e.functionName)(...e.args,r);if(!M(i.hash))throw TypeError(`Expected hex string, got: ${i.hash}`);return i.hash}async#s(e){return this.#i??=this.#o(e).then(e=>(this.walletAccount.setSnapshot(e),e)).finally(()=>{this.#i=void 0}),this.#i}async#c(){let e=await this.#l();return this.walletAccount.setSnapshot(e),e}async#l(){let e=this.#n;if(!e)return;let[t,n]=await Promise.all([e.request({method:`eth_accounts`}),e.request({method:`eth_chainId`})]);if(!Array.isArray(t)||typeof t[0]!=`string`)return;let r=Number(n);if(!(!Number.isSafeInteger(r)||r<=0))return{address:j(t[0]),chainId:r}}};function se(t){if(`signer`in t&&t.signer){let n=new $({signer:t.signer});if(!t.signer.provider)throw Error(`createConfig requires a Signer with an attached provider for chain reads`);let r=new Q({provider:t.signer.provider});return e(n,r,t)}let n=new $({ethereum:t.ethereum}),r=`provider`in t&&t.provider?new Q({provider:t.provider}):new Q({ethereum:t.ethereum});return e(n,r,t)}export{t as BaseSigner,Q as EthersProvider,$ as EthersSigner,ee as ProviderRpcError,i as ZamaSDKEvents,se as createConfig,V as readConfidentialBalanceOfContract,ie as readConfidentialTokenAddressContract,oe as readIsConfidentialTokenValidContract,U as readSupportsInterfaceContract,ae as readTokenAddressContract,re as readTokenPairContract,X as readTokenPairsContract,Z as readTokenPairsLengthContract,ne as readTokenPairsSliceContract,H as readUnderlyingTokenContract,W as writeConfidentialTransferContract,q as writeFinalizeUnwrapContract,J as writeSetOperatorContract,G as writeUnwrapContract,K as writeUnwrapFromBalanceContract,Y as writeWrapContract};
2
2
  //# sourceMappingURL=index.js.map
@@ -1,2 +1,2 @@
1
- import{i as e,r as t,t as n}from"./relayer-nWfQAlo7.js";import{a as r,l as i,n as a,t as o}from"./signing-CVEOw21I.js";var s=class extends t{retryAfter;constructor(t,n){let{retryAfter:r,...i}=n??{};super(e.RpcRateLimited,t,i),this.name=`RpcRateLimitError`,this.retryAfter=r}};const c={[e.SigningRejected]:a,[e.SigningFailed]:o,[e.Configuration]:n,[e.RpcRateLimited]:s,[e.KeyWrappingFailed]:r,[e.RevokedKmsContext]:i};function l(e){return Object.values(c).some(t=>e instanceof t)}export{l as n,s as r,c as t};
2
- //# sourceMappingURL=fatal-batch-BYeHrf0V.js.map
1
+ import{i as e,r as t,t as n}from"./relayer-BuZxFm5d.js";import{a as r,l as i,n as a,t as o}from"./signing-CJBcqlEl.js";var s=class extends t{retryAfter;constructor(t,n){let{retryAfter:r,...i}=n??{};super(e.RpcRateLimited,t,i),this.name=`RpcRateLimitError`,this.retryAfter=r}};const c={[e.SigningRejected]:a,[e.SigningFailed]:o,[e.Configuration]:n,[e.RpcRateLimited]:s,[e.KeyWrappingFailed]:r,[e.RevokedKmsContext]:i};function l(e){return Object.values(c).some(t=>e instanceof t)}export{l as n,s as r,c as t};
2
+ //# sourceMappingURL=fatal-batch-CWhfEMv9.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"fatal-batch-BYeHrf0V.js","names":["ZamaErrorCode","ZamaError","ConfigurationError","KeyWrappingError","RevokedKmsContextError","SigningRejectedError","SigningFailedError","RpcRateLimitError","errorOptions","options","message","retryAfter","fatalBatchErrors","isFatalBatchError","error","Constructor"],"sources":["../../src/errors/rpc.ts","../../src/errors/fatal-batch.ts"],"sourcesContent":["import { ZamaError, ZamaErrorCode } from \"./base\";\n\n/**\n * The consumer's RPC provider rate-limited an on-chain read the SDK performs\n * during decryption (e.g. the ACL check) — HTTP 429 or JSON-RPC `-32005`. An\n * RPC-endpoint problem, **not** a decryption/entitlement failure, and safe to\n * **retry**. Kept distinct from the relayer's own back-pressure\n * ({@link RelayerRequestFailedError}).\n *\n * Backoff for chain RPC is owned by the consumer's transport: viem/ethers\n * already honor the `Retry-After` header and retry internally before this error\n * surfaces, so it is configured on the transport you pass via `chain.network`\n * (not re-implemented here).\n *\n * @example\n * ```ts\n * try {\n * await sdk.decryption.decryptValues([{ encryptedValue, contractAddress }]);\n * } catch (e) {\n * if (e instanceof RpcRateLimitError) {\n * // back off and retry; consider a higher-throughput RPC endpoint\n * }\n * }\n * ```\n */\nexport class RpcRateLimitError extends ZamaError {\n /**\n * Suggested delay before retrying, in **seconds**, when a numeric `retryAfter`\n * is present on the error. Usually `undefined` for chain RPC: the `Retry-After`\n * header is consumed by the consumer's viem/ethers transport (which owns the\n * backoff), not surfaced here — see the class doc.\n */\n readonly retryAfter: number | undefined;\n\n constructor(message: string, options?: ErrorOptions & { retryAfter?: number }) {\n const { retryAfter, ...errorOptions } = options ?? {};\n super(ZamaErrorCode.RpcRateLimited, message, errorOptions);\n this.name = \"RpcRateLimitError\";\n this.retryAfter = retryAfter;\n }\n}\n","import { ZamaErrorCode, type ZamaError } from \"./base\";\nimport { KeyWrappingError, RevokedKmsContextError } from \"./credential\";\nimport { ConfigurationError } from \"./relayer\";\nimport { RpcRateLimitError } from \"./rpc\";\nimport { SigningRejectedError, SigningFailedError } from \"./signing\";\n\nexport const fatalBatchErrors = {\n [ZamaErrorCode.SigningRejected]: SigningRejectedError,\n [ZamaErrorCode.SigningFailed]: SigningFailedError,\n [ZamaErrorCode.Configuration]: ConfigurationError,\n [ZamaErrorCode.RpcRateLimited]: RpcRateLimitError,\n [ZamaErrorCode.KeyWrappingFailed]: KeyWrappingError,\n [ZamaErrorCode.RevokedKmsContext]: RevokedKmsContextError,\n} satisfies Partial<Record<ZamaErrorCode, new (message: string) => ZamaError>>;\n\n/** Systemic failures abort a batch because retrying each item would repeat the same failure. */\nexport function isFatalBatchError(error: unknown): boolean {\n return Object.values(fatalBatchErrors).some((Constructor) => error instanceof Constructor);\n}\n"],"mappings":"A,uHAyBA,IAAaO,EAAb,cAAuCN,CAAU,CAO/C,WAEA,YAAY,EAAiB,EAAkD,CAC7E,GAAM,CAAE,aAAY,GAAGO,GAAiBC,GAAW,CAAC,EACpD,MAAMT,EAAc,eAAgBU,EAASF,CAAY,EACzD,KAAK,KAAO,oBACZ,KAAK,WAAaG,CACpB,CACF,EClCA,MAAaC,EAAmB,EAC7BZ,EAAc,iBAAkBK,GAChCL,EAAc,eAAgBM,GAC9BN,EAAc,eAAgBE,GAC9BF,EAAc,gBAAiBO,GAC/BP,EAAc,mBAAoBG,GAClCH,EAAc,mBAAoBI,CACrC,EAGA,SAAgBS,EAAkB,EAAyB,CACzD,OAAO,OAAO,OAAOD,CAAgB,CAAC,CAAC,KAAM,GAAgBE,aAAiBC,CAAW,CAC3F,C"}
1
+ {"version":3,"file":"fatal-batch-CWhfEMv9.js","names":["ZamaErrorCode","ZamaError","ConfigurationError","KeyWrappingError","RevokedKmsContextError","SigningRejectedError","SigningFailedError","RpcRateLimitError","errorOptions","options","message","retryAfter","fatalBatchErrors","isFatalBatchError","error","Constructor"],"sources":["../../src/errors/rpc.ts","../../src/errors/fatal-batch.ts"],"sourcesContent":["import { ZamaError, ZamaErrorCode } from \"./base\";\n\n/**\n * The consumer's RPC provider rate-limited an on-chain read the SDK performs\n * during decryption (e.g. the ACL check) — HTTP 429 or JSON-RPC `-32005`. An\n * RPC-endpoint problem, **not** a decryption/entitlement failure, and safe to\n * **retry**. Kept distinct from the relayer's own back-pressure\n * ({@link RelayerRequestFailedError}).\n *\n * Backoff for chain RPC is owned by the consumer's transport: viem/ethers\n * already honor the `Retry-After` header and retry internally before this error\n * surfaces, so it is configured on the transport you pass via `chain.network`\n * (not re-implemented here).\n *\n * @example\n * ```ts\n * try {\n * await sdk.decryption.decryptValues([{ encryptedValue, contractAddress }]);\n * } catch (e) {\n * if (e instanceof RpcRateLimitError) {\n * // back off and retry; consider a higher-throughput RPC endpoint\n * }\n * }\n * ```\n */\nexport class RpcRateLimitError extends ZamaError {\n /**\n * Suggested delay before retrying, in **seconds**, when a numeric `retryAfter`\n * is present on the error. Usually `undefined` for chain RPC: the `Retry-After`\n * header is consumed by the consumer's viem/ethers transport (which owns the\n * backoff), not surfaced here — see the class doc.\n */\n readonly retryAfter: number | undefined;\n\n constructor(message: string, options?: ErrorOptions & { retryAfter?: number }) {\n const { retryAfter, ...errorOptions } = options ?? {};\n super(ZamaErrorCode.RpcRateLimited, message, errorOptions);\n this.name = \"RpcRateLimitError\";\n this.retryAfter = retryAfter;\n }\n}\n","import { ZamaErrorCode, type ZamaError } from \"./base\";\nimport { KeyWrappingError, RevokedKmsContextError } from \"./credential\";\nimport { ConfigurationError } from \"./relayer\";\nimport { RpcRateLimitError } from \"./rpc\";\nimport { SigningRejectedError, SigningFailedError } from \"./signing\";\n\nexport const fatalBatchErrors = {\n [ZamaErrorCode.SigningRejected]: SigningRejectedError,\n [ZamaErrorCode.SigningFailed]: SigningFailedError,\n [ZamaErrorCode.Configuration]: ConfigurationError,\n [ZamaErrorCode.RpcRateLimited]: RpcRateLimitError,\n [ZamaErrorCode.KeyWrappingFailed]: KeyWrappingError,\n [ZamaErrorCode.RevokedKmsContext]: RevokedKmsContextError,\n} satisfies Partial<Record<ZamaErrorCode, new (message: string) => ZamaError>>;\n\n/** Systemic failures abort a batch because retrying each item would repeat the same failure. */\nexport function isFatalBatchError(error: unknown): boolean {\n return Object.values(fatalBatchErrors).some((Constructor) => error instanceof Constructor);\n}\n"],"mappings":"A,uHAyBA,IAAaO,EAAb,cAAuCN,CAAU,CAO/C,WAEA,YAAY,EAAiB,EAAkD,CAC7E,GAAM,CAAE,aAAY,GAAGO,GAAiBC,GAAW,CAAC,EACpD,MAAMT,EAAc,eAAgBU,EAASF,CAAY,EACzD,KAAK,KAAO,oBACZ,KAAK,WAAaG,CACpB,CACF,EClCA,MAAaC,EAAmB,EAC7BZ,EAAc,iBAAkBK,GAChCL,EAAc,eAAgBM,GAC9BN,EAAc,eAAgBE,GAC9BF,EAAc,gBAAiBO,GAC/BP,EAAc,mBAAoBG,GAClCH,EAAc,mBAAoBI,CACrC,EAGA,SAAgBS,EAAkB,EAAyB,CACzD,OAAO,OAAO,OAAOD,CAAgB,CAAC,CAAC,KAAM,GAAgBE,aAAiBC,CAAW,CAC3F,C"}
@@ -1,8 +1,8 @@
1
- import{S as e,b as t,t as n}from"./relayer-nWfQAlo7.js";import{a as r,i,n as a}from"./telemetry-DZs0eTBf.js";import{n as o}from"./encryption-BT886Jlj.js";import{createPublicClient as s,custom as c,http as l}from"viem";import{createUnsignedLegacyDecryptionPermitEip712 as u}from"@fhevm/sdk/actions/base";import{createFhevmBaseClient as ee,createFhevmDecryptClient as te,createFhevmEncryptClient as d,hasFhevmRuntimeConfig as f}from"@fhevm/sdk/viem";import{createFhevmCleartextBaseClient as ne,createFhevmCleartextDecryptClient as re,createFhevmCleartextEncryptClient as p}from"@fhevm/sdk/viem/cleartext";function m(e){return{id:e.id,fhevm:{contracts:{acl:{address:e.aclContractAddress},inputVerifier:{address:e.inputVerifierContractAddress},kmsVerifier:{address:e.kmsContractAddress},protocolConfig:void 0},relayerUrl:e.relayerUrl,gateway:{id:e.gatewayChainId,contracts:{decryption:{address:e.verifyingContractAddressDecryption},inputVerification:{address:e.verifyingContractAddressInputVerification}}}}}}
1
+ import{S as e,b as t,t as n}from"./relayer-BuZxFm5d.js";import{a as r,i,n as a}from"./telemetry-DDxj4jDq.js";import{n as o}from"./encryption-B-uikunQ.js";import{createPublicClient as s,custom as c,http as l}from"viem";import{createUnsignedLegacyDecryptionPermitEip712 as u}from"@fhevm/sdk/actions/base";import{createFhevmBaseClient as ee,createFhevmDecryptClient as te,createFhevmEncryptClient as d,hasFhevmRuntimeConfig as f}from"@fhevm/sdk/viem";import{createFhevmCleartextBaseClient as ne,createFhevmCleartextDecryptClient as re,createFhevmCleartextEncryptClient as p}from"@fhevm/sdk/viem/cleartext";function m(e){return{id:e.id,fhevm:{contracts:{acl:{address:e.aclContractAddress},inputVerifier:{address:e.inputVerifierContractAddress},kmsVerifier:{address:e.kmsContractAddress},protocolConfig:void 0},relayerUrl:e.relayerUrl,gateway:{id:e.gatewayChainId,contracts:{decryption:{address:e.verifyingContractAddressDecryption},inputVerification:{address:e.verifyingContractAddressInputVerification}}}}}}
2
2
  /**
3
3
  * @license
4
4
  * Copyright 2019 Google LLC
5
5
  * SPDX-License-Identifier: Apache-2.0
6
6
  */
7
7
  const h=Symbol(`Comlink.proxy`),g=Symbol(`Comlink.endpoint`),ie=Symbol(`Comlink.releaseProxy`),_=Symbol(`Comlink.finalizer`),v=Symbol(`Comlink.thrown`),y=e=>typeof e==`object`&&!!e||typeof e==`function`,b=/* @__PURE__ */ new Map([[`proxy`,{canHandle:e=>y(e)&&e[h],serialize(e){let{port1:t,port2:n}=new MessageChannel;return S(e,t),[n,[n]]},deserialize(e){return e.start(),w(e)}}],[`throw`,{canHandle:e=>y(e)&&v in e,serialize({value:e}){let t;return t=e instanceof Error?{isError:!0,value:{message:e.message,name:e.name,stack:e.stack}}:{isError:!1,value:e},[t,[]]},deserialize(e){throw e.isError?Object.assign(Error(e.value.message),e.value):e.value}}]]);function x(e,t){for(let n of e)if(t===n||n===`*`||n instanceof RegExp&&n.test(t))return!0;return!1}function S(e,t=globalThis,n=[`*`]){t.addEventListener(`message`,function r(i){if(!i||!i.data)return;if(!x(n,i.origin)){console.warn(`Invalid origin '${i.origin}' for comlink proxy`);return}let{id:a,type:o,path:s}=Object.assign({path:[]},i.data),c=(i.data.argumentList||[]).map(L),l;try{let t=s.slice(0,-1).reduce((e,t)=>e[t],e),n=s.reduce((e,t)=>e[t],e);switch(o){case`GET`:l=n;break;case`SET`:t[s.slice(-1)[0]]=L(i.data.value),l=!0;break;case`APPLY`:l=n.apply(t,c);break;case`CONSTRUCT`:l=F(new n(...c));break;case`ENDPOINT`:{let{port1:t,port2:n}=new MessageChannel;S(e,n),l=P(t,[t])}break;case`RELEASE`:l=void 0;break;default:return}}catch(e){l={value:e,[v]:0}}Promise.resolve(l).catch(e=>({value:e,[v]:0})).then(n=>{let[i,s]=I(n);t.postMessage(Object.assign(Object.assign({},i),{id:a}),s),o===`RELEASE`&&(t.removeEventListener(`message`,r),C(t),_ in e&&typeof e[_]==`function`&&e[_]())}).catch(e=>{let[n,r]=I({value:/* @__PURE__ */ TypeError(`Unserializable return value`),[v]:0});t.postMessage(Object.assign(Object.assign({},n),{id:a}),r)})}),t.start&&t.start()}function ae(e){return e.constructor.name===`MessagePort`}function C(e){ae(e)&&e.close()}function w(e,t){let n=/* @__PURE__ */ new Map;return e.addEventListener(`message`,function(e){let{data:t}=e;if(!t||!t.id)return;let r=n.get(t.id);if(r)try{r(t)}finally{n.delete(t.id)}}),j(e,n,[],t)}function T(e){if(e)throw Error(`Proxy has been released and is not useable`)}function E(e){return R(e,/* @__PURE__ */ new Map,{type:`RELEASE`}).then(()=>{C(e)})}const D=/* @__PURE__ */ new WeakMap,O=`FinalizationRegistry`in globalThis&&new FinalizationRegistry(e=>{let t=(D.get(e)||0)-1;D.set(e,t),t===0&&E(e)});function k(e,t){let n=(D.get(t)||0)+1;D.set(t,n),O&&O.register(e,t,e)}function A(e){O&&O.unregister(e)}function j(e,t,n=[],r=function(){}){let i=!1,a=new Proxy(r,{get(r,o){if(T(i),o===ie)return()=>{A(a),E(e),t.clear(),i=!0};if(o===`then`){if(n.length===0)return{then:()=>a};let r=R(e,t,{type:`GET`,path:n.map(e=>e.toString())}).then(L);return r.then.bind(r)}return j(e,t,[...n,o])},set(r,a,o){T(i);let[s,c]=I(o);return R(e,t,{type:`SET`,path:[...n,a].map(e=>e.toString()),value:s},c).then(L)},apply(r,a,o){T(i);let s=n[n.length-1];if(s===g)return R(e,t,{type:`ENDPOINT`}).then(L);if(s===`bind`)return j(e,t,n.slice(0,-1));let[c,l]=M(o);return R(e,t,{type:`APPLY`,path:n.map(e=>e.toString()),argumentList:c},l).then(L)},construct(r,a){T(i);let[o,s]=M(a);return R(e,t,{type:`CONSTRUCT`,path:n.map(e=>e.toString()),argumentList:o},s).then(L)}});return k(a,e),a}function oe(e){return Array.prototype.concat.apply([],e)}function M(e){let t=e.map(I);return[t.map(e=>e[0]),oe(t.map(e=>e[1]))]}const N=/* @__PURE__ */ new WeakMap;function P(e,t){return N.set(e,t),e}function F(e){return Object.assign(e,{[h]:!0})}function I(e){for(let[t,n]of b)if(n.canHandle(e)){let[r,i]=n.serialize(e);return[{type:`HANDLER`,name:t,value:r},i]}return[{type:`RAW`,value:e},N.get(e)||[]]}function L(e){switch(e.type){case`HANDLER`:return b.get(e.name).deserialize(e.value);case`RAW`:return e.value}}function R(e,t,n,r){return new Promise(i=>{let a=z();t.set(a,i),e.start&&e.start(),e.postMessage(Object.assign({id:a},n),r)})}function z(){return[,,,,].fill(0).map(()=>Math.floor(Math.random()*(2**53-1)).toString(16)).join(`-`)}function B(e){return typeof e==`object`&&!!e&&e.wireError===!0}const V=[`statusCode`,`status`,`retryAfter`,`timeoutMs`,`relayerApiError`,`code`,`data`,`shortMessage`,`details`,`error`,`info`];function H(e){try{return structuredClone(e),!0}catch{return!1}}function U(t){let n=t.response;return e(n?.headers)}function W(e){try{return JSON.stringify(e)??String(e)}catch{return String(e)}}function G(e){let n={};for(let t of V){let r=e[t];r!==void 0&&H(r)&&(n[t]=r)}if(!t(n.retryAfter)){let t=U(e);t!==void 0&&(n.retryAfter=t)}return n}function K(e,t=6){if(B(e))return e;let n=e=>t>0&&e!==void 0?K(e,t-1):void 0;if(e instanceof Error)return{wireError:!0,name:e.name,message:e.message,stack:e.stack,props:G(e),cause:n(e.cause)};if(typeof e==`object`&&e){let{message:t,cause:r}=e;return{wireError:!0,name:`Error`,message:typeof t==`string`?t:W(e),stack:void 0,props:G(e),cause:n(r)}}return{wireError:!0,name:`Error`,message:typeof e==`string`?e:W(e),stack:void 0,props:{},cause:void 0}}function q(e){let t=Error(e.message,e.cause?{cause:q(e.cause)}:{});return t.name=e.name,e.stack!==void 0&&(t.stack=e.stack),Object.assign(t,e.props),t}function se(){return new Worker(new URL(`./encrypt.worker.js`,import.meta.url),{type:`module`,name:`zama-fhe-encrypt`})}const J={spawn:1e4,init:3e5},Y=/* @__PURE__ */ new WeakSet;var X=class extends Error{crashed;constructor(e,t){super(e,t),this.name=`WorkerUnavailableError`,this.crashed=t?.crashed??!1}};function ce(e){if(typeof e!=`object`||!e)return!1;let{name:t,message:n}=e;return t===`DataCloneError`||t===`TypeError`&&typeof n==`string`&&n.includes(`Unserializable return value`)}function Z(e){if(e?.aborted)throw e.reason??new DOMException(`The operation was aborted.`,`AbortError`)}const Q={count:0,last:void 0,warnedFor:-1};function le(e){if(e===void 0)return{key:e,transfers:[]};let t=e.publicKeyBytes.bytes,n=e.crsBytes.bytes;if(!(t instanceof Uint8Array)||!(n instanceof Uint8Array))return{key:e,transfers:[]};let r=t.slice(),i=n.slice();return{key:{...e,publicKeyBytes:{...e.publicKeyBytes,bytes:r},crsBytes:{...e.crsBytes,bytes:i}},transfers:[r.buffer,i.buffer]}}function ue(){let e,t=new Promise((t,n)=>{e=n});return t.catch(()=>{}),{initPromise:void 0,worker:void 0,api:void 0,doomed:t,doom:e}}var de=class{#e;#t;#n=!1;#r=Q;#i=0;#a=/* @__PURE__ */ new Map;#o;#s=0;#c=!1;constructor(e){this.#e=e}init=()=>{let e=this.#t??=ue();if(e.initPromise===void 0){let t=this.#f(()=>this.#u(e)).catch(n=>{throw e.initPromise===t&&(e.initPromise=void 0),n});e.initPromise=t}return e.initPromise};encryptValue=e=>this.#f(()=>this.#l(t=>t.encryptValue(e),(t,n,r)=>t.encryptValue(n,{...e,options:r}),e.options));encryptValues=e=>this.#f(()=>this.#l(t=>t.encryptValues(e),(t,n,r)=>t.encryptValues(n,{...e,options:r}),e.options));dispose(){this.#c=!0,this.#p()}async#l(e,t,n){let{signal:r,onProgress:i,...a}=n??{};Z(r),await this.init(),Z(r);let o=this.#t,s=o?.api;if(this.#o!==void 0&&(this.#n||s===void 0))return e(await this.#o);if(o===void 0||s===void 0)return e(await this.#b(o,this.#r.last??new X(`Encrypt worker not running.`)));let c=this.#i++,l=()=>void s.abort(c).catch(()=>{});r?.addEventListener(`abort`,l,{once:!0}),i&&this.#a.set(c,i);try{let e=await this.#v(o,t(s,c,a));return this.#r=Q,e}catch(t){if(t instanceof X)return e(await this.#b(o,t));throw t}finally{this.#a.delete(c),r?.removeEventListener(`abort`,l)}}async#u(e){if(this.#n)return;let t=this.#e.blockedReason;if(t!==void 0){await this.#b(e,new X(t));return}let n=await this.#e.prefetchKey();try{let t=await this.#h(e),r=this.#e.network,i=typeof r==`string`?null:F(async e=>{try{return await r.request(e)}catch(e){throw K(e)}}),a=F((e,t)=>{try{this.#e.logger[e](t)}catch(e){this.#d(`logger`,e)}}),o=F((e,t)=>{try{this.#a.get(e)?.(t)}catch(e){this.#d(`onProgress`,e)}}),s=le(n);await this.#v(e,t.init(P({...this.#e.initPayload,clientOptions:{...this.#e.initPayload.clientOptions,fheEncryptionKey:s.key},rpcUrl:typeof r==`string`?r:void 0},s.transfers),i,a,o),{ms:this.#e.timeouts.init,operation:`init`}),e.api=t,this.#r={...this.#r,last:void 0}}catch(t){if(!(t instanceof X))throw this.#y(e,new X(`Encrypt worker init failed.`)),t;await this.#b(e,t)}}#d(e,t){let n=t instanceof Error?t.message:String(t);try{this.#e.logger.warn(`Encrypt offload ${e} callback threw: ${n}`)}catch{}}async#f(e){this.#s++;try{return await e()}finally{this.#s--,this.#p()}}#p(){!this.#c||this.#s>0||(this.#c=!1,this.#t?.worker?.terminate(),this.#t=void 0,this.#o=void 0,this.#n=!1,this.#r=Q)}#m(){let e=this.#e.workerSource;if(e===void 0)return se();if(typeof e==`function`){let t=e();return Y.has(t)&&this.#e.logger.warnAlways(`The offloadWorker factory returned a worker it already handed out; each call must construct a fresh Worker.`),Y.add(t),t}return new Worker(e,{type:`module`,name:`zama-fhe-encrypt`})}async#h(e){let t;try{t=this.#m()}catch(e){throw new X(e instanceof Error?e.message:String(e),{cause:e})}e.worker=t;let n=await this.#g(e,t);return this.#_(e,t),n}#g(e,t){return new Promise((n,r)=>{let i=()=>{clearTimeout(a),t.removeEventListener(`message`,o),t.removeEventListener(`error`,s)},a=setTimeout(()=>{i(),r(new X(`Encrypt worker did not start within ${this.#e.timeouts.spawn}ms.`))},this.#e.timeouts.spawn),o=e=>{e.data===`zama-encrypt-worker-ready`&&(i(),n(w(t)))},s=t=>{i();let n=t.message||`Encrypt worker error.`;r(new X(n)),this.#y(e,new X(n))};t.addEventListener(`message`,o),t.addEventListener(`error`,s)})}#_(e,t){t.addEventListener(`error`,t=>{if(this.#t!==e)return;let n=new X(t.message||`Encrypt worker error.`,{crashed:!0});this.#r={...this.#r,count:this.#r.count+1,last:n},this.#y(e,n)})}async#v(e,t,n){let r=n===void 0?void 0:setTimeout(()=>{this.#y(e,new X(`Encrypt worker ${n.operation} timed out after ${n.ms}ms.`))},n.ms);try{return await Promise.race([t.catch(e=>{let t=B(e)?q(e):e;throw ce(t)?new X(t.message,{cause:t}):t}),e.doomed])}finally{r!==void 0&&clearTimeout(r)}}#y(e,t){e!==void 0&&(this.#t===e&&(this.#t=void 0),e.worker?.terminate(),e.worker=void 0,e.api=void 0,e.initPromise=void 0,e.doom(t))}async#b(e,t){let n=t instanceof Error?t.message:String(t);if(this.#e.strict)throw this.#y(e,new X(`Encrypt worker unavailable.`)),new o(`Encrypt offload required (offloadEncrypt: true) but unavailable: ${n}`,{cause:t});let{transient:r,pinning:i}=this.#x(t);if(this.#n||=!r,this.#y(e,new X(`Encrypt worker degraded to inline.`)),this.#S(n,r,i),this.#o===void 0){let e=(async()=>{let e=this.#e.createInlineClient();return await e.init(),e})().catch(t=>{throw this.#o===e&&(this.#o=void 0),this.#e.logger.warnAlways(`Encrypt inline fallback failed to initialize: ${t instanceof Error?t.message:String(t)}`),t});this.#o=e}return this.#o}#x(e){let t=e instanceof X&&e.crashed&&this.#r.count<2;return{transient:t,pinning:!t&&!this.#n}}#S(e,t,n){if(!n&&this.#r.warnedFor===this.#r.count)return;this.#r={...this.#r,warnedFor:this.#r.count};let r=t?`in-flight encryption falls back`:`encryption falls back`;this.#e.logger.warnAlways(`Encrypt offload unavailable, ${r} to the calling thread: ${e}`)}},fe=class{#e;#t;#n;#r;#i;#a;#o;constructor(e){this.#e=e.chain;let{timeout:t,debug:n,batchRpcCalls:r,moduleVersions:i,fheEncryptionKey:a}=e.options??{},o=this.#e.auth?$(this.#e.auth):void 0,u=typeof this.#e.network==`string`?l(this.#e.network):c(this.#e.network),f={publicClient:s({transport:u}),chain:m(this.#e),options:{batchRpcCalls:r,moduleVersions:i,fheEncryptionKey:a}};this.#i={...o!==void 0&&{auth:o},...t!==void 0&&{timeout:t},...n!==void 0&&{debug:n}},this.#a=e.telemetry;let h=()=>this.#t.fetchFheEncryptionKeyBytes({options:this.#c(void 0)}),g=e=>({init:async()=>{await h(),await e.init()},encryptValue:t=>e.encryptValue(t),encryptValues:t=>e.encryptValues(t),fetchFheEncryptionKeyBytes:t=>e.fetchFheEncryptionKeyBytes(t)});e.cleartext?(this.#t=ne(f),this.#n=re(f),this.#r=g(p(f))):(this.#t=ee(f),this.#n=te(f),this.#r=this.#s(e,f,{prefetchKey:h,createInlineClient:()=>g(d(f))}))}#s(e,t,n){let r=e.offloadEncrypt??!1,a=r===!0,o=typeof Worker==`function`&&(e.offloadWorker!==void 0||!0);if(r===!1||!(a||o))return n.createInlineClient();let s=i(),c=me(s);if(c!==void 0&&!a)return e.logger.warnAlways(`Encryption runs on the calling thread: ${c}.`),n.createInlineClient();let l=new de({initPayload:{chain:t.chain,clientOptions:t.options,runtime:s??{}},network:this.#e.network,prefetchKey:n.prefetchKey,createInlineClient:n.createInlineClient,logger:e.logger,timeouts:e.offloadTimeouts??J,workerSource:e.offloadWorker,blockedReason:c,strict:a});return{init:()=>l.init(),encryptValue:e=>l.encryptValue(e),encryptValues:e=>l.encryptValues(e),fetchFheEncryptionKeyBytes:e=>this.#t.fetchFheEncryptionKeyBytes(e),dispose:()=>l.dispose()}}get chain(){return this.#e}#c(e){let{operation:t,...n}={...this.#i,...e};if(this.#a===void 0)return n;let{headers:r,query:i}=a(this.#a,t);return{...n,...r&&{headers:{...n.headers,...r}},...i&&{query:{...n.query,...i}}}}#l=()=>(this.#o??=this.#r.init().catch(e=>{throw this.#o=void 0,e}),this.#o);dispose=()=>{this.#o=void 0,this.#r.dispose?.()};decryptPublicValue=async e=>(await this.#t.init(),this.#t.decryptPublicValue({...e,options:this.#c(e.options)}));decryptPublicValues=async e=>(await this.#t.init(),this.#t.decryptPublicValues({...e,options:this.#c(e.options)}));decryptPublicValuesWithSignatures=async e=>(await this.#t.init(),this.#t.decryptPublicValuesWithSignatures({...e,options:this.#c(e.options)}));encryptValue=async e=>(await this.#l(),this.#r.encryptValue({...e,options:this.#c(e.options)}));encryptValues=async e=>(await this.#l(),this.#r.encryptValues({...e,options:this.#c(e.options)}));decryptValue=async e=>(await this.#n.init(),this.#n.decryptValue({...e,options:this.#c(e.options)}));decryptValues=async e=>(await this.#n.init(),this.#n.decryptValues({...e,options:this.#c(e.options)}));decryptValuesFromPairs=async e=>(await this.#n.init(),this.#n.decryptValuesFromPairs({...e,options:this.#c(e.options)}));fetchFheEncryptionKeyBytes=async e=>(await this.#t.init(),this.#t.fetchFheEncryptionKeyBytes({...e,options:this.#c(e?.options)}));signDecryptionPermit=async e=>(await this.#t.init(),this.#t.signDecryptionPermit(e));createUnsignedLegacyDecryptionPermitEip712=e=>u(this.#t,e);serializeTransportKeyPair=e=>this.#n.serializeTransportKeyPair(e);serializeSignedDecryptionPermit=e=>this.#t.serializeSignedDecryptionPermit(e);parseTransportKeyPair=async e=>(await this.#n.init(),this.#n.parseTransportKeyPair(e));parseSignedDecryptionPermit=async e=>{await this.#t.init();let{serializedPermit:t}=e;return this.#t.parseSignedDecryptionPermit({...e,serializedPermit:{...t,signature:pe(t.signature)}})};generateTransportKeyPair=async()=>(await this.#n.init(),this.#n.generateTransportKeyPair())};function pe(e){if(e.length!==132)return e;let t=parseInt(e.slice(130),16);return t!==0&&t!==1?e:`${e.slice(0,130)}${t===0?`1b`:`1c`}`}function me(e){if(r())return`a runtime locateFile cannot cross the encrypt worker boundary`;if(e===void 0&&f())return`a runtime config set outside createConfig cannot be replicated in the encrypt worker realm`}function $(e){let t=e.__type;switch(t){case`ApiKeyHeader`:return{type:t,value:e.value,header:e.header};case`BearerToken`:return{type:t,token:e.token};default:throw new n(`Unknown auth type: ${String(t)}`)}}export{$ as n,J as r,fe as t};
8
- //# sourceMappingURL=fhevm-relayer-Da6yGHJQ.js.map
8
+ //# sourceMappingURL=fhevm-relayer-D_T116vA.js.map