@b3dotfun/sdk 0.0.40 → 0.0.41-alpha.0
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 +11 -1
- package/dist/cjs/anyspend/react/components/AnySpend.js +17 -4
- 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/AnyspendDepositHype.d.ts +8 -0
- package/dist/cjs/anyspend/react/components/AnyspendDepositHype.js +6 -3
- package/dist/cjs/anyspend/react/components/AnyspendSignatureMint.js +1 -2
- package/dist/cjs/anyspend/react/components/common/ConnectWalletPayment.js +5 -3
- package/dist/cjs/anyspend/react/components/common/CryptoPaySection.d.ts +4 -1
- package/dist/cjs/anyspend/react/components/common/CryptoPaySection.js +9 -9
- package/dist/cjs/anyspend/react/components/common/CryptoPaymentMethod.js +80 -10
- package/dist/cjs/anyspend/react/components/common/CryptoReceiveSection.d.ts +2 -1
- package/dist/cjs/anyspend/react/components/common/CryptoReceiveSection.js +40 -37
- package/dist/cjs/anyspend/react/components/common/OrderDetails.js +8 -11
- package/dist/cjs/anyspend/react/components/common/OrderTokenAmount.d.ts +4 -1
- package/dist/cjs/anyspend/react/components/common/OrderTokenAmount.js +23 -9
- package/dist/cjs/anyspend/react/components/common/PanelOnramp.d.ts +4 -1
- package/dist/cjs/anyspend/react/components/common/PanelOnramp.js +10 -6
- 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/components/common/PointsDetailPanel.d.ts +6 -0
- package/dist/cjs/anyspend/react/components/common/PointsDetailPanel.js +14 -0
- package/dist/cjs/anyspend/react/contexts/FeatureFlagsContext.d.ts +11 -0
- package/dist/cjs/anyspend/react/contexts/FeatureFlagsContext.js +21 -0
- package/dist/cjs/anyspend/react/hooks/useAnyspendFlow.d.ts +4 -1
- package/dist/cjs/anyspend/react/hooks/useAnyspendFlow.js +18 -8
- package/dist/cjs/anyspend/react/providers/AnyspendProvider.d.ts +5 -2
- package/dist/cjs/anyspend/react/providers/AnyspendProvider.js +5 -3
- package/dist/cjs/anyspend/react/providers/index.d.ts +1 -0
- package/dist/cjs/anyspend/react/providers/index.js +3 -0
- 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 +51 -1
- package/dist/cjs/anyspend/utils/chain.js +1 -1
- package/dist/cjs/anyspend/utils/orderPayload.js +3 -0
- package/dist/cjs/bondkit/bondkitToken.d.ts +37 -2
- package/dist/cjs/bondkit/bondkitToken.js +268 -2
- package/dist/cjs/bondkit/bondkitTokenFactory.d.ts +1 -1
- package/dist/cjs/bondkit/bondkitTokenFactory.js +2 -2
- package/dist/cjs/bondkit/components/TradingView.js +3 -4
- package/dist/cjs/bondkit/config.d.ts +1 -1
- package/dist/cjs/bondkit/config.js +5 -2
- package/dist/cjs/bondkit/constants.d.ts +4 -0
- package/dist/cjs/bondkit/constants.js +6 -1
- package/dist/cjs/bondkit/index.d.ts +1 -0
- package/dist/cjs/bondkit/index.js +4 -1
- package/dist/cjs/bondkit/swapService.d.ts +43 -0
- package/dist/cjs/bondkit/swapService.js +376 -0
- package/dist/cjs/bondkit/types.d.ts +10 -4
- package/dist/cjs/bondkit/types.js +4 -5
- package/dist/cjs/global-account/react/components/B3Provider/B3Provider.d.ts +4 -3
- package/dist/cjs/global-account/react/components/B3Provider/B3Provider.js +41 -9
- package/dist/cjs/global-account/react/components/LinkAccount/LinkAccount.js +63 -3
- package/dist/cjs/global-account/react/components/ManageAccount/ManageAccount.js +35 -2
- package/dist/cjs/global-account/react/components/SignInWithB3/steps/LoginStepCustom.js +4 -3
- 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 +2 -3
- 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/useSimBalance.js +2 -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 +28 -24
- package/dist/cjs/shared/utils/fetchBalances.d.ts +1 -1
- package/dist/esm/anyspend/react/components/AnySpend.d.ts +11 -1
- package/dist/esm/anyspend/react/components/AnySpend.js +17 -4
- 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/AnyspendDepositHype.d.ts +8 -0
- package/dist/esm/anyspend/react/components/AnyspendDepositHype.js +6 -3
- package/dist/esm/anyspend/react/components/AnyspendSignatureMint.js +1 -2
- package/dist/esm/anyspend/react/components/common/ConnectWalletPayment.js +6 -4
- package/dist/esm/anyspend/react/components/common/CryptoPaySection.d.ts +4 -1
- package/dist/esm/anyspend/react/components/common/CryptoPaySection.js +9 -9
- package/dist/esm/anyspend/react/components/common/CryptoPaymentMethod.js +80 -10
- package/dist/esm/anyspend/react/components/common/CryptoReceiveSection.d.ts +2 -1
- package/dist/esm/anyspend/react/components/common/CryptoReceiveSection.js +40 -37
- package/dist/esm/anyspend/react/components/common/OrderDetails.js +8 -11
- package/dist/esm/anyspend/react/components/common/OrderTokenAmount.d.ts +4 -1
- package/dist/esm/anyspend/react/components/common/OrderTokenAmount.js +23 -9
- package/dist/esm/anyspend/react/components/common/PanelOnramp.d.ts +4 -1
- package/dist/esm/anyspend/react/components/common/PanelOnramp.js +10 -6
- 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/components/common/PointsDetailPanel.d.ts +6 -0
- package/dist/esm/anyspend/react/components/common/PointsDetailPanel.js +8 -0
- package/dist/esm/anyspend/react/contexts/FeatureFlagsContext.d.ts +11 -0
- package/dist/esm/anyspend/react/contexts/FeatureFlagsContext.js +17 -0
- package/dist/esm/anyspend/react/hooks/useAnyspendFlow.d.ts +4 -1
- package/dist/esm/anyspend/react/hooks/useAnyspendFlow.js +18 -8
- package/dist/esm/anyspend/react/providers/AnyspendProvider.d.ts +5 -2
- package/dist/esm/anyspend/react/providers/AnyspendProvider.js +5 -3
- package/dist/esm/anyspend/react/providers/index.d.ts +1 -0
- package/dist/esm/anyspend/react/providers/index.js +1 -0
- 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 +51 -1
- package/dist/esm/anyspend/utils/chain.js +1 -1
- package/dist/esm/anyspend/utils/orderPayload.js +3 -0
- package/dist/esm/bondkit/bondkitToken.d.ts +37 -2
- package/dist/esm/bondkit/bondkitToken.js +268 -2
- package/dist/esm/bondkit/bondkitTokenFactory.d.ts +1 -1
- package/dist/esm/bondkit/bondkitTokenFactory.js +2 -2
- package/dist/esm/bondkit/components/TradingView.js +3 -4
- package/dist/esm/bondkit/config.d.ts +1 -1
- package/dist/esm/bondkit/config.js +5 -2
- package/dist/esm/bondkit/constants.d.ts +4 -0
- package/dist/esm/bondkit/constants.js +5 -0
- package/dist/esm/bondkit/index.d.ts +1 -0
- package/dist/esm/bondkit/index.js +2 -0
- package/dist/esm/bondkit/swapService.d.ts +43 -0
- package/dist/esm/bondkit/swapService.js +372 -0
- package/dist/esm/bondkit/types.d.ts +10 -4
- package/dist/esm/bondkit/types.js +4 -5
- package/dist/esm/global-account/react/components/B3Provider/B3Provider.d.ts +4 -3
- package/dist/esm/global-account/react/components/B3Provider/B3Provider.js +42 -9
- package/dist/esm/global-account/react/components/LinkAccount/LinkAccount.js +65 -5
- package/dist/esm/global-account/react/components/ManageAccount/ManageAccount.js +35 -2
- package/dist/esm/global-account/react/components/SignInWithB3/steps/LoginStepCustom.js +3 -2
- 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 +2 -3
- 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/useSimBalance.js +2 -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 +29 -25
- 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 +11 -1
- 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/AnyspendDepositHype.d.ts +8 -0
- package/dist/types/anyspend/react/components/common/CryptoPaySection.d.ts +4 -1
- package/dist/types/anyspend/react/components/common/CryptoReceiveSection.d.ts +2 -1
- package/dist/types/anyspend/react/components/common/OrderTokenAmount.d.ts +4 -1
- package/dist/types/anyspend/react/components/common/PanelOnramp.d.ts +4 -1
- package/dist/types/anyspend/react/components/common/PointsBadge.d.ts +7 -0
- package/dist/types/anyspend/react/components/common/PointsDetailPanel.d.ts +6 -0
- package/dist/types/anyspend/react/contexts/FeatureFlagsContext.d.ts +11 -0
- package/dist/types/anyspend/react/hooks/useAnyspendFlow.d.ts +4 -1
- package/dist/types/anyspend/react/providers/AnyspendProvider.d.ts +5 -2
- package/dist/types/anyspend/react/providers/index.d.ts +1 -0
- package/dist/types/anyspend/services/anyspend.d.ts +1 -1
- package/dist/types/anyspend/types/api.d.ts +51 -1
- package/dist/types/bondkit/bondkitToken.d.ts +37 -2
- package/dist/types/bondkit/bondkitTokenFactory.d.ts +1 -1
- package/dist/types/bondkit/config.d.ts +1 -1
- package/dist/types/bondkit/constants.d.ts +4 -0
- package/dist/types/bondkit/index.d.ts +1 -0
- package/dist/types/bondkit/swapService.d.ts +43 -0
- package/dist/types/bondkit/types.d.ts +10 -4
- package/dist/types/global-account/react/components/B3Provider/B3Provider.d.ts +4 -3
- 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 +6 -5
- package/src/anyspend/react/components/AnySpend.tsx +37 -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/AnyspendDepositHype.tsx +22 -0
- package/src/anyspend/react/components/AnyspendSignatureMint.tsx +1 -2
- package/src/anyspend/react/components/common/ConnectWalletPayment.tsx +7 -4
- package/src/anyspend/react/components/common/CryptoPaySection.tsx +13 -8
- package/src/anyspend/react/components/common/CryptoPaymentMethod.tsx +170 -44
- package/src/anyspend/react/components/common/CryptoReceiveSection.tsx +61 -45
- package/src/anyspend/react/components/common/OrderDetails.tsx +10 -14
- package/src/anyspend/react/components/common/OrderTokenAmount.tsx +28 -8
- package/src/anyspend/react/components/common/PanelOnramp.tsx +28 -15
- package/src/anyspend/react/components/common/PointsBadge.tsx +20 -0
- package/src/anyspend/react/components/common/PointsDetailPanel.tsx +55 -0
- package/src/anyspend/react/contexts/FeatureFlagsContext.tsx +34 -0
- package/src/anyspend/react/hooks/useAnyspendFlow.ts +18 -8
- package/src/anyspend/react/hooks/useAnyspendOrderAndTransactions.ts +1 -1
- package/src/anyspend/react/hooks/useCoinbaseOnrampOptions.ts +1 -1
- package/src/anyspend/react/providers/AnyspendProvider.tsx +11 -6
- package/src/anyspend/react/providers/index.ts +1 -0
- package/src/anyspend/services/anyspend.ts +3 -1
- package/src/anyspend/types/api.ts +51 -1
- package/src/anyspend/types/api_req_res.ts +6 -10
- package/src/anyspend/utils/chain.ts +1 -1
- package/src/anyspend/utils/orderPayload.ts +3 -0
- package/src/bondkit/bondkitToken.ts +323 -3
- package/src/bondkit/bondkitTokenFactory.ts +2 -2
- package/src/bondkit/components/TradingView.tsx +3 -5
- package/src/bondkit/config.ts +5 -2
- package/src/bondkit/constants.ts +7 -0
- package/src/bondkit/index.ts +3 -0
- package/src/bondkit/swapService.ts +464 -0
- package/src/bondkit/types.ts +12 -5
- package/src/global-account/react/components/B3Provider/B3Provider.tsx +55 -15
- package/src/global-account/react/components/LinkAccount/LinkAccount.tsx +106 -32
- package/src/global-account/react/components/ManageAccount/ManageAccount.tsx +60 -5
- package/src/global-account/react/components/SignInWithB3/steps/LoginStepCustom.tsx +4 -2
- 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 +2 -3
- 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/useSimBalance.ts +2 -2
- 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 +30 -26
- package/src/shared/utils/fetchBalances.ts +1 -1
|
@@ -12,50 +12,56 @@ const invariant_1 = __importDefault(require("invariant"));
|
|
|
12
12
|
const react_1 = require("react");
|
|
13
13
|
const sonner_1 = require("sonner");
|
|
14
14
|
const thirdweb_2 = require("thirdweb");
|
|
15
|
+
const react_2 = require("thirdweb/react");
|
|
16
|
+
const viem_1 = require("viem");
|
|
15
17
|
const wagmi_1 = require("wagmi");
|
|
16
18
|
const components_1 = require("../components");
|
|
17
19
|
const useAccountWallet_1 = require("./useAccountWallet");
|
|
18
|
-
const viem_1 = require("viem");
|
|
19
20
|
const partnerId = String(process.env.PUBLIC_THIRDWEB_PARTNER_ID ||
|
|
20
21
|
process.env.NEXT_PUBLIC_THIRDWEB_PARTNER_ID ||
|
|
21
22
|
process.env.PUBLIC_GLOBAL_ACCOUNTS_PARTNER_ID ||
|
|
22
23
|
process.env.NEXT_PUBLIC_GLOBAL_ACCOUNTS_PARTNER_ID);
|
|
23
24
|
(0, invariant_1.default)(partnerId, "Partner ID is required");
|
|
24
25
|
function useUnifiedChainSwitchAndExecute() {
|
|
25
|
-
const { data: walletClient } = (0, wagmi_1.useWalletClient)();
|
|
26
26
|
const { switchChainAsync } = (0, wagmi_1.useSwitchChain)();
|
|
27
27
|
const [isSwitchingOrExecuting, setIsSwitchingOrExecuting] = (0, react_1.useState)(false);
|
|
28
|
-
const
|
|
28
|
+
const activeWallet = (0, react_2.useActiveWallet)();
|
|
29
|
+
const { isActiveSmartWallet, isActiveEOAWallet, connectedEOAWallet } = (0, useAccountWallet_1.useAccountWallet)();
|
|
29
30
|
const { account: aaAccount } = (0, components_1.useB3)();
|
|
30
31
|
// Handle EOA wallet chain switch and execute transaction
|
|
31
32
|
const handleEOASwitchChainAndSendTransaction = (0, react_1.useCallback)(async (targetChainId, params) => {
|
|
32
|
-
if (!
|
|
33
|
+
if (!connectedEOAWallet) {
|
|
33
34
|
sonner_1.toast.error("Please connect your wallet");
|
|
34
35
|
return;
|
|
35
36
|
}
|
|
36
|
-
|
|
37
|
-
const
|
|
37
|
+
// Get target chain configuration once
|
|
38
|
+
const targetChain = supported_1.supportedChains.find(chain => chain.id === targetChainId);
|
|
39
|
+
if (!targetChain) {
|
|
40
|
+
sonner_1.toast.error(`Chain ${targetChainId} is not supported`);
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
const currentChainId = activeWallet?.getChain()?.id;
|
|
44
|
+
const onCorrectChain = currentChainId === targetChainId;
|
|
38
45
|
// Helper function to execute the transaction
|
|
39
46
|
const executeTransaction = async () => {
|
|
40
|
-
const signer =
|
|
47
|
+
const signer = activeWallet?.getAccount();
|
|
41
48
|
if (!signer) {
|
|
42
49
|
throw new Error("No account connected");
|
|
43
50
|
}
|
|
44
|
-
//
|
|
45
|
-
const
|
|
46
|
-
if (
|
|
47
|
-
|
|
51
|
+
// Coinbase Smart Wallet specific chain switching (different behavior from other wallets)
|
|
52
|
+
const walletChain = connectedEOAWallet.getChain();
|
|
53
|
+
if (walletChain?.id !== targetChainId) {
|
|
54
|
+
activeWallet?.switchChain((0, supported_1.getThirdwebChain)(targetChainId));
|
|
48
55
|
}
|
|
49
56
|
(0, invariant_1.default)((0, viem_1.isAddress)(params.to), "params.to is not a valid address");
|
|
50
|
-
const
|
|
51
|
-
|
|
52
|
-
chain: targetChain,
|
|
57
|
+
const result = await signer.sendTransaction({
|
|
58
|
+
chainId: targetChainId,
|
|
53
59
|
to: params.to,
|
|
54
60
|
data: params.data,
|
|
55
61
|
value: params.value,
|
|
56
62
|
});
|
|
57
|
-
sonner_1.toast.success(`Transaction sent: ${
|
|
58
|
-
return
|
|
63
|
+
sonner_1.toast.success(`Transaction sent: ${result.transactionHash.slice(0, 10)}...`);
|
|
64
|
+
return result.transactionHash;
|
|
59
65
|
};
|
|
60
66
|
try {
|
|
61
67
|
setIsSwitchingOrExecuting(true);
|
|
@@ -63,11 +69,6 @@ function useUnifiedChainSwitchAndExecute() {
|
|
|
63
69
|
return await executeTransaction();
|
|
64
70
|
}
|
|
65
71
|
const switchingToastId = sonner_1.toast.info(`Switching to ${(0, anyspend_1.getChainName)(targetChainId)}…`);
|
|
66
|
-
const targetChain = supported_1.supportedChains.find(chain => chain.id === targetChainId);
|
|
67
|
-
if (!targetChain) {
|
|
68
|
-
sonner_1.toast.error(`Chain ${targetChainId} is not supported`);
|
|
69
|
-
return;
|
|
70
|
-
}
|
|
71
72
|
const blockExplorerUrl = targetChain.blockExplorers?.default.url;
|
|
72
73
|
(0, invariant_1.default)(blockExplorerUrl, "Block explorer URL is required");
|
|
73
74
|
const nativeCurrency = (0, anyspend_1.getNativeToken)(targetChainId);
|
|
@@ -102,7 +103,7 @@ function useUnifiedChainSwitchAndExecute() {
|
|
|
102
103
|
finally {
|
|
103
104
|
setIsSwitchingOrExecuting(false);
|
|
104
105
|
}
|
|
105
|
-
}, [
|
|
106
|
+
}, [connectedEOAWallet, activeWallet, switchChainAsync]);
|
|
106
107
|
// Handle AA wallet transaction (no chain switch needed for AA)
|
|
107
108
|
const handleAASendTransaction = (0, react_1.useCallback)(async (targetChainId, params) => {
|
|
108
109
|
if (!aaAccount) {
|
|
@@ -130,18 +131,21 @@ function useUnifiedChainSwitchAndExecute() {
|
|
|
130
131
|
});
|
|
131
132
|
}
|
|
132
133
|
catch (err) {
|
|
133
|
-
console.error(err);
|
|
134
|
+
console.error("Create global-accounts-intents error", err);
|
|
134
135
|
}
|
|
135
136
|
sonner_1.toast.info("Sending transaction…");
|
|
137
|
+
const start = performance.now();
|
|
136
138
|
const sendTxResponse = await (0, thirdweb_2.sendTransaction)({
|
|
137
139
|
account: aaAccount,
|
|
138
140
|
transaction,
|
|
139
141
|
});
|
|
142
|
+
const end = performance.now();
|
|
143
|
+
console.log("Time taken to send transaction", end - start);
|
|
140
144
|
sonner_1.toast.success("Transaction sent successfully");
|
|
141
145
|
return sendTxResponse.transactionHash;
|
|
142
146
|
}
|
|
143
147
|
catch (err) {
|
|
144
|
-
console.error(err);
|
|
148
|
+
console.error("Send transaction error", err);
|
|
145
149
|
sonner_1.toast.error(err?.message ?? "Transaction failed");
|
|
146
150
|
return undefined;
|
|
147
151
|
}
|
|
@@ -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[]>;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { components } from "../../types/api";
|
|
1
2
|
export interface RecipientOption {
|
|
2
3
|
address: string;
|
|
3
4
|
icon?: string;
|
|
@@ -12,7 +13,8 @@ export declare enum PanelView {
|
|
|
12
13
|
FIAT_PAYMENT = 4,
|
|
13
14
|
RECIPIENT_SELECTION = 5,
|
|
14
15
|
CRYPTO_PAYMENT_METHOD = 6,
|
|
15
|
-
FIAT_PAYMENT_METHOD = 7
|
|
16
|
+
FIAT_PAYMENT_METHOD = 7,
|
|
17
|
+
POINTS_DETAIL = 8
|
|
16
18
|
}
|
|
17
19
|
export declare function AnySpend(props: {
|
|
18
20
|
mode?: "page" | "modal";
|
|
@@ -22,4 +24,12 @@ export declare function AnySpend(props: {
|
|
|
22
24
|
recipientAddress?: string;
|
|
23
25
|
loadOrder?: string;
|
|
24
26
|
hideTransactionHistoryButton?: boolean;
|
|
27
|
+
/**
|
|
28
|
+
* Called when a token is selected. Call event.preventDefault() to prevent default token selection behavior.
|
|
29
|
+
* Useful for handling special cases like B3 token selection.
|
|
30
|
+
*/
|
|
31
|
+
onTokenSelect?: (token: components["schemas"]["Token"], event: {
|
|
32
|
+
preventDefault: () => void;
|
|
33
|
+
}) => void;
|
|
34
|
+
onSuccess?: (txHash?: string) => void;
|
|
25
35
|
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -22,6 +22,7 @@ import { OrderDetails, OrderDetailsLoadingView } from "./common/OrderDetails.js"
|
|
|
22
22
|
import { OrderHistory } from "./common/OrderHistory.js";
|
|
23
23
|
import { PanelOnramp } from "./common/PanelOnramp.js";
|
|
24
24
|
import { PanelOnrampPayment } from "./common/PanelOnrampPayment.js";
|
|
25
|
+
import { PointsDetailPanel } from "./common/PointsDetailPanel.js";
|
|
25
26
|
import { RecipientSelection } from "./common/RecipientSelection.js";
|
|
26
27
|
import { TabSection } from "./common/TabSection.js";
|
|
27
28
|
export var PanelView;
|
|
@@ -34,13 +35,14 @@ export var PanelView;
|
|
|
34
35
|
PanelView[PanelView["RECIPIENT_SELECTION"] = 5] = "RECIPIENT_SELECTION";
|
|
35
36
|
PanelView[PanelView["CRYPTO_PAYMENT_METHOD"] = 6] = "CRYPTO_PAYMENT_METHOD";
|
|
36
37
|
PanelView[PanelView["FIAT_PAYMENT_METHOD"] = 7] = "FIAT_PAYMENT_METHOD";
|
|
38
|
+
PanelView[PanelView["POINTS_DETAIL"] = 8] = "POINTS_DETAIL";
|
|
37
39
|
})(PanelView || (PanelView = {}));
|
|
38
40
|
const ANYSPEND_RECIPIENTS_KEY = "anyspend_recipients";
|
|
39
41
|
export function AnySpend(props) {
|
|
40
42
|
const fingerprintConfig = getFingerprintConfig();
|
|
41
43
|
return (_jsx(AnySpendFingerprintWrapper, { fingerprint: fingerprintConfig, children: _jsx(AnySpendInner, { ...props }) }));
|
|
42
44
|
}
|
|
43
|
-
function AnySpendInner({ destinationTokenAddress, destinationTokenChainId, mode = "modal", defaultActiveTab = "crypto", loadOrder, hideTransactionHistoryButton, recipientAddress: recipientAddressFromProps, }) {
|
|
45
|
+
function AnySpendInner({ destinationTokenAddress, destinationTokenChainId, mode = "modal", defaultActiveTab = "crypto", loadOrder, hideTransactionHistoryButton, recipientAddress: recipientAddressFromProps, onTokenSelect, onSuccess, }) {
|
|
44
46
|
const searchParams = useSearchParamsSSR();
|
|
45
47
|
const router = useRouter();
|
|
46
48
|
// Determine if we're in "buy mode" based on whether destination token props are provided
|
|
@@ -319,8 +321,9 @@ function AnySpendInner({ destinationTokenAddress, destinationTokenChainId, mode
|
|
|
319
321
|
srcTokenAddress: selectedSrcToken.address,
|
|
320
322
|
dstTokenAddress: isBuyMode ? destinationTokenAddress : selectedDstToken.address,
|
|
321
323
|
type: "swap",
|
|
322
|
-
tradeType: isSrcInputDirty ? "EXACT_INPUT" : "
|
|
324
|
+
tradeType: isSrcInputDirty ? "EXACT_INPUT" : "EXACT_OUTPUT",
|
|
323
325
|
amount: activeInputAmountInWei,
|
|
326
|
+
recipientAddress,
|
|
324
327
|
}
|
|
325
328
|
: {
|
|
326
329
|
srcChain: base.id,
|
|
@@ -330,6 +333,7 @@ function AnySpendInner({ destinationTokenAddress, destinationTokenChainId, mode
|
|
|
330
333
|
type: "swap",
|
|
331
334
|
tradeType: "EXACT_INPUT",
|
|
332
335
|
amount: srcAmountOnrampInWei,
|
|
336
|
+
recipientAddress,
|
|
333
337
|
onrampVendor: getOnrampVendor(selectedFiatPaymentMethod),
|
|
334
338
|
});
|
|
335
339
|
// Load custom recipients from local storage on mount
|
|
@@ -382,6 +386,13 @@ function AnySpendInner({ destinationTokenAddress, destinationTokenChainId, mode
|
|
|
382
386
|
}
|
|
383
387
|
}
|
|
384
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]);
|
|
385
396
|
const { createOrder, isCreatingOrder } = useAnyspendCreateOrder({
|
|
386
397
|
onSuccess: data => {
|
|
387
398
|
const orderId = data.data.id;
|
|
@@ -656,7 +667,7 @@ function AnySpendInner({ destinationTokenAddress, destinationTokenChainId, mode
|
|
|
656
667
|
setActivePanel(PanelView.MAIN);
|
|
657
668
|
setSelectedCryptoPaymentMethod(CryptoPaymentMethodType.NONE); // Reset payment method when going back
|
|
658
669
|
} })) }) }));
|
|
659
|
-
const mainView = (_jsxs("div", { className: "mx-auto flex w-[460px] max-w-full flex-col items-center gap-2", children: [isBuyMode && (_jsxs("div", { className: "mb-4 flex flex-col items-center gap-3 text-center", children: [selectedDstToken.metadata?.logoURI && (_jsx("div", { className: "relative", children: _jsx("img", { src: selectedDstToken.metadata.logoURI, alt: selectedDstToken.symbol, className: "border-as-stroke h-12 w-12 rounded-full border-2 shadow-md" }) })), _jsx("div", { children: _jsxs("h1", { className: "text-as-primary text-xl font-bold", children: ["Buy ", selectedDstToken.symbol] }) })] })), _jsx(TabSection, { activeTab: activeTab, setActiveTab: setActiveTab, setSelectedCryptoPaymentMethod: setSelectedCryptoPaymentMethod, setSelectedFiatPaymentMethod: setSelectedFiatPaymentMethod }), _jsxs("div", { className: "relative flex w-full max-w-[calc(100vw-32px)] flex-col gap-2", children: [activeTab === "crypto" ? (_jsx(CryptoPaySection, { selectedSrcChainId: selectedSrcChainId, setSelectedSrcChainId: setSelectedSrcChainId, selectedSrcToken: selectedSrcToken, setSelectedSrcToken: setSelectedSrcToken, srcAmount: srcAmount, setSrcAmount: setSrcAmount, setIsSrcInputDirty: setIsSrcInputDirty, selectedCryptoPaymentMethod: selectedCryptoPaymentMethod, onSelectCryptoPaymentMethod: () => setActivePanel(PanelView.CRYPTO_PAYMENT_METHOD), anyspendQuote: anyspendQuote })) : (_jsx(motion.div, { initial: { opacity: 0, y: 20, filter: "blur(10px)" }, animate: { opacity: 1, y: 0, filter: "blur(0px)" }, transition: { duration: 0.3, delay: 0, ease: "easeInOut" }, children: _jsx(PanelOnramp, { srcAmountOnRamp: srcAmountOnRamp, setSrcAmountOnRamp: setSrcAmountOnRamp, selectedPaymentMethod: selectedFiatPaymentMethod, setActivePanel: setActivePanel, _recipientAddress: recipientAddress, destinationToken: selectedDstToken, destinationChainId: selectedDstChainId, destinationAmount: dstAmount, onDestinationTokenChange: setSelectedDstToken, onDestinationChainChange: setSelectedDstChainId, fiatPaymentMethodIndex: PanelView.FIAT_PAYMENT_METHOD, recipientSelectionPanelIndex: PanelView.RECIPIENT_SELECTION, hideDstToken: isBuyMode }) })), _jsx(Button, { variant: "ghost", className: cn("border-as-stroke bg-as-surface-primary absolute left-1/2 top-1/2 z-10 h-10 w-10 -translate-x-1/2 -translate-y-1/2 rounded-xl border-2 sm:h-8 sm:w-8 sm:rounded-xl", isBuyMode && "top-[calc(50%+56px)] cursor-default", activeTab === "fiat" && "hidden"), onClick: () => {
|
|
670
|
+
const mainView = (_jsxs("div", { className: "mx-auto flex w-[460px] max-w-full flex-col items-center gap-2", children: [isBuyMode && (_jsxs("div", { className: "mb-4 flex flex-col items-center gap-3 text-center", children: [selectedDstToken.metadata?.logoURI && (_jsx("div", { className: "relative", children: _jsx("img", { src: selectedDstToken.metadata.logoURI, alt: selectedDstToken.symbol, className: "border-as-stroke h-12 w-12 rounded-full border-2 shadow-md" }) })), _jsx("div", { children: _jsxs("h1", { className: "text-as-primary text-xl font-bold", children: ["Buy ", selectedDstToken.symbol] }) })] })), _jsx(TabSection, { activeTab: activeTab, setActiveTab: setActiveTab, setSelectedCryptoPaymentMethod: setSelectedCryptoPaymentMethod, setSelectedFiatPaymentMethod: setSelectedFiatPaymentMethod }), _jsxs("div", { className: "relative flex w-full max-w-[calc(100vw-32px)] flex-col gap-2", children: [activeTab === "crypto" ? (_jsx(CryptoPaySection, { selectedSrcChainId: selectedSrcChainId, setSelectedSrcChainId: setSelectedSrcChainId, selectedSrcToken: selectedSrcToken, setSelectedSrcToken: setSelectedSrcToken, srcAmount: srcAmount, setSrcAmount: setSrcAmount, setIsSrcInputDirty: setIsSrcInputDirty, selectedCryptoPaymentMethod: selectedCryptoPaymentMethod, onSelectCryptoPaymentMethod: () => setActivePanel(PanelView.CRYPTO_PAYMENT_METHOD), anyspendQuote: anyspendQuote, onTokenSelect: onTokenSelect })) : (_jsx(motion.div, { initial: { opacity: 0, y: 20, filter: "blur(10px)" }, animate: { opacity: 1, y: 0, filter: "blur(0px)" }, transition: { duration: 0.3, delay: 0, ease: "easeInOut" }, children: _jsx(PanelOnramp, { srcAmountOnRamp: srcAmountOnRamp, setSrcAmountOnRamp: setSrcAmountOnRamp, selectedPaymentMethod: selectedFiatPaymentMethod, setActivePanel: setActivePanel, _recipientAddress: recipientAddress, destinationToken: selectedDstToken, destinationChainId: selectedDstChainId, destinationAmount: dstAmount, onDestinationTokenChange: setSelectedDstToken, onDestinationChainChange: setSelectedDstChainId, fiatPaymentMethodIndex: PanelView.FIAT_PAYMENT_METHOD, recipientSelectionPanelIndex: PanelView.RECIPIENT_SELECTION, hideDstToken: isBuyMode, anyspendQuote: anyspendQuote, onShowPointsDetail: () => setActivePanel(PanelView.POINTS_DETAIL) }) })), _jsx(Button, { variant: "ghost", className: cn("border-as-stroke bg-as-surface-primary absolute left-1/2 top-1/2 z-10 h-10 w-10 -translate-x-1/2 -translate-y-1/2 rounded-xl border-2 sm:h-8 sm:w-8 sm:rounded-xl", isBuyMode && "top-[calc(50%+56px)] cursor-default", activeTab === "fiat" && "hidden"), onClick: () => {
|
|
660
671
|
if (activeTab === "fiat" || isBuyMode) {
|
|
661
672
|
return;
|
|
662
673
|
}
|
|
@@ -678,7 +689,7 @@ function AnySpendInner({ destinationTokenAddress, destinationTokenChainId, mode
|
|
|
678
689
|
}, children: _jsx("div", { className: "relative flex items-center justify-center transition-opacity", children: _jsx(ArrowDown, { className: "text-as-primary/50 h-5 w-5" }) }) }), activeTab === "crypto" && (_jsx(CryptoReceiveSection, { isDepositMode: false, isBuyMode: isBuyMode, selectedRecipientAddress: recipientAddress, recipientName: recipientName || undefined, onSelectRecipient: () => setActivePanel(PanelView.RECIPIENT_SELECTION), dstAmount: dstAmount, dstToken: selectedDstToken, selectedDstChainId: selectedDstChainId, setSelectedDstChainId: setSelectedDstChainId, setSelectedDstToken: setSelectedDstToken, onChangeDstAmount: value => {
|
|
679
690
|
setIsSrcInputDirty(false);
|
|
680
691
|
setDstAmount(value);
|
|
681
|
-
}, anyspendQuote: anyspendQuote }))] }), _jsx(ErrorSection, { error: getAnyspendQuoteError }), _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.2, ease: "easeInOut" }, className: cn("mt-4 flex w-full max-w-[460px] flex-col gap-2", getAnyspendQuoteError && "mt-0"), children: [_jsx(ShinyButton, { accentColor: "hsl(var(--as-brand))", disabled: btnInfo.disable, onClick: onMainButtonClick, className: cn("as-main-button relative w-full", btnInfo.error ? "!bg-as-red" : btnInfo.disable ? "!bg-as-on-surface-2" : "!bg-as-brand"), textClassName: cn(btnInfo.error ? "text-white" : btnInfo.disable ? "text-as-secondary" : "text-white"), children: btnInfo.text }), !hideTransactionHistoryButton && (globalAddress || recipientAddress) ? (_jsxs(Button, { variant: "link", onClick: onClickHistory, className: "text-as-primary/50 hover:text-as-primary flex items-center gap-1 transition-colors", children: [_jsx(HistoryIcon, { className: "h-4 w-4" }), " ", _jsx("span", { className: "pr-4", children: "Transaction History" })] })) : null] })] }));
|
|
692
|
+
}, anyspendQuote: anyspendQuote, onShowPointsDetail: () => setActivePanel(PanelView.POINTS_DETAIL) }))] }), _jsx(ErrorSection, { error: getAnyspendQuoteError }), _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.2, ease: "easeInOut" }, className: cn("mt-4 flex w-full max-w-[460px] flex-col gap-2", getAnyspendQuoteError && "mt-0"), children: [_jsx(ShinyButton, { accentColor: "hsl(var(--as-brand))", disabled: btnInfo.disable, onClick: onMainButtonClick, className: cn("as-main-button relative w-full", btnInfo.error ? "!bg-as-red" : btnInfo.disable ? "!bg-as-on-surface-2" : "!bg-as-brand"), textClassName: cn(btnInfo.error ? "text-white" : btnInfo.disable ? "text-as-secondary" : "text-white"), children: btnInfo.text }), !hideTransactionHistoryButton && (globalAddress || recipientAddress) ? (_jsxs(Button, { variant: "link", onClick: onClickHistory, className: "text-as-primary/50 hover:text-as-primary flex items-center gap-1 transition-colors", children: [_jsx(HistoryIcon, { className: "h-4 w-4" }), " ", _jsx("span", { className: "pr-4", children: "Transaction History" })] })) : null] })] }));
|
|
682
693
|
const onrampPaymentView = (_jsx(PanelOnrampPayment, { srcAmountOnRamp: srcAmountOnRamp, recipientName: recipientName || undefined, recipientAddress: recipientAddress, isBuyMode: isBuyMode, destinationTokenChainId: destinationTokenChainId, destinationTokenAddress: destinationTokenAddress, selectedDstChainId: selectedDstChainId, selectedDstToken: selectedDstToken, orderType: "swap", anyspendQuote: anyspendQuote, globalAddress: globalAddress, onOrderCreated: orderId => {
|
|
683
694
|
setOrderId(orderId);
|
|
684
695
|
setActivePanel(PanelView.ORDER_DETAILS);
|
|
@@ -706,6 +717,7 @@ function AnySpendInner({ destinationTokenAddress, destinationTokenChainId, mode
|
|
|
706
717
|
setSelectedFiatPaymentMethod(method);
|
|
707
718
|
setActivePanel(PanelView.MAIN); // Go back to main panel to show updated pricing
|
|
708
719
|
}, srcAmountOnRamp: srcAmountOnRamp }));
|
|
720
|
+
const pointsDetailView = (_jsx(PointsDetailPanel, { pointsAmount: anyspendQuote?.data?.pointsAmount || 0, onBack: () => setActivePanel(PanelView.MAIN) }));
|
|
709
721
|
// Add tabs to the main component when no order is loaded
|
|
710
722
|
return (_jsx(StyleRoot, { children: _jsx("div", { className: cn("anyspend-container font-inter mx-auto w-full max-w-[460px]", mode === "page" &&
|
|
711
723
|
"bg-as-surface-primary border-as-border-secondary overflow-hidden rounded-2xl border shadow-xl"), children: _jsx(TransitionPanel, { activeIndex: orderId
|
|
@@ -729,5 +741,6 @@ function AnySpendInner({ destinationTokenAddress, destinationTokenChainId, mode
|
|
|
729
741
|
_jsx("div", { className: cn(mode === "page" && "p-6"), children: recipientSelectionView }, "recipient-selection-view"),
|
|
730
742
|
_jsx("div", { className: cn(mode === "page" && "p-6"), children: cryptoPaymentMethodView }, "crypto-payment-method-view"),
|
|
731
743
|
_jsx("div", { className: cn(mode === "page" && "p-6"), children: fiatPaymentMethodView }, "fiat-payment-method-view"),
|
|
744
|
+
_jsx("div", { className: cn(mode === "page" && "p-6"), children: pointsDetailView }, "points-detail-view"),
|
|
732
745
|
] }) }) }));
|
|
733
746
|
}
|
|
@@ -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
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { components } from "../../../anyspend/types/api";
|
|
1
2
|
export declare const HYPE_TOKEN_DETAILS: {
|
|
2
3
|
SYMBOL: string;
|
|
3
4
|
LOGO_URI: string;
|
|
@@ -11,5 +12,12 @@ export interface AnySpendDepositHypeProps {
|
|
|
11
12
|
sourceTokenChainId?: number;
|
|
12
13
|
onSuccess?: () => void;
|
|
13
14
|
mainFooter?: React.ReactNode;
|
|
15
|
+
/**
|
|
16
|
+
* Called when a token is selected. Call event.preventDefault() to prevent default token selection behavior.
|
|
17
|
+
* Useful for handling special cases like B3 token selection.
|
|
18
|
+
*/
|
|
19
|
+
onTokenSelect?: (token: components["schemas"]["Token"], event: {
|
|
20
|
+
preventDefault: () => void;
|
|
21
|
+
}) => void;
|
|
14
22
|
}
|
|
15
23
|
export declare function AnySpendDepositHype(props: AnySpendDepositHypeProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -15,6 +15,7 @@ import { CryptoReceiveSection } from "./common/CryptoReceiveSection.js";
|
|
|
15
15
|
import { ErrorSection } from "./common/ErrorSection.js";
|
|
16
16
|
import { FiatPaymentMethod, FiatPaymentMethodComponent } from "./common/FiatPaymentMethod.js";
|
|
17
17
|
import { OrderDetails } from "./common/OrderDetails.js";
|
|
18
|
+
import { PointsDetailPanel } from "./common/PointsDetailPanel.js";
|
|
18
19
|
import { RecipientSelection } from "./common/RecipientSelection.js";
|
|
19
20
|
import { ArrowDown } from "lucide-react";
|
|
20
21
|
import { PanelOnramp } from "./common/PanelOnramp.js";
|
|
@@ -27,7 +28,7 @@ export function AnySpendDepositHype(props) {
|
|
|
27
28
|
const fingerprintConfig = getFingerprintConfig();
|
|
28
29
|
return (_jsx(AnySpendFingerprintWrapper, { fingerprint: fingerprintConfig, children: _jsx(AnySpendDepositHypeInner, { ...props }) }));
|
|
29
30
|
}
|
|
30
|
-
function AnySpendDepositHypeInner({ loadOrder, mode = "modal", recipientAddress, paymentType = "crypto", sourceTokenAddress, sourceTokenChainId, onSuccess, mainFooter, }) {
|
|
31
|
+
function AnySpendDepositHypeInner({ loadOrder, mode = "modal", recipientAddress, paymentType = "crypto", sourceTokenAddress, sourceTokenChainId, onSuccess, mainFooter, onTokenSelect, }) {
|
|
31
32
|
// Use shared flow hook
|
|
32
33
|
const { activePanel, setActivePanel, orderId, setOrderId, oat, selectedSrcChainId, setSelectedSrcChainId, selectedSrcToken, setSelectedSrcToken, srcAmount, setSrcAmount, dstAmount, setIsSrcInputDirty, selectedCryptoPaymentMethod, setSelectedCryptoPaymentMethod, selectedFiatPaymentMethod, setSelectedFiatPaymentMethod, selectedRecipientAddress, setSelectedRecipientAddress, recipientName, globalAddress, anyspendQuote, isLoadingAnyspendQuote, getAnyspendQuoteError, activeInputAmountInWei, geoData, coinbaseAvailablePaymentMethods, stripeWeb2Support, createOrder, isCreatingOrder, createOnrampOrder, isCreatingOnrampOrder, } = useAnyspendFlow({
|
|
33
34
|
paymentType,
|
|
@@ -111,10 +112,10 @@ function AnySpendDepositHypeInner({ loadOrder, mode = "modal", recipientAddress,
|
|
|
111
112
|
await handleFiatOrder();
|
|
112
113
|
}
|
|
113
114
|
};
|
|
114
|
-
const mainView = (_jsxs("div", { className: "mx-auto flex w-[460px] max-w-full flex-col items-center gap-2", children: [_jsx("div", { className: "mb-4 flex flex-col items-center gap-3 text-center", children: _jsx("div", { children: _jsx("h1", { className: "text-as-primary text-xl font-bold", children: paymentType === "crypto" ? "Deposit Crypto" : "Fund with Fiat" }) }) }), _jsx("div", { className: "relative flex w-full max-w-[calc(100vw-32px)] flex-col gap-2", children: _jsxs("div", { className: "relative flex w-full max-w-[calc(100vw-32px)] flex-col gap-2", children: [paymentType === "crypto" ? (_jsx(CryptoPaySection, { selectedSrcChainId: selectedSrcChainId, setSelectedSrcChainId: setSelectedSrcChainId, selectedSrcToken: selectedSrcToken, setSelectedSrcToken: setSelectedSrcToken, srcAmount: srcAmount, setSrcAmount: setSrcAmount, setIsSrcInputDirty: setIsSrcInputDirty, selectedCryptoPaymentMethod: selectedCryptoPaymentMethod, onSelectCryptoPaymentMethod: () => setActivePanel(PanelView.CRYPTO_PAYMENT_METHOD), anyspendQuote: anyspendQuote })) : (_jsx(motion.div, { initial: { opacity: 0, y: 20, filter: "blur(10px)" }, animate: { opacity: 1, y: 0, filter: "blur(0px)" }, transition: { duration: 0.3, delay: 0, ease: "easeInOut" }, children: _jsx(PanelOnramp, { srcAmountOnRamp: srcAmount, setSrcAmountOnRamp: setSrcAmount, selectedPaymentMethod: selectedFiatPaymentMethod, setActivePanel: setActivePanel, _recipientAddress: recipientAddress, destinationToken: B3_TOKEN, destinationChainId: base.id, dstTokenSymbol: HYPE_TOKEN_DETAILS.SYMBOL, hideDstToken: true, destinationAmount: dstAmount, onDestinationTokenChange: () => { }, onDestinationChainChange: () => { }, fiatPaymentMethodIndex: PanelView.FIAT_PAYMENT_METHOD, recipientSelectionPanelIndex: PanelView.RECIPIENT_SELECTION }) })), _jsx("div", { className: cn("relative -my-1 flex h-0 items-center justify-center", paymentType === "fiat" && "hidden"), children: _jsx(Button, { variant: "ghost", className: cn("swap-direction-button border-as-stroke bg-as-surface-primary z-10 h-10 w-10 cursor-default rounded-xl border-2 sm:h-8 sm:w-8 sm:rounded-xl"), children: _jsx("div", { className: "relative flex items-center justify-center transition-opacity", children: _jsx(ArrowDown, { className: "text-as-primary/50 h-5 w-5" }) }) }) }), paymentType === "crypto" && (_jsx(CryptoReceiveSection, { isDepositMode: false, isBuyMode: true, selectedRecipientAddress: recipientAddress, recipientName: recipientName || undefined, onSelectRecipient: () => setActivePanel(PanelView.RECIPIENT_SELECTION), dstAmount: dstAmount, dstToken: B3_TOKEN, dstTokenSymbol: HYPE_TOKEN_DETAILS.SYMBOL, dstTokenLogoURI: HYPE_TOKEN_DETAILS.LOGO_URI, selectedDstChainId: base.id, setSelectedDstChainId: () => { }, setSelectedDstToken: () => { }, onChangeDstAmount: value => {
|
|
115
|
+
const mainView = (_jsxs("div", { className: "mx-auto flex w-[460px] max-w-full flex-col items-center gap-2", children: [_jsx("div", { className: "mb-4 flex flex-col items-center gap-3 text-center", children: _jsx("div", { children: _jsx("h1", { className: "text-as-primary text-xl font-bold", children: paymentType === "crypto" ? "Deposit Crypto" : "Fund with Fiat" }) }) }), _jsx("div", { className: "relative flex w-full max-w-[calc(100vw-32px)] flex-col gap-2", children: _jsxs("div", { className: "relative flex w-full max-w-[calc(100vw-32px)] flex-col gap-2", children: [paymentType === "crypto" ? (_jsx(CryptoPaySection, { selectedSrcChainId: selectedSrcChainId, setSelectedSrcChainId: setSelectedSrcChainId, selectedSrcToken: selectedSrcToken, setSelectedSrcToken: setSelectedSrcToken, srcAmount: srcAmount, setSrcAmount: setSrcAmount, setIsSrcInputDirty: setIsSrcInputDirty, selectedCryptoPaymentMethod: selectedCryptoPaymentMethod, onSelectCryptoPaymentMethod: () => setActivePanel(PanelView.CRYPTO_PAYMENT_METHOD), anyspendQuote: anyspendQuote, onTokenSelect: onTokenSelect })) : (_jsx(motion.div, { initial: { opacity: 0, y: 20, filter: "blur(10px)" }, animate: { opacity: 1, y: 0, filter: "blur(0px)" }, transition: { duration: 0.3, delay: 0, ease: "easeInOut" }, children: _jsx(PanelOnramp, { srcAmountOnRamp: srcAmount, setSrcAmountOnRamp: setSrcAmount, selectedPaymentMethod: selectedFiatPaymentMethod, setActivePanel: setActivePanel, _recipientAddress: recipientAddress, destinationToken: B3_TOKEN, destinationChainId: base.id, dstTokenSymbol: HYPE_TOKEN_DETAILS.SYMBOL, hideDstToken: true, destinationAmount: dstAmount, onDestinationTokenChange: () => { }, onDestinationChainChange: () => { }, fiatPaymentMethodIndex: PanelView.FIAT_PAYMENT_METHOD, recipientSelectionPanelIndex: PanelView.RECIPIENT_SELECTION, anyspendQuote: anyspendQuote, onShowPointsDetail: () => setActivePanel(PanelView.POINTS_DETAIL) }) })), _jsx("div", { className: cn("relative -my-1 flex h-0 items-center justify-center", paymentType === "fiat" && "hidden"), children: _jsx(Button, { variant: "ghost", className: cn("swap-direction-button border-as-stroke bg-as-surface-primary z-10 h-10 w-10 cursor-default rounded-xl border-2 sm:h-8 sm:w-8 sm:rounded-xl"), children: _jsx("div", { className: "relative flex items-center justify-center transition-opacity", children: _jsx(ArrowDown, { className: "text-as-primary/50 h-5 w-5" }) }) }) }), paymentType === "crypto" && (_jsx(CryptoReceiveSection, { isDepositMode: false, isBuyMode: true, selectedRecipientAddress: recipientAddress, recipientName: recipientName || undefined, onSelectRecipient: () => setActivePanel(PanelView.RECIPIENT_SELECTION), dstAmount: dstAmount, dstToken: B3_TOKEN, dstTokenSymbol: HYPE_TOKEN_DETAILS.SYMBOL, dstTokenLogoURI: HYPE_TOKEN_DETAILS.LOGO_URI, selectedDstChainId: base.id, setSelectedDstChainId: () => { }, setSelectedDstToken: () => { }, onChangeDstAmount: value => {
|
|
115
116
|
setIsSrcInputDirty(false);
|
|
116
117
|
setSrcAmount(value);
|
|
117
|
-
}, anyspendQuote: anyspendQuote }))] }) }), _jsx(ErrorSection, { error: getAnyspendQuoteError }), _jsx(motion.div, { initial: { opacity: 0, y: 20, filter: "blur(10px)" }, animate: { opacity: 1, y: 0, filter: "blur(0px)" }, transition: { duration: 0.3, delay: 0.2, ease: "easeInOut" }, className: cn("mt-4 flex w-full max-w-[460px] flex-col gap-2", getAnyspendQuoteError && "mt-0"), children: _jsx(ShinyButton, { accentColor: "hsl(var(--as-brand))", disabled: btnInfo.disable, onClick: onMainButtonClick, className: cn("as-main-button relative w-full", btnInfo.error ? "!bg-as-red" : btnInfo.disable ? "!bg-as-on-surface-2" : "!bg-as-brand"), textClassName: cn(btnInfo.error ? "text-white" : btnInfo.disable ? "text-as-secondary" : "text-white"), children: btnInfo.text }) }), mainFooter ? mainFooter : null] }));
|
|
118
|
+
}, anyspendQuote: anyspendQuote, onShowPointsDetail: () => setActivePanel(PanelView.POINTS_DETAIL) }))] }) }), _jsx(ErrorSection, { error: getAnyspendQuoteError }), _jsx(motion.div, { initial: { opacity: 0, y: 20, filter: "blur(10px)" }, animate: { opacity: 1, y: 0, filter: "blur(0px)" }, transition: { duration: 0.3, delay: 0.2, ease: "easeInOut" }, className: cn("mt-4 flex w-full max-w-[460px] flex-col gap-2", getAnyspendQuoteError && "mt-0"), children: _jsx(ShinyButton, { accentColor: "hsl(var(--as-brand))", disabled: btnInfo.disable, onClick: onMainButtonClick, className: cn("as-main-button relative w-full", btnInfo.error ? "!bg-as-red" : btnInfo.disable ? "!bg-as-on-surface-2" : "!bg-as-brand"), textClassName: cn(btnInfo.error ? "text-white" : btnInfo.disable ? "text-as-secondary" : "text-white"), children: btnInfo.text }) }), mainFooter ? mainFooter : null] }));
|
|
118
119
|
// Handle crypto order creation
|
|
119
120
|
const handleCryptoOrder = async () => {
|
|
120
121
|
try {
|
|
@@ -211,6 +212,7 @@ function AnySpendDepositHypeInner({ loadOrder, mode = "modal", recipientAddress,
|
|
|
211
212
|
setSelectedFiatPaymentMethod(method);
|
|
212
213
|
setActivePanel(PanelView.MAIN);
|
|
213
214
|
}, srcAmountOnRamp: srcAmount }));
|
|
215
|
+
const pointsDetailView = (_jsx(PointsDetailPanel, { pointsAmount: anyspendQuote?.data?.pointsAmount || 0, onBack: () => setActivePanel(PanelView.MAIN) }));
|
|
214
216
|
// If showing token selection, render with panel transitions
|
|
215
217
|
return (_jsx(StyleRoot, { children: _jsx("div", { className: cn("anyspend-container font-inter mx-auto w-full max-w-[460px]", mode === "page" &&
|
|
216
218
|
"bg-as-surface-primary border-as-border-secondary overflow-hidden rounded-2xl border shadow-xl"), children: _jsx(TransitionPanel, { activeIndex: orderId
|
|
@@ -232,5 +234,6 @@ function AnySpendDepositHypeInner({ loadOrder, mode = "modal", recipientAddress,
|
|
|
232
234
|
_jsx("div", { className: cn(mode === "page" && "p-6"), children: recipientSelectionView }, "recipient-selection-view"),
|
|
233
235
|
_jsx("div", { className: cn(mode === "page" && "p-6"), children: orderDetailsView }, "order-details-view"),
|
|
234
236
|
_jsx("div", { className: cn(mode === "page" && "p-6"), children: loadingView }, "loading-view"),
|
|
237
|
+
_jsx("div", { className: cn(mode === "page" && "p-6"), children: pointsDetailView }, "points-detail-view"),
|
|
235
238
|
] }) }) }));
|
|
236
239
|
}
|
|
@@ -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
|
}
|