@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.
@@ -0,0 +1,173 @@
1
+ "use client";
2
+ import { useQuery, useSuspenseQuery, useMutation } from '@tanstack/react-query';
3
+ import { readConfidentialBalanceOfContract, writeConfidentialTransferContract, writeConfidentialBatchTransferContract, writeUnwrapContract, writeUnwrapFromBalanceContract, writeFinalizeUnwrapContract, writeSetOperatorContract, readWrapperForTokenContract, readUnderlyingTokenContract, writeWrapContract, writeWrapETHContract, readWrapperExistsContract, readSupportsInterfaceContract } from '@zama-fhe/sdk/viem';
4
+ export { ViemSigner } from '@zama-fhe/sdk/viem';
5
+
6
+ // src/viem/use-confidential-balance-of.ts
7
+ function useConfidentialBalanceOf(config) {
8
+ const { client, tokenAddress, userAddress } = config;
9
+ const enabled = !!tokenAddress && !!userAddress;
10
+ return useQuery({
11
+ queryKey: ["confidentialBalanceOf", client, tokenAddress, userAddress],
12
+ queryFn: () => readConfidentialBalanceOfContract(client, tokenAddress, userAddress),
13
+ enabled
14
+ });
15
+ }
16
+ function useConfidentialBalanceOfSuspense(config) {
17
+ const { client, tokenAddress, userAddress } = config;
18
+ return useSuspenseQuery({
19
+ queryKey: ["confidentialBalanceOf", client, tokenAddress, userAddress],
20
+ queryFn: () => readConfidentialBalanceOfContract(client, tokenAddress, userAddress)
21
+ });
22
+ }
23
+ function useConfidentialTransfer() {
24
+ return useMutation({
25
+ mutationFn: (params) => writeConfidentialTransferContract(
26
+ params.client,
27
+ params.tokenAddress,
28
+ params.to,
29
+ params.handle,
30
+ params.inputProof
31
+ )
32
+ });
33
+ }
34
+ function useConfidentialBatchTransfer() {
35
+ return useMutation({
36
+ mutationFn: (params) => writeConfidentialBatchTransferContract(
37
+ params.client,
38
+ params.batcherAddress,
39
+ params.tokenAddress,
40
+ params.fromAddress,
41
+ params.batchTransferData,
42
+ params.fees
43
+ )
44
+ });
45
+ }
46
+ function useUnwrap() {
47
+ return useMutation({
48
+ mutationFn: (params) => writeUnwrapContract(
49
+ params.client,
50
+ params.encryptedErc20,
51
+ params.from,
52
+ params.to,
53
+ params.encryptedAmount,
54
+ params.inputProof
55
+ )
56
+ });
57
+ }
58
+ function useUnwrapFromBalance() {
59
+ return useMutation({
60
+ mutationFn: (params) => writeUnwrapFromBalanceContract(
61
+ params.client,
62
+ params.encryptedErc20,
63
+ params.from,
64
+ params.to,
65
+ params.encryptedBalance
66
+ )
67
+ });
68
+ }
69
+ function useFinalizeUnwrap() {
70
+ return useMutation({
71
+ mutationFn: (params) => writeFinalizeUnwrapContract(
72
+ params.client,
73
+ params.wrapper,
74
+ params.burntAmount,
75
+ params.burntAmountCleartext,
76
+ params.decryptionProof
77
+ )
78
+ });
79
+ }
80
+ function useSetOperator() {
81
+ return useMutation({
82
+ mutationFn: (params) => writeSetOperatorContract(
83
+ params.client,
84
+ params.tokenAddress,
85
+ params.spender,
86
+ params.timestamp
87
+ )
88
+ });
89
+ }
90
+ function useWrapperForToken(config) {
91
+ const { client, coordinator, tokenAddress } = config;
92
+ const enabled = !!coordinator && !!tokenAddress;
93
+ return useQuery({
94
+ queryKey: ["wrapperForToken", client, coordinator, tokenAddress],
95
+ queryFn: () => readWrapperForTokenContract(client, coordinator, tokenAddress),
96
+ enabled
97
+ });
98
+ }
99
+ function useWrapperForTokenSuspense(config) {
100
+ const { client, coordinator, tokenAddress } = config;
101
+ return useSuspenseQuery({
102
+ queryKey: ["wrapperForToken", client, coordinator, tokenAddress],
103
+ queryFn: () => readWrapperForTokenContract(client, coordinator, tokenAddress)
104
+ });
105
+ }
106
+ function useUnderlyingToken(config) {
107
+ const { client, wrapperAddress } = config;
108
+ const enabled = !!wrapperAddress;
109
+ return useQuery({
110
+ queryKey: ["underlyingToken", client, wrapperAddress],
111
+ queryFn: () => readUnderlyingTokenContract(client, wrapperAddress),
112
+ enabled
113
+ });
114
+ }
115
+ function useUnderlyingTokenSuspense(config) {
116
+ const { client, wrapperAddress } = config;
117
+ return useSuspenseQuery({
118
+ queryKey: ["underlyingToken", client, wrapperAddress],
119
+ queryFn: () => readUnderlyingTokenContract(client, wrapperAddress)
120
+ });
121
+ }
122
+ function useWrap() {
123
+ return useMutation({
124
+ mutationFn: (params) => writeWrapContract(params.client, params.wrapperAddress, params.to, params.amount)
125
+ });
126
+ }
127
+ function useWrapETH() {
128
+ return useMutation({
129
+ mutationFn: (params) => writeWrapETHContract(
130
+ params.client,
131
+ params.wrapperAddress,
132
+ params.to,
133
+ params.amount,
134
+ params.value
135
+ )
136
+ });
137
+ }
138
+ function useWrapperExists(config) {
139
+ const { client, coordinator, tokenAddress } = config;
140
+ const enabled = !!coordinator && !!tokenAddress;
141
+ return useQuery({
142
+ queryKey: ["wrapperExists", client, coordinator, tokenAddress],
143
+ queryFn: () => readWrapperExistsContract(client, coordinator, tokenAddress),
144
+ enabled
145
+ });
146
+ }
147
+ function useWrapperExistsSuspense(config) {
148
+ const { client, coordinator, tokenAddress } = config;
149
+ return useSuspenseQuery({
150
+ queryKey: ["wrapperExists", client, coordinator, tokenAddress],
151
+ queryFn: () => readWrapperExistsContract(client, coordinator, tokenAddress)
152
+ });
153
+ }
154
+ function useSupportsInterface(config) {
155
+ const { client, tokenAddress, interfaceId } = config;
156
+ const enabled = !!tokenAddress && !!interfaceId;
157
+ return useQuery({
158
+ queryKey: ["supportsInterface", client, tokenAddress, interfaceId],
159
+ queryFn: () => readSupportsInterfaceContract(client, tokenAddress, interfaceId),
160
+ enabled
161
+ });
162
+ }
163
+ function useSupportsInterfaceSuspense(config) {
164
+ const { client, tokenAddress, interfaceId } = config;
165
+ return useSuspenseQuery({
166
+ queryKey: ["supportsInterface", client, tokenAddress, interfaceId],
167
+ queryFn: () => readSupportsInterfaceContract(client, tokenAddress, interfaceId)
168
+ });
169
+ }
170
+
171
+ export { useConfidentialBalanceOf, useConfidentialBalanceOfSuspense, useConfidentialBatchTransfer, useConfidentialTransfer, useFinalizeUnwrap, useSetOperator, useSupportsInterface, useSupportsInterfaceSuspense, useUnderlyingToken, useUnderlyingTokenSuspense, useUnwrap, useUnwrapFromBalance, useWrap, useWrapETH, useWrapperExists, useWrapperExistsSuspense, useWrapperForToken, useWrapperForTokenSuspense };
172
+ //# sourceMappingURL=index.js.map
173
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/viem/use-confidential-balance-of.ts","../../src/viem/use-confidential-transfer.ts","../../src/viem/use-confidential-batch-transfer.ts","../../src/viem/use-unwrap.ts","../../src/viem/use-unwrap-from-balance.ts","../../src/viem/use-finalize-unwrap.ts","../../src/viem/use-set-operator.ts","../../src/viem/use-wrapper-for-token.ts","../../src/viem/use-underlying-token.ts","../../src/viem/use-wrap.ts","../../src/viem/use-wrap-eth.ts","../../src/viem/use-wrapper-exists.ts","../../src/viem/use-supports-interface.ts"],"names":["useMutation","useQuery","useSuspenseQuery"],"mappings":";;;;;AAoBO,SAAS,yBAAyB,MAAA,EAAwC;AAC/E,EAAA,MAAM,EAAE,MAAA,EAAQ,YAAA,EAAc,WAAA,EAAY,GAAI,MAAA;AAC9C,EAAA,MAAM,OAAA,GAAU,CAAC,CAAC,YAAA,IAAgB,CAAC,CAAC,WAAA;AACpC,EAAA,OAAO,QAAA,CAAS;AAAA,IACd,QAAA,EAAU,CAAC,uBAAA,EAAyB,MAAA,EAAQ,cAAc,WAAW,CAAA;AAAA,IACrE,OAAA,EAAS,MACP,iCAAA,CAAkC,MAAA,EAAQ,cAAyB,WAAsB,CAAA;AAAA,IAC3F;AAAA,GACD,CAAA;AACH;AAEO,SAAS,iCAAiC,MAAA,EAAgD;AAC/F,EAAA,MAAM,EAAE,MAAA,EAAQ,YAAA,EAAc,WAAA,EAAY,GAAI,MAAA;AAC9C,EAAA,OAAO,gBAAA,CAAiB;AAAA,IACtB,QAAA,EAAU,CAAC,uBAAA,EAAyB,MAAA,EAAQ,cAAc,WAAW,CAAA;AAAA,IACrE,OAAA,EAAS,MACP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A,IACjE,OAAA,EAAS,MAAM,6BAAA,CAA8B,MAAA,EAAQ,cAAc,WAAW;AAAA,GAC/E,CAAA;AACH","file":"index.js","sourcesContent":["\"use client\";\n\nimport { useQuery, useSuspenseQuery } from \"@tanstack/react-query\";\nimport type { Address } from \"@zama-fhe/sdk\";\nimport { readConfidentialBalanceOfContract } from \"@zama-fhe/sdk/viem\";\n\ntype Params = Parameters<typeof readConfidentialBalanceOfContract>;\n\nexport interface UseConfidentialBalanceOfConfig {\n client: Params[0];\n tokenAddress: Address | undefined;\n userAddress: Address | undefined;\n}\n\nexport interface UseConfidentialBalanceOfSuspenseConfig {\n client: Params[0];\n tokenAddress: Address;\n userAddress: Address;\n}\n\nexport function useConfidentialBalanceOf(config: UseConfidentialBalanceOfConfig) {\n const { client, tokenAddress, userAddress } = config;\n const enabled = !!tokenAddress && !!userAddress;\n return useQuery({\n queryKey: [\"confidentialBalanceOf\", client, tokenAddress, userAddress],\n queryFn: () =>\n readConfidentialBalanceOfContract(client, tokenAddress as Address, userAddress as Address),\n enabled,\n });\n}\n\nexport function useConfidentialBalanceOfSuspense(config: UseConfidentialBalanceOfSuspenseConfig) {\n const { client, tokenAddress, userAddress } = config;\n return useSuspenseQuery({\n queryKey: [\"confidentialBalanceOf\", client, tokenAddress, userAddress],\n queryFn: () =>\n readConfidentialBalanceOfContract(client, tokenAddress as Address, userAddress as Address),\n });\n}\n","\"use client\";\n\nimport { useMutation } from \"@tanstack/react-query\";\nimport { writeConfidentialTransferContract } from \"@zama-fhe/sdk/viem\";\n\ntype WriteFn = typeof writeConfidentialTransferContract;\ntype Params = Parameters<WriteFn>;\n\nexport interface ConfidentialTransferParams {\n client: Params[0];\n tokenAddress: Params[1];\n to: Params[2];\n handle: Params[3];\n inputProof: Params[4];\n}\nexport function useConfidentialTransfer() {\n return useMutation<Awaited<ReturnType<WriteFn>>, Error, ConfidentialTransferParams>({\n mutationFn: (params) =>\n writeConfidentialTransferContract(\n params.client,\n params.tokenAddress,\n params.to,\n params.handle,\n params.inputProof,\n ),\n });\n}\n","\"use client\";\n\nimport { useMutation } from \"@tanstack/react-query\";\nimport { writeConfidentialBatchTransferContract } from \"@zama-fhe/sdk/viem\";\n\ntype WriteFn = typeof writeConfidentialBatchTransferContract;\ntype Params = Parameters<WriteFn>;\n\nexport interface ConfidentialBatchTransferParams {\n client: Params[0];\n batcherAddress: Params[1];\n tokenAddress: Params[2];\n fromAddress: Params[3];\n batchTransferData: Params[4];\n fees: Params[5];\n}\nexport function useConfidentialBatchTransfer() {\n return useMutation<Awaited<ReturnType<WriteFn>>, Error, ConfidentialBatchTransferParams>({\n mutationFn: (params) =>\n writeConfidentialBatchTransferContract(\n params.client,\n params.batcherAddress,\n params.tokenAddress,\n params.fromAddress,\n params.batchTransferData,\n params.fees,\n ),\n });\n}\n","\"use client\";\n\nimport { useMutation } from \"@tanstack/react-query\";\nimport { writeUnwrapContract } from \"@zama-fhe/sdk/viem\";\n\ntype WriteFn = typeof writeUnwrapContract;\ntype Params = Parameters<WriteFn>;\n\nexport interface UnwrapParams {\n client: Params[0];\n encryptedErc20: Params[1];\n from: Params[2];\n to: Params[3];\n encryptedAmount: Params[4];\n inputProof: Params[5];\n}\nexport function useUnwrap() {\n return useMutation<Awaited<ReturnType<WriteFn>>, Error, UnwrapParams>({\n mutationFn: (params) =>\n writeUnwrapContract(\n params.client,\n params.encryptedErc20,\n params.from,\n params.to,\n params.encryptedAmount,\n params.inputProof,\n ),\n });\n}\n","\"use client\";\n\nimport { useMutation } from \"@tanstack/react-query\";\nimport { writeUnwrapFromBalanceContract } from \"@zama-fhe/sdk/viem\";\n\ntype WriteFn = typeof writeUnwrapFromBalanceContract;\ntype Params = Parameters<WriteFn>;\n\nexport interface UnwrapFromBalanceParams {\n client: Params[0];\n encryptedErc20: Params[1];\n from: Params[2];\n to: Params[3];\n encryptedBalance: Params[4];\n}\nexport function useUnwrapFromBalance() {\n return useMutation<Awaited<ReturnType<WriteFn>>, Error, UnwrapFromBalanceParams>({\n mutationFn: (params) =>\n writeUnwrapFromBalanceContract(\n params.client,\n params.encryptedErc20,\n params.from,\n params.to,\n params.encryptedBalance,\n ),\n });\n}\n","\"use client\";\n\nimport { useMutation } from \"@tanstack/react-query\";\nimport { writeFinalizeUnwrapContract } from \"@zama-fhe/sdk/viem\";\n\ntype WriteFn = typeof writeFinalizeUnwrapContract;\ntype Params = Parameters<WriteFn>;\n\nexport interface FinalizeUnwrapParams {\n client: Params[0];\n wrapper: Params[1];\n burntAmount: Params[2];\n burntAmountCleartext: Params[3];\n decryptionProof: Params[4];\n}\nexport function useFinalizeUnwrap() {\n return useMutation<Awaited<ReturnType<WriteFn>>, Error, FinalizeUnwrapParams>({\n mutationFn: (params) =>\n writeFinalizeUnwrapContract(\n params.client,\n params.wrapper,\n params.burntAmount,\n params.burntAmountCleartext,\n params.decryptionProof,\n ),\n });\n}\n","\"use client\";\n\nimport { useMutation } from \"@tanstack/react-query\";\nimport { writeSetOperatorContract } from \"@zama-fhe/sdk/viem\";\n\ntype WriteFn = typeof writeSetOperatorContract;\ntype Params = Parameters<WriteFn>;\n\nexport interface SetOperatorParams {\n client: Params[0];\n tokenAddress: Params[1];\n spender: Params[2];\n timestamp?: Params[3];\n}\nexport function useSetOperator() {\n return useMutation<Awaited<ReturnType<WriteFn>>, Error, SetOperatorParams>({\n mutationFn: (params) =>\n writeSetOperatorContract(\n params.client,\n params.tokenAddress,\n params.spender,\n params.timestamp,\n ),\n });\n}\n","\"use client\";\n\nimport { useQuery, useSuspenseQuery } from \"@tanstack/react-query\";\nimport type { Address } from \"@zama-fhe/sdk\";\nimport { readWrapperForTokenContract } from \"@zama-fhe/sdk/viem\";\n\ntype Params = Parameters<typeof readWrapperForTokenContract>;\n\nexport interface UseWrapperForTokenConfig {\n client: Params[0];\n coordinator: Address | undefined;\n tokenAddress: Address | undefined;\n}\n\nexport interface UseWrapperForTokenSuspenseConfig {\n client: Params[0];\n coordinator: Address;\n tokenAddress: Address;\n}\n\nexport function useWrapperForToken(config: UseWrapperForTokenConfig) {\n const { client, coordinator, tokenAddress } = config;\n const enabled = !!coordinator && !!tokenAddress;\n return useQuery({\n queryKey: [\"wrapperForToken\", client, coordinator, tokenAddress],\n queryFn: () =>\n readWrapperForTokenContract(client, coordinator as Address, tokenAddress as Address),\n enabled,\n });\n}\n\nexport function useWrapperForTokenSuspense(config: UseWrapperForTokenSuspenseConfig) {\n const { client, coordinator, tokenAddress } = config;\n return useSuspenseQuery({\n queryKey: [\"wrapperForToken\", client, coordinator, tokenAddress],\n queryFn: () => readWrapperForTokenContract(client, coordinator, tokenAddress),\n });\n}\n","\"use client\";\n\nimport { useQuery, useSuspenseQuery } from \"@tanstack/react-query\";\nimport type { Address } from \"@zama-fhe/sdk\";\nimport { readUnderlyingTokenContract } from \"@zama-fhe/sdk/viem\";\n\ntype Params = Parameters<typeof readUnderlyingTokenContract>;\n\nexport interface UseUnderlyingTokenConfig {\n client: Params[0];\n wrapperAddress: Address | undefined;\n}\n\nexport interface UseUnderlyingTokenSuspenseConfig {\n client: Params[0];\n wrapperAddress: Address;\n}\n\nexport function useUnderlyingToken(config: UseUnderlyingTokenConfig) {\n const { client, wrapperAddress } = config;\n const enabled = !!wrapperAddress;\n return useQuery({\n queryKey: [\"underlyingToken\", client, wrapperAddress],\n queryFn: () => readUnderlyingTokenContract(client, wrapperAddress as Address),\n enabled,\n });\n}\n\nexport function useUnderlyingTokenSuspense(config: UseUnderlyingTokenSuspenseConfig) {\n const { client, wrapperAddress } = config;\n return useSuspenseQuery({\n queryKey: [\"underlyingToken\", client, wrapperAddress],\n queryFn: () => readUnderlyingTokenContract(client, wrapperAddress),\n });\n}\n","\"use client\";\n\nimport { useMutation } from \"@tanstack/react-query\";\nimport { writeWrapContract } from \"@zama-fhe/sdk/viem\";\n\ntype WriteFn = typeof writeWrapContract;\ntype Params = Parameters<WriteFn>;\n\nexport interface WrapParams {\n client: Params[0];\n wrapperAddress: Params[1];\n to: Params[2];\n amount: Params[3];\n}\nexport function useWrap() {\n return useMutation<Awaited<ReturnType<WriteFn>>, Error, WrapParams>({\n mutationFn: (params) =>\n writeWrapContract(params.client, params.wrapperAddress, params.to, params.amount),\n });\n}\n","\"use client\";\n\nimport { useMutation } from \"@tanstack/react-query\";\nimport { writeWrapETHContract } from \"@zama-fhe/sdk/viem\";\n\ntype WriteFn = typeof writeWrapETHContract;\ntype Params = Parameters<WriteFn>;\n\nexport interface WrapETHParams {\n client: Params[0];\n wrapperAddress: Params[1];\n to: Params[2];\n amount: Params[3];\n value: Params[4];\n}\nexport function useWrapETH() {\n return useMutation<Awaited<ReturnType<WriteFn>>, Error, WrapETHParams>({\n mutationFn: (params) =>\n writeWrapETHContract(\n params.client,\n params.wrapperAddress,\n params.to,\n params.amount,\n params.value,\n ),\n });\n}\n","\"use client\";\n\nimport { useQuery, useSuspenseQuery } from \"@tanstack/react-query\";\nimport type { Address } from \"@zama-fhe/sdk\";\nimport { readWrapperExistsContract } from \"@zama-fhe/sdk/viem\";\n\ntype Params = Parameters<typeof readWrapperExistsContract>;\n\nexport interface UseWrapperExistsConfig {\n client: Params[0];\n coordinator: Address | undefined;\n tokenAddress: Address | undefined;\n}\n\nexport interface UseWrapperExistsSuspenseConfig {\n client: Params[0];\n coordinator: Address;\n tokenAddress: Address;\n}\n\nexport function useWrapperExists(config: UseWrapperExistsConfig) {\n const { client, coordinator, tokenAddress } = config;\n const enabled = !!coordinator && !!tokenAddress;\n return useQuery({\n queryKey: [\"wrapperExists\", client, coordinator, tokenAddress],\n queryFn: () =>\n readWrapperExistsContract(client, coordinator as Address, tokenAddress as Address),\n enabled,\n });\n}\n\nexport function useWrapperExistsSuspense(config: UseWrapperExistsSuspenseConfig) {\n const { client, coordinator, tokenAddress } = config;\n return useSuspenseQuery({\n queryKey: [\"wrapperExists\", client, coordinator, tokenAddress],\n queryFn: () => readWrapperExistsContract(client, coordinator, tokenAddress),\n });\n}\n","\"use client\";\n\nimport { useQuery, useSuspenseQuery } from \"@tanstack/react-query\";\nimport { readSupportsInterfaceContract } from \"@zama-fhe/sdk/viem\";\n\ntype Params = Parameters<typeof readSupportsInterfaceContract>;\n\nexport interface UseSupportsInterfaceConfig {\n client: Params[0];\n tokenAddress: Params[1] | undefined;\n interfaceId: Params[2] | undefined;\n}\n\nexport interface UseSupportsInterfaceSuspenseConfig {\n client: Params[0];\n tokenAddress: Params[1];\n interfaceId: Params[2];\n}\n\nexport function useSupportsInterface(config: UseSupportsInterfaceConfig) {\n const { client, tokenAddress, interfaceId } = config;\n const enabled = !!tokenAddress && !!interfaceId;\n return useQuery({\n queryKey: [\"supportsInterface\", client, tokenAddress, interfaceId],\n queryFn: () =>\n readSupportsInterfaceContract(client, tokenAddress as Params[1], interfaceId as Params[2]),\n enabled,\n });\n}\n\nexport function useSupportsInterfaceSuspense(config: UseSupportsInterfaceSuspenseConfig) {\n const { client, tokenAddress, interfaceId } = config;\n return useSuspenseQuery({\n queryKey: [\"supportsInterface\", client, tokenAddress, interfaceId],\n queryFn: () => readSupportsInterfaceContract(client, tokenAddress, interfaceId),\n });\n}\n"]}