@pyratzlabs/react-fhevm-utils 2.0.0 → 2.0.2

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,12 +1 @@
1
- import { FhevmInstance } from "@zama-fhe/relayer-sdk/web";
2
- interface EventData {
3
- tokenAddress: string;
4
- address?: string;
5
- value: bigint;
6
- instance: FhevmInstance;
7
- }
8
- export declare const encryptInt64: (data: EventData) => Promise<{
9
- handles: Uint8Array[];
10
- inputProof: Uint8Array;
11
- }>;
12
1
  export {};
@@ -8,13 +8,28 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  step((generator = generator.apply(thisArg, _arguments || [])).next());
9
9
  });
10
10
  };
11
- export const encryptInt64 = (data) => __awaiter(void 0, void 0, void 0, function* () {
12
- const { tokenAddress, address, value, instance } = data;
11
+ import { getOrCreateFhevmInstance } from "../lib/fhevm";
12
+ const ctx = self;
13
+ ctx.onmessage = (event) => __awaiter(void 0, void 0, void 0, function* () {
14
+ const { tokenAddress, address, value, chainId, networkUrl, network } = event.data;
15
+ const instance = yield getOrCreateFhevmInstance({
16
+ chainId,
17
+ network,
18
+ networkUrl,
19
+ });
13
20
  if (!instance || !address) {
14
- throw new Error("Instance or address is undefined");
21
+ ctx.postMessage({ error: "Instance or address is undefined" });
22
+ return;
23
+ }
24
+ try {
25
+ const result = yield instance
26
+ .createEncryptedInput(tokenAddress, address)
27
+ .add64(value)
28
+ .encrypt();
29
+ ctx.postMessage({ result });
30
+ }
31
+ catch (error) {
32
+ console.error("Worker error", error);
33
+ ctx.postMessage({ error });
15
34
  }
16
- return yield instance
17
- .createEncryptedInput(tokenAddress, address)
18
- .add64(value)
19
- .encrypt();
20
35
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pyratzlabs/react-fhevm-utils",
3
- "version": "2.0.0",
3
+ "version": "2.0.2",
4
4
  "description": "React hooks and utilities for Fhevmjs",
5
5
  "main": "dist/index.js",
6
6
  "files": [
@@ -31,7 +31,7 @@
31
31
  },
32
32
  "dependencies": {
33
33
  "@tanstack/react-query": "^5.71.5",
34
- "@zama-fhe/relayer-sdk": "^0.1.2",
34
+ "@zama-fhe/relayer-sdk": "0.1.0",
35
35
  "react": "^19.1.0",
36
36
  "viem": "^2.25.0",
37
37
  "wagmi": "^2.14.16"