@pyratzlabs/react-fhevm-utils 1.0.5 → 1.1.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,11 @@
1
+ import { Address } from "viem";
2
+ interface Props {
3
+ tokenAddress: Address;
4
+ }
5
+ export declare const useEncryptedApprove: ({ tokenAddress }: Props) => {
6
+ confidentialApprove: (spender: Address, handles: Uint8Array[], inputProof: Uint8Array) => void;
7
+ isFailed: boolean;
8
+ isLoading: boolean;
9
+ isSuccess: boolean;
10
+ };
11
+ export {};
@@ -0,0 +1,25 @@
1
+ import { usePerformTransaction } from "./usePerformTransaction";
2
+ import { encryptedABI } from "../types/encryptedABI";
3
+ import { toHexString } from "../utils/string.utils";
4
+ export const useEncryptedApprove = ({ tokenAddress }) => {
5
+ const { perform, isFailed, isLoading, isSuccess } = usePerformTransaction({
6
+ abi: encryptedABI,
7
+ address: tokenAddress,
8
+ functionName: "confidentialApprove",
9
+ });
10
+ const confidentialApprove = (spender, handles, inputProof) => {
11
+ if (handles.length === 0)
12
+ throw new Error("Bad handles format");
13
+ const encryptedAmount = toHexString(handles[0]);
14
+ const proof = toHexString(inputProof);
15
+ perform({
16
+ args: [spender, encryptedAmount, proof],
17
+ });
18
+ };
19
+ return {
20
+ confidentialApprove,
21
+ isFailed,
22
+ isLoading,
23
+ isSuccess,
24
+ };
25
+ };
@@ -24,7 +24,7 @@ ctx.onmessage = (event) => __awaiter(void 0, void 0, void 0, function* () {
24
24
  try {
25
25
  const result = yield instance
26
26
  .createEncryptedInput(tokenAddress, address)
27
- .add64(value)
27
+ .add256(value)
28
28
  .encrypt();
29
29
  ctx.postMessage({ result });
30
30
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pyratzlabs/react-fhevm-utils",
3
- "version": "1.0.5",
3
+ "version": "1.1.0",
4
4
  "description": "React hooks and utilities for Fhevmjs",
5
5
  "main": "dist/index.js",
6
6
  "files": [