@pyratzlabs/react-fhevm-utils 3.4.7 → 3.5.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/dist/client/context/FhevmProvider.d.ts +6 -5
- package/dist/client/context/FhevmProvider.js +2 -2
- package/dist/client/hooks/useDecryptHandles.d.ts +9 -9
- package/dist/client/hooks/useDecryptHandles.js +3 -3
- package/dist/client/hooks/useGetFhevmConfig.d.ts +17 -1
- package/dist/client/hooks/usePublicDecrypt.d.ts +45 -9
- package/dist/lib/fhevm.d.ts +5 -4
- package/dist/lib/fhevm.js +7 -4
- package/dist/types/fhevmConfig.d.ts +5 -0
- package/package.json +2 -2
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import React, { ReactNode } from "react";
|
|
2
|
-
import {
|
|
3
|
-
import { FhevmInstance } from "@zama-fhe/relayer-sdk/bundle";
|
|
2
|
+
import { Network } from "../../types/fhevmConfig";
|
|
3
|
+
import { FhevmInstance, FhevmInstanceConfig } from "@zama-fhe/relayer-sdk/bundle";
|
|
4
4
|
interface ProviderProps {
|
|
5
5
|
children: ReactNode;
|
|
6
|
-
|
|
6
|
+
network?: Network;
|
|
7
|
+
config?: FhevmInstanceConfig;
|
|
7
8
|
}
|
|
8
9
|
interface ContextProps {
|
|
9
10
|
instance?: FhevmInstance;
|
|
10
|
-
config?:
|
|
11
|
+
config?: FhevmInstanceConfig;
|
|
11
12
|
}
|
|
12
13
|
export declare const FhevmContext: React.Context<ContextProps>;
|
|
13
|
-
declare const FhevmProvider: ({ children, config }: ProviderProps) => import("react/jsx-runtime").JSX.Element;
|
|
14
|
+
declare const FhevmProvider: ({ children, network, config, }: ProviderProps) => import("react/jsx-runtime").JSX.Element;
|
|
14
15
|
export declare const useFhevmContext: () => ContextProps;
|
|
15
16
|
export default FhevmProvider;
|
|
@@ -14,11 +14,11 @@ export const FhevmContext = createContext({
|
|
|
14
14
|
instance: undefined,
|
|
15
15
|
config: undefined,
|
|
16
16
|
});
|
|
17
|
-
const FhevmProvider = ({ children, config }) => {
|
|
17
|
+
const FhevmProvider = ({ children, network = "sepolia", config, }) => {
|
|
18
18
|
const [instance, setInstance] = useState();
|
|
19
19
|
const initFhevm = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
20
20
|
try {
|
|
21
|
-
const instance = yield getOrCreateFhevmInstance(config);
|
|
21
|
+
const instance = yield getOrCreateFhevmInstance(network, config);
|
|
22
22
|
setInstance(instance);
|
|
23
23
|
}
|
|
24
24
|
catch (error) {
|
|
@@ -8,14 +8,14 @@ export declare const useDecryptHandles: () => {
|
|
|
8
8
|
isPending: false;
|
|
9
9
|
isSuccess: false;
|
|
10
10
|
status: "idle";
|
|
11
|
-
mutate: import("@tanstack/react-query").UseMutateFunction<import("@zama-fhe/relayer-sdk/web").
|
|
11
|
+
mutate: import("@tanstack/react-query").UseMutateFunction<Readonly<Record<`0x${string}`, import("@zama-fhe/relayer-sdk/web").ClearValueType>>, Error, HandleContractPair[], unknown>;
|
|
12
12
|
reset: () => void;
|
|
13
13
|
context: unknown;
|
|
14
14
|
failureCount: number;
|
|
15
15
|
failureReason: Error | null;
|
|
16
16
|
isPaused: boolean;
|
|
17
17
|
submittedAt: number;
|
|
18
|
-
mutateAsync: import("@tanstack/react-query").UseMutateAsyncFunction<import("@zama-fhe/relayer-sdk/web").
|
|
18
|
+
mutateAsync: import("@tanstack/react-query").UseMutateAsyncFunction<Readonly<Record<`0x${string}`, import("@zama-fhe/relayer-sdk/web").ClearValueType>>, Error, HandleContractPair[], unknown>;
|
|
19
19
|
} | {
|
|
20
20
|
data: undefined;
|
|
21
21
|
variables: HandleContractPair[];
|
|
@@ -25,14 +25,14 @@ export declare const useDecryptHandles: () => {
|
|
|
25
25
|
isPending: true;
|
|
26
26
|
isSuccess: false;
|
|
27
27
|
status: "pending";
|
|
28
|
-
mutate: import("@tanstack/react-query").UseMutateFunction<import("@zama-fhe/relayer-sdk/web").
|
|
28
|
+
mutate: import("@tanstack/react-query").UseMutateFunction<Readonly<Record<`0x${string}`, import("@zama-fhe/relayer-sdk/web").ClearValueType>>, Error, HandleContractPair[], unknown>;
|
|
29
29
|
reset: () => void;
|
|
30
30
|
context: unknown;
|
|
31
31
|
failureCount: number;
|
|
32
32
|
failureReason: Error | null;
|
|
33
33
|
isPaused: boolean;
|
|
34
34
|
submittedAt: number;
|
|
35
|
-
mutateAsync: import("@tanstack/react-query").UseMutateAsyncFunction<import("@zama-fhe/relayer-sdk/web").
|
|
35
|
+
mutateAsync: import("@tanstack/react-query").UseMutateAsyncFunction<Readonly<Record<`0x${string}`, import("@zama-fhe/relayer-sdk/web").ClearValueType>>, Error, HandleContractPair[], unknown>;
|
|
36
36
|
} | {
|
|
37
37
|
data: undefined;
|
|
38
38
|
error: Error;
|
|
@@ -42,16 +42,16 @@ export declare const useDecryptHandles: () => {
|
|
|
42
42
|
isPending: false;
|
|
43
43
|
isSuccess: false;
|
|
44
44
|
status: "error";
|
|
45
|
-
mutate: import("@tanstack/react-query").UseMutateFunction<import("@zama-fhe/relayer-sdk/web").
|
|
45
|
+
mutate: import("@tanstack/react-query").UseMutateFunction<Readonly<Record<`0x${string}`, import("@zama-fhe/relayer-sdk/web").ClearValueType>>, Error, HandleContractPair[], unknown>;
|
|
46
46
|
reset: () => void;
|
|
47
47
|
context: unknown;
|
|
48
48
|
failureCount: number;
|
|
49
49
|
failureReason: Error | null;
|
|
50
50
|
isPaused: boolean;
|
|
51
51
|
submittedAt: number;
|
|
52
|
-
mutateAsync: import("@tanstack/react-query").UseMutateAsyncFunction<import("@zama-fhe/relayer-sdk/web").
|
|
52
|
+
mutateAsync: import("@tanstack/react-query").UseMutateAsyncFunction<Readonly<Record<`0x${string}`, import("@zama-fhe/relayer-sdk/web").ClearValueType>>, Error, HandleContractPair[], unknown>;
|
|
53
53
|
} | {
|
|
54
|
-
data: import("@zama-fhe/relayer-sdk/web").
|
|
54
|
+
data: Readonly<Record<`0x${string}`, import("@zama-fhe/relayer-sdk/web").ClearValueType>>;
|
|
55
55
|
error: null;
|
|
56
56
|
variables: HandleContractPair[];
|
|
57
57
|
isError: false;
|
|
@@ -59,12 +59,12 @@ export declare const useDecryptHandles: () => {
|
|
|
59
59
|
isPending: false;
|
|
60
60
|
isSuccess: true;
|
|
61
61
|
status: "success";
|
|
62
|
-
mutate: import("@tanstack/react-query").UseMutateFunction<import("@zama-fhe/relayer-sdk/web").
|
|
62
|
+
mutate: import("@tanstack/react-query").UseMutateFunction<Readonly<Record<`0x${string}`, import("@zama-fhe/relayer-sdk/web").ClearValueType>>, Error, HandleContractPair[], unknown>;
|
|
63
63
|
reset: () => void;
|
|
64
64
|
context: unknown;
|
|
65
65
|
failureCount: number;
|
|
66
66
|
failureReason: Error | null;
|
|
67
67
|
isPaused: boolean;
|
|
68
68
|
submittedAt: number;
|
|
69
|
-
mutateAsync: import("@tanstack/react-query").UseMutateAsyncFunction<import("@zama-fhe/relayer-sdk/web").
|
|
69
|
+
mutateAsync: import("@tanstack/react-query").UseMutateAsyncFunction<Readonly<Record<`0x${string}`, import("@zama-fhe/relayer-sdk/web").ClearValueType>>, Error, HandleContractPair[], unknown>;
|
|
70
70
|
};
|
|
@@ -21,8 +21,8 @@ export const useDecryptHandles = () => {
|
|
|
21
21
|
throw new Error("Instance is not defined");
|
|
22
22
|
if (!address)
|
|
23
23
|
throw new Error("User wallet is not connected");
|
|
24
|
-
const startTimeStamp = Math.floor(Date.now() / 1000)
|
|
25
|
-
const durationDays =
|
|
24
|
+
const startTimeStamp = Math.floor(Date.now() / 1000);
|
|
25
|
+
const durationDays = 1;
|
|
26
26
|
const { publicKey, privateKey } = instance.generateKeypair();
|
|
27
27
|
const contractAddresses = handles.map((handle) => handle.contractAddress);
|
|
28
28
|
const eip712 = instance.createEIP712(publicKey, contractAddresses, startTimeStamp, durationDays);
|
|
@@ -32,7 +32,7 @@ export const useDecryptHandles = () => {
|
|
|
32
32
|
UserDecryptRequestVerification: eip712.types.UserDecryptRequestVerification,
|
|
33
33
|
},
|
|
34
34
|
primaryType: "UserDecryptRequestVerification",
|
|
35
|
-
message: eip712.message,
|
|
35
|
+
message: Object.assign(Object.assign({}, eip712.message), { startTimestamp: BigInt(eip712.message.startTimestamp), durationDays: BigInt(eip712.message.durationDays) }),
|
|
36
36
|
});
|
|
37
37
|
const decryptedBalance = yield instance.userDecrypt(handles, privateKey, publicKey, signature.replace("0x", ""), contractAddresses, address, startTimeStamp, durationDays);
|
|
38
38
|
return decryptedBalance;
|
|
@@ -1,3 +1,19 @@
|
|
|
1
1
|
export declare const useGetFhevmConfig: () => {
|
|
2
|
-
config:
|
|
2
|
+
config: {
|
|
3
|
+
verifyingContractAddressDecryption: string;
|
|
4
|
+
verifyingContractAddressInputVerification: string;
|
|
5
|
+
kmsContractAddress: string;
|
|
6
|
+
inputVerifierContractAddress: string;
|
|
7
|
+
aclContractAddress: string;
|
|
8
|
+
gatewayChainId: number;
|
|
9
|
+
relayerUrl: string;
|
|
10
|
+
network: import("ethers").Eip1193Provider | string;
|
|
11
|
+
chainId?: number | undefined;
|
|
12
|
+
batchRpcCalls?: boolean | undefined;
|
|
13
|
+
relayerRouteVersion?: 1 | 2 | undefined;
|
|
14
|
+
publicKey?: import("@zama-fhe/relayer-sdk/web").FhevmPublicKeyType | undefined;
|
|
15
|
+
publicParams?: import("@zama-fhe/relayer-sdk/web").FhevmPkeCrsByCapacityType | undefined;
|
|
16
|
+
auth?: import("@zama-fhe/relayer-sdk/web").Auth | undefined;
|
|
17
|
+
debug?: boolean | undefined;
|
|
18
|
+
} | undefined;
|
|
3
19
|
};
|
|
@@ -7,14 +7,22 @@ export declare const usePublicDecrypt: () => {
|
|
|
7
7
|
isPending: false;
|
|
8
8
|
isSuccess: false;
|
|
9
9
|
status: "idle";
|
|
10
|
-
mutate: import("@tanstack/react-query").UseMutateFunction<
|
|
10
|
+
mutate: import("@tanstack/react-query").UseMutateFunction<Readonly<{
|
|
11
|
+
clearValues: import("@zama-fhe/relayer-sdk/web").ClearValues;
|
|
12
|
+
abiEncodedClearValues: `0x${string}`;
|
|
13
|
+
decryptionProof: `0x${string}`;
|
|
14
|
+
}> | undefined, Error, string[], unknown>;
|
|
11
15
|
reset: () => void;
|
|
12
16
|
context: unknown;
|
|
13
17
|
failureCount: number;
|
|
14
18
|
failureReason: Error | null;
|
|
15
19
|
isPaused: boolean;
|
|
16
20
|
submittedAt: number;
|
|
17
|
-
mutateAsync: import("@tanstack/react-query").UseMutateAsyncFunction<
|
|
21
|
+
mutateAsync: import("@tanstack/react-query").UseMutateAsyncFunction<Readonly<{
|
|
22
|
+
clearValues: import("@zama-fhe/relayer-sdk/web").ClearValues;
|
|
23
|
+
abiEncodedClearValues: `0x${string}`;
|
|
24
|
+
decryptionProof: `0x${string}`;
|
|
25
|
+
}> | undefined, Error, string[], unknown>;
|
|
18
26
|
} | {
|
|
19
27
|
data: undefined;
|
|
20
28
|
variables: string[];
|
|
@@ -24,14 +32,22 @@ export declare const usePublicDecrypt: () => {
|
|
|
24
32
|
isPending: true;
|
|
25
33
|
isSuccess: false;
|
|
26
34
|
status: "pending";
|
|
27
|
-
mutate: import("@tanstack/react-query").UseMutateFunction<
|
|
35
|
+
mutate: import("@tanstack/react-query").UseMutateFunction<Readonly<{
|
|
36
|
+
clearValues: import("@zama-fhe/relayer-sdk/web").ClearValues;
|
|
37
|
+
abiEncodedClearValues: `0x${string}`;
|
|
38
|
+
decryptionProof: `0x${string}`;
|
|
39
|
+
}> | undefined, Error, string[], unknown>;
|
|
28
40
|
reset: () => void;
|
|
29
41
|
context: unknown;
|
|
30
42
|
failureCount: number;
|
|
31
43
|
failureReason: Error | null;
|
|
32
44
|
isPaused: boolean;
|
|
33
45
|
submittedAt: number;
|
|
34
|
-
mutateAsync: import("@tanstack/react-query").UseMutateAsyncFunction<
|
|
46
|
+
mutateAsync: import("@tanstack/react-query").UseMutateAsyncFunction<Readonly<{
|
|
47
|
+
clearValues: import("@zama-fhe/relayer-sdk/web").ClearValues;
|
|
48
|
+
abiEncodedClearValues: `0x${string}`;
|
|
49
|
+
decryptionProof: `0x${string}`;
|
|
50
|
+
}> | undefined, Error, string[], unknown>;
|
|
35
51
|
} | {
|
|
36
52
|
data: undefined;
|
|
37
53
|
error: Error;
|
|
@@ -41,16 +57,28 @@ export declare const usePublicDecrypt: () => {
|
|
|
41
57
|
isPending: false;
|
|
42
58
|
isSuccess: false;
|
|
43
59
|
status: "error";
|
|
44
|
-
mutate: import("@tanstack/react-query").UseMutateFunction<
|
|
60
|
+
mutate: import("@tanstack/react-query").UseMutateFunction<Readonly<{
|
|
61
|
+
clearValues: import("@zama-fhe/relayer-sdk/web").ClearValues;
|
|
62
|
+
abiEncodedClearValues: `0x${string}`;
|
|
63
|
+
decryptionProof: `0x${string}`;
|
|
64
|
+
}> | undefined, Error, string[], unknown>;
|
|
45
65
|
reset: () => void;
|
|
46
66
|
context: unknown;
|
|
47
67
|
failureCount: number;
|
|
48
68
|
failureReason: Error | null;
|
|
49
69
|
isPaused: boolean;
|
|
50
70
|
submittedAt: number;
|
|
51
|
-
mutateAsync: import("@tanstack/react-query").UseMutateAsyncFunction<
|
|
71
|
+
mutateAsync: import("@tanstack/react-query").UseMutateAsyncFunction<Readonly<{
|
|
72
|
+
clearValues: import("@zama-fhe/relayer-sdk/web").ClearValues;
|
|
73
|
+
abiEncodedClearValues: `0x${string}`;
|
|
74
|
+
decryptionProof: `0x${string}`;
|
|
75
|
+
}> | undefined, Error, string[], unknown>;
|
|
52
76
|
} | {
|
|
53
|
-
data:
|
|
77
|
+
data: Readonly<{
|
|
78
|
+
clearValues: import("@zama-fhe/relayer-sdk/web").ClearValues;
|
|
79
|
+
abiEncodedClearValues: `0x${string}`;
|
|
80
|
+
decryptionProof: `0x${string}`;
|
|
81
|
+
}> | undefined;
|
|
54
82
|
error: null;
|
|
55
83
|
variables: string[];
|
|
56
84
|
isError: false;
|
|
@@ -58,12 +86,20 @@ export declare const usePublicDecrypt: () => {
|
|
|
58
86
|
isPending: false;
|
|
59
87
|
isSuccess: true;
|
|
60
88
|
status: "success";
|
|
61
|
-
mutate: import("@tanstack/react-query").UseMutateFunction<
|
|
89
|
+
mutate: import("@tanstack/react-query").UseMutateFunction<Readonly<{
|
|
90
|
+
clearValues: import("@zama-fhe/relayer-sdk/web").ClearValues;
|
|
91
|
+
abiEncodedClearValues: `0x${string}`;
|
|
92
|
+
decryptionProof: `0x${string}`;
|
|
93
|
+
}> | undefined, Error, string[], unknown>;
|
|
62
94
|
reset: () => void;
|
|
63
95
|
context: unknown;
|
|
64
96
|
failureCount: number;
|
|
65
97
|
failureReason: Error | null;
|
|
66
98
|
isPaused: boolean;
|
|
67
99
|
submittedAt: number;
|
|
68
|
-
mutateAsync: import("@tanstack/react-query").UseMutateAsyncFunction<
|
|
100
|
+
mutateAsync: import("@tanstack/react-query").UseMutateAsyncFunction<Readonly<{
|
|
101
|
+
clearValues: import("@zama-fhe/relayer-sdk/web").ClearValues;
|
|
102
|
+
abiEncodedClearValues: `0x${string}`;
|
|
103
|
+
decryptionProof: `0x${string}`;
|
|
104
|
+
}> | undefined, Error, string[], unknown>;
|
|
69
105
|
};
|
package/dist/lib/fhevm.d.ts
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import type { createInstance, FhevmInstance, SepoliaConfig, initSDK } from "@zama-fhe/relayer-sdk/bundle";
|
|
1
|
+
import { Network } from "../types/fhevmConfig";
|
|
2
|
+
import type { createInstance, FhevmInstance, SepoliaConfig, MainnetConfig, initSDK, FhevmInstanceConfig } from "@zama-fhe/relayer-sdk/bundle";
|
|
3
3
|
declare global {
|
|
4
4
|
interface Window {
|
|
5
5
|
relayerSDK: {
|
|
6
6
|
initSDK: typeof initSDK;
|
|
7
7
|
createInstance: typeof createInstance;
|
|
8
8
|
SepoliaConfig: typeof SepoliaConfig;
|
|
9
|
+
MainnetConfig: typeof MainnetConfig;
|
|
9
10
|
};
|
|
10
11
|
}
|
|
11
12
|
}
|
|
12
|
-
export declare const createFhevmInstance: (
|
|
13
|
-
export declare const getOrCreateFhevmInstance: (
|
|
13
|
+
export declare const createFhevmInstance: (network?: Network, customConfig?: FhevmInstanceConfig) => Promise<FhevmInstance>;
|
|
14
|
+
export declare const getOrCreateFhevmInstance: (network?: Network, customConfig?: FhevmInstanceConfig) => Promise<FhevmInstance>;
|
|
14
15
|
export declare const getInstance: () => FhevmInstance | null;
|
package/dist/lib/fhevm.js
CHANGED
|
@@ -8,16 +8,19 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
10
|
let fhevmInstance = null;
|
|
11
|
-
export const createFhevmInstance = (
|
|
11
|
+
export const createFhevmInstance = (...args_1) => __awaiter(void 0, [...args_1], void 0, function* (network = "sepolia", customConfig) {
|
|
12
12
|
if (!fhevmInstance) {
|
|
13
13
|
yield window.relayerSDK.initSDK();
|
|
14
|
-
|
|
14
|
+
const defaultConfig = network === "mainnet"
|
|
15
|
+
? window.relayerSDK.MainnetConfig
|
|
16
|
+
: window.relayerSDK.SepoliaConfig;
|
|
17
|
+
fhevmInstance = yield window.relayerSDK.createInstance(Object.assign(Object.assign(Object.assign({}, defaultConfig), customConfig), { network: "https://ethereum-sepolia-rpc.publicnode.com" }));
|
|
15
18
|
}
|
|
16
19
|
return fhevmInstance;
|
|
17
20
|
});
|
|
18
|
-
export const getOrCreateFhevmInstance = (
|
|
21
|
+
export const getOrCreateFhevmInstance = (...args_1) => __awaiter(void 0, [...args_1], void 0, function* (network = "sepolia", customConfig) {
|
|
19
22
|
if (!fhevmInstance) {
|
|
20
|
-
fhevmInstance = yield createFhevmInstance(
|
|
23
|
+
fhevmInstance = yield createFhevmInstance(network, customConfig);
|
|
21
24
|
}
|
|
22
25
|
return fhevmInstance;
|
|
23
26
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pyratzlabs/react-fhevm-utils",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.5.0",
|
|
4
4
|
"description": "React hooks and utilities for Fhevmjs",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"files": [
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
32
|
"@tanstack/react-query": "^5.71.5",
|
|
33
|
-
"@zama-fhe/relayer-sdk": "^0.
|
|
33
|
+
"@zama-fhe/relayer-sdk": "^0.4.0-3",
|
|
34
34
|
"react": "^19.1.0",
|
|
35
35
|
"viem": "^2.25.0",
|
|
36
36
|
"wagmi": "^2.14.16"
|