@b3dotfun/sdk 0.0.41 → 0.0.42
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 +11 -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 +33 -11
- 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/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 +11 -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 +33 -11
- 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/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/shared/utils/fetchBalances.d.ts +1 -1
- package/package.json +22 -23
- package/src/anyspend/react/components/AnySpend.tsx +14 -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 +63 -13
- 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/shared/utils/fetchBalances.ts +1 -1
|
@@ -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) {
|
|
@@ -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
|
|
@@ -321,8 +321,9 @@ function AnySpendInner({ destinationTokenAddress, destinationTokenChainId, mode
|
|
|
321
321
|
srcTokenAddress: selectedSrcToken.address,
|
|
322
322
|
dstTokenAddress: isBuyMode ? destinationTokenAddress : selectedDstToken.address,
|
|
323
323
|
type: "swap",
|
|
324
|
-
tradeType: isSrcInputDirty ? "EXACT_INPUT" : "
|
|
324
|
+
tradeType: isSrcInputDirty ? "EXACT_INPUT" : "EXACT_OUTPUT",
|
|
325
325
|
amount: activeInputAmountInWei,
|
|
326
|
+
recipientAddress,
|
|
326
327
|
}
|
|
327
328
|
: {
|
|
328
329
|
srcChain: base.id,
|
|
@@ -332,6 +333,7 @@ function AnySpendInner({ destinationTokenAddress, destinationTokenChainId, mode
|
|
|
332
333
|
type: "swap",
|
|
333
334
|
tradeType: "EXACT_INPUT",
|
|
334
335
|
amount: srcAmountOnrampInWei,
|
|
336
|
+
recipientAddress,
|
|
335
337
|
onrampVendor: getOnrampVendor(selectedFiatPaymentMethod),
|
|
336
338
|
});
|
|
337
339
|
// Load custom recipients from local storage on mount
|
|
@@ -384,6 +386,13 @@ function AnySpendInner({ destinationTokenAddress, destinationTokenChainId, mode
|
|
|
384
386
|
}
|
|
385
387
|
}
|
|
386
388
|
}, [anyspendQuote, isSrcInputDirty]);
|
|
389
|
+
useEffect(() => {
|
|
390
|
+
if (oat?.data?.order.status === "executed") {
|
|
391
|
+
console.log("Calling onSuccess");
|
|
392
|
+
const txHash = oat?.data?.executeTx?.txHash;
|
|
393
|
+
onSuccess?.(txHash);
|
|
394
|
+
}
|
|
395
|
+
}, [oat?.data?.executeTx?.txHash, oat?.data?.order.status, onSuccess]);
|
|
387
396
|
const { createOrder, isCreatingOrder } = useAnyspendCreateOrder({
|
|
388
397
|
onSuccess: data => {
|
|
389
398
|
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
|
}
|
|
@@ -13,12 +13,15 @@ import { motion } from "motion/react";
|
|
|
13
13
|
import { useCallback, useEffect, useMemo, useState } from "react";
|
|
14
14
|
import { toast } from "sonner";
|
|
15
15
|
import { base } from "viem/chains";
|
|
16
|
+
import { useFeatureFlags } from "../contexts/FeatureFlagsContext.js";
|
|
16
17
|
import { AnySpendFingerprintWrapper, getFingerprintConfig } from "./AnySpendFingerprintWrapper.js";
|
|
17
18
|
import { CryptoPaymentMethod, CryptoPaymentMethodType } from "./common/CryptoPaymentMethod.js";
|
|
18
19
|
import { FiatPaymentMethod, FiatPaymentMethodComponent } from "./common/FiatPaymentMethod.js";
|
|
19
20
|
import { OrderDetails } from "./common/OrderDetails.js";
|
|
20
21
|
import { OrderHistory } from "./common/OrderHistory.js";
|
|
21
22
|
import { OrderToken } from "./common/OrderToken.js";
|
|
23
|
+
import { PointsBadge } from "./common/PointsBadge.js";
|
|
24
|
+
import { PointsDetailPanel } from "./common/PointsDetailPanel.js";
|
|
22
25
|
import { RecipientSelection } from "./common/RecipientSelection.js";
|
|
23
26
|
var PanelView;
|
|
24
27
|
(function (PanelView) {
|
|
@@ -29,8 +32,9 @@ var PanelView;
|
|
|
29
32
|
PanelView[PanelView["RECIPIENT_SELECTION"] = 4] = "RECIPIENT_SELECTION";
|
|
30
33
|
PanelView[PanelView["CRYPTO_PAYMENT_METHOD"] = 5] = "CRYPTO_PAYMENT_METHOD";
|
|
31
34
|
PanelView[PanelView["FIAT_PAYMENT_METHOD"] = 6] = "FIAT_PAYMENT_METHOD";
|
|
35
|
+
PanelView[PanelView["POINTS_DETAIL"] = 7] = "POINTS_DETAIL";
|
|
32
36
|
})(PanelView || (PanelView = {}));
|
|
33
|
-
function generateGetRelayQuoteRequest({ orderType, srcChainId, srcToken, dstChainId, dstToken, dstAmount, contractAddress, tokenId, contractType, encodedData, spenderAddress, }) {
|
|
37
|
+
function generateGetRelayQuoteRequest({ orderType, srcChainId, srcToken, dstChainId, dstToken, recipientAddress, dstAmount, contractAddress, tokenId, contractType, encodedData, spenderAddress, }) {
|
|
34
38
|
switch (orderType) {
|
|
35
39
|
case "mint_nft": {
|
|
36
40
|
invariant(contractType, "Contract type is required");
|
|
@@ -40,6 +44,7 @@ function generateGetRelayQuoteRequest({ orderType, srcChainId, srcToken, dstChai
|
|
|
40
44
|
srcTokenAddress: srcToken.address,
|
|
41
45
|
dstChain: dstChainId,
|
|
42
46
|
dstTokenAddress: dstToken.address,
|
|
47
|
+
recipientAddress,
|
|
43
48
|
price: dstAmount,
|
|
44
49
|
contractAddress: contractAddress,
|
|
45
50
|
tokenId: tokenId,
|
|
@@ -53,6 +58,7 @@ function generateGetRelayQuoteRequest({ orderType, srcChainId, srcToken, dstChai
|
|
|
53
58
|
srcTokenAddress: srcToken.address,
|
|
54
59
|
dstChain: dstChainId,
|
|
55
60
|
dstTokenAddress: dstToken.address,
|
|
61
|
+
recipientAddress,
|
|
56
62
|
price: dstAmount,
|
|
57
63
|
contractAddress: contractAddress,
|
|
58
64
|
};
|
|
@@ -64,6 +70,7 @@ function generateGetRelayQuoteRequest({ orderType, srcChainId, srcToken, dstChai
|
|
|
64
70
|
srcTokenAddress: srcToken.address,
|
|
65
71
|
dstChain: dstChainId,
|
|
66
72
|
dstTokenAddress: dstToken.address,
|
|
73
|
+
recipientAddress,
|
|
67
74
|
fundAmount: dstAmount,
|
|
68
75
|
contractAddress: contractAddress,
|
|
69
76
|
};
|
|
@@ -75,6 +82,7 @@ function generateGetRelayQuoteRequest({ orderType, srcChainId, srcToken, dstChai
|
|
|
75
82
|
srcTokenAddress: srcToken.address,
|
|
76
83
|
dstChain: dstChainId,
|
|
77
84
|
dstTokenAddress: dstToken.address,
|
|
85
|
+
recipientAddress,
|
|
78
86
|
payload: {
|
|
79
87
|
amount: dstAmount,
|
|
80
88
|
data: encodedData,
|
|
@@ -92,8 +100,9 @@ export function AnySpendCustom(props) {
|
|
|
92
100
|
const fingerprintConfig = getFingerprintConfig();
|
|
93
101
|
return (_jsx(AnySpendFingerprintWrapper, { fingerprint: fingerprintConfig, children: _jsx(AnySpendCustomInner, { ...props }) }));
|
|
94
102
|
}
|
|
95
|
-
function AnySpendCustomInner({ loadOrder, mode = "modal", activeTab: activeTabProps = "crypto", recipientAddress: recipientAddressProps, spenderAddress, orderType, dstChainId, dstToken, dstAmount, contractAddress, encodedData, metadata, header, onSuccess, showRecipient = true, }) {
|
|
103
|
+
function AnySpendCustomInner({ loadOrder, mode = "modal", activeTab: activeTabProps = "crypto", recipientAddress: recipientAddressProps, spenderAddress, orderType, dstChainId, dstToken, dstAmount, contractAddress, encodedData, metadata, header, onSuccess, showRecipient = true, onShowPointsDetail, }) {
|
|
96
104
|
const hasMounted = useHasMounted();
|
|
105
|
+
const featureFlags = useFeatureFlags();
|
|
97
106
|
const searchParams = useSearchParamsSSR();
|
|
98
107
|
const router = useRouter();
|
|
99
108
|
const [activePanel, setActivePanel] = useState(loadOrder ? PanelView.ORDER_DETAILS : PanelView.CONFIRM_ORDER);
|
|
@@ -168,10 +177,11 @@ function AnySpendCustomInner({ loadOrder, mode = "modal", activeTab: activeTabPr
|
|
|
168
177
|
srcToken: activeTab === "fiat" ? USDC_BASE : srcToken,
|
|
169
178
|
dstChainId: dstChainId,
|
|
170
179
|
dstToken: dstToken,
|
|
180
|
+
recipientAddress,
|
|
171
181
|
dstAmount: dstAmount,
|
|
172
182
|
contractAddress: contractAddress,
|
|
173
|
-
tokenId:
|
|
174
|
-
contractType:
|
|
183
|
+
tokenId: orderType === "mint_nft" ? metadata?.nftContract?.tokenId : undefined,
|
|
184
|
+
contractType: orderType === "mint_nft" ? metadata?.nftContract?.type : undefined,
|
|
175
185
|
encodedData: encodedData,
|
|
176
186
|
spenderAddress: spenderAddress,
|
|
177
187
|
});
|
|
@@ -184,8 +194,8 @@ function AnySpendCustomInner({ loadOrder, mode = "modal", activeTab: activeTabPr
|
|
|
184
194
|
encodedData,
|
|
185
195
|
metadata?.nftContract?.tokenId,
|
|
186
196
|
metadata?.nftContract?.type,
|
|
187
|
-
metadata?.type,
|
|
188
197
|
orderType,
|
|
198
|
+
recipientAddress,
|
|
189
199
|
spenderAddress,
|
|
190
200
|
srcChainId,
|
|
191
201
|
srcToken,
|
|
@@ -261,7 +271,7 @@ function AnySpendCustomInner({ loadOrder, mode = "modal", activeTab: activeTabPr
|
|
|
261
271
|
srcAmount: srcAmount.toString(),
|
|
262
272
|
recipientAddress,
|
|
263
273
|
creatorAddress: currentWallet?.wallet?.address,
|
|
264
|
-
nft:
|
|
274
|
+
nft: orderType === "mint_nft"
|
|
265
275
|
? metadata.nftContract.type === "erc1155"
|
|
266
276
|
? {
|
|
267
277
|
type: "erc1155",
|
|
@@ -282,7 +292,7 @@ function AnySpendCustomInner({ loadOrder, mode = "modal", activeTab: activeTabPr
|
|
|
282
292
|
imageUrl: metadata.nftContract.imageUrl,
|
|
283
293
|
}
|
|
284
294
|
: undefined,
|
|
285
|
-
tournament:
|
|
295
|
+
tournament: orderType === "join_tournament" || orderType === "fund_tournament"
|
|
286
296
|
? {
|
|
287
297
|
...metadata.tournament,
|
|
288
298
|
contractAddress: contractAddress,
|
|
@@ -290,13 +300,12 @@ function AnySpendCustomInner({ loadOrder, mode = "modal", activeTab: activeTabPr
|
|
|
290
300
|
}
|
|
291
301
|
: undefined,
|
|
292
302
|
// only populate payload for custom tx
|
|
293
|
-
payload:
|
|
303
|
+
payload: orderType === "custom"
|
|
294
304
|
? {
|
|
295
305
|
amount: dstAmount,
|
|
296
306
|
data: encodedData,
|
|
297
307
|
spenderAddress: spenderAddress,
|
|
298
308
|
to: contractAddress,
|
|
299
|
-
action: metadata.action,
|
|
300
309
|
}
|
|
301
310
|
: undefined,
|
|
302
311
|
};
|
|
@@ -421,6 +430,16 @@ function AnySpendCustomInner({ loadOrder, mode = "modal", activeTab: activeTabPr
|
|
|
421
430
|
router.push(`${window.location.pathname}?${params.toString()}`);
|
|
422
431
|
} })), mode === "page" && _jsx("div", { className: "h-12" })] }));
|
|
423
432
|
const loadingView = (_jsxs("div", { className: cn("mx-auto flex w-full flex-col items-center gap-4 p-5", mode === "modal" && "bg-b3-react-background"), children: [_jsxs(Badge, { variant: "default", className: "bg-b3-react-muted/30 border-b3-react-border hover:bg-b3-react-muted/50 flex items-center gap-3 px-4 py-1 text-base transition-all", children: [_jsx(Loader2, { className: "text-b3-react-foreground size-4 animate-spin" }), _jsx(TextShimmer, { duration: 1, className: "font-sf-rounded text-base font-semibold", children: "Loading..." })] }), _jsxs("div", { className: "flex w-full flex-1 flex-col", children: [_jsxs("div", { className: "mb-4 flex flex-col gap-1", children: [_jsx(Skeleton, { className: "h-4 w-24" }), _jsxs("div", { className: "mt-2 flex items-center gap-2", children: [_jsx(Skeleton, { className: "h-8 w-48" }), _jsx(Skeleton, { className: "ml-4 h-8 w-32" })] }), _jsx(Skeleton, { className: "mt-4 h-8 w-24" })] }), _jsx(Skeleton, { className: "mb-4 h-12 w-full" }), _jsxs("div", { className: "flex w-full items-center justify-between gap-4", children: [_jsxs(Skeleton, { className: "rounded-lg bg-white/5 p-6 pb-3", children: [_jsx("div", { className: "size-[200px]" }), _jsx("div", { className: "mt-3 flex items-center justify-center gap-2", children: _jsx("div", { className: "size-5 rounded-full" }) })] }), _jsx("div", { className: "flex flex-1 flex-col gap-2", children: [1, 2, 3].map(i => (_jsx(Skeleton, { className: "h-10 w-full" }, i))) })] })] }), _jsxs("div", { className: "bg-b3-react-muted/30 mt-8 w-full rounded-lg p-4", children: [_jsx(Skeleton, { className: "mb-3 h-4 w-48" }), _jsxs("div", { className: "flex items-center gap-4", children: [_jsx(Skeleton, { className: "h-10 flex-1" }), _jsx(Skeleton, { className: "h-10 flex-1" })] })] }), _jsx("div", { className: "flex w-full flex-col gap-3", children: [1, 2, 3, 4, 5].map(i => (_jsxs("div", { className: "flex w-full justify-between", children: [_jsx(Skeleton, { className: "h-4 w-24" }), _jsx(Skeleton, { className: "h-4 w-32" })] }, i))) }), _jsx(Skeleton, { className: "h-10 w-full" }), mode === "page" && _jsx("div", { className: "h-12" })] }));
|
|
433
|
+
// Render points badge if conditions are met
|
|
434
|
+
const renderPointsBadge = () => {
|
|
435
|
+
if (featureFlags.showPoints && anyspendQuote?.data?.pointsAmount && anyspendQuote.data.pointsAmount > 0) {
|
|
436
|
+
return (_jsx(PointsBadge, { pointsAmount: anyspendQuote.data.pointsAmount, pointsMultiplier: anyspendQuote.data.pointsMultiplier, onClick: () => {
|
|
437
|
+
onShowPointsDetail?.();
|
|
438
|
+
setActivePanel(PanelView.POINTS_DETAIL);
|
|
439
|
+
} }));
|
|
440
|
+
}
|
|
441
|
+
return null;
|
|
442
|
+
};
|
|
424
443
|
// Confirm order view.
|
|
425
444
|
const confirmOrderView = (_jsxs("div", { className: "relative mx-auto flex w-full flex-col items-center", children: [header({ anyspendPrice: anyspendQuote, isLoadingAnyspendPrice: isLoadingAnyspendQuote }), _jsxs(Tabs, { value: activeTab, onValueChange: value => setActiveTab(value), className: "bg-b3-react-background max-h-[60dvh] w-full overflow-y-auto p-5", children: [_jsx("div", { className: "w-full", children: _jsxs("div", { className: "bg-as-surface-secondary relative mb-4 grid h-10 grid-cols-2 rounded-xl", children: [_jsx("div", { className: cn("bg-as-brand absolute bottom-0 left-0 top-0 z-0 rounded-xl transition-transform duration-100", "h-full w-1/2", activeTab === "fiat" ? "translate-x-full" : "translate-x-0"), style: { willChange: "transform" } }), _jsx("button", { className: cn("relative z-10 h-full w-full rounded-xl px-3 text-sm font-medium transition-colors duration-100", activeTab === "crypto" ? "text-white" : "text-as-primary/70 hover:bg-as-on-surface-2 bg-transparent"), onClick: () => {
|
|
426
445
|
setActiveTab("crypto");
|
|
@@ -445,7 +464,7 @@ function AnySpendCustomInner({ loadOrder, mode = "modal", activeTab: activeTabPr
|
|
|
445
464
|
opacity: hasMounted ? 1 : 0,
|
|
446
465
|
y: hasMounted ? 0 : 20,
|
|
447
466
|
filter: hasMounted ? "blur(0px)" : "blur(10px)",
|
|
448
|
-
}, transition: { duration: 0.3, delay: 0.1, ease: "easeInOut" }, className: "relative flex w-full items-center justify-between", children: [_jsxs("span", { className: "text-as-tertiarry text-sm", children: ["Total ", _jsx("span", { className: "text-as-tertiarry", children: "(with fee)" })] }), _jsxs("span", { className: "text-as-primary font-semibold", children: [formattedSrcAmount || "--", " ", srcToken.symbol] })] })] })] }), _jsx("div", { className: cn("flex w-full flex-col items-center justify-between gap-2"), children: _jsx(motion.div, { initial: false, animate: {
|
|
467
|
+
}, transition: { duration: 0.3, delay: 0.1, ease: "easeInOut" }, className: "relative flex w-full items-center justify-between", children: [_jsxs("div", { className: "flex items-center gap-2", children: [_jsxs("span", { className: "text-as-tertiarry text-sm", children: ["Total ", _jsx("span", { className: "text-as-tertiarry", children: "(with fee)" })] }), renderPointsBadge()] }), _jsxs("span", { className: "text-as-primary font-semibold", children: [formattedSrcAmount || "--", " ", srcToken.symbol] })] })] })] }), _jsx("div", { className: cn("flex w-full flex-col items-center justify-between gap-2"), children: _jsx(motion.div, { initial: false, animate: {
|
|
449
468
|
opacity: hasMounted ? 1 : 0,
|
|
450
469
|
y: hasMounted ? 0 : 20,
|
|
451
470
|
filter: hasMounted ? "blur(0px)" : "blur(10px)",
|
|
@@ -457,7 +476,7 @@ function AnySpendCustomInner({ loadOrder, mode = "modal", activeTab: activeTabPr
|
|
|
457
476
|
opacity: hasMounted ? 1 : 0,
|
|
458
477
|
y: hasMounted ? 0 : 20,
|
|
459
478
|
filter: hasMounted ? "blur(0px)" : "blur(10px)",
|
|
460
|
-
}, transition: { duration: 0.3, delay: 0.1, ease: "easeInOut" }, className: "relative flex w-full items-center justify-between", children: [_jsxs("span", { className: "text-as-tertiarry text-sm", children: ["Total ", _jsx("span", { className: "text-as-tertiarry", children: "(USD)" })] }), _jsxs("span", { className: "text-as-primary text-xl font-semibold", children: ["$", srcFiatAmount || "0.00"] })] })] }), _jsx("div", { className: cn("flex w-full flex-col items-center justify-between gap-2"), children: _jsx(motion.div, { initial: false, animate: {
|
|
479
|
+
}, transition: { duration: 0.3, delay: 0.1, ease: "easeInOut" }, className: "relative flex w-full items-center justify-between", children: [_jsxs("div", { className: "flex items-center gap-2", children: [_jsxs("span", { className: "text-as-tertiarry text-sm", children: ["Total ", _jsx("span", { className: "text-as-tertiarry", children: "(USD)" })] }), renderPointsBadge()] }), _jsxs("span", { className: "text-as-primary text-xl font-semibold", children: ["$", srcFiatAmount || "0.00"] })] })] }), _jsx("div", { className: cn("flex w-full flex-col items-center justify-between gap-2"), children: _jsx(motion.div, { initial: false, animate: {
|
|
461
480
|
opacity: hasMounted ? 1 : 0,
|
|
462
481
|
y: hasMounted ? 0 : 20,
|
|
463
482
|
filter: hasMounted ? "blur(0px)" : "blur(10px)",
|
|
@@ -484,6 +503,8 @@ function AnySpendCustomInner({ loadOrder, mode = "modal", activeTab: activeTabPr
|
|
|
484
503
|
setSelectedFiatPaymentMethod(method);
|
|
485
504
|
setActivePanel(PanelView.CONFIRM_ORDER);
|
|
486
505
|
}, srcAmountOnRamp: srcFiatAmount }) }));
|
|
506
|
+
// Points detail view
|
|
507
|
+
const pointsDetailView = (_jsx("div", { className: cn("bg-as-surface-primary mx-auto w-[460px] max-w-full rounded-xl p-4"), children: _jsx(PointsDetailPanel, { pointsAmount: anyspendQuote?.data?.pointsAmount || 0, onBack: () => setActivePanel(PanelView.CONFIRM_ORDER) }) }));
|
|
487
508
|
// Return the TransitionPanel with all views
|
|
488
509
|
return (_jsx(StyleRoot, { children: _jsx(TransitionPanel, { activeIndex: orderId
|
|
489
510
|
? oat
|
|
@@ -503,5 +524,6 @@ function AnySpendCustomInner({ loadOrder, mode = "modal", activeTab: activeTabPr
|
|
|
503
524
|
_jsx("div", { className: "w-full", children: recipientSelectionView }, "recipient-selection-view"),
|
|
504
525
|
_jsx("div", { className: "w-full", children: cryptoPaymentMethodView }, "crypto-payment-method-view"),
|
|
505
526
|
_jsx("div", { className: "w-full", children: fiatPaymentMethodView }, "fiat-payment-method-view"),
|
|
527
|
+
_jsx("div", { className: "w-full", children: pointsDetailView }, "points-detail-view"),
|
|
506
528
|
] }) }));
|
|
507
529
|
}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { components } from "../../../anyspend/types/api";
|
|
2
|
-
export declare function AnySpendNFT({ loadOrder, mode, recipientAddress, nftContract, onSuccess, }: {
|
|
2
|
+
export declare function AnySpendNFT({ loadOrder, mode, recipientAddress, nftContract, onSuccess, onShowPointsDetail, }: {
|
|
3
3
|
loadOrder?: string;
|
|
4
4
|
mode?: "modal" | "page";
|
|
5
5
|
recipientAddress?: string;
|
|
6
6
|
nftContract: components["schemas"]["NftContract"];
|
|
7
7
|
onSuccess?: (txHash?: string) => void;
|
|
8
|
+
onShowPointsDetail?: () => void;
|
|
8
9
|
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -26,7 +26,7 @@ const CONTRACT_URI_ABI = [
|
|
|
26
26
|
type: "function",
|
|
27
27
|
},
|
|
28
28
|
];
|
|
29
|
-
export function AnySpendNFT({ loadOrder, mode = "modal", recipientAddress, nftContract, onSuccess, }) {
|
|
29
|
+
export function AnySpendNFT({ loadOrder, mode = "modal", recipientAddress, nftContract, onSuccess, onShowPointsDetail, }) {
|
|
30
30
|
const [imageUrlWithFallback, setFallbackImageUrl] = useState(nftContract.imageUrl);
|
|
31
31
|
const [isLoadingFallback, setIsLoadingFallback] = useState(false);
|
|
32
32
|
// Fetch contract metadata when imageUrl is empty
|
|
@@ -86,7 +86,7 @@ export function AnySpendNFT({ loadOrder, mode = "modal", recipientAddress, nftCo
|
|
|
86
86
|
return (_jsx(AnySpendCustom, { loadOrder: loadOrder, mode: mode, activeTab: "fiat", recipientAddress: recipientAddress, orderType: "mint_nft", dstChainId: nftContract.chainId, dstToken: nftContract.currency, dstAmount: nftContract.price, contractAddress: nftContract.contractAddress, encodedData: "0x", metadata: {
|
|
87
87
|
type: "mint_nft",
|
|
88
88
|
nftContract: nftContract,
|
|
89
|
-
}, header: header, onSuccess: onSuccess }));
|
|
89
|
+
}, header: header, onSuccess: onSuccess, onShowPointsDetail: onShowPointsDetail }));
|
|
90
90
|
}
|
|
91
91
|
function DropdownMenu({ nftContract }) {
|
|
92
92
|
const [open, setOpen] = useState(false);
|
|
@@ -258,7 +258,6 @@ export function AnySpendStakeB3({ loadOrder, mode = "modal", recipientAddress, s
|
|
|
258
258
|
}
|
|
259
259
|
const encodedData = generateEncodedDataForStakingB3(userStakeAmount, recipientAddress);
|
|
260
260
|
return (_jsx(AnySpendCustom, { loadOrder: loadOrder, mode: mode, recipientAddress: recipientAddress, orderType: "custom", dstChainId: base.id, dstToken: B3_TOKEN, dstAmount: userStakeAmount, contractAddress: ERC20Staking, encodedData: encodedData, metadata: {
|
|
261
|
-
type: "custom",
|
|
262
261
|
action: "stake B3",
|
|
263
262
|
}, header: header, onSuccess: onSuccess, showRecipient: true }));
|
|
264
263
|
}
|
|
@@ -66,8 +66,7 @@ export function AnyspendSignatureMint({ loadOrder, mode = "modal", signatureData
|
|
|
66
66
|
}
|
|
67
67
|
const encodedData = generateEncodedDataForSignatureMint(signatureData);
|
|
68
68
|
const price = parseEther(signatureData.payload.price?.toString() || "0");
|
|
69
|
-
return (_jsx(AnySpendCustom, { loadOrder: loadOrder, mode: mode, recipientAddress: signatureData.payload.to, orderType: "custom", dstChainId: signatureData.collection.chainId, dstToken: dstToken, dstAmount: price.toString(), contractAddress: signatureData.collection.address, encodedData: encodedData, metadata: {
|
|
70
|
-
type: "custom",
|
|
69
|
+
return (_jsx(AnySpendCustom, { loadOrder: loadOrder, mode: mode, recipientAddress: signatureData.payload.to, orderType: "custom", dstChainId: signatureData.collection.chainId, dstToken: dstToken, dstAmount: price.toString(), contractAddress: signatureData.collection.address || "", encodedData: encodedData, metadata: {
|
|
71
70
|
action: "Signature Mint",
|
|
72
71
|
}, header: header, onSuccess: onSuccess, showRecipient: true }));
|
|
73
72
|
}
|
|
@@ -15,7 +15,7 @@ export function CryptoPaySection({ selectedSrcChainId, setSelectedSrcChainId, se
|
|
|
15
15
|
// Determine which address to use based on payment method
|
|
16
16
|
const walletAddress = selectedCryptoPaymentMethod === CryptoPaymentMethodType.GLOBAL_WALLET
|
|
17
17
|
? connectedSmartWallet?.getAccount()?.address
|
|
18
|
-
: connectedEOAWallet?.getAccount()?.address
|
|
18
|
+
: connectedEOAWallet?.getAccount()?.address;
|
|
19
19
|
const { data: profileData } = useProfile({ address: walletAddress });
|
|
20
20
|
const connectedName = profileData?.displayName;
|
|
21
21
|
// Add ref to track if we've applied metadata
|
|
@@ -7,6 +7,7 @@ import { ChevronRight } from "lucide-react";
|
|
|
7
7
|
import { motion } from "motion/react";
|
|
8
8
|
import { useFeatureFlags } from "../../contexts/FeatureFlagsContext.js";
|
|
9
9
|
import { OrderTokenAmount } from "./OrderTokenAmount.js";
|
|
10
|
+
import { PointsBadge } from "./PointsBadge.js";
|
|
10
11
|
export function CryptoReceiveSection({ isDepositMode = false, isBuyMode = false, selectedRecipientAddress, recipientName, onSelectRecipient, dstAmount, dstToken, selectedDstChainId, setSelectedDstChainId, setSelectedDstToken, onChangeDstAmount, anyspendQuote, dstTokenSymbol, dstTokenLogoURI, onShowPointsDetail, }) {
|
|
11
12
|
const featureFlags = useFeatureFlags();
|
|
12
13
|
return (_jsxs(motion.div, { initial: { opacity: 0, y: 20, filter: "blur(10px)" }, animate: { opacity: 1, y: 0, filter: "blur(0px)" }, transition: { duration: 0.3, delay: 0.1, ease: "easeInOut" }, className: "receive-section bg-as-surface-secondary border-as-border-secondary relative flex w-full flex-col gap-2 rounded-2xl border p-4 sm:p-6", children: [_jsxs("div", { className: "flex w-full items-center justify-between", children: [_jsx("div", { className: "text-as-primary/50 flex h-7 items-center text-sm", children: isDepositMode ? "Deposit" : "Receive" }), selectedRecipientAddress ? (_jsx("button", { className: cn("text-as-tertiarry flex h-7 items-center gap-2 rounded-lg"), onClick: onSelectRecipient, children: _jsxs(_Fragment, { children: [_jsx("span", { className: "text-as-tertiarry flex items-center gap-1 text-sm", children: recipientName ? formatUsername(recipientName) : shortenAddress(selectedRecipientAddress || "") }), _jsx(ChevronRight, { className: "h-4 w-4" })] }) })) : (_jsx("button", { className: "text-as-primary/70 flex items-center gap-1 rounded-lg", onClick: onSelectRecipient, children: _jsx("div", { className: "text-sm font-medium", children: "Select recipient" }) }))] }), isBuyMode || isDepositMode ? (
|
|
@@ -48,5 +49,5 @@ export function CryptoReceiveSection({ isDepositMode = false, isBuyMode = false,
|
|
|
48
49
|
}
|
|
49
50
|
// Using inline style to ensure color displays
|
|
50
51
|
return (_jsxs("span", { className: "ml-2", style: { color: percentageNum >= 10 ? "red" : "#FFD700" }, children: ["(", isNegative ? "-" : "", percentage, "%)"] }));
|
|
51
|
-
})()] }), featureFlags.showPoints && anyspendQuote?.data?.pointsAmount
|
|
52
|
+
})()] }), featureFlags.showPoints && anyspendQuote?.data?.pointsAmount > 0 && (_jsx(PointsBadge, { pointsAmount: anyspendQuote.data.pointsAmount, pointsMultiplier: anyspendQuote.data.pointsMultiplier, onClick: () => onShowPointsDetail?.() }))] })] }));
|
|
52
53
|
}
|