@zama-fhe/react-sdk 1.0.0-alpha.7 → 1.0.1

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.
@@ -1,286 +1,2 @@
1
- "use client";
2
- export { useActivityFeed, useApproveUnderlying, useAuthorizeAll, useConfidentialApprove, useConfidentialBalance, useConfidentialBalances, useConfidentialTransferFrom, useResumeUnshield, useTokenMetadata, useUnshield, useUnshieldAll, useUnwrapAll } from '../chunk-463DUSLG.js';
3
- import { symbolContract, decimalsContract, balanceOfContract, confidentialBalanceOfContract, getWrapperContract, underlyingContract, wrapperExistsContract, supportsInterfaceContract, TransactionRevertedError, confidentialBatchTransferContract, confidentialTransferContract, finalizeUnwrapContract, setOperatorContract, wrapContract, wrapETHContract, unwrapContract, unwrapFromBalanceContract } from '@zama-fhe/sdk';
4
- import { formatUnits } from 'viem';
5
- import * as wagmi from 'wagmi';
6
- import { useReadContracts, useReadContract, useWriteContract, useAccount } from 'wagmi';
7
- import * as actions from 'wagmi/actions';
8
- import { getChainId, signTypedData, writeContract, readContract, waitForTransactionReceipt, getAccount } from 'wagmi/actions';
9
-
10
- var useConnection2 = "useConnection" in wagmi ? wagmi.useConnection : useAccount;
11
- var getConnection2 = "getConnection" in actions ? actions.getConnection : getAccount;
12
-
13
- // src/wagmi/use-balance-of.ts
14
- function useBalanceOf(config) {
15
- const { address: connectedAddress } = useConnection2();
16
- const { tokenAddress, userAddress = connectedAddress } = config;
17
- const enabled = !!tokenAddress && !!userAddress;
18
- const { data, ...query } = useReadContracts({
19
- contracts: [
20
- symbolContract(tokenAddress),
21
- decimalsContract(tokenAddress),
22
- enabled ? balanceOfContract(tokenAddress, userAddress) : {}
23
- ],
24
- query: { enabled }
25
- });
26
- const symbol = data?.[0]?.result;
27
- const decimals = data?.[1]?.result;
28
- const value = data?.[2]?.result;
29
- const formatted = value !== void 0 && decimals !== void 0 ? formatUnits(value, decimals) : void 0;
30
- return {
31
- data: { value, symbol, decimals, formatted },
32
- ...query
33
- };
34
- }
35
- function useBalanceOfSuspense(config) {
36
- const { address: connectedAddress } = useConnection2();
37
- const { tokenAddress, userAddress = connectedAddress } = config;
38
- const enabled = !!userAddress;
39
- const { data, ...query } = useReadContracts({
40
- contracts: [
41
- symbolContract(tokenAddress),
42
- decimalsContract(tokenAddress),
43
- enabled ? balanceOfContract(tokenAddress, userAddress) : {}
44
- ],
45
- query: { suspense: true, enabled }
46
- });
47
- const symbol = data?.[0]?.result;
48
- const decimals = data?.[1]?.result;
49
- const value = data?.[2]?.result;
50
- const formatted = value !== void 0 && decimals !== void 0 ? formatUnits(value, decimals) : void 0;
51
- return {
52
- data: { value, symbol, decimals, formatted },
53
- ...query
54
- };
55
- }
56
- function useConfidentialBalanceOf(config) {
57
- const { tokenAddress, userAddress } = config;
58
- const enabled = !!tokenAddress && !!userAddress;
59
- const contract = enabled ? confidentialBalanceOfContract(tokenAddress, userAddress) : {};
60
- return useReadContract({ ...contract, query: { enabled } });
61
- }
62
- function useConfidentialBalanceOfSuspense(config) {
63
- const contract = confidentialBalanceOfContract(config.tokenAddress, config.userAddress);
64
- return useReadContract({ ...contract, query: { suspense: true } });
65
- }
66
- function useConfidentialTransfer() {
67
- const { mutate, mutateAsync, ...mutation } = useWriteContract();
68
- function transfer(encryptedErc20, to, handle, inputProof) {
69
- return mutate(confidentialTransferContract(encryptedErc20, to, handle, inputProof));
70
- }
71
- async function transferAsync(encryptedErc20, to, handle, inputProof) {
72
- return mutateAsync(confidentialTransferContract(encryptedErc20, to, handle, inputProof));
73
- }
74
- return {
75
- mutate: transfer,
76
- mutateAsync: transferAsync,
77
- ...mutation
78
- };
79
- }
80
- function useConfidentialBatchTransfer() {
81
- const { mutate, mutateAsync, ...mutation } = useWriteContract();
82
- function batchTransfer(batcherAddress, tokenAddress, fromAddress, batchTransferData, fees) {
83
- return mutate(
84
- confidentialBatchTransferContract(
85
- batcherAddress,
86
- tokenAddress,
87
- fromAddress,
88
- batchTransferData,
89
- fees
90
- )
91
- );
92
- }
93
- async function batchTransferAsync(batcherAddress, tokenAddress, fromAddress, batchTransferData, fees) {
94
- return mutateAsync(
95
- confidentialBatchTransferContract(
96
- batcherAddress,
97
- tokenAddress,
98
- fromAddress,
99
- batchTransferData,
100
- fees
101
- )
102
- );
103
- }
104
- return {
105
- mutate: batchTransfer,
106
- mutateAsync: batchTransferAsync,
107
- ...mutation
108
- };
109
- }
110
- function useUnwrap() {
111
- const { mutate, mutateAsync, ...mutation } = useWriteContract();
112
- function unwrap(encryptedErc20, from, to, encryptedAmount, inputProof) {
113
- return mutate(unwrapContract(encryptedErc20, from, to, encryptedAmount, inputProof));
114
- }
115
- async function unwrapAsync(encryptedErc20, from, to, encryptedAmount, inputProof) {
116
- return mutateAsync(unwrapContract(encryptedErc20, from, to, encryptedAmount, inputProof));
117
- }
118
- return {
119
- mutate: unwrap,
120
- mutateAsync: unwrapAsync,
121
- ...mutation
122
- };
123
- }
124
- function useUnwrapFromBalance() {
125
- const { mutate, mutateAsync, ...mutation } = useWriteContract();
126
- function unwrapFromBalance(encryptedErc20, from, to, encryptedBalance) {
127
- return mutate(unwrapFromBalanceContract(encryptedErc20, from, to, encryptedBalance));
128
- }
129
- async function unwrapFromBalanceAsync(encryptedErc20, from, to, encryptedBalance) {
130
- return mutateAsync(unwrapFromBalanceContract(encryptedErc20, from, to, encryptedBalance));
131
- }
132
- return {
133
- mutate: unwrapFromBalance,
134
- mutateAsync: unwrapFromBalanceAsync,
135
- ...mutation
136
- };
137
- }
138
- function useFinalizeUnwrap() {
139
- const { mutate, mutateAsync, ...mutation } = useWriteContract();
140
- function finalizeUnwrap(wrapper, burntAmount, burntAmountCleartext, decryptionProof) {
141
- return mutate(
142
- finalizeUnwrapContract(wrapper, burntAmount, burntAmountCleartext, decryptionProof)
143
- );
144
- }
145
- async function finalizeUnwrapAsync(wrapper, burntAmount, burntAmountCleartext, decryptionProof) {
146
- return mutateAsync(
147
- finalizeUnwrapContract(wrapper, burntAmount, burntAmountCleartext, decryptionProof)
148
- );
149
- }
150
- return {
151
- mutate: finalizeUnwrap,
152
- mutateAsync: finalizeUnwrapAsync,
153
- ...mutation
154
- };
155
- }
156
- function useSetOperator() {
157
- const { mutate, mutateAsync, ...mutation } = useWriteContract();
158
- function setOperator(tokenAddress, spender, timestamp) {
159
- return mutate(setOperatorContract(tokenAddress, spender, timestamp));
160
- }
161
- async function setOperatorAsync(tokenAddress, spender, timestamp) {
162
- return mutateAsync(setOperatorContract(tokenAddress, spender, timestamp));
163
- }
164
- return {
165
- mutate: setOperator,
166
- mutateAsync: setOperatorAsync,
167
- ...mutation
168
- };
169
- }
170
- function useWrapperForToken(config) {
171
- const { coordinator, tokenAddress } = config;
172
- const enabled = !!coordinator && !!tokenAddress;
173
- const contract = enabled ? getWrapperContract(coordinator, tokenAddress) : {};
174
- return useReadContract({ ...contract, query: { enabled } });
175
- }
176
- function useWrapperForTokenSuspense(config) {
177
- const contract = getWrapperContract(config.coordinator, config.tokenAddress);
178
- return useReadContract({ ...contract, query: { suspense: true } });
179
- }
180
- function useUnderlyingToken(config) {
181
- const { wrapperAddress } = config;
182
- const enabled = !!wrapperAddress;
183
- const contract = enabled ? underlyingContract(wrapperAddress) : {};
184
- return useReadContract({ ...contract, query: { enabled } });
185
- }
186
- function useUnderlyingTokenSuspense(config) {
187
- const contract = underlyingContract(config.wrapperAddress);
188
- return useReadContract({ ...contract, query: { suspense: true } });
189
- }
190
- function useWrapperExists(config) {
191
- const { coordinator, tokenAddress } = config;
192
- const enabled = !!coordinator && !!tokenAddress;
193
- const contract = enabled ? wrapperExistsContract(coordinator, tokenAddress) : {};
194
- return useReadContract({ ...contract, query: { enabled } });
195
- }
196
- function useWrapperExistsSuspense(config) {
197
- const contract = wrapperExistsContract(config.coordinator, config.tokenAddress);
198
- return useReadContract({ ...contract, query: { suspense: true } });
199
- }
200
- function useSupportsInterface(config) {
201
- const { tokenAddress, interfaceId } = config;
202
- const enabled = !!tokenAddress && !!interfaceId;
203
- const contract = enabled ? supportsInterfaceContract(tokenAddress, interfaceId) : {};
204
- return useReadContract({ ...contract, query: { enabled } });
205
- }
206
- function useSupportsInterfaceSuspense(config) {
207
- const contract = supportsInterfaceContract(config.tokenAddress, config.interfaceId);
208
- return useReadContract({ ...contract, query: { suspense: true } });
209
- }
210
- function useShield() {
211
- const { mutate, mutateAsync, ...mutation } = useWriteContract();
212
- function shield(wrapperAddress, to, amount) {
213
- return mutate(wrapContract(wrapperAddress, to, amount));
214
- }
215
- async function shieldAsync(wrapperAddress, to, amount) {
216
- return mutateAsync(wrapContract(wrapperAddress, to, amount));
217
- }
218
- return {
219
- mutate: shield,
220
- mutateAsync: shieldAsync,
221
- ...mutation
222
- };
223
- }
224
- function useShieldETH() {
225
- const { mutate, mutateAsync, ...mutation } = useWriteContract();
226
- function shieldETH(wrapperAddress, to, amount, value) {
227
- return mutate(wrapETHContract(wrapperAddress, to, amount, value));
228
- }
229
- async function shieldETHAsync(wrapperAddress, to, amount, value) {
230
- return mutateAsync(wrapETHContract(wrapperAddress, to, amount, value));
231
- }
232
- return {
233
- mutate: shieldETH,
234
- mutateAsync: shieldETHAsync,
235
- ...mutation
236
- };
237
- }
238
- var WagmiSigner = class {
239
- config;
240
- constructor(signerConfig) {
241
- this.config = signerConfig.config;
242
- }
243
- async getChainId() {
244
- return getChainId(this.config);
245
- }
246
- async getAddress() {
247
- const account = getConnection2(this.config);
248
- if (!account?.address) {
249
- throw new TypeError("Invalid address");
250
- }
251
- return account.address;
252
- }
253
- async signTypedData(typedData) {
254
- const { EIP712Domain: _, ...sigTypes } = typedData.types;
255
- return signTypedData(this.config, {
256
- primaryType: Object.keys(sigTypes)[0],
257
- types: sigTypes,
258
- domain: typedData.domain,
259
- message: typedData.message
260
- });
261
- }
262
- async writeContract(config) {
263
- return writeContract(this.config, config);
264
- }
265
- async readContract(config) {
266
- return readContract(this.config, config);
267
- }
268
- async waitForTransactionReceipt(hash) {
269
- try {
270
- return await waitForTransactionReceipt(this.config, { hash });
271
- } catch (error) {
272
- const message = error instanceof Error ? error.message : String(error);
273
- if (message.includes("could not be found") || message.includes("Transaction not found")) {
274
- throw new TransactionRevertedError(
275
- `Could not find transaction receipt for hash "${hash.slice(0, 10)}\u2026". If using ERC-4337 with a bundler, your connector may be returning a UserOperation hash instead of a transaction hash.`,
276
- { cause: error instanceof Error ? error : void 0 }
277
- );
278
- }
279
- throw error;
280
- }
281
- }
282
- };
283
-
284
- export { WagmiSigner, useBalanceOf, useBalanceOfSuspense, useConfidentialBalanceOf, useConfidentialBalanceOfSuspense, useConfidentialBatchTransfer, useConfidentialTransfer, useFinalizeUnwrap, useSetOperator, useShield, useShieldETH, useSupportsInterface, useSupportsInterfaceSuspense, useUnderlyingToken, useUnderlyingTokenSuspense, useUnwrap, useUnwrapFromBalance, useWrapperExists, useWrapperExistsSuspense, useWrapperForToken, useWrapperForTokenSuspense };
285
- //# sourceMappingURL=index.js.map
1
+ "use client";import{TransactionRevertedError as e}from"@zama-fhe/sdk";import{getAccount as t,getChainId as n,readContract as r,signTypedData as i,waitForTransactionReceipt as a,watchConnection as o,writeContract as s}from"wagmi/actions";var c=class{config;constructor(e){this.config=e.config}async getChainId(){return n(this.config)}async getAddress(){let e=t(this.config);if(!e?.address)throw TypeError(`Invalid address`);return e.address}async signTypedData(e){let{EIP712Domain:t,...n}=e.types;return i(this.config,{primaryType:Object.keys(n)[0],types:n,domain:e.domain,message:e.message})}async writeContract(e){return s(this.config,e)}async readContract(e){return r(this.config,e)}async waitForTransactionReceipt(t){try{return await a(this.config,{hash:t})}catch(n){let r=n instanceof Error?n.message:String(n);throw r.includes(`could not be found`)||r.includes(`Transaction not found`)?new e(`Could not find transaction receipt for hash "${t.slice(0,10)}…". If using ERC-4337 with a bundler, your connector may be returning a UserOperation hash instead of a transaction hash.`,{cause:n instanceof Error?n:void 0}):n}}subscribe({onDisconnect:e=()=>{},onAccountChange:t=()=>{},onChainChange:n=()=>{}}){return o(this.config,{onChange(r,i){r.status===`disconnected`&&i.status!==`disconnected`&&e(),i.address&&r.address&&r.address!==i.address&&t(r.address),typeof i.chainId==`number`&&typeof r.chainId==`number`&&r.chainId!==i.chainId&&n(r.chainId)}})}};export{c as WagmiSigner};
286
2
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/wagmi/compat.ts","../../src/wagmi/use-balance-of.ts","../../src/wagmi/use-confidential-balance-of.ts","../../src/wagmi/use-confidential-transfer.ts","../../src/wagmi/use-confidential-batch-transfer.ts","../../src/wagmi/use-unwrap.ts","../../src/wagmi/use-unwrap-from-balance.ts","../../src/wagmi/use-finalize-unwrap.ts","../../src/wagmi/use-set-operator.ts","../../src/wagmi/use-wrapper-for-token.ts","../../src/wagmi/use-underlying-token.ts","../../src/wagmi/use-wrapper-exists.ts","../../src/wagmi/use-supports-interface.ts","../../src/wagmi/use-wrap.ts","../../src/wagmi/use-wrap-eth.ts","../../src/wagmi/wagmi-signer.ts"],"names":["useConnection","getConnection","useWriteContract","useReadContract"],"mappings":";;;;;;;;AAMO,IAAMA,cAAAA,GAAgB,eAAA,IAAmB,KAAA,GAAc,KAAA,CAAA,aAAA,GAAgB,UAAA;AAGvE,IAAMC,cAAAA,GAAgB,eAAA,IAAmB,OAAA,GAAkB,OAAA,CAAA,aAAA,GAAgB,UAAA;;;ACa3E,SAAS,aAAa,MAAA,EAAgD;AAC3E,EAAA,MAAM,EAAE,OAAA,EAAS,gBAAA,EAAiB,GAAID,cAAAA,EAAc;AACpD,EAAA,MAAM,EAAE,YAAA,EAAc,WAAA,GAAc,gBAAA,EAAiB,GAAI,MAAA;AACzD,EAAA,MAAM,OAAA,GAAU,CAAC,CAAC,YAAA,IAAgB,CAAC,CAAC,WAAA;AAEpC,EAAA,MAAM,EAAE,IAAA,EAAM,GAAG,KAAA,KAAU,gBAAA,CAAiB;AAAA,IAC1C,SAAA,EAAW;AAAA,MACT,eAAe,YAAY,CAAA;AAAA,MAC3B,iBAAiB,YAAY,CAAA;AAAA,MA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AA,MAClB,SAAS,SAAA,CAAU;AAAA,KACpB,CAAA;AAAA,EACH;AAAA,EAEA,MAAM,cAA4C,MAAA,EAAyB;AACzE,IAAA,OAAO,aAAA,CAAc,IAAA,CAAK,MAAA,EAAQ,MAA6C,CAAA;AAAA,EACjF;AAAA,EAEA,MAAM,aAAmE,MAAA,EAAuB;AAC9F,IAAA,OAAO,YAAA,CAAa,IAAA,CAAK,MAAA,EAAQ,MAAM,CAAA;AAAA,EACzC;AAAA,EAEA,MAAM,0BAA0B,IAAA,EAAwC;AACtE,IAAA,IAAI;AACF,MAAA,OAAO,MAAM,yBAAA,CAA0B,IAAA,CAAK,MAAA,EAAQ,EAAE,MAAM,CAAA;AAAA,IAC9D,SAAS,KAAA,EAAO;AACd,MAAA,MAAM,UAAU,KAAA,YAAiB,KAAA,GAAQ,KAAA,CAAM,OAAA,GAAU,OAAO,KAAK,CAAA;AACrE,MAAA,IAAI,QAAQ,QAAA,CAAS,oBAAoB,KAAK,OAAA,CAAQ,QAAA,CAAS,uBAAuB,CAAA,EAAG;AACvF,QAAA,MAAM,IAAI,wBAAA;AAAA,UACR,CAAA,6CAAA,EAAgD,IAAA,CAAK,KAAA,CAAM,CAAA,EAAG,EAAE,CAAC,CAAA,8HAAA,CAAA;AAAA,UAGjE,EAAE,KAAA,EAAO,KAAA,YAAiB,KAAA,GAAQ,QAAQ,MAAA;AAAU,SACtD;AAAA,MACF;AACA,MAAA,MAAM,KAAA;AAAA,IACR;AAAA,EACF;AACF","file":"index.js","sourcesContent":["import * as wagmi from \"wagmi\";\nimport { useAccount } from \"wagmi\";\nimport * as actions from \"wagmi/actions\";\nimport { getAccount } from \"wagmi/actions\";\n\n// wagmi v3 renamed useAccount → useConnection\nexport const useConnection = \"useConnection\" in wagmi ? wagmi.useConnection : useAccount;\n\n// wagmi v3 renamed getAccount → getConnection\nexport const getConnection = \"getConnection\" in actions ? actions.getConnection : getAccount;\n","\"use client\";\n\nimport type { Address } from \"@zama-fhe/sdk\";\nimport { balanceOfContract, decimalsContract, symbolContract } from \"@zama-fhe/sdk\";\nimport { formatUnits } from \"viem\";\nimport { useReadContracts } from \"wagmi\";\nimport { useConnection } from \"./compat\";\n\nexport interface UseBalanceOfConfig {\n tokenAddress: Address;\n userAddress?: Address;\n}\n\nexport type UseBalanceOfResult = Omit<ReturnType<typeof useReadContracts>, \"data\"> & {\n data: {\n value: bigint | undefined;\n symbol: string | undefined;\n decimals: number | undefined;\n formatted: string | undefined;\n };\n};\n\nexport function useBalanceOf(config: UseBalanceOfConfig): UseBalanceOfResult {\n const { address: connectedAddress } = useConnection();\n const { tokenAddress, userAddress = connectedAddress } = config;\n const enabled = !!tokenAddress && !!userAddress;\n\n const { data, ...query } = useReadContracts({\n contracts: [\n symbolContract(tokenAddress),\n decimalsContract(tokenAddress),\n enabled ? balanceOfContract(tokenAddress, userAddress) : {},\n ],\n query: { enabled },\n });\n\n const symbol = data?.[0]?.result as string | undefined;\n const decimals = data?.[1]?.result as number | undefined;\n const value = data?.[2]?.result as bigint | undefined;\n const formatted =\n value !== undefined && decimals !== undefined ? formatUnits(value, decimals) : undefined;\n\n return {\n data: { value, symbol, decimals, formatted },\n ...query,\n };\n}\n\nexport interface UseBalanceOfSuspenseConfig {\n tokenAddress: Address;\n userAddress?: Address;\n}\n\nexport function useBalanceOfSuspense(config: UseBalanceOfSuspenseConfig): UseBalanceOfResult {\n const { address: connectedAddress } = useConnection();\n const { tokenAddress, userAddress = connectedAddress } = config;\n const enabled = !!userAddress;\n\n const { data, ...query } = useReadContracts({\n contracts: [\n symbolContract(tokenAddress),\n decimalsContract(tokenAddress),\n enabled ? balanceOfContract(tokenAddress, userAddress) : {},\n ],\n query: { suspense: true, enabled: enabled },\n });\n\n const symbol = data?.[0]?.result as string | undefined;\n const decimals = data?.[1]?.result as number | undefined;\n const value = data?.[2]?.result as bigint | undefined;\n const formatted =\n value !== undefined && decimals !== undefined ? formatUnits(value, decimals) : undefined;\n\n return {\n data: { value, symbol, decimals, formatted },\n ...query,\n };\n}\n","\"use client\";\n\nimport { confidentialBalanceOfContract } from \"@zama-fhe/sdk\";\nimport type { Address } from \"@zama-fhe/sdk\";\nimport { useReadContract } from \"wagmi\";\n\nexport interface UseConfidentialBalanceOfConfig {\n tokenAddress: Address | undefined;\n userAddress: Address | undefined;\n}\n\nexport function useConfidentialBalanceOf(config: UseConfidentialBalanceOfConfig) {\n const { tokenAddress, userAddress } = config;\n const enabled = !!tokenAddress && !!userAddress;\n const contract = enabled ? confidentialBalanceOfContract(tokenAddress, userAddress) : {};\n return useReadContract({ ...contract, query: { enabled } });\n}\n\nexport interface UseConfidentialBalanceOfSuspenseConfig {\n tokenAddress: Address;\n userAddress: Address;\n}\n\nexport function useConfidentialBalanceOfSuspense(config: UseConfidentialBalanceOfSuspenseConfig) {\n const contract = confidentialBalanceOfContract(config.tokenAddress, config.userAddress);\n return useReadContract({ ...contract, query: { suspense: true } });\n}\n","\"use client\";\n\nimport { confidentialTransferContract } from \"@zama-fhe/sdk\";\nimport { useWriteContract } from \"wagmi\";\n\ntype EncryptedTransferParameters = Parameters<typeof confidentialTransferContract>;\n\nexport function useConfidentialTransfer() {\n const { mutate, mutateAsync, ...mutation } = useWriteContract();\n\n function transfer(\n encryptedErc20: EncryptedTransferParameters[0],\n to: EncryptedTransferParameters[1],\n handle: EncryptedTransferParameters[2],\n inputProof: EncryptedTransferParameters[3],\n ) {\n return mutate(confidentialTransferContract(encryptedErc20, to, handle, inputProof));\n }\n\n async function transferAsync(\n encryptedErc20: EncryptedTransferParameters[0],\n to: EncryptedTransferParameters[1],\n handle: EncryptedTransferParameters[2],\n inputProof: EncryptedTransferParameters[3],\n ) {\n return mutateAsync(confidentialTransferContract(encryptedErc20, to, handle, inputProof));\n }\n\n return {\n mutate: transfer,\n mutateAsync: transferAsync,\n ...mutation,\n };\n}\n","\"use client\";\n\nimport { confidentialBatchTransferContract } from \"@zama-fhe/sdk\";\nimport { useWriteContract } from \"wagmi\";\n\ntype BatchTransferParameters = Parameters<typeof confidentialBatchTransferContract>;\n\nexport function useConfidentialBatchTransfer() {\n const { mutate, mutateAsync, ...mutation } = useWriteContract();\n\n function batchTransfer(\n batcherAddress: BatchTransferParameters[0],\n tokenAddress: BatchTransferParameters[1],\n fromAddress: BatchTransferParameters[2],\n batchTransferData: BatchTransferParameters[3],\n fees: BatchTransferParameters[4],\n ) {\n return mutate(\n confidentialBatchTransferContract(\n batcherAddress,\n tokenAddress,\n fromAddress,\n batchTransferData,\n fees,\n ),\n );\n }\n\n async function batchTransferAsync(\n batcherAddress: BatchTransferParameters[0],\n tokenAddress: BatchTransferParameters[1],\n fromAddress: BatchTransferParameters[2],\n batchTransferData: BatchTransferParameters[3],\n fees: BatchTransferParameters[4],\n ) {\n return mutateAsync(\n confidentialBatchTransferContract(\n batcherAddress,\n tokenAddress,\n fromAddress,\n batchTransferData,\n fees,\n ),\n );\n }\n\n return {\n mutate: batchTransfer,\n mutateAsync: batchTransferAsync,\n ...mutation,\n };\n}\n","\"use client\";\n\nimport { unwrapContract } from \"@zama-fhe/sdk\";\nimport { useWriteContract } from \"wagmi\";\n\ntype UnwrapParameters = Parameters<typeof unwrapContract>;\n\nexport function useUnwrap() {\n const { mutate, mutateAsync, ...mutation } = useWriteContract();\n\n function unwrap(\n encryptedErc20: UnwrapParameters[0],\n from: UnwrapParameters[1],\n to: UnwrapParameters[2],\n encryptedAmount: UnwrapParameters[3],\n inputProof: UnwrapParameters[4],\n ) {\n return mutate(unwrapContract(encryptedErc20, from, to, encryptedAmount, inputProof));\n }\n\n async function unwrapAsync(\n encryptedErc20: UnwrapParameters[0],\n from: UnwrapParameters[1],\n to: UnwrapParameters[2],\n encryptedAmount: UnwrapParameters[3],\n inputProof: UnwrapParameters[4],\n ) {\n return mutateAsync(unwrapContract(encryptedErc20, from, to, encryptedAmount, inputProof));\n }\n\n return {\n mutate: unwrap,\n mutateAsync: unwrapAsync,\n ...mutation,\n };\n}\n","\"use client\";\n\nimport { unwrapFromBalanceContract } from \"@zama-fhe/sdk\";\nimport { useWriteContract } from \"wagmi\";\n\ntype UnwrapFromBalanceParameters = Parameters<typeof unwrapFromBalanceContract>;\n\nexport function useUnwrapFromBalance() {\n const { mutate, mutateAsync, ...mutation } = useWriteContract();\n\n function unwrapFromBalance(\n encryptedErc20: UnwrapFromBalanceParameters[0],\n from: UnwrapFromBalanceParameters[1],\n to: UnwrapFromBalanceParameters[2],\n encryptedBalance: UnwrapFromBalanceParameters[3],\n ) {\n return mutate(unwrapFromBalanceContract(encryptedErc20, from, to, encryptedBalance));\n }\n\n async function unwrapFromBalanceAsync(\n encryptedErc20: UnwrapFromBalanceParameters[0],\n from: UnwrapFromBalanceParameters[1],\n to: UnwrapFromBalanceParameters[2],\n encryptedBalance: UnwrapFromBalanceParameters[3],\n ) {\n return mutateAsync(unwrapFromBalanceContract(encryptedErc20, from, to, encryptedBalance));\n }\n\n return {\n mutate: unwrapFromBalance,\n mutateAsync: unwrapFromBalanceAsync,\n ...mutation,\n };\n}\n","\"use client\";\n\nimport { finalizeUnwrapContract } from \"@zama-fhe/sdk\";\nimport { useWriteContract } from \"wagmi\";\n\ntype FinalizeUnwrapParameters = Parameters<typeof finalizeUnwrapContract>;\n\nexport function useFinalizeUnwrap() {\n const { mutate, mutateAsync, ...mutation } = useWriteContract();\n\n function finalizeUnwrap(\n wrapper: FinalizeUnwrapParameters[0],\n burntAmount: FinalizeUnwrapParameters[1],\n burntAmountCleartext: FinalizeUnwrapParameters[2],\n decryptionProof: FinalizeUnwrapParameters[3],\n ) {\n return mutate(\n finalizeUnwrapContract(wrapper, burntAmount, burntAmountCleartext, decryptionProof),\n );\n }\n\n async function finalizeUnwrapAsync(\n wrapper: FinalizeUnwrapParameters[0],\n burntAmount: FinalizeUnwrapParameters[1],\n burntAmountCleartext: FinalizeUnwrapParameters[2],\n decryptionProof: FinalizeUnwrapParameters[3],\n ) {\n return mutateAsync(\n finalizeUnwrapContract(wrapper, burntAmount, burntAmountCleartext, decryptionProof),\n );\n }\n\n return {\n mutate: finalizeUnwrap,\n mutateAsync: finalizeUnwrapAsync,\n ...mutation,\n };\n}\n","\"use client\";\n\nimport { setOperatorContract } from \"@zama-fhe/sdk\";\nimport { useWriteContract } from \"wagmi\";\n\ntype SetOperatorParameters = Parameters<typeof setOperatorContract>;\n\nexport function useSetOperator() {\n const { mutate, mutateAsync, ...mutation } = useWriteContract();\n\n function setOperator(\n tokenAddress: SetOperatorParameters[0],\n spender: SetOperatorParameters[1],\n timestamp?: SetOperatorParameters[2],\n ) {\n return mutate(setOperatorContract(tokenAddress, spender, timestamp));\n }\n\n async function setOperatorAsync(\n tokenAddress: SetOperatorParameters[0],\n spender: SetOperatorParameters[1],\n timestamp?: SetOperatorParameters[2],\n ) {\n return mutateAsync(setOperatorContract(tokenAddress, spender, timestamp));\n }\n\n return {\n mutate: setOperator,\n mutateAsync: setOperatorAsync,\n ...mutation,\n };\n}\n","\"use client\";\n\nimport { getWrapperContract } from \"@zama-fhe/sdk\";\nimport type { Address } from \"@zama-fhe/sdk\";\nimport { useReadContract } from \"wagmi\";\n\nexport interface UseWrapperForZamaConfig {\n coordinator: Address | undefined;\n tokenAddress: Address | undefined;\n}\n\nexport function useWrapperForToken(config: UseWrapperForZamaConfig) {\n const { coordinator, tokenAddress } = config;\n const enabled = !!coordinator && !!tokenAddress;\n const contract = enabled ? getWrapperContract(coordinator, tokenAddress) : {};\n return useReadContract({ ...contract, query: { enabled } });\n}\n\nexport interface UseWrapperForTokenSuspenseConfig {\n coordinator: Address;\n tokenAddress: Address;\n}\n\nexport function useWrapperForTokenSuspense(config: UseWrapperForTokenSuspenseConfig) {\n const contract = getWrapperContract(config.coordinator, config.tokenAddress);\n return useReadContract({ ...contract, query: { suspense: true } });\n}\n","\"use client\";\n\nimport { underlyingContract } from \"@zama-fhe/sdk\";\nimport type { Address } from \"@zama-fhe/sdk\";\nimport { useReadContract } from \"wagmi\";\n\nexport interface UseUnderlyingZamaConfig {\n wrapperAddress: Address | undefined;\n}\n\nexport function useUnderlyingToken(config: UseUnderlyingZamaConfig) {\n const { wrapperAddress } = config;\n const enabled = !!wrapperAddress;\n const contract = enabled ? underlyingContract(wrapperAddress) : {};\n return useReadContract({ ...contract, query: { enabled } });\n}\n\nexport interface UseUnderlyingTokenSuspenseConfig {\n wrapperAddress: Address;\n}\n\nexport function useUnderlyingTokenSuspense(config: UseUnderlyingTokenSuspenseConfig) {\n const contract = underlyingContract(config.wrapperAddress);\n return useReadContract({ ...contract, query: { suspense: true } });\n}\n","\"use client\";\n\nimport { wrapperExistsContract } from \"@zama-fhe/sdk\";\nimport type { Address } from \"@zama-fhe/sdk\";\nimport { useReadContract } from \"wagmi\";\n\nexport interface UseWrapperExistsConfig {\n coordinator: Address | undefined;\n tokenAddress: Address | undefined;\n}\n\nexport function useWrapperExists(config: UseWrapperExistsConfig) {\n const { coordinator, tokenAddress } = config;\n const enabled = !!coordinator && !!tokenAddress;\n const contract = enabled ? wrapperExistsContract(coordinator, tokenAddress) : {};\n return useReadContract({ ...contract, query: { enabled } });\n}\n\nexport interface UseWrapperExistsSuspenseConfig {\n coordinator: Address;\n tokenAddress: Address;\n}\n\nexport function useWrapperExistsSuspense(config: UseWrapperExistsSuspenseConfig) {\n const contract = wrapperExistsContract(config.coordinator, config.tokenAddress);\n return useReadContract({ ...contract, query: { suspense: true } });\n}\n","\"use client\";\n\nimport { supportsInterfaceContract } from \"@zama-fhe/sdk\";\nimport type { Address } from \"@zama-fhe/sdk\";\nimport { useReadContract } from \"wagmi\";\n\nexport interface UseSupportsInterfaceConfig {\n tokenAddress: Address | undefined;\n interfaceId: Address | undefined;\n}\n\nexport function useSupportsInterface(config: UseSupportsInterfaceConfig) {\n const { tokenAddress, interfaceId } = config;\n const enabled = !!tokenAddress && !!interfaceId;\n const contract = enabled ? supportsInterfaceContract(tokenAddress, interfaceId) : {};\n return useReadContract({ ...contract, query: { enabled } });\n}\n\nexport interface UseSupportsInterfaceSuspenseConfig {\n tokenAddress: Address;\n interfaceId: Address;\n}\n\nexport function useSupportsInterfaceSuspense(config: UseSupportsInterfaceSuspenseConfig) {\n const contract = supportsInterfaceContract(config.tokenAddress, config.interfaceId);\n return useReadContract({ ...contract, query: { suspense: true } });\n}\n","\"use client\";\n\nimport { wrapContract } from \"@zama-fhe/sdk\";\nimport { useWriteContract } from \"wagmi\";\n\ntype WrapParameters = Parameters<typeof wrapContract>;\n\nexport function useShield() {\n const { mutate, mutateAsync, ...mutation } = useWriteContract();\n\n function shield(\n wrapperAddress: WrapParameters[0],\n to: WrapParameters[1],\n amount: WrapParameters[2],\n ) {\n return mutate(wrapContract(wrapperAddress, to, amount));\n }\n\n async function shieldAsync(\n wrapperAddress: WrapParameters[0],\n to: WrapParameters[1],\n amount: WrapParameters[2],\n ) {\n return mutateAsync(wrapContract(wrapperAddress, to, amount));\n }\n\n return {\n mutate: shield,\n mutateAsync: shieldAsync,\n ...mutation,\n };\n}\n","\"use client\";\n\nimport { wrapETHContract } from \"@zama-fhe/sdk\";\nimport { useWriteContract } from \"wagmi\";\n\ntype WrapETHParameters = Parameters<typeof wrapETHContract>;\n\nexport function useShieldETH() {\n const { mutate, mutateAsync, ...mutation } = useWriteContract();\n\n function shieldETH(\n wrapperAddress: WrapETHParameters[0],\n to: WrapETHParameters[1],\n amount: WrapETHParameters[2],\n value: WrapETHParameters[3],\n ) {\n return mutate(wrapETHContract(wrapperAddress, to, amount, value));\n }\n\n async function shieldETHAsync(\n wrapperAddress: WrapETHParameters[0],\n to: WrapETHParameters[1],\n amount: WrapETHParameters[2],\n value: WrapETHParameters[3],\n ) {\n return mutateAsync(wrapETHContract(wrapperAddress, to, amount, value));\n }\n\n return {\n mutate: shieldETH,\n mutateAsync: shieldETHAsync,\n ...mutation,\n };\n}\n","import type {\n GenericSigner,\n ContractCallConfig,\n TransactionReceipt,\n Address,\n Hex,\n EIP712TypedData,\n} from \"@zama-fhe/sdk\";\nimport { TransactionRevertedError } from \"@zama-fhe/sdk\";\nimport type { Config } from \"wagmi\";\nimport {\n getChainId,\n readContract,\n signTypedData,\n waitForTransactionReceipt,\n writeContract,\n} from \"wagmi/actions\";\nimport { getConnection } from \"./compat\";\n\n/** Configuration for {@link WagmiSigner}. */\nexport interface WagmiSignerConfig {\n config: Config;\n}\n\n/**\n * GenericSigner backed by wagmi.\n *\n * @param signerConfig - {@link WagmiSignerConfig} with wagmi config\n */\nexport class WagmiSigner implements GenericSigner {\n private readonly config: Config;\n\n constructor(signerConfig: WagmiSignerConfig) {\n this.config = signerConfig.config;\n }\n\n async getChainId(): Promise<number> {\n return getChainId(this.config);\n }\n\n async getAddress(): Promise<Address> {\n const account = getConnection(this.config);\n if (!account?.address) {\n throw new TypeError(\"Invalid address\");\n }\n return account.address;\n }\n\n async signTypedData(typedData: EIP712TypedData): Promise<Hex> {\n const { EIP712Domain: _, ...sigTypes } = typedData.types;\n return signTypedData(this.config, {\n primaryType: Object.keys(sigTypes)[0]!,\n types: sigTypes,\n domain: typedData.domain,\n message: typedData.message,\n });\n }\n\n async writeContract<C extends ContractCallConfig>(config: C): Promise<Hex> {\n return writeContract(this.config, config as Parameters<typeof writeContract>[1]);\n }\n\n async readContract<T, C extends ContractCallConfig = ContractCallConfig>(config: C): Promise<T> {\n return readContract(this.config, config) as Promise<T>;\n }\n\n async waitForTransactionReceipt(hash: Hex): Promise<TransactionReceipt> {\n try {\n return await waitForTransactionReceipt(this.config, { hash });\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n if (message.includes(\"could not be found\") || message.includes(\"Transaction not found\")) {\n throw new TransactionRevertedError(\n `Could not find transaction receipt for hash \"${hash.slice(0, 10)}…\". ` +\n \"If using ERC-4337 with a bundler, your connector may be returning a UserOperation hash \" +\n \"instead of a transaction hash.\",\n { cause: error instanceof Error ? error : undefined },\n );\n }\n throw error;\n }\n }\n}\n"]}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../src/wagmi/wagmi-signer.ts"],"sourcesContent":["import type {\n Address,\n ContractAbi,\n EIP712TypedData,\n GenericSigner,\n Hex,\n ReadContractArgs,\n ReadContractConfig,\n ReadContractReturnType,\n ReadFunctionName,\n SignerLifecycleCallbacks,\n TransactionReceipt,\n WriteContractArgs,\n WriteFunctionName,\n WriteContractConfig,\n} from \"@zama-fhe/sdk\";\nimport { TransactionRevertedError } from \"@zama-fhe/sdk\";\nimport type { Config } from \"wagmi\";\nimport {\n getChainId,\n getAccount,\n readContract,\n signTypedData,\n waitForTransactionReceipt,\n watchConnection,\n writeContract,\n} from \"wagmi/actions\";\n\n/** Configuration for {@link WagmiSigner}. */\nexport interface WagmiSignerConfig {\n config: Config;\n}\n\n/**\n * GenericSigner backed by wagmi.\n *\n * @param signerConfig - {@link WagmiSignerConfig} with wagmi config\n */\nexport class WagmiSigner implements GenericSigner {\n private readonly config: Config;\n\n constructor(signerConfig: WagmiSignerConfig) {\n this.config = signerConfig.config;\n }\n\n async getChainId(): Promise<number> {\n return getChainId(this.config);\n }\n\n async getAddress(): Promise<Address> {\n const account = getAccount(this.config);\n if (!account?.address) {\n throw new TypeError(\"Invalid address\");\n }\n return account.address;\n }\n\n async signTypedData(typedData: EIP712TypedData): Promise<Hex> {\n const { EIP712Domain: _, ...sigTypes } = typedData.types;\n return signTypedData(this.config, {\n primaryType: Object.keys(sigTypes)[0]!,\n types: sigTypes,\n domain: typedData.domain,\n message: typedData.message,\n });\n }\n\n async writeContract<\n const TAbi extends ContractAbi,\n TFunctionName extends WriteFunctionName<TAbi>,\n const TArgs extends WriteContractArgs<TAbi, TFunctionName>,\n >(config: WriteContractConfig<TAbi, TFunctionName, TArgs>): Promise<Hex> {\n return writeContract(this.config, config as Parameters<typeof writeContract>[1]);\n }\n\n async readContract<\n const TAbi extends ContractAbi,\n TFunctionName extends ReadFunctionName<TAbi>,\n const TArgs extends ReadContractArgs<TAbi, TFunctionName>,\n >(\n config: ReadContractConfig<TAbi, TFunctionName, TArgs>,\n ): Promise<ReadContractReturnType<TAbi, TFunctionName, TArgs>> {\n return readContract(this.config, config);\n }\n\n async waitForTransactionReceipt(hash: Hex): Promise<TransactionReceipt> {\n try {\n return await waitForTransactionReceipt(this.config, { hash });\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n if (message.includes(\"could not be found\") || message.includes(\"Transaction not found\")) {\n throw new TransactionRevertedError(\n `Could not find transaction receipt for hash \"${hash.slice(0, 10)}…\". ` +\n \"If using ERC-4337 with a bundler, your connector may be returning a UserOperation hash \" +\n \"instead of a transaction hash.\",\n { cause: error instanceof Error ? error : undefined },\n );\n }\n throw error;\n }\n }\n\n subscribe({\n onDisconnect = () => {},\n onAccountChange = () => {},\n onChainChange = () => {},\n }: SignerLifecycleCallbacks): () => void {\n return watchConnection(this.config, {\n onChange(connection, prevConnection) {\n if (connection.status === \"disconnected\" && prevConnection.status !== \"disconnected\") {\n onDisconnect();\n }\n if (\n prevConnection.address &&\n connection.address &&\n connection.address !== prevConnection.address\n ) {\n onAccountChange(connection.address);\n }\n if (\n typeof prevConnection.chainId === \"number\" &&\n typeof connection.chainId === \"number\" &&\n connection.chainId !== prevConnection.chainId\n ) {\n onChainChange(connection.chainId);\n }\n },\n });\n }\n}\n"],"mappings":"6OAsCA,IAAa,EAAb,KAAkD,CAChD,OAEA,YAAY,EAAiC,CAC3C,KAAK,OAAS,EAAa,OAG7B,MAAM,YAA8B,CAClC,OAAO,EAAW,KAAK,OAAO,CAGhC,MAAM,YAA+B,CACnC,IAAM,EAAU,EAAW,KAAK,OAAO,CACvC,GAAI,CAAC,GAAS,QACZ,MAAU,UAAU,kBAAkB,CAExC,OAAO,EAAQ,QAGjB,MAAM,cAAc,EAA0C,CAC5D,GAAM,CAAE,aAAc,EAAG,GAAG,GAAa,EAAU,MACnD,OAAO,EAAc,KAAK,OAAQ,CAChC,YAAa,OAAO,KAAK,EAAS,CAAC,GACnC,MAAO,EACP,OAAQ,EAAU,OAClB,QAAS,EAAU,QACpB,CAAC,CAGJ,MAAM,cAIJ,EAAuE,CACvE,OAAO,EAAc,KAAK,OAAQ,EAA8C,CAGlF,MAAM,aAKJ,EAC6D,CAC7D,OAAO,EAAa,KAAK,OAAQ,EAAO,CAG1C,MAAM,0BAA0B,EAAwC,CACtE,GAAI,CACF,OAAO,MAAM,EAA0B,KAAK,OAAQ,CAAE,OAAM,CAAC,OACtD,EAAO,CACd,IAAM,EAAU,aAAiB,MAAQ,EAAM,QAAU,OAAO,EAAM,CAStE,MARI,EAAQ,SAAS,qBAAqB,EAAI,EAAQ,SAAS,wBAAwB,CAC/E,IAAI,EACR,gDAAgD,EAAK,MAAM,EAAG,GAAG,CAAC,2HAGlE,CAAE,MAAO,aAAiB,MAAQ,EAAQ,IAAA,GAAW,CACtD,CAEG,GAIV,UAAU,CACR,mBAAqB,GACrB,sBAAwB,GACxB,oBAAsB,IACiB,CACvC,OAAO,EAAgB,KAAK,OAAQ,CAClC,SAAS,EAAY,EAAgB,CAC/B,EAAW,SAAW,gBAAkB,EAAe,SAAW,gBACpE,GAAc,CAGd,EAAe,SACf,EAAW,SACX,EAAW,UAAY,EAAe,SAEtC,EAAgB,EAAW,QAAQ,CAGnC,OAAO,EAAe,SAAY,UAClC,OAAO,EAAW,SAAY,UAC9B,EAAW,UAAY,EAAe,SAEtC,EAAc,EAAW,QAAQ,EAGtC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zama-fhe/react-sdk",
3
- "version": "1.0.0-alpha.7",
3
+ "version": "1.0.1",
4
4
  "description": "React hooks for Zama SDK",
5
5
  "license": "BSD-3-Clause-Clear",
6
6
  "author": "Zama",
@@ -17,14 +17,6 @@
17
17
  "types": "./dist/index.d.ts",
18
18
  "import": "./dist/index.js"
19
19
  },
20
- "./viem": {
21
- "types": "./dist/viem/index.d.ts",
22
- "import": "./dist/viem/index.js"
23
- },
24
- "./ethers": {
25
- "types": "./dist/ethers/index.d.ts",
26
- "import": "./dist/ethers/index.js"
27
- },
28
20
  "./wagmi": {
29
21
  "types": "./dist/wagmi/index.d.ts",
30
22
  "import": "./dist/wagmi/index.js"
@@ -55,37 +47,28 @@
55
47
  "url": "https://github.com/zama-ai/sdk/issues"
56
48
  },
57
49
  "scripts": {
58
- "build": "tsup",
50
+ "build": "rm -rf dist && rolldown --config rolldown.config.ts",
59
51
  "lint": "eslint .",
60
52
  "typecheck": "tsc --noEmit"
61
53
  },
62
54
  "devDependencies": {
63
55
  "@zama-fhe/sdk": "workspace:*",
64
- "tsup": "^8.5.1"
56
+ "rolldown": "1.0.0-rc.7",
57
+ "rolldown-plugin-dts": "^0.22.4"
65
58
  },
66
59
  "peerDependencies": {
67
- "@zama-fhe/sdk": "^1.0.0-alpha.7",
68
- "react": ">=18",
69
60
  "@tanstack/react-query": ">=5",
70
- "ethers": ">=6",
71
- "viem": ">=2",
61
+ "@zama-fhe/sdk": "^1.0.1",
62
+ "react": ">=18",
72
63
  "wagmi": ">=2"
73
64
  },
74
65
  "sideEffects": false,
75
66
  "peerDependenciesMeta": {
76
- "ethers": {
77
- "optional": true
78
- },
79
- "viem": {
80
- "optional": true
81
- },
82
67
  "wagmi": {
83
68
  "optional": true
84
69
  }
85
70
  },
86
- "packageManager": "pnpm@10.30.2",
87
71
  "engines": {
88
- "node": ">=22",
89
- "pnpm": ">=10"
72
+ "node": ">=22"
90
73
  }
91
74
  }