@b3dotfun/sdk 0.0.40-test.3 → 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.js +14 -0
- package/dist/cjs/global-account/react/hooks/useAccountWallet.js +12 -0
- package/dist/esm/global-account/react/components/B3Provider/B3Provider.js +14 -0
- package/dist/esm/global-account/react/hooks/useAccountWallet.js +12 -0
- package/package.json +1 -1
- package/src/global-account/react/components/B3Provider/B3Provider.tsx +15 -0
- package/src/global-account/react/hooks/useAccountWallet.tsx +13 -0
|
@@ -73,6 +73,20 @@ function InnerProvider({ children, accountOverride, environment, defaultPermissi
|
|
|
73
73
|
const wallets = (0, react_3.useConnectedWallets)();
|
|
74
74
|
const setActiveWallet = (0, react_3.useSetActiveWallet)();
|
|
75
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]);
|
|
76
90
|
const [user, setUser] = (0, react_2.useState)(() => {
|
|
77
91
|
// Try to restore user from localStorage on initialization
|
|
78
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,
|
|
@@ -69,6 +69,20 @@ export function InnerProvider({ children, accountOverride, environment, defaultP
|
|
|
69
69
|
const wallets = useConnectedWallets();
|
|
70
70
|
const setActiveWallet = useSetActiveWallet();
|
|
71
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]);
|
|
72
86
|
const [user, setUser] = useState(() => {
|
|
73
87
|
// Try to restore user from localStorage on initialization
|
|
74
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,
|
package/package.json
CHANGED
|
@@ -151,6 +151,21 @@ export function InnerProvider({
|
|
|
151
151
|
const wallets = useConnectedWallets();
|
|
152
152
|
const setActiveWallet = useSetActiveWallet();
|
|
153
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]);
|
|
154
169
|
|
|
155
170
|
const [user, setUser] = useState<Users | undefined>(() => {
|
|
156
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: {
|