@b3dotfun/sdk 0.0.7-alpha.7 → 0.0.7-alpha.9
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.js +5 -2
- package/dist/cjs/anyspend/index.d.ts +1 -0
- package/dist/cjs/anyspend/index.js +1 -0
- package/dist/cjs/anyspend/react/components/AnySpendBuySpin.js +33 -33
- package/dist/cjs/anyspend/react/components/AnySpendCustom.d.ts +2 -2
- package/dist/cjs/anyspend/react/components/AnySpendCustom.js +80 -43
- package/dist/cjs/anyspend/react/components/AnySpendNFT.d.ts +3 -2
- package/dist/cjs/anyspend/react/components/AnySpendNFT.js +5 -3
- package/dist/cjs/anyspend/react/components/AnySpendStakeB3.js +4 -3
- package/dist/cjs/anyspend/react/components/AnySpendTournament.js +4 -1
- package/dist/cjs/anyspend/services/anyspend.d.ts +1 -1
- package/dist/cjs/anyspend/services/anyspend.js +1 -1
- package/dist/cjs/anyspend/types/index.d.ts +1 -0
- package/dist/cjs/anyspend/types/index.js +1 -0
- package/dist/cjs/anyspend/types/metadata.d.ts +26 -0
- package/dist/cjs/anyspend/types/metadata.js +16 -0
- package/dist/cjs/anyspend/types/nft.d.ts +1 -0
- package/dist/cjs/anyspend/types/req-res/getQuote.d.ts +11 -0
- package/dist/cjs/anyspend/types/req-res/getQuote.js +4 -1
- package/dist/cjs/anyspend/utils/orderPayload.d.ts +3 -3
- package/dist/cjs/anyspend/utils/orderPayload.js +18 -4
- package/dist/cjs/global-account/react/stores/useModalStore.d.ts +2 -0
- package/dist/esm/anyspend/constants/index.js +5 -2
- package/dist/esm/anyspend/index.d.ts +1 -0
- package/dist/esm/anyspend/index.js +1 -0
- package/dist/esm/anyspend/react/components/AnySpendBuySpin.js +5 -5
- package/dist/esm/anyspend/react/components/AnySpendCustom.d.ts +2 -2
- package/dist/esm/anyspend/react/components/AnySpendCustom.js +57 -20
- package/dist/esm/anyspend/react/components/AnySpendNFT.d.ts +3 -2
- package/dist/esm/anyspend/react/components/AnySpendNFT.js +5 -3
- package/dist/esm/anyspend/react/components/AnySpendStakeB3.js +5 -4
- package/dist/esm/anyspend/react/components/AnySpendTournament.js +4 -1
- package/dist/esm/anyspend/services/anyspend.d.ts +1 -1
- package/dist/esm/anyspend/services/anyspend.js +1 -1
- package/dist/esm/anyspend/types/index.d.ts +1 -0
- package/dist/esm/anyspend/types/index.js +1 -0
- package/dist/esm/anyspend/types/metadata.d.ts +26 -0
- package/dist/esm/anyspend/types/metadata.js +11 -0
- package/dist/esm/anyspend/types/nft.d.ts +1 -0
- package/dist/esm/anyspend/types/req-res/getQuote.d.ts +11 -0
- package/dist/esm/anyspend/types/req-res/getQuote.js +4 -1
- package/dist/esm/anyspend/utils/orderPayload.d.ts +3 -3
- package/dist/esm/anyspend/utils/orderPayload.js +19 -5
- package/dist/esm/global-account/react/stores/useModalStore.d.ts +2 -0
- package/dist/types/anyspend/index.d.ts +1 -0
- package/dist/types/anyspend/react/components/AnySpendCustom.d.ts +2 -2
- package/dist/types/anyspend/react/components/AnySpendNFT.d.ts +3 -2
- package/dist/types/anyspend/services/anyspend.d.ts +1 -1
- package/dist/types/anyspend/types/index.d.ts +1 -0
- package/dist/types/anyspend/types/metadata.d.ts +26 -0
- package/dist/types/anyspend/types/nft.d.ts +1 -0
- package/dist/types/anyspend/types/req-res/getQuote.d.ts +11 -0
- package/dist/types/anyspend/utils/orderPayload.d.ts +3 -3
- package/dist/types/global-account/react/stores/useModalStore.d.ts +2 -0
- package/package.json +1 -1
- package/src/anyspend/constants/index.ts +5 -3
- package/src/anyspend/index.ts +1 -0
- package/src/anyspend/react/components/AnySpendBuySpin.tsx +8 -7
- package/src/anyspend/react/components/AnySpendCustom.tsx +73 -24
- package/src/anyspend/react/components/AnySpendNFT.tsx +9 -4
- package/src/anyspend/react/components/AnySpendStakeB3.tsx +7 -6
- package/src/anyspend/react/components/AnySpendTournament.tsx +4 -1
- package/src/anyspend/services/anyspend.ts +2 -2
- package/src/anyspend/types/index.ts +1 -0
- package/src/anyspend/types/metadata.ts +41 -0
- package/src/anyspend/types/nft.ts +1 -0
- package/src/anyspend/types/req-res/getQuote.ts +4 -1
- package/src/anyspend/utils/orderPayload.ts +17 -5
- package/src/global-account/react/stores/useModalStore.ts +2 -0
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.VENDOR_DISPLAY_NAMES = exports.PAYMENT_METHOD_ICONS = exports.STRIPE_CONFIG = exports.DEFAULT_NFT_CONTRACT = exports.NFT_CONTRACTS = 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_TESTNET_BASE_URL = exports.ANYSPEND_MAINNET_BASE_URL = void 0;
|
|
4
|
+
const types_1 = require("../../anyspend/types");
|
|
4
5
|
const chains_1 = require("viem/chains");
|
|
5
6
|
exports.ANYSPEND_MAINNET_BASE_URL = process.env.NEXT_PUBLIC_ANYSPEND_BASE_URL || "https://mainnet.anyspend.com";
|
|
6
7
|
exports.ANYSPEND_TESTNET_BASE_URL = process.env.NEXT_PUBLIC_ANYSPEND_BASE_URL || "https://testnet.anyspend.com";
|
|
@@ -39,7 +40,8 @@ exports.NFT_CONTRACTS = [
|
|
|
39
40
|
imageUrl: "https://storage.googleapis.com/nftimagebucket/base/tokens/0x80f0e6644723abb03aa8867d21e32bd854b2a2d9/preview/TVRjME1EUTRORFl4T0E9PV8zNjcy.jpg",
|
|
40
41
|
name: "Downhill Ski",
|
|
41
42
|
description: "Downhill Ski",
|
|
42
|
-
tokenId: null
|
|
43
|
+
tokenId: null,
|
|
44
|
+
type: types_1.NftType.ERC721
|
|
43
45
|
},
|
|
44
46
|
{
|
|
45
47
|
chainId: chains_1.base.id,
|
|
@@ -50,7 +52,8 @@ exports.NFT_CONTRACTS = [
|
|
|
50
52
|
imageUrl: "https://cdn.b3.fun/game-weapon-demo.png",
|
|
51
53
|
name: "Eclipse Venom",
|
|
52
54
|
description: "The Eclipse Venom's crystalline blade channels imprisoned astral toxins through swirling currents of violet and teal light, synchronizing with its wielder's heartbeat for strikes that bypass conventional armor. Wounds from this otherworldly weapon resist healing as victims describe being consumed from within by liquid darkness, their final moments filled with visions of infinite cosmic depths.",
|
|
53
|
-
tokenId: null
|
|
55
|
+
tokenId: null,
|
|
56
|
+
type: types_1.NftType.ERC721
|
|
54
57
|
}
|
|
55
58
|
];
|
|
56
59
|
exports.DEFAULT_NFT_CONTRACT = exports.NFT_CONTRACTS[1];
|
|
@@ -20,6 +20,7 @@ __exportStar(require("./react/hooks"), exports);
|
|
|
20
20
|
__exportStar(require("./react/providers/AnyspendProvider"), exports);
|
|
21
21
|
// Types
|
|
22
22
|
__exportStar(require("./types"), exports);
|
|
23
|
+
__exportStar(require("./types/metadata"), exports);
|
|
23
24
|
// Utils
|
|
24
25
|
__exportStar(require("./utils/address"), exports);
|
|
25
26
|
__exportStar(require("./utils/chain"), exports);
|
|
@@ -6,20 +6,19 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.AnySpendBuySpin = AnySpendBuySpin;
|
|
7
7
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
8
8
|
const anyspend_1 = require("../../../anyspend");
|
|
9
|
-
const supported_1 = require("../../../shared/constants/chains/supported");
|
|
10
|
-
const EthIcon_1 = require("./icons/EthIcon");
|
|
11
|
-
const SolIcon_1 = require("./icons/SolIcon");
|
|
12
|
-
const USDCIcon_1 = require("./icons/USDCIcon");
|
|
13
9
|
const react_1 = require("../../../global-account/react");
|
|
14
|
-
const
|
|
10
|
+
const supported_1 = require("../../../shared/constants/chains/supported");
|
|
15
11
|
const framer_motion_1 = require("framer-motion");
|
|
16
12
|
const invariant_1 = __importDefault(require("invariant"));
|
|
17
13
|
const lucide_react_1 = require("lucide-react");
|
|
18
|
-
const
|
|
14
|
+
const react_2 = require("react");
|
|
19
15
|
const sonner_1 = require("sonner");
|
|
20
16
|
const viem_1 = require("viem");
|
|
21
17
|
const wagmi_1 = require("wagmi");
|
|
22
18
|
const AnySpendCustom_1 = require("./AnySpendCustom");
|
|
19
|
+
const EthIcon_1 = require("./icons/EthIcon");
|
|
20
|
+
const SolIcon_1 = require("./icons/SolIcon");
|
|
21
|
+
const USDCIcon_1 = require("./icons/USDCIcon");
|
|
23
22
|
const SPIN_WHEEL_ABI = [
|
|
24
23
|
{
|
|
25
24
|
inputs: [],
|
|
@@ -95,24 +94,24 @@ const basePublicClient = (0, viem_1.createPublicClient)({
|
|
|
95
94
|
transport: (0, viem_1.http)()
|
|
96
95
|
});
|
|
97
96
|
function AnySpendBuySpin({ isMainnet = true, loadOrder, mode = "modal", spinwheelContractAddress, chainId, recipientAddress, prefillQuantity, onSuccess }) {
|
|
98
|
-
const hasMounted = (0,
|
|
99
|
-
const { setB3ModalOpen } = (0,
|
|
97
|
+
const hasMounted = (0, react_1.useHasMounted)();
|
|
98
|
+
const { setB3ModalOpen } = (0, react_1.useModalStore)();
|
|
100
99
|
// Payment config state
|
|
101
|
-
const [paymentConfig, setPaymentConfig] = (0,
|
|
102
|
-
const [isLoadingConfig, setIsLoadingConfig] = (0,
|
|
103
|
-
const [configError, setConfigError] = (0,
|
|
104
|
-
const [wheelInfo, setWheelInfo] = (0,
|
|
100
|
+
const [paymentConfig, setPaymentConfig] = (0, react_2.useState)(null);
|
|
101
|
+
const [isLoadingConfig, setIsLoadingConfig] = (0, react_2.useState)(true);
|
|
102
|
+
const [configError, setConfigError] = (0, react_2.useState)("");
|
|
103
|
+
const [wheelInfo, setWheelInfo] = (0, react_2.useState)(null);
|
|
105
104
|
// Fetch B3 token balance
|
|
106
|
-
const { formattedBalance: b3Balance, isLoading: isBalanceLoading, rawBalance: b3RawBalance } = (0,
|
|
105
|
+
const { formattedBalance: b3Balance, isLoading: isBalanceLoading, rawBalance: b3RawBalance } = (0, react_1.useTokenBalance)({
|
|
107
106
|
token: anyspend_1.B3_TOKEN
|
|
108
107
|
});
|
|
109
108
|
// Wagmi hooks
|
|
110
109
|
const { address } = (0, wagmi_1.useAccount)();
|
|
111
110
|
const { writeContractAsync } = (0, wagmi_1.useWriteContract)();
|
|
112
|
-
const { switchChainAndExecute } = (0,
|
|
111
|
+
const { switchChainAndExecute } = (0, react_1.useChainSwitchWithAction)();
|
|
113
112
|
// State for direct buying flow (when user has B3 tokens)
|
|
114
|
-
const [isBuying, setIsBuying] = (0,
|
|
115
|
-
const [buyingTxHash, setBuyingTxHash] = (0,
|
|
113
|
+
const [isBuying, setIsBuying] = (0, react_2.useState)(false);
|
|
114
|
+
const [buyingTxHash, setBuyingTxHash] = (0, react_2.useState)("");
|
|
116
115
|
const { isLoading: isTxPending, isSuccess: isTxSuccess, isError: isTxError, error: txError } = (0, wagmi_1.useWaitForTransactionReceipt)({
|
|
117
116
|
hash: buyingTxHash,
|
|
118
117
|
query: {
|
|
@@ -120,7 +119,7 @@ function AnySpendBuySpin({ isMainnet = true, loadOrder, mode = "modal", spinwhee
|
|
|
120
119
|
}
|
|
121
120
|
});
|
|
122
121
|
// Handle transaction status
|
|
123
|
-
(0,
|
|
122
|
+
(0, react_2.useEffect)(() => {
|
|
124
123
|
if (!buyingTxHash)
|
|
125
124
|
return;
|
|
126
125
|
if (isTxSuccess) {
|
|
@@ -137,14 +136,14 @@ function AnySpendBuySpin({ isMainnet = true, loadOrder, mode = "modal", spinwhee
|
|
|
137
136
|
}
|
|
138
137
|
}, [isTxSuccess, isTxError, buyingTxHash, onSuccess, setB3ModalOpen, txError]);
|
|
139
138
|
// Spin quantity state
|
|
140
|
-
const [userSpinQuantity, setUserSpinQuantity] = (0,
|
|
141
|
-
const [showAmountPrompt, setShowAmountPrompt] = (0,
|
|
142
|
-
const [isQuantityValid, setIsQuantityValid] = (0,
|
|
143
|
-
const [validationError, setValidationError] = (0,
|
|
144
|
-
const [displayQuantity, setDisplayQuantity] = (0,
|
|
145
|
-
const [debouncedQuantity, setDebouncedQuantity] = (0,
|
|
146
|
-
const [debouncedUserSpinQuantity, setDebouncedUserSpinQuantity] = (0,
|
|
147
|
-
(0,
|
|
139
|
+
const [userSpinQuantity, setUserSpinQuantity] = (0, react_2.useState)("");
|
|
140
|
+
const [showAmountPrompt, setShowAmountPrompt] = (0, react_2.useState)(true);
|
|
141
|
+
const [isQuantityValid, setIsQuantityValid] = (0, react_2.useState)(false);
|
|
142
|
+
const [validationError, setValidationError] = (0, react_2.useState)("");
|
|
143
|
+
const [displayQuantity, setDisplayQuantity] = (0, react_2.useState)("");
|
|
144
|
+
const [debouncedQuantity, setDebouncedQuantity] = (0, react_2.useState)("");
|
|
145
|
+
const [debouncedUserSpinQuantity, setDebouncedUserSpinQuantity] = (0, react_2.useState)("");
|
|
146
|
+
(0, react_2.useEffect)(() => {
|
|
148
147
|
if (prefillQuantity && wheelInfo) {
|
|
149
148
|
const remainingSpins = wheelInfo.totalPrizesAvailable_ - wheelInfo.prizesRequestedCount_;
|
|
150
149
|
const adjustedQuantity = BigInt(prefillQuantity) > remainingSpins ? remainingSpins.toString() : prefillQuantity;
|
|
@@ -154,7 +153,7 @@ function AnySpendBuySpin({ isMainnet = true, loadOrder, mode = "modal", spinwhee
|
|
|
154
153
|
// Calculate total cost
|
|
155
154
|
const totalCost = paymentConfig && userSpinQuantity ? paymentConfig.pricePerEntry * BigInt(userSpinQuantity) : BigInt(0);
|
|
156
155
|
// Fetch payment configuration and wheel info
|
|
157
|
-
const fetchPaymentConfig = (0,
|
|
156
|
+
const fetchPaymentConfig = (0, react_2.useCallback)(async () => {
|
|
158
157
|
if (!basePublicClient || !spinwheelContractAddress)
|
|
159
158
|
return;
|
|
160
159
|
try {
|
|
@@ -205,11 +204,11 @@ function AnySpendBuySpin({ isMainnet = true, loadOrder, mode = "modal", spinwhee
|
|
|
205
204
|
}
|
|
206
205
|
}, [spinwheelContractAddress, chainId]);
|
|
207
206
|
// Fetch config on mount and when dependencies change
|
|
208
|
-
(0,
|
|
207
|
+
(0, react_2.useEffect)(() => {
|
|
209
208
|
fetchPaymentConfig();
|
|
210
209
|
}, [fetchPaymentConfig]);
|
|
211
210
|
// Debounce the quantity for balance checks
|
|
212
|
-
(0,
|
|
211
|
+
(0, react_2.useEffect)(() => {
|
|
213
212
|
const timer = setTimeout(() => {
|
|
214
213
|
setDebouncedQuantity(displayQuantity);
|
|
215
214
|
setDebouncedUserSpinQuantity(userSpinQuantity);
|
|
@@ -322,7 +321,7 @@ function AnySpendBuySpin({ isMainnet = true, loadOrder, mode = "modal", spinwhee
|
|
|
322
321
|
setShowAmountPrompt(false);
|
|
323
322
|
}
|
|
324
323
|
};
|
|
325
|
-
const header = () => ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)("div", { className: "relative mx-auto size-32", children: [(0, jsx_runtime_1.jsx)("div", { className: "absolute inset-0 scale-95 rounded-[50%] bg-gradient-to-br from-blue-500/20 to-purple-600/20 blur-xl" }), (0, jsx_runtime_1.jsxs)(
|
|
324
|
+
const header = () => ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)("div", { className: "relative mx-auto size-32", children: [(0, jsx_runtime_1.jsx)("div", { className: "absolute inset-0 scale-95 rounded-[50%] bg-gradient-to-br from-blue-500/20 to-purple-600/20 blur-xl" }), (0, jsx_runtime_1.jsxs)(react_1.GlareCardRounded, { className: "overflow-hidden rounded-full border-none bg-gradient-to-br from-blue-500/10 to-purple-600/10 backdrop-blur-sm", children: [(0, jsx_runtime_1.jsx)("img", { alt: "B3 Token", className: "size-full", src: "https://cdn.b3.fun/b3-coin-3d.png" }), (0, jsx_runtime_1.jsx)("div", { className: "absolute inset-0 rounded-[50%] border border-white/20" })] })] }), (0, jsx_runtime_1.jsxs)("div", { className: "from-b3-react-background to-as-on-surface-1 mt-[-60px] w-full rounded-t-lg bg-gradient-to-t", children: [(0, jsx_runtime_1.jsx)("div", { className: "h-[60px] w-full" }), (0, jsx_runtime_1.jsxs)("div", { className: "mb-1 flex w-full flex-col items-center gap-2 p-5", children: [(0, jsx_runtime_1.jsxs)("span", { className: "font-sf-rounded text-2xl font-semibold", children: ["Buy ", userSpinQuantity || "", " Spin", userSpinQuantity !== "1" ? "s" : ""] }), (0, jsx_runtime_1.jsx)("p", { className: "text-as-primary/70 text-sm", children: "Pay with B3 \u2022 Get spin wheel entries" })] })] })] }));
|
|
326
325
|
const onFocusQuantityInput = () => {
|
|
327
326
|
window.scrollTo(0, 0);
|
|
328
327
|
document.body.scrollTop = 0;
|
|
@@ -333,7 +332,7 @@ function AnySpendBuySpin({ isMainnet = true, loadOrder, mode = "modal", spinwhee
|
|
|
333
332
|
}
|
|
334
333
|
// Error state
|
|
335
334
|
if (configError || !paymentConfig) {
|
|
336
|
-
return ((0, jsx_runtime_1.jsx)(react_1.StyleRoot, { children: (0, jsx_runtime_1.jsxs)("div", { className: "bg-b3-react-background flex w-full flex-col items-center justify-center p-8", children: [(0, jsx_runtime_1.jsx)("p", { className: "text-as-red mb-4 text-center", children: configError || "Failed to load configuration" }), (0, jsx_runtime_1.jsx)(
|
|
335
|
+
return ((0, jsx_runtime_1.jsx)(react_1.StyleRoot, { children: (0, jsx_runtime_1.jsxs)("div", { className: "bg-b3-react-background flex w-full flex-col items-center justify-center p-8", children: [(0, jsx_runtime_1.jsx)("p", { className: "text-as-red mb-4 text-center", children: configError || "Failed to load configuration" }), (0, jsx_runtime_1.jsx)(react_1.Button, { onClick: fetchPaymentConfig, variant: "outline", children: "Retry" })] }) }));
|
|
337
336
|
}
|
|
338
337
|
// Render quantity input prompt
|
|
339
338
|
if (showAmountPrompt) {
|
|
@@ -384,16 +383,17 @@ function AnySpendBuySpin({ isMainnet = true, loadOrder, mode = "modal", spinwhee
|
|
|
384
383
|
opacity: hasMounted ? 1 : 0,
|
|
385
384
|
y: hasMounted ? 0 : 20,
|
|
386
385
|
filter: hasMounted ? "blur(0px)" : "blur(10px)"
|
|
387
|
-
}, transition: { duration: 0.3, delay: 0.2, ease: "easeInOut" }, className: "bg-b3-react-background w-full p-6", children: isActive ? ((0, jsx_runtime_1.jsxs)("div", { className: "space-y-4", children: [(0, jsx_runtime_1.jsxs)("div", { className: "flex items-center justify-between", children: [(0, jsx_runtime_1.jsx)("p", { className: "text-as-primary/70 text-sm font-medium", children: "Number of spins" }), (0, jsx_runtime_1.jsxs)("span", { className: "text-as-primary/50 flex items-center gap-1 text-sm", children: ["Available: ", isBalanceLoading ? (0, jsx_runtime_1.jsx)(lucide_react_1.Loader2, { className: "h-3 w-3 animate-spin" }) : `${b3Balance} B3`] })] }), (0, jsx_runtime_1.jsxs)("div", { className: "relative", children: [(0, jsx_runtime_1.jsx)(
|
|
386
|
+
}, transition: { duration: 0.3, delay: 0.2, ease: "easeInOut" }, className: "bg-b3-react-background w-full p-6", children: isActive ? ((0, jsx_runtime_1.jsxs)("div", { className: "space-y-4", children: [(0, jsx_runtime_1.jsxs)("div", { className: "flex items-center justify-between", children: [(0, jsx_runtime_1.jsx)("p", { className: "text-as-primary/70 text-sm font-medium", children: "Number of spins" }), (0, jsx_runtime_1.jsxs)("span", { className: "text-as-primary/50 flex items-center gap-1 text-sm", children: ["Available: ", isBalanceLoading ? (0, jsx_runtime_1.jsx)(lucide_react_1.Loader2, { className: "h-3 w-3 animate-spin" }) : `${b3Balance} B3`] })] }), (0, jsx_runtime_1.jsxs)("div", { className: "relative", children: [(0, jsx_runtime_1.jsx)(react_1.Input, { onFocus: onFocusQuantityInput, type: "text", placeholder: "1", value: displayQuantity, onChange: e => validateAndSetQuantity(e.target.value), className: `h-14 px-4 pr-20 text-lg ${!isQuantityValid && displayQuantity ? "border-as-red" : "border-b3-react-border"}` }), (0, jsx_runtime_1.jsx)("div", { className: "font-pack absolute right-4 top-1/2 -translate-y-1/2 text-lg font-medium text-blue-500/70", children: displayQuantity === "1" ? "Spin" : "Spins" })] }), !isQuantityValid && displayQuantity && (0, jsx_runtime_1.jsx)("p", { className: "text-as-red text-sm", children: validationError }), (0, jsx_runtime_1.jsx)("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: [displayQuantity && isQuantityValid ? (0, viem_1.formatUnits)(totalCost, 18) : "0", " B3"] }) })] }) }), (0, jsx_runtime_1.jsx)("div", { className: "mt-4", children: (() => {
|
|
388
387
|
const hasEnoughBalance = b3RawBalance && totalCost <= b3RawBalance;
|
|
389
388
|
if (!hasEnoughBalance && debouncedQuantity) {
|
|
390
|
-
return ((0, jsx_runtime_1.jsxs)("div", { className: "bg-as-brand/10 flex flex-col items-center gap-2 rounded-lg p-4 pb-5", children: [(0, jsx_runtime_1.jsxs)("div", { className: "flex items-center justify-center gap-2", children: [(0, jsx_runtime_1.jsx)("span", { className: "text-as-primary text-sm font-semibold", children: "Swap & buy from any token" }), (0, jsx_runtime_1.jsxs)(
|
|
389
|
+
return ((0, jsx_runtime_1.jsxs)("div", { className: "bg-as-brand/10 flex flex-col items-center gap-2 rounded-lg p-4 pb-5", children: [(0, jsx_runtime_1.jsxs)("div", { className: "flex items-center justify-center gap-2", children: [(0, jsx_runtime_1.jsx)("span", { className: "text-as-primary text-sm font-semibold", children: "Swap & buy from any token" }), (0, jsx_runtime_1.jsxs)(react_1.TextLoop, { children: [(0, jsx_runtime_1.jsx)(EthIcon_1.EthIcon, { className: "h-8 w-8" }), (0, jsx_runtime_1.jsx)(SolIcon_1.SolIcon, { className: "h-8 w-8" }), (0, jsx_runtime_1.jsx)(USDCIcon_1.UsdcIcon, { className: "h-8 w-8" })] }), (0, jsx_runtime_1.jsx)(lucide_react_1.ArrowRight, { className: "text-as-primary h-4 w-4" }), (0, jsx_runtime_1.jsx)("img", { src: "https://cdn.b3.fun/b3-coin-3d.png", className: "h-7 w-7", alt: "B3 Token" })] }), (0, jsx_runtime_1.jsx)("p", { className: "text-as-primary/50 text-sm font-medium", children: "No problem, we'll help you swap to B3 for your spins!" })] }));
|
|
391
390
|
}
|
|
392
|
-
})() }), (0, jsx_runtime_1.jsx)(
|
|
391
|
+
})() }), (0, jsx_runtime_1.jsx)(react_1.Button, { onClick: confirmQuantity, disabled: !isQuantityValid || !displayQuantity || isBuying || isTxPending, 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: isBuying ? "Buying..." : isTxPending ? "Confirming..." : "Continue" })] })) : null })] }) }));
|
|
393
392
|
}
|
|
394
393
|
// AnySpend flow for when user needs to swap to B3
|
|
395
394
|
const encodedData = generateEncodedDataForBuyEntriesAndSpin(address || "", userSpinQuantity);
|
|
396
395
|
return ((0, jsx_runtime_1.jsx)(AnySpendCustom_1.AnySpendCustom, { isMainnet: isMainnet, loadOrder: loadOrder, mode: mode, recipientAddress: recipientAddress, orderType: anyspend_1.OrderType.Custom, dstChainId: chainId, dstToken: anyspend_1.B3_TOKEN, dstAmount: totalCost.toString(), contractAddress: spinwheelContractAddress, spenderAddress: paymentConfig.entryModule, encodedData: encodedData, metadata: {
|
|
396
|
+
type: anyspend_1.OrderType.Custom,
|
|
397
397
|
action: `buy ${userSpinQuantity} spin${userSpinQuantity !== "1" ? "s" : ""}`
|
|
398
398
|
}, header: header, onSuccess: txHash => onSuccess?.(txHash), showRecipient: false }));
|
|
399
399
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { GetQuoteResponse, OrderType, Token } from "../../../anyspend";
|
|
1
|
+
import { AnySpendMetadata, GetQuoteResponse, OrderType, Token } from "../../../anyspend";
|
|
2
2
|
import React from "react";
|
|
3
3
|
export declare function AnySpendCustom({ isMainnet, loadOrder, mode, recipientAddress: recipientAddressProps, spenderAddress, orderType, dstChainId, dstToken, dstAmount, contractAddress, encodedData, metadata, header, onSuccess, showRecipient }: {
|
|
4
4
|
isMainnet?: boolean;
|
|
@@ -12,7 +12,7 @@ export declare function AnySpendCustom({ isMainnet, loadOrder, mode, recipientAd
|
|
|
12
12
|
dstAmount: string;
|
|
13
13
|
contractAddress: string;
|
|
14
14
|
encodedData: string;
|
|
15
|
-
metadata:
|
|
15
|
+
metadata: AnySpendMetadata;
|
|
16
16
|
header: ({ anyspendPrice, isLoadingAnyspendPrice }: {
|
|
17
17
|
anyspendPrice: GetQuoteResponse | undefined;
|
|
18
18
|
isLoadingAnyspendPrice: boolean;
|
|
@@ -7,9 +7,6 @@ exports.AnySpendCustom = AnySpendCustom;
|
|
|
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 react_2 = require("../../../global-account/react");
|
|
11
|
-
const react_3 = require("../../../global-account/react");
|
|
12
|
-
const react_4 = require("../../../global-account/react");
|
|
13
10
|
const utils_1 = require("../../../shared/utils");
|
|
14
11
|
const centerTruncate_1 = __importDefault(require("../../../shared/utils/centerTruncate"));
|
|
15
12
|
const number_1 = require("../../../shared/utils/number");
|
|
@@ -17,7 +14,7 @@ const simplehash_1 = require("../../../shared/utils/simplehash");
|
|
|
17
14
|
const framer_motion_1 = require("framer-motion");
|
|
18
15
|
const invariant_1 = __importDefault(require("invariant"));
|
|
19
16
|
const lucide_react_1 = require("lucide-react");
|
|
20
|
-
const
|
|
17
|
+
const react_2 = require("react");
|
|
21
18
|
const sonner_1 = require("sonner");
|
|
22
19
|
const chains_1 = require("viem/chains");
|
|
23
20
|
const OrderDetails_1 = require("./common/OrderDetails");
|
|
@@ -32,7 +29,7 @@ var PanelView;
|
|
|
32
29
|
PanelView[PanelView["ORDER_DETAILS"] = 2] = "ORDER_DETAILS";
|
|
33
30
|
PanelView[PanelView["LOADING"] = 3] = "LOADING";
|
|
34
31
|
})(PanelView || (PanelView = {}));
|
|
35
|
-
function generateGetRelayQuoteRequest({ orderType, srcChainId, srcToken, dstChainId, dstToken, dstAmount, contractAddress, encodedData, spenderAddress }) {
|
|
32
|
+
function generateGetRelayQuoteRequest({ orderType, srcChainId, srcToken, dstChainId, dstToken, dstAmount, contractAddress, tokenId, contractType, encodedData, spenderAddress }) {
|
|
36
33
|
switch (orderType) {
|
|
37
34
|
case anyspend_1.OrderType.MintNFT: {
|
|
38
35
|
return {
|
|
@@ -42,7 +39,9 @@ function generateGetRelayQuoteRequest({ orderType, srcChainId, srcToken, dstChai
|
|
|
42
39
|
dstChain: dstChainId,
|
|
43
40
|
dstTokenAddress: dstToken.address,
|
|
44
41
|
price: dstAmount,
|
|
45
|
-
contractAddress: contractAddress
|
|
42
|
+
contractAddress: contractAddress,
|
|
43
|
+
tokenId: tokenId,
|
|
44
|
+
contractType: contractType
|
|
46
45
|
};
|
|
47
46
|
}
|
|
48
47
|
case anyspend_1.OrderType.JoinTournament: {
|
|
@@ -88,15 +87,15 @@ function generateGetRelayQuoteRequest({ orderType, srcChainId, srcToken, dstChai
|
|
|
88
87
|
}
|
|
89
88
|
}
|
|
90
89
|
function AnySpendCustom({ isMainnet = true, loadOrder, mode = "modal", recipientAddress: recipientAddressProps, spenderAddress, orderType, dstChainId, dstToken, dstAmount, contractAddress, encodedData, metadata, header, onSuccess, showRecipient = true }) {
|
|
91
|
-
const { setB3ModalOpen, setB3ModalContentType } = (0,
|
|
92
|
-
const hasMounted = (0,
|
|
93
|
-
const searchParams = (0,
|
|
94
|
-
const router = (0,
|
|
95
|
-
const [activePanel, setActivePanel] = (0,
|
|
96
|
-
const [activeTab, setActiveTab] = (0,
|
|
90
|
+
const { setB3ModalOpen, setB3ModalContentType } = (0, react_1.useModalStore)();
|
|
91
|
+
const hasMounted = (0, react_1.useHasMounted)();
|
|
92
|
+
const searchParams = (0, react_1.useSearchParamsSSR)();
|
|
93
|
+
const router = (0, react_1.useRouter)();
|
|
94
|
+
const [activePanel, setActivePanel] = (0, react_2.useState)(loadOrder ? PanelView.ORDER_DETAILS : PanelView.CONFIRM_ORDER);
|
|
95
|
+
const [activeTab, setActiveTab] = (0, react_2.useState)("crypto");
|
|
97
96
|
// Get current user's wallet
|
|
98
|
-
const currentWallet = (0,
|
|
99
|
-
const recipientPropsProfile = (0,
|
|
97
|
+
const currentWallet = (0, react_1.useAccountWallet)();
|
|
98
|
+
const recipientPropsProfile = (0, react_1.useBsmntProfile)({ address: recipientAddressProps });
|
|
100
99
|
const recipientAddress = recipientAddressProps || currentWallet.address;
|
|
101
100
|
const recipientEnsName = recipientAddressProps
|
|
102
101
|
? recipientPropsProfile.data?.username?.replaceAll(".b3.fun", "")
|
|
@@ -104,19 +103,19 @@ function AnySpendCustom({ isMainnet = true, loadOrder, mode = "modal", recipient
|
|
|
104
103
|
const recipientImageUrl = recipientAddressProps
|
|
105
104
|
? recipientPropsProfile.data?.avatar
|
|
106
105
|
: currentWallet.wallet.meta?.icon;
|
|
107
|
-
const [orderId, setOrderId] = (0,
|
|
108
|
-
const [srcChainId, setSrcChainId] = (0,
|
|
106
|
+
const [orderId, setOrderId] = (0, react_2.useState)(loadOrder);
|
|
107
|
+
const [srcChainId, setSrcChainId] = (0, react_2.useState)(isMainnet ? chains_1.base.id : chains_1.baseSepolia.id);
|
|
109
108
|
// Get token list for token balance check
|
|
110
|
-
const chainName = (0,
|
|
109
|
+
const chainName = (0, react_2.useMemo)(() => (0, simplehash_1.simpleHashChainToChainName)(srcChainId), [srcChainId]);
|
|
111
110
|
const { data: tokenList } = (0, anyspend_1.useAnyspendTokenList)(isMainnet, srcChainId, "");
|
|
112
111
|
// Get token balances for the selected chain
|
|
113
|
-
const { nativeTokens, fungibleTokens } = (0,
|
|
112
|
+
const { nativeTokens, fungibleTokens } = (0, react_1.useTokenBalancesByChain)({
|
|
114
113
|
address: currentWallet?.wallet?.address || "",
|
|
115
114
|
chainsIds: [srcChainId],
|
|
116
115
|
enabled: !!currentWallet?.wallet?.address && !!chainName
|
|
117
116
|
});
|
|
118
117
|
// Find a token with a balance, prioritizing tokens the user already owns
|
|
119
|
-
const getTokenWithBalance = (0,
|
|
118
|
+
const getTokenWithBalance = (0, react_2.useCallback)(() => {
|
|
120
119
|
if (!currentWallet?.wallet?.address || (!nativeTokens && !fungibleTokens) || !tokenList) {
|
|
121
120
|
return (0, anyspend_1.getDefaultToken)(srcChainId);
|
|
122
121
|
}
|
|
@@ -146,10 +145,10 @@ function AnySpendCustom({ isMainnet = true, loadOrder, mode = "modal", recipient
|
|
|
146
145
|
return (0, anyspend_1.getDefaultToken)(srcChainId);
|
|
147
146
|
}, [currentWallet?.wallet?.address, nativeTokens, fungibleTokens, tokenList, srcChainId]);
|
|
148
147
|
// Set the selected token with preference for tokens user owns
|
|
149
|
-
const [srcToken, setSrcToken] = (0,
|
|
150
|
-
const [dirtySelectSrcToken, setDirtySelectSrcToken] = (0,
|
|
148
|
+
const [srcToken, setSrcToken] = (0, react_2.useState)((0, anyspend_1.getDefaultToken)(srcChainId));
|
|
149
|
+
const [dirtySelectSrcToken, setDirtySelectSrcToken] = (0, react_2.useState)(false);
|
|
151
150
|
// Update token when chain changes or token balances are loaded
|
|
152
|
-
(0,
|
|
151
|
+
(0, react_2.useEffect)(() => {
|
|
153
152
|
if (tokenList?.length && !dirtySelectSrcToken) {
|
|
154
153
|
const tokenWithBalance = getTokenWithBalance();
|
|
155
154
|
if ((0, anyspend_1.eqci)(tokenWithBalance.address, dstToken.address) === false) {
|
|
@@ -166,6 +165,8 @@ function AnySpendCustom({ isMainnet = true, loadOrder, mode = "modal", recipient
|
|
|
166
165
|
dstToken: dstToken,
|
|
167
166
|
dstAmount: dstAmount,
|
|
168
167
|
contractAddress: contractAddress,
|
|
168
|
+
tokenId: (0, anyspend_1.isNftMetadata)(metadata) ? metadata.nftContract.tokenId : undefined,
|
|
169
|
+
contractType: (0, anyspend_1.isNftMetadata)(metadata) ? metadata.nftContract.type : undefined,
|
|
169
170
|
encodedData: encodedData,
|
|
170
171
|
spenderAddress: spenderAddress
|
|
171
172
|
});
|
|
@@ -181,11 +182,11 @@ function AnySpendCustom({ isMainnet = true, loadOrder, mode = "modal", recipient
|
|
|
181
182
|
params.set("orderId", selectedOrderId);
|
|
182
183
|
router.push(`${window.location.pathname}?${params.toString()}`);
|
|
183
184
|
};
|
|
184
|
-
const [srcAmount, setSrcAmount] = (0,
|
|
185
|
+
const [srcAmount, setSrcAmount] = (0, react_2.useState)(null);
|
|
185
186
|
const formattedSrcAmount = srcAmount ? (0, number_1.formatTokenAmount)(srcAmount, srcToken.decimals, 6, false) : null;
|
|
186
187
|
// Update the selected src token to USDC and chain to base when the active tab is fiat,
|
|
187
188
|
// also force not to update srcToken by setting dirtySelectSrcToken to true.
|
|
188
|
-
(0,
|
|
189
|
+
(0, react_2.useEffect)(() => {
|
|
189
190
|
if (activeTab === "fiat") {
|
|
190
191
|
setSrcChainId(chains_1.base.id);
|
|
191
192
|
setSrcToken(anyspend_1.USDC_BASE);
|
|
@@ -193,7 +194,7 @@ function AnySpendCustom({ isMainnet = true, loadOrder, mode = "modal", recipient
|
|
|
193
194
|
}
|
|
194
195
|
}, [activeTab]);
|
|
195
196
|
// Update dependent amount when relay price changes
|
|
196
|
-
(0,
|
|
197
|
+
(0, react_2.useEffect)(() => {
|
|
197
198
|
if (anyspendQuote?.data &&
|
|
198
199
|
anyspendQuote.data.currencyIn?.amount &&
|
|
199
200
|
anyspendQuote.data.currencyIn?.currency?.decimals) {
|
|
@@ -205,7 +206,7 @@ function AnySpendCustom({ isMainnet = true, loadOrder, mode = "modal", recipient
|
|
|
205
206
|
setSrcAmount(null);
|
|
206
207
|
}
|
|
207
208
|
}, [anyspendQuote?.data]);
|
|
208
|
-
(0,
|
|
209
|
+
(0, react_2.useEffect)(() => {
|
|
209
210
|
if (oat?.data?.order.status === anyspend_1.OrderStatus.Executed) {
|
|
210
211
|
console.log("Calling onSuccess");
|
|
211
212
|
const txHash = oat?.data?.executeTx?.txHash;
|
|
@@ -245,21 +246,40 @@ function AnySpendCustom({ isMainnet = true, loadOrder, mode = "modal", recipient
|
|
|
245
246
|
srcAmount: srcAmount.toString(),
|
|
246
247
|
recipientAddress,
|
|
247
248
|
creatorAddress: currentWallet?.wallet?.address,
|
|
248
|
-
nft:
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
249
|
+
nft: (0, anyspend_1.isNftMetadata)(metadata)
|
|
250
|
+
? metadata.nftContract.type === anyspend_1.NftType.ERC1155
|
|
251
|
+
? {
|
|
252
|
+
type: anyspend_1.NftType.ERC1155,
|
|
253
|
+
contractAddress: metadata.nftContract.contractAddress,
|
|
254
|
+
tokenId: metadata.nftContract.tokenId,
|
|
255
|
+
name: metadata.nftContract.name,
|
|
256
|
+
description: metadata.nftContract.description,
|
|
257
|
+
imageUrl: metadata.nftContract.imageUrl,
|
|
258
|
+
nftPrice: dstAmount
|
|
259
|
+
}
|
|
260
|
+
: {
|
|
261
|
+
type: anyspend_1.NftType.ERC721,
|
|
262
|
+
contractAddress: metadata.nftContract.contractAddress,
|
|
263
|
+
contractType: metadata.nftContract.type,
|
|
264
|
+
nftPrice: dstAmount,
|
|
265
|
+
name: metadata.nftContract.name,
|
|
266
|
+
description: metadata.nftContract.description,
|
|
267
|
+
imageUrl: metadata.nftContract.imageUrl
|
|
268
|
+
}
|
|
269
|
+
: undefined,
|
|
270
|
+
tournament: (0, anyspend_1.isTournamentMetadata)(metadata)
|
|
271
|
+
? {
|
|
272
|
+
...metadata.tournament,
|
|
273
|
+
contractAddress: contractAddress,
|
|
274
|
+
entryPriceOrFundAmount: dstAmount
|
|
275
|
+
}
|
|
276
|
+
: undefined,
|
|
257
277
|
payload: {
|
|
258
278
|
amount: dstAmount,
|
|
259
279
|
data: encodedData,
|
|
260
280
|
spenderAddress: spenderAddress,
|
|
261
281
|
to: contractAddress,
|
|
262
|
-
action: metadata.action
|
|
282
|
+
action: (0, anyspend_1.isCustomTxMetadata)(metadata) ? metadata.action : undefined
|
|
263
283
|
}
|
|
264
284
|
};
|
|
265
285
|
if (onramp) {
|
|
@@ -327,7 +347,7 @@ function AnySpendCustom({ isMainnet = true, loadOrder, mode = "modal", recipient
|
|
|
327
347
|
? "Receive NFT at"
|
|
328
348
|
: orderType === anyspend_1.OrderType.JoinTournament
|
|
329
349
|
? "Join for"
|
|
330
|
-
: "Recipient" }), (0, jsx_runtime_1.jsx)("div", { children: (0, jsx_runtime_1.jsxs)(
|
|
350
|
+
: "Recipient" }), (0, jsx_runtime_1.jsx)("div", { children: (0, jsx_runtime_1.jsxs)(react_1.Button, { variant: "outline", className: "w-full justify-between border-none p-0", children: [(0, jsx_runtime_1.jsxs)("div", { className: "flex items-center gap-2", children: [recipientImageUrl && ((0, jsx_runtime_1.jsx)("img", { src: recipientImageUrl, alt: recipientImageUrl, className: "bg-b3-react-foreground size-7 rounded-full object-cover opacity-100" })), (0, jsx_runtime_1.jsxs)("div", { className: "flex flex-col items-start gap-1", children: [recipientEnsName && (0, jsx_runtime_1.jsxs)("span", { children: ["@", recipientEnsName] }), (0, jsx_runtime_1.jsx)("span", { children: (0, centerTruncate_1.default)(recipientAddress) })] })] }), (0, jsx_runtime_1.jsx)(lucide_react_1.ChevronRightCircle, { className: "ml-2 size-4 shrink-0 opacity-50" })] }) })] })) : null;
|
|
331
351
|
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: () => {
|
|
332
352
|
setActivePanel(PanelView.HISTORY);
|
|
333
353
|
}, onSelectOrder: onSelectOrder }) }));
|
|
@@ -339,9 +359,9 @@ function AnySpendCustom({ isMainnet = true, loadOrder, mode = "modal", recipient
|
|
|
339
359
|
params.delete("orderId");
|
|
340
360
|
router.push(`${window.location.pathname}?${params.toString()}`);
|
|
341
361
|
} })] })), mode === "page" && (0, jsx_runtime_1.jsx)("div", { className: "h-12" })] }));
|
|
342
|
-
const loadingView = ((0, jsx_runtime_1.jsxs)("div", { className: (0, utils_1.cn)("mx-auto flex w-full flex-col items-center gap-4 p-5", mode === "modal" && "bg-b3-react-background"), children: [(0, jsx_runtime_1.jsxs)(
|
|
362
|
+
const loadingView = ((0, jsx_runtime_1.jsxs)("div", { className: (0, utils_1.cn)("mx-auto flex w-full flex-col items-center gap-4 p-5", mode === "modal" && "bg-b3-react-background"), children: [(0, jsx_runtime_1.jsxs)(react_1.Badge, { variant: "default", className: "bg-b3-react-muted/30 border-b3-react-border hover:bg-b3-react-muted/50 flex items-center gap-3 px-4 py-1 text-base transition-all", children: [(0, jsx_runtime_1.jsx)(lucide_react_1.Loader2, { className: "text-b3-react-foreground size-4 animate-spin" }), (0, jsx_runtime_1.jsx)(react_1.TextShimmer, { duration: 1, className: "font-sf-rounded text-base font-semibold", children: "Loading..." })] }), (0, jsx_runtime_1.jsxs)("div", { className: "flex w-full flex-1 flex-col", children: [(0, jsx_runtime_1.jsxs)("div", { className: "mb-4 flex flex-col gap-1", children: [(0, jsx_runtime_1.jsx)(react_1.Skeleton, { className: "h-4 w-24" }), (0, jsx_runtime_1.jsxs)("div", { className: "mt-2 flex items-center gap-2", children: [(0, jsx_runtime_1.jsx)(react_1.Skeleton, { className: "h-8 w-48" }), (0, jsx_runtime_1.jsx)(react_1.Skeleton, { className: "ml-4 h-8 w-32" })] }), (0, jsx_runtime_1.jsx)(react_1.Skeleton, { className: "mt-4 h-8 w-24" })] }), (0, jsx_runtime_1.jsx)(react_1.Skeleton, { className: "mb-4 h-12 w-full" }), (0, jsx_runtime_1.jsxs)("div", { className: "flex w-full items-center justify-between gap-4", children: [(0, jsx_runtime_1.jsxs)(react_1.Skeleton, { className: "rounded-lg bg-white/5 p-6 pb-3", children: [(0, jsx_runtime_1.jsx)("div", { className: "size-[200px]" }), (0, jsx_runtime_1.jsx)("div", { className: "mt-3 flex items-center justify-center gap-2", children: (0, jsx_runtime_1.jsx)("div", { className: "size-5 rounded-full" }) })] }), (0, jsx_runtime_1.jsx)("div", { className: "flex flex-1 flex-col gap-2", children: [1, 2, 3].map(i => ((0, jsx_runtime_1.jsx)(react_1.Skeleton, { className: "h-10 w-full" }, i))) })] })] }), (0, jsx_runtime_1.jsxs)("div", { className: "bg-b3-react-muted/30 mt-8 w-full rounded-lg p-4", children: [(0, jsx_runtime_1.jsx)(react_1.Skeleton, { className: "mb-3 h-4 w-48" }), (0, jsx_runtime_1.jsxs)("div", { className: "flex items-center gap-4", children: [(0, jsx_runtime_1.jsx)(react_1.Skeleton, { className: "h-10 flex-1" }), (0, jsx_runtime_1.jsx)(react_1.Skeleton, { className: "h-10 flex-1" })] })] }), (0, jsx_runtime_1.jsx)("div", { className: "flex w-full flex-col gap-3", children: [1, 2, 3, 4, 5].map(i => ((0, jsx_runtime_1.jsxs)("div", { className: "flex w-full justify-between", children: [(0, jsx_runtime_1.jsx)(react_1.Skeleton, { className: "h-4 w-24" }), (0, jsx_runtime_1.jsx)(react_1.Skeleton, { className: "h-4 w-32" })] }, i))) }), (0, jsx_runtime_1.jsx)(react_1.Skeleton, { className: "h-10 w-full" }), mode === "page" && (0, jsx_runtime_1.jsx)("div", { className: "h-12" })] }));
|
|
343
363
|
// Confirm order view.
|
|
344
|
-
const confirmOrderView = ((0, jsx_runtime_1.jsxs)("div", { className: "relative mx-auto flex w-full flex-col items-center", children: [header({ anyspendPrice: anyspendQuote, isLoadingAnyspendPrice: isLoadingAnyspendQuote }), (0, jsx_runtime_1.jsx)("div", { className: "divider w-full" }), (0, jsx_runtime_1.jsxs)(
|
|
364
|
+
const confirmOrderView = ((0, jsx_runtime_1.jsxs)("div", { className: "relative mx-auto flex w-full flex-col items-center", children: [header({ anyspendPrice: anyspendQuote, isLoadingAnyspendPrice: isLoadingAnyspendQuote }), (0, jsx_runtime_1.jsx)("div", { className: "divider w-full" }), (0, jsx_runtime_1.jsxs)(react_1.Tabs, { value: activeTab, onValueChange: value => setActiveTab(value), className: "bg-b3-react-background w-full p-5", children: [isOnrampSupported || activeTab === "fiat" ? ((0, jsx_runtime_1.jsxs)(react_1.TabsList, { hideGradient: true, className: "justify-center", children: [(0, jsx_runtime_1.jsx)(react_1.TabTrigger, { value: "crypto", children: (0, jsx_runtime_1.jsx)("span", { className: "text-as-primary w-[140px]", children: "Pay with crypto" }) }), (0, jsx_runtime_1.jsx)(react_1.TabTrigger, { value: "fiat", children: (0, jsx_runtime_1.jsx)("span", { className: "text-as-primary w-[140px]", children: "Pay with fiat" }) })] })) : null, (0, jsx_runtime_1.jsx)(react_1.TabsContent, { value: "crypto", children: (0, jsx_runtime_1.jsxs)("div", { className: "mt-2 flex flex-col gap-4", children: [(0, jsx_runtime_1.jsxs)("div", { className: "flex flex-col gap-4", children: [(0, jsx_runtime_1.jsxs)(framer_motion_1.motion.div, { initial: false, animate: {
|
|
345
365
|
opacity: hasMounted ? 1 : 0,
|
|
346
366
|
y: hasMounted ? 0 : 20,
|
|
347
367
|
filter: hasMounted ? "blur(0px)" : "blur(10px)"
|
|
@@ -356,9 +376,26 @@ function AnySpendCustom({ isMainnet = true, loadOrder, mode = "modal", recipient
|
|
|
356
376
|
opacity: hasMounted ? 1 : 0,
|
|
357
377
|
y: hasMounted ? 0 : 20,
|
|
358
378
|
filter: hasMounted ? "blur(0px)" : "blur(10px)"
|
|
359
|
-
}, transition: { duration: 0.3, delay: 0.3, ease: "easeInOut" }, className: "flex w-full flex-col gap-2", children: (0, jsx_runtime_1.jsx)(
|
|
360
|
-
?
|
|
361
|
-
|
|
379
|
+
}, transition: { duration: 0.3, delay: 0.3, ease: "easeInOut" }, className: "flex w-full flex-col gap-2", children: (0, jsx_runtime_1.jsx)(react_1.ShinyButton, { accentColor: "hsl(var(--as-brand))", textColor: "text-white", disabled: isCreatingOrder || isLoadingAnyspendQuote || !anyspendQuote, onClick: () => handleConfirmOrder(), className: "relative w-full", children: !isAuthenticated ? ("Sign in with B3") : isCreatingOrder ? ((0, jsx_runtime_1.jsxs)("div", { className: "flex items-center gap-2", children: [(0, jsx_runtime_1.jsx)(lucide_react_1.Loader2, { className: "size-4 animate-spin" }), (0, jsx_runtime_1.jsx)("span", { children: "Creating order..." })] })) : isLoadingAnyspendQuote ? ((0, jsx_runtime_1.jsxs)("div", { className: "flex items-center gap-2", children: [(0, jsx_runtime_1.jsx)(lucide_react_1.Loader2, { className: "size-4 animate-spin" }), (0, jsx_runtime_1.jsx)("span", { children: "Loading quote..." })] })) : anyspendQuote ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("span", { children: "Checkout" }), (0, jsx_runtime_1.jsx)(lucide_react_1.ChevronRightCircle, { className: "absolute right-0 top-1/2 size-6 -translate-y-1/2 opacity-70" })] })) : ("No quote found") }) }) })] }) }), (0, jsx_runtime_1.jsx)(react_1.TabsContent, { value: "fiat", children: (0, jsx_runtime_1.jsx)("div", { className: "mt-6 flex w-full flex-col gap-6", children: (0, jsx_runtime_1.jsx)(PanelOnrampPayment_1.PanelOnrampPayment, { srcAmountOnRamp: anyspendQuote?.data?.currencyIn?.amountUsd || "0", recipientName: recipientEnsName, recipientAddress: recipientAddress, isMainnet: isMainnet, isBuyMode: false, selectedDstChainId: dstChainId, selectedDstToken: dstToken, anyspendQuote: anyspendQuote, globalAddress: currentWallet?.wallet?.address, onOrderCreated: (orderId) => setOrderId(orderId), onBack: () => setActiveTab("crypto"), orderType: orderType, nft: (0, anyspend_1.isNftMetadata)(metadata)
|
|
380
|
+
? metadata.nftContract.type === anyspend_1.NftType.ERC1155
|
|
381
|
+
? {
|
|
382
|
+
type: anyspend_1.NftType.ERC1155,
|
|
383
|
+
contractAddress: metadata.nftContract.contractAddress,
|
|
384
|
+
tokenId: metadata.nftContract.tokenId,
|
|
385
|
+
imageUrl: metadata.nftContract.imageUrl,
|
|
386
|
+
name: metadata.nftContract.name,
|
|
387
|
+
description: metadata.nftContract.description,
|
|
388
|
+
price: dstAmount
|
|
389
|
+
}
|
|
390
|
+
: {
|
|
391
|
+
type: anyspend_1.NftType.ERC721,
|
|
392
|
+
contractAddress: metadata.nftContract.contractAddress,
|
|
393
|
+
name: metadata.nftContract.name,
|
|
394
|
+
description: metadata.nftContract.description,
|
|
395
|
+
imageUrl: metadata.nftContract.imageUrl,
|
|
396
|
+
price: dstAmount
|
|
397
|
+
}
|
|
398
|
+
: undefined, payload: (0, anyspend_1.isCustomTxMetadata)(metadata)
|
|
362
399
|
? {
|
|
363
400
|
...metadata,
|
|
364
401
|
amount: dstAmount,
|
|
@@ -368,7 +405,7 @@ function AnySpendCustom({ isMainnet = true, loadOrder, mode = "modal", recipient
|
|
|
368
405
|
}
|
|
369
406
|
: undefined, recipientEnsName: recipientEnsName, recipientImageUrl: recipientImageUrl }) }) })] })] }));
|
|
370
407
|
// Return the TransitionPanel with all views
|
|
371
|
-
return ((0, jsx_runtime_1.jsx)(react_1.StyleRoot, { children: (0, jsx_runtime_1.jsx)(
|
|
408
|
+
return ((0, jsx_runtime_1.jsx)(react_1.StyleRoot, { children: (0, jsx_runtime_1.jsx)(react_1.TransitionPanel, { activeIndex: orderId
|
|
372
409
|
? oat
|
|
373
410
|
? PanelView.ORDER_DETAILS
|
|
374
411
|
: PanelView.LOADING
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { NftContract } from "../../../anyspend/types";
|
|
2
|
-
export declare function AnySpendNFT({ isMainnet, loadOrder, mode, recipientAddress, nftContract }: {
|
|
2
|
+
export declare function AnySpendNFT({ isMainnet, loadOrder, mode, recipientAddress, nftContract, onSuccess }: {
|
|
3
3
|
isMainnet?: boolean;
|
|
4
4
|
loadOrder?: string;
|
|
5
5
|
mode?: "modal" | "page";
|
|
6
6
|
recipientAddress?: string;
|
|
7
|
-
nftContract
|
|
7
|
+
nftContract: NftContract;
|
|
8
|
+
onSuccess?: (txHash?: string) => void;
|
|
8
9
|
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.AnySpendNFT = AnySpendNFT;
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
5
|
const anyspend_1 = require("../../../anyspend");
|
|
6
|
-
const constants_1 = require("../../../anyspend/constants");
|
|
7
6
|
const react_1 = require("../../../global-account/react");
|
|
8
7
|
const utils_1 = require("../../../shared/utils");
|
|
9
8
|
const ipfs_1 = require("../../../shared/utils/ipfs");
|
|
@@ -13,11 +12,14 @@ const lucide_react_1 = require("lucide-react");
|
|
|
13
12
|
const react_2 = require("react");
|
|
14
13
|
const chains_1 = require("viem/chains");
|
|
15
14
|
const AnySpendCustom_1 = require("./AnySpendCustom");
|
|
16
|
-
function AnySpendNFT({ isMainnet = true, loadOrder, mode = "modal", recipientAddress, nftContract
|
|
15
|
+
function AnySpendNFT({ isMainnet = true, loadOrder, mode = "modal", recipientAddress, nftContract, onSuccess }) {
|
|
17
16
|
const header = ({ anyspendPrice, isLoadingAnyspendPrice }) => ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)("div", { className: "relative size-[200px]", children: [(0, jsx_runtime_1.jsx)("div", { className: "absolute inset-0 scale-95 bg-black/30 blur-md" }), (0, jsx_runtime_1.jsxs)(react_1.GlareCard, { className: "overflow-hidden", children: [(0, jsx_runtime_1.jsx)("img", { src: (0, ipfs_1.getIpfsUrl)(nftContract.imageUrl), alt: nftContract.name, className: "size-full object-cover" }), (0, jsx_runtime_1.jsx)("div", { className: "absolute inset-0 rounded-xl border border-white/10" })] }), (0, jsx_runtime_1.jsx)(DropdownMenu, { nftContract: nftContract })] }), (0, jsx_runtime_1.jsxs)("div", { className: "from-b3-react-background to-as-on-surface-1 mt-[-100px] w-full rounded-t-lg bg-gradient-to-t", children: [(0, jsx_runtime_1.jsx)("div", { className: "h-[100px] w-full" }), (0, jsx_runtime_1.jsxs)("div", { className: "mb-1 flex w-full flex-col items-center gap-2 p-5", children: [(0, jsx_runtime_1.jsx)("span", { className: "font-sf-rounded text-2xl font-semibold", children: nftContract.name }), (0, jsx_runtime_1.jsx)("div", { className: "flex w-fit items-center gap-1", children: anyspendPrice ? ((0, jsx_runtime_1.jsx)(framer_motion_1.AnimatePresence, { mode: "wait", children: (0, jsx_runtime_1.jsx)("div", { className: (0, utils_1.cn)("text-as-primary group flex items-center text-3xl font-semibold transition-all", {
|
|
18
17
|
"opacity-0": isLoadingAnyspendPrice
|
|
19
18
|
}), children: (0, number_1.formatDisplayNumber)(anyspendPrice?.data?.currencyIn?.amountUsd, { style: "currency" }) }) })) : ((0, jsx_runtime_1.jsx)("div", { className: "h-[36px] w-full" })) })] })] })] }));
|
|
20
|
-
return ((0, jsx_runtime_1.jsx)(AnySpendCustom_1.AnySpendCustom, { isMainnet: isMainnet, loadOrder: loadOrder, mode: mode, recipientAddress: recipientAddress, orderType: anyspend_1.OrderType.MintNFT, dstChainId: nftContract.chainId, dstToken: nftContract.currency, dstAmount: nftContract.price, contractAddress: nftContract.contractAddress, encodedData: "0x", metadata: {
|
|
19
|
+
return ((0, jsx_runtime_1.jsx)(AnySpendCustom_1.AnySpendCustom, { isMainnet: isMainnet, loadOrder: loadOrder, mode: mode, recipientAddress: recipientAddress, orderType: anyspend_1.OrderType.MintNFT, dstChainId: nftContract.chainId, dstToken: nftContract.currency, dstAmount: nftContract.price, contractAddress: nftContract.contractAddress, encodedData: "0x", metadata: {
|
|
20
|
+
type: anyspend_1.OrderType.MintNFT,
|
|
21
|
+
nftContract: nftContract
|
|
22
|
+
}, header: header, onSuccess: onSuccess }));
|
|
21
23
|
}
|
|
22
24
|
function DropdownMenu({ nftContract }) {
|
|
23
25
|
const [open, setOpen] = (0, react_2.useState)(false);
|
|
@@ -6,9 +6,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.AnySpendStakeB3 = AnySpendStakeB3;
|
|
7
7
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
8
8
|
const anyspend_1 = require("../../../anyspend");
|
|
9
|
-
const EthIcon_1 = require("./icons/EthIcon");
|
|
10
|
-
const SolIcon_1 = require("./icons/SolIcon");
|
|
11
|
-
const USDCIcon_1 = require("./icons/USDCIcon");
|
|
12
9
|
const react_1 = require("../../../global-account/react");
|
|
13
10
|
const number_1 = require("../../../shared/utils/number");
|
|
14
11
|
const framer_motion_1 = require("framer-motion");
|
|
@@ -20,6 +17,9 @@ const viem_1 = require("viem");
|
|
|
20
17
|
const chains_1 = require("viem/chains");
|
|
21
18
|
const wagmi_1 = require("wagmi");
|
|
22
19
|
const AnySpendCustom_1 = require("./AnySpendCustom");
|
|
20
|
+
const EthIcon_1 = require("./icons/EthIcon");
|
|
21
|
+
const SolIcon_1 = require("./icons/SolIcon");
|
|
22
|
+
const USDCIcon_1 = require("./icons/USDCIcon");
|
|
23
23
|
const basePublicClient = (0, viem_1.createPublicClient)({
|
|
24
24
|
chain: chains_1.base,
|
|
25
25
|
transport: (0, viem_1.http)()
|
|
@@ -256,6 +256,7 @@ function AnySpendStakeB3({ isMainnet = true, loadOrder, mode = "modal", recipien
|
|
|
256
256
|
}
|
|
257
257
|
const encodedData = generateEncodedDataForStakingB3(userStakeAmount, recipientAddress);
|
|
258
258
|
return ((0, jsx_runtime_1.jsx)(AnySpendCustom_1.AnySpendCustom, { isMainnet: isMainnet, loadOrder: loadOrder, mode: mode, recipientAddress: recipientAddress, orderType: anyspend_1.OrderType.Custom, dstChainId: chains_1.base.id, dstToken: anyspend_1.B3_TOKEN, dstAmount: userStakeAmount, contractAddress: ERC20Staking, encodedData: encodedData, metadata: {
|
|
259
|
+
type: anyspend_1.OrderType.Custom,
|
|
259
260
|
action: "stake B3"
|
|
260
261
|
}, header: header, onSuccess: onSuccess, showRecipient: true }));
|
|
261
262
|
}
|
|
@@ -14,5 +14,8 @@ function AnySpendTournament(props) {
|
|
|
14
14
|
const header = ({ anyspendPrice, isLoadingAnyspendPrice }) => ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("div", { className: "z-10 mt-[-100px] flex h-[270px] w-full items-end justify-center", children: (0, jsx_runtime_1.jsx)("img", { src: "https://cdn.b3.fun/tournament-play.svg", alt: "Tournament Play", className: "h-[200px] w-[360px] object-cover object-center" }) }), (0, jsx_runtime_1.jsxs)("div", { className: "from-b3-react-background to-as-on-surface-1 mt-[-100px] w-full rounded-t-lg bg-gradient-to-t", children: [(0, jsx_runtime_1.jsx)("div", { className: "h-[100px] w-full" }), (0, jsx_runtime_1.jsxs)("div", { className: "flex w-full flex-col items-center gap-1 p-6 pt-0", children: [(0, jsx_runtime_1.jsxs)("span", { className: "font-sf-rounded text-center text-lg font-semibold", children: [action === "join" ? "Pay entry fee to join " : "Pay to fund ", " ", tournamentMetadata.name] }), (0, jsx_runtime_1.jsx)("div", { className: "mt-2 flex w-fit items-center gap-1", children: anyspendPrice ? ((0, jsx_runtime_1.jsx)(framer_motion_1.AnimatePresence, { mode: "wait", children: (0, jsx_runtime_1.jsxs)("div", { className: (0, utils_1.cn)("text-as-primary group flex items-center text-2xl font-semibold transition-all", {
|
|
15
15
|
"opacity-0": isLoadingAnyspendPrice
|
|
16
16
|
}), children: [(0, number_1.formatDisplayNumber)(anyspendPrice?.data?.currencyIn?.amountUsd, { style: "currency" }), " (", (0, number_1.formatTokenAmount)(BigInt(dstAmount), dstToken.decimals, 6, true), " ", dstToken.symbol, ")"] }) })) : ((0, jsx_runtime_1.jsx)("div", { className: "h-[32px] w-full" })) })] })] })] }));
|
|
17
|
-
return ((0, jsx_runtime_1.jsx)(AnySpendCustom_1.AnySpendCustom, { isMainnet: isMainnet, loadOrder: loadOrder, mode: mode, recipientAddress: action === "join" ? props.joinFor : undefined, orderType: action === "join" ? anyspend_1.OrderType.JoinTournament : anyspend_1.OrderType.FundTournament, dstChainId: tournamentChainId, dstToken: dstToken, dstAmount: dstAmount, contractAddress: tournamentContractAddress, encodedData: "0x", metadata: {
|
|
17
|
+
return ((0, jsx_runtime_1.jsx)(AnySpendCustom_1.AnySpendCustom, { isMainnet: isMainnet, loadOrder: loadOrder, mode: mode, recipientAddress: action === "join" ? props.joinFor : undefined, orderType: action === "join" ? anyspend_1.OrderType.JoinTournament : anyspend_1.OrderType.FundTournament, dstChainId: tournamentChainId, dstToken: dstToken, dstAmount: dstAmount, contractAddress: tournamentContractAddress, encodedData: "0x", metadata: {
|
|
18
|
+
type: action === "join" ? anyspend_1.OrderType.JoinTournament : anyspend_1.OrderType.FundTournament,
|
|
19
|
+
tournament: tournamentMetadata
|
|
20
|
+
}, header: header, onSuccess: onSuccess, showRecipient: action === "join" }));
|
|
18
21
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { GetOrderAndTxsResponse, GetQuoteRequest, GetQuoteResponse, SendPermitDataRequestBody, Token } from "../../anyspend/types";
|
|
2
1
|
import { OnrampOptions } from "../../anyspend/react";
|
|
2
|
+
import { GetOrderAndTxsResponse, GetQuoteRequest, GetQuoteResponse, SendPermitDataRequestBody, Token } from "../../anyspend/types";
|
|
3
3
|
export declare const anyspendService: {
|
|
4
4
|
getTokenList: (isMainnet: boolean, chainId: number, query: string) => Promise<Token[]>;
|
|
5
5
|
getToken: (isMainnet: boolean, chainId: number, tokenAddress: string) => Promise<Token>;
|