@b3dotfun/sdk 0.0.28 → 0.0.29-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/anyspend/abis/escrow.d.ts +987 -0
- package/dist/cjs/anyspend/abis/escrow.js +1275 -0
- package/dist/cjs/anyspend/react/components/AnySpend.js +10 -168
- package/dist/cjs/anyspend/react/components/AnySpendBondKit.d.ts +1 -1
- package/dist/cjs/anyspend/react/components/AnySpendBondKit.js +23 -24
- package/dist/cjs/anyspend/react/components/AnySpendCustom.js +2 -2
- package/dist/cjs/anyspend/react/components/AnyspendDepositHype.d.ts +10 -0
- package/dist/cjs/anyspend/react/components/AnyspendDepositHype.js +263 -0
- package/dist/cjs/anyspend/react/components/common/CryptoReceiveSection.d.ts +17 -0
- package/dist/cjs/anyspend/react/components/common/CryptoReceiveSection.js +53 -0
- package/dist/cjs/anyspend/react/components/common/ErrorSection.d.ts +6 -0
- package/dist/cjs/anyspend/react/components/common/ErrorSection.js +12 -0
- package/dist/cjs/anyspend/react/components/common/PanelOnramp.d.ts +2 -1
- package/dist/cjs/anyspend/react/components/common/PanelOnramp.js +2 -2
- package/dist/cjs/anyspend/react/components/common/PaySection.d.ts +20 -0
- package/dist/cjs/anyspend/react/components/common/PaySection.js +58 -0
- package/dist/cjs/anyspend/react/components/common/TabSection.d.ts +10 -0
- package/dist/cjs/anyspend/react/components/common/TabSection.js +18 -0
- package/dist/cjs/anyspend/react/components/index.d.ts +2 -0
- package/dist/cjs/anyspend/react/components/index.js +5 -1
- package/dist/cjs/anyspend/react/hooks/useAnyspendFlow.d.ts +165 -0
- package/dist/cjs/anyspend/react/hooks/useAnyspendFlow.js +184 -0
- package/dist/cjs/anyspend/react/hooks/useSigMint.d.ts +2 -2
- package/dist/cjs/bondkit/abis/BondkitTokenABI.d.ts +2 -5
- package/dist/cjs/bondkit/abis/BondkitTokenABI.js +2 -3
- package/dist/cjs/global-account/react/components/B3DynamicModal.js +3 -0
- package/dist/cjs/global-account/react/components/custom/Button.d.ts +1 -1
- package/dist/cjs/global-account/react/components/ui/button.d.ts +1 -1
- package/dist/cjs/global-account/react/components/ui/command.d.ts +2 -2
- package/dist/cjs/global-account/react/hooks/useSiwe.native.d.ts +4 -0
- package/dist/cjs/global-account/react/hooks/useSiwe.native.js +40 -0
- package/dist/cjs/global-account/react/stores/useModalStore.d.ts +19 -3
- package/dist/cjs/shared/constants/chains/b3Chain.d.ts +1 -1
- package/dist/cjs/shared/constants/chains/supported.d.ts +3 -3
- package/dist/esm/anyspend/abis/escrow.d.ts +987 -0
- package/dist/esm/anyspend/abis/escrow.js +1272 -0
- package/dist/esm/anyspend/react/components/AnySpend.js +12 -170
- package/dist/esm/anyspend/react/components/AnySpendBondKit.d.ts +1 -1
- package/dist/esm/anyspend/react/components/AnySpendBondKit.js +23 -24
- package/dist/esm/anyspend/react/components/AnySpendCustom.js +3 -3
- package/dist/esm/anyspend/react/components/AnyspendDepositHype.d.ts +10 -0
- package/dist/esm/anyspend/react/components/AnyspendDepositHype.js +257 -0
- package/dist/esm/anyspend/react/components/common/CryptoReceiveSection.d.ts +17 -0
- package/dist/esm/anyspend/react/components/common/CryptoReceiveSection.js +50 -0
- package/dist/esm/anyspend/react/components/common/ErrorSection.d.ts +6 -0
- package/dist/esm/anyspend/react/components/common/ErrorSection.js +9 -0
- package/dist/esm/anyspend/react/components/common/PanelOnramp.d.ts +2 -1
- package/dist/esm/anyspend/react/components/common/PanelOnramp.js +2 -2
- package/dist/esm/anyspend/react/components/common/PaySection.d.ts +20 -0
- package/dist/esm/anyspend/react/components/common/PaySection.js +55 -0
- package/dist/esm/anyspend/react/components/common/TabSection.d.ts +10 -0
- package/dist/esm/anyspend/react/components/common/TabSection.js +15 -0
- package/dist/esm/anyspend/react/components/index.d.ts +2 -0
- package/dist/esm/anyspend/react/components/index.js +2 -0
- package/dist/esm/anyspend/react/hooks/useAnyspendFlow.d.ts +165 -0
- package/dist/esm/anyspend/react/hooks/useAnyspendFlow.js +180 -0
- package/dist/esm/anyspend/react/hooks/useSigMint.d.ts +2 -2
- package/dist/esm/bondkit/abis/BondkitTokenABI.d.ts +2 -5
- package/dist/esm/bondkit/abis/BondkitTokenABI.js +2 -3
- package/dist/esm/global-account/react/components/B3DynamicModal.js +3 -0
- package/dist/esm/global-account/react/components/custom/Button.d.ts +1 -1
- package/dist/esm/global-account/react/components/ui/button.d.ts +1 -1
- package/dist/esm/global-account/react/components/ui/command.d.ts +2 -2
- package/dist/esm/global-account/react/hooks/useSiwe.native.d.ts +4 -0
- package/dist/esm/global-account/react/hooks/useSiwe.native.js +34 -0
- package/dist/esm/global-account/react/stores/useModalStore.d.ts +19 -3
- package/dist/esm/shared/constants/chains/b3Chain.d.ts +1 -1
- package/dist/esm/shared/constants/chains/supported.d.ts +3 -3
- package/dist/styles/index.css +1 -1
- package/dist/types/anyspend/abis/escrow.d.ts +987 -0
- package/dist/types/anyspend/react/components/AnySpendBondKit.d.ts +1 -1
- package/dist/types/anyspend/react/components/AnyspendDepositHype.d.ts +10 -0
- package/dist/types/anyspend/react/components/common/CryptoReceiveSection.d.ts +17 -0
- package/dist/types/anyspend/react/components/common/ErrorSection.d.ts +6 -0
- package/dist/types/anyspend/react/components/common/PanelOnramp.d.ts +2 -1
- package/dist/types/anyspend/react/components/common/PaySection.d.ts +20 -0
- package/dist/types/anyspend/react/components/common/TabSection.d.ts +10 -0
- package/dist/types/anyspend/react/components/index.d.ts +2 -0
- package/dist/types/anyspend/react/hooks/useAnyspendFlow.d.ts +165 -0
- package/dist/types/anyspend/react/hooks/useSigMint.d.ts +2 -2
- package/dist/types/bondkit/abis/BondkitTokenABI.d.ts +2 -5
- package/dist/types/global-account/react/components/custom/Button.d.ts +1 -1
- package/dist/types/global-account/react/components/ui/button.d.ts +1 -1
- package/dist/types/global-account/react/components/ui/command.d.ts +2 -2
- package/dist/types/global-account/react/hooks/useSiwe.native.d.ts +4 -0
- package/dist/types/global-account/react/stores/useModalStore.d.ts +19 -3
- package/dist/types/shared/constants/chains/b3Chain.d.ts +1 -1
- package/dist/types/shared/constants/chains/supported.d.ts +3 -3
- package/package.json +13 -1
- package/src/anyspend/abis/escrow.ts +1272 -0
- package/src/anyspend/react/components/AnySpend.tsx +48 -389
- package/src/anyspend/react/components/AnySpendBondKit.tsx +28 -28
- package/src/anyspend/react/components/AnySpendCustom.tsx +2 -10
- package/src/anyspend/react/components/AnyspendDepositHype.tsx +525 -0
- package/src/anyspend/react/components/common/CryptoReceiveSection.tsx +152 -0
- package/src/anyspend/react/components/common/ErrorSection.tsx +21 -0
- package/src/anyspend/react/components/common/PanelOnramp.tsx +4 -2
- package/src/anyspend/react/components/common/PaySection.tsx +222 -0
- package/src/anyspend/react/components/common/TabSection.tsx +58 -0
- package/src/anyspend/react/components/index.ts +2 -0
- package/src/anyspend/react/hooks/useAnyspendFlow.ts +226 -0
- package/src/bondkit/abis/BondkitTokenABI.ts +2 -3
- package/src/global-account/react/components/B3DynamicModal.tsx +3 -0
- package/src/global-account/react/hooks/useSiwe.native.tsx +40 -0
- package/src/global-account/react/stores/useModalStore.ts +21 -3
- package/dist/cjs/anyspend/abis/bondKit.d.ts +0 -35
- package/dist/cjs/anyspend/abis/bondKit.js +0 -29
- package/dist/esm/anyspend/abis/bondKit.d.ts +0 -35
- package/dist/esm/anyspend/abis/bondKit.js +0 -26
- package/dist/types/anyspend/abis/bondKit.d.ts +0 -35
- package/src/anyspend/abis/bondKit.ts +0 -26
|
@@ -10,9 +10,7 @@ const jsx_runtime_1 = require("react/jsx-runtime");
|
|
|
10
10
|
const anyspend_1 = require("../../../anyspend");
|
|
11
11
|
const react_1 = require("../../../anyspend/react");
|
|
12
12
|
const react_2 = require("../../../global-account/react");
|
|
13
|
-
const utils_1 = require("../../../shared/utils");
|
|
14
13
|
const cn_1 = require("../../../shared/utils/cn");
|
|
15
|
-
const formatAddress_1 = require("../../../shared/utils/formatAddress");
|
|
16
14
|
const number_1 = require("../../../shared/utils/number");
|
|
17
15
|
const invariant_1 = __importDefault(require("invariant"));
|
|
18
16
|
const lucide_react_1 = require("lucide-react");
|
|
@@ -23,15 +21,17 @@ const viem_1 = require("viem");
|
|
|
23
21
|
const chains_1 = require("viem/chains");
|
|
24
22
|
const AnySpendFingerprintWrapper_1 = require("./AnySpendFingerprintWrapper");
|
|
25
23
|
const CryptoPaymentMethod_1 = require("./common/CryptoPaymentMethod");
|
|
24
|
+
const CryptoReceiveSection_1 = require("./common/CryptoReceiveSection");
|
|
25
|
+
const ErrorSection_1 = require("./common/ErrorSection");
|
|
26
26
|
const FiatPaymentMethod_1 = require("./common/FiatPaymentMethod");
|
|
27
27
|
const OrderDetails_1 = require("./common/OrderDetails");
|
|
28
28
|
const OrderHistory_1 = require("./common/OrderHistory");
|
|
29
29
|
const OrderStatus_1 = require("./common/OrderStatus");
|
|
30
|
-
const OrderTokenAmount_1 = require("./common/OrderTokenAmount");
|
|
31
30
|
const PanelOnramp_1 = require("./common/PanelOnramp");
|
|
32
31
|
const PanelOnrampPayment_1 = require("./common/PanelOnrampPayment");
|
|
32
|
+
const PaySection_1 = require("./common/PaySection");
|
|
33
33
|
const RecipientSelection_1 = require("./common/RecipientSelection");
|
|
34
|
-
const
|
|
34
|
+
const TabSection_1 = require("./common/TabSection");
|
|
35
35
|
var PanelView;
|
|
36
36
|
(function (PanelView) {
|
|
37
37
|
PanelView[PanelView["MAIN"] = 0] = "MAIN";
|
|
@@ -291,8 +291,7 @@ function AnySpendInner({ destinationTokenAddress, destinationTokenChainId, mode
|
|
|
291
291
|
// );
|
|
292
292
|
// State for recipient selection
|
|
293
293
|
const [recipientAddress, setRecipientAddress] = (0, react_4.useState)();
|
|
294
|
-
const { address: globalAddress, wallet: globalWallet
|
|
295
|
-
const connectedAddress = globalWallet?.address;
|
|
294
|
+
const { address: globalAddress, wallet: globalWallet } = (0, react_2.useAccountWallet)();
|
|
296
295
|
const recipientProfile = (0, react_2.useProfile)({ address: recipientAddress, fresh: true });
|
|
297
296
|
const recipientName = recipientProfile.data?.name;
|
|
298
297
|
// Set default recipient address when wallet changes
|
|
@@ -364,113 +363,6 @@ function AnySpendInner({ destinationTokenAddress, destinationTokenChainId, mode
|
|
|
364
363
|
}
|
|
365
364
|
// Only run this effect once on mount
|
|
366
365
|
}, [globalAddress, recipientAddress, customRecipients.length]);
|
|
367
|
-
// Available recipient options
|
|
368
|
-
// const recipientOptions = useMemo<RecipientOption[]>(() => {
|
|
369
|
-
// const options: RecipientOption[] = [];
|
|
370
|
-
// // Add current wallet if connected
|
|
371
|
-
// if (globalAddress) {
|
|
372
|
-
// options.push({
|
|
373
|
-
// address: globalAddress,
|
|
374
|
-
// icon: "https://gradvatar.com/" + globalAddress,
|
|
375
|
-
// label: "Current Wallet",
|
|
376
|
-
// ensName: walletName
|
|
377
|
-
// });
|
|
378
|
-
// }
|
|
379
|
-
// // Add custom recipients with their onchain names
|
|
380
|
-
// customRecipients.forEach((recipient, index) => {
|
|
381
|
-
// options.push({
|
|
382
|
-
// ...recipient,
|
|
383
|
-
// ensName: customRecipientNames[index] || undefined
|
|
384
|
-
// });
|
|
385
|
-
// });
|
|
386
|
-
// // Add current recipientAddress if it exists and isn't already in options
|
|
387
|
-
// if (
|
|
388
|
-
// recipientAddress &&
|
|
389
|
-
// !options.some(opt => normalizeAddress(opt.address) === normalizeAddress(recipientAddress))
|
|
390
|
-
// ) {
|
|
391
|
-
// options.push({
|
|
392
|
-
// address: recipientAddress,
|
|
393
|
-
// label: `Custom (${centerTruncate(recipientAddress, 6)})`,
|
|
394
|
-
// ensName: recipientName
|
|
395
|
-
// });
|
|
396
|
-
// }
|
|
397
|
-
// return options;
|
|
398
|
-
// }, [globalAddress, customRecipients, recipientAddress, recipientName, walletName, customRecipientNames]);
|
|
399
|
-
// const handleCreateOrder = async (recipientAddress: string) => {
|
|
400
|
-
// try {
|
|
401
|
-
// invariant(anyspendPrice, "Relay price is not found");
|
|
402
|
-
// const srcAmountBigInt = parseUnits(srcAmount.replace(/,/g, ""), selectedSrcToken.decimals);
|
|
403
|
-
// createOrder({
|
|
404
|
-
// recipientAddress,
|
|
405
|
-
// orderType: "swap",
|
|
406
|
-
// srcChain: selectedSrcChainId,
|
|
407
|
-
// dstChain: selectedDstChainId,
|
|
408
|
-
// srcToken: selectedSrcToken,
|
|
409
|
-
// dstToken: selectedDstToken,
|
|
410
|
-
// srcAmount: srcAmountBigInt.toString(),
|
|
411
|
-
// expectedDstAmount: anyspendPrice?.data?.currencyOut?.amount || "0"
|
|
412
|
-
// });
|
|
413
|
-
// } catch (err) {
|
|
414
|
-
// console.error(err);
|
|
415
|
-
// toast.error((err as Error).message);
|
|
416
|
-
// throw err; // Re-throw to handle in the calling function
|
|
417
|
-
// }
|
|
418
|
-
// };
|
|
419
|
-
// const handleSaveRecipient = async () => {
|
|
420
|
-
// if (!newRecipientAddress) {
|
|
421
|
-
// toast.error("Please enter an address");
|
|
422
|
-
// recipientInputRef.current?.focus();
|
|
423
|
-
// return;
|
|
424
|
-
// }
|
|
425
|
-
// let normalizedAddress: string;
|
|
426
|
-
// try {
|
|
427
|
-
// // Handle ENS name
|
|
428
|
-
// if (
|
|
429
|
-
// newRecipientAddress.toLowerCase().endsWith(".eth") ||
|
|
430
|
-
// newRecipientAddress.startsWith("@") ||
|
|
431
|
-
// newRecipientAddress.includes(".b3")
|
|
432
|
-
// ) {
|
|
433
|
-
// if (!resolvedAddress) {
|
|
434
|
-
// toast.error("Could not resolve ENS name");
|
|
435
|
-
// return;
|
|
436
|
-
// }
|
|
437
|
-
// normalizedAddress = getAddress(resolvedAddress);
|
|
438
|
-
// }
|
|
439
|
-
// // Handle regular address
|
|
440
|
-
// else {
|
|
441
|
-
// if (!isEvmOrSolanaAddress(newRecipientAddress)) {
|
|
442
|
-
// toast.error("Please enter a valid address or ENS name");
|
|
443
|
-
// recipientInputRef.current?.focus();
|
|
444
|
-
// return;
|
|
445
|
-
// }
|
|
446
|
-
// normalizedAddress = normalizeAddress(newRecipientAddress);
|
|
447
|
-
// }
|
|
448
|
-
// // Check for duplicate address
|
|
449
|
-
// if (!customRecipients.some(r => normalizeAddress(r.address) === normalizedAddress)) {
|
|
450
|
-
// // Add to custom recipients
|
|
451
|
-
// const newRecipient = {
|
|
452
|
-
// address: normalizedAddress,
|
|
453
|
-
// label:
|
|
454
|
-
// newRecipientAddress.toLowerCase().endsWith(".eth") ||
|
|
455
|
-
// newRecipientAddress.startsWith("@") ||
|
|
456
|
-
// newRecipientAddress.includes(".b3")
|
|
457
|
-
// ? newRecipientAddress // Keep ENS name as label
|
|
458
|
-
// : `Custom (${centerTruncate(normalizedAddress, 6)})`
|
|
459
|
-
// };
|
|
460
|
-
// setCustomRecipients(prev => [...prev, newRecipient]);
|
|
461
|
-
// }
|
|
462
|
-
// setRecipientAddress(normalizedAddress);
|
|
463
|
-
// // Handle based on login state
|
|
464
|
-
// if (!globalAddress) {
|
|
465
|
-
// await handleCreateOrder(normalizedAddress);
|
|
466
|
-
// } else {
|
|
467
|
-
// setActivePanel(PanelView.MAIN);
|
|
468
|
-
// }
|
|
469
|
-
// } catch (err) {
|
|
470
|
-
// // Error handling is done in handleCreateOrder
|
|
471
|
-
// console.error("Error in handleSaveRecipient:", err);
|
|
472
|
-
// }
|
|
473
|
-
// };
|
|
474
366
|
// Update dependent amount when relay price changes
|
|
475
367
|
(0, react_4.useEffect)(() => {
|
|
476
368
|
if (anyspendQuote?.data &&
|
|
@@ -764,49 +656,13 @@ function AnySpendInner({ destinationTokenAddress, destinationTokenChainId, mode
|
|
|
764
656
|
(0, react_4.useEffect)(() => {
|
|
765
657
|
window.scrollTo({ top: 0, behavior: "smooth" });
|
|
766
658
|
}, [activePanel]);
|
|
767
|
-
const calculatePriceImpact = (inputUsd, outputUsd) => {
|
|
768
|
-
if (!inputUsd || !outputUsd) {
|
|
769
|
-
return { percentage: "0.00", isNegative: false };
|
|
770
|
-
}
|
|
771
|
-
const input = Number(inputUsd);
|
|
772
|
-
const output = Number(outputUsd);
|
|
773
|
-
// Handle edge cases
|
|
774
|
-
if (input === 0 || isNaN(input) || isNaN(output) || input <= output) {
|
|
775
|
-
return { percentage: "0.00", isNegative: false };
|
|
776
|
-
}
|
|
777
|
-
const percentageValue = ((output - input) / input) * 100;
|
|
778
|
-
// Handle the -0.00% case
|
|
779
|
-
if (percentageValue > -0.005 && percentageValue < 0) {
|
|
780
|
-
return { percentage: "0.00", isNegative: false };
|
|
781
|
-
}
|
|
782
|
-
return {
|
|
783
|
-
percentage: Math.abs(percentageValue).toFixed(2),
|
|
784
|
-
isNegative: percentageValue < 0,
|
|
785
|
-
};
|
|
786
|
-
};
|
|
787
|
-
// Add state for rate details toggle
|
|
788
|
-
// const [showRateDetails, setShowRateDetails] = useState(false);
|
|
789
659
|
const historyView = ((0, jsx_runtime_1.jsx)("div", { className: "mx-auto flex w-[560px] max-w-full flex-col items-center", children: (0, jsx_runtime_1.jsx)(OrderHistory_1.OrderHistory, { mode: mode, onBack: () => setActivePanel(PanelView.MAIN), onSelectOrder: onSelectOrder }) }));
|
|
790
660
|
const orderDetailsView = ((0, jsx_runtime_1.jsx)("div", { className: "mx-auto w-[460px] max-w-full", children: (0, jsx_runtime_1.jsx)("div", { className: "relative flex flex-col gap-4", children: oat && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(OrderStatus_1.OrderStatus, { order: oat.data.order }), (0, jsx_runtime_1.jsx)(OrderDetails_1.OrderDetails, { mode: mode, order: oat.data.order, depositTxs: oat.data.depositTxs, relayTx: oat.data.relayTx, executeTx: oat.data.executeTx, refundTxs: oat.data.refundTxs, onBack: () => {
|
|
791
661
|
setOrderId(undefined);
|
|
792
662
|
setActivePanel(PanelView.MAIN);
|
|
793
663
|
setSelectedCryptoPaymentMethod(CryptoPaymentMethod_1.CryptoPaymentMethodType.NONE); // Reset payment method when going back
|
|
794
664
|
} })] })) }) }));
|
|
795
|
-
const mainView = ((0, jsx_runtime_1.jsxs)("div", { className: "mx-auto flex w-[460px] max-w-full flex-col items-center gap-2", children: [isBuyMode && ((0, jsx_runtime_1.jsxs)("div", { className: "mb-4 flex flex-col items-center gap-3 text-center", children: [selectedDstToken.metadata?.logoURI && ((0, jsx_runtime_1.jsx)("div", { className: "relative", children: (0, jsx_runtime_1.jsx)("img", { src: selectedDstToken.metadata.logoURI, alt: selectedDstToken.symbol, className: "border-as-stroke h-12 w-12 rounded-full border-2 shadow-md" }) })), (0, jsx_runtime_1.jsx)("div", { children: (0, jsx_runtime_1.jsxs)("h1", { className: "text-as-primary text-xl font-bold", children: ["Buy ", selectedDstToken.symbol] }) })] })), (0, jsx_runtime_1.jsx)(
|
|
796
|
-
setActiveTab("crypto");
|
|
797
|
-
setSelectedCryptoPaymentMethod(CryptoPaymentMethod_1.CryptoPaymentMethodType.NONE); // Reset payment method when switching to crypto
|
|
798
|
-
setSelectedFiatPaymentMethod(FiatPaymentMethod_1.FiatPaymentMethod.NONE); // Reset fiat payment method when switching to crypto
|
|
799
|
-
}, children: "Pay with crypto" }), (0, jsx_runtime_1.jsx)("button", { className: (0, cn_1.cn)("relative z-10 h-full w-full rounded-xl px-3 text-sm font-medium transition-colors duration-100", activeTab === "fiat" ? "text-white" : "text-as-primary/70 hover:bg-as-on-surface-2 bg-transparent"), onClick: () => {
|
|
800
|
-
setActiveTab("fiat");
|
|
801
|
-
setSelectedCryptoPaymentMethod(CryptoPaymentMethod_1.CryptoPaymentMethodType.NONE); // Reset crypto payment method when switching to fiat
|
|
802
|
-
setSelectedFiatPaymentMethod(FiatPaymentMethod_1.FiatPaymentMethod.NONE); // Reset fiat payment method when switching to fiat
|
|
803
|
-
}, children: "Pay with Fiat" })] }) }), (0, jsx_runtime_1.jsxs)("div", { className: "relative flex w-full max-w-[calc(100vw-32px)] flex-col gap-2", children: [activeTab === "crypto" ? ((0, jsx_runtime_1.jsxs)(react_3.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" }, className: "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: [(0, jsx_runtime_1.jsxs)("div", { className: "flex items-center justify-between", children: [(0, jsx_runtime_1.jsx)("div", { className: "text-as-primary/50 flex h-7 items-center text-sm", children: "Pay" }), (0, jsx_runtime_1.jsx)("button", { className: "text-as-tertiarry flex h-7 items-center gap-2 text-sm transition-colors", onClick: () => setActivePanel(PanelView.CRYPTO_PAYMENT_METHOD), children: selectedCryptoPaymentMethod === CryptoPaymentMethod_1.CryptoPaymentMethodType.CONNECT_WALLET ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [connectedAddress ? ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (0, jsx_runtime_1.jsx)("div", { className: "flex items-center gap-1", children: connectedName ? (0, utils_1.formatUsername)(connectedName) : (0, formatAddress_1.shortenAddress)(connectedAddress || "") }) })) : ("Connect wallet"), (0, jsx_runtime_1.jsx)(lucide_react_1.ChevronRight, { className: "h-4 w-4" })] })) : selectedCryptoPaymentMethod === CryptoPaymentMethod_1.CryptoPaymentMethodType.TRANSFER_CRYPTO ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: ["Transfer crypto", (0, jsx_runtime_1.jsx)(lucide_react_1.ChevronRight, { className: "h-4 w-4" })] })) : ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: ["Select payment method", (0, jsx_runtime_1.jsx)(lucide_react_1.ChevronRight, { className: "h-4 w-4" })] })) })] }), (0, jsx_runtime_1.jsx)(OrderTokenAmount_1.OrderTokenAmount, { address: globalAddress, context: "from", inputValue: srcAmount, onChangeInput: value => {
|
|
804
|
-
setIsSrcInputDirty(true);
|
|
805
|
-
setSrcAmount(value);
|
|
806
|
-
}, chainId: selectedSrcChainId, setChainId: setSelectedSrcChainId, token: selectedSrcToken, setToken: setSelectedSrcToken }), (0, jsx_runtime_1.jsxs)("div", { className: "flex items-center justify-between", children: [(0, jsx_runtime_1.jsx)("div", { className: "text-as-primary/50 flex h-5 items-center text-sm", children: (0, number_1.formatDisplayNumber)(anyspendQuote?.data?.currencyIn?.amountUsd, { style: "currency", fallback: "" }) }), (0, jsx_runtime_1.jsx)(TokenBalance_1.TokenBalance, { token: selectedSrcToken, walletAddress: globalAddress, onChangeInput: value => {
|
|
807
|
-
setIsSrcInputDirty(true);
|
|
808
|
-
setSrcAmount(value);
|
|
809
|
-
} })] })] })) : ((0, jsx_runtime_1.jsx)(react_3.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: (0, jsx_runtime_1.jsx)(PanelOnramp_1.PanelOnramp, { srcAmountOnRamp: srcAmountOnRamp, setSrcAmountOnRamp: setSrcAmountOnRamp, selectedPaymentMethod: selectedFiatPaymentMethod, setActivePanel: setActivePanel, _recipientAddress: recipientAddress, destinationToken: selectedDstToken, destinationChainId: selectedDstChainId, destinationAmount: dstAmount, onDestinationTokenChange: setSelectedDstToken, onDestinationChainChange: setSelectedDstChainId }) })), (0, jsx_runtime_1.jsx)(react_2.Button, { variant: "ghost", className: (0, cn_1.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: () => {
|
|
665
|
+
const mainView = ((0, jsx_runtime_1.jsxs)("div", { className: "mx-auto flex w-[460px] max-w-full flex-col items-center gap-2", children: [isBuyMode && ((0, jsx_runtime_1.jsxs)("div", { className: "mb-4 flex flex-col items-center gap-3 text-center", children: [selectedDstToken.metadata?.logoURI && ((0, jsx_runtime_1.jsx)("div", { className: "relative", children: (0, jsx_runtime_1.jsx)("img", { src: selectedDstToken.metadata.logoURI, alt: selectedDstToken.symbol, className: "border-as-stroke h-12 w-12 rounded-full border-2 shadow-md" }) })), (0, jsx_runtime_1.jsx)("div", { children: (0, jsx_runtime_1.jsxs)("h1", { className: "text-as-primary text-xl font-bold", children: ["Buy ", selectedDstToken.symbol] }) })] })), (0, jsx_runtime_1.jsx)(TabSection_1.TabSection, { activeTab: activeTab, setActiveTab: setActiveTab, setSelectedCryptoPaymentMethod: setSelectedCryptoPaymentMethod, setSelectedFiatPaymentMethod: setSelectedFiatPaymentMethod }), (0, jsx_runtime_1.jsxs)("div", { className: "relative flex w-full max-w-[calc(100vw-32px)] flex-col gap-2", children: [activeTab === "crypto" ? ((0, jsx_runtime_1.jsx)(PaySection_1.PaySection, { paymentType: "crypto", selectedSrcChainId: selectedSrcChainId, setSelectedSrcChainId: setSelectedSrcChainId, selectedSrcToken: selectedSrcToken, setSelectedSrcToken: setSelectedSrcToken, srcAmount: srcAmount, setSrcAmount: setSrcAmount, setIsSrcInputDirty: setIsSrcInputDirty, selectedCryptoPaymentMethod: selectedCryptoPaymentMethod, selectedFiatPaymentMethod: selectedFiatPaymentMethod, onSelectCryptoPaymentMethod: () => setActivePanel(PanelView.CRYPTO_PAYMENT_METHOD), onSelectFiatPaymentMethod: () => setActivePanel(PanelView.FIAT_PAYMENT_METHOD), anyspendQuote: anyspendQuote })) : ((0, jsx_runtime_1.jsx)(react_3.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: (0, jsx_runtime_1.jsx)(PanelOnramp_1.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 }) })), (0, jsx_runtime_1.jsx)(react_2.Button, { variant: "ghost", className: (0, cn_1.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: () => {
|
|
810
666
|
if (activeTab === "fiat" || isBuyMode) {
|
|
811
667
|
return;
|
|
812
668
|
}
|
|
@@ -825,24 +681,10 @@ function AnySpendInner({ destinationTokenAddress, destinationTokenChainId, mode
|
|
|
825
681
|
const tempDstAmount = dstAmount;
|
|
826
682
|
setSrcAmount(tempDstAmount);
|
|
827
683
|
setDstAmount(tempSrcAmount);
|
|
828
|
-
}, children: (0, jsx_runtime_1.jsx)("div", { className: "relative flex items-center justify-center transition-opacity", children: (0, jsx_runtime_1.jsx)(lucide_react_1.ArrowDown, { className: "text-as-primary/50 h-5 w-5" }) }) }), activeTab
|
|
829
|
-
|
|
830
|
-
(
|
|
831
|
-
|
|
832
|
-
setDstAmount(value);
|
|
833
|
-
}, chainId: selectedDstChainId, setChainId: setSelectedDstChainId, token: selectedDstToken, setToken: setSelectedDstToken })), (0, jsx_runtime_1.jsxs)("div", { className: "text-as-primary/50 flex h-5 items-center text-sm", children: [(0, number_1.formatDisplayNumber)(anyspendQuote?.data?.currencyOut?.amountUsd, { style: "currency", fallback: "" }), anyspendQuote?.data?.currencyIn?.amountUsd &&
|
|
834
|
-
anyspendQuote?.data?.currencyOut?.amountUsd &&
|
|
835
|
-
(() => {
|
|
836
|
-
const { percentage, isNegative } = calculatePriceImpact(anyspendQuote.data.currencyIn.amountUsd, anyspendQuote.data.currencyOut.amountUsd);
|
|
837
|
-
// Parse the percentage as a number for comparison
|
|
838
|
-
const percentageNum = parseFloat(percentage);
|
|
839
|
-
// Don't show if less than 1%
|
|
840
|
-
if (percentageNum < 1) {
|
|
841
|
-
return null;
|
|
842
|
-
}
|
|
843
|
-
// Using inline style to ensure color displays
|
|
844
|
-
return ((0, jsx_runtime_1.jsxs)("span", { className: "ml-2", style: { color: percentageNum >= 10 ? "red" : "#FFD700" }, children: ["(", isNegative ? "-" : "", percentage, "%)"] }));
|
|
845
|
-
})()] })] }))] }), getAnyspendQuoteError && ((0, jsx_runtime_1.jsxs)("div", { className: "bg-as-on-surface-1 flex w-full max-w-[460px] items-center gap-2 rounded-2xl px-4 py-2", children: [(0, jsx_runtime_1.jsx)(lucide_react_1.CircleAlert, { className: "bg-as-red h-4 min-h-4 w-4 min-w-4 rounded-full p-0 text-sm font-medium text-white" }), (0, jsx_runtime_1.jsx)("div", { className: "text-as-red text-sm", children: getAnyspendQuoteError.message })] })), (0, jsx_runtime_1.jsxs)(react_3.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: (0, cn_1.cn)("mt-4 flex w-full max-w-[460px] flex-col gap-2", getAnyspendQuoteError && "mt-0"), children: [(0, jsx_runtime_1.jsx)(react_2.ShinyButton, { accentColor: "hsl(var(--as-brand))", disabled: btnInfo.disable, onClick: onMainButtonClick, className: (0, cn_1.cn)("as-main-button relative w-full", btnInfo.error ? "!bg-as-red" : btnInfo.disable ? "!bg-as-on-surface-2" : "!bg-as-brand"), textClassName: (0, cn_1.cn)(btnInfo.error ? "text-white" : btnInfo.disable ? "text-as-secondary" : "text-white"), children: btnInfo.text }), !hideTransactionHistoryButton && (globalAddress || recipientAddress) ? ((0, jsx_runtime_1.jsxs)(react_2.Button, { variant: "link", onClick: onClickHistory, className: "text-as-primary/50 hover:text-as-primary flex items-center gap-1 transition-colors", children: [(0, jsx_runtime_1.jsx)(lucide_react_1.HistoryIcon, { className: "h-4 w-4" }), " ", (0, jsx_runtime_1.jsx)("span", { className: "pr-4", children: "Transaction History" })] })) : null] })] }));
|
|
684
|
+
}, children: (0, jsx_runtime_1.jsx)("div", { className: "relative flex items-center justify-center transition-opacity", children: (0, jsx_runtime_1.jsx)(lucide_react_1.ArrowDown, { className: "text-as-primary/50 h-5 w-5" }) }) }), activeTab === "crypto" && ((0, jsx_runtime_1.jsx)(CryptoReceiveSection_1.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 => {
|
|
685
|
+
setIsSrcInputDirty(false);
|
|
686
|
+
setDstAmount(value);
|
|
687
|
+
}, anyspendQuote: anyspendQuote }))] }), (0, jsx_runtime_1.jsx)(ErrorSection_1.ErrorSection, { error: getAnyspendQuoteError }), (0, jsx_runtime_1.jsxs)(react_3.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: (0, cn_1.cn)("mt-4 flex w-full max-w-[460px] flex-col gap-2", getAnyspendQuoteError && "mt-0"), children: [(0, jsx_runtime_1.jsx)(react_2.ShinyButton, { accentColor: "hsl(var(--as-brand))", disabled: btnInfo.disable, onClick: onMainButtonClick, className: (0, cn_1.cn)("as-main-button relative w-full", btnInfo.error ? "!bg-as-red" : btnInfo.disable ? "!bg-as-on-surface-2" : "!bg-as-brand"), textClassName: (0, cn_1.cn)(btnInfo.error ? "text-white" : btnInfo.disable ? "text-as-secondary" : "text-white"), children: btnInfo.text }), !hideTransactionHistoryButton && (globalAddress || recipientAddress) ? ((0, jsx_runtime_1.jsxs)(react_2.Button, { variant: "link", onClick: onClickHistory, className: "text-as-primary/50 hover:text-as-primary flex items-center gap-1 transition-colors", children: [(0, jsx_runtime_1.jsx)(lucide_react_1.HistoryIcon, { className: "h-4 w-4" }), " ", (0, jsx_runtime_1.jsx)("span", { className: "pr-4", children: "Transaction History" })] })) : null] })] }));
|
|
846
688
|
const onrampPaymentView = ((0, jsx_runtime_1.jsx)(PanelOnrampPayment_1.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 => {
|
|
847
689
|
setOrderId(orderId);
|
|
848
690
|
setActivePanel(PanelView.ORDER_DETAILS);
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { AnySpendBondKitProps } from "../../../global-account/react/stores/useModalStore";
|
|
2
|
-
export declare function AnySpendBondKit({ mode, recipientAddress, contractAddress, minTokensOut, imageUrl,
|
|
2
|
+
export declare function AnySpendBondKit({ mode, recipientAddress, contractAddress, minTokensOut, imageUrl, b3Amount: initialB3Amount, onSuccess, }: AnySpendBondKitProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -2,13 +2,12 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.AnySpendBondKit = AnySpendBondKit;
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
-
const bondkit_1 = require("../../../bondkit");
|
|
6
5
|
const react_1 = require("../../../global-account/react");
|
|
7
6
|
const supported_1 = require("../../../shared/constants/chains/supported");
|
|
8
7
|
const react_2 = require("motion/react");
|
|
9
8
|
const react_3 = require("react");
|
|
10
9
|
const viem_1 = require("viem");
|
|
11
|
-
const
|
|
10
|
+
const bondkit_1 = require("../../../bondkit");
|
|
12
11
|
const AnySpendCustom_1 = require("./AnySpendCustom");
|
|
13
12
|
// Debounce utility function
|
|
14
13
|
function debounce(func, wait) {
|
|
@@ -24,11 +23,11 @@ function formatNumberWithCommas(x) {
|
|
|
24
23
|
parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, ",");
|
|
25
24
|
return parts.join(".");
|
|
26
25
|
}
|
|
27
|
-
function AnySpendBondKit({ mode = "modal", recipientAddress, contractAddress, minTokensOut = "0", imageUrl,
|
|
26
|
+
function AnySpendBondKit({ mode = "modal", recipientAddress, contractAddress, minTokensOut = "0", imageUrl, b3Amount: initialB3Amount, onSuccess, }) {
|
|
28
27
|
const hasMounted = (0, react_1.useHasMounted)();
|
|
29
|
-
const [showAmountPrompt, setShowAmountPrompt] = (0, react_3.useState)(!
|
|
30
|
-
const [
|
|
31
|
-
const [isAmountValid, setIsAmountValid] = (0, react_3.useState)(!!
|
|
28
|
+
const [showAmountPrompt, setShowAmountPrompt] = (0, react_3.useState)(!initialB3Amount);
|
|
29
|
+
const [b3Amount, setB3Amount] = (0, react_3.useState)(initialB3Amount || "");
|
|
30
|
+
const [isAmountValid, setIsAmountValid] = (0, react_3.useState)(!!initialB3Amount);
|
|
32
31
|
const [validationError, setValidationError] = (0, react_3.useState)("");
|
|
33
32
|
const [tokenName, setTokenName] = (0, react_3.useState)("");
|
|
34
33
|
const [tokenSymbol, setTokenSymbol] = (0, react_3.useState)("");
|
|
@@ -60,12 +59,12 @@ function AnySpendBondKit({ mode = "modal", recipientAddress, contractAddress, mi
|
|
|
60
59
|
const [name, symbol] = await Promise.all([
|
|
61
60
|
basePublicClient.readContract({
|
|
62
61
|
address: contractAddress,
|
|
63
|
-
abi:
|
|
62
|
+
abi: bondkit_1.BondkitTokenABI,
|
|
64
63
|
functionName: "name",
|
|
65
64
|
}),
|
|
66
65
|
basePublicClient.readContract({
|
|
67
66
|
address: contractAddress,
|
|
68
|
-
abi:
|
|
67
|
+
abi: bondkit_1.BondkitTokenABI,
|
|
69
68
|
functionName: "symbol",
|
|
70
69
|
}),
|
|
71
70
|
]);
|
|
@@ -82,8 +81,8 @@ function AnySpendBondKit({ mode = "modal", recipientAddress, contractAddress, mi
|
|
|
82
81
|
fetchTokenName();
|
|
83
82
|
}
|
|
84
83
|
}, [contractAddress, basePublicClient]);
|
|
85
|
-
// Get
|
|
86
|
-
const { data: tokenData, isError: isTokenError, isLoading, } = (0, react_1.useTokenData)(supported_1.baseMainnet.id, "
|
|
84
|
+
// Get b3 token data
|
|
85
|
+
const { data: tokenData, isError: isTokenError, isLoading, } = (0, react_1.useTokenData)(supported_1.baseMainnet.id, "0xB3B32F9f8827D4634fE7d973Fa1034Ec9fdDB3B3");
|
|
87
86
|
// Convert token data to AnySpend Token type
|
|
88
87
|
const dstToken = (0, react_3.useMemo)(() => {
|
|
89
88
|
if (!tokenData)
|
|
@@ -119,16 +118,16 @@ function AnySpendBondKit({ mode = "modal", recipientAddress, contractAddress, mi
|
|
|
119
118
|
setIsLoadingQuote(false);
|
|
120
119
|
}
|
|
121
120
|
}, 500), [bondkitTokenClient]);
|
|
122
|
-
// Fetch initial quote if
|
|
121
|
+
// Fetch initial quote if b3Amount is provided
|
|
123
122
|
(0, react_3.useEffect)(() => {
|
|
124
|
-
if (
|
|
125
|
-
debouncedGetQuote(
|
|
123
|
+
if (initialB3Amount && bondkitTokenClient) {
|
|
124
|
+
debouncedGetQuote(initialB3Amount);
|
|
126
125
|
}
|
|
127
|
-
}, [
|
|
126
|
+
}, [initialB3Amount, bondkitTokenClient, debouncedGetQuote]);
|
|
128
127
|
const validateAndSetAmount = (value) => {
|
|
129
128
|
// Allow empty input
|
|
130
129
|
if (value === "") {
|
|
131
|
-
|
|
130
|
+
setB3Amount("");
|
|
132
131
|
setIsAmountValid(false);
|
|
133
132
|
setValidationError("");
|
|
134
133
|
setQuote(null);
|
|
@@ -144,14 +143,14 @@ function AnySpendBondKit({ mode = "modal", recipientAddress, contractAddress, mi
|
|
|
144
143
|
if ((value.match(/\./g) || []).length > 1) {
|
|
145
144
|
return;
|
|
146
145
|
}
|
|
147
|
-
// Prevent more than 18 decimal places (
|
|
146
|
+
// Prevent more than 18 decimal places (B3 precision)
|
|
148
147
|
const parts = value.split(".");
|
|
149
148
|
if (parts[1] && parts[1].length > 18) {
|
|
150
149
|
return;
|
|
151
150
|
}
|
|
152
151
|
// Clean the input - remove leading zeros if not decimal
|
|
153
152
|
const cleanedValue = value.startsWith("0") && !value.startsWith("0.") ? value.replace(/^0+/, "0") : value;
|
|
154
|
-
|
|
153
|
+
setB3Amount(cleanedValue);
|
|
155
154
|
try {
|
|
156
155
|
const parsedAmount = (0, viem_1.parseEther)(cleanedValue);
|
|
157
156
|
if (parsedAmount <= BigInt(0)) {
|
|
@@ -169,7 +168,7 @@ function AnySpendBondKit({ mode = "modal", recipientAddress, contractAddress, mi
|
|
|
169
168
|
setValidationError("Please enter a valid amount");
|
|
170
169
|
}
|
|
171
170
|
};
|
|
172
|
-
const header = () => ((0, jsx_runtime_1.jsx)("div", { className: "bg-as-surface-primary w-full px-6 py-4", children: (0, jsx_runtime_1.jsxs)("div", { className: "flex w-full flex-col items-center space-y-6", children: [(0, jsx_runtime_1.jsxs)("h2", { className: "text-[28px] font-bold", children: ["Buy ", tokenName, " (", tokenSymbol, ")"] }), (0, jsx_runtime_1.jsxs)("div", { className: "flex w-full flex-col items-center space-y-2", children: [(0, jsx_runtime_1.jsxs)("span", { className: "text-[28px] font-bold", children: [
|
|
171
|
+
const header = () => ((0, jsx_runtime_1.jsx)("div", { className: "bg-as-surface-primary w-full px-6 py-4", children: (0, jsx_runtime_1.jsxs)("div", { className: "flex w-full flex-col items-center space-y-6", children: [(0, jsx_runtime_1.jsxs)("h2", { className: "text-[28px] font-bold", children: ["Buy ", tokenName, " (", tokenSymbol, ")"] }), (0, jsx_runtime_1.jsxs)("div", { className: "flex w-full flex-col items-center space-y-2", children: [(0, jsx_runtime_1.jsxs)("span", { className: "text-[28px] font-bold", children: [b3Amount, " B3"] }), quote && ((0, jsx_runtime_1.jsxs)("span", { className: "text-lg", children: ["\u2248 ", formatNumberWithCommas(parseFloat(quote).toFixed(4)), " ", tokenSymbol] }))] })] }) }));
|
|
173
172
|
// Show loading state while fetching token data
|
|
174
173
|
if (isLoading) {
|
|
175
174
|
return ((0, jsx_runtime_1.jsx)(react_1.StyleRoot, { children: (0, jsx_runtime_1.jsx)("div", { className: "b3-root b3-modal bg-b3-react-background flex w-full flex-col items-center p-8", children: (0, jsx_runtime_1.jsx)("p", { className: "text-as-primary/70 text-center text-sm", children: "Loading payment information..." }) }) }));
|
|
@@ -191,18 +190,18 @@ function AnySpendBondKit({ mode = "modal", recipientAddress, contractAddress, mi
|
|
|
191
190
|
opacity: hasMounted ? 1 : 0,
|
|
192
191
|
y: hasMounted ? 0 : 20,
|
|
193
192
|
filter: hasMounted ? "blur(0px)" : "blur(10px)",
|
|
194
|
-
}, transition: { duration: 0.3, delay: 0.2, ease: "easeInOut" }, className: "bg-b3-react-background w-full p-6", children: (0, jsx_runtime_1.jsxs)("div", { className: "space-y-4", children: [(0, jsx_runtime_1.jsx)("div", { className: "flex items-center justify-between", children: (0, jsx_runtime_1.jsx)("p", { className: "text-as-primary/70 text-sm font-medium", children: "
|
|
195
|
-
if (isAmountValid &&
|
|
193
|
+
}, transition: { duration: 0.3, delay: 0.2, ease: "easeInOut" }, className: "bg-b3-react-background w-full p-6", children: (0, jsx_runtime_1.jsxs)("div", { className: "space-y-4", children: [(0, jsx_runtime_1.jsx)("div", { className: "flex items-center justify-between", children: (0, jsx_runtime_1.jsx)("p", { className: "text-as-primary/70 text-sm font-medium", children: "B3 Amount" }) }), (0, jsx_runtime_1.jsx)("div", { className: "relative", children: (0, jsx_runtime_1.jsx)(react_1.Input, { type: "text", inputMode: "decimal", placeholder: "0.1", value: b3Amount, onChange: e => validateAndSetAmount(e.target.value), className: `h-14 px-4 text-lg ${!isAmountValid && b3Amount ? "border-as-red" : "border-b3-react-border"}` }) }), !isAmountValid && b3Amount && (0, jsx_runtime_1.jsx)("p", { className: "text-as-red text-sm", children: validationError }), (0, jsx_runtime_1.jsxs)("div", { className: "bg-as-on-surface-2/30 rounded-lg border border-white/10 p-4 backdrop-blur-sm", children: [(0, jsx_runtime_1.jsxs)("div", { className: "flex items-center justify-between", children: [(0, jsx_runtime_1.jsx)("span", { className: "text-as-primary/70 text-sm font-medium", children: "Total Cost:" }), (0, jsx_runtime_1.jsx)("div", { className: "flex items-center gap-2", children: (0, jsx_runtime_1.jsxs)("span", { className: "text-as-primary text-lg font-bold", children: [b3Amount || "0", " B3"] }) })] }), isLoadingQuote ? ((0, jsx_runtime_1.jsx)("div", { className: "mt-2 text-center", children: (0, jsx_runtime_1.jsx)("span", { className: "text-as-primary/70 text-sm", children: "Calculating tokens..." }) })) : quote ? ((0, jsx_runtime_1.jsxs)("div", { className: "mt-2 flex items-center justify-between", children: [(0, jsx_runtime_1.jsx)("span", { className: "text-as-primary/70 text-sm font-medium", children: "You'll receive:" }), (0, jsx_runtime_1.jsxs)("span", { className: "text-as-primary text-sm font-medium", children: ["\u2248 ", formatNumberWithCommas(parseFloat(quote).toFixed(4)), " ", tokenSymbol] })] })) : null] }), (0, jsx_runtime_1.jsx)(react_1.Button, { onClick: () => {
|
|
194
|
+
if (isAmountValid && b3Amount) {
|
|
196
195
|
setShowAmountPrompt(false);
|
|
197
196
|
}
|
|
198
|
-
}, disabled: !isAmountValid || !
|
|
197
|
+
}, disabled: !isAmountValid || !b3Amount || isLoadingQuote, className: "bg-as-brand hover:bg-as-brand/90 text-as-primary mt-4 h-14 w-full rounded-xl text-lg font-medium", children: "Continue" })] }) })] }) }));
|
|
199
198
|
}
|
|
200
199
|
const encodedData = (0, viem_1.encodeFunctionData)({
|
|
201
|
-
abi:
|
|
200
|
+
abi: bondkit_1.BondkitTokenABI,
|
|
202
201
|
functionName: "buyFor",
|
|
203
|
-
args: [recipientAddress, BigInt(minTokensOut)],
|
|
202
|
+
args: [recipientAddress, (0, viem_1.parseEther)(b3Amount), BigInt(minTokensOut)],
|
|
204
203
|
});
|
|
205
|
-
return ((0, jsx_runtime_1.jsx)(AnySpendCustom_1.AnySpendCustom, { mode: mode, recipientAddress: recipientAddress, orderType: "custom", dstChainId: supported_1.baseMainnet.id, dstToken: dstToken, dstAmount: (0, viem_1.parseEther)(
|
|
204
|
+
return ((0, jsx_runtime_1.jsx)(AnySpendCustom_1.AnySpendCustom, { mode: mode, recipientAddress: recipientAddress, orderType: "custom", dstChainId: supported_1.baseMainnet.id, dstToken: dstToken, dstAmount: (0, viem_1.parseEther)(b3Amount).toString(), contractAddress: contractAddress, encodedData: encodedData, metadata: {
|
|
206
205
|
type: "custom",
|
|
207
206
|
action: "BondKit Buy",
|
|
208
207
|
}, header: header, onSuccess: onSuccess, showRecipient: true }));
|
|
@@ -415,11 +415,11 @@ function AnySpendCustomInner({ loadOrder, mode = "modal", activeTab: activeTabPr
|
|
|
415
415
|
? "Receive NFT at"
|
|
416
416
|
: orderType === "join_tournament"
|
|
417
417
|
? "Join for"
|
|
418
|
-
: "Recipient" }), (0, jsx_runtime_1.jsxs)("div", { className: "flex items-center gap-2", children: [recipientAddress ? ((0, jsx_runtime_1.jsx)("button", { className: (0, utils_1.cn)("text-as-tertiarry flex h-7 items-center gap-2 rounded-lg"), onClick: () => setActivePanel(PanelView.RECIPIENT_SELECTION), children: (0, jsx_runtime_1.
|
|
418
|
+
: "Recipient" }), (0, jsx_runtime_1.jsxs)("div", { className: "flex items-center gap-2", children: [recipientAddress ? ((0, jsx_runtime_1.jsx)("button", { className: (0, utils_1.cn)("text-as-tertiarry flex h-7 items-center gap-2 rounded-lg"), onClick: () => setActivePanel(PanelView.RECIPIENT_SELECTION), children: (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (0, jsx_runtime_1.jsx)("div", { className: "text-as-tertiarry flex items-center gap-1 text-sm", children: (0, jsx_runtime_1.jsx)("span", { children: recipientName ? (0, utils_1.formatUsername)(recipientName) : (0, formatAddress_1.shortenAddress)(recipientAddress) }) }) }) })) : ((0, jsx_runtime_1.jsx)("button", { className: "text-as-primary/70 flex items-center gap-1 rounded-lg", onClick: () => setActivePanel(PanelView.RECIPIENT_SELECTION), children: (0, jsx_runtime_1.jsx)("div", { className: "text-sm font-medium", children: "Select recipient" }) })), (0, jsx_runtime_1.jsx)(lucide_react_1.ChevronRight, { className: "h-4 w-4" })] })] }, recipientAddress)) : null;
|
|
419
419
|
const historyView = ((0, jsx_runtime_1.jsx)("div", { className: (0, utils_1.cn)("mx-auto flex w-full max-w-2xl flex-col items-center p-5", mode === "modal" && "bg-b3-react-background"), children: (0, jsx_runtime_1.jsx)(OrderHistory_1.OrderHistory, { mode: mode, onBack: () => {
|
|
420
420
|
setActivePanel(PanelView.HISTORY);
|
|
421
421
|
}, onSelectOrder: onSelectOrder }) }));
|
|
422
|
-
const orderDetailsView = ((0, jsx_runtime_1.jsxs)("div", { className: (0, utils_1.cn)("mx-auto flex w-full flex-col items-center gap-4
|
|
422
|
+
const orderDetailsView = ((0, jsx_runtime_1.jsxs)("div", { className: (0, utils_1.cn)("mx-auto flex w-full flex-col items-center gap-4", mode === "modal" && "bg-b3-react-background rounded-xl"), children: [oat && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(OrderStatus_1.OrderStatus, { order: oat.data.order }), (0, jsx_runtime_1.jsx)(OrderDetails_1.OrderDetails, { mode: mode, order: oat.data.order, depositTxs: oat.data.depositTxs, relayTx: oat.data.relayTx, executeTx: oat.data.executeTx, refundTxs: oat.data.refundTxs, cryptoPaymentMethod: activeTab === "fiat" ? CryptoPaymentMethod_1.CryptoPaymentMethodType.NONE : selectedCryptoPaymentMethod, onBack: () => {
|
|
423
423
|
setOrderId(undefined);
|
|
424
424
|
setActivePanel(PanelView.CONFIRM_ORDER);
|
|
425
425
|
// Remove orderId from URL when canceling
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare function AnySpendDepositHype(props: {
|
|
2
|
+
loadOrder?: string;
|
|
3
|
+
mode?: "modal" | "page";
|
|
4
|
+
recipientAddress: string;
|
|
5
|
+
paymentType?: "crypto" | "fiat";
|
|
6
|
+
sourceTokenAddress?: string;
|
|
7
|
+
sourceTokenChainId?: number;
|
|
8
|
+
onSuccess?: () => void;
|
|
9
|
+
depositContractAddress?: string;
|
|
10
|
+
}): import("react/jsx-runtime").JSX.Element;
|