@b3dotfun/sdk 0.0.29-alpha.0 → 0.0.29-alpha.2
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 +1 -1
- 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 +1 -1
- package/dist/cjs/anyspend/react/components/AnyspendDepositHype.d.ts +4 -2
- package/dist/cjs/anyspend/react/components/AnyspendDepositHype.js +9 -8
- 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/bondkit/abis/BondkitTokenABI.d.ts +2 -5
- package/dist/cjs/bondkit/abis/BondkitTokenABI.js +2 -3
- package/dist/cjs/global-account/react/stores/useModalStore.d.ts +4 -2
- 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 +1 -1
- 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 +1 -1
- package/dist/esm/anyspend/react/components/AnyspendDepositHype.d.ts +4 -2
- package/dist/esm/anyspend/react/components/AnyspendDepositHype.js +11 -10
- 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/bondkit/abis/BondkitTokenABI.d.ts +2 -5
- package/dist/esm/bondkit/abis/BondkitTokenABI.js +2 -3
- package/dist/esm/global-account/react/stores/useModalStore.d.ts +4 -2
- 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/bondkit/abis/BondkitTokenABI.d.ts +2 -5
- package/dist/types/global-account/react/stores/useModalStore.d.ts +4 -2
- package/package.json +1 -1
- package/src/anyspend/constants/index.ts +2 -0
- package/src/anyspend/react/components/AnySpend.tsx +1 -1
- package/src/anyspend/react/components/AnySpendBondKit.tsx +28 -28
- package/src/anyspend/react/components/AnySpendCustom.tsx +1 -1
- package/src/anyspend/react/components/AnyspendDepositHype.tsx +131 -129
- package/src/anyspend/react/components/common/OrderDetailsCollapsible.tsx +10 -4
- package/src/anyspend/react/components/common/OrderStatus.tsx +9 -2
- package/src/bondkit/abis/BondkitTokenABI.ts +2 -3
- package/src/global-account/react/stores/useModalStore.ts +4 -2
- 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,7 +657,7 @@ 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
|
|
@@ -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 }));
|
|
@@ -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
|
|
@@ -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;
|
|
@@ -40,7 +40,7 @@ function AnySpendDepositHype(props) {
|
|
|
40
40
|
const fingerprintConfig = (0, AnySpendFingerprintWrapper_1.getFingerprintConfig)();
|
|
41
41
|
return ((0, jsx_runtime_1.jsx)(AnySpendFingerprintWrapper_1.AnySpendFingerprintWrapper, { fingerprint: fingerprintConfig, children: (0, jsx_runtime_1.jsx)(AnySpendDepositHypeInner, { ...props }) }));
|
|
42
42
|
}
|
|
43
|
-
function AnySpendDepositHypeInner({ loadOrder, mode = "modal", recipientAddress, paymentType = "crypto", sourceTokenAddress, sourceTokenChainId, onSuccess, depositContractAddress, }) {
|
|
43
|
+
function AnySpendDepositHypeInner({ loadOrder, mode = "modal", recipientAddress, paymentType = "crypto", sourceTokenAddress, sourceTokenChainId, onSuccess, depositContractAddress, mainFooter, }) {
|
|
44
44
|
// Use shared flow hook
|
|
45
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
46
|
paymentType,
|
|
@@ -122,6 +122,10 @@ function AnySpendDepositHypeInner({ loadOrder, mode = "modal", recipientAddress,
|
|
|
122
122
|
await handleFiatOrder();
|
|
123
123
|
}
|
|
124
124
|
};
|
|
125
|
+
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 }) })), (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 => {
|
|
126
|
+
setIsSrcInputDirty(false);
|
|
127
|
+
setSrcAmount(value);
|
|
128
|
+
}, 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
129
|
// Handle crypto order creation
|
|
126
130
|
const handleCryptoOrder = async () => {
|
|
127
131
|
try {
|
|
@@ -144,7 +148,7 @@ function AnySpendDepositHypeInner({ loadOrder, mode = "modal", recipientAddress,
|
|
|
144
148
|
amount: depositAmountWei,
|
|
145
149
|
data: encodedData,
|
|
146
150
|
to: depositContractAddress,
|
|
147
|
-
action:
|
|
151
|
+
action: anyspend_1.DEPOSIT_HYPE_ACTION,
|
|
148
152
|
},
|
|
149
153
|
});
|
|
150
154
|
}
|
|
@@ -206,7 +210,7 @@ function AnySpendDepositHypeInner({ loadOrder, mode = "modal", recipientAddress,
|
|
|
206
210
|
amount: depositAmountWei,
|
|
207
211
|
data: encodedData,
|
|
208
212
|
to: depositContractAddress,
|
|
209
|
-
action:
|
|
213
|
+
action: anyspend_1.DEPOSIT_HYPE_ACTION,
|
|
210
214
|
},
|
|
211
215
|
});
|
|
212
216
|
}
|
|
@@ -216,7 +220,7 @@ function AnySpendDepositHypeInner({ loadOrder, mode = "modal", recipientAddress,
|
|
|
216
220
|
}
|
|
217
221
|
};
|
|
218
222
|
// 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: () => {
|
|
223
|
+
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: () => {
|
|
220
224
|
setActivePanel(useAnyspendFlow_1.PanelView.MAIN);
|
|
221
225
|
onSuccess?.();
|
|
222
226
|
} })] })) }) }));
|
|
@@ -250,10 +254,7 @@ function AnySpendDepositHypeInner({ loadOrder, mode = "modal", recipientAddress,
|
|
|
250
254
|
center: { x: 0, opacity: 1 },
|
|
251
255
|
exit: { x: -300, opacity: 0 },
|
|
252
256
|
}, 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"),
|
|
257
|
+
(0, jsx_runtime_1.jsx)("div", { className: (0, cn_1.cn)(mode === "page" && "p-6"), children: mainView }, "main-view"),
|
|
257
258
|
(0, jsx_runtime_1.jsx)("div", { className: (0, cn_1.cn)(mode === "page" && "p-6"), children: cryptoPaymentMethodView }, "crypto-payment-method-view"),
|
|
258
259
|
(0, jsx_runtime_1.jsx)("div", { className: (0, cn_1.cn)(mode === "page" && "p-6"), children: fiatPaymentMethodView }, "fiat-payment-method-view"),
|
|
259
260
|
(0, jsx_runtime_1.jsx)("div", { className: (0, cn_1.cn)(mode === "page" && "p-6"), children: recipientSelectionView }, "recipient-selection-view"),
|
|
@@ -35,8 +35,10 @@ exports.OrderDetailsCollapsible = (0, react_3.memo)(function OrderDetailsCollaps
|
|
|
35
35
|
: order.type === "fund_tournament"
|
|
36
36
|
? "Fund tournament"
|
|
37
37
|
: order.type === "custom"
|
|
38
|
-
? order.metadata.action
|
|
39
|
-
?
|
|
40
|
-
:
|
|
41
|
-
|
|
38
|
+
? order.metadata.action === anyspend_1.DEPOSIT_HYPE_ACTION
|
|
39
|
+
? "Deposit HYPE"
|
|
40
|
+
: order.metadata.action
|
|
41
|
+
? (0, anyspend_1.capitalizeFirstLetter)(order.metadata.action)
|
|
42
|
+
: "Contract execution"
|
|
43
|
+
: "" }), (0, jsx_runtime_1.jsxs)("div", { className: "flex items-end gap-2", children: [order.type === "swap" ? (`~${finalFormattedExpectedDstAmount} ${dstToken.symbol}`) : order.type === "mint_nft" ? ((0, jsx_runtime_1.jsxs)("div", { className: "flex items-center gap-2", children: [(0, jsx_runtime_1.jsx)("img", { src: nft?.imageUrl, alt: nft?.name || "NFT", className: "h-5 w-5" }), (0, jsx_runtime_1.jsx)("div", { children: nft?.name || "NFT" })] })) : order.type === "join_tournament" || order.type === "fund_tournament" ? ((0, jsx_runtime_1.jsxs)("div", { className: "flex items-center gap-2", children: [(0, jsx_runtime_1.jsx)("img", { src: tournament?.imageUrl, alt: tournament?.name || "Tournament", className: "h-5 w-5" }), (0, jsx_runtime_1.jsx)("div", { children: tournament?.name || "Tournament" })] })) : order.type === "custom" && order.metadata.action === anyspend_1.DEPOSIT_HYPE_ACTION ? ((0, jsx_runtime_1.jsx)("div", { className: "flex items-center gap-2", children: (0, jsx_runtime_1.jsxs)("div", { children: [(0, number_1.formatTokenAmount)(BigInt(order.payload.amount), dstToken.decimals), " HYPE"] }) })) : null, (0, jsx_runtime_1.jsxs)("div", { className: "text-as-primary/50 flex items-center gap-2", children: [(0, jsx_runtime_1.jsxs)("span", { children: ["on ", order.dstChain !== chains_1.b3.id && (0, anyspend_1.getChainName)(order.dstChain)] }), (0, jsx_runtime_1.jsx)("img", { src: anyspend_1.ALL_CHAINS[order.dstChain].logoUrl, alt: (0, anyspend_1.getChainName)(order.dstChain), className: (0, utils_1.cn)("h-3", order.dstChain !== chains_1.b3.id && "w-3 rounded-full", order.dstChain === chains_1.b3.id && "h-4") })] })] })] }), (0, jsx_runtime_1.jsx)("div", { className: "divider w-full" }), (0, jsx_runtime_1.jsxs)("div", { className: "flex w-full justify-between gap-4", children: [(0, jsx_runtime_1.jsx)("div", { className: "text-as-tertiarry", children: showTotal ? "Total (included fee)" : "Order ID" }), (0, jsx_runtime_1.jsx)("div", { className: "text-as-primary overflow-hidden text-ellipsis whitespace-nowrap", children: showTotal && totalAmount ? totalAmount : order.id })] })] }) })) : ((0, jsx_runtime_1.jsxs)("div", { className: "flex w-full items-center", children: [(0, jsx_runtime_1.jsx)("div", { className: "divider w-full" }), (0, jsx_runtime_1.jsx)("button", { className: "whitespace-nowrap text-sm", onClick: () => setShowOrderDetails(true), children: "Order Details" }), (0, jsx_runtime_1.jsx)(lucide_react_1.ChevronDown, { className: "text-as-primary mx-1 h-4 min-h-4 w-4 min-w-4" }), (0, jsx_runtime_1.jsx)("div", { className: "divider w-full" })] })) }));
|
|
42
44
|
});
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { components } from "../../../../anyspend/types/api";
|
|
2
|
+
import { CryptoPaymentMethodType } from "./CryptoPaymentMethod";
|
|
2
3
|
export declare const OrderStatus: import("react").NamedExoticComponent<{
|
|
3
4
|
order: components["schemas"]["Order"];
|
|
5
|
+
selectedCryptoPaymentMethod?: CryptoPaymentMethodType;
|
|
4
6
|
}>;
|
|
@@ -7,11 +7,11 @@ const react_1 = require("../../../../shared/react");
|
|
|
7
7
|
const lucide_react_1 = require("lucide-react");
|
|
8
8
|
const react_2 = require("react");
|
|
9
9
|
const StepProgress_1 = require("./StepProgress");
|
|
10
|
-
exports.OrderStatus = (0, react_2.memo)(function OrderStatus({ order }) {
|
|
10
|
+
exports.OrderStatus = (0, react_2.memo)(function OrderStatus({ order, selectedCryptoPaymentMethod, }) {
|
|
11
11
|
const isComplete = order.status === "executed";
|
|
12
12
|
const { text, status: displayStatus, description } = (0, anyspend_1.getStatusDisplay)(order);
|
|
13
13
|
const searchParams = (0, react_1.useSearchParams)();
|
|
14
|
-
const cryptoPaymentMethod = searchParams.get("cryptoPaymentMethod");
|
|
14
|
+
const cryptoPaymentMethod = selectedCryptoPaymentMethod || searchParams.get("cryptoPaymentMethod");
|
|
15
15
|
console.log("OrderStatus", displayStatus);
|
|
16
16
|
console.log("OrderStatus", order);
|
|
17
17
|
const paymentSteps = [
|
|
@@ -627,7 +627,7 @@ export declare const BondkitTokenABI: readonly [{
|
|
|
627
627
|
}];
|
|
628
628
|
readonly name: "buy";
|
|
629
629
|
readonly outputs: readonly [];
|
|
630
|
-
readonly stateMutability: "
|
|
630
|
+
readonly stateMutability: "nonpayable";
|
|
631
631
|
readonly type: "function";
|
|
632
632
|
}, {
|
|
633
633
|
readonly inputs: readonly [{
|
|
@@ -645,7 +645,7 @@ export declare const BondkitTokenABI: readonly [{
|
|
|
645
645
|
}];
|
|
646
646
|
readonly name: "buyFor";
|
|
647
647
|
readonly outputs: readonly [];
|
|
648
|
-
readonly stateMutability: "
|
|
648
|
+
readonly stateMutability: "nonpayable";
|
|
649
649
|
readonly type: "function";
|
|
650
650
|
}, {
|
|
651
651
|
readonly inputs: readonly [];
|
|
@@ -1242,7 +1242,4 @@ export declare const BondkitTokenABI: readonly [{
|
|
|
1242
1242
|
}];
|
|
1243
1243
|
readonly stateMutability: "view";
|
|
1244
1244
|
readonly type: "function";
|
|
1245
|
-
}, {
|
|
1246
|
-
readonly stateMutability: "payable";
|
|
1247
|
-
readonly type: "receive";
|
|
1248
1245
|
}];
|
|
@@ -326,7 +326,7 @@ exports.BondkitTokenABI = [
|
|
|
326
326
|
],
|
|
327
327
|
name: "buy",
|
|
328
328
|
outputs: [],
|
|
329
|
-
stateMutability: "
|
|
329
|
+
stateMutability: "nonpayable",
|
|
330
330
|
type: "function",
|
|
331
331
|
},
|
|
332
332
|
{
|
|
@@ -337,7 +337,7 @@ exports.BondkitTokenABI = [
|
|
|
337
337
|
],
|
|
338
338
|
name: "buyFor",
|
|
339
339
|
outputs: [],
|
|
340
|
-
stateMutability: "
|
|
340
|
+
stateMutability: "nonpayable",
|
|
341
341
|
type: "function",
|
|
342
342
|
},
|
|
343
343
|
{
|
|
@@ -704,5 +704,4 @@ exports.BondkitTokenABI = [
|
|
|
704
704
|
stateMutability: "view",
|
|
705
705
|
type: "function",
|
|
706
706
|
},
|
|
707
|
-
{ stateMutability: "payable", type: "receive" },
|
|
708
707
|
];
|
|
@@ -273,8 +273,8 @@ export interface AnySpendBondKitProps extends BaseModalProps {
|
|
|
273
273
|
imageUrl?: string;
|
|
274
274
|
/** Token name to display */
|
|
275
275
|
tokenName?: string;
|
|
276
|
-
/** Optional pre-filled
|
|
277
|
-
|
|
276
|
+
/** Optional pre-filled B3 amount */
|
|
277
|
+
b3Amount?: string;
|
|
278
278
|
/** Callback function called when purchase is successful */
|
|
279
279
|
onSuccess?: (txHash?: string) => void;
|
|
280
280
|
}
|
|
@@ -300,6 +300,8 @@ export interface AnySpendDepositHypeProps extends BaseModalProps {
|
|
|
300
300
|
paymentType?: "crypto" | "fiat";
|
|
301
301
|
/** Deposit contract address */
|
|
302
302
|
depositContractAddress: string;
|
|
303
|
+
/** Main footer */
|
|
304
|
+
mainFooter?: React.ReactNode;
|
|
303
305
|
/** Callback function called when the deposit is successful */
|
|
304
306
|
onSuccess?: () => void;
|
|
305
307
|
}
|
|
@@ -650,7 +650,7 @@ function AnySpendInner({ destinationTokenAddress, destinationTokenChainId, mode
|
|
|
650
650
|
window.scrollTo({ top: 0, behavior: "smooth" });
|
|
651
651
|
}, [activePanel]);
|
|
652
652
|
const historyView = (_jsx("div", { className: "mx-auto flex w-[560px] max-w-full flex-col items-center", children: _jsx(OrderHistory, { mode: mode, onBack: () => setActivePanel(PanelView.MAIN), onSelectOrder: onSelectOrder }) }));
|
|
653
|
-
const orderDetailsView = (_jsx("div", { className: "mx-auto w-[460px] max-w-full", children: _jsx("div", { className: "relative flex flex-col gap-4", children: oat && (_jsxs(_Fragment, { children: [_jsx(OrderStatus, { order: oat.data.order }), _jsx(OrderDetails, { mode: mode, order: oat.data.order, depositTxs: oat.data.depositTxs, relayTx: oat.data.relayTx, executeTx: oat.data.executeTx, refundTxs: oat.data.refundTxs, onBack: () => {
|
|
653
|
+
const orderDetailsView = (_jsx("div", { className: "mx-auto w-[460px] max-w-full", children: _jsx("div", { className: "relative flex flex-col gap-4", children: oat && (_jsxs(_Fragment, { children: [_jsx(OrderStatus, { order: oat.data.order, selectedCryptoPaymentMethod: selectedCryptoPaymentMethod }), _jsx(OrderDetails, { mode: mode, order: oat.data.order, depositTxs: oat.data.depositTxs, relayTx: oat.data.relayTx, executeTx: oat.data.executeTx, refundTxs: oat.data.refundTxs, onBack: () => {
|
|
654
654
|
setOrderId(undefined);
|
|
655
655
|
setActivePanel(PanelView.MAIN);
|
|
656
656
|
setSelectedCryptoPaymentMethod(CryptoPaymentMethodType.NONE); // Reset payment method when going back
|
|
@@ -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;
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { BondkitToken } from "../../../bondkit/index.js";
|
|
3
2
|
import { Button, GlareCardRounded, Input, StyleRoot, useHasMounted, useTokenData, } from "../../../global-account/react/index.js";
|
|
4
3
|
import { baseMainnet } from "../../../shared/constants/chains/supported.js";
|
|
5
4
|
import { motion } from "motion/react";
|
|
6
5
|
import { useEffect, useMemo, useState } from "react";
|
|
7
6
|
import { createPublicClient, encodeFunctionData, formatEther, http, parseEther } from "viem";
|
|
8
|
-
import {
|
|
7
|
+
import { BondkitToken, BondkitTokenABI } from "../../../bondkit/index.js";
|
|
9
8
|
import { AnySpendCustom } from "./AnySpendCustom.js";
|
|
10
9
|
// Debounce utility function
|
|
11
10
|
function debounce(func, wait) {
|
|
@@ -21,11 +20,11 @@ function formatNumberWithCommas(x) {
|
|
|
21
20
|
parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, ",");
|
|
22
21
|
return parts.join(".");
|
|
23
22
|
}
|
|
24
|
-
export function AnySpendBondKit({ mode = "modal", recipientAddress, contractAddress, minTokensOut = "0", imageUrl,
|
|
23
|
+
export function AnySpendBondKit({ mode = "modal", recipientAddress, contractAddress, minTokensOut = "0", imageUrl, b3Amount: initialB3Amount, onSuccess, }) {
|
|
25
24
|
const hasMounted = useHasMounted();
|
|
26
|
-
const [showAmountPrompt, setShowAmountPrompt] = useState(!
|
|
27
|
-
const [
|
|
28
|
-
const [isAmountValid, setIsAmountValid] = useState(!!
|
|
25
|
+
const [showAmountPrompt, setShowAmountPrompt] = useState(!initialB3Amount);
|
|
26
|
+
const [b3Amount, setB3Amount] = useState(initialB3Amount || "");
|
|
27
|
+
const [isAmountValid, setIsAmountValid] = useState(!!initialB3Amount);
|
|
29
28
|
const [validationError, setValidationError] = useState("");
|
|
30
29
|
const [tokenName, setTokenName] = useState("");
|
|
31
30
|
const [tokenSymbol, setTokenSymbol] = useState("");
|
|
@@ -57,12 +56,12 @@ export function AnySpendBondKit({ mode = "modal", recipientAddress, contractAddr
|
|
|
57
56
|
const [name, symbol] = await Promise.all([
|
|
58
57
|
basePublicClient.readContract({
|
|
59
58
|
address: contractAddress,
|
|
60
|
-
abi:
|
|
59
|
+
abi: BondkitTokenABI,
|
|
61
60
|
functionName: "name",
|
|
62
61
|
}),
|
|
63
62
|
basePublicClient.readContract({
|
|
64
63
|
address: contractAddress,
|
|
65
|
-
abi:
|
|
64
|
+
abi: BondkitTokenABI,
|
|
66
65
|
functionName: "symbol",
|
|
67
66
|
}),
|
|
68
67
|
]);
|
|
@@ -79,8 +78,8 @@ export function AnySpendBondKit({ mode = "modal", recipientAddress, contractAddr
|
|
|
79
78
|
fetchTokenName();
|
|
80
79
|
}
|
|
81
80
|
}, [contractAddress, basePublicClient]);
|
|
82
|
-
// Get
|
|
83
|
-
const { data: tokenData, isError: isTokenError, isLoading, } = useTokenData(baseMainnet.id, "
|
|
81
|
+
// Get b3 token data
|
|
82
|
+
const { data: tokenData, isError: isTokenError, isLoading, } = useTokenData(baseMainnet.id, "0xB3B32F9f8827D4634fE7d973Fa1034Ec9fdDB3B3");
|
|
84
83
|
// Convert token data to AnySpend Token type
|
|
85
84
|
const dstToken = useMemo(() => {
|
|
86
85
|
if (!tokenData)
|
|
@@ -116,16 +115,16 @@ export function AnySpendBondKit({ mode = "modal", recipientAddress, contractAddr
|
|
|
116
115
|
setIsLoadingQuote(false);
|
|
117
116
|
}
|
|
118
117
|
}, 500), [bondkitTokenClient]);
|
|
119
|
-
// Fetch initial quote if
|
|
118
|
+
// Fetch initial quote if b3Amount is provided
|
|
120
119
|
useEffect(() => {
|
|
121
|
-
if (
|
|
122
|
-
debouncedGetQuote(
|
|
120
|
+
if (initialB3Amount && bondkitTokenClient) {
|
|
121
|
+
debouncedGetQuote(initialB3Amount);
|
|
123
122
|
}
|
|
124
|
-
}, [
|
|
123
|
+
}, [initialB3Amount, bondkitTokenClient, debouncedGetQuote]);
|
|
125
124
|
const validateAndSetAmount = (value) => {
|
|
126
125
|
// Allow empty input
|
|
127
126
|
if (value === "") {
|
|
128
|
-
|
|
127
|
+
setB3Amount("");
|
|
129
128
|
setIsAmountValid(false);
|
|
130
129
|
setValidationError("");
|
|
131
130
|
setQuote(null);
|
|
@@ -141,14 +140,14 @@ export function AnySpendBondKit({ mode = "modal", recipientAddress, contractAddr
|
|
|
141
140
|
if ((value.match(/\./g) || []).length > 1) {
|
|
142
141
|
return;
|
|
143
142
|
}
|
|
144
|
-
// Prevent more than 18 decimal places (
|
|
143
|
+
// Prevent more than 18 decimal places (B3 precision)
|
|
145
144
|
const parts = value.split(".");
|
|
146
145
|
if (parts[1] && parts[1].length > 18) {
|
|
147
146
|
return;
|
|
148
147
|
}
|
|
149
148
|
// Clean the input - remove leading zeros if not decimal
|
|
150
149
|
const cleanedValue = value.startsWith("0") && !value.startsWith("0.") ? value.replace(/^0+/, "0") : value;
|
|
151
|
-
|
|
150
|
+
setB3Amount(cleanedValue);
|
|
152
151
|
try {
|
|
153
152
|
const parsedAmount = parseEther(cleanedValue);
|
|
154
153
|
if (parsedAmount <= BigInt(0)) {
|
|
@@ -166,7 +165,7 @@ export function AnySpendBondKit({ mode = "modal", recipientAddress, contractAddr
|
|
|
166
165
|
setValidationError("Please enter a valid amount");
|
|
167
166
|
}
|
|
168
167
|
};
|
|
169
|
-
const header = () => (_jsx("div", { className: "bg-as-surface-primary w-full px-6 py-4", children: _jsxs("div", { className: "flex w-full flex-col items-center space-y-6", children: [_jsxs("h2", { className: "text-[28px] font-bold", children: ["Buy ", tokenName, " (", tokenSymbol, ")"] }), _jsxs("div", { className: "flex w-full flex-col items-center space-y-2", children: [_jsxs("span", { className: "text-[28px] font-bold", children: [
|
|
168
|
+
const header = () => (_jsx("div", { className: "bg-as-surface-primary w-full px-6 py-4", children: _jsxs("div", { className: "flex w-full flex-col items-center space-y-6", children: [_jsxs("h2", { className: "text-[28px] font-bold", children: ["Buy ", tokenName, " (", tokenSymbol, ")"] }), _jsxs("div", { className: "flex w-full flex-col items-center space-y-2", children: [_jsxs("span", { className: "text-[28px] font-bold", children: [b3Amount, " B3"] }), quote && (_jsxs("span", { className: "text-lg", children: ["\u2248 ", formatNumberWithCommas(parseFloat(quote).toFixed(4)), " ", tokenSymbol] }))] })] }) }));
|
|
170
169
|
// Show loading state while fetching token data
|
|
171
170
|
if (isLoading) {
|
|
172
171
|
return (_jsx(StyleRoot, { children: _jsx("div", { className: "b3-root b3-modal bg-b3-react-background flex w-full flex-col items-center p-8", children: _jsx("p", { className: "text-as-primary/70 text-center text-sm", children: "Loading payment information..." }) }) }));
|
|
@@ -188,18 +187,18 @@ export function AnySpendBondKit({ mode = "modal", recipientAddress, contractAddr
|
|
|
188
187
|
opacity: hasMounted ? 1 : 0,
|
|
189
188
|
y: hasMounted ? 0 : 20,
|
|
190
189
|
filter: hasMounted ? "blur(0px)" : "blur(10px)",
|
|
191
|
-
}, transition: { duration: 0.3, delay: 0.2, ease: "easeInOut" }, className: "bg-b3-react-background w-full p-6", children: _jsxs("div", { className: "space-y-4", children: [_jsx("div", { className: "flex items-center justify-between", children: _jsx("p", { className: "text-as-primary/70 text-sm font-medium", children: "
|
|
192
|
-
if (isAmountValid &&
|
|
190
|
+
}, transition: { duration: 0.3, delay: 0.2, ease: "easeInOut" }, className: "bg-b3-react-background w-full p-6", children: _jsxs("div", { className: "space-y-4", children: [_jsx("div", { className: "flex items-center justify-between", children: _jsx("p", { className: "text-as-primary/70 text-sm font-medium", children: "B3 Amount" }) }), _jsx("div", { className: "relative", children: _jsx(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 && _jsx("p", { className: "text-as-red text-sm", children: validationError }), _jsxs("div", { className: "bg-as-on-surface-2/30 rounded-lg border border-white/10 p-4 backdrop-blur-sm", children: [_jsxs("div", { className: "flex items-center justify-between", children: [_jsx("span", { className: "text-as-primary/70 text-sm font-medium", children: "Total Cost:" }), _jsx("div", { className: "flex items-center gap-2", children: _jsxs("span", { className: "text-as-primary text-lg font-bold", children: [b3Amount || "0", " B3"] }) })] }), isLoadingQuote ? (_jsx("div", { className: "mt-2 text-center", children: _jsx("span", { className: "text-as-primary/70 text-sm", children: "Calculating tokens..." }) })) : quote ? (_jsxs("div", { className: "mt-2 flex items-center justify-between", children: [_jsx("span", { className: "text-as-primary/70 text-sm font-medium", children: "You'll receive:" }), _jsxs("span", { className: "text-as-primary text-sm font-medium", children: ["\u2248 ", formatNumberWithCommas(parseFloat(quote).toFixed(4)), " ", tokenSymbol] })] })) : null] }), _jsx(Button, { onClick: () => {
|
|
191
|
+
if (isAmountValid && b3Amount) {
|
|
193
192
|
setShowAmountPrompt(false);
|
|
194
193
|
}
|
|
195
|
-
}, disabled: !isAmountValid || !
|
|
194
|
+
}, 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" })] }) })] }) }));
|
|
196
195
|
}
|
|
197
196
|
const encodedData = encodeFunctionData({
|
|
198
|
-
abi:
|
|
197
|
+
abi: BondkitTokenABI,
|
|
199
198
|
functionName: "buyFor",
|
|
200
|
-
args: [recipientAddress, BigInt(minTokensOut)],
|
|
199
|
+
args: [recipientAddress, parseEther(b3Amount), BigInt(minTokensOut)],
|
|
201
200
|
});
|
|
202
|
-
return (_jsx(AnySpendCustom, { mode: mode, recipientAddress: recipientAddress, orderType: "custom", dstChainId: baseMainnet.id, dstToken: dstToken, dstAmount: parseEther(
|
|
201
|
+
return (_jsx(AnySpendCustom, { mode: mode, recipientAddress: recipientAddress, orderType: "custom", dstChainId: baseMainnet.id, dstToken: dstToken, dstAmount: parseEther(b3Amount).toString(), contractAddress: contractAddress, encodedData: encodedData, metadata: {
|
|
203
202
|
type: "custom",
|
|
204
203
|
action: "BondKit Buy",
|
|
205
204
|
}, header: header, onSuccess: onSuccess, showRecipient: true }));
|
|
@@ -413,7 +413,7 @@ function AnySpendCustomInner({ loadOrder, mode = "modal", activeTab: activeTabPr
|
|
|
413
413
|
const historyView = (_jsx("div", { className: cn("mx-auto flex w-full max-w-2xl flex-col items-center p-5", mode === "modal" && "bg-b3-react-background"), children: _jsx(OrderHistory, { mode: mode, onBack: () => {
|
|
414
414
|
setActivePanel(PanelView.HISTORY);
|
|
415
415
|
}, onSelectOrder: onSelectOrder }) }));
|
|
416
|
-
const orderDetailsView = (_jsxs("div", { className: cn("mx-auto flex w-full flex-col items-center gap-4", mode === "modal" && "bg-b3-react-background rounded-xl"), children: [oat && (_jsxs(_Fragment, { children: [_jsx(OrderStatusDisplay, { order: oat.data.order }), _jsx(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" ? CryptoPaymentMethodType.NONE : selectedCryptoPaymentMethod, onBack: () => {
|
|
416
|
+
const orderDetailsView = (_jsxs("div", { className: cn("mx-auto flex w-full flex-col items-center gap-4", mode === "modal" && "bg-b3-react-background rounded-xl"), children: [oat && (_jsxs(_Fragment, { children: [_jsx(OrderStatusDisplay, { order: oat.data.order, selectedCryptoPaymentMethod: selectedCryptoPaymentMethod }), _jsx(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" ? CryptoPaymentMethodType.NONE : selectedCryptoPaymentMethod, onBack: () => {
|
|
417
417
|
setOrderId(undefined);
|
|
418
418
|
setActivePanel(PanelView.CONFIRM_ORDER);
|
|
419
419
|
// Remove orderId from URL when canceling
|
|
@@ -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;
|