@b3dotfun/sdk 0.0.40-test.2 → 0.0.40-test.4
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/cjs/global-account/react/components/B3Provider/B3Provider.d.ts +2 -9
- package/dist/cjs/global-account/react/components/B3Provider/B3Provider.js +37 -15
- package/dist/cjs/global-account/react/hooks/useAccountWallet.js +12 -0
- package/dist/esm/global-account/react/components/B3Provider/B3Provider.d.ts +2 -9
- package/dist/esm/global-account/react/components/B3Provider/B3Provider.js +37 -14
- package/dist/esm/global-account/react/hooks/useAccountWallet.js +12 -0
- package/dist/types/global-account/react/components/B3Provider/B3Provider.d.ts +2 -9
- package/package.json +1 -1
- package/src/global-account/react/components/B3Provider/B3Provider.tsx +45 -14
- package/src/global-account/react/hooks/useAccountWallet.tsx +13 -0
- package/src/global-account/app.d.ts +0 -14
|
@@ -3,18 +3,10 @@ import "@reservoir0x/relay-kit-ui/styles.css";
|
|
|
3
3
|
import { Account } from "thirdweb/wallets";
|
|
4
4
|
import { ClientType } from "../../../client-manager";
|
|
5
5
|
import { B3ContextType } from "./types";
|
|
6
|
-
export declare const wagmiConfig: import("wagmi").Config<readonly [import("viem").Chain, ...import("viem").Chain[]], any, readonly [import("wagmi").CreateConnectorFn<import("thirdweb/dist/types/adapters/eip1193").EIP1193Provider | undefined, {
|
|
7
|
-
connect(parameters?: import("@thirdweb-dev/wagmi-adapter/dist/types/connector").ConnectionOptions): Promise<{
|
|
8
|
-
accounts: readonly `0x${string}`[];
|
|
9
|
-
chainId: number;
|
|
10
|
-
}>;
|
|
11
|
-
}, {
|
|
12
|
-
"thirdweb:lastChainId": number;
|
|
13
|
-
}>]>;
|
|
14
6
|
/**
|
|
15
7
|
* Main B3Provider component
|
|
16
8
|
*/
|
|
17
|
-
export declare function B3Provider({ theme, children, accountOverride, environment, automaticallySetFirstEoa, simDuneApiKey, toaster, clientType, }: {
|
|
9
|
+
export declare function B3Provider({ theme, children, accountOverride, environment, automaticallySetFirstEoa, simDuneApiKey, toaster, clientType, partnerId, }: {
|
|
18
10
|
theme: "light" | "dark";
|
|
19
11
|
children: React.ReactNode;
|
|
20
12
|
accountOverride?: Account;
|
|
@@ -26,6 +18,7 @@ export declare function B3Provider({ theme, children, accountOverride, environme
|
|
|
26
18
|
style?: React.CSSProperties;
|
|
27
19
|
};
|
|
28
20
|
clientType?: ClientType;
|
|
21
|
+
partnerId?: string;
|
|
29
22
|
}): import("react/jsx-runtime").JSX.Element;
|
|
30
23
|
/**
|
|
31
24
|
* Inner provider component that provides the actual B3Context
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.wagmiConfig = void 0;
|
|
4
3
|
exports.B3Provider = B3Provider;
|
|
5
4
|
exports.InnerProvider = InnerProvider;
|
|
6
5
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
@@ -28,24 +27,12 @@ const DEFAULT_PERMISSIONS = {
|
|
|
28
27
|
startDate: new Date(),
|
|
29
28
|
endDate: new Date(Date.now() + 1000 * 60 * 60 * 24 * 365), // 1 year from now
|
|
30
29
|
};
|
|
31
|
-
exports.wagmiConfig = (0, wagmi_1.createConfig)({
|
|
32
|
-
chains: [supported_1.supportedChains[0], ...supported_1.supportedChains.slice(1)],
|
|
33
|
-
transports: Object.fromEntries(supported_1.supportedChains.map(chain => [chain.id, (0, wagmi_1.http)()])),
|
|
34
|
-
connectors: [
|
|
35
|
-
(0, wagmi_adapter_1.inAppWalletConnector)({
|
|
36
|
-
ecosystemId: constants_1.ecosystemWalletId,
|
|
37
|
-
client: thirdweb_1.client,
|
|
38
|
-
}),
|
|
39
|
-
// injected(),
|
|
40
|
-
// coinbaseWallet({ appName: "HypeDuel" }),
|
|
41
|
-
],
|
|
42
|
-
});
|
|
43
30
|
// Create queryClient instance
|
|
44
31
|
const queryClient = new react_query_1.QueryClient();
|
|
45
32
|
/**
|
|
46
33
|
* Main B3Provider component
|
|
47
34
|
*/
|
|
48
|
-
function B3Provider({ theme = "light", children, accountOverride, environment, automaticallySetFirstEoa, simDuneApiKey, toaster, clientType = "rest", }) {
|
|
35
|
+
function B3Provider({ theme = "light", children, accountOverride, environment, automaticallySetFirstEoa, simDuneApiKey, toaster, clientType = "rest", partnerId, }) {
|
|
49
36
|
// Initialize Google Analytics on mount
|
|
50
37
|
(0, react_2.useEffect)(() => {
|
|
51
38
|
(0, analytics_1.loadGA4Script)();
|
|
@@ -54,7 +41,28 @@ function B3Provider({ theme = "light", children, accountOverride, environment, a
|
|
|
54
41
|
(0, react_2.useEffect)(() => {
|
|
55
42
|
(0, client_manager_1.setClientType)(clientType);
|
|
56
43
|
}, [clientType]);
|
|
57
|
-
|
|
44
|
+
const ecocystemConfig = (0, react_2.useMemo)(() => {
|
|
45
|
+
if (!partnerId)
|
|
46
|
+
return undefined;
|
|
47
|
+
return {
|
|
48
|
+
ecosystemId: constants_1.ecosystemWalletId,
|
|
49
|
+
partnerId: partnerId,
|
|
50
|
+
client: thirdweb_1.client,
|
|
51
|
+
};
|
|
52
|
+
}, [partnerId]);
|
|
53
|
+
const wagmiConfig = (0, react_2.useMemo)(() => (0, wagmi_1.createConfig)({
|
|
54
|
+
chains: [supported_1.supportedChains[0], ...supported_1.supportedChains.slice(1)],
|
|
55
|
+
transports: Object.fromEntries(supported_1.supportedChains.map(chain => [chain.id, (0, wagmi_1.http)()])),
|
|
56
|
+
connectors: [
|
|
57
|
+
(0, wagmi_adapter_1.inAppWalletConnector)({
|
|
58
|
+
...ecocystemConfig,
|
|
59
|
+
client: thirdweb_1.client,
|
|
60
|
+
}),
|
|
61
|
+
// injected(),
|
|
62
|
+
// coinbaseWallet({ appName: "HypeDuel" }),
|
|
63
|
+
],
|
|
64
|
+
}), [partnerId]);
|
|
65
|
+
return ((0, jsx_runtime_1.jsx)(wagmi_1.WagmiProvider, { config: wagmiConfig, children: (0, jsx_runtime_1.jsx)(react_query_1.QueryClientProvider, { client: queryClient, children: (0, jsx_runtime_1.jsx)(react_3.ThirdwebProvider, { children: (0, jsx_runtime_1.jsx)(react_1.TooltipProvider, { children: (0, jsx_runtime_1.jsx)(InnerProvider, { accountOverride: accountOverride, environment: environment, theme: theme, automaticallySetFirstEoa: !!automaticallySetFirstEoa, clientType: clientType, children: (0, jsx_runtime_1.jsxs)(react_1.RelayKitProviderWrapper, { simDuneApiKey: simDuneApiKey, children: [children, (0, jsx_runtime_1.jsx)(StyleRoot_1.StyleRoot, { id: "b3-root" }), (0, jsx_runtime_1.jsx)(sonner_1.Toaster, { theme: theme, position: toaster?.position, style: toaster?.style })] }) }) }) }) }) }));
|
|
58
66
|
}
|
|
59
67
|
/**
|
|
60
68
|
* Inner provider component that provides the actual B3Context
|
|
@@ -65,6 +73,20 @@ function InnerProvider({ children, accountOverride, environment, defaultPermissi
|
|
|
65
73
|
const wallets = (0, react_3.useConnectedWallets)();
|
|
66
74
|
const setActiveWallet = (0, react_3.useSetActiveWallet)();
|
|
67
75
|
const isAuthenticated = (0, react_1.useAuthStore)(state => state.isAuthenticated);
|
|
76
|
+
console.log("@@wallets", wallets);
|
|
77
|
+
// Get auth token fro mecosystm wallet
|
|
78
|
+
(0, react_2.useEffect)(() => {
|
|
79
|
+
async function getEcosystemAccount() {
|
|
80
|
+
const ecosystemWallet = wallets.find(wallet => wallet.id === constants_1.ecosystemWalletId);
|
|
81
|
+
if (ecosystemWallet) {
|
|
82
|
+
const authToken = ecosystemWallet.getAuthToken?.();
|
|
83
|
+
const ecosystemAccount = await ecosystemWallet.getAccount();
|
|
84
|
+
console.log("@wallets:@authToken", authToken);
|
|
85
|
+
console.log("@@wallets:ecosystemAccount", ecosystemAccount);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
getEcosystemAccount();
|
|
89
|
+
}, [wallets]);
|
|
68
90
|
const [user, setUser] = (0, react_2.useState)(() => {
|
|
69
91
|
// Try to restore user from localStorage on initialization
|
|
70
92
|
if (typeof window !== "undefined") {
|
|
@@ -43,6 +43,18 @@ function useAccountWallet() {
|
|
|
43
43
|
const { data: profileData } = (0, react_1.useProfile)({ address: account?.address });
|
|
44
44
|
const ensName = profileData?.displayName?.replace(/\.b3\.fun/g, "");
|
|
45
45
|
const avatarUrl = user?.avatar ? (0, ipfs_1.getIpfsUrl)(user?.avatar) : profileData?.avatar;
|
|
46
|
+
console.log("@@gio:connectedWallets", connectedWallets);
|
|
47
|
+
// useEffect(() => {
|
|
48
|
+
// if (connectedWallets.length > 0) {
|
|
49
|
+
// console.log("connectedWallets:1", connectedWallets);
|
|
50
|
+
// // force autoconnect
|
|
51
|
+
// const firstWallet = connectedWallets[0];
|
|
52
|
+
// console.log("firstWallet:1", firstWallet);
|
|
53
|
+
// firstWallet.autoConnect({
|
|
54
|
+
// client: client,
|
|
55
|
+
// });
|
|
56
|
+
// }
|
|
57
|
+
// }, [connectedWallets]);
|
|
46
58
|
const res = (0, react_2.useMemo)(() => ({
|
|
47
59
|
wallet: {
|
|
48
60
|
...account,
|
|
@@ -3,18 +3,10 @@ import "@reservoir0x/relay-kit-ui/styles.css";
|
|
|
3
3
|
import { Account } from "thirdweb/wallets";
|
|
4
4
|
import { ClientType } from "../../../client-manager";
|
|
5
5
|
import { B3ContextType } from "./types";
|
|
6
|
-
export declare const wagmiConfig: import("wagmi").Config<readonly [import("viem").Chain, ...import("viem").Chain[]], any, readonly [import("wagmi").CreateConnectorFn<import("thirdweb/dist/types/adapters/eip1193").EIP1193Provider | undefined, {
|
|
7
|
-
connect(parameters?: import("@thirdweb-dev/wagmi-adapter/dist/types/connector").ConnectionOptions): Promise<{
|
|
8
|
-
accounts: readonly `0x${string}`[];
|
|
9
|
-
chainId: number;
|
|
10
|
-
}>;
|
|
11
|
-
}, {
|
|
12
|
-
"thirdweb:lastChainId": number;
|
|
13
|
-
}>]>;
|
|
14
6
|
/**
|
|
15
7
|
* Main B3Provider component
|
|
16
8
|
*/
|
|
17
|
-
export declare function B3Provider({ theme, children, accountOverride, environment, automaticallySetFirstEoa, simDuneApiKey, toaster, clientType, }: {
|
|
9
|
+
export declare function B3Provider({ theme, children, accountOverride, environment, automaticallySetFirstEoa, simDuneApiKey, toaster, clientType, partnerId, }: {
|
|
18
10
|
theme: "light" | "dark";
|
|
19
11
|
children: React.ReactNode;
|
|
20
12
|
accountOverride?: Account;
|
|
@@ -26,6 +18,7 @@ export declare function B3Provider({ theme, children, accountOverride, environme
|
|
|
26
18
|
style?: React.CSSProperties;
|
|
27
19
|
};
|
|
28
20
|
clientType?: ClientType;
|
|
21
|
+
partnerId?: string;
|
|
29
22
|
}): import("react/jsx-runtime").JSX.Element;
|
|
30
23
|
/**
|
|
31
24
|
* Inner provider component that provides the actual B3Context
|
|
@@ -7,7 +7,7 @@ import { client } from "../../../../shared/utils/thirdweb.js";
|
|
|
7
7
|
import "@reservoir0x/relay-kit-ui/styles.css";
|
|
8
8
|
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
|
|
9
9
|
import { inAppWalletConnector } from "@thirdweb-dev/wagmi-adapter";
|
|
10
|
-
import { useCallback, useEffect, useState } from "react";
|
|
10
|
+
import { useCallback, useEffect, useMemo, useState } from "react";
|
|
11
11
|
import { Toaster } from "sonner";
|
|
12
12
|
import { getLastAuthProvider, ThirdwebProvider, useActiveAccount, useConnectedWallets, useSetActiveWallet, } from "thirdweb/react";
|
|
13
13
|
import { createConfig, http, WagmiProvider } from "wagmi";
|
|
@@ -23,24 +23,12 @@ const DEFAULT_PERMISSIONS = {
|
|
|
23
23
|
startDate: new Date(),
|
|
24
24
|
endDate: new Date(Date.now() + 1000 * 60 * 60 * 24 * 365), // 1 year from now
|
|
25
25
|
};
|
|
26
|
-
export const wagmiConfig = createConfig({
|
|
27
|
-
chains: [supportedChains[0], ...supportedChains.slice(1)],
|
|
28
|
-
transports: Object.fromEntries(supportedChains.map(chain => [chain.id, http()])),
|
|
29
|
-
connectors: [
|
|
30
|
-
inAppWalletConnector({
|
|
31
|
-
ecosystemId: ecosystemWalletId,
|
|
32
|
-
client,
|
|
33
|
-
}),
|
|
34
|
-
// injected(),
|
|
35
|
-
// coinbaseWallet({ appName: "HypeDuel" }),
|
|
36
|
-
],
|
|
37
|
-
});
|
|
38
26
|
// Create queryClient instance
|
|
39
27
|
const queryClient = new QueryClient();
|
|
40
28
|
/**
|
|
41
29
|
* Main B3Provider component
|
|
42
30
|
*/
|
|
43
|
-
export function B3Provider({ theme = "light", children, accountOverride, environment, automaticallySetFirstEoa, simDuneApiKey, toaster, clientType = "rest", }) {
|
|
31
|
+
export function B3Provider({ theme = "light", children, accountOverride, environment, automaticallySetFirstEoa, simDuneApiKey, toaster, clientType = "rest", partnerId, }) {
|
|
44
32
|
// Initialize Google Analytics on mount
|
|
45
33
|
useEffect(() => {
|
|
46
34
|
loadGA4Script();
|
|
@@ -49,6 +37,27 @@ export function B3Provider({ theme = "light", children, accountOverride, environ
|
|
|
49
37
|
useEffect(() => {
|
|
50
38
|
setClientType(clientType);
|
|
51
39
|
}, [clientType]);
|
|
40
|
+
const ecocystemConfig = useMemo(() => {
|
|
41
|
+
if (!partnerId)
|
|
42
|
+
return undefined;
|
|
43
|
+
return {
|
|
44
|
+
ecosystemId: ecosystemWalletId,
|
|
45
|
+
partnerId: partnerId,
|
|
46
|
+
client,
|
|
47
|
+
};
|
|
48
|
+
}, [partnerId]);
|
|
49
|
+
const wagmiConfig = useMemo(() => createConfig({
|
|
50
|
+
chains: [supportedChains[0], ...supportedChains.slice(1)],
|
|
51
|
+
transports: Object.fromEntries(supportedChains.map(chain => [chain.id, http()])),
|
|
52
|
+
connectors: [
|
|
53
|
+
inAppWalletConnector({
|
|
54
|
+
...ecocystemConfig,
|
|
55
|
+
client,
|
|
56
|
+
}),
|
|
57
|
+
// injected(),
|
|
58
|
+
// coinbaseWallet({ appName: "HypeDuel" }),
|
|
59
|
+
],
|
|
60
|
+
}), [partnerId]);
|
|
52
61
|
return (_jsx(WagmiProvider, { config: wagmiConfig, children: _jsx(QueryClientProvider, { client: queryClient, children: _jsx(ThirdwebProvider, { children: _jsx(TooltipProvider, { children: _jsx(InnerProvider, { accountOverride: accountOverride, environment: environment, theme: theme, automaticallySetFirstEoa: !!automaticallySetFirstEoa, clientType: clientType, children: _jsxs(RelayKitProviderWrapper, { simDuneApiKey: simDuneApiKey, children: [children, _jsx(StyleRoot, { id: "b3-root" }), _jsx(Toaster, { theme: theme, position: toaster?.position, style: toaster?.style })] }) }) }) }) }) }));
|
|
53
62
|
}
|
|
54
63
|
/**
|
|
@@ -60,6 +69,20 @@ export function InnerProvider({ children, accountOverride, environment, defaultP
|
|
|
60
69
|
const wallets = useConnectedWallets();
|
|
61
70
|
const setActiveWallet = useSetActiveWallet();
|
|
62
71
|
const isAuthenticated = useAuthStore(state => state.isAuthenticated);
|
|
72
|
+
console.log("@@wallets", wallets);
|
|
73
|
+
// Get auth token fro mecosystm wallet
|
|
74
|
+
useEffect(() => {
|
|
75
|
+
async function getEcosystemAccount() {
|
|
76
|
+
const ecosystemWallet = wallets.find(wallet => wallet.id === ecosystemWalletId);
|
|
77
|
+
if (ecosystemWallet) {
|
|
78
|
+
const authToken = ecosystemWallet.getAuthToken?.();
|
|
79
|
+
const ecosystemAccount = await ecosystemWallet.getAccount();
|
|
80
|
+
console.log("@wallets:@authToken", authToken);
|
|
81
|
+
console.log("@@wallets:ecosystemAccount", ecosystemAccount);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
getEcosystemAccount();
|
|
85
|
+
}, [wallets]);
|
|
63
86
|
const [user, setUser] = useState(() => {
|
|
64
87
|
// Try to restore user from localStorage on initialization
|
|
65
88
|
if (typeof window !== "undefined") {
|
|
@@ -40,6 +40,18 @@ export function useAccountWallet() {
|
|
|
40
40
|
const { data: profileData } = useProfile({ address: account?.address });
|
|
41
41
|
const ensName = profileData?.displayName?.replace(/\.b3\.fun/g, "");
|
|
42
42
|
const avatarUrl = user?.avatar ? getIpfsUrl(user?.avatar) : profileData?.avatar;
|
|
43
|
+
console.log("@@gio:connectedWallets", connectedWallets);
|
|
44
|
+
// useEffect(() => {
|
|
45
|
+
// if (connectedWallets.length > 0) {
|
|
46
|
+
// console.log("connectedWallets:1", connectedWallets);
|
|
47
|
+
// // force autoconnect
|
|
48
|
+
// const firstWallet = connectedWallets[0];
|
|
49
|
+
// console.log("firstWallet:1", firstWallet);
|
|
50
|
+
// firstWallet.autoConnect({
|
|
51
|
+
// client: client,
|
|
52
|
+
// });
|
|
53
|
+
// }
|
|
54
|
+
// }, [connectedWallets]);
|
|
43
55
|
const res = useMemo(() => ({
|
|
44
56
|
wallet: {
|
|
45
57
|
...account,
|
|
@@ -3,18 +3,10 @@ import "@reservoir0x/relay-kit-ui/styles.css";
|
|
|
3
3
|
import { Account } from "thirdweb/wallets";
|
|
4
4
|
import { ClientType } from "../../../client-manager";
|
|
5
5
|
import { B3ContextType } from "./types";
|
|
6
|
-
export declare const wagmiConfig: import("wagmi").Config<readonly [import("viem").Chain, ...import("viem").Chain[]], any, readonly [import("wagmi").CreateConnectorFn<import("thirdweb/dist/types/adapters/eip1193").EIP1193Provider | undefined, {
|
|
7
|
-
connect(parameters?: import("@thirdweb-dev/wagmi-adapter/dist/types/connector").ConnectionOptions): Promise<{
|
|
8
|
-
accounts: readonly `0x${string}`[];
|
|
9
|
-
chainId: number;
|
|
10
|
-
}>;
|
|
11
|
-
}, {
|
|
12
|
-
"thirdweb:lastChainId": number;
|
|
13
|
-
}>]>;
|
|
14
6
|
/**
|
|
15
7
|
* Main B3Provider component
|
|
16
8
|
*/
|
|
17
|
-
export declare function B3Provider({ theme, children, accountOverride, environment, automaticallySetFirstEoa, simDuneApiKey, toaster, clientType, }: {
|
|
9
|
+
export declare function B3Provider({ theme, children, accountOverride, environment, automaticallySetFirstEoa, simDuneApiKey, toaster, clientType, partnerId, }: {
|
|
18
10
|
theme: "light" | "dark";
|
|
19
11
|
children: React.ReactNode;
|
|
20
12
|
accountOverride?: Account;
|
|
@@ -26,6 +18,7 @@ export declare function B3Provider({ theme, children, accountOverride, environme
|
|
|
26
18
|
style?: React.CSSProperties;
|
|
27
19
|
};
|
|
28
20
|
clientType?: ClientType;
|
|
21
|
+
partnerId?: string;
|
|
29
22
|
}): import("react/jsx-runtime").JSX.Element;
|
|
30
23
|
/**
|
|
31
24
|
* Inner provider component that provides the actual B3Context
|
package/package.json
CHANGED
|
@@ -8,7 +8,7 @@ import { client } from "@b3dotfun/sdk/shared/utils/thirdweb";
|
|
|
8
8
|
import "@reservoir0x/relay-kit-ui/styles.css";
|
|
9
9
|
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
|
|
10
10
|
import { inAppWalletConnector } from "@thirdweb-dev/wagmi-adapter";
|
|
11
|
-
import { useCallback, useEffect, useState } from "react";
|
|
11
|
+
import { useCallback, useEffect, useMemo, useState } from "react";
|
|
12
12
|
import { Toaster } from "sonner";
|
|
13
13
|
import {
|
|
14
14
|
getLastAuthProvider,
|
|
@@ -33,19 +33,6 @@ const DEFAULT_PERMISSIONS = {
|
|
|
33
33
|
endDate: new Date(Date.now() + 1000 * 60 * 60 * 24 * 365), // 1 year from now
|
|
34
34
|
};
|
|
35
35
|
|
|
36
|
-
export const wagmiConfig = createConfig({
|
|
37
|
-
chains: [supportedChains[0], ...supportedChains.slice(1)],
|
|
38
|
-
transports: Object.fromEntries(supportedChains.map(chain => [chain.id, http()])) as any,
|
|
39
|
-
connectors: [
|
|
40
|
-
inAppWalletConnector({
|
|
41
|
-
ecosystemId: ecosystemWalletId,
|
|
42
|
-
client,
|
|
43
|
-
}),
|
|
44
|
-
// injected(),
|
|
45
|
-
// coinbaseWallet({ appName: "HypeDuel" }),
|
|
46
|
-
],
|
|
47
|
-
});
|
|
48
|
-
|
|
49
36
|
// Create queryClient instance
|
|
50
37
|
const queryClient = new QueryClient();
|
|
51
38
|
|
|
@@ -61,6 +48,7 @@ export function B3Provider({
|
|
|
61
48
|
simDuneApiKey,
|
|
62
49
|
toaster,
|
|
63
50
|
clientType = "rest",
|
|
51
|
+
partnerId,
|
|
64
52
|
}: {
|
|
65
53
|
theme: "light" | "dark";
|
|
66
54
|
children: React.ReactNode;
|
|
@@ -73,6 +61,7 @@ export function B3Provider({
|
|
|
73
61
|
style?: React.CSSProperties;
|
|
74
62
|
};
|
|
75
63
|
clientType?: ClientType;
|
|
64
|
+
partnerId?: string;
|
|
76
65
|
}) {
|
|
77
66
|
// Initialize Google Analytics on mount
|
|
78
67
|
useEffect(() => {
|
|
@@ -84,6 +73,33 @@ export function B3Provider({
|
|
|
84
73
|
setClientType(clientType);
|
|
85
74
|
}, [clientType]);
|
|
86
75
|
|
|
76
|
+
const ecocystemConfig = useMemo(() => {
|
|
77
|
+
if (!partnerId) return undefined;
|
|
78
|
+
|
|
79
|
+
return {
|
|
80
|
+
ecosystemId: ecosystemWalletId,
|
|
81
|
+
partnerId: partnerId,
|
|
82
|
+
client,
|
|
83
|
+
};
|
|
84
|
+
}, [partnerId]);
|
|
85
|
+
|
|
86
|
+
const wagmiConfig = useMemo(
|
|
87
|
+
() =>
|
|
88
|
+
createConfig({
|
|
89
|
+
chains: [supportedChains[0], ...supportedChains.slice(1)],
|
|
90
|
+
transports: Object.fromEntries(supportedChains.map(chain => [chain.id, http()])) as any,
|
|
91
|
+
connectors: [
|
|
92
|
+
inAppWalletConnector({
|
|
93
|
+
...ecocystemConfig,
|
|
94
|
+
client,
|
|
95
|
+
}),
|
|
96
|
+
// injected(),
|
|
97
|
+
// coinbaseWallet({ appName: "HypeDuel" }),
|
|
98
|
+
],
|
|
99
|
+
}),
|
|
100
|
+
[partnerId],
|
|
101
|
+
);
|
|
102
|
+
|
|
87
103
|
return (
|
|
88
104
|
<WagmiProvider config={wagmiConfig}>
|
|
89
105
|
<QueryClientProvider client={queryClient}>
|
|
@@ -135,6 +151,21 @@ export function InnerProvider({
|
|
|
135
151
|
const wallets = useConnectedWallets();
|
|
136
152
|
const setActiveWallet = useSetActiveWallet();
|
|
137
153
|
const isAuthenticated = useAuthStore(state => state.isAuthenticated);
|
|
154
|
+
console.log("@@wallets", wallets);
|
|
155
|
+
|
|
156
|
+
// Get auth token fro mecosystm wallet
|
|
157
|
+
useEffect(() => {
|
|
158
|
+
async function getEcosystemAccount() {
|
|
159
|
+
const ecosystemWallet = wallets.find(wallet => wallet.id === ecosystemWalletId);
|
|
160
|
+
if (ecosystemWallet) {
|
|
161
|
+
const authToken = ecosystemWallet.getAuthToken?.();
|
|
162
|
+
const ecosystemAccount = await ecosystemWallet.getAccount();
|
|
163
|
+
console.log("@wallets:@authToken", authToken);
|
|
164
|
+
console.log("@@wallets:ecosystemAccount", ecosystemAccount);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
getEcosystemAccount();
|
|
168
|
+
}, [wallets]);
|
|
138
169
|
|
|
139
170
|
const [user, setUser] = useState<Users | undefined>(() => {
|
|
140
171
|
// Try to restore user from localStorage on initialization
|
|
@@ -75,6 +75,19 @@ export function useAccountWallet(): {
|
|
|
75
75
|
const ensName = profileData?.displayName?.replace(/\.b3\.fun/g, "");
|
|
76
76
|
const avatarUrl = user?.avatar ? getIpfsUrl(user?.avatar) : profileData?.avatar;
|
|
77
77
|
|
|
78
|
+
console.log("@@gio:connectedWallets", connectedWallets);
|
|
79
|
+
// useEffect(() => {
|
|
80
|
+
// if (connectedWallets.length > 0) {
|
|
81
|
+
// console.log("connectedWallets:1", connectedWallets);
|
|
82
|
+
// // force autoconnect
|
|
83
|
+
// const firstWallet = connectedWallets[0];
|
|
84
|
+
// console.log("firstWallet:1", firstWallet);
|
|
85
|
+
// firstWallet.autoConnect({
|
|
86
|
+
// client: client,
|
|
87
|
+
// });
|
|
88
|
+
// }
|
|
89
|
+
// }, [connectedWallets]);
|
|
90
|
+
|
|
78
91
|
const res = useMemo(
|
|
79
92
|
() => ({
|
|
80
93
|
wallet: {
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { ClientApplication } from "@b3dotfun/b3-api";
|
|
2
|
-
import { ClientType } from "./client-manager";
|
|
3
|
-
|
|
4
|
-
// Hybrid app type that is both a client instance AND a function
|
|
5
|
-
export interface HybridApp extends ClientApplication {
|
|
6
|
-
(clientType: "socket"): ClientApplication;
|
|
7
|
-
(clientType: "rest"): ClientApplication;
|
|
8
|
-
(clientType: ClientType): ClientApplication;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
// Export the hybrid app as the default
|
|
12
|
-
declare const app: HybridApp;
|
|
13
|
-
export default app;
|
|
14
|
-
|