@verified-network/verified-custody 0.1.9 → 0.2.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,65 @@
1
+ import React, { createContext, useContext, useState } from "react";
2
+
3
+ interface VaultStore {
4
+ chainId: number | null;
5
+ pk: string | null;
6
+ address: string | null;
7
+ signer: any;
8
+ provider: any;
9
+ vaultContract: any;
10
+ vaultData: any;
11
+ setChainId: (chainId: number | null) => void;
12
+ setPk: (pk: string | null) => void;
13
+ setAddress: (address: string | null) => void;
14
+ setSigner: (signer: any) => void;
15
+ setProvider: (provider: any) => void;
16
+ setVaultContract: (vaultContract: any) => void;
17
+ setVaultData: (vaultData: any) => void;
18
+ }
19
+
20
+ const VaultStoreContext = createContext<VaultStore | undefined>(undefined);
21
+
22
+ export const VaultContextProvider = (props: {
23
+ children: React.JSX.Element;
24
+ }) => {
25
+ const [chainId, setChainId] = useState<number | null>(null);
26
+ const [pk, setPk] = useState<string | null>(null);
27
+ const [address, setAddress] = useState<string | null>(null);
28
+ const [signer, setSigner] = useState<any>(null);
29
+ const [provider, setProvider] = useState<any>(null);
30
+ const [vaultContract, setVaultContract] = useState<any>(null);
31
+ const [vaultData, setVaultData] = useState<any>(null);
32
+ const [fcmToken, setFcmToken] = useState<string | null>(null);
33
+
34
+ return (
35
+ <VaultStoreContext.Provider
36
+ value={{
37
+ chainId,
38
+ pk,
39
+ address,
40
+ signer,
41
+ provider,
42
+ vaultContract,
43
+ vaultData,
44
+ setChainId,
45
+ setPk,
46
+ setAddress,
47
+ setSigner,
48
+ setProvider,
49
+ setVaultContract,
50
+ setVaultData,
51
+ }}
52
+ >
53
+ {props.children}
54
+ </VaultStoreContext.Provider>
55
+ );
56
+ };
57
+
58
+ export const useVaultStore = () => {
59
+ const context = useContext(VaultStoreContext);
60
+ if (context) {
61
+ return context;
62
+ } else {
63
+ throw Error("useVaultStore must be used within VaultContextProvider");
64
+ }
65
+ };