@b3dotfun/sdk 0.0.29 → 0.0.30-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/constants/index.d.ts +1 -0
- package/dist/cjs/anyspend/constants/index.js +2 -1
- package/dist/cjs/anyspend/react/components/AnySpend.js +2 -2
- 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/AnySpendBuySpin.js +2 -1
- package/dist/cjs/anyspend/react/components/AnySpendCustom.js +1 -1
- package/dist/cjs/anyspend/react/components/AnySpendStakeB3.js +2 -1
- package/dist/cjs/anyspend/react/components/AnyspendDepositHype.d.ts +4 -2
- package/dist/cjs/anyspend/react/components/AnyspendDepositHype.js +17 -10
- package/dist/cjs/anyspend/react/components/common/ConnectWalletPayment.js +9 -1
- package/dist/cjs/anyspend/react/components/common/CryptoPaymentMethod.js +124 -41
- package/dist/cjs/anyspend/react/components/common/OrderDetails.js +6 -3
- package/dist/cjs/anyspend/react/components/common/OrderDetailsCollapsible.js +6 -4
- package/dist/cjs/anyspend/react/components/common/OrderStatus.d.ts +2 -0
- package/dist/cjs/anyspend/react/components/common/OrderStatus.js +2 -2
- package/dist/cjs/anyspend/react/components/common/OrderTokenAmount.js +1 -1
- 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.js +6 -4
- package/dist/cjs/anyspend/react/hooks/useAnyspendFlow.d.ts +2 -1
- package/dist/cjs/anyspend/react/hooks/useAnyspendFlow.js +34 -3
- package/dist/cjs/anyspend/react/hooks/useSigMint.d.ts +1 -1
- package/dist/cjs/bondkit/abis/BondkitTokenABI.d.ts +62 -17
- package/dist/cjs/bondkit/abis/BondkitTokenABI.js +41 -9
- package/dist/cjs/bondkit/abis/BondkitTokenFactoryABI.d.ts +0 -25
- package/dist/cjs/bondkit/abis/BondkitTokenFactoryABI.js +0 -9
- package/dist/cjs/bondkit/constants.js +1 -1
- package/dist/cjs/global-account/react/components/LinkAccount/LinkAccount.js +28 -15
- package/dist/cjs/global-account/react/components/ManageAccount/ManageAccount.js +1 -1
- package/dist/cjs/global-account/react/hooks/useB3BalanceFromAddresses.js +2 -1
- package/dist/cjs/global-account/react/hooks/useNativeBalance.js +2 -1
- package/dist/cjs/global-account/react/hooks/useUnifiedChainSwitchAndExecute.d.ts +1 -0
- package/dist/cjs/global-account/react/hooks/useUnifiedChainSwitchAndExecute.js +1 -0
- package/dist/cjs/global-account/react/stores/useModalStore.d.ts +4 -2
- package/dist/cjs/shared/constants/chains/b3Chain.d.ts +2 -2
- package/dist/cjs/shared/constants/chains/supported.d.ts +4 -4
- package/dist/cjs/shared/constants/index.d.ts +1 -0
- package/dist/cjs/shared/constants/index.js +2 -1
- package/dist/esm/anyspend/constants/index.d.ts +1 -0
- package/dist/esm/anyspend/constants/index.js +1 -0
- package/dist/esm/anyspend/react/components/AnySpend.js +2 -2
- 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/AnySpendBuySpin.js +2 -1
- package/dist/esm/anyspend/react/components/AnySpendCustom.js +1 -1
- package/dist/esm/anyspend/react/components/AnySpendStakeB3.js +2 -1
- package/dist/esm/anyspend/react/components/AnyspendDepositHype.d.ts +4 -2
- package/dist/esm/anyspend/react/components/AnyspendDepositHype.js +19 -12
- package/dist/esm/anyspend/react/components/common/ConnectWalletPayment.js +6 -1
- package/dist/esm/anyspend/react/components/common/CryptoPaymentMethod.js +126 -43
- package/dist/esm/anyspend/react/components/common/OrderDetails.js +7 -4
- package/dist/esm/anyspend/react/components/common/OrderDetailsCollapsible.js +7 -5
- package/dist/esm/anyspend/react/components/common/OrderStatus.d.ts +2 -0
- package/dist/esm/anyspend/react/components/common/OrderStatus.js +2 -2
- package/dist/esm/anyspend/react/components/common/OrderTokenAmount.js +1 -1
- 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.js +7 -5
- package/dist/esm/anyspend/react/hooks/useAnyspendFlow.d.ts +2 -1
- package/dist/esm/anyspend/react/hooks/useAnyspendFlow.js +35 -4
- package/dist/esm/anyspend/react/hooks/useSigMint.d.ts +1 -1
- package/dist/esm/bondkit/abis/BondkitTokenABI.d.ts +62 -17
- package/dist/esm/bondkit/abis/BondkitTokenABI.js +41 -9
- package/dist/esm/bondkit/abis/BondkitTokenFactoryABI.d.ts +0 -25
- package/dist/esm/bondkit/abis/BondkitTokenFactoryABI.js +0 -9
- package/dist/esm/bondkit/constants.js +1 -1
- package/dist/esm/global-account/react/components/LinkAccount/LinkAccount.js +28 -15
- package/dist/esm/global-account/react/components/ManageAccount/ManageAccount.js +1 -1
- package/dist/esm/global-account/react/hooks/useB3BalanceFromAddresses.js +2 -1
- package/dist/esm/global-account/react/hooks/useNativeBalance.js +2 -1
- package/dist/esm/global-account/react/hooks/useUnifiedChainSwitchAndExecute.d.ts +1 -0
- package/dist/esm/global-account/react/hooks/useUnifiedChainSwitchAndExecute.js +1 -0
- package/dist/esm/global-account/react/stores/useModalStore.d.ts +4 -2
- package/dist/esm/shared/constants/chains/b3Chain.d.ts +2 -2
- package/dist/esm/shared/constants/chains/supported.d.ts +4 -4
- package/dist/esm/shared/constants/index.d.ts +1 -0
- package/dist/esm/shared/constants/index.js +1 -0
- package/dist/styles/index.css +1 -1
- package/dist/types/anyspend/constants/index.d.ts +1 -0
- package/dist/types/anyspend/react/components/AnySpendBondKit.d.ts +1 -1
- package/dist/types/anyspend/react/components/AnyspendDepositHype.d.ts +4 -2
- package/dist/types/anyspend/react/components/common/OrderStatus.d.ts +2 -0
- package/dist/types/anyspend/react/components/common/PanelOnramp.d.ts +2 -1
- package/dist/types/anyspend/react/hooks/useAnyspendFlow.d.ts +2 -1
- package/dist/types/anyspend/react/hooks/useSigMint.d.ts +1 -1
- package/dist/types/bondkit/abis/BondkitTokenABI.d.ts +62 -17
- package/dist/types/bondkit/abis/BondkitTokenFactoryABI.d.ts +0 -25
- package/dist/types/global-account/react/hooks/useUnifiedChainSwitchAndExecute.d.ts +1 -0
- package/dist/types/global-account/react/stores/useModalStore.d.ts +4 -2
- package/dist/types/shared/constants/chains/b3Chain.d.ts +2 -2
- package/dist/types/shared/constants/chains/supported.d.ts +4 -4
- package/dist/types/shared/constants/index.d.ts +1 -0
- package/package.json +1 -1
- package/src/anyspend/constants/index.ts +2 -0
- package/src/anyspend/react/components/AnySpend.tsx +2 -1
- package/src/anyspend/react/components/AnySpendBondKit.tsx +28 -28
- package/src/anyspend/react/components/AnySpendBuySpin.tsx +2 -1
- package/src/anyspend/react/components/AnySpendCustom.tsx +1 -1
- package/src/anyspend/react/components/AnySpendStakeB3.tsx +2 -1
- package/src/anyspend/react/components/AnyspendDepositHype.tsx +143 -130
- package/src/anyspend/react/components/common/ConnectWalletPayment.tsx +9 -0
- package/src/anyspend/react/components/common/CryptoPaymentMethod.tsx +243 -104
- package/src/anyspend/react/components/common/OrderDetails.tsx +7 -3
- package/src/anyspend/react/components/common/OrderDetailsCollapsible.tsx +10 -4
- package/src/anyspend/react/components/common/OrderStatus.tsx +9 -2
- package/src/anyspend/react/components/common/OrderTokenAmount.tsx +2 -2
- package/src/anyspend/react/components/common/PanelOnramp.tsx +3 -1
- package/src/anyspend/react/components/common/PaySection.tsx +10 -8
- package/src/anyspend/react/hooks/useAnyspendFlow.ts +41 -3
- package/src/bondkit/abis/BondkitTokenABI.ts +41 -9
- package/src/bondkit/abis/BondkitTokenFactoryABI.ts +0 -9
- package/src/bondkit/constants.ts +1 -1
- package/src/global-account/react/components/LinkAccount/LinkAccount.tsx +26 -10
- package/src/global-account/react/components/ManageAccount/ManageAccount.tsx +5 -1
- package/src/global-account/react/hooks/useB3BalanceFromAddresses.ts +2 -1
- package/src/global-account/react/hooks/useNativeBalance.tsx +2 -1
- package/src/global-account/react/hooks/useUnifiedChainSwitchAndExecute.ts +1 -0
- package/src/global-account/react/stores/useModalStore.ts +4 -2
- package/src/shared/constants/index.ts +2 -0
- 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
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.VENDOR_DISPLAY_NAMES = exports.PAYMENT_METHOD_ICONS = exports.STRIPE_CONFIG = exports.DEFAULT_NFT_CONTRACT = exports.NFT_CONTRACTS = exports.ETH_BASE = exports.USDC_BASE = exports.B3_TOKEN = exports.SOLANA_TOKEN_2022_PROGRAM_ID = exports.SOLANA_ASSOCIATED_TOKEN_ACCOUNT_PROGRAM_ID = exports.RELAY_SOLANA_MAINNET_CHAIN_ID = exports.RELAY_SOL_ADDRESS = exports.RELAY_ETH_ADDRESS = exports.ANYSPEND_MAINNET_BASE_URL = void 0;
|
|
3
|
+
exports.DEPOSIT_HYPE_ACTION = exports.VENDOR_DISPLAY_NAMES = exports.PAYMENT_METHOD_ICONS = exports.STRIPE_CONFIG = exports.DEFAULT_NFT_CONTRACT = exports.NFT_CONTRACTS = exports.ETH_BASE = exports.USDC_BASE = exports.B3_TOKEN = exports.SOLANA_TOKEN_2022_PROGRAM_ID = exports.SOLANA_ASSOCIATED_TOKEN_ACCOUNT_PROGRAM_ID = exports.RELAY_SOLANA_MAINNET_CHAIN_ID = exports.RELAY_SOL_ADDRESS = exports.RELAY_ETH_ADDRESS = exports.ANYSPEND_MAINNET_BASE_URL = void 0;
|
|
4
4
|
const chains_1 = require("viem/chains");
|
|
5
5
|
exports.ANYSPEND_MAINNET_BASE_URL = process.env.NEXT_PUBLIC_ANYSPEND_BASE_URL || "https://mainnet.anyspend.com";
|
|
6
6
|
exports.RELAY_ETH_ADDRESS = "0x0000000000000000000000000000000000000000";
|
|
@@ -81,3 +81,4 @@ exports.VENDOR_DISPLAY_NAMES = {
|
|
|
81
81
|
stripe: "Stripe",
|
|
82
82
|
unknown: "Unknown Vendor",
|
|
83
83
|
};
|
|
84
|
+
exports.DEPOSIT_HYPE_ACTION = "deposit_hype";
|
|
@@ -657,12 +657,12 @@ function AnySpendInner({ destinationTokenAddress, destinationTokenChainId, mode
|
|
|
657
657
|
window.scrollTo({ top: 0, behavior: "smooth" });
|
|
658
658
|
}, [activePanel]);
|
|
659
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 }) }));
|
|
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: () => {
|
|
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, selectedCryptoPaymentMethod: selectedCryptoPaymentMethod }), (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: () => {
|
|
661
661
|
setOrderId(undefined);
|
|
662
662
|
setActivePanel(PanelView.MAIN);
|
|
663
663
|
setSelectedCryptoPaymentMethod(CryptoPaymentMethod_1.CryptoPaymentMethodType.NONE); // Reset payment method when going back
|
|
664
664
|
} })] })) }) }));
|
|
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: () => {
|
|
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, recipientSelectionPanelIndex: PanelView.RECIPIENT_SELECTION }) })), (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: () => {
|
|
666
666
|
if (activeTab === "fiat" || isBuyMode) {
|
|
667
667
|
return;
|
|
668
668
|
}
|
|
@@ -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 }));
|
|
@@ -7,6 +7,7 @@ exports.AnySpendBuySpin = AnySpendBuySpin;
|
|
|
7
7
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
8
8
|
const anyspend_1 = require("../../../anyspend");
|
|
9
9
|
const react_1 = require("../../../global-account/react");
|
|
10
|
+
const constants_1 = require("../../../shared/constants");
|
|
10
11
|
const supported_1 = require("../../../shared/constants/chains/supported");
|
|
11
12
|
const invariant_1 = __importDefault(require("invariant"));
|
|
12
13
|
const lucide_react_1 = require("lucide-react");
|
|
@@ -88,7 +89,7 @@ function generateEncodedDataForBuyEntriesAndSpin(user, quantity) {
|
|
|
88
89
|
}
|
|
89
90
|
const basePublicClient = (0, viem_1.createPublicClient)({
|
|
90
91
|
chain: supported_1.baseMainnet,
|
|
91
|
-
transport: (0, viem_1.http)(),
|
|
92
|
+
transport: (0, viem_1.http)(constants_1.PUBLIC_BASE_RPC_URL),
|
|
92
93
|
});
|
|
93
94
|
function AnySpendBuySpin({ loadOrder, mode = "modal", spinwheelContractAddress, chainId, recipientAddress, prefillQuantity, onSuccess, }) {
|
|
94
95
|
const hasMounted = (0, react_1.useHasMounted)();
|
|
@@ -419,7 +419,7 @@ function AnySpendCustomInner({ loadOrder, mode = "modal", activeTab: activeTabPr
|
|
|
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", 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: () => {
|
|
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, selectedCryptoPaymentMethod: selectedCryptoPaymentMethod }), (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
|
|
@@ -7,6 +7,7 @@ exports.AnySpendStakeB3 = AnySpendStakeB3;
|
|
|
7
7
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
8
8
|
const anyspend_1 = require("../../../anyspend");
|
|
9
9
|
const react_1 = require("../../../global-account/react");
|
|
10
|
+
const constants_1 = require("../../../shared/constants");
|
|
10
11
|
const number_1 = require("../../../shared/utils/number");
|
|
11
12
|
const invariant_1 = __importDefault(require("invariant"));
|
|
12
13
|
const lucide_react_1 = require("lucide-react");
|
|
@@ -22,7 +23,7 @@ const SolIcon_1 = require("./icons/SolIcon");
|
|
|
22
23
|
const USDCIcon_1 = require("./icons/USDCIcon");
|
|
23
24
|
const basePublicClient = (0, viem_1.createPublicClient)({
|
|
24
25
|
chain: chains_1.base,
|
|
25
|
-
transport: (0, viem_1.http)(),
|
|
26
|
+
transport: (0, viem_1.http)(constants_1.PUBLIC_BASE_RPC_URL),
|
|
26
27
|
});
|
|
27
28
|
const ERC20Staking = "0xbf04200be3cbf371467a539706393c81c470f523";
|
|
28
29
|
function generateEncodedDataForStakingB3(amount, beneficiary) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export
|
|
1
|
+
export interface AnySpendDepositHypeProps {
|
|
2
2
|
loadOrder?: string;
|
|
3
3
|
mode?: "modal" | "page";
|
|
4
4
|
recipientAddress: string;
|
|
@@ -7,4 +7,6 @@ export declare function AnySpendDepositHype(props: {
|
|
|
7
7
|
sourceTokenChainId?: number;
|
|
8
8
|
onSuccess?: () => void;
|
|
9
9
|
depositContractAddress?: string;
|
|
10
|
-
|
|
10
|
+
mainFooter?: React.ReactNode;
|
|
11
|
+
}
|
|
12
|
+
export declare function AnySpendDepositHype(props: AnySpendDepositHypeProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -27,6 +27,7 @@ const RecipientSelection_1 = require("./common/RecipientSelection");
|
|
|
27
27
|
const escrow_1 = require("../../../anyspend/abis/escrow");
|
|
28
28
|
const lucide_react_1 = require("lucide-react");
|
|
29
29
|
const PanelOnramp_1 = require("./common/PanelOnramp");
|
|
30
|
+
const SLIPPAGE_PERCENT = 3;
|
|
30
31
|
function generateEncodedDataForDepositHype(amount, beneficiary) {
|
|
31
32
|
(0, invariant_1.default)(BigInt(amount) > 0, "Amount must be greater than zero");
|
|
32
33
|
const encodedData = (0, viem_1.encodeFunctionData)({
|
|
@@ -40,9 +41,9 @@ function AnySpendDepositHype(props) {
|
|
|
40
41
|
const fingerprintConfig = (0, AnySpendFingerprintWrapper_1.getFingerprintConfig)();
|
|
41
42
|
return ((0, jsx_runtime_1.jsx)(AnySpendFingerprintWrapper_1.AnySpendFingerprintWrapper, { fingerprint: fingerprintConfig, children: (0, jsx_runtime_1.jsx)(AnySpendDepositHypeInner, { ...props }) }));
|
|
42
43
|
}
|
|
43
|
-
function AnySpendDepositHypeInner({ loadOrder, mode = "modal", recipientAddress, paymentType = "crypto", sourceTokenAddress, sourceTokenChainId, onSuccess, depositContractAddress, }) {
|
|
44
|
+
function AnySpendDepositHypeInner({ loadOrder, mode = "modal", recipientAddress, paymentType = "crypto", sourceTokenAddress, sourceTokenChainId, onSuccess, depositContractAddress, mainFooter, }) {
|
|
44
45
|
// Use shared flow hook
|
|
45
|
-
const { activePanel, setActivePanel, orderId, 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, } = (0, useAnyspendFlow_1.useAnyspendFlow)({
|
|
46
|
+
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, } = (0, useAnyspendFlow_1.useAnyspendFlow)({
|
|
46
47
|
paymentType,
|
|
47
48
|
recipientAddress,
|
|
48
49
|
loadOrder,
|
|
@@ -50,6 +51,7 @@ function AnySpendDepositHypeInner({ loadOrder, mode = "modal", recipientAddress,
|
|
|
50
51
|
onTransactionSuccess: onSuccess,
|
|
51
52
|
sourceTokenAddress,
|
|
52
53
|
sourceTokenChainId,
|
|
54
|
+
slippage: SLIPPAGE_PERCENT,
|
|
53
55
|
});
|
|
54
56
|
// Button state logic
|
|
55
57
|
const btnInfo = (0, react_3.useMemo)(() => {
|
|
@@ -122,6 +124,10 @@ function AnySpendDepositHypeInner({ loadOrder, mode = "modal", recipientAddress,
|
|
|
122
124
|
await handleFiatOrder();
|
|
123
125
|
}
|
|
124
126
|
};
|
|
127
|
+
const mainView = ((0, jsx_runtime_1.jsxs)("div", { className: "mx-auto flex w-[460px] max-w-full flex-col items-center gap-2", children: [(0, jsx_runtime_1.jsx)("div", { className: "mb-4 flex flex-col items-center gap-3 text-center", children: (0, jsx_runtime_1.jsx)("div", { children: (0, jsx_runtime_1.jsx)("h1", { className: "text-as-primary text-xl font-bold", children: paymentType === "crypto" ? "Deposit Crypto" : "Fund with Fiat" }) }) }), (0, jsx_runtime_1.jsx)("div", { className: "relative flex w-full max-w-[calc(100vw-32px)] flex-col gap-2", children: (0, jsx_runtime_1.jsxs)("div", { className: "relative flex w-full max-w-[calc(100vw-32px)] flex-col gap-2", children: [paymentType === "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(useAnyspendFlow_1.PanelView.CRYPTO_PAYMENT_METHOD), onSelectFiatPaymentMethod: () => setActivePanel(useAnyspendFlow_1.PanelView.FIAT_PAYMENT_METHOD), anyspendQuote: anyspendQuote })) : ((0, jsx_runtime_1.jsx)(react_2.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: srcAmount, setSrcAmountOnRamp: setSrcAmount, selectedPaymentMethod: selectedFiatPaymentMethod, setActivePanel: setActivePanel, _recipientAddress: recipientAddress, destinationToken: anyspend_1.B3_TOKEN, destinationChainId: chains_1.base.id, destinationAmount: dstAmount, onDestinationTokenChange: () => { }, onDestinationChainChange: () => { }, fiatPaymentMethodIndex: useAnyspendFlow_1.PanelView.FIAT_PAYMENT_METHOD, recipientSelectionPanelIndex: useAnyspendFlow_1.PanelView.RECIPIENT_SELECTION }) })), (0, jsx_runtime_1.jsx)("div", { className: (0, cn_1.cn)("relative -my-1 flex h-0 items-center justify-center", paymentType === "fiat" && "hidden"), children: (0, jsx_runtime_1.jsx)(react_1.Button, { variant: "ghost", className: (0, cn_1.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: (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" }) }) }) }), paymentType === "crypto" && ((0, jsx_runtime_1.jsx)(CryptoReceiveSection_1.CryptoReceiveSection, { isDepositMode: false, isBuyMode: true, selectedRecipientAddress: recipientAddress, recipientName: recipientName || undefined, onSelectRecipient: () => setActivePanel(useAnyspendFlow_1.PanelView.RECIPIENT_SELECTION), dstAmount: dstAmount, dstToken: anyspend_1.B3_TOKEN, selectedDstChainId: chains_1.base.id, setSelectedDstChainId: () => { }, setSelectedDstToken: () => { }, onChangeDstAmount: value => {
|
|
128
|
+
setIsSrcInputDirty(false);
|
|
129
|
+
setSrcAmount(value);
|
|
130
|
+
}, anyspendQuote: anyspendQuote }))] }) }), (0, jsx_runtime_1.jsx)(ErrorSection_1.ErrorSection, { error: getAnyspendQuoteError }), (0, jsx_runtime_1.jsx)(react_2.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_1.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 }) }), mainFooter ? mainFooter : null] }));
|
|
125
131
|
// Handle crypto order creation
|
|
126
132
|
const handleCryptoOrder = async () => {
|
|
127
133
|
try {
|
|
@@ -129,7 +135,10 @@ function AnySpendDepositHypeInner({ loadOrder, mode = "modal", recipientAddress,
|
|
|
129
135
|
(0, invariant_1.default)(selectedRecipientAddress, "Recipient address is not found");
|
|
130
136
|
(0, invariant_1.default)(depositContractAddress, "Deposit contract address is not found");
|
|
131
137
|
const srcAmountBigInt = BigInt(activeInputAmountInWei);
|
|
132
|
-
|
|
138
|
+
// TODO: temp subtract 3% for slippage
|
|
139
|
+
const originalDepositAmountWei = anyspendQuote.data?.currencyOut?.amount || "0";
|
|
140
|
+
const depositAmountWei = ((BigInt(originalDepositAmountWei) * BigInt(100 - SLIPPAGE_PERCENT)) /
|
|
141
|
+
BigInt(100)).toString();
|
|
133
142
|
const encodedData = generateEncodedDataForDepositHype(depositAmountWei, selectedRecipientAddress);
|
|
134
143
|
createOrder({
|
|
135
144
|
recipientAddress: selectedRecipientAddress,
|
|
@@ -144,7 +153,7 @@ function AnySpendDepositHypeInner({ loadOrder, mode = "modal", recipientAddress,
|
|
|
144
153
|
amount: depositAmountWei,
|
|
145
154
|
data: encodedData,
|
|
146
155
|
to: depositContractAddress,
|
|
147
|
-
action:
|
|
156
|
+
action: anyspend_1.DEPOSIT_HYPE_ACTION,
|
|
148
157
|
},
|
|
149
158
|
});
|
|
150
159
|
}
|
|
@@ -206,7 +215,7 @@ function AnySpendDepositHypeInner({ loadOrder, mode = "modal", recipientAddress,
|
|
|
206
215
|
amount: depositAmountWei,
|
|
207
216
|
data: encodedData,
|
|
208
217
|
to: depositContractAddress,
|
|
209
|
-
action:
|
|
218
|
+
action: anyspend_1.DEPOSIT_HYPE_ACTION,
|
|
210
219
|
},
|
|
211
220
|
});
|
|
212
221
|
}
|
|
@@ -216,7 +225,8 @@ function AnySpendDepositHypeInner({ loadOrder, mode = "modal", recipientAddress,
|
|
|
216
225
|
}
|
|
217
226
|
};
|
|
218
227
|
// Order details view
|
|
219
|
-
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, cryptoPaymentMethod: paymentType === "fiat" ? CryptoPaymentMethod_1.CryptoPaymentMethodType.NONE : selectedCryptoPaymentMethod, onBack: () => {
|
|
228
|
+
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, selectedCryptoPaymentMethod: selectedCryptoPaymentMethod }), (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: paymentType === "fiat" ? CryptoPaymentMethod_1.CryptoPaymentMethodType.NONE : selectedCryptoPaymentMethod, onBack: () => {
|
|
229
|
+
setOrderId(undefined);
|
|
220
230
|
setActivePanel(useAnyspendFlow_1.PanelView.MAIN);
|
|
221
231
|
onSuccess?.();
|
|
222
232
|
} })] })) }) }));
|
|
@@ -250,10 +260,7 @@ function AnySpendDepositHypeInner({ loadOrder, mode = "modal", recipientAddress,
|
|
|
250
260
|
center: { x: 0, opacity: 1 },
|
|
251
261
|
exit: { x: -300, opacity: 0 },
|
|
252
262
|
}, transition: { type: "spring", stiffness: 300, damping: 30 }, children: [
|
|
253
|
-
(0, jsx_runtime_1.jsx)("div", { className: (0, cn_1.cn)(mode === "page" && "p-6"), children:
|
|
254
|
-
setIsSrcInputDirty(false);
|
|
255
|
-
setSrcAmount(value);
|
|
256
|
-
}, anyspendQuote: anyspendQuote }))] }) }), (0, jsx_runtime_1.jsx)(ErrorSection_1.ErrorSection, { error: getAnyspendQuoteError }), (0, jsx_runtime_1.jsx)(react_2.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_1.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 }) })] }) }, "main-view"),
|
|
263
|
+
(0, jsx_runtime_1.jsx)("div", { className: (0, cn_1.cn)(mode === "page" && "p-6"), children: mainView }, "main-view"),
|
|
257
264
|
(0, jsx_runtime_1.jsx)("div", { className: (0, cn_1.cn)(mode === "page" && "p-6"), children: cryptoPaymentMethodView }, "crypto-payment-method-view"),
|
|
258
265
|
(0, jsx_runtime_1.jsx)("div", { className: (0, cn_1.cn)(mode === "page" && "p-6"), children: fiatPaymentMethodView }, "fiat-payment-method-view"),
|
|
259
266
|
(0, jsx_runtime_1.jsx)("div", { className: (0, cn_1.cn)(mode === "page" && "p-6"), children: recipientSelectionView }, "recipient-selection-view"),
|
|
@@ -1,17 +1,23 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
"use client";
|
|
3
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
|
+
};
|
|
3
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
7
|
exports.default = ConnectWalletPayment;
|
|
5
8
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
6
9
|
const anyspend_1 = require("../../../../anyspend");
|
|
7
10
|
const react_1 = require("../../../../global-account/react");
|
|
11
|
+
const centerTruncate_1 = __importDefault(require("../../../../shared/utils/centerTruncate"));
|
|
8
12
|
const number_1 = require("../../../../shared/utils/number");
|
|
9
13
|
const framer_motion_1 = require("framer-motion");
|
|
10
14
|
const lucide_react_1 = require("lucide-react");
|
|
15
|
+
const wagmi_1 = require("wagmi");
|
|
11
16
|
const OrderDetailsCollapsible_1 = require("./OrderDetailsCollapsible");
|
|
12
17
|
function ConnectWalletPayment({ order, onPayment, txLoading, isSwitchingOrExecuting, phantomWalletAddress, tournament, nft, }) {
|
|
13
18
|
const profile = (0, react_1.useProfile)({ address: order.recipientAddress });
|
|
14
19
|
const recipientName = profile.data?.name?.replace(/\.b3\.fun/g, "");
|
|
20
|
+
const { address: connectedAddress } = (0, wagmi_1.useAccount)();
|
|
15
21
|
const srcToken = order.metadata.srcToken;
|
|
16
22
|
const dstToken = order.metadata.dstToken;
|
|
17
23
|
const expectedDstAmount = order.type === "mint_nft" ||
|
|
@@ -26,5 +32,7 @@ function ConnectWalletPayment({ order, onPayment, txLoading, isSwitchingOrExecut
|
|
|
26
32
|
}
|
|
27
33
|
return ((0, jsx_runtime_1.jsx)("div", { className: "flex w-full flex-col items-center gap-6", children: (0, jsx_runtime_1.jsxs)(framer_motion_1.motion.div, { initial: { opacity: 0, y: 20 }, animate: { opacity: 1, y: 0 }, transition: { delay: 0.5 }, className: "flex w-full flex-col items-center gap-2", children: [(0, jsx_runtime_1.jsx)(react_1.ShinyButton, { accentColor: "hsl(var(--as-brand))", textColor: "text-white", className: "flex w-5/6 max-w-[400px] items-center gap-2 sm:px-0", disabled: txLoading || isSwitchingOrExecuting, onClick: onPayment, children: txLoading ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: ["Transaction Pending", (0, jsx_runtime_1.jsx)(lucide_react_1.Loader2, { className: "ml-2 h-5 w-5 animate-spin" })] })) : ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("span", { className: "whitespace-nowrap pl-4 text-lg md:text-sm", children: order.srcChain === anyspend_1.RELAY_SOLANA_MAINNET_CHAIN_ID && phantomWalletAddress
|
|
28
34
|
? "Pay from Phantom Wallet"
|
|
29
|
-
: "Pay from Connected Wallet" }), (0, jsx_runtime_1.jsx)(lucide_react_1.ChevronRight, { className: "h-4 w-4" })] })) }), (0, jsx_runtime_1.
|
|
35
|
+
: "Pay from Connected Wallet" }), (0, jsx_runtime_1.jsx)(lucide_react_1.ChevronRight, { className: "h-4 w-4" })] })) }), (0, jsx_runtime_1.jsxs)("span", { className: "label-style text-as-primary/50 text-xs", children: ["Connected to:", " ", order.srcChain === anyspend_1.RELAY_SOLANA_MAINNET_CHAIN_ID && phantomWalletAddress
|
|
36
|
+
? (0, centerTruncate_1.default)(phantomWalletAddress, 6)
|
|
37
|
+
: (0, centerTruncate_1.default)(connectedAddress || "")] }), (0, jsx_runtime_1.jsx)("div", { className: "mt-4", children: (0, jsx_runtime_1.jsx)(OrderDetailsCollapsible_1.OrderDetailsCollapsible, { order: order, dstToken: dstToken, tournament: tournament, nft: nft, recipientName: recipientName, formattedExpectedDstAmount: formattedExpectedDstAmount }) })] }) }));
|
|
30
38
|
}
|