@b3dotfun/sdk 0.0.40-alpha.25 → 0.0.40-alpha.26
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/hooks/index.d.ts +1 -0
- package/dist/cjs/global-account/react/hooks/index.js +3 -1
- package/dist/cjs/global-account/react/hooks/useGlobalAccount.d.ts +6 -0
- package/dist/cjs/global-account/react/hooks/useGlobalAccount.js +32 -0
- package/dist/esm/global-account/react/hooks/index.d.ts +1 -0
- package/dist/esm/global-account/react/hooks/index.js +1 -0
- package/dist/esm/global-account/react/hooks/useGlobalAccount.d.ts +6 -0
- package/dist/esm/global-account/react/hooks/useGlobalAccount.js +29 -0
- package/dist/types/global-account/react/hooks/index.d.ts +1 -0
- package/dist/types/global-account/react/hooks/useGlobalAccount.d.ts +6 -0
- package/package.json +1 -1
- package/src/global-account/react/hooks/index.ts +1 -0
- package/src/global-account/react/hooks/useGlobalAccount.tsx +36 -0
|
@@ -14,6 +14,7 @@ export { useExchangeRate } from "./useExchangeRate";
|
|
|
14
14
|
export { useFirstEOA } from "./useFirstEOA";
|
|
15
15
|
export { useGetAllTWSigners, type TWSignerWithMetadata } from "./useGetAllTWSigners";
|
|
16
16
|
export { useGetGeo } from "./useGetGeo";
|
|
17
|
+
export { useGlobalAccount } from "./useGlobalAccount";
|
|
17
18
|
export { useHandleConnectWithPrivy } from "./useHandleConnectWithPrivy";
|
|
18
19
|
export { useHasMounted } from "./useHasMounted";
|
|
19
20
|
export { useIsMobile } from "./useIsMobile";
|
|
@@ -14,7 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.useURLParams = exports.useUnifiedChainSwitchAndExecute = exports.useTokensFromAddress = exports.useTokenPriceWithFallback = exports.useTokenPrice = exports.useTokenFromUrl = exports.useTokenData = exports.useTokenBalancesByChain = exports.useTokenBalance = exports.useSiwe = exports.useSimBalance = exports.useSearchParamsSSR = exports.useRouter = exports.useRemoveSessionKey = exports.useQueryBSMNT = exports.useQueryB3 = exports.useProfilePreference = exports.useProfile = exports.useOneBalance = exports.useNativeBalanceFromRPC = exports.useNativeBalance = exports.useMediaQuery = exports.useIsomorphicLayoutEffect = exports.useIsMobile = exports.useHasMounted = exports.useHandleConnectWithPrivy = exports.useGetGeo = exports.useGetAllTWSigners = exports.useFirstEOA = exports.useExchangeRate = exports.useConnect = exports.useClient = exports.useChainSwitchWithAction = exports.useBestTransactionPath = exports.useB3EnsName = exports.useB3BalanceFromAddresses = exports.useAuthentication = exports.useAnalytics = exports.useAddTWSessionKey = exports.useAccountWallet = exports.useAccountAssets = void 0;
|
|
17
|
+
exports.useURLParams = exports.useUnifiedChainSwitchAndExecute = exports.useTokensFromAddress = exports.useTokenPriceWithFallback = exports.useTokenPrice = exports.useTokenFromUrl = exports.useTokenData = exports.useTokenBalancesByChain = exports.useTokenBalance = exports.useSiwe = exports.useSimBalance = exports.useSearchParamsSSR = exports.useRouter = exports.useRemoveSessionKey = exports.useQueryBSMNT = exports.useQueryB3 = exports.useProfilePreference = exports.useProfile = exports.useOneBalance = exports.useNativeBalanceFromRPC = exports.useNativeBalance = exports.useMediaQuery = exports.useIsomorphicLayoutEffect = exports.useIsMobile = exports.useHasMounted = exports.useHandleConnectWithPrivy = exports.useGlobalAccount = exports.useGetGeo = exports.useGetAllTWSigners = exports.useFirstEOA = exports.useExchangeRate = exports.useConnect = exports.useClient = exports.useChainSwitchWithAction = exports.useBestTransactionPath = exports.useB3EnsName = exports.useB3BalanceFromAddresses = exports.useAuthentication = exports.useAnalytics = exports.useAddTWSessionKey = exports.useAccountWallet = exports.useAccountAssets = void 0;
|
|
18
18
|
var useAccountAssets_1 = require("./useAccountAssets");
|
|
19
19
|
Object.defineProperty(exports, "useAccountAssets", { enumerable: true, get: function () { return useAccountAssets_1.useAccountAssets; } });
|
|
20
20
|
var useAccountWallet_1 = require("./useAccountWallet");
|
|
@@ -46,6 +46,8 @@ var useGetAllTWSigners_1 = require("./useGetAllTWSigners");
|
|
|
46
46
|
Object.defineProperty(exports, "useGetAllTWSigners", { enumerable: true, get: function () { return useGetAllTWSigners_1.useGetAllTWSigners; } });
|
|
47
47
|
var useGetGeo_1 = require("./useGetGeo");
|
|
48
48
|
Object.defineProperty(exports, "useGetGeo", { enumerable: true, get: function () { return useGetGeo_1.useGetGeo; } });
|
|
49
|
+
var useGlobalAccount_1 = require("./useGlobalAccount");
|
|
50
|
+
Object.defineProperty(exports, "useGlobalAccount", { enumerable: true, get: function () { return useGlobalAccount_1.useGlobalAccount; } });
|
|
49
51
|
var useHandleConnectWithPrivy_1 = require("./useHandleConnectWithPrivy");
|
|
50
52
|
Object.defineProperty(exports, "useHandleConnectWithPrivy", { enumerable: true, get: function () { return useHandleConnectWithPrivy_1.useHandleConnectWithPrivy; } });
|
|
51
53
|
var useHasMounted_1 = require("./useHasMounted");
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useGlobalAccount = useGlobalAccount;
|
|
4
|
+
const react_1 = require("../../../global-account/react");
|
|
5
|
+
const debug_1 = require("../../../shared/utils/debug");
|
|
6
|
+
const react_2 = require("react");
|
|
7
|
+
const react_3 = require("thirdweb/react");
|
|
8
|
+
const debug = (0, debug_1.debugB3React)("useGlobalAccount");
|
|
9
|
+
function useGlobalAccount() {
|
|
10
|
+
const wallets = (0, react_3.useConnectedWallets)();
|
|
11
|
+
const isConnected = (0, react_1.useAuthStore)(state => state.isConnected);
|
|
12
|
+
const [globalAccount, setGlobalAccount] = (0, react_2.useState)(undefined);
|
|
13
|
+
const [address, setAddress] = (0, react_2.useState)(undefined);
|
|
14
|
+
const walletInfo = (0, react_3.useWalletInfo)(globalAccount?.id);
|
|
15
|
+
(0, react_2.useEffect)(() => {
|
|
16
|
+
if (!isConnected) {
|
|
17
|
+
debug("Not connected");
|
|
18
|
+
setGlobalAccount(undefined);
|
|
19
|
+
setAddress(undefined);
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
const globalAccountWallet = wallets.find(wallet => wallet.id.startsWith("ecosystem."));
|
|
23
|
+
const account = globalAccountWallet?.getAccount();
|
|
24
|
+
setGlobalAccount(globalAccountWallet);
|
|
25
|
+
setAddress(account?.address);
|
|
26
|
+
}, [isConnected, wallets]);
|
|
27
|
+
return {
|
|
28
|
+
account: globalAccount,
|
|
29
|
+
address,
|
|
30
|
+
info: walletInfo,
|
|
31
|
+
};
|
|
32
|
+
}
|
|
@@ -14,6 +14,7 @@ export { useExchangeRate } from "./useExchangeRate";
|
|
|
14
14
|
export { useFirstEOA } from "./useFirstEOA";
|
|
15
15
|
export { useGetAllTWSigners, type TWSignerWithMetadata } from "./useGetAllTWSigners";
|
|
16
16
|
export { useGetGeo } from "./useGetGeo";
|
|
17
|
+
export { useGlobalAccount } from "./useGlobalAccount";
|
|
17
18
|
export { useHandleConnectWithPrivy } from "./useHandleConnectWithPrivy";
|
|
18
19
|
export { useHasMounted } from "./useHasMounted";
|
|
19
20
|
export { useIsMobile } from "./useIsMobile";
|
|
@@ -14,6 +14,7 @@ export { useExchangeRate } from "./useExchangeRate.js";
|
|
|
14
14
|
export { useFirstEOA } from "./useFirstEOA.js";
|
|
15
15
|
export { useGetAllTWSigners } from "./useGetAllTWSigners.js";
|
|
16
16
|
export { useGetGeo } from "./useGetGeo.js";
|
|
17
|
+
export { useGlobalAccount } from "./useGlobalAccount.js";
|
|
17
18
|
export { useHandleConnectWithPrivy } from "./useHandleConnectWithPrivy.js";
|
|
18
19
|
export { useHasMounted } from "./useHasMounted.js";
|
|
19
20
|
export { useIsMobile } from "./useIsMobile.js";
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { useAuthStore } from "../../../global-account/react/index.js";
|
|
2
|
+
import { debugB3React } from "../../../shared/utils/debug.js";
|
|
3
|
+
import { useEffect, useState } from "react";
|
|
4
|
+
import { useConnectedWallets, useWalletInfo } from "thirdweb/react";
|
|
5
|
+
const debug = debugB3React("useGlobalAccount");
|
|
6
|
+
export function useGlobalAccount() {
|
|
7
|
+
const wallets = useConnectedWallets();
|
|
8
|
+
const isConnected = useAuthStore(state => state.isConnected);
|
|
9
|
+
const [globalAccount, setGlobalAccount] = useState(undefined);
|
|
10
|
+
const [address, setAddress] = useState(undefined);
|
|
11
|
+
const walletInfo = useWalletInfo(globalAccount?.id);
|
|
12
|
+
useEffect(() => {
|
|
13
|
+
if (!isConnected) {
|
|
14
|
+
debug("Not connected");
|
|
15
|
+
setGlobalAccount(undefined);
|
|
16
|
+
setAddress(undefined);
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
const globalAccountWallet = wallets.find(wallet => wallet.id.startsWith("ecosystem."));
|
|
20
|
+
const account = globalAccountWallet?.getAccount();
|
|
21
|
+
setGlobalAccount(globalAccountWallet);
|
|
22
|
+
setAddress(account?.address);
|
|
23
|
+
}, [isConnected, wallets]);
|
|
24
|
+
return {
|
|
25
|
+
account: globalAccount,
|
|
26
|
+
address,
|
|
27
|
+
info: walletInfo,
|
|
28
|
+
};
|
|
29
|
+
}
|
|
@@ -14,6 +14,7 @@ export { useExchangeRate } from "./useExchangeRate";
|
|
|
14
14
|
export { useFirstEOA } from "./useFirstEOA";
|
|
15
15
|
export { useGetAllTWSigners, type TWSignerWithMetadata } from "./useGetAllTWSigners";
|
|
16
16
|
export { useGetGeo } from "./useGetGeo";
|
|
17
|
+
export { useGlobalAccount } from "./useGlobalAccount";
|
|
17
18
|
export { useHandleConnectWithPrivy } from "./useHandleConnectWithPrivy";
|
|
18
19
|
export { useHasMounted } from "./useHasMounted";
|
|
19
20
|
export { useIsMobile } from "./useIsMobile";
|
package/package.json
CHANGED
|
@@ -14,6 +14,7 @@ export { useExchangeRate } from "./useExchangeRate";
|
|
|
14
14
|
export { useFirstEOA } from "./useFirstEOA";
|
|
15
15
|
export { useGetAllTWSigners, type TWSignerWithMetadata } from "./useGetAllTWSigners";
|
|
16
16
|
export { useGetGeo } from "./useGetGeo";
|
|
17
|
+
export { useGlobalAccount } from "./useGlobalAccount";
|
|
17
18
|
export { useHandleConnectWithPrivy } from "./useHandleConnectWithPrivy";
|
|
18
19
|
export { useHasMounted } from "./useHasMounted";
|
|
19
20
|
export { useIsMobile } from "./useIsMobile";
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { useAuthStore } from "@b3dotfun/sdk/global-account/react";
|
|
2
|
+
import { debugB3React } from "@b3dotfun/sdk/shared/utils/debug";
|
|
3
|
+
import { useEffect, useState } from "react";
|
|
4
|
+
import { useConnectedWallets, useWalletInfo } from "thirdweb/react";
|
|
5
|
+
import { Wallet } from "thirdweb/wallets";
|
|
6
|
+
|
|
7
|
+
const debug = debugB3React("useGlobalAccount");
|
|
8
|
+
|
|
9
|
+
export function useGlobalAccount() {
|
|
10
|
+
const wallets = useConnectedWallets();
|
|
11
|
+
const isConnected = useAuthStore(state => state.isConnected);
|
|
12
|
+
const [globalAccount, setGlobalAccount] = useState<Wallet | undefined>(undefined);
|
|
13
|
+
const [address, setAddress] = useState<string | undefined>(undefined);
|
|
14
|
+
const walletInfo = useWalletInfo(globalAccount?.id);
|
|
15
|
+
|
|
16
|
+
useEffect(() => {
|
|
17
|
+
if (!isConnected) {
|
|
18
|
+
debug("Not connected");
|
|
19
|
+
setGlobalAccount(undefined);
|
|
20
|
+
setAddress(undefined);
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const globalAccountWallet = wallets.find(wallet => wallet.id.startsWith("ecosystem."));
|
|
25
|
+
|
|
26
|
+
const account = globalAccountWallet?.getAccount();
|
|
27
|
+
setGlobalAccount(globalAccountWallet);
|
|
28
|
+
setAddress(account?.address);
|
|
29
|
+
}, [isConnected, wallets]);
|
|
30
|
+
|
|
31
|
+
return {
|
|
32
|
+
account: globalAccount,
|
|
33
|
+
address,
|
|
34
|
+
info: walletInfo,
|
|
35
|
+
};
|
|
36
|
+
}
|