@zama-fhe/sdk 3.8.0-beta.8 → 3.8.0

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 (153) hide show
  1. package/dist/cjs/alignment.cjs +2 -0
  2. package/dist/cjs/alignment.cjs.map +1 -0
  3. package/dist/cjs/base-signer.cjs +1 -1
  4. package/dist/cjs/base-signer.cjs.map +1 -1
  5. package/dist/cjs/chains.cjs +1 -1
  6. package/dist/cjs/chains.cjs.map +1 -1
  7. package/dist/cjs/cleartext.cjs +1 -1
  8. package/dist/cjs/cleartext.cjs.map +1 -1
  9. package/dist/cjs/eip1193-subscribe.cjs +1 -1
  10. package/dist/cjs/eip1193-subscribe.cjs.map +1 -1
  11. package/dist/cjs/encryption.cjs.map +1 -1
  12. package/dist/cjs/ethers/index.cjs +1 -1
  13. package/dist/cjs/ethers/index.cjs.map +1 -1
  14. package/dist/cjs/fatal-batch.cjs.map +1 -1
  15. package/dist/cjs/fhevm-relayer.cjs +2 -2
  16. package/dist/cjs/fhevm-relayer.cjs.map +1 -1
  17. package/dist/cjs/index.cjs +1 -1
  18. package/dist/cjs/index.cjs.map +1 -1
  19. package/dist/cjs/internal/index.cjs +1 -1
  20. package/dist/cjs/internal/index.cjs.map +1 -1
  21. package/dist/cjs/log-decoding.cjs +2 -0
  22. package/dist/cjs/log-decoding.cjs.map +1 -0
  23. package/dist/cjs/node/index.cjs +1 -1
  24. package/dist/cjs/node/index.cjs.map +1 -1
  25. package/dist/cjs/query/index.cjs +1 -1
  26. package/dist/cjs/query/index.cjs.map +1 -1
  27. package/dist/cjs/query-keys.cjs +2 -0
  28. package/dist/cjs/query-keys.cjs.map +1 -0
  29. package/dist/cjs/relayer.cjs +1 -1
  30. package/dist/cjs/relayer.cjs.map +1 -1
  31. package/dist/cjs/signing.cjs +1 -1
  32. package/dist/cjs/signing.cjs.map +1 -1
  33. package/dist/cjs/telemetry.cjs +1 -1
  34. package/dist/cjs/telemetry.cjs.map +1 -1
  35. package/dist/cjs/token.cjs +1 -1
  36. package/dist/cjs/token.cjs.map +1 -1
  37. package/dist/cjs/typed-data.cjs.map +1 -1
  38. package/dist/cjs/validation.cjs.map +1 -1
  39. package/dist/cjs/vaults/index.cjs +1 -1
  40. package/dist/cjs/vaults/index.cjs.map +1 -1
  41. package/dist/cjs/viem/index.cjs +1 -1
  42. package/dist/cjs/viem/index.cjs.map +1 -1
  43. package/dist/cjs/web/index.cjs.map +1 -1
  44. package/dist/cjs/wrappers-registry.cjs +1 -1
  45. package/dist/cjs/wrappers-registry.cjs.map +1 -1
  46. package/dist/esm/alignment-o-YIndFR.js +2 -0
  47. package/dist/esm/alignment-o-YIndFR.js.map +1 -0
  48. package/dist/esm/base-signer-D8-tyO9l.js +2 -0
  49. package/dist/esm/base-signer-D8-tyO9l.js.map +1 -0
  50. package/dist/esm/{base-signer-CPJ3mxtC.d.ts → base-signer-nenGJU9U.d.ts} +2 -7
  51. package/dist/esm/chains/index.d.ts +11 -1
  52. package/dist/esm/chains/index.js +1 -1
  53. package/dist/esm/chains-BQXSxIwU.js +2 -0
  54. package/dist/esm/chains-BQXSxIwU.js.map +1 -0
  55. package/dist/esm/cleartext/index.d.ts +9 -2
  56. package/dist/esm/cleartext/index.js +1 -1
  57. package/dist/esm/{cleartext-CJZLnm03.js → cleartext-3QqBsH3R.js} +2 -2
  58. package/dist/esm/cleartext-3QqBsH3R.js.map +1 -0
  59. package/dist/esm/{cleartext-kj8U3zlJ.d.ts → cleartext-BLMLdKFh.d.ts} +2 -5
  60. package/dist/esm/{index-D2-D-KzK.d.ts → decryption-Cp8calaa.d.ts} +7109 -4010
  61. package/dist/esm/{eip1193-subscribe-CNxVHW6y.js → eip1193-subscribe-DxAQh8dY.js} +2 -2
  62. package/dist/esm/eip1193-subscribe-DxAQh8dY.js.map +1 -0
  63. package/dist/esm/{encrypt-worker-client-BlvStkvI.d.ts → encrypt-worker-client-CkEIA0Tp.d.ts} +3 -6
  64. package/dist/esm/encrypt.worker.js +27 -33
  65. package/dist/esm/{encryption-ieCO6J5r.js → encryption-BT886Jlj.js} +2 -2
  66. package/dist/esm/{encryption-ieCO6J5r.js.map → encryption-BT886Jlj.js.map} +1 -1
  67. package/dist/esm/ethers/index.d.ts +39 -34
  68. package/dist/esm/ethers/index.js +1 -1
  69. package/dist/esm/ethers/index.js.map +1 -1
  70. package/dist/esm/{fatal-batch-CI1pes1q.js → fatal-batch-BYeHrf0V.js} +2 -2
  71. package/dist/esm/fatal-batch-BYeHrf0V.js.map +1 -0
  72. package/dist/esm/fhevm-relayer-D0Uio0ls.js +8 -0
  73. package/dist/esm/fhevm-relayer-D0Uio0ls.js.map +1 -0
  74. package/dist/esm/{index-B3VPiqps.d.ts → index-CI6f4jxt.d.ts} +7 -10
  75. package/dist/esm/{index-B61orJOE.d.ts → index-ClNBSbRy.d.ts} +4 -9
  76. package/dist/esm/{index-D1Wtji3m.d.ts → index-ZTcD9b_z.d.ts} +31 -29
  77. package/dist/esm/index.d.ts +26 -30
  78. package/dist/esm/index.js +1 -1
  79. package/dist/esm/index.js.map +1 -1
  80. package/dist/esm/internal/index.d.ts +9 -18
  81. package/dist/esm/internal/index.js +1 -1
  82. package/dist/esm/internal/index.js.map +1 -1
  83. package/dist/esm/{invalidation-CJ-pzOUG.d.ts → invalidation-IBiMIXGB.d.ts} +1 -4
  84. package/dist/esm/log-decoding-ZthqwHOv.js +2 -0
  85. package/dist/esm/log-decoding-ZthqwHOv.js.map +1 -0
  86. package/dist/esm/node/index.d.ts +12 -4
  87. package/dist/esm/node/index.js +1 -1
  88. package/dist/esm/node/index.js.map +1 -1
  89. package/dist/esm/query/index.d.ts +69 -141
  90. package/dist/esm/query/index.js +1 -1
  91. package/dist/esm/query/index.js.map +1 -1
  92. package/dist/esm/query-keys-CSPxPLBB.js +2 -0
  93. package/dist/esm/query-keys-CSPxPLBB.js.map +1 -0
  94. package/dist/esm/relayer-nWfQAlo7.js +2 -0
  95. package/dist/esm/relayer-nWfQAlo7.js.map +1 -0
  96. package/dist/esm/{signing-CneT-WIV.js → signing-CVEOw21I.js} +2 -2
  97. package/dist/esm/signing-CVEOw21I.js.map +1 -0
  98. package/dist/esm/telemetry-r8qLB6-r.js +2 -0
  99. package/dist/esm/telemetry-r8qLB6-r.js.map +1 -0
  100. package/dist/esm/token-AXsOIUDB.js +2 -0
  101. package/dist/esm/token-AXsOIUDB.js.map +1 -0
  102. package/dist/esm/typed-data-eAgGr9V-.js.map +1 -1
  103. package/dist/esm/{types-DPs3N2Vk.d.ts → types-D253qkvB.d.ts} +3 -6
  104. package/dist/esm/{types-CDlukOrk.d.ts → types-DH06Ap0n.d.ts} +3 -6
  105. package/dist/esm/{types-5ThXjdi3.d.ts → types-Ubeo72FV.d.ts} +28 -33
  106. package/dist/esm/{validation-ChQwNxaY.js → validation-CZfDLOUh.js} +2 -2
  107. package/dist/esm/{validation-ChQwNxaY.js.map → validation-CZfDLOUh.js.map} +1 -1
  108. package/dist/esm/vaults/index.d.ts +296 -13523
  109. package/dist/esm/vaults/index.js +1 -1
  110. package/dist/esm/vaults/index.js.map +1 -1
  111. package/dist/esm/viem/index.d.ts +39 -34
  112. package/dist/esm/viem/index.js +1 -1
  113. package/dist/esm/viem/index.js.map +1 -1
  114. package/dist/esm/web/index.d.ts +13 -7
  115. package/dist/esm/web/index.js +1 -1
  116. package/dist/esm/web/index.js.map +1 -1
  117. package/dist/esm/wrappers-registry-Cm3JJeqx.js +2 -0
  118. package/dist/esm/wrappers-registry-Cm3JJeqx.js.map +1 -0
  119. package/package.json +2 -2
  120. package/dist/cjs/applied-runtime.cjs +0 -2
  121. package/dist/cjs/applied-runtime.cjs.map +0 -1
  122. package/dist/cjs/invalidation.cjs +0 -2
  123. package/dist/cjs/invalidation.cjs.map +0 -1
  124. package/dist/cjs/primitives.cjs +0 -2
  125. package/dist/cjs/primitives.cjs.map +0 -1
  126. package/dist/cjs/wrapped-token.cjs +0 -2
  127. package/dist/cjs/wrapped-token.cjs.map +0 -1
  128. package/dist/esm/applied-runtime-3fzqBC2V.js +0 -2
  129. package/dist/esm/applied-runtime-3fzqBC2V.js.map +0 -1
  130. package/dist/esm/base-signer-zPd_i06-.js +0 -2
  131. package/dist/esm/base-signer-zPd_i06-.js.map +0 -1
  132. package/dist/esm/chains-BwlDI944.js +0 -2
  133. package/dist/esm/chains-BwlDI944.js.map +0 -1
  134. package/dist/esm/cleartext-CJZLnm03.js.map +0 -1
  135. package/dist/esm/eip1193-subscribe-CNxVHW6y.js.map +0 -1
  136. package/dist/esm/fatal-batch-CI1pes1q.js.map +0 -1
  137. package/dist/esm/fhevm-relayer-Bq4dUHvo.js +0 -8
  138. package/dist/esm/fhevm-relayer-Bq4dUHvo.js.map +0 -1
  139. package/dist/esm/invalidation-BgFjmXeQ.js +0 -2
  140. package/dist/esm/invalidation-BgFjmXeQ.js.map +0 -1
  141. package/dist/esm/primitives-Cym-3HKa.js +0 -2
  142. package/dist/esm/primitives-Cym-3HKa.js.map +0 -1
  143. package/dist/esm/relayer-ov8b_HOu.js +0 -2
  144. package/dist/esm/relayer-ov8b_HOu.js.map +0 -1
  145. package/dist/esm/signing-CneT-WIV.js.map +0 -1
  146. package/dist/esm/telemetry-Bnz3CyE0.js +0 -2
  147. package/dist/esm/telemetry-Bnz3CyE0.js.map +0 -1
  148. package/dist/esm/token-DlsiZmg5.js +0 -2
  149. package/dist/esm/token-DlsiZmg5.js.map +0 -1
  150. package/dist/esm/wrapped-token-C8eKid8W.js +0 -2
  151. package/dist/esm/wrapped-token-C8eKid8W.js.map +0 -1
  152. package/dist/esm/wrappers-registry-DnYVQ02R.js +0 -2
  153. package/dist/esm/wrappers-registry-DnYVQ02R.js.map +0 -1
@@ -1,13 +1,16 @@
1
- import { d as AtLeastOneChain, f as FheChain, p as FheChainAuth } from "../index-D1Wtji3m.js";
2
- import { $ as SetOperatorSubmittedEvent, $t as TransactionReceipt, A as WalletAccountListener, B as ApproveUnderlyingSubmittedEvent, D as GenericSigner, F as ReadContractReturnType, G as DelegationSubmittedEvent, H as DecryptEndEvent, I as ReadFunctionName, J as EncryptStartEvent, K as EncryptEndEvent, L as WriteContractArgs, M as ContractAbi, N as ReadContractArgs, O as WalletAccount, P as ReadContractConfig, Q as RevokeDelegationSubmittedEvent, Qt as RawLog, R as WriteContractConfig, U as DecryptErrorEvent, V as BaseEvent, W as DecryptStartEvent, X as PermitErrorEvent, Y as FinalizeUnwrapSubmittedEvent, Z as PermitOperation, a as ZamaConfigBase, at as UnshieldPhase1SubmittedEvent, c as GenericStorage, cn as EncryptedValue, ct as UnwrapSubmittedEvent, dt as WrapSubmittedEvent, et as ShieldSubmittedEvent, fn as FhevmRuntimeConfig, ft as ZamaSDKEvent, ht as ZamaSDKEvents, i as ZamaConfig, in as EIP712TypedData, it as TransferSubmittedEvent, j as WalletAccountStore, k as WalletAccountChange, l as GenericProvider, mt as ZamaSDKEventType, n as RelayerConfig, nt as TransactionOperation, ot as UnshieldPhase2StartedEvent, pt as ZamaSDKEventListener, q as EncryptErrorEvent, rt as TransferFromSubmittedEvent, s as GenericLogger, st as UnshieldPhase2SubmittedEvent, tn as ClearValue, tt as TransactionErrorEvent, vt as ShieldPath, z as WriteFunctionName } from "../types-5ThXjdi3.js";
3
- import { n as MutableWalletAccountStore, t as BaseSigner } from "../base-signer-CPJ3mxtC.js";
4
- import { t as ZamaConfigViem } from "../types-DPs3N2Vk.js";
1
+ /**
2
+ * Viem adapter for `@zama-fhe/sdk` — provides {@link ViemSigner} and
3
+ * viem-native contract read/write helpers.
4
+ *
5
+ * @packageDocumentation
6
+ */
7
+ import { t as ZamaConfigViem } from "../types-D253qkvB.js";
8
+ import { $ as RevokeDelegationSubmittedEvent, $t as RawLog, A as WalletAccountListener, B as WriteFunctionName, D as GenericSigner, F as ReadContractConfig, G as DecryptStartEvent, H as BaseEvent, I as ReadContractReturnType, J as EncryptErrorEvent, K as DelegationSubmittedEvent, L as ReadFunctionName, M as ContractAbi, N as MulticallReturnType, O as WalletAccount, P as ReadContractArgs, Q as PermitOperation, R as WriteContractArgs, U as DecryptEndEvent, V as ApproveUnderlyingSubmittedEvent, W as DecryptErrorEvent, X as FinalizeUnwrapSubmittedEvent, Y as EncryptStartEvent, Z as PermitErrorEvent, a as ZamaConfigBase, an as EIP712TypedData, at as TransferSubmittedEvent, c as GenericStorage, ct as UnshieldPhase2SubmittedEvent, en as TransactionReceipt, et as SetOperatorSubmittedEvent, ft as WrapSubmittedEvent, gt as ZamaSDKEvents, ht as ZamaSDKEventType, i as ZamaConfig, it as TransferFromSubmittedEvent, j as WalletAccountStore, k as WalletAccountChange, l as GenericProvider, ln as EncryptedValue, lt as UnwrapSubmittedEvent, mt as ZamaSDKEventListener, n as RelayerConfig, nn as ClearValue, nt as TransactionErrorEvent, ot as UnshieldPhase1SubmittedEvent, pn as FhevmRuntimeConfig, pt as ZamaSDKEvent, q as EncryptEndEvent, rt as TransactionOperation, s as GenericLogger, st as UnshieldPhase2StartedEvent, tt as ShieldSubmittedEvent, yt as ShieldPath, z as WriteContractConfig } from "../types-Ubeo72FV.js";
9
+ import { d as AtLeastOneChain, f as FheChain, p as FheChainAuth } from "../index-ZTcD9b_z.js";
10
+ import { n as MutableWalletAccountStore, t as BaseSigner } from "../base-signer-nenGJU9U.js";
5
11
  import { Abi, Address, ContractFunctionArgs, ContractFunctionName, ContractFunctionReturnType, EIP1193Provider, Hex, Hex as Hex$1, PublicClient, WalletClient } from "viem";
6
- //#region src/viem/config.d.ts
7
12
  /** Create a {@link ZamaConfig} from viem clients. */
8
- declare function createConfig<const TChains extends readonly [FheChain, ...FheChain[]]>(params: ZamaConfigViem<TChains>): ZamaConfig;
9
- //#endregion
10
- //#region src/viem/viem-signer.d.ts
13
+ export declare function createConfig<const TChains extends readonly [FheChain, ...FheChain[]]>(params: ZamaConfigViem<TChains>): ZamaConfig;
11
14
  /**
12
15
  * Configuration for {@link ViemSigner}.
13
16
  *
@@ -31,7 +34,7 @@ interface ViemSignerConfig {
31
34
  * write transactions. Pass `ethereum` in {@link ViemSignerConfig} to track
32
35
  * wallet lifecycle events.
33
36
  */
34
- declare class ViemSigner extends BaseSigner {
37
+ export declare class ViemSigner extends BaseSigner {
35
38
  #private;
36
39
  constructor(config: ViemSignerConfig);
37
40
  /** Sign EIP-712 typed data (used for decrypt authorization). */
@@ -41,8 +44,6 @@ declare class ViemSigner extends BaseSigner {
41
44
  /** Unsubscribe from the EIP-1193 provider's wallet lifecycle events. */
42
45
  protected onDispose(): void;
43
46
  }
44
- //#endregion
45
- //#region src/viem/viem-provider.d.ts
46
47
  /** Configuration for {@link ViemProvider}. */
47
48
  interface ViemProviderConfig {
48
49
  /** A viem `PublicClient` backing all read operations. */
@@ -61,17 +62,25 @@ interface ViemProviderConfig {
61
62
  * const provider = new ViemProvider({ publicClient });
62
63
  * ```
63
64
  */
64
- declare class ViemProvider implements GenericProvider {
65
+ export declare class ViemProvider implements GenericProvider {
65
66
  #private;
66
67
  constructor(config: ViemProviderConfig);
67
68
  /** Return the chain ID of the connected network. */
68
69
  getChainId(): Promise<number>;
69
70
  /** Execute a read-only call and return the decoded result. */
70
71
  readContract<const TAbi extends Abi | readonly unknown[], TFunctionName extends ContractFunctionName<TAbi, "pure" | "view">, const TArgs extends ContractFunctionArgs<TAbi, "pure" | "view", TFunctionName>>(config: ReadContractConfig<TAbi, TFunctionName, TArgs>): Promise<ContractFunctionReturnType<TAbi, "pure" | "view", TFunctionName, TArgs>>;
72
+ /**
73
+ * Run many reads in one Multicall3 call. On a chain whose viem definition
74
+ * names no Multicall3, such as a local Hardhat node, the call carries its code.
75
+ */
76
+ multicall<const TCalls extends readonly ReadContractConfig[]>(params: {
77
+ readonly calls: TCalls;
78
+ readonly chainId?: number;
79
+ }): Promise<MulticallReturnType<TCalls>>;
71
80
  /** Wait for a transaction to be mined and return its receipt. */
72
81
  waitForTransactionReceipt(hash: Hex$1): Promise<TransactionReceipt>;
73
82
  /** Return the latest block timestamp in seconds. */
74
- getBlockTimestamp(): Promise<bigint>;
83
+ getBlockTimestamp(chainId?: number): Promise<bigint>;
75
84
  /** Build a fully-populated, RLP-encoded unsigned transaction ready to be signed offline. */
76
85
  prepareTransaction<const TAbi extends ContractAbi, TFunctionName extends WriteFunctionName<TAbi>, const TArgs extends WriteContractArgs<TAbi, TFunctionName>>(args: {
77
86
  from: Address;
@@ -84,52 +93,48 @@ declare class ViemProvider implements GenericProvider {
84
93
  };
85
94
  }): Promise<Hex$1>;
86
95
  }
87
- //#endregion
88
- //#region src/viem/contracts.d.ts
89
96
  /** Reads a token's confidential (encrypted) balance handle for `userAddress` via a viem client. */
90
- declare function readConfidentialBalanceOfContract(client: PublicClient, tokenAddress: Address, userAddress: Address): Promise<`0x${string}`>;
97
+ export declare function readConfidentialBalanceOfContract(client: PublicClient, tokenAddress: Address, userAddress: Address): Promise<`0x${string}`>;
91
98
  /** Reads the underlying ERC-20 address wrapped by a confidential wrapper via a viem client. */
92
- declare function readUnderlyingTokenContract(client: PublicClient, wrapperAddress: Address): Promise<`0x${string}`>;
99
+ export declare function readUnderlyingTokenContract(client: PublicClient, wrapperAddress: Address): Promise<`0x${string}`>;
93
100
  /** Reads whether a token implements the given ERC-165 interface id via a viem client. */
94
- declare function readSupportsInterfaceContract(client: PublicClient, tokenAddress: Address, interfaceId: Address): Promise<boolean>;
101
+ export declare function readSupportsInterfaceContract(client: PublicClient, tokenAddress: Address, interfaceId: Address): Promise<boolean>;
95
102
  /** Submits a confidential transfer of an encrypted amount to `to` via a viem wallet client. */
96
- declare function writeConfidentialTransferContract(client: WalletClient, tokenAddress: Address, to: Address, encryptedAmount: EncryptedValue, inputProof: Hex$1): Promise<`0x${string}`>;
103
+ export declare function writeConfidentialTransferContract(client: WalletClient, tokenAddress: Address, to: Address, encryptedAmount: EncryptedValue, inputProof: Hex$1): Promise<`0x${string}`>;
97
104
  /** Submits an unwrap of an encrypted amount from `from` to `to` on a confidential ERC-20 via a viem wallet client. */
98
- declare function writeUnwrapContract(client: WalletClient, encryptedErc20: Address, from: Address, to: Address, encryptedAmount: EncryptedValue, inputProof: Hex$1): Promise<`0x${string}`>;
105
+ export declare function writeUnwrapContract(client: WalletClient, encryptedErc20: Address, from: Address, to: Address, encryptedAmount: EncryptedValue, inputProof: Hex$1): Promise<`0x${string}`>;
99
106
  /** Submits an unwrap of the full encrypted balance from `from` to `to` via a viem wallet client. */
100
- declare function writeUnwrapFromBalanceContract(client: WalletClient, encryptedErc20: Address, from: Address, to: Address, encryptedBalance: EncryptedValue): Promise<`0x${string}`>;
107
+ export declare function writeUnwrapFromBalanceContract(client: WalletClient, encryptedErc20: Address, from: Address, to: Address, encryptedBalance: EncryptedValue): Promise<`0x${string}`>;
101
108
  /** Finalizes a pending unwrap request with the decrypted amount and decryption proof via a viem wallet client. */
102
- declare function writeFinalizeUnwrapContract(client: WalletClient, wrapper: Address, unwrapRequestId: EncryptedValue, unwrapAmountCleartext: bigint, decryptionProof: Hex$1): Promise<`0x${string}`>;
109
+ export declare function writeFinalizeUnwrapContract(client: WalletClient, wrapper: Address, unwrapRequestId: EncryptedValue, unwrapAmountCleartext: bigint, decryptionProof: Hex$1): Promise<`0x${string}`>;
103
110
  /** Authorizes `operator` on a token, until an optional expiry timestamp, via a viem wallet client. */
104
- declare function writeSetOperatorContract(client: WalletClient, tokenAddress: Address, operator: Address, until?: number): Promise<`0x${string}`>;
111
+ export declare function writeSetOperatorContract(client: WalletClient, tokenAddress: Address, operator: Address, until?: number): Promise<`0x${string}`>;
105
112
  /** Wraps `amount` of the underlying ERC-20 into confidential tokens credited to `to` via a viem wallet client. */
106
- declare function writeWrapContract(client: WalletClient, wrapperAddress: Address, to: Address, amount: bigint): Promise<`0x${string}`>;
113
+ export declare function writeWrapContract(client: WalletClient, wrapperAddress: Address, to: Address, amount: bigint): Promise<`0x${string}`>;
107
114
  /** Reads all underlying/confidential token pairs from a wrappers registry via a viem client. */
108
- declare function readTokenPairsContract(client: PublicClient, registry: Address): Promise<readonly {
115
+ export declare function readTokenPairsContract(client: PublicClient, registry: Address): Promise<readonly {
109
116
  tokenAddress: `0x${string}`;
110
117
  confidentialTokenAddress: `0x${string}`;
111
118
  isValid: boolean;
112
119
  }[]>;
113
120
  /** Reads the number of token pairs in a wrappers registry via a viem client. */
114
- declare function readTokenPairsLengthContract(client: PublicClient, registry: Address): Promise<bigint>;
121
+ export declare function readTokenPairsLengthContract(client: PublicClient, registry: Address): Promise<bigint>;
115
122
  /** Reads a slice of token pairs (`fromIndex` to `toIndex`) from a wrappers registry via a viem client. */
116
- declare function readTokenPairsSliceContract(client: PublicClient, registry: Address, fromIndex: bigint, toIndex: bigint): Promise<readonly {
123
+ export declare function readTokenPairsSliceContract(client: PublicClient, registry: Address, fromIndex: bigint, toIndex: bigint): Promise<readonly {
117
124
  tokenAddress: `0x${string}`;
118
125
  confidentialTokenAddress: `0x${string}`;
119
126
  isValid: boolean;
120
127
  }[]>;
121
128
  /** Reads the token pair at `index` from a wrappers registry via a viem client. */
122
- declare function readTokenPairContract(client: PublicClient, registry: Address, index: bigint): Promise<{
129
+ export declare function readTokenPairContract(client: PublicClient, registry: Address, index: bigint): Promise<{
123
130
  tokenAddress: `0x${string}`;
124
131
  confidentialTokenAddress: `0x${string}`;
125
132
  isValid: boolean;
126
133
  }>;
127
134
  /** Reads the confidential token registered for a given underlying token in a wrappers registry via a viem client. */
128
- declare function readConfidentialTokenAddressContract(client: PublicClient, registry: Address, tokenAddress: Address): Promise<readonly [boolean, `0x${string}`]>;
135
+ export declare function readConfidentialTokenAddressContract(client: PublicClient, registry: Address, tokenAddress: Address): Promise<readonly [boolean, `0x${string}`]>;
129
136
  /** Reads the underlying token registered for a given confidential token in a wrappers registry via a viem client. */
130
- declare function readTokenAddressContract(client: PublicClient, registry: Address, confidentialTokenAddress: Address): Promise<readonly [boolean, `0x${string}`]>;
137
+ export declare function readTokenAddressContract(client: PublicClient, registry: Address, confidentialTokenAddress: Address): Promise<readonly [boolean, `0x${string}`]>;
131
138
  /** Reads whether a confidential token is registered and valid in a wrappers registry via a viem client. */
132
- declare function readIsConfidentialTokenValidContract(client: PublicClient, registry: Address, confidentialTokenAddress: Address): Promise<boolean>;
133
- //#endregion
134
- export { type ApproveUnderlyingSubmittedEvent, type AtLeastOneChain, type BaseEvent, BaseSigner, type ClearValue, type ContractAbi, type DecryptEndEvent, type DecryptErrorEvent, type DecryptStartEvent, type DelegationSubmittedEvent, type EIP712TypedData, type EncryptEndEvent, type EncryptErrorEvent, type EncryptStartEvent, type EncryptedValue, type FheChain, type FheChainAuth, type FhevmRuntimeConfig, type FinalizeUnwrapSubmittedEvent, type GenericLogger, type GenericProvider, type GenericSigner, type GenericStorage, type Hex, type MutableWalletAccountStore, type PermitErrorEvent, type PermitOperation, type RawLog, type ReadContractArgs, type ReadContractConfig, type ReadContractReturnType, type ReadFunctionName, type RelayerConfig, type RevokeDelegationSubmittedEvent, type SetOperatorSubmittedEvent, type ShieldPath, type ShieldSubmittedEvent, type TransactionErrorEvent, type TransactionOperation, type TransactionReceipt, type TransferFromSubmittedEvent, type TransferSubmittedEvent, type UnshieldPhase1SubmittedEvent, type UnshieldPhase2StartedEvent, type UnshieldPhase2SubmittedEvent, type UnwrapSubmittedEvent, ViemProvider, type ViemProviderConfig, ViemSigner, type ViemSignerConfig, type WalletAccount, type WalletAccountChange, type WalletAccountListener, type WalletAccountStore, type WrapSubmittedEvent, type WriteContractArgs, type WriteContractConfig, type WriteFunctionName, type ZamaConfig, type ZamaConfigBase, type ZamaConfigViem, type ZamaSDKEvent, type ZamaSDKEventListener, type ZamaSDKEventType, ZamaSDKEvents, createConfig, readConfidentialBalanceOfContract, readConfidentialTokenAddressContract, readIsConfidentialTokenValidContract, readSupportsInterfaceContract, readTokenAddressContract, readTokenPairContract, readTokenPairsContract, readTokenPairsLengthContract, readTokenPairsSliceContract, readUnderlyingTokenContract, writeConfidentialTransferContract, writeFinalizeUnwrapContract, writeSetOperatorContract, writeUnwrapContract, writeUnwrapFromBalanceContract, writeWrapContract };
135
- //# sourceMappingURL=index.d.ts.map
139
+ export declare function readIsConfidentialTokenValidContract(client: PublicClient, registry: Address, confidentialTokenAddress: Address): Promise<boolean>;
140
+ export { type ApproveUnderlyingSubmittedEvent, type AtLeastOneChain, type BaseEvent, BaseSigner, type ClearValue, type ContractAbi, type DecryptEndEvent, type DecryptErrorEvent, type DecryptStartEvent, type DelegationSubmittedEvent, type EIP712TypedData, type EncryptEndEvent, type EncryptErrorEvent, type EncryptStartEvent, type EncryptedValue, type FheChain, type FheChainAuth, type FhevmRuntimeConfig, type FinalizeUnwrapSubmittedEvent, type GenericLogger, type GenericProvider, type GenericSigner, type GenericStorage, type Hex, type MulticallReturnType, type MutableWalletAccountStore, type PermitErrorEvent, type PermitOperation, type RawLog, type ReadContractArgs, type ReadContractConfig, type ReadContractReturnType, type ReadFunctionName, type RelayerConfig, type RevokeDelegationSubmittedEvent, type SetOperatorSubmittedEvent, type ShieldPath, type ShieldSubmittedEvent, type TransactionErrorEvent, type TransactionOperation, type TransactionReceipt, type TransferFromSubmittedEvent, type TransferSubmittedEvent, type UnshieldPhase1SubmittedEvent, type UnshieldPhase2StartedEvent, type UnshieldPhase2SubmittedEvent, type UnwrapSubmittedEvent, type ViemProviderConfig, type ViemSignerConfig, type WalletAccount, type WalletAccountChange, type WalletAccountListener, type WalletAccountStore, type WrapSubmittedEvent, type WriteContractArgs, type WriteContractConfig, type WriteFunctionName, type ZamaConfig, type ZamaConfigBase, type ZamaConfigViem, type ZamaSDKEvent, type ZamaSDKEventListener, type ZamaSDKEventType, ZamaSDKEvents };
@@ -1,2 +1,2 @@
1
- import{F as e,H as t,L as n,M as r,N as i,O as a,P as o,S as s,T as c,Y as l,a as u,i as d,m as f,n as p,o as m,q as h,r as g,s as _,t as v}from"../wrappers-registry-DnYVQ02R.js";import{i as y,t as b}from"../base-signer-zPd_i06-.js";import{t as x}from"../typed-data-eAgGr9V-.js";import{t as S}from"../eip1193-subscribe-CNxVHW6y.js";import{encodeFunctionData as C,getAddress as w,serializeTransaction as T}from"viem";var E=class{#e;constructor(e){this.#e=e.publicClient}async getChainId(){return this.#e.getChainId()}async readContract(e){return this.#e.readContract(e)}async waitForTransactionReceipt(e){return this.#e.waitForTransactionReceipt({hash:e})}async getBlockTimestamp(){return(await this.#e.getBlock()).timestamp}async prepareTransaction(e){let{from:t,calldata:n}=e,r=C({abi:n.abi,functionName:n.functionName,args:n.args}),i=this.#e.getChainId(),a=e.nonce===void 0?this.#e.getTransactionCount({address:t,blockTag:`pending`}):Promise.resolve(e.nonce),o=e.gasLimit===void 0?n.gas??this.#e.estimateGas({account:t,to:n.address,data:r,value:n.value??0n}).catch(e=>{throw new l(`ViemProvider.prepareTransaction: gas estimation reverted for ${n.functionName} on ${n.address}`,{cause:e})}):Promise.resolve(e.gasLimit),s=e.fees??this.#e.estimateFeesPerGas(),[c,u,d,f]=await Promise.all([i,a,o,s]);return T({type:`eip1559`,chainId:c,nonce:u,to:n.address,data:r,value:n.value??0n,gas:d,maxFeePerGas:f.maxFeePerGas,maxPriorityFeePerGas:f.maxPriorityFeePerGas})}};function D(e){if(!(!e.account||!e.chain))return{address:w(e.account.address),chainId:e.chain.id}}var O=class extends b{#e;#t;#n;constructor(e){super(D(e.walletClient)),this.#e=e.walletClient,this.#t=e.ethereum,this.#n=this.#i()}#r(e){if(!this.#e.account)throw new h(e);return{walletClient:this.#e,account:this.#e.account}}async signTypedData(e){let{walletClient:t,account:n}=this.#r(`signTypedData`);return t.signTypedData({account:n,...x(e)})}async writeContract(e){let{walletClient:t,account:n}=this.#r(`writeContract`);return t.writeContract({chain:t.chain,account:n,...e})}#i(){return this.#t?S({provider:this.#t,getInitialWalletAccount:()=>D(this.#e),onWalletAccountChange:({next:e})=>{this.walletAccount.setSnapshot(e)}}):()=>{}}onDispose(){this.#n()}};function k(e){return y(new O({walletClient:e.walletClient,ethereum:e.ethereum}),new E({publicClient:e.publicClient}),e)}function A(e){if(!e.account)throw TypeError(`WalletClient has no account`);return e.account}function j(e,t,n){return e.readContract(s(t,n))}function M(e,t){return e.readContract(i(t))}function N(e,t,n){return e.readContract(f(t,n))}function P(e,t,n,r,i){return e.writeContract({chain:e.chain,account:A(e),...c(t,n,r,i)})}function F(e,t,n,r,i,a){return e.writeContract({chain:e.chain,account:A(e),...o(t,n,r,i,a)})}function I(t,n,r,i,a){return t.writeContract({chain:t.chain,account:A(t),...e(n,r,i,a)})}function L(e,t,n,r,i){return e.writeContract({chain:e.chain,account:A(e),...a(t,n,r,i)})}function R(e,t,n,i){return e.writeContract({chain:e.chain,account:A(e),...r(t,n,i)})}function z(e,t,r,i){return e.writeContract({chain:e.chain,account:A(e),...n(t,r,i)})}function B(e,t){return e.readContract(d(t))}function V(e,t){return e.readContract(u(t))}function H(e,t,n,r){return e.readContract(m(t,n,r))}function U(e,t,n){return e.readContract(g(t,n))}function W(e,t,n){return e.readContract(v(t,n))}function G(e,t,n){return e.readContract(p(t,n))}function K(e,t,n){return e.readContract(_(t,n))}export{b as BaseSigner,E as ViemProvider,O as ViemSigner,t as ZamaSDKEvents,k as createConfig,j as readConfidentialBalanceOfContract,W as readConfidentialTokenAddressContract,K as readIsConfidentialTokenValidContract,N as readSupportsInterfaceContract,G as readTokenAddressContract,U as readTokenPairContract,B as readTokenPairsContract,V as readTokenPairsLengthContract,H as readTokenPairsSliceContract,M as readUnderlyingTokenContract,P as writeConfidentialTransferContract,L as writeFinalizeUnwrapContract,R as writeSetOperatorContract,F as writeUnwrapContract,I as writeUnwrapFromBalanceContract,z as writeWrapContract};
1
+ import{A as e,B as t,F as n,G as r,M as i,N as a,S as o,T as s,X as c,d as l,k as u,r as d,y as f}from"../alignment-o-YIndFR.js";import{i as p,t as m}from"../base-signer-D8-tyO9l.js";import{t as h}from"../eip1193-subscribe-DxAQh8dY.js";import{t as g}from"../typed-data-eAgGr9V-.js";import{a as _,i as v,n as y,o as b,r as x,s as S,t as C}from"../wrappers-registry-Cm3JJeqx.js";import{encodeFunctionData as w,getAddress as T,serializeTransaction as E}from"viem";var D=class{#e;constructor(e){this.#e=e.publicClient}async getChainId(){return this.#e.getChainId()}async readContract(e){let{chainId:t,...n}=e;return await d(`ViemProvider`,t,()=>this.getChainId()),this.#e.readContract(n)}async multicall(e){return await d(`ViemProvider`,e.chainId,()=>this.getChainId()),await this.#e.multicall({contracts:e.calls.map(({chainId:e,...t})=>t),allowFailure:!1,deployless:this.#e.chain?.contracts?.multicall3===void 0})}async waitForTransactionReceipt(e){return this.#e.waitForTransactionReceipt({hash:e})}async getBlockTimestamp(e){return await d(`ViemProvider`,e,()=>this.getChainId()),(await this.#e.getBlock()).timestamp}async prepareTransaction(e){let{from:t,calldata:n}=e,r=w({abi:n.abi,functionName:n.functionName,args:n.args}),i=this.#e.getChainId(),a=e.nonce===void 0?this.#e.getTransactionCount({address:t,blockTag:`pending`}):Promise.resolve(e.nonce),o=e.gasLimit===void 0?n.gas??this.#e.estimateGas({account:t,to:n.address,data:r,value:n.value??0n}).catch(e=>{throw new c(`ViemProvider.prepareTransaction: gas estimation reverted for ${n.functionName} on ${n.address}`,{cause:e})}):Promise.resolve(e.gasLimit),s=e.fees??this.#e.estimateFeesPerGas(),[l,u,d,f]=await Promise.all([i,a,o,s]);return E({type:`eip1559`,chainId:l,nonce:u,to:n.address,data:r,value:n.value??0n,gas:d,maxFeePerGas:f.maxFeePerGas,maxPriorityFeePerGas:f.maxPriorityFeePerGas})}};function O(e){if(e.account&&e.chain)return{address:T(e.account.address),chainId:e.chain.id}}var k=class extends m{#e;#t;#n;constructor(e){super(O(e.walletClient)),this.#e=e.walletClient,this.#t=e.ethereum,this.#n=this.#i()}#r(e){if(!this.#e.account)throw new r(e);return{walletClient:this.#e,account:this.#e.account}}async signTypedData(e){let{walletClient:t,account:n}=this.#r(`signTypedData`);return t.signTypedData({account:n,...g(e)})}async writeContract(e){let{walletClient:t,account:n}=this.#r(`writeContract`);return t.writeContract({chain:t.chain,account:n,...e})}#i(){return this.#t?h({provider:this.#t,getInitialWalletAccount:()=>O(this.#e),onWalletAccountChange:({next:e})=>{this.walletAccount.setSnapshot(e)}}):()=>{}}onDispose(){this.#n()}};function A(e){let t=new k({walletClient:e.walletClient,ethereum:e.ethereum}),n=new D({publicClient:e.publicClient});return p(t,n,e)}function j(e){if(!e.account)throw TypeError(`WalletClient has no account`);return e.account}function M(e,t,n){return e.readContract(f(t,n))}function N(t,n){return t.readContract(e(n))}function P(e,t,n){return e.readContract(l(t,n))}function F(e,t,n,r,i){return e.writeContract({chain:e.chain,account:j(e),...o(t,n,r,i)})}function I(e,t,n,r,a,o){return e.writeContract({chain:e.chain,account:j(e),...i(t,n,r,a,o)})}function L(e,t,n,r,i){return e.writeContract({chain:e.chain,account:j(e),...a(t,n,r,i)})}function R(e,t,n,r,i){return e.writeContract({chain:e.chain,account:j(e),...s(t,n,r,i)})}function z(e,t,n,r){return e.writeContract({chain:e.chain,account:j(e),...u(t,n,r)})}function B(e,t,r,i){return e.writeContract({chain:e.chain,account:j(e),...n(t,r,i)})}function V(e,t){return e.readContract(v(t))}function H(e,t){return e.readContract(_(t))}function U(e,t,n,r){return e.readContract(b(t,n,r))}function W(e,t,n){return e.readContract(x(t,n))}function G(e,t,n){return e.readContract(C(t,n))}function K(e,t,n){return e.readContract(y(t,n))}function q(e,t,n){return e.readContract(S(t,n))}export{m as BaseSigner,D as ViemProvider,k as ViemSigner,t as ZamaSDKEvents,A as createConfig,M as readConfidentialBalanceOfContract,G as readConfidentialTokenAddressContract,q as readIsConfidentialTokenValidContract,P as readSupportsInterfaceContract,K as readTokenAddressContract,W as readTokenPairContract,V as readTokenPairsContract,H as readTokenPairsLengthContract,U as readTokenPairsSliceContract,N as readUnderlyingTokenContract,F as writeConfidentialTransferContract,R as writeFinalizeUnwrapContract,z as writeSetOperatorContract,I as writeUnwrapContract,L as writeUnwrapFromBalanceContract,B as writeWrapContract};
2
2
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["#publicClient","#walletClient","#ethereum","#unsubscribeProvider","#subscribeToProvider","#requireAccount"],"sources":["../../../src/viem/viem-provider.ts","../../../src/viem/viem-signer.ts","../../../src/viem/config.ts","../../../src/viem/contracts.ts"],"sourcesContent":["import {\n encodeFunctionData,\n serializeTransaction,\n type Abi,\n type Address,\n type ContractFunctionArgs,\n type ContractFunctionName,\n type ContractFunctionReturnType,\n type Hex,\n type PublicClient,\n} from \"viem\";\nimport { TransactionRevertedError } from \"../errors\";\nimport type {\n ContractAbi,\n GenericProvider,\n ReadContractConfig,\n TransactionReceipt,\n WriteContractArgs,\n WriteContractConfig,\n WriteFunctionName,\n} from \"../types\";\n\n/** Configuration for {@link ViemProvider}. */\nexport interface ViemProviderConfig {\n /** A viem `PublicClient` backing all read operations. */\n publicClient: PublicClient;\n}\n\n/**\n * Read-only {@link GenericProvider} backed by a viem `PublicClient`.\n *\n * Use this for integrations that only need public chain reads before the user has Pair with a\n * {@link ViemSigner} when wallet authority is required; the two can share a transport or point at\n * independent RPCs.\n *\n * @example\n * ```ts\n * const publicClient = createPublicClient({ chain: sepolia, transport: http(ALCHEMY_URL) });\n * const provider = new ViemProvider({ publicClient });\n * ```\n */\nexport class ViemProvider implements GenericProvider {\n readonly #publicClient: PublicClient;\n\n constructor(config: ViemProviderConfig) {\n this.#publicClient = config.publicClient;\n }\n\n /** Return the chain ID of the connected network. */\n async getChainId(): Promise<number> {\n return this.#publicClient.getChainId();\n }\n\n /** Execute a read-only call and return the decoded result. */\n async readContract<\n const TAbi extends Abi | readonly unknown[],\n TFunctionName extends ContractFunctionName<TAbi, \"pure\" | \"view\">,\n const TArgs extends ContractFunctionArgs<TAbi, \"pure\" | \"view\", TFunctionName>,\n >(\n config: ReadContractConfig<TAbi, TFunctionName, TArgs>,\n ): Promise<ContractFunctionReturnType<TAbi, \"pure\" | \"view\", TFunctionName, TArgs>> {\n return this.#publicClient.readContract(config);\n }\n\n /** Wait for a transaction to be mined and return its receipt. */\n async waitForTransactionReceipt(hash: Hex): Promise<TransactionReceipt> {\n return this.#publicClient.waitForTransactionReceipt({ hash });\n }\n\n /** Return the latest block timestamp in seconds. */\n async getBlockTimestamp(): Promise<bigint> {\n const block = await this.#publicClient.getBlock();\n return block.timestamp;\n }\n\n /** Build a fully-populated, RLP-encoded unsigned transaction ready to be signed offline. */\n async prepareTransaction<\n const TAbi extends ContractAbi,\n TFunctionName extends WriteFunctionName<TAbi>,\n const TArgs extends WriteContractArgs<TAbi, TFunctionName>,\n >(args: {\n from: Address;\n calldata: WriteContractConfig<TAbi, TFunctionName, TArgs>;\n nonce?: number;\n gasLimit?: bigint;\n fees?: { maxFeePerGas: bigint; maxPriorityFeePerGas: bigint };\n }): Promise<Hex> {\n const { from, calldata } = args;\n const data = encodeFunctionData({\n abi: calldata.abi as Abi,\n functionName: calldata.functionName as string,\n args: calldata.args as readonly unknown[],\n });\n // Wrap the estimateGas leg so a pre-flight revert (the most common\n // prepareTransaction failure) surfaces as a typed error with the\n // function name + cause. Other legs propagate as-is — failures there\n // (chainId, nonce, fee data) are rare and usually self-explanatory.\n // Skip the network round-trips entirely when the caller supplied\n // overrides — useful for custodians with their own nonce/fee managers.\n const chainIdPromise = this.#publicClient.getChainId();\n const noncePromise =\n args.nonce !== undefined\n ? Promise.resolve(args.nonce)\n : this.#publicClient.getTransactionCount({ address: from, blockTag: \"pending\" });\n const gasPromise =\n args.gasLimit !== undefined\n ? Promise.resolve(args.gasLimit)\n : (calldata.gas ??\n this.#publicClient\n .estimateGas({ account: from, to: calldata.address, data, value: calldata.value ?? 0n })\n .catch((error: unknown) => {\n throw new TransactionRevertedError(\n `ViemProvider.prepareTransaction: gas estimation reverted for ${calldata.functionName} on ${calldata.address}`,\n { cause: error },\n );\n }));\n const feesPromise = args.fees ?? this.#publicClient.estimateFeesPerGas();\n const [chainId, nonce, gas, fees] = await Promise.all([\n chainIdPromise,\n noncePromise,\n gasPromise,\n feesPromise,\n ]);\n return serializeTransaction({\n type: \"eip1559\",\n chainId,\n nonce,\n to: calldata.address,\n data,\n value: calldata.value ?? 0n,\n gas,\n maxFeePerGas: fees.maxFeePerGas,\n maxPriorityFeePerGas: fees.maxPriorityFeePerGas,\n });\n }\n}\n","import type {\n Account,\n Abi,\n ContractFunctionArgs,\n ContractFunctionName,\n EIP1193Provider,\n WalletClient,\n Hex,\n} from \"viem\";\nimport { getAddress } from \"viem\";\nimport type { writeContract } from \"viem/actions\";\nimport { WalletNotConnectedError } from \"../errors\";\nimport type { EIP712TypedData } from \"../relayer/types\";\nimport { BaseSigner } from \"../signer/base-signer\";\nimport { eip1193Subscribe } from \"../signer/eip1193-subscribe\";\nimport type { WalletAccount, WriteContractConfig } from \"../types\";\nimport { toViemTypedData } from \"./typed-data\";\n\n/**\n * Configuration for {@link ViemSigner}.\n *\n * The optional `ethereum` field is needed for `subscribe()` (EIP-1193\n * `accountsChanged` / `disconnect` events). It cannot be auto-extracted from\n * `walletClient` because viem's `custom(ethereum)` transport captures the\n * provider in a closure and does **not** expose `on` / `removeListener` on\n * `walletClient.transport`.\n *\n * If you omit `ethereum`, `subscribe()` returns a no-op. For automatic\n * wallet lifecycle handling, consider using `WagmiSigner` instead.\n */\nexport interface ViemSignerConfig {\n /** Wallet client for signing and write operations. */\n walletClient: WalletClient;\n /** Raw EIP-1193 provider enabling wallet lifecycle events; omit for a no-op `subscribe()`. */\n ethereum?: EIP1193Provider;\n}\n\nfunction walletAccountFromWalletClient(walletClient: WalletClient): WalletAccount | undefined {\n if (!walletClient.account || !walletClient.chain) {\n return undefined;\n }\n const address = getAddress(walletClient.account.address);\n return { address, chainId: walletClient.chain.id };\n}\n\n/**\n * {@link GenericSigner} backed by a viem `WalletClient` for EIP-712 signing and\n * write transactions. Pass `ethereum` in {@link ViemSignerConfig} to track\n * wallet lifecycle events.\n */\nexport class ViemSigner extends BaseSigner {\n readonly #walletClient: WalletClient;\n readonly #ethereum?: EIP1193Provider;\n readonly #unsubscribeProvider: () => void;\n\n constructor(config: ViemSignerConfig) {\n super(walletAccountFromWalletClient(config.walletClient));\n this.#walletClient = config.walletClient;\n this.#ethereum = config.ethereum;\n this.#unsubscribeProvider = this.#subscribeToProvider();\n }\n\n #requireAccount(operation: string): { walletClient: WalletClient; account: Account } {\n if (!this.#walletClient.account) {\n throw new WalletNotConnectedError(operation);\n }\n return { walletClient: this.#walletClient, account: this.#walletClient.account };\n }\n\n /** Sign EIP-712 typed data (used for decrypt authorization). */\n async signTypedData(typedData: EIP712TypedData): Promise<Hex> {\n const { walletClient, account } = this.#requireAccount(\"signTypedData\");\n return walletClient.signTypedData({ account, ...toViemTypedData(typedData) });\n }\n\n /** Send a write transaction and return the tx hash. */\n async writeContract<\n const TAbi extends Abi | readonly unknown[],\n TFunctionName extends ContractFunctionName<TAbi, \"nonpayable\" | \"payable\">,\n const TArgs extends ContractFunctionArgs<TAbi, \"nonpayable\" | \"payable\", TFunctionName>,\n >(config: WriteContractConfig<TAbi, TFunctionName, TArgs>): Promise<Hex> {\n const { walletClient, account } = this.#requireAccount(\"writeContract\");\n return walletClient.writeContract({\n chain: walletClient.chain,\n account,\n ...config,\n } as Parameters<typeof writeContract>[1]);\n }\n\n #subscribeToProvider(): () => void {\n if (!this.#ethereum) {\n return () => {};\n }\n return eip1193Subscribe({\n provider: this.#ethereum,\n getInitialWalletAccount: () => walletAccountFromWalletClient(this.#walletClient),\n onWalletAccountChange: ({ next }) => {\n this.walletAccount.setSnapshot(next);\n },\n });\n }\n\n /** Unsubscribe from the EIP-1193 provider's wallet lifecycle events. */\n protected override onDispose(): void {\n this.#unsubscribeProvider();\n }\n}\n","import type { FheChain } from \"../chains\";\nimport type { ZamaConfig } from \"../config/types\";\nimport { buildZamaConfig } from \"../config/build\";\nimport { ViemProvider } from \"./viem-provider\";\nimport { ViemSigner } from \"./viem-signer\";\nimport type { ZamaConfigViem } from \"./types\";\n\n/** Create a {@link ZamaConfig} from viem clients. */\nexport function createConfig<const TChains extends readonly [FheChain, ...FheChain[]]>(\n params: ZamaConfigViem<TChains>,\n): ZamaConfig {\n const signer = new ViemSigner({ walletClient: params.walletClient, ethereum: params.ethereum });\n const provider = new ViemProvider({ publicClient: params.publicClient });\n return buildZamaConfig(signer, provider, params);\n}\n","import type { PublicClient, WalletClient, Address, Hex } from \"viem\";\nimport type { EncryptedValue } from \"../relayer/types\";\nimport {\n confidentialBalanceOfContract,\n confidentialTransferContract,\n finalizeUnwrapContract,\n setOperatorContract,\n supportsInterfaceContract,\n underlyingContract,\n unwrapContract,\n unwrapFromBalanceContract,\n wrapContract,\n getTokenPairsContract,\n getTokenPairsLengthContract,\n getTokenPairsSliceContract,\n getTokenPairContract,\n getConfidentialTokenAddressContract,\n getTokenAddressContract,\n isConfidentialTokenValidContract,\n} from \"../contracts\";\n\n// ── Helpers ────────────────────────────────────────────────\n\nfunction requireAccount(client: WalletClient) {\n if (!client.account) {\n throw new TypeError(\"WalletClient has no account\");\n }\n return client.account;\n}\n\n// ── Read helpers ────────────────────────────────────────────\n\n/** Reads a token's confidential (encrypted) balance handle for `userAddress` via a viem client. */\nexport function readConfidentialBalanceOfContract(\n client: PublicClient,\n tokenAddress: Address,\n userAddress: Address,\n) {\n return client.readContract(confidentialBalanceOfContract(tokenAddress, userAddress));\n}\n\n/** Reads the underlying ERC-20 address wrapped by a confidential wrapper via a viem client. */\nexport function readUnderlyingTokenContract(client: PublicClient, wrapperAddress: Address) {\n return client.readContract(underlyingContract(wrapperAddress));\n}\n\n/** Reads whether a token implements the given ERC-165 interface id via a viem client. */\nexport function readSupportsInterfaceContract(\n client: PublicClient,\n tokenAddress: Address,\n interfaceId: Address,\n) {\n return client.readContract(supportsInterfaceContract(tokenAddress, interfaceId));\n}\n\n// ── Write helpers ───────────────────────────────────────────\n\n/** Submits a confidential transfer of an encrypted amount to `to` via a viem wallet client. */\nexport function writeConfidentialTransferContract(\n client: WalletClient,\n tokenAddress: Address,\n to: Address,\n encryptedAmount: EncryptedValue,\n inputProof: Hex,\n) {\n return client.writeContract({\n chain: client.chain,\n account: requireAccount(client),\n ...confidentialTransferContract(tokenAddress, to, encryptedAmount, inputProof),\n });\n}\n\n/** Submits an unwrap of an encrypted amount from `from` to `to` on a confidential ERC-20 via a viem wallet client. */\nexport function writeUnwrapContract(\n client: WalletClient,\n encryptedErc20: Address,\n from: Address,\n to: Address,\n encryptedAmount: EncryptedValue,\n inputProof: Hex,\n) {\n return client.writeContract({\n chain: client.chain,\n account: requireAccount(client),\n ...unwrapContract(encryptedErc20, from, to, encryptedAmount, inputProof),\n });\n}\n\n/** Submits an unwrap of the full encrypted balance from `from` to `to` via a viem wallet client. */\nexport function writeUnwrapFromBalanceContract(\n client: WalletClient,\n encryptedErc20: Address,\n from: Address,\n to: Address,\n encryptedBalance: EncryptedValue,\n) {\n return client.writeContract({\n chain: client.chain,\n account: requireAccount(client),\n ...unwrapFromBalanceContract(encryptedErc20, from, to, encryptedBalance),\n });\n}\n\n/** Finalizes a pending unwrap request with the decrypted amount and decryption proof via a viem wallet client. */\nexport function writeFinalizeUnwrapContract(\n client: WalletClient,\n wrapper: Address,\n unwrapRequestId: EncryptedValue,\n unwrapAmountCleartext: bigint,\n decryptionProof: Hex,\n) {\n return client.writeContract({\n chain: client.chain,\n account: requireAccount(client),\n ...finalizeUnwrapContract(wrapper, unwrapRequestId, unwrapAmountCleartext, decryptionProof),\n });\n}\n\n/** Authorizes `operator` on a token, until an optional expiry timestamp, via a viem wallet client. */\nexport function writeSetOperatorContract(\n client: WalletClient,\n tokenAddress: Address,\n operator: Address,\n until?: number,\n) {\n return client.writeContract({\n chain: client.chain,\n account: requireAccount(client),\n ...setOperatorContract(tokenAddress, operator, until),\n });\n}\n\n/** Wraps `amount` of the underlying ERC-20 into confidential tokens credited to `to` via a viem wallet client. */\nexport function writeWrapContract(\n client: WalletClient,\n wrapperAddress: Address,\n to: Address,\n amount: bigint,\n) {\n return client.writeContract({\n chain: client.chain,\n account: requireAccount(client),\n ...wrapContract(wrapperAddress, to, amount),\n });\n}\n\n// ── Registry read helpers ──────────────────────────────────\n\n/** Reads all underlying/confidential token pairs from a wrappers registry via a viem client. */\nexport function readTokenPairsContract(client: PublicClient, registry: Address) {\n return client.readContract(getTokenPairsContract(registry));\n}\n\n/** Reads the number of token pairs in a wrappers registry via a viem client. */\nexport function readTokenPairsLengthContract(client: PublicClient, registry: Address) {\n return client.readContract(getTokenPairsLengthContract(registry));\n}\n\n/** Reads a slice of token pairs (`fromIndex` to `toIndex`) from a wrappers registry via a viem client. */\nexport function readTokenPairsSliceContract(\n client: PublicClient,\n registry: Address,\n fromIndex: bigint,\n toIndex: bigint,\n) {\n return client.readContract(getTokenPairsSliceContract(registry, fromIndex, toIndex));\n}\n\n/** Reads the token pair at `index` from a wrappers registry via a viem client. */\nexport function readTokenPairContract(client: PublicClient, registry: Address, index: bigint) {\n return client.readContract(getTokenPairContract(registry, index));\n}\n\n/** Reads the confidential token registered for a given underlying token in a wrappers registry via a viem client. */\nexport function readConfidentialTokenAddressContract(\n client: PublicClient,\n registry: Address,\n tokenAddress: Address,\n) {\n return client.readContract(getConfidentialTokenAddressContract(registry, tokenAddress));\n}\n\n/** Reads the underlying token registered for a given confidential token in a wrappers registry via a viem client. */\nexport function readTokenAddressContract(\n client: PublicClient,\n registry: Address,\n confidentialTokenAddress: Address,\n) {\n return client.readContract(getTokenAddressContract(registry, confidentialTokenAddress));\n}\n\n/** Reads whether a confidential token is registered and valid in a wrappers registry via a viem client. */\nexport function readIsConfidentialTokenValidContract(\n client: PublicClient,\n registry: Address,\n confidentialTokenAddress: Address,\n) {\n return client.readContract(isConfidentialTokenValidContract(registry, confidentialTokenAddress));\n}\n"],"mappings":"gaAyCA,IAAa,EAAb,KAAqD,CACnD,GAEA,YAAY,EAA4B,CACtC,KAAKA,GAAgB,EAAO,YAC9B,CAGA,MAAM,YAA8B,CAClC,OAAO,KAAKA,GAAc,WAAW,CACvC,CAGA,MAAM,aAKJ,EACkF,CAClF,OAAO,KAAKA,GAAc,aAAa,CAAM,CAC/C,CAGA,MAAM,0BAA0B,EAAwC,CACtE,OAAO,KAAKA,GAAc,0BAA0B,CAAE,MAAK,CAAC,CAC9D,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CAAQ,CAAC,CAClE,CAGA,SAAgB,EACd,EACA,EACA,EACA,EACA,CACA,OAAO,EAAO,aAAa,EAA2B,EAAU,EAAW,CAAO,CAAC,CACrF,CAGA,SAAgB,EAAsB,EAAsB,EAAmB,EAAe,CAC5F,OAAO,EAAO,aAAa,EAAqB,EAAU,CAAK,CAAC,CAClE,CAGA,SAAgB,EACd,EACA,EACA,EACA,CACA,OAAO,EAAO,aAAa,EAAoC,EAAU,CAAY,CAAC,CACxF,CAGA,SAAgB,EACd,EACA,EACA,EACA,CACA,OAAO,EAAO,aAAa,EAAwB,EAAU,CAAwB,CAAC,CACxF,CAGA,SAAgB,EACd,EACA,EACA,EACA,CACA,OAAO,EAAO,aAAa,EAAiC,EAAU,CAAwB,CAAC,CACjG"}
1
+ {"version":3,"file":"index.js","names":["underlyingContract","ZamaSDKEvents","wrapContract","WalletNotConnectedError","unwrapContract","unwrapFromBalanceContract","confidentialTransferContract","finalizeUnwrapContract","TransactionRevertedError","supportsInterfaceContract","setOperatorContract","requireReadChain","confidentialBalanceOfContract","buildZamaConfig","BaseSigner","eip1193Subscribe","toViemTypedData","getTokenPairsLengthContract","getTokenPairsContract","getTokenAddressContract","getTokenPairsSliceContract","getTokenPairContract","isConfidentialTokenValidContract","getConfidentialTokenAddressContract","ViemProvider","#publicClient","config","call","chainId","params","_","args","data","encodeFunctionData","calldata","chainIdPromise","noncePromise","from","gasPromise","error","feesPromise","nonce","gas","fees","serializeTransaction","walletAccountFromWalletClient","walletClient","getAddress","ViemSigner","#walletClient","#ethereum","#unsubscribeProvider","#subscribeToProvider","operation","#requireAccount","typedData","next","createConfig","signer","provider","requireAccount","client","readConfidentialBalanceOfContract","tokenAddress","userAddress","readUnderlyingTokenContract","wrapperAddress","readSupportsInterfaceContract","interfaceId","writeConfidentialTransferContract","to","encryptedAmount","inputProof","writeUnwrapContract","encryptedErc20","writeUnwrapFromBalanceContract","encryptedBalance","writeFinalizeUnwrapContract","wrapper","unwrapRequestId","unwrapAmountCleartext","decryptionProof","writeSetOperatorContract","operator","until","writeWrapContract","amount","readTokenPairsContract","registry","readTokenPairsLengthContract","readTokenPairsSliceContract","fromIndex","toIndex","readTokenPairContract","index","readConfidentialTokenAddressContract","readTokenAddressContract","confidentialTokenAddress","readIsConfidentialTokenValidContract"],"sources":["../../../src/viem/viem-provider.ts","../../../src/viem/viem-signer.ts","../../../src/viem/config.ts","../../../src/viem/contracts.ts"],"sourcesContent":["import {\n encodeFunctionData,\n serializeTransaction,\n type Abi,\n type Address,\n type ContractFunctionArgs,\n type ContractFunctionName,\n type ContractFunctionReturnType,\n type Hex,\n type PublicClient,\n} from \"viem\";\nimport { TransactionRevertedError } from \"../errors\";\nimport type {\n ContractAbi,\n GenericProvider,\n MulticallReturnType,\n ReadContractConfig,\n TransactionReceipt,\n WriteContractArgs,\n WriteContractConfig,\n WriteFunctionName,\n} from \"../types\";\nimport { requireReadChain } from \"../utils/alignment\";\n\n/** Configuration for {@link ViemProvider}. */\nexport interface ViemProviderConfig {\n /** A viem `PublicClient` backing all read operations. */\n publicClient: PublicClient;\n}\n\n/**\n * Read-only {@link GenericProvider} backed by a viem `PublicClient`.\n *\n * Use this for integrations that only need public chain reads before the user has Pair with a\n * {@link ViemSigner} when wallet authority is required; the two can share a transport or point at\n * independent RPCs.\n *\n * @example\n * ```ts\n * const publicClient = createPublicClient({ chain: sepolia, transport: http(ALCHEMY_URL) });\n * const provider = new ViemProvider({ publicClient });\n * ```\n */\nexport class ViemProvider implements GenericProvider {\n readonly #publicClient: PublicClient;\n\n constructor(config: ViemProviderConfig) {\n this.#publicClient = config.publicClient;\n }\n\n /** Return the chain ID of the connected network. */\n async getChainId(): Promise<number> {\n return this.#publicClient.getChainId();\n }\n\n /** Execute a read-only call and return the decoded result. */\n async readContract<\n const TAbi extends Abi | readonly unknown[],\n TFunctionName extends ContractFunctionName<TAbi, \"pure\" | \"view\">,\n const TArgs extends ContractFunctionArgs<TAbi, \"pure\" | \"view\", TFunctionName>,\n >(\n config: ReadContractConfig<TAbi, TFunctionName, TArgs>,\n ): Promise<ContractFunctionReturnType<TAbi, \"pure\" | \"view\", TFunctionName, TArgs>> {\n const { chainId, ...call } = config;\n await requireReadChain(\"ViemProvider\", chainId, () => this.getChainId());\n return this.#publicClient.readContract(call as typeof config);\n }\n\n /**\n * Run many reads in one Multicall3 call. On a chain whose viem definition\n * names no Multicall3, such as a local Hardhat node, the call carries its code.\n */\n async multicall<const TCalls extends readonly ReadContractConfig[]>(params: {\n readonly calls: TCalls;\n readonly chainId?: number;\n }): Promise<MulticallReturnType<TCalls>> {\n await requireReadChain(\"ViemProvider\", params.chainId, () => this.getChainId());\n const results = await this.#publicClient.multicall({\n contracts: params.calls.map(({ chainId: _, ...call }) => call) as never,\n allowFailure: false,\n deployless: this.#publicClient.chain?.contracts?.multicall3 === undefined,\n });\n return results as MulticallReturnType<TCalls>;\n }\n\n /** Wait for a transaction to be mined and return its receipt. */\n async waitForTransactionReceipt(hash: Hex): Promise<TransactionReceipt> {\n return this.#publicClient.waitForTransactionReceipt({ hash });\n }\n\n /** Return the latest block timestamp in seconds. */\n async getBlockTimestamp(chainId?: number): Promise<bigint> {\n await requireReadChain(\"ViemProvider\", chainId, () => this.getChainId());\n const block = await this.#publicClient.getBlock();\n return block.timestamp;\n }\n\n /** Build a fully-populated, RLP-encoded unsigned transaction ready to be signed offline. */\n async prepareTransaction<\n const TAbi extends ContractAbi,\n TFunctionName extends WriteFunctionName<TAbi>,\n const TArgs extends WriteContractArgs<TAbi, TFunctionName>,\n >(args: {\n from: Address;\n calldata: WriteContractConfig<TAbi, TFunctionName, TArgs>;\n nonce?: number;\n gasLimit?: bigint;\n fees?: { maxFeePerGas: bigint; maxPriorityFeePerGas: bigint };\n }): Promise<Hex> {\n const { from, calldata } = args;\n const data = encodeFunctionData({\n abi: calldata.abi as Abi,\n functionName: calldata.functionName as string,\n args: calldata.args as readonly unknown[],\n });\n // Wrap the estimateGas leg so a pre-flight revert (the most common\n // prepareTransaction failure) surfaces as a typed error with the\n // function name + cause. Other legs propagate as-is — failures there\n // (chainId, nonce, fee data) are rare and usually self-explanatory.\n // Skip the network round-trips entirely when the caller supplied\n // overrides — useful for custodians with their own nonce/fee managers.\n const chainIdPromise = this.#publicClient.getChainId();\n const noncePromise =\n args.nonce !== undefined\n ? Promise.resolve(args.nonce)\n : this.#publicClient.getTransactionCount({ address: from, blockTag: \"pending\" });\n const gasPromise =\n args.gasLimit !== undefined\n ? Promise.resolve(args.gasLimit)\n : (calldata.gas ??\n this.#publicClient\n .estimateGas({ account: from, to: calldata.address, data, value: calldata.value ?? 0n })\n .catch((error: unknown) => {\n throw new TransactionRevertedError(\n `ViemProvider.prepareTransaction: gas estimation reverted for ${calldata.functionName} on ${calldata.address}`,\n { cause: error },\n );\n }));\n const feesPromise = args.fees ?? this.#publicClient.estimateFeesPerGas();\n const [chainId, nonce, gas, fees] = await Promise.all([\n chainIdPromise,\n noncePromise,\n gasPromise,\n feesPromise,\n ]);\n return serializeTransaction({\n type: \"eip1559\",\n chainId,\n nonce,\n to: calldata.address,\n data,\n value: calldata.value ?? 0n,\n gas,\n maxFeePerGas: fees.maxFeePerGas,\n maxPriorityFeePerGas: fees.maxPriorityFeePerGas,\n });\n }\n}\n","import type {\n Account,\n Abi,\n ContractFunctionArgs,\n ContractFunctionName,\n EIP1193Provider,\n WalletClient,\n Hex,\n} from \"viem\";\nimport { getAddress } from \"viem\";\nimport type { writeContract } from \"viem/actions\";\nimport { WalletNotConnectedError } from \"../errors\";\nimport type { EIP712TypedData } from \"../relayer/types\";\nimport { BaseSigner } from \"../signer/base-signer\";\nimport { eip1193Subscribe } from \"../signer/eip1193-subscribe\";\nimport type { WalletAccount, WriteContractConfig } from \"../types\";\nimport { toViemTypedData } from \"./typed-data\";\n\n/**\n * Configuration for {@link ViemSigner}.\n *\n * The optional `ethereum` field is needed for `subscribe()` (EIP-1193\n * `accountsChanged` / `disconnect` events). It cannot be auto-extracted from\n * `walletClient` because viem's `custom(ethereum)` transport captures the\n * provider in a closure and does **not** expose `on` / `removeListener` on\n * `walletClient.transport`.\n *\n * If you omit `ethereum`, `subscribe()` returns a no-op. For automatic\n * wallet lifecycle handling, consider using `WagmiSigner` instead.\n */\nexport interface ViemSignerConfig {\n /** Wallet client for signing and write operations. */\n walletClient: WalletClient;\n /** Raw EIP-1193 provider enabling wallet lifecycle events; omit for a no-op `subscribe()`. */\n ethereum?: EIP1193Provider;\n}\n\nfunction walletAccountFromWalletClient(walletClient: WalletClient): WalletAccount | undefined {\n if (!walletClient.account || !walletClient.chain) {\n return undefined;\n }\n const address = getAddress(walletClient.account.address);\n return { address, chainId: walletClient.chain.id };\n}\n\n/**\n * {@link GenericSigner} backed by a viem `WalletClient` for EIP-712 signing and\n * write transactions. Pass `ethereum` in {@link ViemSignerConfig} to track\n * wallet lifecycle events.\n */\nexport class ViemSigner extends BaseSigner {\n readonly #walletClient: WalletClient;\n readonly #ethereum?: EIP1193Provider;\n readonly #unsubscribeProvider: () => void;\n\n constructor(config: ViemSignerConfig) {\n super(walletAccountFromWalletClient(config.walletClient));\n this.#walletClient = config.walletClient;\n this.#ethereum = config.ethereum;\n this.#unsubscribeProvider = this.#subscribeToProvider();\n }\n\n #requireAccount(operation: string): { walletClient: WalletClient; account: Account } {\n if (!this.#walletClient.account) {\n throw new WalletNotConnectedError(operation);\n }\n return { walletClient: this.#walletClient, account: this.#walletClient.account };\n }\n\n /** Sign EIP-712 typed data (used for decrypt authorization). */\n async signTypedData(typedData: EIP712TypedData): Promise<Hex> {\n const { walletClient, account } = this.#requireAccount(\"signTypedData\");\n return walletClient.signTypedData({ account, ...toViemTypedData(typedData) });\n }\n\n /** Send a write transaction and return the tx hash. */\n async writeContract<\n const TAbi extends Abi | readonly unknown[],\n TFunctionName extends ContractFunctionName<TAbi, \"nonpayable\" | \"payable\">,\n const TArgs extends ContractFunctionArgs<TAbi, \"nonpayable\" | \"payable\", TFunctionName>,\n >(config: WriteContractConfig<TAbi, TFunctionName, TArgs>): Promise<Hex> {\n const { walletClient, account } = this.#requireAccount(\"writeContract\");\n return walletClient.writeContract({\n chain: walletClient.chain,\n account,\n ...config,\n } as Parameters<typeof writeContract>[1]);\n }\n\n #subscribeToProvider(): () => void {\n if (!this.#ethereum) {\n return () => {};\n }\n return eip1193Subscribe({\n provider: this.#ethereum,\n getInitialWalletAccount: () => walletAccountFromWalletClient(this.#walletClient),\n onWalletAccountChange: ({ next }) => {\n this.walletAccount.setSnapshot(next);\n },\n });\n }\n\n /** Unsubscribe from the EIP-1193 provider's wallet lifecycle events. */\n protected override onDispose(): void {\n this.#unsubscribeProvider();\n }\n}\n","import type { FheChain } from \"../chains\";\nimport type { ZamaConfig } from \"../config/types\";\nimport { buildZamaConfig } from \"../config/build\";\nimport { ViemProvider } from \"./viem-provider\";\nimport { ViemSigner } from \"./viem-signer\";\nimport type { ZamaConfigViem } from \"./types\";\n\n/** Create a {@link ZamaConfig} from viem clients. */\nexport function createConfig<const TChains extends readonly [FheChain, ...FheChain[]]>(\n params: ZamaConfigViem<TChains>,\n): ZamaConfig {\n const signer = new ViemSigner({ walletClient: params.walletClient, ethereum: params.ethereum });\n const provider = new ViemProvider({ publicClient: params.publicClient });\n return buildZamaConfig(signer, provider, params);\n}\n","import type { PublicClient, WalletClient, Address, Hex } from \"viem\";\nimport type { EncryptedValue } from \"../relayer/types\";\nimport {\n confidentialBalanceOfContract,\n confidentialTransferContract,\n finalizeUnwrapContract,\n setOperatorContract,\n supportsInterfaceContract,\n underlyingContract,\n unwrapContract,\n unwrapFromBalanceContract,\n wrapContract,\n getTokenPairsContract,\n getTokenPairsLengthContract,\n getTokenPairsSliceContract,\n getTokenPairContract,\n getConfidentialTokenAddressContract,\n getTokenAddressContract,\n isConfidentialTokenValidContract,\n} from \"../contracts\";\n\n// ── Helpers ────────────────────────────────────────────────\n\nfunction requireAccount(client: WalletClient) {\n if (!client.account) {\n throw new TypeError(\"WalletClient has no account\");\n }\n return client.account;\n}\n\n// ── Read helpers ────────────────────────────────────────────\n\n/** Reads a token's confidential (encrypted) balance handle for `userAddress` via a viem client. */\nexport function readConfidentialBalanceOfContract(\n client: PublicClient,\n tokenAddress: Address,\n userAddress: Address,\n) {\n return client.readContract(confidentialBalanceOfContract(tokenAddress, userAddress));\n}\n\n/** Reads the underlying ERC-20 address wrapped by a confidential wrapper via a viem client. */\nexport function readUnderlyingTokenContract(client: PublicClient, wrapperAddress: Address) {\n return client.readContract(underlyingContract(wrapperAddress));\n}\n\n/** Reads whether a token implements the given ERC-165 interface id via a viem client. */\nexport function readSupportsInterfaceContract(\n client: PublicClient,\n tokenAddress: Address,\n interfaceId: Address,\n) {\n return client.readContract(supportsInterfaceContract(tokenAddress, interfaceId));\n}\n\n// ── Write helpers ───────────────────────────────────────────\n\n/** Submits a confidential transfer of an encrypted amount to `to` via a viem wallet client. */\nexport function writeConfidentialTransferContract(\n client: WalletClient,\n tokenAddress: Address,\n to: Address,\n encryptedAmount: EncryptedValue,\n inputProof: Hex,\n) {\n return client.writeContract({\n chain: client.chain,\n account: requireAccount(client),\n ...confidentialTransferContract(tokenAddress, to, encryptedAmount, inputProof),\n });\n}\n\n/** Submits an unwrap of an encrypted amount from `from` to `to` on a confidential ERC-20 via a viem wallet client. */\nexport function writeUnwrapContract(\n client: WalletClient,\n encryptedErc20: Address,\n from: Address,\n to: Address,\n encryptedAmount: EncryptedValue,\n inputProof: Hex,\n) {\n return client.writeContract({\n chain: client.chain,\n account: requireAccount(client),\n ...unwrapContract(encryptedErc20, from, to, encryptedAmount, inputProof),\n });\n}\n\n/** Submits an unwrap of the full encrypted balance from `from` to `to` via a viem wallet client. */\nexport function writeUnwrapFromBalanceContract(\n client: WalletClient,\n encryptedErc20: Address,\n from: Address,\n to: Address,\n encryptedBalance: EncryptedValue,\n) {\n return client.writeContract({\n chain: client.chain,\n account: requireAccount(client),\n ...unwrapFromBalanceContract(encryptedErc20, from, to, encryptedBalance),\n });\n}\n\n/** Finalizes a pending unwrap request with the decrypted amount and decryption proof via a viem wallet client. */\nexport function writeFinalizeUnwrapContract(\n client: WalletClient,\n wrapper: Address,\n unwrapRequestId: EncryptedValue,\n unwrapAmountCleartext: bigint,\n decryptionProof: Hex,\n) {\n return client.writeContract({\n chain: client.chain,\n account: requireAccount(client),\n ...finalizeUnwrapContract(wrapper, unwrapRequestId, unwrapAmountCleartext, decryptionProof),\n });\n}\n\n/** Authorizes `operator` on a token, until an optional expiry timestamp, via a viem wallet client. */\nexport function writeSetOperatorContract(\n client: WalletClient,\n tokenAddress: Address,\n operator: Address,\n until?: number,\n) {\n return client.writeContract({\n chain: client.chain,\n account: requireAccount(client),\n ...setOperatorContract(tokenAddress, operator, until),\n });\n}\n\n/** Wraps `amount` of the underlying ERC-20 into confidential tokens credited to `to` via a viem wallet client. */\nexport function writeWrapContract(\n client: WalletClient,\n wrapperAddress: Address,\n to: Address,\n amount: bigint,\n) {\n return client.writeContract({\n chain: client.chain,\n account: requireAccount(client),\n ...wrapContract(wrapperAddress, to, amount),\n });\n}\n\n// ── Registry read helpers ──────────────────────────────────\n\n/** Reads all underlying/confidential token pairs from a wrappers registry via a viem client. */\nexport function readTokenPairsContract(client: PublicClient, registry: Address) {\n return client.readContract(getTokenPairsContract(registry));\n}\n\n/** Reads the number of token pairs in a wrappers registry via a viem client. */\nexport function readTokenPairsLengthContract(client: PublicClient, registry: Address) {\n return client.readContract(getTokenPairsLengthContract(registry));\n}\n\n/** Reads a slice of token pairs (`fromIndex` to `toIndex`) from a wrappers registry via a viem client. */\nexport function readTokenPairsSliceContract(\n client: PublicClient,\n registry: Address,\n fromIndex: bigint,\n toIndex: bigint,\n) {\n return client.readContract(getTokenPairsSliceContract(registry, fromIndex, toIndex));\n}\n\n/** Reads the token pair at `index` from a wrappers registry via a viem client. */\nexport function readTokenPairContract(client: PublicClient, registry: Address, index: bigint) {\n return client.readContract(getTokenPairContract(registry, index));\n}\n\n/** Reads the confidential token registered for a given underlying token in a wrappers registry via a viem client. */\nexport function readConfidentialTokenAddressContract(\n client: PublicClient,\n registry: Address,\n tokenAddress: Address,\n) {\n return client.readContract(getConfidentialTokenAddressContract(registry, tokenAddress));\n}\n\n/** Reads the underlying token registered for a given confidential token in a wrappers registry via a viem client. */\nexport function readTokenAddressContract(\n client: PublicClient,\n registry: Address,\n confidentialTokenAddress: Address,\n) {\n return client.readContract(getTokenAddressContract(registry, confidentialTokenAddress));\n}\n\n/** Reads whether a confidential token is registered and valid in a wrappers registry via a viem client. */\nexport function readIsConfidentialTokenValidContract(\n client: PublicClient,\n registry: Address,\n confidentialTokenAddress: Address,\n) {\n return client.readContract(isConfidentialTokenValidContract(registry, confidentialTokenAddress));\n}\n"],"mappings":"A,6cA2CA,IAAawB,EAAb,KAAqD,CACnD,GAEA,YAAY,EAA4B,CACtC,KAAKC,GAAgBC,EAAO,YAC9B,CAGA,MAAM,YAA8B,CAClC,OAAO,KAAKD,GAAc,WAAW,CACvC,CAGA,MAAM,aAKJ,EACkF,CAClF,GAAM,CAAE,UAAS,GAAGE,GAASD,EAE7B,OADA,MAAMf,EAAiB,eAAgBiB,MAAe,KAAK,WAAW,CAAC,EAChE,KAAKH,GAAc,aAAaE,CAAqB,CAC9D,CAMA,MAAM,UAA8D,EAG3B,CAOvC,OANA,MAAMhB,EAAiB,eAAgBkB,EAAO,YAAe,KAAK,WAAW,CAAC,EAMvE,MALe,KAAKJ,GAAc,UAAU,CACjD,UAAWI,EAAO,MAAM,KAAK,CAAE,QAASC,EAAG,GAAGH,KAAWA,CAAI,EAC7D,aAAc,GACd,WAAY,KAAKF,GAAc,OAAO,WAAW,aAAe,IAAA,EAClE,CAAC,CAEH,CAGA,MAAM,0BAA0B,EAAwC,CACtE,OAAO,KAAKA,GAAc,0BAA0B,CAAE,MAAK,CAAC,CAC9D,CAGA,MAAM,kBAAkB,EAAmC,CAGzD,OAFA,MAAMd,EAAiB,eAAgBiB,MAAe,KAAK,WAAW,CAAC,GAEhE,MADa,KAAKH,GAAc,SAAS,EAAA,CACnC,SACf,CAGA,MAAM,m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A,SAAgBC,EAAuB,EAAsB,EAAmB,CAC9E,OAAO1B,EAAO,aAAa3C,EAAsBsE,CAAQ,CAAC,CAC5D,CAGA,SAAgBC,EAA6B,EAAsB,EAAmB,CACpF,OAAO5B,EAAO,aAAa5C,EAA4BuE,CAAQ,CAAC,CAClE,CAGA,SAAgBE,EACd,EACA,EACA,EACA,EACA,CACA,OAAO7B,EAAO,aAAazC,EAA2BoE,EAAUG,EAAWC,CAAO,CAAC,CACrF,CAGA,SAAgBC,EAAsB,EAAsB,EAAmB,EAAe,CAC5F,OAAOhC,EAAO,aAAaxC,EAAqBmE,EAAUM,CAAK,CAAC,CAClE,CAGA,SAAgBC,EACd,EACA,EACA,EACA,CACA,OAAOlC,EAAO,aAAatC,EAAoCiE,EAAUzB,CAAY,CAAC,CACxF,CAGA,SAAgBiC,EACd,EACA,EACA,EACA,CACA,OAAOnC,EAAO,aAAa1C,EAAwBqE,EAAUS,CAAwB,CAAC,CACxF,CAGA,SAAgBC,EACd,EACA,EACA,EACA,CACA,OAAOrC,EAAO,aAAavC,EAAiCkE,EAAUS,CAAwB,CAAC,CACjG,C"}
@@ -1,6 +1,14 @@
1
- import { dn as FhevmRelayerOptions, fn as FhevmRuntimeConfig, n as RelayerConfig, pn as RelayerOptions, r as WebRelayerConfig, un as FhevmClientOptions } from "../types-5ThXjdi3.js";
2
- import { t as EncryptWorkerTimeouts } from "../encrypt-worker-client-BlvStkvI.js";
3
- //#region src/config/web.d.ts
1
+ /**
2
+ * Browser transport for `@zama-fhe/sdk` — provides the {@link web} factory
3
+ * that drives `@fhevm/sdk`, offloading encryption to a Web Worker by default.
4
+ *
5
+ * Import from `@zama-fhe/sdk/web` to keep browser-only dependencies out of
6
+ * Node.js entry points.
7
+ *
8
+ * @packageDocumentation
9
+ */
10
+ import { dn as FhevmClientOptions, fn as FhevmRelayerOptions, mn as RelayerOptions, n as RelayerConfig, pn as FhevmRuntimeConfig, r as WebRelayerConfig } from "../types-Ubeo72FV.js";
11
+ import { t as EncryptWorkerTimeouts } from "../encrypt-worker-client-CkEIA0Tp.js";
4
12
  /** {@link RelayerOptions} plus the web-only encryption offload switches. */
5
13
  interface WebRelayerOptions extends RelayerOptions {
6
14
  /**
@@ -66,7 +74,5 @@ interface WebRelayerOptions extends RelayerOptions {
66
74
  * }
67
75
  * ```
68
76
  */
69
- declare function web(options?: WebRelayerOptions): WebRelayerConfig;
70
- //#endregion
71
- export { type EncryptWorkerTimeouts, type FhevmClientOptions, type FhevmRelayerOptions, type FhevmRuntimeConfig, type RelayerConfig, type RelayerOptions, type WebRelayerConfig, type WebRelayerOptions, web };
72
- //# sourceMappingURL=index.d.ts.map
77
+ export declare function web(options?: WebRelayerOptions): WebRelayerConfig;
78
+ export type { EncryptWorkerTimeouts, FhevmClientOptions, FhevmRelayerOptions, FhevmRuntimeConfig, RelayerConfig, RelayerOptions, WebRelayerConfig, WebRelayerOptions };
@@ -1,2 +1,2 @@
1
- import{r as e,t}from"../fhevm-relayer-Bq4dUHvo.js";import{t as n}from"../validation-ChQwNxaY.js";import{z as r}from"zod/mini";const i=e=>r._default(r.number().check(r.positive()),e),a=r.custom(e=>typeof e==`function`),o=r.object({offloadEncrypt:r._default(r.union([r.literal(`auto`),r.boolean()]),`auto`),offloadTimeouts:r.optional(r.object({spawn:i(e.spawn),init:i(e.init)})),offloadWorker:r.optional(r.union([r.string().check(r.minLength(1)),r.instanceof(URL),a]))});function s(e){let{offloadEncrypt:r,offloadTimeouts:i,offloadWorker:a,...s}=e??{},c=n(o,{offloadEncrypt:r,offloadTimeouts:i,offloadWorker:a});return{type:`web`,createRelayer:(e,n,r)=>new t({chain:e,options:s,telemetry:r&&{state:r,runtime:`web`,mode:r.mode},offloadEncrypt:c.offloadEncrypt,offloadTimeouts:c.offloadTimeouts,offloadWorker:c.offloadWorker,logger:n})}}export{s as web};
1
+ import{r as e,t}from"../fhevm-relayer-D0Uio0ls.js";import{t as n}from"../validation-CZfDLOUh.js";import{z as r}from"zod/mini";const i=e=>r._default(r.number().check(r.positive()),e),a=r.custom(e=>typeof e==`function`),o=r.object({offloadEncrypt:r._default(r.union([r.literal(`auto`),r.boolean()]),`auto`),offloadTimeouts:r.optional(r.object({spawn:i(e.spawn),init:i(e.init)})),offloadWorker:r.optional(r.union([r.string().check(r.minLength(1)),r.instanceof(URL),a]))});function s(e){let{offloadEncrypt:r,offloadTimeouts:i,offloadWorker:a,...s}=e??{},c=n(o,{offloadEncrypt:r,offloadTimeouts:i,offloadWorker:a});return{type:`web`,createRelayer:(e,n,r)=>new t({chain:e,options:s,telemetry:r&&{state:r,runtime:`web`,mode:r.mode},offloadEncrypt:c.offloadEncrypt,offloadTimeouts:c.offloadTimeouts,offloadWorker:c.offloadWorker,logger:n})}}export{s as web};
2
2
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../../../src/config/web.ts"],"sourcesContent":["import { z } from \"zod/mini\";\nimport { FhevmRelayer } from \"../relayer/fhevm-relayer\";\nimport type { RelayerOptions } from \"../relayer/types\";\nimport { parseSchema } from \"../validation\";\nimport {\n DEFAULT_ENCRYPT_WORKER_TIMEOUTS,\n type EncryptWorkerTimeouts,\n} from \"../worker/encrypt-worker-client\";\nimport type { WebRelayerConfig } from \"./types\";\n\n/** {@link RelayerOptions} plus the web-only encryption offload switches. */\nexport interface WebRelayerOptions extends RelayerOptions {\n /**\n * Run encryption in a dedicated Web Worker so ZK proof generation never\n * blocks the page's main thread.\n *\n * - `\"auto\"` (the default) offloads when the environment can spawn module\n * workers, and falls back to the main thread when it can't (the worker\n * script fails to load, times out, or crashes), warning on the console.\n * - `true` requires the offload: the same failures reject the encryption\n * with `EncryptOffloadUnavailableError` instead of falling back.\n * The rejection happens on the first encryption, not at config time, so\n * server-side rendering is unaffected.\n * - `false` always encrypts on the calling thread.\n *\n * @defaultValue `\"auto\"`\n */\n readonly offloadEncrypt?: \"auto\" | boolean;\n /**\n * Watchdog deadlines for the encrypt worker's lifecycle steps, in\n * milliseconds. A missed deadline means the worker is presumed stuck: it\n * is discarded, and the operation falls back or rejects per the\n * `offloadEncrypt` setting. Individual encrypt operations are not watched; a\n * worker computing a ZK proof can run for as long as it needs.\n *\n * @defaultValue `{ spawn: 10_000, init: 300_000 }`\n */\n readonly offloadTimeouts?: Partial<EncryptWorkerTimeouts>;\n /**\n * Custom source for the encrypt worker, for bundlers or CSPs that the\n * built-in `new Worker(new URL(\"./encrypt.worker.js\", import.meta.url))`\n * spawn doesn't reach: Vite dev-mode pre-bundling and older webpack don't\n * always detect that pattern inside `node_modules`, and a strict\n * `worker-src` CSP may only allow a path the app itself serves.\n *\n * - A string or `URL`: spawned as `new Worker(source, options)` with the\n * SDK's own worker options. Same-origin rules apply, as for any worker\n * URL. Serve `dist/esm/encrypt.worker.js` from this package, copied into\n * your public/static directory.\n * - A factory `() => Worker`: called to obtain the worker; you own every\n * construction option. Write the `new Worker(new URL(...))` expression\n * in your own source so your bundler can detect and rewrite it natively.\n *\n * When absent, the SDK spawns its own bundled worker.\n *\n * @example\n * ```ts\n * web({ offloadWorker: \"/encrypt.worker.js\" })\n * web({ offloadWorker: () => new Worker(new URL(\"./workers/encrypt.js\", import.meta.url), { type: \"module\" }) })\n * ```\n */\n readonly offloadWorker?: string | URL | (() => Worker);\n}\n\nconst timeoutSchema = (fallback: number) => z._default(z.number().check(z.positive()), fallback);\nconst offloadWorkerFunction = z.custom<() => Worker>((v) => typeof v === \"function\");\nconst WebRelayerOptionsSchema = z.object({\n offloadEncrypt: z._default(z.union([z.literal(\"auto\"), z.boolean()]), \"auto\"),\n // Per-field defaults, so an explicit `{ spawn: undefined }` cannot overwrite\n // a default downstream.\n offloadTimeouts: z.optional(\n z.object({\n spawn: timeoutSchema(DEFAULT_ENCRYPT_WORKER_TIMEOUTS.spawn),\n init: timeoutSchema(DEFAULT_ENCRYPT_WORKER_TIMEOUTS.init),\n }),\n ),\n // Non-empty: `new Worker(\"\")` resolves to the document URL and fails as a\n // spawn error rather than as the configuration mistake it is.\n offloadWorker: z.optional(\n z.union([z.string().check(z.minLength(1)), z.instanceof(URL), offloadWorkerFunction]),\n ),\n});\n\n/**\n * Browser relayer, driving `@fhevm/sdk` via {@link FhevmRelayer} with\n * encryption offloaded to a Web Worker by default.\n *\n * @example\n * ```ts\n * relayers: {\n * [sepolia.id]: web({ timeout: 5 * 60_000 }),\n * [mainnet.id]: web({ batchRpcCalls: true, offloadEncrypt: false }),\n * }\n * ```\n */\nexport function web(options?: WebRelayerOptions): WebRelayerConfig {\n const { offloadEncrypt, offloadTimeouts, offloadWorker, ...relayerOptions } = options ?? {};\n const parsed = parseSchema(WebRelayerOptionsSchema, {\n offloadEncrypt,\n offloadTimeouts,\n offloadWorker,\n });\n return {\n type: \"web\",\n createRelayer: (chain, logger, telemetry) =>\n new FhevmRelayer({\n chain,\n options: relayerOptions,\n telemetry: telemetry && { state: telemetry, runtime: \"web\", mode: telemetry.mode },\n offloadEncrypt: parsed.offloadEncrypt,\n offloadTimeouts: parsed.offloadTimeouts,\n offloadWorker: parsed.offloadWorker,\n logger,\n }),\n };\n}\n"],"mappings":"8HAgEA,MAAM,EAAiB,GAAqB,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC,MAAM,EAAE,SAAS,CAAC,EAAG,CAAQ,EACzF,EAAwB,EAAE,OAAsB,GAAM,OAAO,GAAM,UAAU,EAC7E,EAA0B,EAAE,OAAO,CACvC,eAAgB,EAAE,SAAS,EAAE,MAAM,CAAC,EAAE,QAAQ,MAAM,EAAG,EAAE,QAAQ,CAAC,CAAC,EAAG,MAAM,EAG5E,gBAAiB,EAAE,SACjB,EAAE,OAAO,CACP,MAAO,EAAc,EAAgC,KAAK,EAC1D,KAAM,EAAc,EAAgC,IAAI,CAC1D,CAAC,CACH,EAGA,cAAe,EAAE,SACf,EAAE,MAAM,CAAC,EAAE,OAAO,CAAC,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC,EAAG,EAAE,WAAW,GAAG,EAAG,CAAqB,CAAC,CACtF,CACF,CAAC,EAcD,SAAgB,EAAI,EAA+C,CACjE,GAAM,CAAE,iBAAgB,kBAAiB,gBAAe,GAAG,GAAmB,GAAW,CAAC,EACpF,EAAS,EAAY,EAAyB,CAClD,iBACA,kBACA,eACF,CAAC,EACD,MAAO,CACL,KAAM,MACN,eAAgB,EAAO,EAAQ,IAC7B,IAAI,EAAa,CACf,QACA,QAAS,EACT,UAAW,GAAa,CAAE,MAAO,EAAW,QAAS,MAAO,KAAM,EAAU,IAAK,EACjF,eAAgB,EAAO,eACvB,gBAAiB,EAAO,gBACxB,cAAe,EAAO,cACtB,QACF,CAAC,CACL,CACF"}
1
+ {"version":3,"file":"index.js","names":["DEFAULT_ENCRYPT_WORKER_TIMEOUTS","parseSchema","timeoutSchema","z","fallback","offloadWorkerFunction","v","WebRelayerOptionsSchema","web","relayerOptions","options","parsed","FhevmRelayer","telemetry"],"sources":["../../../src/config/web.ts"],"sourcesContent":["import { z } from \"zod/mini\";\nimport { FhevmRelayer } from \"../relayer/fhevm-relayer\";\nimport type { RelayerOptions } from \"../relayer/types\";\nimport { parseSchema } from \"../validation\";\nimport {\n DEFAULT_ENCRYPT_WORKER_TIMEOUTS,\n type EncryptWorkerTimeouts,\n} from \"../worker/encrypt-worker-client\";\nimport type { WebRelayerConfig } from \"./types\";\n\n/** {@link RelayerOptions} plus the web-only encryption offload switches. */\nexport interface WebRelayerOptions extends RelayerOptions {\n /**\n * Run encryption in a dedicated Web Worker so ZK proof generation never\n * blocks the page's main thread.\n *\n * - `\"auto\"` (the default) offloads when the environment can spawn module\n * workers, and falls back to the main thread when it can't (the worker\n * script fails to load, times out, or crashes), warning on the console.\n * - `true` requires the offload: the same failures reject the encryption\n * with `EncryptOffloadUnavailableError` instead of falling back.\n * The rejection happens on the first encryption, not at config time, so\n * server-side rendering is unaffected.\n * - `false` always encrypts on the calling thread.\n *\n * @defaultValue `\"auto\"`\n */\n readonly offloadEncrypt?: \"auto\" | boolean;\n /**\n * Watchdog deadlines for the encrypt worker's lifecycle steps, in\n * milliseconds. A missed deadline means the worker is presumed stuck: it\n * is discarded, and the operation falls back or rejects per the\n * `offloadEncrypt` setting. Individual encrypt operations are not watched; a\n * worker computing a ZK proof can run for as long as it needs.\n *\n * @defaultValue `{ spawn: 10_000, init: 300_000 }`\n */\n readonly offloadTimeouts?: Partial<EncryptWorkerTimeouts>;\n /**\n * Custom source for the encrypt worker, for bundlers or CSPs that the\n * built-in `new Worker(new URL(\"./encrypt.worker.js\", import.meta.url))`\n * spawn doesn't reach: Vite dev-mode pre-bundling and older webpack don't\n * always detect that pattern inside `node_modules`, and a strict\n * `worker-src` CSP may only allow a path the app itself serves.\n *\n * - A string or `URL`: spawned as `new Worker(source, options)` with the\n * SDK's own worker options. Same-origin rules apply, as for any worker\n * URL. Serve `dist/esm/encrypt.worker.js` from this package, copied into\n * your public/static directory.\n * - A factory `() => Worker`: called to obtain the worker; you own every\n * construction option. Write the `new Worker(new URL(...))` expression\n * in your own source so your bundler can detect and rewrite it natively.\n *\n * When absent, the SDK spawns its own bundled worker.\n *\n * @example\n * ```ts\n * web({ offloadWorker: \"/encrypt.worker.js\" })\n * web({ offloadWorker: () => new Worker(new URL(\"./workers/encrypt.js\", import.meta.url), { type: \"module\" }) })\n * ```\n */\n readonly offloadWorker?: string | URL | (() => Worker);\n}\n\nconst timeoutSchema = (fallback: number) => z._default(z.number().check(z.positive()), fallback);\nconst offloadWorkerFunction = z.custom<() => Worker>((v) => typeof v === \"function\");\nconst WebRelayerOptionsSchema = z.object({\n offloadEncrypt: z._default(z.union([z.literal(\"auto\"), z.boolean()]), \"auto\"),\n // Per-field defaults, so an explicit `{ spawn: undefined }` cannot overwrite\n // a default downstream.\n offloadTimeouts: z.optional(\n z.object({\n spawn: timeoutSchema(DEFAULT_ENCRYPT_WORKER_TIMEOUTS.spawn),\n init: timeoutSchema(DEFAULT_ENCRYPT_WORKER_TIMEOUTS.init),\n }),\n ),\n // Non-empty: `new Worker(\"\")` resolves to the document URL and fails as a\n // spawn error rather than as the configuration mistake it is.\n offloadWorker: z.optional(\n z.union([z.string().check(z.minLength(1)), z.instanceof(URL), offloadWorkerFunction]),\n ),\n});\n\n/**\n * Browser relayer, driving `@fhevm/sdk` via {@link FhevmRelayer} with\n * encryption offloaded to a Web Worker by default.\n *\n * @example\n * ```ts\n * relayers: {\n * [sepolia.id]: web({ timeout: 5 * 60_000 }),\n * [mainnet.id]: web({ batchRpcCalls: true, offloadEncrypt: false }),\n * }\n * ```\n */\nexport function web(options?: WebRelayerOptions): WebRelayerConfig {\n const { offloadEncrypt, offloadTimeouts, offloadWorker, ...relayerOptions } = options ?? {};\n const parsed = parseSchema(WebRelayerOptionsSchema, {\n offloadEncrypt,\n offloadTimeouts,\n offloadWorker,\n });\n return {\n type: \"web\",\n createRelayer: (chain, logger, telemetry) =>\n new FhevmRelayer({\n chain,\n options: relayerOptions,\n telemetry: telemetry && { state: telemetry, runtime: \"web\", mode: telemetry.mode },\n offloadEncrypt: parsed.offloadEncrypt,\n offloadTimeouts: parsed.offloadTimeouts,\n offloadWorker: parsed.offloadWorker,\n logger,\n }),\n };\n}\n"],"mappings":"A,8HAgEA,MAAME,EAAiB,GAAqBC,EAAE,SAASA,EAAE,OAAO,CAAC,CAAC,MAAMA,EAAE,SAAS,CAAC,EAAGC,CAAQ,EACzFC,EAAwBF,EAAE,OAAsB,GAAM,OAAOG,GAAM,UAAU,EAC7EC,EAA0BJ,EAAE,OAAO,CACvC,eAAgBA,EAAE,SAASA,EAAE,MAAM,CAACA,EAAE,QAAQ,MAAM,EAAGA,EAAE,QAAQ,CAAC,CAAC,EAAG,MAAM,EAG5E,gBAAiBA,EAAE,SACjBA,EAAE,OAAO,CACP,MAAOD,EAAcF,EAAgC,KAAK,EAC1D,KAAME,EAAcF,EAAgC,IAAI,CAC1D,CAAC,CACH,EAGA,cAAeG,EAAE,SACfA,EAAE,MAAM,CAACA,EAAE,OAAO,CAAC,CAAC,MAAMA,EAAE,UAAU,CAAC,CAAC,EAAGA,EAAE,WAAW,GAAG,EAAGE,CAAqB,CAAC,CACtF,CACF,CAAC,EAcD,SAAgBG,EAAI,EAA+C,CACjE,GAAM,CAAE,iBAAgB,kBAAiB,gBAAe,GAAGC,GAAmBC,GAAW,CAAC,EACpFC,EAASV,EAAYM,EAAyB,CAClD,iBACA,kBACA,eACF,CAAC,EACD,MAAO,CACL,KAAM,MACN,eAAgB,EAAO,EAAQ,IAC7B,IAAIK,EAAa,CACf,QACA,QAASH,EACT,UAAWI,GAAa,CAAE,MAAOA,EAAW,QAAS,MAAO,KAAMA,EAAU,IAAK,EACjF,eAAgBF,EAAO,eACvB,gBAAiBA,EAAO,gBACxB,cAAeA,EAAO,cACtB,QACF,CAAC,CACL,CACF,C"}
@@ -0,0 +1,2 @@
1
+ const e=[{inputs:[],name:`getTokenConfidentialTokenPairs`,outputs:[{components:[{internalType:`address`,name:`tokenAddress`,type:`address`},{internalType:`address`,name:`confidentialTokenAddress`,type:`address`},{internalType:`bool`,name:`isValid`,type:`bool`}],internalType:`struct ConfidentialTokenWrappersRegistry.TokenWrapperPair[]`,name:``,type:`tuple[]`}],stateMutability:`view`,type:`function`},{inputs:[],name:`getTokenConfidentialTokenPairsLength`,outputs:[{internalType:`uint256`,name:``,type:`uint256`}],stateMutability:`view`,type:`function`},{inputs:[{internalType:`uint256`,name:`fromIndex`,type:`uint256`},{internalType:`uint256`,name:`toIndex`,type:`uint256`}],name:`getTokenConfidentialTokenPairsSlice`,outputs:[{components:[{internalType:`address`,name:`tokenAddress`,type:`address`},{internalType:`address`,name:`confidentialTokenAddress`,type:`address`},{internalType:`bool`,name:`isValid`,type:`bool`}],internalType:`struct ConfidentialTokenWrappersRegistry.TokenWrapperPair[]`,name:``,type:`tuple[]`}],stateMutability:`view`,type:`function`},{inputs:[{internalType:`uint256`,name:`index`,type:`uint256`}],name:`getTokenConfidentialTokenPair`,outputs:[{components:[{internalType:`address`,name:`tokenAddress`,type:`address`},{internalType:`address`,name:`confidentialTokenAddress`,type:`address`},{internalType:`bool`,name:`isValid`,type:`bool`}],internalType:`struct ConfidentialTokenWrappersRegistry.TokenWrapperPair`,name:``,type:`tuple`}],stateMutability:`view`,type:`function`},{inputs:[{internalType:`address`,name:`tokenAddress`,type:`address`}],name:`getConfidentialTokenAddress`,outputs:[{internalType:`bool`,name:``,type:`bool`},{internalType:`address`,name:``,type:`address`}],stateMutability:`view`,type:`function`},{inputs:[{internalType:`address`,name:`confidentialTokenAddress`,type:`address`}],name:`getTokenAddress`,outputs:[{internalType:`bool`,name:``,type:`bool`},{internalType:`address`,name:``,type:`address`}],stateMutability:`view`,type:`function`},{inputs:[{internalType:`address`,name:`confidentialTokenAddress`,type:`address`}],name:`isConfidentialTokenValid`,outputs:[{internalType:`bool`,name:``,type:`bool`}],stateMutability:`view`,type:`function`},{inputs:[{internalType:`address`,name:`initialOwner`,type:`address`}],name:`initialize`,outputs:[],stateMutability:`nonpayable`,type:`function`},{inputs:[{internalType:`address`,name:`tokenAddress`,type:`address`},{internalType:`address`,name:`confidentialTokenAddress`,type:`address`}],name:`registerConfidentialToken`,outputs:[],stateMutability:`nonpayable`,type:`function`},{inputs:[{internalType:`address`,name:`confidentialTokenAddress`,type:`address`}],name:`revokeConfidentialToken`,outputs:[],stateMutability:`nonpayable`,type:`function`}];function t(t){return{address:t,abi:e,functionName:`getTokenConfidentialTokenPairs`,args:[]}}function n(t){return{address:t,abi:e,functionName:`getTokenConfidentialTokenPairsLength`,args:[]}}function r(t,n,r){return{address:t,abi:e,functionName:`getTokenConfidentialTokenPairsSlice`,args:[n,r]}}function i(t,n){return{address:t,abi:e,functionName:`getTokenConfidentialTokenPair`,args:[n]}}function a(t,n){return{address:t,abi:e,functionName:`getConfidentialTokenAddress`,args:[n]}}function o(t,n){return{address:t,abi:e,functionName:`getTokenAddress`,args:[n]}}function s(t,n){return{address:t,abi:e,functionName:`isConfidentialTokenValid`,args:[n]}}export{n as a,t as i,o as n,r as o,i as r,s,a as t};
2
+ //# sourceMappingURL=wrappers-registry-Cm3JJeqx.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wrappers-registry-Cm3JJeqx.js","names":["wrappersRegistryAbi","getTokenPairsContract","registry","getTokenPairsLengthContract","getTokenPairsSliceContract","fromIndex","toIndex","getTokenPairContract","index","getConfidentialTokenAddressContract","tokenAddress","getTokenAddressContract","confidentialTokenAddress","isConfidentialTokenValidContract"],"sources":["../../src/contracts/wrappers-registry.ts"],"sourcesContent":["import type { Address } from \"viem\";\n\nexport const wrappersRegistryAbi = [\n {\n inputs: [],\n name: \"getTokenConfidentialTokenPairs\",\n outputs: [\n {\n components: [\n { internalType: \"address\", name: \"tokenAddress\", type: \"address\" },\n { internalType: \"address\", name: \"confidentialTokenAddress\", type: \"address\" },\n { internalType: \"bool\", name: \"isValid\", type: \"bool\" },\n ],\n internalType: \"struct ConfidentialTokenWrappersRegistry.TokenWrapperPair[]\",\n name: \"\",\n type: \"tuple[]\",\n },\n ],\n stateMutability: \"view\",\n type: \"function\",\n },\n {\n inputs: [],\n name: \"getTokenConfidentialTokenPairsLength\",\n outputs: [{ internalType: \"uint256\", name: \"\", type: \"uint256\" }],\n stateMutability: \"view\",\n type: \"function\",\n },\n {\n inputs: [\n { internalType: \"uint256\", name: \"fromIndex\", type: \"uint256\" },\n { internalType: \"uint256\", name: \"toIndex\", type: \"uint256\" },\n ],\n name: \"getTokenConfidentialTokenPairsSlice\",\n outputs: [\n {\n components: [\n { internalType: \"address\", name: \"tokenAddress\", type: \"address\" },\n { internalType: \"address\", name: \"confidentialTokenAddress\", type: \"address\" },\n { internalType: \"bool\", name: \"isValid\", type: \"bool\" },\n ],\n internalType: \"struct ConfidentialTokenWrappersRegistry.TokenWrapperPair[]\",\n name: \"\",\n type: \"tuple[]\",\n },\n ],\n stateMutability: \"view\",\n type: \"function\",\n },\n {\n inputs: [{ internalType: \"uint256\", name: \"index\", type: \"uint256\" }],\n name: \"getTokenConfidentialTokenPair\",\n outputs: [\n {\n components: [\n { internalType: \"address\", name: \"tokenAddress\", type: \"address\" },\n { internalType: \"address\", name: \"confidentialTokenAddress\", type: \"address\" },\n { internalType: \"bool\", name: \"isValid\", type: \"bool\" },\n ],\n internalType: \"struct ConfidentialTokenWrappersRegistry.TokenWrapperPair\",\n name: \"\",\n type: \"tuple\",\n },\n ],\n stateMutability: \"view\",\n type: \"function\",\n },\n {\n inputs: [{ internalType: \"address\", name: \"tokenAddress\", type: \"address\" }],\n name: \"getConfidentialTokenAddress\",\n outputs: [\n { internalType: \"bool\", name: \"\", type: \"bool\" },\n { internalType: \"address\", name: \"\", type: \"address\" },\n ],\n stateMutability: \"view\",\n type: \"function\",\n },\n {\n inputs: [{ internalType: \"address\", name: \"confidentialTokenAddress\", type: \"address\" }],\n name: \"getTokenAddress\",\n outputs: [\n { internalType: \"bool\", name: \"\", type: \"bool\" },\n { internalType: \"address\", name: \"\", type: \"address\" },\n ],\n stateMutability: \"view\",\n type: \"function\",\n },\n {\n inputs: [{ internalType: \"address\", name: \"confidentialTokenAddress\", type: \"address\" }],\n name: \"isConfidentialTokenValid\",\n outputs: [{ internalType: \"bool\", name: \"\", type: \"bool\" }],\n stateMutability: \"view\",\n type: \"function\",\n },\n {\n inputs: [{ internalType: \"address\", name: \"initialOwner\", type: \"address\" }],\n name: \"initialize\",\n outputs: [],\n stateMutability: \"nonpayable\",\n type: \"function\",\n },\n {\n inputs: [\n { internalType: \"address\", name: \"tokenAddress\", type: \"address\" },\n { internalType: \"address\", name: \"confidentialTokenAddress\", type: \"address\" },\n ],\n name: \"registerConfidentialToken\",\n outputs: [],\n stateMutability: \"nonpayable\",\n type: \"function\",\n },\n {\n inputs: [{ internalType: \"address\", name: \"confidentialTokenAddress\", type: \"address\" }],\n name: \"revokeConfidentialToken\",\n outputs: [],\n stateMutability: \"nonpayable\",\n type: \"function\",\n },\n] as const;\n\n/** A registered plain-token / confidential-token pairing from the wrappers registry. */\nexport interface TokenWrapperPair {\n /** Address of the underlying public ERC-20 token. */\n readonly tokenAddress: Address;\n /** Address of the paired confidential (ERC-7984) token. */\n readonly confidentialTokenAddress: Address;\n /** Whether the pairing is currently valid (registered and not revoked). */\n readonly isValid: boolean;\n}\n\n/** Extended pair with on-chain metadata for both tokens. */\nexport interface TokenWrapperPairWithMetadata extends TokenWrapperPair {\n /** On-chain metadata of the underlying public ERC-20 token. */\n readonly underlying: {\n readonly name: string;\n readonly symbol: string;\n readonly decimals: number;\n readonly totalSupply: bigint;\n };\n /** On-chain metadata of the confidential token. */\n readonly confidential: {\n readonly name: string;\n readonly symbol: string;\n readonly decimals: number;\n };\n}\n\n/** Paginated result set modeled after standard API pagination. */\nexport interface PaginatedResult<T> {\n /** Items on the current page. */\n readonly items: readonly T[];\n /** Total number of items across all pages. */\n readonly total: number;\n /** One-based index of the current page. */\n readonly page: number;\n /** Maximum number of items per page. */\n readonly pageSize: number;\n}\n\n/**\n * Returns the contract config to fetch all token wrapper pairs.\n *\n * @example\n * ```ts\n * const pairs = await client.readContract(\n * getTokenPairsContract(registryAddress),\n * );\n * ```\n */\nexport function getTokenPairsContract(registry: Address) {\n return {\n address: registry,\n abi: wrappersRegistryAbi,\n functionName: \"getTokenConfidentialTokenPairs\",\n args: [],\n } as const;\n}\n\n/**\n * Returns the contract config to get the number of token wrapper pairs.\n *\n * @example\n * ```ts\n * const length = await client.readContract(\n * getTokenPairsLengthContract(registryAddress),\n * );\n * ```\n */\nexport function getTokenPairsLengthContract(registry: Address) {\n return {\n address: registry,\n abi: wrappersRegistryAbi,\n functionName: \"getTokenConfidentialTokenPairsLength\",\n args: [],\n } as const;\n}\n\n/**\n * Returns the contract config to fetch a slice of token wrapper pairs.\n *\n * @example\n * ```ts\n * const pairs = await client.readContract(\n * getTokenPairsSliceContract(registryAddress, 0n, 10n),\n * );\n * ```\n */\nexport function getTokenPairsSliceContract(registry: Address, fromIndex: bigint, toIndex: bigint) {\n return {\n address: registry,\n abi: wrappersRegistryAbi,\n functionName: \"getTokenConfidentialTokenPairsSlice\",\n args: [fromIndex, toIndex],\n } as const;\n}\n\n/**\n * Returns the contract config to fetch a single token wrapper pair by index.\n *\n * @example\n * ```ts\n * const pair = await client.readContract(\n * getTokenPairContract(registryAddress, 0n),\n * );\n * ```\n */\nexport function getTokenPairContract(registry: Address, index: bigint) {\n return {\n address: registry,\n abi: wrappersRegistryAbi,\n functionName: \"getTokenConfidentialTokenPair\",\n args: [index],\n } as const;\n}\n\n/**\n * Returns the contract config to look up the confidential token for a given plain token.\n *\n * @example\n * ```ts\n * const [isValid, confidentialToken] = await client.readContract(\n * getConfidentialTokenAddressContract(registryAddress, tokenAddress),\n * );\n * // isValid=false + confidentialToken=zeroAddress → not registered\n * // isValid=false + confidentialToken=nonZeroAddress → registered but revoked\n * // isValid=true + confidentialToken=nonZeroAddress → registered and valid\n * ```\n */\nexport function getConfidentialTokenAddressContract(registry: Address, tokenAddress: Address) {\n return {\n address: registry,\n abi: wrappersRegistryAbi,\n functionName: \"getConfidentialTokenAddress\",\n args: [tokenAddress],\n } as const;\n}\n\n/**\n * Returns the contract config to look up the plain token for a given confidential token.\n *\n * @example\n * ```ts\n * const [isValid, token] = await client.readContract(\n * getTokenAddressContract(registryAddress, confidentialTokenAddress),\n * );\n * // isValid=false + token=zeroAddress → not registered\n * // isValid=false + token=nonZeroAddress → registered but revoked\n * // isValid=true + token=nonZeroAddress → registered and valid\n * ```\n */\nexport function getTokenAddressContract(registry: Address, confidentialTokenAddress: Address) {\n return {\n address: registry,\n abi: wrappersRegistryAbi,\n functionName: \"getTokenAddress\",\n args: [confidentialTokenAddress],\n } as const;\n}\n\n/**\n * Returns the contract config to check if a confidential token is valid.\n *\n * @example\n * ```ts\n * const isValid = await client.readContract(\n * isConfidentialTokenValidContract(registryAddress, confidentialTokenAddress),\n * );\n * ```\n */\nexport function isConfidentialTokenValidContract(\n registry: Address,\n confidentialTokenAddress: Address,\n) {\n return {\n address: registry,\n abi: wrappersRegistryAbi,\n functionName: \"isConfidentialTokenValid\",\n args: [confidentialTokenAddress],\n } as const;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uCACd,KAAM,CAAC,CACT,CACF,CAYA,SAAgBI,EAA2B,EAAmB,EAAmB,EAAiB,CAChG,MAAO,CACL,QAASF,EACT,IAAKF,EACL,aAAc,sCACd,KAAM,CAACK,EAAWC,CAAO,CAC3B,CACF,CAYA,SAAgBC,EAAqB,EAAmB,EAAe,CACrE,MAAO,CACL,QAASL,EACT,IAAKF,EACL,aAAc,gCACd,KAAM,CAACQ,CAAK,CACd,CACF,CAeA,SAAgBC,EAAoC,EAAmB,EAAuB,CAC5F,MAAO,CACL,QAASP,EACT,IAAKF,EACL,aAAc,8BACd,KAAM,CAACU,CAAY,CACrB,CACF,CAeA,SAAgBC,EAAwB,EAAmB,EAAmC,CAC5F,MAAO,CACL,QAAST,EACT,IAAKF,EACL,aAAc,kBACd,KAAM,CAACY,CAAwB,CACjC,CACF,CAYA,SAAgBC,EACd,EACA,EACA,CACA,MAAO,CACL,QAASX,EACT,IAAKF,EACL,aAAc,2BACd,KAAM,CAACY,CAAwB,CACjC,CACF,C"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zama-fhe/sdk",
3
- "version": "3.8.0-beta.8",
3
+ "version": "3.8.0",
4
4
  "description": "TypeScript SDK for Zama fhEVM confidential smart contracts",
5
5
  "keywords": [
6
6
  "blockchain",
@@ -202,7 +202,7 @@
202
202
  "devDependencies": {
203
203
  "@dfns/sdk": "^0.8.20",
204
204
  "@dfns/sdk-keysigner": "^0.8.20",
205
- "@tanstack/query-core": "^5.104.1",
205
+ "@tanstack/query-core": "^5.107.0",
206
206
  "comlink": "^4.4.2"
207
207
  },
208
208
  "peerDependencies": {
@@ -1,2 +0,0 @@
1
- let e,t=!1;function n(n){e=Object.freeze({wasmAssetLoadMode:n.wasmAssetLoadMode,moduleVersions:n.moduleVersions,singleThread:n.singleThread,numberOfThreads:n.numberOfThreads,auth:n.auth}),t=n.locateFile!==void 0}function r(){return e}function i(){return t}Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return i}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return n}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return r}});
2
- //# sourceMappingURL=applied-runtime.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"applied-runtime.cjs","names":[],"sources":["../../src/relayer/applied-runtime.ts"],"sourcesContent":["import type { FhevmRuntimeConfig, WireRuntimeConfig } from \"./types\";\n\n/**\n * Mirror of the runtime config this package applied via the upstream\n * `setFhevmRuntimeConfig`, which is itself a process-wide one-shot. An encrypt\n * worker realm replicates it, since the upstream lock offers no getter.\n */\nlet appliedWireRuntime: WireRuntimeConfig | undefined;\n\n/** `locateFile` is a function, so it stays off the wire and is only flagged here. */\nlet appliedLocateFile = false;\n\n/** Projects the applied runtime onto the fields a worker realm replicates. */\nexport function recordAppliedRuntimeConfig(runtime: FhevmRuntimeConfig): void {\n appliedWireRuntime = Object.freeze({\n wasmAssetLoadMode: runtime.wasmAssetLoadMode,\n moduleVersions: runtime.moduleVersions,\n singleThread: runtime.singleThread,\n numberOfThreads: runtime.numberOfThreads,\n auth: runtime.auth,\n });\n appliedLocateFile = runtime.locateFile !== undefined;\n}\n\n/** `undefined` when the upstream lock was set outside this package. */\nexport function getAppliedWireRuntime(): WireRuntimeConfig | undefined {\n return appliedWireRuntime;\n}\n\nexport function hasAppliedLocateFile(): boolean {\n return appliedLocateFile;\n}\n\n/** @internal */\nexport function resetAppliedRuntimeConfig(): void {\n appliedWireRuntime = undefined;\n appliedLocateFile = false;\n}\n"],"mappings":"AAOA,IAAI,EAGA,EAAoB,GAGxB,SAAgB,EAA2B,EAAmC,CAC5E,EAAqB,OAAO,OAAO,CACjC,kBAAmB,EAAQ,kBAC3B,eAAgB,EAAQ,eACxB,aAAc,EAAQ,aACtB,gBAAiB,EAAQ,gBACzB,KAAM,EAAQ,IAChB,CAAC,EACD,EAAoB,EAAQ,aAAe,IAAA,EAC7C,CAGA,SAAgB,GAAuD,CACrE,OAAO,CACT,CAEA,SAAgB,GAAgC,CAC9C,OAAO,CACT"}
@@ -1,2 +0,0 @@
1
- let e=require("viem"),t=require("zod/mini");function n(e){if(!r(e))return!1;let t=e.constructor;if(t===void 0)return!0;let n=t.prototype;return!(!r(n)||!n.hasOwnProperty(`isPrototypeOf`))}function r(e){return Object.prototype.toString.call(e)===`[object Object]`}function i(e){let{gcTime:t,staleTime:n,enabled:r,select:i,refetchInterval:a,refetchOnMount:o,refetchOnWindowFocus:s,refetchOnReconnect:c,retry:l,retryDelay:u,retryOnMount:d,queryFn:f,queryKey:p,queryKeyHashFn:m,initialData:h,initialDataUpdatedAt:g,placeholderData:_,structuralSharing:v,throwOnError:y,meta:b,query:x,pollingInterval:S,...C}=e;return C}function a(e){return JSON.stringify(e,(e,t)=>n(t)?Object.keys(t).sort().reduce((e,n)=>(e[n]=t[n],e),{}):typeof t==`bigint`?t.toString():t)}const o=t=>t.map(t=>(0,e.getAddress)(t)),s=t=>t===void 0?void 0:(0,e.getAddress)(t),c=t=>t?{walletAddress:(0,e.getAddress)(t.address),walletChainId:t.chainId}:{},l={confidentialBalance:{all:[`zama.confidentialBalance`],token:t=>[`zama.confidentialBalance`,{tokenAddress:(0,e.getAddress)(t)}],owner:(t,n,r)=>[`zama.confidentialBalance`,{tokenAddress:(0,e.getAddress)(t),...c(r),...n?{owner:(0,e.getAddress)(n)}:{}}]},confidentialBalances:{all:[`zama.confidentialBalances`],tokens:(t,n,r)=>[`zama.confidentialBalances`,{tokenAddresses:o(t),...c(r),...n?{owner:(0,e.getAddress)(n)}:{}}]},tokenMetadata:{all:[`zama.tokenMetadata`],token:t=>[`zama.tokenMetadata`,{tokenAddress:(0,e.getAddress)(t)}]},isConfidential:{all:[`zama.isConfidential`],token:t=>[`zama.isConfidential`,{tokenAddress:(0,e.getAddress)(t)}]},isWrapper:{all:[`zama.isWrapper`],token:t=>[`zama.isWrapper`,{tokenAddress:(0,e.getAddress)(t)}]},wrapperDiscovery:{all:[`zama.wrapperDiscovery`],token:(e,t,n)=>{let r=s(e),i=s(t),a=s(n);return[`zama.wrapperDiscovery`,{...r?{tokenAddress:r}:{},...i?{erc20Address:i}:{},...a?{registryAddress:a}:{}}]}},underlyingAllowance:{all:[`zama.underlyingAllowance`],token:t=>[`zama.underlyingAllowance`,{tokenAddress:(0,e.getAddress)(t)}],scope:(t,n)=>[`zama.underlyingAllowance`,{tokenAddress:(0,e.getAddress)(t),...n?{owner:(0,e.getAddress)(n)}:{}}]},confidentialIsOperator:{all:[`zama.confidentialIsOperator`],token:e=>{let t=s(e);return[`zama.confidentialIsOperator`,t?{tokenAddress:t}:{}]},scope:(e,t,n)=>{let r=s(e),i=s(t),a=s(n);return[`zama.confidentialIsOperator`,{...r?{tokenAddress:r}:{},...i?{holder:i}:{},...a?{spender:a}:{}}]}},totalSupply:{all:[`zama.totalSupply`],token:t=>[`zama.totalSupply`,{tokenAddress:(0,e.getAddress)(t)}]},pendingUnshield:{all:[`zama.pendingUnshield`],token:t=>[`zama.pendingUnshield`,{tokenAddress:(0,e.getAddress)(t)}]},hasPermit:{all:[`zama.hasPermit`],scope:(e,t)=>[`zama.hasPermit`,{...c(t),contractAddresses:o(e).sort()}]},delegationStatus:{all:[`zama.delegationStatus`],contract:e=>{let t=s(e);return[`zama.delegationStatus`,t?{contractAddress:t}:{}]},scope:(e,t,n)=>{let r=s(e),i=s(t),a=s(n);return[`zama.delegationStatus`,{...r?{contractAddress:r}:{},...i?{delegatorAddress:i}:{},...a?{delegateAddress:a}:{}}]}},decryption:{all:[`zama.decryption`],encryptedValue:(t,n)=>[`zama.decryption`,{encryptedValue:t,...n===void 0?{}:{contractAddress:(0,e.getAddress)(n)}}],encryptedInputs:(t,n)=>[`zama.decryption`,{...c(n),encryptedInputs:[...t].sort((e,t)=>e.encryptedValue.localeCompare(t.encryptedValue)).map(t=>({encryptedValue:t.encryptedValue,contractAddress:(0,e.getAddress)(t.contractAddress)}))}]},wrappersRegistry:{all:[`zama.wrappersRegistry`],chainId:()=>[`zama.wrappersRegistry`,{type:`chainId`}],tokenPairs:t=>[`zama.wrappersRegistry`,{type:`tokenPairs`,registryAddress:(0,e.getAddress)(t)}],confidentialTokenAddress:(t,n)=>[`zama.wrappersRegistry`,{type:`confidentialTokenAddress`,registryAddress:(0,e.getAddress)(t),tokenAddress:(0,e.getAddress)(n)}],tokenAddress:(t,n)=>[`zama.wrappersRegistry`,{type:`tokenAddress`,registryAddress:(0,e.getAddress)(t),confidentialTokenAddress:(0,e.getAddress)(n)}],tokenPairsLength:t=>[`zama.wrappersRegistry`,{type:`tokenPairsLength`,registryAddress:(0,e.getAddress)(t)}],tokenPairsSlice:(t,n,r)=>[`zama.wrappersRegistry`,{type:`tokenPairsSlice`,registryAddress:(0,e.getAddress)(t),fromIndex:n,toIndex:r}],tokenPair:(t,n)=>[`zama.wrappersRegistry`,{type:`tokenPair`,registryAddress:(0,e.getAddress)(t),index:n}],isConfidentialTokenValid:(t,n)=>[`zama.wrappersRegistry`,{type:`isConfidentialTokenValid`,registryAddress:(0,e.getAddress)(t),confidentialTokenAddress:(0,e.getAddress)(n)}],listPairs:(t,n,r,i)=>[`zama.wrappersRegistry`,{type:`listPairs`,registryAddress:(0,e.getAddress)(t),page:n,pageSize:r,metadata:i}]}};function u(e,t){e.invalidateQueries({queryKey:l.underlyingAllowance.token(t)})}function d(e,t){e.invalidateQueries({queryKey:l.pendingUnshield.token(t)})}function f(e,t){m(e,t),u(e,t),d(e,t),D(e)}function p(e,t){m(e,t),u(e,t),D(e)}function m(e,t){e.invalidateQueries({queryKey:l.confidentialBalance.token(t)}),e.invalidateQueries({queryKey:l.confidentialBalances.all})}function h(e,t){m(e,t),u(e,t),D(e)}function g(e,t){m(e,t),u(e,t),d(e,t),D(e)}function _(e,t){d(e,t)}function v(e,t){m(e,t)}function y(e,t){u(e,t)}function b(e,t){e.invalidateQueries({queryKey:l.confidentialIsOperator.token(t)})}function x(e){return Array.isArray(e.queryKey)&&typeof e.queryKey[0]==`string`?e.queryKey[0].startsWith(`zama.`):!1}const S=t.z.enum([`balanceOf`,`confidentialBalanceOf`]),C=t.z.object({functionName:S}),w=t.z.object({contracts:t.z.array(t.z.unknown())});function T(e){if(C.safeParse(e).success)return!0;let t=w.safeParse(e);return t.success&&t.data.contracts.some(e=>C.safeParse(e).success)}function E(e){return Array.isArray(e.queryKey)&&e.queryKey.some(T)}function D(e){e.invalidateQueries({predicate:E})}function O(e){e.removeQueries({queryKey:l.decryption.all}),e.removeQueries({queryKey:l.hasPermit.all}),e.invalidateQueries({predicate:x}),D(e)}Object.defineProperty(exports,"a",{enumerable:!0,get:function(){return g}}),Object.defineProperty(exports,"c",{enumerable:!0,get:function(){return p}}),Object.defineProperty(exports,"d",{enumerable:!0,get:function(){return O}}),Object.defineProperty(exports,"f",{enumerable:!0,get:function(){return l}}),Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return v}}),Object.defineProperty(exports,"l",{enumerable:!0,get:function(){return m}}),Object.defineProperty(exports,"m",{enumerable:!0,get:function(){return a}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return b}}),Object.defineProperty(exports,"o",{enumerable:!0,get:function(){return _}}),Object.defineProperty(exports,"p",{enumerable:!0,get:function(){return i}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return h}}),Object.defineProperty(exports,"s",{enumerable:!0,get:function(){return f}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return y}}),Object.defineProperty(exports,"u",{enumerable:!0,get:function(){return D}});
2
- //# sourceMappingURL=invalidation.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"invalidation.cjs","names":["z"],"sources":["../../src/query/utils.ts","../../src/query/query-keys.ts","../../src/query/invalidation.ts"],"sourcesContent":["// Adapted from the wagmi codebase\n// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-wrapper-object-types\nfunction isPlainObject(value: any): value is Object {\n if (!hasObjectPrototype(value)) {\n return false;\n }\n\n // If has modified constructor\n const ctor = value.constructor;\n if (ctor === undefined) {\n return true;\n }\n\n // If has modified prototype\n const prot = ctor.prototype;\n if (!hasObjectPrototype(prot)) {\n return false;\n }\n\n // If constructor does not have an Object-specific method\n // eslint-disable-next-line no-prototype-builtins\n if (!prot.hasOwnProperty(\"isPrototypeOf\")) {\n return false;\n }\n\n // Most likely a plain Object\n return true;\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nfunction hasObjectPrototype(o: any): boolean {\n return Object.prototype.toString.call(o) === \"[object Object]\";\n}\n\n/** Union of TanStack Query option keys stripped by {@link filterQueryOptions}, leaving only domain parameters. */\nexport type StrippedQueryOptionKeys =\n // Keep this union aligned with @tanstack/query-core behavioral options\n // (for example QueryObserverOptions). Revisit on every upgrade to avoid\n // leaking query controls into lower-level query factories.\n | \"gcTime\"\n | \"staleTime\"\n | \"enabled\"\n | \"select\"\n | \"refetchInterval\"\n | \"refetchOnMount\"\n | \"refetchOnWindowFocus\"\n | \"refetchOnReconnect\"\n | \"retry\"\n | \"retryDelay\"\n | \"retryOnMount\"\n | \"queryFn\"\n | \"queryKey\"\n | \"queryKeyHashFn\"\n | \"initialData\"\n | \"initialDataUpdatedAt\"\n | \"placeholderData\"\n | \"structuralSharing\"\n | \"throwOnError\"\n | \"meta\"\n | \"query\"\n | \"pollingInterval\";\n\n/**\n * Remove TanStack behavioral options from a query config object so only domain\n * parameters remain for the lower-level factory.\n *\n * @example\n * ```ts\n * const params = filterQueryOptions({\n * query: { enabled: false },\n * gcTime: 60_000,\n * owner: \"0xabc\",\n * });\n * // => { owner: \"0xabc\" }\n * ```\n */\nexport function filterQueryOptions<TOptions extends Record<string, unknown>>(\n options: TOptions,\n): Omit<TOptions, StrippedQueryOptionKeys> {\n const {\n gcTime: _gcTime,\n staleTime: _staleTime,\n enabled: _enabled,\n select: _select,\n refetchInterval: _refetchInterval,\n refetchOnMount: _refetchOnMount,\n refetchOnWindowFocus: _refetchOnWindowFocus,\n refetchOnReconnect: _refetchOnReconnect,\n retry: _retry,\n retryDelay: _retryDelay,\n retryOnMount: _retryOnMount,\n queryFn: _queryFn,\n queryKey: _queryKey,\n queryKeyHashFn: _queryKeyHashFn,\n initialData: _initialData,\n initialDataUpdatedAt: _initialDataUpdatedAt,\n placeholderData: _placeholderData,\n structuralSharing: _structuralSharing,\n throwOnError: _throwOnError,\n meta: _meta,\n query: _query,\n pollingInterval: _pollingInterval,\n ...rest\n } = options;\n\n return rest;\n}\n\n/**\n * Stable hash function for query keys.\n * Sorts object keys recursively and converts bigint values to strings.\n *\n * @remarks\n * bigint values are serialized as decimal strings, so `42n` and `\"42\"` hash to\n * the same token when they occupy the same position. This collision is accepted\n * by design for the current query-key conventions in this package.\n */\nexport function hashFn(queryKey: readonly unknown[]): string {\n return JSON.stringify(queryKey, (_, value) => {\n if (isPlainObject(value)) {\n return Object.keys(value)\n .sort()\n .reduce(\n (result, key) => {\n result[key] = value[key];\n return result;\n },\n {} as Record<string, unknown>,\n );\n }\n\n if (typeof value === \"bigint\") {\n return value.toString();\n }\n\n return value;\n });\n}\n","import { getAddress } from \"viem\";\nimport type { Address, Hex } from \"viem\";\nimport type { WalletAccount } from \"../types\";\n\nconst normalizeAddresses = (addresses: Address[]): Address[] =>\n addresses.map((address) => getAddress(address));\nconst normalizeAddress = (address?: Address): Address | undefined =>\n address === undefined ? undefined : getAddress(address);\nconst walletAccountKey = (walletAccount?: WalletAccount) =>\n walletAccount\n ? { walletAddress: getAddress(walletAccount.address), walletChainId: walletAccount.chainId }\n : {};\n\n/**\n * Canonical query-key namespace for `@zama-fhe/sdk/query`.\n *\n * @example\n * ```ts\n * queryClient.invalidateQueries({\n * queryKey: zamaQueryKeys.confidentialBalance.token(\"0xToken\"),\n * });\n * ```\n */\nexport const zamaQueryKeys = {\n confidentialBalance: {\n all: [\"zama.confidentialBalance\"] as const,\n token: (tokenAddress: Address) =>\n [\"zama.confidentialBalance\", { tokenAddress: getAddress(tokenAddress) }] as const,\n owner: (tokenAddress: Address, owner?: Address, walletAccount?: WalletAccount) =>\n [\n \"zama.confidentialBalance\",\n {\n tokenAddress: getAddress(tokenAddress),\n ...walletAccountKey(walletAccount),\n ...(owner ? { owner: getAddress(owner) } : {}),\n },\n ] as const,\n },\n\n confidentialBalances: {\n all: [\"zama.confidentialBalances\"] as const,\n tokens: (tokenAddresses: Address[], owner?: Address, walletAccount?: WalletAccount) =>\n [\n \"zama.confidentialBalances\",\n {\n tokenAddresses: normalizeAddresses(tokenAddresses),\n ...walletAccountKey(walletAccount),\n ...(owner ? { owner: getAddress(owner) } : {}),\n },\n ] as const,\n },\n\n tokenMetadata: {\n all: [\"zama.tokenMetadata\"] as const,\n token: (tokenAddress: Address) =>\n [\"zama.tokenMetadata\", { tokenAddress: getAddress(tokenAddress) }] as const,\n },\n\n isConfidential: {\n all: [\"zama.isConfidential\"] as const,\n token: (tokenAddress: Address) =>\n [\"zama.isConfidential\", { tokenAddress: getAddress(tokenAddress) }] as const,\n },\n\n isWrapper: {\n all: [\"zama.isWrapper\"] as const,\n token: (tokenAddress: Address) =>\n [\"zama.isWrapper\", { tokenAddress: getAddress(tokenAddress) }] as const,\n },\n\n wrapperDiscovery: {\n all: [\"zama.wrapperDiscovery\"] as const,\n token: (tokenAddress?: Address, erc20Address?: Address, registryAddress?: Address) => {\n const t = normalizeAddress(tokenAddress);\n const e = normalizeAddress(erc20Address);\n const r = normalizeAddress(registryAddress);\n return [\n \"zama.wrapperDiscovery\",\n {\n ...(t ? { tokenAddress: t } : {}),\n ...(e ? { erc20Address: e } : {}),\n ...(r ? { registryAddress: r } : {}),\n },\n ] as const;\n },\n },\n\n underlyingAllowance: {\n all: [\"zama.underlyingAllowance\"] as const,\n token: (tokenAddress: Address) =>\n [\"zama.underlyingAllowance\", { tokenAddress: getAddress(tokenAddress) }] as const,\n scope: (tokenAddress: Address, owner?: Address) =>\n [\n \"zama.underlyingAllowance\",\n { tokenAddress: getAddress(tokenAddress), ...(owner ? { owner: getAddress(owner) } : {}) },\n ] as const,\n },\n\n confidentialIsOperator: {\n all: [\"zama.confidentialIsOperator\"] as const,\n token: (tokenAddress?: Address) => {\n const t = normalizeAddress(tokenAddress);\n return [\"zama.confidentialIsOperator\", t ? { tokenAddress: t } : {}] as const;\n },\n scope: (tokenAddress?: Address, holder?: Address, spender?: Address) => {\n const t = normalizeAddress(tokenAddress);\n const h = normalizeAddress(holder);\n const s = normalizeAddress(spender);\n return [\n \"zama.confidentialIsOperator\",\n {\n ...(t ? { tokenAddress: t } : {}),\n ...(h ? { holder: h } : {}),\n ...(s ? { spender: s } : {}),\n },\n ] as const;\n },\n },\n\n totalSupply: {\n all: [\"zama.totalSupply\"] as const,\n token: (tokenAddress: Address) =>\n [\"zama.totalSupply\", { tokenAddress: getAddress(tokenAddress) }] as const,\n },\n\n pendingUnshield: {\n all: [\"zama.pendingUnshield\"] as const,\n token: (tokenAddress: Address) =>\n [\"zama.pendingUnshield\", { tokenAddress: getAddress(tokenAddress) }] as const,\n },\n\n hasPermit: {\n all: [\"zama.hasPermit\"] as const,\n scope: (contractAddresses: Address[], walletAccount?: WalletAccount) =>\n [\n \"zama.hasPermit\",\n {\n ...walletAccountKey(walletAccount),\n contractAddresses: normalizeAddresses(contractAddresses).sort(),\n },\n ] as const,\n },\n\n delegationStatus: {\n all: [\"zama.delegationStatus\"] as const,\n contract: (contractAddress?: Address) => {\n const t = normalizeAddress(contractAddress);\n return [\"zama.delegationStatus\", t ? { contractAddress: t } : {}] as const;\n },\n scope: (contractAddress?: Address, delegator?: Address, delegate?: Address) => {\n const t = normalizeAddress(contractAddress);\n const dr = normalizeAddress(delegator);\n const de = normalizeAddress(delegate);\n return [\n \"zama.delegationStatus\",\n {\n ...(t ? { contractAddress: t } : {}),\n ...(dr ? { delegatorAddress: dr } : {}),\n ...(de ? { delegateAddress: de } : {}),\n },\n ] as const;\n },\n },\n\n decryption: {\n all: [\"zama.decryption\"] as const,\n encryptedValue: (encryptedValue: string, contractAddress?: Address) =>\n [\n \"zama.decryption\",\n {\n encryptedValue,\n ...(contractAddress === undefined\n ? {}\n : { contractAddress: getAddress(contractAddress) }),\n },\n ] as const,\n encryptedInputs: (\n encryptedInputs: readonly { encryptedValue: string; contractAddress: Address }[],\n walletAccount?: WalletAccount,\n ) =>\n [\n \"zama.decryption\",\n {\n ...walletAccountKey(walletAccount),\n encryptedInputs: [...encryptedInputs]\n .sort((a, b) => a.encryptedValue.localeCompare(b.encryptedValue))\n .map((h) => ({\n encryptedValue: h.encryptedValue as Hex,\n contractAddress: getAddress(h.contractAddress),\n })),\n },\n ] as const,\n },\n\n wrappersRegistry: {\n all: [\"zama.wrappersRegistry\"] as const,\n chainId: () => [\"zama.wrappersRegistry\", { type: \"chainId\" }] as const,\n tokenPairs: (registryAddress: Address) =>\n [\n \"zama.wrappersRegistry\",\n { type: \"tokenPairs\", registryAddress: getAddress(registryAddress) },\n ] as const,\n confidentialTokenAddress: (registryAddress: Address, tokenAddress: Address) =>\n [\n \"zama.wrappersRegistry\",\n {\n type: \"confidentialTokenAddress\",\n registryAddress: getAddress(registryAddress),\n tokenAddress: getAddress(tokenAddress),\n },\n ] as const,\n tokenAddress: (registryAddress: Address, confidentialTokenAddress: Address) =>\n [\n \"zama.wrappersRegistry\",\n {\n type: \"tokenAddress\",\n registryAddress: getAddress(registryAddress),\n confidentialTokenAddress: getAddress(confidentialTokenAddress),\n },\n ] as const,\n tokenPairsLength: (registryAddress: Address) =>\n [\n \"zama.wrappersRegistry\",\n { type: \"tokenPairsLength\", registryAddress: getAddress(registryAddress) },\n ] as const,\n tokenPairsSlice: (registryAddress: Address, fromIndex: string, toIndex: string) =>\n [\n \"zama.wrappersRegistry\",\n {\n type: \"tokenPairsSlice\",\n registryAddress: getAddress(registryAddress),\n fromIndex,\n toIndex,\n },\n ] as const,\n tokenPair: (registryAddress: Address, index: string) =>\n [\n \"zama.wrappersRegistry\",\n { type: \"tokenPair\", registryAddress: getAddress(registryAddress), index },\n ] as const,\n isConfidentialTokenValid: (registryAddress: Address, confidentialTokenAddress: Address) =>\n [\n \"zama.wrappersRegistry\",\n {\n type: \"isConfidentialTokenValid\",\n registryAddress: getAddress(registryAddress),\n confidentialTokenAddress: getAddress(confidentialTokenAddress),\n },\n ] as const,\n listPairs: (registryAddress: Address, page: number, pageSize: number, metadata: boolean) =>\n [\n \"zama.wrappersRegistry\",\n {\n type: \"listPairs\",\n registryAddress: getAddress(registryAddress),\n page,\n pageSize,\n metadata,\n },\n ] as const,\n },\n} as const;\n","import type { Address } from \"viem\";\nimport { z } from \"zod/mini\";\nimport { zamaQueryKeys } from \"./query-keys\";\n\n/** Minimal query shape read by the invalidation predicates. */\nexport interface QueryLike {\n /** The query's cache key. */\n queryKey: readonly unknown[];\n}\n\n/** Minimal filter shape accepted by the invalidation helpers, matching TanStack Query's `QueryFilters`. */\nexport interface QueryFilterLike {\n /** Match queries whose key starts with this prefix. */\n queryKey?: readonly unknown[];\n /** Match queries for which this returns `true`. */\n predicate?: (query: QueryLike) => boolean;\n}\n\n/** Minimal `QueryClient` surface used by the invalidation helpers. */\nexport interface QueryClientLike {\n /** Mark matching queries stale so they refetch. */\n invalidateQueries(filters: QueryFilterLike): void | Promise<void>;\n /** Remove matching queries from the cache entirely. */\n removeQueries(filters: QueryFilterLike): void;\n}\n\nfunction invalidateUnderlyingAllowanceQueries(\n queryClient: QueryClientLike,\n tokenAddress: Address,\n): void {\n void queryClient.invalidateQueries({\n queryKey: zamaQueryKeys.underlyingAllowance.token(tokenAddress),\n });\n}\n\nfunction invalidatePendingUnshieldQueries(\n queryClient: QueryClientLike,\n tokenAddress: Address,\n): void {\n void queryClient.invalidateQueries({\n queryKey: zamaQueryKeys.pendingUnshield.token(tokenAddress),\n });\n}\n\n/** Invalidates the caches affected by an unwrap: confidential balances, underlying allowance, and pending unshields. */\nexport function invalidateAfterUnwrap(queryClient: QueryClientLike, tokenAddress: Address): void {\n invalidateBalanceQueries(queryClient, tokenAddress);\n invalidateUnderlyingAllowanceQueries(queryClient, tokenAddress);\n invalidatePendingUnshieldQueries(queryClient, tokenAddress);\n invalidateWagmiBalanceQueries(queryClient);\n}\n\n/** Invalidates the caches affected by a wrap: confidential balances and underlying allowance. */\nexport function invalidateAfterWrap(queryClient: QueryClientLike, tokenAddress: Address): void {\n invalidateBalanceQueries(queryClient, tokenAddress);\n invalidateUnderlyingAllowanceQueries(queryClient, tokenAddress);\n invalidateWagmiBalanceQueries(queryClient);\n}\n\n/** Invalidates the confidential balance queries for a token (single-token and batched). */\nexport function invalidateBalanceQueries(\n queryClient: QueryClientLike,\n tokenAddress: Address,\n): void {\n void queryClient.invalidateQueries({\n queryKey: zamaQueryKeys.confidentialBalance.token(tokenAddress),\n });\n void queryClient.invalidateQueries({ queryKey: zamaQueryKeys.confidentialBalances.all });\n}\n\n/** Invalidates the caches affected by a shield: confidential balances and underlying allowance. */\nexport function invalidateAfterShield(queryClient: QueryClientLike, tokenAddress: Address): void {\n invalidateBalanceQueries(queryClient, tokenAddress);\n invalidateUnderlyingAllowanceQueries(queryClient, tokenAddress);\n invalidateWagmiBalanceQueries(queryClient);\n}\n\n/** Invalidates the caches affected by an unshield request: confidential balances, underlying allowance, and pending unshields. */\nexport function invalidateAfterUnshield(queryClient: QueryClientLike, tokenAddress: Address): void {\n invalidateBalanceQueries(queryClient, tokenAddress);\n invalidateUnderlyingAllowanceQueries(queryClient, tokenAddress);\n invalidatePendingUnshieldQueries(queryClient, tokenAddress);\n invalidateWagmiBalanceQueries(queryClient);\n}\n\n/** Invalidates the pending-unshield cache once an unshield has settled on-chain. */\nexport function invalidateAfterUnshieldSettled(\n queryClient: QueryClientLike,\n tokenAddress: Address,\n): void {\n invalidatePendingUnshieldQueries(queryClient, tokenAddress);\n}\n\n/** Invalidates the confidential balance caches affected by a transfer. */\nexport function invalidateAfterTransfer(queryClient: QueryClientLike, tokenAddress: Address): void {\n invalidateBalanceQueries(queryClient, tokenAddress);\n}\n\n/** Invalidates the underlying-allowance cache after approving the underlying ERC-20. */\nexport function invalidateAfterApproveUnderlying(\n queryClient: QueryClientLike,\n tokenAddress: Address,\n): void {\n invalidateUnderlyingAllowanceQueries(queryClient, tokenAddress);\n}\n\n/** Invalidates the operator-status cache after changing a token operator. */\nexport function invalidateAfterSetOperator(\n queryClient: QueryClientLike,\n tokenAddress: Address,\n): void {\n void queryClient.invalidateQueries({\n queryKey: zamaQueryKeys.confidentialIsOperator.token(tokenAddress),\n });\n}\n\nfunction isZamaQuery(query: QueryLike): boolean {\n return Array.isArray(query.queryKey) && typeof query.queryKey[0] === \"string\"\n ? query.queryKey[0].startsWith(\"zama.\")\n : false;\n}\n\nconst balanceFunctionName = z.enum([\"balanceOf\", \"confidentialBalanceOf\"]);\n\nconst balanceReadArgs = z.object({ functionName: balanceFunctionName });\n\nconst batchedReadArgs = z.object({ contracts: z.array(z.unknown()) });\n\nfunction isBalanceReadPart(part: unknown): boolean {\n if (balanceReadArgs.safeParse(part).success) {\n return true;\n }\n const batched = batchedReadArgs.safeParse(part);\n return (\n batched.success && batched.data.contracts.some((c) => balanceReadArgs.safeParse(c).success)\n );\n}\n\nfunction isWagmiBalanceQuery(query: QueryLike): boolean {\n return Array.isArray(query.queryKey) && query.queryKey.some(isBalanceReadPart);\n}\n\n/** Invalidates any wagmi `useBalance`/`readContract` balance queries so ERC-20 balances refresh. */\nexport function invalidateWagmiBalanceQueries(queryClient: QueryClientLike): void {\n void queryClient.invalidateQueries({ predicate: isWagmiBalanceQuery });\n}\n\n/** Clears wallet-local caches (decryption, permits) and invalidates all Zama queries — call on wallet connect/disconnect so a stale entitlement can't leak across accounts. */\nexport function invalidateWalletLifecycleQueries(queryClient: QueryClientLike): void {\n // Remove (not just invalidate) wallet-local caches so a stale allowed/true\n // cannot surface between wallet disconnect and the next refetch.\n queryClient.removeQueries({ queryKey: zamaQueryKeys.decryption.all });\n queryClient.removeQueries({ queryKey: zamaQueryKeys.hasPermit.all });\n void queryClient.invalidateQueries({ predicate: isZamaQuery });\n invalidateWagmiBalanceQueries(queryClient);\n}\n"],"mappings":"4CAEA,SAAS,EAAc,EAA6B,CAClD,GAAI,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AAgB,UAAU,CAAI,EAC9C,OACE,EAAQ,SAAW,EAAQ,KAAK,UAAU,KAAM,GAAM,EAAgB,UAAU,CAAC,CAAC,CAAC,OAAO,CAE9F,CAEA,SAAS,EAAoB,EAA2B,CACtD,OAAO,MAAM,QAAQ,EAAM,QAAQ,GAAK,EAAM,SAAS,KAAK,CAAiB,CAC/E,CAGA,SAAgB,EAA8B,EAAoC,CAChF,EAAiB,kBAAkB,CAAE,UAAW,CAAoB,CAAC,CACvE,CAGA,SAAgB,EAAiC,EAAoC,CAGnF,EAAY,cAAc,CAAE,SAAU,EAAc,WAAW,GAAI,CAAC,EACpE,EAAY,cAAc,CAAE,SAAU,EAAc,UAAU,GAAI,CAAC,EACnE,EAAiB,kBAAkB,CAAE,UAAW,CAAY,CAAC,EAC7D,EAA8B,CAAW,CAC3C"}
@@ -1,2 +0,0 @@
1
- let e=require("viem"),t=require("zod/mini");function n(t){return(0,e.getAddress)(t)}const r=t.z.custom(t=>typeof t==`string`&&(0,e.isHex)(t,{strict:!0}),`expected 0x-prefixed hex string`),i=t.z.custom(t=>typeof t==`string`&&(0,e.isAddress)(t,{strict:!1}),`expected EVM address`),a=t.z.pipe(i,t.z.transform(n)),o=t.z.int().check(t.z.nonnegative()),s=t.z.int().check(t.z.positive()),c=t.z.int().check(t.z.nonnegative()),l=t.z.int().check(t.z.positive());t.z.int().check(t.z.positive()),Object.defineProperty(exports,"a",{enumerable:!0,get:function(){return l}}),Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return c}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return a}}),Object.defineProperty(exports,"o",{enumerable:!0,get:function(){return s}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return r}}),Object.defineProperty(exports,"s",{enumerable:!0,get:function(){return o}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return n}});
2
- //# sourceMappingURL=primitives.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"primitives.cjs","names":["z"],"sources":["../../src/schemas/primitives.ts"],"sourcesContent":["import { type Address, getAddress, isAddress, isHex, type Hex } from \"viem\";\nimport { z } from \"zod/mini\";\n\ndeclare const checksummedTag: unique symbol;\n\n/** An EVM address that has been put through `getAddress` (EIP-55 checksum form). */\nexport type ChecksummedAddress = Address & { readonly [checksummedTag]: true };\n\n/** Stamp the brand on an arbitrary `Address` after normalizing it. */\nexport function checksum(value: Address): ChecksummedAddress {\n return getAddress(value) as ChecksummedAddress;\n}\n\n/** `0x`-prefixed hex string. */\nexport const hex = z.custom<Hex>(\n (v) => typeof v === \"string\" && isHex(v, { strict: true }),\n \"expected 0x-prefixed hex string\",\n);\n\n/** Validates an EVM address string. Output type is `Address` (`` `0x${string}` ``). */\nexport const evmAddress = z.custom<Address>(\n (v) => typeof v === \"string\" && isAddress(v, { strict: false }),\n \"expected EVM address\",\n);\n\n/** Validates and EIP-55 checksums an EVM address. Output is {@link ChecksummedAddress}. */\nexport const checksummedAddress = z.pipe(evmAddress, z.transform(checksum));\n\n/** Non-negative integer Unix timestamp in seconds. */\nexport const unixSeconds = z.int().check(z.nonnegative());\n\n/** Positive integer count of seconds (e.g. a TTL). */\nexport const positiveSeconds = z.int().check(z.positive());\n\n/** Non-negative integer count of seconds (e.g. a cache TTL where 0 disables caching). */\nexport const nonNegativeSeconds = z.int().check(z.nonnegative());\n\n/** Positive integer count of days (e.g. a permit duration). */\nexport const positiveDays = z.int().check(z.positive());\n\n/** Positive integer EVM chain ID. */\nexport const chainId = z.int().check(z.positive());\n"],"mappings":"4CASA,SAAgB,EAAS,EAAoC,CAC3D,OAAA,EAAA,EAAA,WAAA,CAAkB,CAAK,CACzB,CAGA,MAAa,EAAMA,EAAAA,EAAE,OAClB,GAAM,OAAO,GAAM,WAAA,EAAA,EAAA,MAAA,CAAkB,EAAG,CAAE,OAAQ,EAAK,CAAC,EACzD,iCACF,EAGa,EAAaA,EAAAA,EAAE,OACzB,GAAM,OAAO,GAAM,WAAA,EAAA,EAAA,UAAA,CAAsB,EAAG,CAAE,OAAQ,EAAM,CAAC,EAC9D,sBACF,EAGa,EAAqBA,EAAAA,EAAE,KAAK,EAAYA,EAAAA,EAAE,UAAU,CAAQ,CAAC,EAG7D,EAAcA,EAAAA,EAAE,IAAI,CAAC,CAAC,MAAMA,EAAAA,EAAE,YAAY,CAAC,EAG3C,EAAkBA,EAAAA,EAAE,IAAI,CAAC,CAAC,MAAMA,EAAAA,EAAE,SAAS,CAAC,EAG5C,EAAqBA,EAAAA,EAAE,IAAI,CAAC,CAAC,MAAMA,EAAAA,EAAE,YAAY,CAAC,EAGlD,EAAeA,EAAAA,EAAE,IAAI,CAAC,CAAC,MAAMA,EAAAA,EAAE,SAAS,CAAC,EAG/BA,EAAAA,EAAE,IAAI,CAAC,CAAC,MAAMA,EAAAA,EAAE,SAAS,CAAC"}