@b3dotfun/sdk 0.0.1-alpha.21 → 0.0.1-alpha.23
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/package.json
CHANGED
|
@@ -8,33 +8,33 @@ import { createContext } from "react";
|
|
|
8
8
|
* Context type for B3Provider
|
|
9
9
|
*/
|
|
10
10
|
export interface B3ContextType {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
11
|
+
account?: Account;
|
|
12
|
+
automaticallySetFirstEoa: boolean;
|
|
13
|
+
user?: User;
|
|
14
|
+
setAccount: (account: Account) => void;
|
|
15
|
+
setWallet: (wallet: Wallet) => void;
|
|
16
|
+
wallet?: Wallet;
|
|
17
|
+
setUser: (user?: User) => void;
|
|
18
|
+
initialized: boolean;
|
|
19
|
+
ready: boolean;
|
|
20
|
+
environment?: "development" | "production";
|
|
21
|
+
defaultPermissions?: PermissionsConfig;
|
|
22
|
+
theme: "light" | "dark";
|
|
23
|
+
}
|
|
24
24
|
|
|
25
25
|
/**
|
|
26
26
|
* Context for B3 provider
|
|
27
27
|
*/
|
|
28
28
|
export const B3Context = createContext<B3ContextType>({
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
29
|
+
account: undefined,
|
|
30
|
+
automaticallySetFirstEoa: false,
|
|
31
|
+
user: undefined,
|
|
32
|
+
setAccount: () => {},
|
|
33
|
+
setWallet: () => {},
|
|
34
|
+
wallet: undefined,
|
|
35
|
+
setUser: () => {},
|
|
36
|
+
initialized: false,
|
|
37
|
+
ready: false,
|
|
38
|
+
environment: "development",
|
|
39
|
+
theme: "light"
|
|
40
|
+
});
|
|
@@ -6,12 +6,12 @@ import { B3Context } from "./types";
|
|
|
6
6
|
* @throws Error if used outside a B3Provider
|
|
7
7
|
*/
|
|
8
8
|
export function useB3() {
|
|
9
|
-
|
|
9
|
+
const context = useContext(B3Context);
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
// Return a stable reference
|
|
16
|
-
return useMemo(() => context, [context]);
|
|
11
|
+
if (!context.initialized) {
|
|
12
|
+
throw new Error("useB3 must be used within a B3Provider");
|
|
17
13
|
}
|
|
14
|
+
|
|
15
|
+
// Return a stable reference
|
|
16
|
+
return useMemo(() => context, [context]);
|
|
17
|
+
}
|