@b3dotfun/sdk 0.0.40-alpha.24 → 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/anyspend/react/hooks/useAnyspendFlow.js +3 -1
- 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/anyspend/react/hooks/useAnyspendFlow.js +3 -1
- 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/anyspend/react/hooks/useAnyspendFlow.ts +3 -1
- package/src/global-account/react/hooks/index.ts +1 -0
- package/src/global-account/react/hooks/useGlobalAccount.tsx +36 -0
|
@@ -111,7 +111,9 @@ function useAnyspendFlow({ paymentType = "crypto", recipientAddress, loadOrder,
|
|
|
111
111
|
}
|
|
112
112
|
};
|
|
113
113
|
// Get quote
|
|
114
|
-
|
|
114
|
+
// For fiat payments, always use USDC decimals (6) regardless of selectedSrcToken
|
|
115
|
+
const effectiveDecimals = paymentType === "fiat" ? anyspend_1.USDC_BASE.decimals : selectedSrcToken.decimals;
|
|
116
|
+
const activeInputAmountInWei = (0, viem_1.parseUnits)(srcAmount.replace(/,/g, ""), effectiveDecimals).toString();
|
|
115
117
|
const { anyspendQuote, isLoadingAnyspendQuote, getAnyspendQuoteError } = (0, react_1.useAnyspendQuote)({
|
|
116
118
|
srcChain: paymentType === "fiat" ? chains_1.base.id : selectedSrcChainId,
|
|
117
119
|
dstChain: isDepositMode ? chains_1.base.id : selectedDstChainId, // For deposits, always Base; for swaps, use selected destination
|
|
@@ -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
|
+
}
|
|
@@ -107,7 +107,9 @@ export function useAnyspendFlow({ paymentType = "crypto", recipientAddress, load
|
|
|
107
107
|
}
|
|
108
108
|
};
|
|
109
109
|
// Get quote
|
|
110
|
-
|
|
110
|
+
// For fiat payments, always use USDC decimals (6) regardless of selectedSrcToken
|
|
111
|
+
const effectiveDecimals = paymentType === "fiat" ? USDC_BASE.decimals : selectedSrcToken.decimals;
|
|
112
|
+
const activeInputAmountInWei = parseUnits(srcAmount.replace(/,/g, ""), effectiveDecimals).toString();
|
|
111
113
|
const { anyspendQuote, isLoadingAnyspendQuote, getAnyspendQuoteError } = useAnyspendQuote({
|
|
112
114
|
srcChain: paymentType === "fiat" ? base.id : selectedSrcChainId,
|
|
113
115
|
dstChain: isDepositMode ? base.id : selectedDstChainId, // For deposits, always Base; for swaps, use selected destination
|
|
@@ -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
|
@@ -157,7 +157,9 @@ export function useAnyspendFlow({
|
|
|
157
157
|
};
|
|
158
158
|
|
|
159
159
|
// Get quote
|
|
160
|
-
|
|
160
|
+
// For fiat payments, always use USDC decimals (6) regardless of selectedSrcToken
|
|
161
|
+
const effectiveDecimals = paymentType === "fiat" ? USDC_BASE.decimals : selectedSrcToken.decimals;
|
|
162
|
+
const activeInputAmountInWei = parseUnits(srcAmount.replace(/,/g, ""), effectiveDecimals).toString();
|
|
161
163
|
const { anyspendQuote, isLoadingAnyspendQuote, getAnyspendQuoteError } = useAnyspendQuote({
|
|
162
164
|
srcChain: paymentType === "fiat" ? base.id : selectedSrcChainId,
|
|
163
165
|
dstChain: isDepositMode ? base.id : selectedDstChainId, // For deposits, always Base; for swaps, use selected destination
|
|
@@ -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
|
+
}
|