@b3dotfun/sdk 0.0.41 → 0.0.42-alpha.1
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/components/AnySpend.d.ts +1 -0
- package/dist/cjs/anyspend/react/components/AnySpend.js +18 -2
- package/dist/cjs/anyspend/react/components/AnySpendBondKit.js +0 -1
- package/dist/cjs/anyspend/react/components/AnySpendBuySpin.js +0 -1
- package/dist/cjs/anyspend/react/components/AnySpendCustom.d.ts +1 -0
- package/dist/cjs/anyspend/react/components/AnySpendCustom.js +76 -14
- package/dist/cjs/anyspend/react/components/AnySpendNFT.d.ts +2 -1
- package/dist/cjs/anyspend/react/components/AnySpendNFT.js +2 -2
- package/dist/cjs/anyspend/react/components/AnySpendStakeB3.js +0 -1
- package/dist/cjs/anyspend/react/components/AnyspendSignatureMint.js +1 -2
- package/dist/cjs/anyspend/react/components/common/CryptoPaySection.js +1 -1
- package/dist/cjs/anyspend/react/components/common/CryptoReceiveSection.js +2 -1
- package/dist/cjs/anyspend/react/components/common/PanelOnramp.js +4 -1
- package/dist/cjs/anyspend/react/components/common/PointsBadge.d.ts +7 -0
- package/dist/cjs/anyspend/react/components/common/PointsBadge.js +7 -0
- package/dist/cjs/anyspend/react/hooks/useAnyspendFlow.js +5 -3
- package/dist/cjs/anyspend/services/anyspend.d.ts +1 -1
- package/dist/cjs/anyspend/services/anyspend.js +2 -0
- package/dist/cjs/anyspend/types/api.d.ts +41 -1
- package/dist/cjs/anyspend/utils/orderPayload.js +3 -0
- package/dist/cjs/bondkit/components/TradingView.js +3 -4
- package/dist/cjs/bondkit/swapService.js +3 -0
- package/dist/cjs/global-account/react/components/B3Provider/B3Provider.js +19 -13
- 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/useAccountAssets.js +5 -2
- package/dist/cjs/global-account/react/hooks/useAuthentication.js +1 -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/cjs/global-account/react/hooks/useQueryB3.js +5 -2
- package/dist/cjs/global-account/react/hooks/useQueryBSMNT.js +5 -2
- package/dist/cjs/global-account/react/hooks/useTokenBalancesByChain.js +7 -1
- package/dist/cjs/global-account/react/hooks/useTokenFromUrl.js +2 -2
- package/dist/cjs/global-account/react/hooks/useUnifiedChainSwitchAndExecute.js +1 -2
- package/dist/cjs/global-account/react/stores/useModalStore.d.ts +1 -1
- package/dist/cjs/shared/utils/fetchBalances.d.ts +1 -1
- package/dist/esm/anyspend/react/components/AnySpend.d.ts +1 -0
- package/dist/esm/anyspend/react/components/AnySpend.js +18 -2
- package/dist/esm/anyspend/react/components/AnySpendBondKit.js +0 -1
- package/dist/esm/anyspend/react/components/AnySpendBuySpin.js +0 -1
- package/dist/esm/anyspend/react/components/AnySpendCustom.d.ts +1 -0
- package/dist/esm/anyspend/react/components/AnySpendCustom.js +43 -14
- package/dist/esm/anyspend/react/components/AnySpendNFT.d.ts +2 -1
- package/dist/esm/anyspend/react/components/AnySpendNFT.js +2 -2
- package/dist/esm/anyspend/react/components/AnySpendStakeB3.js +0 -1
- package/dist/esm/anyspend/react/components/AnyspendSignatureMint.js +1 -2
- package/dist/esm/anyspend/react/components/common/CryptoPaySection.js +1 -1
- package/dist/esm/anyspend/react/components/common/CryptoReceiveSection.js +2 -1
- package/dist/esm/anyspend/react/components/common/PanelOnramp.js +4 -1
- package/dist/esm/anyspend/react/components/common/PointsBadge.d.ts +7 -0
- package/dist/esm/anyspend/react/components/common/PointsBadge.js +4 -0
- package/dist/esm/anyspend/react/hooks/useAnyspendFlow.js +5 -3
- package/dist/esm/anyspend/services/anyspend.d.ts +1 -1
- package/dist/esm/anyspend/services/anyspend.js +2 -0
- package/dist/esm/anyspend/types/api.d.ts +41 -1
- package/dist/esm/anyspend/utils/orderPayload.js +3 -0
- package/dist/esm/bondkit/components/TradingView.js +3 -4
- package/dist/esm/bondkit/swapService.js +5 -2
- package/dist/esm/global-account/react/components/B3Provider/B3Provider.js +19 -13
- 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/useAccountAssets.js +2 -2
- package/dist/esm/global-account/react/hooks/useAuthentication.js +1 -1
- 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/esm/global-account/react/hooks/useQueryB3.js +5 -2
- package/dist/esm/global-account/react/hooks/useQueryBSMNT.js +5 -2
- package/dist/esm/global-account/react/hooks/useTokenBalancesByChain.js +4 -1
- package/dist/esm/global-account/react/hooks/useTokenFromUrl.js +2 -2
- package/dist/esm/global-account/react/hooks/useUnifiedChainSwitchAndExecute.js +2 -3
- package/dist/esm/global-account/react/stores/useModalStore.d.ts +1 -1
- package/dist/esm/shared/utils/fetchBalances.d.ts +1 -1
- package/dist/styles/index.css +1 -1
- package/dist/types/anyspend/react/components/AnySpend.d.ts +1 -0
- package/dist/types/anyspend/react/components/AnySpendCustom.d.ts +1 -0
- package/dist/types/anyspend/react/components/AnySpendNFT.d.ts +2 -1
- package/dist/types/anyspend/react/components/common/PointsBadge.d.ts +7 -0
- package/dist/types/anyspend/services/anyspend.d.ts +1 -1
- package/dist/types/anyspend/types/api.d.ts +41 -1
- 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/dist/types/global-account/react/stores/useModalStore.d.ts +1 -1
- package/dist/types/shared/utils/fetchBalances.d.ts +1 -1
- package/package.json +22 -23
- package/src/anyspend/react/components/AnySpend.tsx +23 -1
- package/src/anyspend/react/components/AnySpendBondKit.tsx +0 -1
- package/src/anyspend/react/components/AnySpendBuySpin.tsx +0 -1
- package/src/anyspend/react/components/AnySpendCustom.tsx +74 -15
- package/src/anyspend/react/components/AnySpendNFT.tsx +3 -0
- package/src/anyspend/react/components/AnySpendStakeB3.tsx +0 -1
- package/src/anyspend/react/components/AnyspendSignatureMint.tsx +1 -2
- package/src/anyspend/react/components/common/CryptoPaySection.tsx +1 -1
- package/src/anyspend/react/components/common/CryptoReceiveSection.tsx +6 -8
- package/src/anyspend/react/components/common/PanelOnramp.tsx +10 -10
- package/src/anyspend/react/components/common/PointsBadge.tsx +20 -0
- package/src/anyspend/react/hooks/useAnyspendFlow.ts +5 -3
- package/src/anyspend/react/hooks/useAnyspendOrderAndTransactions.ts +1 -1
- package/src/anyspend/react/hooks/useCoinbaseOnrampOptions.ts +1 -1
- package/src/anyspend/services/anyspend.ts +3 -1
- package/src/anyspend/types/api.ts +41 -1
- package/src/anyspend/utils/orderPayload.ts +3 -0
- package/src/bondkit/components/TradingView.tsx +3 -5
- package/src/bondkit/swapService.ts +10 -7
- package/src/global-account/react/components/B3Provider/B3Provider.tsx +21 -17
- package/src/global-account/react/hooks/index.ts +1 -0
- package/src/global-account/react/hooks/useAccountAssets.ts +4 -3
- package/src/global-account/react/hooks/useAuthentication.ts +1 -1
- package/src/global-account/react/hooks/useGlobalAccount.tsx +36 -0
- package/src/global-account/react/hooks/useOneBalance.tsx +1 -1
- package/src/global-account/react/hooks/useQueryB3.ts +22 -15
- package/src/global-account/react/hooks/useQueryBSMNT.ts +22 -15
- package/src/global-account/react/hooks/useTokenBalancesByChain.tsx +4 -1
- package/src/global-account/react/hooks/useTokenFromUrl.tsx +2 -2
- package/src/global-account/react/hooks/useUnifiedChainSwitchAndExecute.ts +2 -3
- package/src/global-account/react/stores/useModalStore.ts +1 -1
- package/src/shared/utils/fetchBalances.ts +1 -1
|
@@ -9,6 +9,7 @@ const buildPayload = (orderType, params) => {
|
|
|
9
9
|
return {
|
|
10
10
|
expectedDstAmount,
|
|
11
11
|
actualDstAmount: null,
|
|
12
|
+
amountInAfterFee: null,
|
|
12
13
|
};
|
|
13
14
|
case "mint_nft":
|
|
14
15
|
if (nft?.type === "erc1155") {
|
|
@@ -23,6 +24,7 @@ const buildPayload = (orderType, params) => {
|
|
|
23
24
|
return {
|
|
24
25
|
contractAddress: (0, utils_1.normalizeAddress)(nft.contractAddress),
|
|
25
26
|
nftPrice: nft?.price || "",
|
|
27
|
+
tokenId: null,
|
|
26
28
|
contractType: nft?.type,
|
|
27
29
|
};
|
|
28
30
|
}
|
|
@@ -45,6 +47,7 @@ const buildPayload = (orderType, params) => {
|
|
|
45
47
|
return {
|
|
46
48
|
expectedDstAmount,
|
|
47
49
|
actualDstAmount: null,
|
|
50
|
+
amountInAfterFee: null,
|
|
48
51
|
};
|
|
49
52
|
default:
|
|
50
53
|
throw new Error(`Invalid order type: ${orderType}`);
|
|
@@ -2,16 +2,15 @@
|
|
|
2
2
|
"use client";
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
-
const cdn_loader_1 = require("./utils/cdn-loader");
|
|
6
|
-
const format_1 = require("./utils/format");
|
|
7
5
|
const lucide_react_1 = require("lucide-react");
|
|
8
6
|
const react_1 = require("react");
|
|
7
|
+
const cdn_loader_1 = require("./utils/cdn-loader");
|
|
8
|
+
const format_1 = require("./utils/format");
|
|
9
9
|
// TradingView will be available on window after loading from CDN
|
|
10
10
|
// Datafeed will be implemented inline
|
|
11
11
|
// Mock loading overlay - replace with your actual loading component
|
|
12
12
|
const GifLoadingOverlay = ({ className }) => ((0, jsx_runtime_1.jsx)("div", { className: `absolute inset-0 flex items-center justify-center bg-white/50 backdrop-blur-sm ${className || ""}`, children: (0, jsx_runtime_1.jsx)(lucide_react_1.Loader2, { className: "text-secondary-grey h-8 w-8 animate-spin" }) }));
|
|
13
13
|
const TradingView = ({ className, tokenAddress, tokenSymbol }) => {
|
|
14
|
-
const theme = "light";
|
|
15
14
|
// Use token info for the current trade
|
|
16
15
|
const currentTrade = {
|
|
17
16
|
product_id: tokenAddress && tokenSymbol ? `${tokenSymbol}-${tokenAddress}` : "BONDKIT",
|
|
@@ -247,7 +246,7 @@ const TradingView = ({ className, tokenAddress, tokenSymbol }) => {
|
|
|
247
246
|
tvWidgetRef.current = null;
|
|
248
247
|
}
|
|
249
248
|
};
|
|
250
|
-
}, [
|
|
249
|
+
}, [librariesLoaded, currentTrade?.product_id, tradingViewDefaultInterval, tradingViewTimezone]);
|
|
251
250
|
(0, react_1.useEffect)(() => {
|
|
252
251
|
if (chartLoaded &&
|
|
253
252
|
currentTrade?.product_id &&
|
|
@@ -52,23 +52,29 @@ function B3Provider({ theme = "light", children, accountOverride, environment, a
|
|
|
52
52
|
client: thirdweb_1.client,
|
|
53
53
|
};
|
|
54
54
|
}, [partnerId]);
|
|
55
|
+
// Stringify rpcUrls for stable comparison to prevent wagmiConfig recreation
|
|
56
|
+
// when parent component passes new object references with same content
|
|
57
|
+
const rpcUrlsString = (0, react_2.useMemo)(() => (rpcUrls ? JSON.stringify(rpcUrls) : undefined), [rpcUrls]);
|
|
55
58
|
/**
|
|
56
59
|
* Creates wagmi config with optional custom RPC URLs
|
|
57
60
|
* @param rpcUrls - Optional mapping of chain IDs to RPC URLs
|
|
58
61
|
*/
|
|
59
|
-
const wagmiConfig = (0, react_2.useMemo)(() =>
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
(0,
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
62
|
+
const wagmiConfig = (0, react_2.useMemo)(() => {
|
|
63
|
+
const parsedRpcUrls = rpcUrlsString ? JSON.parse(rpcUrlsString) : undefined;
|
|
64
|
+
return (0, wagmi_1.createConfig)({
|
|
65
|
+
chains: [supported_1.supportedChains[0], ...supported_1.supportedChains.slice(1)],
|
|
66
|
+
transports: Object.fromEntries(supported_1.supportedChains.map(chain => [chain.id, (0, wagmi_1.http)(parsedRpcUrls?.[chain.id])])),
|
|
67
|
+
connectors: [
|
|
68
|
+
(0, wagmi_adapter_1.inAppWalletConnector)({
|
|
69
|
+
...(ecocystemConfig || {}),
|
|
70
|
+
client: thirdweb_1.client,
|
|
71
|
+
}),
|
|
72
|
+
// injected(),
|
|
73
|
+
// coinbaseWallet({ appName: "HypeDuel" }),
|
|
74
|
+
],
|
|
75
|
+
});
|
|
76
|
+
}, [ecocystemConfig, rpcUrlsString]);
|
|
77
|
+
return ((0, jsx_runtime_1.jsx)(react_3.ThirdwebProvider, { children: (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_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 })] }) }) }) }) }) }));
|
|
72
78
|
}
|
|
73
79
|
/**
|
|
74
80
|
* Inner provider component that provides the actual B3Context
|
|
@@ -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");
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.useAccountAssets = useAccountAssets;
|
|
4
7
|
const simplehash_1 = require("../../../shared/utils/simplehash");
|
|
5
8
|
const react_query_1 = require("@tanstack/react-query");
|
|
9
|
+
const invariant_1 = __importDefault(require("invariant"));
|
|
6
10
|
async function fetchAccountAssets(address) {
|
|
7
|
-
|
|
8
|
-
throw new Error("Address is required");
|
|
11
|
+
(0, invariant_1.default)(address, "Address is required");
|
|
9
12
|
const [nftResponse] = await Promise.all([
|
|
10
13
|
(0, simplehash_1.fetchSimpleHashData)(`/v0/nfts/owners`, {
|
|
11
14
|
chains: "b3,b3-sepolia,base",
|
|
@@ -98,7 +98,7 @@ function useAuthentication(partnerId, loginWithSiwe) {
|
|
|
98
98
|
setIsAuthenticating(false);
|
|
99
99
|
}
|
|
100
100
|
useAutoConnectLoadingPrevious.current = useAutoConnectLoading;
|
|
101
|
-
}, [useAutoConnectLoading]);
|
|
101
|
+
}, [useAutoConnectLoading, hasStartedConnecting, setIsAuthenticating]);
|
|
102
102
|
// Ensure isAuthenticating stays true until we're fully ready
|
|
103
103
|
(0, react_2.useEffect)(() => {
|
|
104
104
|
if (useAutoConnectLoading) {
|
|
@@ -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
|
+
}
|
|
@@ -30,11 +30,14 @@ fetchInitially = true) {
|
|
|
30
30
|
finally {
|
|
31
31
|
setIsLoading(false);
|
|
32
32
|
}
|
|
33
|
-
}, []);
|
|
33
|
+
}, [service, method]);
|
|
34
|
+
// Serialize params for stable comparison
|
|
35
|
+
const paramsJson = JSON.stringify(params);
|
|
34
36
|
(0, react_1.useEffect)(() => {
|
|
35
37
|
if (fetchInitially) {
|
|
36
38
|
runQuery(params);
|
|
37
39
|
}
|
|
38
|
-
|
|
40
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
41
|
+
}, [runQuery, fetchInitially, paramsJson]);
|
|
39
42
|
return { data, error, isLoading, runQuery };
|
|
40
43
|
}
|
|
@@ -30,11 +30,14 @@ fetchInitially = true) {
|
|
|
30
30
|
finally {
|
|
31
31
|
setIsLoading(false);
|
|
32
32
|
}
|
|
33
|
-
}, []);
|
|
33
|
+
}, [service, method]);
|
|
34
|
+
// Serialize params for stable comparison
|
|
35
|
+
const paramsJson = JSON.stringify(params);
|
|
34
36
|
(0, react_1.useEffect)(() => {
|
|
35
37
|
if (fetchInitially) {
|
|
36
38
|
runQuery(params);
|
|
37
39
|
}
|
|
38
|
-
|
|
40
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
41
|
+
}, [runQuery, fetchInitially, paramsJson]);
|
|
39
42
|
return { data, error, isLoading, runQuery };
|
|
40
43
|
}
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
"use client";
|
|
3
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
|
+
};
|
|
3
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
7
|
exports.useTokenBalancesByChain = useTokenBalancesByChain;
|
|
5
8
|
const thirdweb_insights_1 = require("../../../shared/utils/thirdweb-insights");
|
|
@@ -8,6 +11,7 @@ const b3Chain_1 = require("../../../shared/constants/chains/b3Chain");
|
|
|
8
11
|
const chains_1 = require("../../../shared/utils/chains");
|
|
9
12
|
const thirdweb_1 = require("../../../shared/utils/thirdweb");
|
|
10
13
|
const wallets_1 = require("thirdweb/wallets");
|
|
14
|
+
const invariant_1 = __importDefault(require("invariant"));
|
|
11
15
|
function useTokenBalancesByChain({ address, chainsIds, enabled = true, }) {
|
|
12
16
|
// Normalize chains to array
|
|
13
17
|
const chainIds = Array.isArray(chainsIds) ? chainsIds : [chainsIds];
|
|
@@ -19,10 +23,12 @@ function useTokenBalancesByChain({ address, chainsIds, enabled = true, }) {
|
|
|
19
23
|
const [nativeTokens, fungibleResponse] = await Promise.all([
|
|
20
24
|
// Fetch native token balances
|
|
21
25
|
Promise.all(chainIds.map(async (chainId) => {
|
|
26
|
+
const chain = (0, chains_1.getChainById)(chainId);
|
|
27
|
+
(0, invariant_1.default)(chain, "Chain is required");
|
|
22
28
|
const walletBalance = await (0, wallets_1.getWalletBalance)({
|
|
23
29
|
address,
|
|
24
30
|
client: thirdweb_1.client,
|
|
25
|
-
chain: (0, b3Chain_1.viemToThirdwebChain)(
|
|
31
|
+
chain: (0, b3Chain_1.viemToThirdwebChain)(chain),
|
|
26
32
|
});
|
|
27
33
|
return {
|
|
28
34
|
...walletBalance,
|
|
@@ -38,7 +38,7 @@ function useTokenFromUrl({ defaultToken, prefix }) {
|
|
|
38
38
|
const network = chainIdParam ? (0, supported_1.getCoingeckoChainInfo)(Number(chainIdParam)).coingecko_id : "";
|
|
39
39
|
const { data: tokenInfo, isError } = (0, react_query_1.useQuery)({
|
|
40
40
|
queryKey: ["tokenInfo", network, currencyParam],
|
|
41
|
-
queryFn: () => fetchTokenInfo(network, currencyParam),
|
|
41
|
+
queryFn: () => fetchTokenInfo(network, currencyParam || ""),
|
|
42
42
|
enabled: shouldFetchToken,
|
|
43
43
|
staleTime: Infinity,
|
|
44
44
|
gcTime: Infinity,
|
|
@@ -51,7 +51,7 @@ function useTokenFromUrl({ defaultToken, prefix }) {
|
|
|
51
51
|
if (isError || !tokenInfo) {
|
|
52
52
|
return {
|
|
53
53
|
...defaultToken,
|
|
54
|
-
address: currencyParam,
|
|
54
|
+
address: currencyParam || "",
|
|
55
55
|
chainId: Number(chainIdParam),
|
|
56
56
|
};
|
|
57
57
|
}
|
|
@@ -23,7 +23,6 @@ const partnerId = String(process.env.PUBLIC_THIRDWEB_PARTNER_ID ||
|
|
|
23
23
|
process.env.NEXT_PUBLIC_GLOBAL_ACCOUNTS_PARTNER_ID);
|
|
24
24
|
(0, invariant_1.default)(partnerId, "Partner ID is required");
|
|
25
25
|
function useUnifiedChainSwitchAndExecute() {
|
|
26
|
-
const { data: walletClient } = (0, wagmi_1.useWalletClient)();
|
|
27
26
|
const { switchChainAsync } = (0, wagmi_1.useSwitchChain)();
|
|
28
27
|
const [isSwitchingOrExecuting, setIsSwitchingOrExecuting] = (0, react_1.useState)(false);
|
|
29
28
|
const activeWallet = (0, react_2.useActiveWallet)();
|
|
@@ -104,7 +103,7 @@ function useUnifiedChainSwitchAndExecute() {
|
|
|
104
103
|
finally {
|
|
105
104
|
setIsSwitchingOrExecuting(false);
|
|
106
105
|
}
|
|
107
|
-
}, [
|
|
106
|
+
}, [connectedEOAWallet, activeWallet, switchChainAsync]);
|
|
108
107
|
// Handle AA wallet transaction (no chain switch needed for AA)
|
|
109
108
|
const handleAASendTransaction = (0, react_1.useCallback)(async (targetChainId, params) => {
|
|
110
109
|
if (!aaAccount) {
|
|
@@ -117,7 +117,7 @@ export interface AnySpendModalProps extends BaseModalProps {
|
|
|
117
117
|
/** Whether to hide the transaction history button */
|
|
118
118
|
hideTransactionHistoryButton?: boolean;
|
|
119
119
|
/** Callback function called when the transaction is successful */
|
|
120
|
-
onSuccess?: () => void;
|
|
120
|
+
onSuccess?: (txHash?: string) => void;
|
|
121
121
|
/** Token address of the destination token to buy (enables buy mode) */
|
|
122
122
|
destinationTokenAddress?: string;
|
|
123
123
|
/** Chain ID where the destination token exists (enables buy mode) */
|
|
@@ -13,4 +13,4 @@ export interface AssetBalance {
|
|
|
13
13
|
totalBalance: string;
|
|
14
14
|
chainBalances: ChainBalance[];
|
|
15
15
|
}
|
|
16
|
-
export declare const fetchBalances: (address: string, testnet?: boolean) => Promise<AssetBalance[]>;
|
|
16
|
+
export declare const fetchBalances: (address: string | undefined, testnet?: boolean) => Promise<AssetBalance[]>;
|
|
@@ -42,7 +42,7 @@ export function AnySpend(props) {
|
|
|
42
42
|
const fingerprintConfig = getFingerprintConfig();
|
|
43
43
|
return (_jsx(AnySpendFingerprintWrapper, { fingerprint: fingerprintConfig, children: _jsx(AnySpendInner, { ...props }) }));
|
|
44
44
|
}
|
|
45
|
-
function AnySpendInner({ destinationTokenAddress, destinationTokenChainId, mode = "modal", defaultActiveTab = "crypto", loadOrder, hideTransactionHistoryButton, recipientAddress: recipientAddressFromProps, onTokenSelect, }) {
|
|
45
|
+
function AnySpendInner({ destinationTokenAddress, destinationTokenChainId, mode = "modal", defaultActiveTab = "crypto", loadOrder, hideTransactionHistoryButton, recipientAddress: recipientAddressFromProps, onTokenSelect, onSuccess, }) {
|
|
46
46
|
const searchParams = useSearchParamsSSR();
|
|
47
47
|
const router = useRouter();
|
|
48
48
|
// Determine if we're in "buy mode" based on whether destination token props are provided
|
|
@@ -50,6 +50,8 @@ function AnySpendInner({ destinationTokenAddress, destinationTokenChainId, mode
|
|
|
50
50
|
// Add refs to track URL state
|
|
51
51
|
const initialUrlProcessed = useRef(false);
|
|
52
52
|
const lastUrlUpdate = useRef(null);
|
|
53
|
+
// Track if onSuccess has been called for the current order
|
|
54
|
+
const onSuccessCalled = useRef(false);
|
|
53
55
|
const [activeTab, setActiveTab] = useState(defaultActiveTab);
|
|
54
56
|
const [orderId, setOrderId] = useState(loadOrder);
|
|
55
57
|
const { orderAndTransactions: oat, getOrderAndTransactionsError } = useAnyspendOrderAndTransactions(orderId);
|
|
@@ -321,8 +323,9 @@ function AnySpendInner({ destinationTokenAddress, destinationTokenChainId, mode
|
|
|
321
323
|
srcTokenAddress: selectedSrcToken.address,
|
|
322
324
|
dstTokenAddress: isBuyMode ? destinationTokenAddress : selectedDstToken.address,
|
|
323
325
|
type: "swap",
|
|
324
|
-
tradeType: isSrcInputDirty ? "EXACT_INPUT" : "
|
|
326
|
+
tradeType: isSrcInputDirty ? "EXACT_INPUT" : "EXACT_OUTPUT",
|
|
325
327
|
amount: activeInputAmountInWei,
|
|
328
|
+
recipientAddress,
|
|
326
329
|
}
|
|
327
330
|
: {
|
|
328
331
|
srcChain: base.id,
|
|
@@ -332,6 +335,7 @@ function AnySpendInner({ destinationTokenAddress, destinationTokenChainId, mode
|
|
|
332
335
|
type: "swap",
|
|
333
336
|
tradeType: "EXACT_INPUT",
|
|
334
337
|
amount: srcAmountOnrampInWei,
|
|
338
|
+
recipientAddress,
|
|
335
339
|
onrampVendor: getOnrampVendor(selectedFiatPaymentMethod),
|
|
336
340
|
});
|
|
337
341
|
// Load custom recipients from local storage on mount
|
|
@@ -384,6 +388,18 @@ function AnySpendInner({ destinationTokenAddress, destinationTokenChainId, mode
|
|
|
384
388
|
}
|
|
385
389
|
}
|
|
386
390
|
}, [anyspendQuote, isSrcInputDirty]);
|
|
391
|
+
useEffect(() => {
|
|
392
|
+
if (oat?.data?.order.status === "executed" && !onSuccessCalled.current) {
|
|
393
|
+
console.log("Calling onSuccess");
|
|
394
|
+
const txHash = oat?.data?.executeTx?.txHash;
|
|
395
|
+
onSuccess?.(txHash);
|
|
396
|
+
onSuccessCalled.current = true;
|
|
397
|
+
}
|
|
398
|
+
}, [oat?.data?.order.status, oat?.data?.executeTx?.txHash, onSuccess]);
|
|
399
|
+
// Reset flag when orderId changes
|
|
400
|
+
useEffect(() => {
|
|
401
|
+
onSuccessCalled.current = false;
|
|
402
|
+
}, [orderId]);
|
|
387
403
|
const { createOrder, isCreatingOrder } = useAnyspendCreateOrder({
|
|
388
404
|
onSuccess: data => {
|
|
389
405
|
const orderId = data.data.id;
|
|
@@ -199,7 +199,6 @@ export function AnySpendBondKit({ mode = "modal", recipientAddress, contractAddr
|
|
|
199
199
|
args: [recipientAddress, parseEther(b3Amount), BigInt(minTokensOut)],
|
|
200
200
|
});
|
|
201
201
|
return (_jsx(AnySpendCustom, { mode: mode, recipientAddress: recipientAddress, orderType: "custom", dstChainId: baseMainnet.id, dstToken: dstToken, dstAmount: parseEther(b3Amount).toString(), contractAddress: contractAddress, encodedData: encodedData, metadata: {
|
|
202
|
-
type: "custom",
|
|
203
202
|
action: "BondKit Buy",
|
|
204
203
|
}, header: header, onSuccess: onSuccess, showRecipient: true }));
|
|
205
204
|
}
|
|
@@ -390,7 +390,6 @@ export function AnySpendBuySpin({ loadOrder, mode = "modal", spinwheelContractAd
|
|
|
390
390
|
// AnySpend flow for when user needs to swap to B3
|
|
391
391
|
const encodedData = generateEncodedDataForBuyEntriesAndSpin(address || "", userSpinQuantity);
|
|
392
392
|
return (_jsx(AnySpendCustom, { loadOrder: loadOrder, mode: mode, recipientAddress: recipientAddress, orderType: "custom", dstChainId: chainId, dstToken: B3_TOKEN, dstAmount: totalCost.toString(), contractAddress: spinwheelContractAddress, spenderAddress: paymentConfig.entryModule, encodedData: encodedData, metadata: {
|
|
393
|
-
type: "custom",
|
|
394
393
|
action: `buy ${userSpinQuantity} spin${userSpinQuantity !== "1" ? "s" : ""}`,
|
|
395
394
|
}, header: header, onSuccess: txHash => onSuccess?.(txHash), showRecipient: false }));
|
|
396
395
|
}
|