@pyratzlabs/react-fhevm-utils 3.3.0 → 3.4.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/hooks/useAccount.d.ts +45 -0
- package/dist/client/hooks/useAccount.js +6 -0
- package/dist/client/hooks/useDecryptHandles.js +2 -1
- package/dist/client/hooks/useEncryptValue.js +1 -1
- package/dist/client/hooks/useEncryptedBatchTransfer.js +1 -1
- package/dist/client/hooks/useFinalizeUnwrap.js +1 -1
- package/dist/client/hooks/useGetEncryptedBalance.js +2 -1
- package/dist/client/hooks/useUnwrap.d.ts +1 -1
- package/dist/client/hooks/useUnwrap.js +6 -8
- package/dist/types/ABI/Wrapper.abi.d.ts +851 -19
- package/dist/types/ABI/Wrapper.abi.js +1218 -139
- package/package.json +1 -1
- package/dist/client/hooks/useEncryptedApprove.d.ts +0 -11
- package/dist/client/hooks/useEncryptedApprove.js +0 -26
- package/dist/context/FhevmProvider.d.ts +0 -15
- package/dist/context/FhevmProvider.js +0 -34
- package/dist/hooks/useDecryptHandles.d.ts +0 -70
- package/dist/hooks/useDecryptHandles.js +0 -41
- package/dist/hooks/useEncryptValue.d.ts +0 -104
- package/dist/hooks/useEncryptValue.js +0 -30
- package/dist/hooks/useEncryptedApprove.d.ts +0 -11
- package/dist/hooks/useEncryptedApprove.js +0 -26
- package/dist/hooks/useEncryptedTransfer.d.ts +0 -11
- package/dist/hooks/useEncryptedTransfer.js +0 -24
- package/dist/hooks/useFhevmInstance.d.ts +0 -3
- package/dist/hooks/useFhevmInstance.js +0 -5
- package/dist/hooks/useGetEncryptedBalance.d.ts +0 -8
- package/dist/hooks/useGetEncryptedBalance.js +0 -16
- package/dist/hooks/useGetFhevmConfig.d.ts +0 -3
- package/dist/hooks/useGetFhevmConfig.js +0 -5
- package/dist/hooks/usePerformTransaction.d.ts +0 -17
- package/dist/hooks/usePerformTransaction.js +0 -40
- package/dist/types/encryptedABI.d.ts +0 -1180
- package/dist/types/encryptedABI.js +0 -1534
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
export declare const useAccount: () => {
|
|
2
|
+
address: `0x${string}` | undefined;
|
|
3
|
+
addresses: undefined;
|
|
4
|
+
chain: undefined;
|
|
5
|
+
chainId: undefined;
|
|
6
|
+
connector: undefined;
|
|
7
|
+
isConnected: false;
|
|
8
|
+
isReconnecting: false;
|
|
9
|
+
isConnecting: false;
|
|
10
|
+
isDisconnected: true;
|
|
11
|
+
status: "disconnected";
|
|
12
|
+
} | {
|
|
13
|
+
address: `0x${string}` | undefined;
|
|
14
|
+
addresses: readonly [import("abitype").Address, ...import("abitype").Address[]];
|
|
15
|
+
chain: import("viem").Chain | undefined;
|
|
16
|
+
chainId: number;
|
|
17
|
+
connector: import("wagmi").Connector;
|
|
18
|
+
isConnected: true;
|
|
19
|
+
isConnecting: false;
|
|
20
|
+
isDisconnected: false;
|
|
21
|
+
isReconnecting: false;
|
|
22
|
+
status: "connected";
|
|
23
|
+
} | {
|
|
24
|
+
address: `0x${string}` | undefined;
|
|
25
|
+
addresses: readonly import("abitype").Address[] | undefined;
|
|
26
|
+
chain: import("viem").Chain | undefined;
|
|
27
|
+
chainId: number | undefined;
|
|
28
|
+
connector: import("wagmi").Connector | undefined;
|
|
29
|
+
isConnected: boolean;
|
|
30
|
+
isConnecting: false;
|
|
31
|
+
isDisconnected: false;
|
|
32
|
+
isReconnecting: true;
|
|
33
|
+
status: "reconnecting";
|
|
34
|
+
} | {
|
|
35
|
+
address: `0x${string}` | undefined;
|
|
36
|
+
addresses: readonly import("abitype").Address[] | undefined;
|
|
37
|
+
chain: import("viem").Chain | undefined;
|
|
38
|
+
chainId: number | undefined;
|
|
39
|
+
connector: import("wagmi").Connector | undefined;
|
|
40
|
+
isConnected: false;
|
|
41
|
+
isReconnecting: false;
|
|
42
|
+
isConnecting: true;
|
|
43
|
+
isDisconnected: false;
|
|
44
|
+
status: "connecting";
|
|
45
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { getAddress } from "viem";
|
|
2
|
+
import { useAccount as useWagmiAccount } from "wagmi";
|
|
3
|
+
export const useAccount = () => {
|
|
4
|
+
const account = useWagmiAccount();
|
|
5
|
+
return Object.assign(Object.assign({}, account), { address: account.address ? getAddress(account.address) : undefined });
|
|
6
|
+
};
|
|
@@ -8,8 +8,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
10
|
import { useMutation } from "@tanstack/react-query";
|
|
11
|
-
import {
|
|
11
|
+
import { useSignTypedData } from "wagmi";
|
|
12
12
|
import { useFhevmContext } from "../context/FhevmProvider";
|
|
13
|
+
import { useAccount } from "./useAccount";
|
|
13
14
|
export const useDecryptHandles = () => {
|
|
14
15
|
const { instance } = useFhevmContext();
|
|
15
16
|
const { address } = useAccount();
|
|
@@ -8,9 +8,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
10
|
import { useMutation } from "@tanstack/react-query";
|
|
11
|
-
import { useAccount } from "wagmi";
|
|
12
11
|
import { useFhevmContext } from "../context/FhevmProvider";
|
|
13
12
|
import { encryptValues } from "../../server/encrypt";
|
|
13
|
+
import { useAccount } from "./useAccount";
|
|
14
14
|
export const useEncryptValue = ({ tokenAddress }) => {
|
|
15
15
|
const { instance } = useFhevmContext();
|
|
16
16
|
const { address } = useAccount();
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { usePerformTransaction } from "./usePerformTransaction";
|
|
2
2
|
import { TRANSFER_BATCHER_ABI } from "../../types/ABI/TransferBatcher.abi";
|
|
3
|
-
import { useAccount } from "
|
|
3
|
+
import { useAccount } from "./useAccount";
|
|
4
4
|
export const useEncryptedBatchTransfer = ({ batcherAddress }) => {
|
|
5
5
|
const { address } = useAccount();
|
|
6
6
|
const { perform, isLoading, isFailed, isSuccess, error } = usePerformTransaction({
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { usePerformTransaction } from "./usePerformTransaction";
|
|
2
|
-
import { useAccount } from "wagmi";
|
|
3
2
|
import { WRAPPER_ABI } from "../../types/ABI/Wrapper.abi";
|
|
3
|
+
import { useAccount } from "./useAccount";
|
|
4
4
|
export const useFinalizeUnwrap = ({ wrapper }) => {
|
|
5
5
|
const { address } = useAccount();
|
|
6
6
|
const { perform, isFailed, isLoading, isSuccess } = usePerformTransaction({
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useReadContract } from "wagmi";
|
|
2
2
|
import { encryptedABI } from "../../types/ABI/encryptedABI";
|
|
3
|
+
import { useAccount } from "./useAccount";
|
|
3
4
|
export const useGetEncryptedBalance = ({ tokenAddress, userAddress, }) => {
|
|
4
5
|
const { address } = useAccount();
|
|
5
6
|
const { data } = useReadContract({
|
|
@@ -23,7 +23,7 @@ export declare const useUnwrap: ({ encryptedErc20 }: Props) => {
|
|
|
23
23
|
type: import("viem").TransactionType;
|
|
24
24
|
chainId: number;
|
|
25
25
|
} | undefined;
|
|
26
|
-
unwrap: (
|
|
26
|
+
unwrap: (handles: Uint8Array[], inputProof: Uint8Array) => void;
|
|
27
27
|
isFailed: boolean;
|
|
28
28
|
isLoading: boolean;
|
|
29
29
|
isSuccess: boolean;
|
|
@@ -1,23 +1,21 @@
|
|
|
1
|
-
import { encryptedABI } from "../../types/ABI/encryptedABI";
|
|
2
|
-
import { encodeAbiParameters } from "viem";
|
|
3
1
|
import { usePerformTransaction } from "./usePerformTransaction";
|
|
4
2
|
import { toHexString } from "../../utils/string.utils";
|
|
5
|
-
import { useAccount } from "
|
|
3
|
+
import { useAccount } from "./useAccount";
|
|
4
|
+
import { WRAPPER_ABI } from "../../types/ABI/Wrapper.abi";
|
|
6
5
|
export const useUnwrap = ({ encryptedErc20 }) => {
|
|
7
6
|
const { address } = useAccount();
|
|
8
7
|
const { data, perform, isFailed, isLoading, isSuccess } = usePerformTransaction({
|
|
9
|
-
abi:
|
|
8
|
+
abi: WRAPPER_ABI,
|
|
10
9
|
address: encryptedErc20,
|
|
11
|
-
functionName: "
|
|
10
|
+
functionName: "unwrap",
|
|
12
11
|
});
|
|
13
|
-
const unwrap = (
|
|
12
|
+
const unwrap = (handles, inputProof) => {
|
|
14
13
|
if (!address)
|
|
15
14
|
throw new Error("UNWRAP: User is not connected");
|
|
16
15
|
const handle = toHexString(handles[0]);
|
|
17
16
|
const proof = toHexString(inputProof);
|
|
18
|
-
const data = encodeAbiParameters([{ type: "address" }, { type: "address" }, { type: "bytes" }], [address, address, "0x"]);
|
|
19
17
|
perform({
|
|
20
|
-
args: [
|
|
18
|
+
args: [address, address, handle, proof],
|
|
21
19
|
});
|
|
22
20
|
};
|
|
23
21
|
return { unwrapData: data, unwrap, isFailed, isLoading, isSuccess };
|