@zama-fhe/react-sdk 1.0.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.
- package/LICENSE +28 -0
- package/README.md +735 -0
- package/dist/ethers/index.d.ts +162 -0
- package/dist/ethers/index.js +173 -0
- package/dist/ethers/index.js.map +1 -0
- package/dist/index.d.ts +1820 -0
- package/dist/index.js +978 -0
- package/dist/index.js.map +1 -0
- package/dist/viem/index.d.ts +162 -0
- package/dist/viem/index.js +173 -0
- package/dist/viem/index.js.map +1 -0
- package/dist/wagmi/index.d.ts +7133 -0
- package/dist/wagmi/index.js +269 -0
- package/dist/wagmi/index.js.map +1 -0
- package/package.json +88 -0
|
@@ -0,0 +1,269 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { symbolContract, decimalsContract, balanceOfContract, confidentialBalanceOfContract, getWrapperContract, underlyingContract, wrapperExistsContract, supportsInterfaceContract, confidentialBatchTransferContract, confidentialTransferContract, finalizeUnwrapContract, setOperatorContract, unwrapContract, unwrapFromBalanceContract, wrapContract, wrapETHContract } from '@zama-fhe/sdk';
|
|
3
|
+
import { formatUnits } from 'viem';
|
|
4
|
+
import { useConnection, useReadContracts, useReadContract, useWriteContract } from 'wagmi';
|
|
5
|
+
import { getChainId, getConnection, signTypedData, writeContract, readContract, waitForTransactionReceipt } from 'wagmi/actions';
|
|
6
|
+
|
|
7
|
+
// src/wagmi/use-balance-of.ts
|
|
8
|
+
function useBalanceOf(config) {
|
|
9
|
+
const { address: connectedAddress } = useConnection();
|
|
10
|
+
const { tokenAddress, userAddress = connectedAddress } = config;
|
|
11
|
+
const enabled = !!tokenAddress && !!userAddress;
|
|
12
|
+
const { data, ...query } = useReadContracts({
|
|
13
|
+
contracts: [
|
|
14
|
+
symbolContract(tokenAddress),
|
|
15
|
+
decimalsContract(tokenAddress),
|
|
16
|
+
enabled ? balanceOfContract(tokenAddress, userAddress) : {}
|
|
17
|
+
],
|
|
18
|
+
query: { enabled }
|
|
19
|
+
});
|
|
20
|
+
const symbol = data?.[0]?.result;
|
|
21
|
+
const decimals = data?.[1]?.result;
|
|
22
|
+
const value = data?.[2]?.result;
|
|
23
|
+
const formatted = value !== void 0 && decimals !== void 0 ? formatUnits(value, decimals) : void 0;
|
|
24
|
+
return {
|
|
25
|
+
data: { value, symbol, decimals, formatted },
|
|
26
|
+
...query
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
function useBalanceOfSuspense(config) {
|
|
30
|
+
const { address: connectedAddress } = useConnection();
|
|
31
|
+
const { tokenAddress, userAddress = connectedAddress } = config;
|
|
32
|
+
const enabled = !!userAddress;
|
|
33
|
+
const { data, ...query } = useReadContracts({
|
|
34
|
+
contracts: [
|
|
35
|
+
symbolContract(tokenAddress),
|
|
36
|
+
decimalsContract(tokenAddress),
|
|
37
|
+
enabled ? balanceOfContract(tokenAddress, userAddress) : {}
|
|
38
|
+
],
|
|
39
|
+
query: { suspense: true, enabled }
|
|
40
|
+
});
|
|
41
|
+
const symbol = data?.[0]?.result;
|
|
42
|
+
const decimals = data?.[1]?.result;
|
|
43
|
+
const value = data?.[2]?.result;
|
|
44
|
+
const formatted = value !== void 0 && decimals !== void 0 ? formatUnits(value, decimals) : void 0;
|
|
45
|
+
return {
|
|
46
|
+
data: { value, symbol, decimals, formatted },
|
|
47
|
+
...query
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
function useConfidentialBalanceOf(config) {
|
|
51
|
+
const { tokenAddress, userAddress } = config;
|
|
52
|
+
const enabled = !!tokenAddress && !!userAddress;
|
|
53
|
+
const contract = enabled ? confidentialBalanceOfContract(tokenAddress, userAddress) : {};
|
|
54
|
+
return useReadContract({ ...contract, query: { enabled } });
|
|
55
|
+
}
|
|
56
|
+
function useConfidentialBalanceOfSuspense(config) {
|
|
57
|
+
const contract = confidentialBalanceOfContract(config.tokenAddress, config.userAddress);
|
|
58
|
+
return useReadContract({ ...contract, query: { suspense: true } });
|
|
59
|
+
}
|
|
60
|
+
function useConfidentialTransfer() {
|
|
61
|
+
const { mutate, mutateAsync, ...mutation } = useWriteContract();
|
|
62
|
+
function transfer(encryptedErc20, to, handle, inputProof) {
|
|
63
|
+
return mutate(confidentialTransferContract(encryptedErc20, to, handle, inputProof));
|
|
64
|
+
}
|
|
65
|
+
async function transferAsync(encryptedErc20, to, handle, inputProof) {
|
|
66
|
+
return mutateAsync(confidentialTransferContract(encryptedErc20, to, handle, inputProof));
|
|
67
|
+
}
|
|
68
|
+
return {
|
|
69
|
+
mutate: transfer,
|
|
70
|
+
mutateAsync: transferAsync,
|
|
71
|
+
...mutation
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
function useConfidentialBatchTransfer() {
|
|
75
|
+
const { mutate, mutateAsync, ...mutation } = useWriteContract();
|
|
76
|
+
function batchTransfer(batcherAddress, tokenAddress, fromAddress, batchTransferData, fees) {
|
|
77
|
+
return mutate(
|
|
78
|
+
confidentialBatchTransferContract(
|
|
79
|
+
batcherAddress,
|
|
80
|
+
tokenAddress,
|
|
81
|
+
fromAddress,
|
|
82
|
+
batchTransferData,
|
|
83
|
+
fees
|
|
84
|
+
)
|
|
85
|
+
);
|
|
86
|
+
}
|
|
87
|
+
async function batchTransferAsync(batcherAddress, tokenAddress, fromAddress, batchTransferData, fees) {
|
|
88
|
+
return mutateAsync(
|
|
89
|
+
confidentialBatchTransferContract(
|
|
90
|
+
batcherAddress,
|
|
91
|
+
tokenAddress,
|
|
92
|
+
fromAddress,
|
|
93
|
+
batchTransferData,
|
|
94
|
+
fees
|
|
95
|
+
)
|
|
96
|
+
);
|
|
97
|
+
}
|
|
98
|
+
return {
|
|
99
|
+
mutate: batchTransfer,
|
|
100
|
+
mutateAsync: batchTransferAsync,
|
|
101
|
+
...mutation
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
function useUnwrap() {
|
|
105
|
+
const { mutate, mutateAsync, ...mutation } = useWriteContract();
|
|
106
|
+
function unwrap(encryptedErc20, from, to, encryptedAmount, inputProof) {
|
|
107
|
+
return mutate(unwrapContract(encryptedErc20, from, to, encryptedAmount, inputProof));
|
|
108
|
+
}
|
|
109
|
+
async function unwrapAsync(encryptedErc20, from, to, encryptedAmount, inputProof) {
|
|
110
|
+
return mutateAsync(unwrapContract(encryptedErc20, from, to, encryptedAmount, inputProof));
|
|
111
|
+
}
|
|
112
|
+
return {
|
|
113
|
+
mutate: unwrap,
|
|
114
|
+
mutateAsync: unwrapAsync,
|
|
115
|
+
...mutation
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
function useUnwrapFromBalance() {
|
|
119
|
+
const { mutate, mutateAsync, ...mutation } = useWriteContract();
|
|
120
|
+
function unwrapFromBalance(encryptedErc20, from, to, encryptedBalance) {
|
|
121
|
+
return mutate(unwrapFromBalanceContract(encryptedErc20, from, to, encryptedBalance));
|
|
122
|
+
}
|
|
123
|
+
async function unwrapFromBalanceAsync(encryptedErc20, from, to, encryptedBalance) {
|
|
124
|
+
return mutateAsync(unwrapFromBalanceContract(encryptedErc20, from, to, encryptedBalance));
|
|
125
|
+
}
|
|
126
|
+
return {
|
|
127
|
+
mutate: unwrapFromBalance,
|
|
128
|
+
mutateAsync: unwrapFromBalanceAsync,
|
|
129
|
+
...mutation
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
function useFinalizeUnwrap() {
|
|
133
|
+
const { mutate, mutateAsync, ...mutation } = useWriteContract();
|
|
134
|
+
function finalizeUnwrap(wrapper, burntAmount, burntAmountCleartext, decryptionProof) {
|
|
135
|
+
return mutate(
|
|
136
|
+
finalizeUnwrapContract(wrapper, burntAmount, burntAmountCleartext, decryptionProof)
|
|
137
|
+
);
|
|
138
|
+
}
|
|
139
|
+
async function finalizeUnwrapAsync(wrapper, burntAmount, burntAmountCleartext, decryptionProof) {
|
|
140
|
+
return mutateAsync(
|
|
141
|
+
finalizeUnwrapContract(wrapper, burntAmount, burntAmountCleartext, decryptionProof)
|
|
142
|
+
);
|
|
143
|
+
}
|
|
144
|
+
return {
|
|
145
|
+
mutate: finalizeUnwrap,
|
|
146
|
+
mutateAsync: finalizeUnwrapAsync,
|
|
147
|
+
...mutation
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
function useSetOperator() {
|
|
151
|
+
const { mutate, mutateAsync, ...mutation } = useWriteContract();
|
|
152
|
+
function setOperator(tokenAddress, spender, timestamp) {
|
|
153
|
+
return mutate(setOperatorContract(tokenAddress, spender, timestamp));
|
|
154
|
+
}
|
|
155
|
+
async function setOperatorAsync(tokenAddress, spender, timestamp) {
|
|
156
|
+
return mutateAsync(setOperatorContract(tokenAddress, spender, timestamp));
|
|
157
|
+
}
|
|
158
|
+
return {
|
|
159
|
+
mutate: setOperator,
|
|
160
|
+
mutateAsync: setOperatorAsync,
|
|
161
|
+
...mutation
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
function useWrapperForToken(config) {
|
|
165
|
+
const { coordinator, tokenAddress } = config;
|
|
166
|
+
const enabled = !!coordinator && !!tokenAddress;
|
|
167
|
+
const contract = enabled ? getWrapperContract(coordinator, tokenAddress) : {};
|
|
168
|
+
return useReadContract({ ...contract, query: { enabled } });
|
|
169
|
+
}
|
|
170
|
+
function useWrapperForTokenSuspense(config) {
|
|
171
|
+
const contract = getWrapperContract(config.coordinator, config.tokenAddress);
|
|
172
|
+
return useReadContract({ ...contract, query: { suspense: true } });
|
|
173
|
+
}
|
|
174
|
+
function useUnderlyingToken(config) {
|
|
175
|
+
const { wrapperAddress } = config;
|
|
176
|
+
const enabled = !!wrapperAddress;
|
|
177
|
+
const contract = enabled ? underlyingContract(wrapperAddress) : {};
|
|
178
|
+
return useReadContract({ ...contract, query: { enabled } });
|
|
179
|
+
}
|
|
180
|
+
function useUnderlyingTokenSuspense(config) {
|
|
181
|
+
const contract = underlyingContract(config.wrapperAddress);
|
|
182
|
+
return useReadContract({ ...contract, query: { suspense: true } });
|
|
183
|
+
}
|
|
184
|
+
function useWrapperExists(config) {
|
|
185
|
+
const { coordinator, tokenAddress } = config;
|
|
186
|
+
const enabled = !!coordinator && !!tokenAddress;
|
|
187
|
+
const contract = enabled ? wrapperExistsContract(coordinator, tokenAddress) : {};
|
|
188
|
+
return useReadContract({ ...contract, query: { enabled } });
|
|
189
|
+
}
|
|
190
|
+
function useWrapperExistsSuspense(config) {
|
|
191
|
+
const contract = wrapperExistsContract(config.coordinator, config.tokenAddress);
|
|
192
|
+
return useReadContract({ ...contract, query: { suspense: true } });
|
|
193
|
+
}
|
|
194
|
+
function useSupportsInterface(config) {
|
|
195
|
+
const { tokenAddress, interfaceId } = config;
|
|
196
|
+
const enabled = !!tokenAddress && !!interfaceId;
|
|
197
|
+
const contract = enabled ? supportsInterfaceContract(tokenAddress, interfaceId) : {};
|
|
198
|
+
return useReadContract({ ...contract, query: { enabled } });
|
|
199
|
+
}
|
|
200
|
+
function useSupportsInterfaceSuspense(config) {
|
|
201
|
+
const contract = supportsInterfaceContract(config.tokenAddress, config.interfaceId);
|
|
202
|
+
return useReadContract({ ...contract, query: { suspense: true } });
|
|
203
|
+
}
|
|
204
|
+
function useWrap() {
|
|
205
|
+
const { mutate, mutateAsync, ...mutation } = useWriteContract();
|
|
206
|
+
function wrap(wrapperAddress, to, amount) {
|
|
207
|
+
return mutate(wrapContract(wrapperAddress, to, amount));
|
|
208
|
+
}
|
|
209
|
+
async function wrapAsync(wrapperAddress, to, amount) {
|
|
210
|
+
return mutateAsync(wrapContract(wrapperAddress, to, amount));
|
|
211
|
+
}
|
|
212
|
+
return {
|
|
213
|
+
mutate: wrap,
|
|
214
|
+
mutateAsync: wrapAsync,
|
|
215
|
+
...mutation
|
|
216
|
+
};
|
|
217
|
+
}
|
|
218
|
+
function useWrapETH() {
|
|
219
|
+
const { mutate, mutateAsync, ...mutation } = useWriteContract();
|
|
220
|
+
function wrapETH(wrapperAddress, to, amount, value) {
|
|
221
|
+
return mutate(wrapETHContract(wrapperAddress, to, amount, value));
|
|
222
|
+
}
|
|
223
|
+
async function wrapETHAsync(wrapperAddress, to, amount, value) {
|
|
224
|
+
return mutateAsync(wrapETHContract(wrapperAddress, to, amount, value));
|
|
225
|
+
}
|
|
226
|
+
return {
|
|
227
|
+
mutate: wrapETH,
|
|
228
|
+
mutateAsync: wrapETHAsync,
|
|
229
|
+
...mutation
|
|
230
|
+
};
|
|
231
|
+
}
|
|
232
|
+
var WagmiSigner = class {
|
|
233
|
+
config;
|
|
234
|
+
constructor(config) {
|
|
235
|
+
this.config = config;
|
|
236
|
+
}
|
|
237
|
+
async getChainId() {
|
|
238
|
+
return getChainId(this.config);
|
|
239
|
+
}
|
|
240
|
+
async getAddress() {
|
|
241
|
+
const account = getConnection(this.config);
|
|
242
|
+
if (!account?.address) {
|
|
243
|
+
throw new TypeError("Invalid address");
|
|
244
|
+
}
|
|
245
|
+
return account.address;
|
|
246
|
+
}
|
|
247
|
+
async signTypedData(typedData) {
|
|
248
|
+
const { EIP712Domain: _, ...sigTypes } = typedData.types;
|
|
249
|
+
return signTypedData(this.config, {
|
|
250
|
+
primaryType: Object.keys(sigTypes)[0],
|
|
251
|
+
types: sigTypes,
|
|
252
|
+
domain: typedData.domain,
|
|
253
|
+
message: typedData.message
|
|
254
|
+
});
|
|
255
|
+
}
|
|
256
|
+
async writeContract(config) {
|
|
257
|
+
return writeContract(this.config, config);
|
|
258
|
+
}
|
|
259
|
+
async readContract(config) {
|
|
260
|
+
return readContract(this.config, config);
|
|
261
|
+
}
|
|
262
|
+
async waitForTransactionReceipt(hash) {
|
|
263
|
+
return waitForTransactionReceipt(this.config, { hash });
|
|
264
|
+
}
|
|
265
|
+
};
|
|
266
|
+
|
|
267
|
+
export { WagmiSigner, useBalanceOf, useBalanceOfSuspense, useConfidentialBalanceOf, useConfidentialBalanceOfSuspense, useConfidentialBatchTransfer, useConfidentialTransfer, useFinalizeUnwrap, useSetOperator, useSupportsInterface, useSupportsInterfaceSuspense, useUnderlyingToken, useUnderlyingTokenSuspense, useUnwrap, useUnwrapFromBalance, useWrap, useWrapETH, useWrapperExists, useWrapperExistsSuspense, useWrapperForToken, useWrapperForTokenSuspense };
|
|
268
|
+
//# sourceMappingURL=index.js.map
|
|
269
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../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":["useWriteContract","useReadContract"],"mappings":";;;;;;AAqBO,SAAS,aAAa,MAAA,EAAgD;AAC3E,EAAA,MAAM,EAAE,OAAA,EAAS,gBAAA,EAAiB,GAAI,aAAA,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,MAC7B,OAAA,GAAU,iBAAA,CAAkB,YAAA,EAAc,WAAW,IAAI;AAAC,KAC5D;AAAA,IACA,KAAA,EAAO,EAAE,OAAA;AAAQ,GAClB,CAAA;AAED,EAAA,MAAM,MAAA,GAAS,IAAA,GAAO,CAAC,CAAA,EAAG,MAAA;AAC1B,EAAA,MAAM,QAAA,GAAW,IAAA,GAAO,CAA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AAA,CAAK,MAAA,EAAQ,MAAM,CAAA;AAAA,EACzC;AAAA,EAEA,MAAM,0BAA0B,IAAA,EAAwC;AACtE,IAAA,OAAO,yBAAA,CAA0B,IAAA,CAAK,MAAA,EAAQ,EAAE,MAAM,CAAA;AAAA,EACxD;AACF","file":"index.js","sourcesContent":["\"use client\";\n\nimport type { Address } from \"@zama-fhe/sdk\";\nimport { balanceOfContract, decimalsContract, symbolContract } from \"@zama-fhe/sdk\";\nimport { formatUnits } from \"viem\";\nimport { useConnection, useReadContracts } from \"wagmi\";\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 UseWrapperForTokenConfig {\n coordinator: Address | undefined;\n tokenAddress: Address | undefined;\n}\n\nexport function useWrapperForToken(config: UseWrapperForTokenConfig) {\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 UseUnderlyingTokenConfig {\n wrapperAddress: Address | undefined;\n}\n\nexport function useUnderlyingToken(config: UseUnderlyingTokenConfig) {\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 useWrap() {\n const { mutate, mutateAsync, ...mutation } = useWriteContract();\n\n function wrap(\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 wrapAsync(\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: wrap,\n mutateAsync: wrapAsync,\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 useWrapETH() {\n const { mutate, mutateAsync, ...mutation } = useWriteContract();\n\n function wrapETH(\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 wrapETHAsync(\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: wrapETH,\n mutateAsync: wrapETHAsync,\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 type { Config } from \"wagmi\";\nimport {\n getChainId,\n getConnection,\n readContract,\n signTypedData,\n waitForTransactionReceipt,\n writeContract,\n} from \"wagmi/actions\";\n\n/**\n * GenericSigner backed by wagmi.\n *\n * @param config - Wagmi config (from useConfig())\n */\nexport class WagmiSigner implements GenericSigner {\n private readonly config: Config;\n\n constructor(config: Config) {\n this.config = 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 return waitForTransactionReceipt(this.config, { hash });\n }\n}\n"]}
|
package/package.json
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@zama-fhe/react-sdk",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "React hooks for Zama SDK",
|
|
5
|
+
"license": "BSD-3-Clause",
|
|
6
|
+
"author": "Zama",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "https://github.com/zama-ai/sdk",
|
|
10
|
+
"directory": "packages/react-sdk"
|
|
11
|
+
},
|
|
12
|
+
"type": "module",
|
|
13
|
+
"main": "./dist/index.js",
|
|
14
|
+
"types": "./dist/index.d.ts",
|
|
15
|
+
"exports": {
|
|
16
|
+
".": {
|
|
17
|
+
"types": "./dist/index.d.ts",
|
|
18
|
+
"import": "./dist/index.js"
|
|
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
|
+
"./wagmi": {
|
|
29
|
+
"types": "./dist/wagmi/index.d.ts",
|
|
30
|
+
"import": "./dist/wagmi/index.js"
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
"files": [
|
|
34
|
+
"dist",
|
|
35
|
+
"README.md",
|
|
36
|
+
"LICENSE"
|
|
37
|
+
],
|
|
38
|
+
"keywords": [
|
|
39
|
+
"fhe",
|
|
40
|
+
"zama",
|
|
41
|
+
"fhevm",
|
|
42
|
+
"confidential",
|
|
43
|
+
"erc20",
|
|
44
|
+
"privacy",
|
|
45
|
+
"homomorphic-encryption",
|
|
46
|
+
"react",
|
|
47
|
+
"hooks",
|
|
48
|
+
"ethereum"
|
|
49
|
+
],
|
|
50
|
+
"homepage": "https://github.com/zama-ai/sdk#readme",
|
|
51
|
+
"bugs": {
|
|
52
|
+
"url": "https://github.com/zama-ai/sdk/issues"
|
|
53
|
+
},
|
|
54
|
+
"scripts": {
|
|
55
|
+
"build": "tsup",
|
|
56
|
+
"prepare": "tsup",
|
|
57
|
+
"lint": "eslint .",
|
|
58
|
+
"typecheck": "tsc --noEmit"
|
|
59
|
+
},
|
|
60
|
+
"dependencies": {
|
|
61
|
+
"tsup": "^8.5.1"
|
|
62
|
+
},
|
|
63
|
+
"peerDependencies": {
|
|
64
|
+
"@zama-fhe/sdk": "workspace:*",
|
|
65
|
+
"react": ">=18",
|
|
66
|
+
"@tanstack/react-query": ">=5",
|
|
67
|
+
"ethers": ">=6",
|
|
68
|
+
"viem": ">=2",
|
|
69
|
+
"wagmi": ">=2"
|
|
70
|
+
},
|
|
71
|
+
"sideEffects": false,
|
|
72
|
+
"peerDependenciesMeta": {
|
|
73
|
+
"ethers": {
|
|
74
|
+
"optional": true
|
|
75
|
+
},
|
|
76
|
+
"viem": {
|
|
77
|
+
"optional": true
|
|
78
|
+
},
|
|
79
|
+
"wagmi": {
|
|
80
|
+
"optional": true
|
|
81
|
+
}
|
|
82
|
+
},
|
|
83
|
+
"packageManager": "pnpm@10.30.2",
|
|
84
|
+
"engines": {
|
|
85
|
+
"node": ">=24",
|
|
86
|
+
"pnpm": ">=10"
|
|
87
|
+
}
|
|
88
|
+
}
|