@b3dotfun/sdk 0.0.7-alpha.14 → 0.0.7-alpha.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/anyspend/react/components/AnySpendBuySpin.js +4 -2
- package/dist/cjs/anyspend/react/components/common/OrderDetails.js +15 -5
- package/dist/cjs/global-account/react/hooks/useB3EnsName.d.ts +7 -0
- package/dist/cjs/global-account/react/hooks/useB3EnsName.js +9 -0
- package/dist/esm/anyspend/react/components/AnySpendBuySpin.js +4 -2
- package/dist/esm/anyspend/react/components/common/OrderDetails.js +16 -6
- package/dist/esm/global-account/react/hooks/useB3EnsName.d.ts +7 -0
- package/dist/esm/global-account/react/hooks/useB3EnsName.js +9 -0
- package/dist/types/global-account/react/hooks/useB3EnsName.d.ts +7 -0
- package/package.json +1 -1
- package/src/anyspend/react/components/AnySpendBuySpin.tsx +6 -2
- package/src/anyspend/react/components/common/OrderDetails.tsx +26 -5
- package/src/global-account/react/hooks/useB3EnsName.ts +18 -0
|
@@ -237,7 +237,9 @@ function AnySpendBuySpin({ isMainnet = true, loadOrder, mode = "modal", spinwhee
|
|
|
237
237
|
return;
|
|
238
238
|
}
|
|
239
239
|
// Check maximum entries per user (0 means no limit)
|
|
240
|
-
if (paymentConfig &&
|
|
240
|
+
if (paymentConfig &&
|
|
241
|
+
paymentConfig.maxEntriesPerUser > BigInt(0) &&
|
|
242
|
+
BigInt(numValue) > paymentConfig.maxEntriesPerUser) {
|
|
241
243
|
setIsQuantityValid(false);
|
|
242
244
|
setUserSpinQuantity("");
|
|
243
245
|
setValidationError(`Maximum ${paymentConfig.maxEntriesPerUser.toString()} spins allowed`);
|
|
@@ -337,7 +339,7 @@ function AnySpendBuySpin({ isMainnet = true, loadOrder, mode = "modal", spinwhee
|
|
|
337
339
|
// Render quantity input prompt
|
|
338
340
|
if (showAmountPrompt) {
|
|
339
341
|
const pricePerEntry = (0, viem_1.formatUnits)(paymentConfig.pricePerEntry, 18);
|
|
340
|
-
const remainingEntries = wheelInfo ? wheelInfo.totalPrizesAvailable_ - wheelInfo.prizesRequestedCount_ :
|
|
342
|
+
const remainingEntries = wheelInfo ? wheelInfo.totalPrizesAvailable_ - wheelInfo.prizesRequestedCount_ : BigInt(0);
|
|
341
343
|
const wheelStatus = wheelInfo ? getWheelStatus(wheelInfo) : null;
|
|
342
344
|
const isSoldOut = wheelStatus === "sold_out";
|
|
343
345
|
const isActive = wheelStatus === "active";
|
|
@@ -274,14 +274,18 @@ exports.OrderDetails = (0, react_4.memo)(function OrderDetails({ isMainnet, mode
|
|
|
274
274
|
};
|
|
275
275
|
if (refundTxs) {
|
|
276
276
|
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)("div", { className: "relative mt-4 flex w-full flex-col gap-4", children: [(0, jsx_runtime_1.jsx)("div", { className: "bg-b3-react-background absolute bottom-2 left-4 top-2 z-[5] w-2", children: (0, jsx_runtime_1.jsx)(framer_motion_1.motion.div, { className: "from-as-brand/50 absolute left-[2px] top-0 z-10 w-[3px] bg-gradient-to-b from-20% via-purple-500/50 via-80% to-transparent", initial: { height: "0%" }, animate: { height: "100%" }, transition: { duration: 1.5, ease: "easeInOut" } }) }), depositTxs
|
|
277
|
-
? depositTxs.map(dTx => ((0, jsx_runtime_1.jsx)(TransactionDetails, { title:
|
|
277
|
+
? depositTxs.map(dTx => ((0, jsx_runtime_1.jsx)(TransactionDetails, { title: order.onrampMetadata?.vendor === anyspend_1.OnrampVendor.StripeWeb2
|
|
278
|
+
? `Received payment`
|
|
279
|
+
: `Received ${(0, number_1.formatTokenAmount)(BigInt(dTx.amount), srcToken.decimals)} ${srcToken.symbol}`, chainId: order.srcChain, tx: dTx, isProcessing: false }, dTx.txHash)))
|
|
278
280
|
: null, refundTxs
|
|
279
281
|
? refundTxs.map(rTx => ((0, jsx_runtime_1.jsx)(TransactionDetails, { title: `Refunded ${(0, number_1.formatTokenAmount)(BigInt(rTx.amount), srcToken.decimals)} ${srcToken.symbol}`, chainId: order.srcChain, tx: rTx, isProcessing: false }, rTx.txHash)))
|
|
280
282
|
: null] }), order.errorDetails && ((0, jsx_runtime_1.jsx)("div", { className: "flex justify-center", children: (0, jsx_runtime_1.jsx)("span", { className: "text-as-primary/50 text-center text-sm", style: { maxWidth: "40ch" }, children: (0, anyspend_1.getErrorDisplay)(order.errorDetails) }) })), (0, jsx_runtime_1.jsx)("button", { className: "bg-as-on-surface-2 text-as-secondary flex w-full items-center justify-center gap-2 rounded-lg p-2", onClick: mode === "page" ? onBack : () => setB3ModalOpen(false), children: mode === "page" ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: ["Return to Home ", (0, jsx_runtime_1.jsx)(lucide_react_1.Home, { className: "ml-2 h-4 w-4" })] })) : ("Close") })] }));
|
|
281
283
|
}
|
|
282
284
|
if (executeTx) {
|
|
283
285
|
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)("div", { className: "relative mt-4 flex w-full flex-col gap-4", children: [(0, jsx_runtime_1.jsx)("div", { className: "bg-b3-react-background absolute bottom-2 left-4 top-2 z-[5] w-2", children: (0, jsx_runtime_1.jsx)(framer_motion_1.motion.div, { className: "from-as-brand/50 absolute left-[2px] top-0 z-10 w-[3px] bg-gradient-to-b from-20% via-purple-500/50 via-80% to-transparent", initial: { height: "0%" }, animate: { height: "100%" }, transition: { duration: 1.5, ease: "easeInOut" } }) }), depositTxs
|
|
284
|
-
? depositTxs.map(dTxs => ((0, jsx_runtime_1.jsx)(TransactionDetails, { title:
|
|
286
|
+
? depositTxs.map(dTxs => ((0, jsx_runtime_1.jsx)(TransactionDetails, { title: order.onrampMetadata?.vendor === anyspend_1.OnrampVendor.StripeWeb2
|
|
287
|
+
? `Received payment`
|
|
288
|
+
: `Received ${(0, number_1.formatTokenAmount)(BigInt(dTxs.amount), srcToken.decimals)} ${srcToken.symbol}`, chainId: order.srcChain, tx: dTxs, isProcessing: false }, dTxs.txHash)))
|
|
285
289
|
: null, (0, jsx_runtime_1.jsx)(TransactionDetails, { title: "Processed Transaction", chainId: order.srcChain, tx: relayTx, delay: 0.5, isProcessing: false }), (0, jsx_runtime_1.jsx)(TransactionDetails, { title: order.type === anyspend_1.OrderType.Swap
|
|
286
290
|
? "Processed Swap"
|
|
287
291
|
: order.type === anyspend_1.OrderType.MintNFT
|
|
@@ -301,7 +305,9 @@ exports.OrderDetails = (0, react_4.memo)(function OrderDetails({ isMainnet, mode
|
|
|
301
305
|
}
|
|
302
306
|
if (relayTx && relayTx.status === "success") {
|
|
303
307
|
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)("div", { className: "relative mt-4 flex w-full flex-col gap-4", children: [(0, jsx_runtime_1.jsx)("div", { className: "bg-b3-react-background absolute bottom-2 left-4 top-2 z-[5] w-2", children: (0, jsx_runtime_1.jsx)(framer_motion_1.motion.div, { className: "from-as-brand/50 absolute left-[2px] top-0 z-10 w-[3px] bg-gradient-to-b from-20% via-purple-500/50 via-80% to-transparent", initial: { height: "0%" }, animate: { height: "100%" }, transition: { duration: 1.5, ease: "easeInOut" } }) }), depositTxs
|
|
304
|
-
? depositTxs.map(dTxs => ((0, jsx_runtime_1.jsx)(TransactionDetails, { title:
|
|
308
|
+
? depositTxs.map(dTxs => ((0, jsx_runtime_1.jsx)(TransactionDetails, { title: order.onrampMetadata?.vendor === anyspend_1.OnrampVendor.StripeWeb2
|
|
309
|
+
? `Received payment`
|
|
310
|
+
: `Received ${(0, number_1.formatTokenAmount)(BigInt(dTxs.amount), srcToken.decimals)} ${srcToken.symbol}`, chainId: order.srcChain, tx: dTxs, isProcessing: false }, dTxs.txHash)))
|
|
305
311
|
: null, order.srcChain === order.dstChain ? ((0, jsx_runtime_1.jsx)(TransactionDetails, { title: order.type === anyspend_1.OrderType.Swap
|
|
306
312
|
? "Processed Swap"
|
|
307
313
|
: order.type === anyspend_1.OrderType.MintNFT
|
|
@@ -330,7 +336,9 @@ exports.OrderDetails = (0, react_4.memo)(function OrderDetails({ isMainnet, mode
|
|
|
330
336
|
// This boolean indicates that user finish payment, and waiting for the deposit to be confirmed. We get this from query params (waitingForDeposit=true)
|
|
331
337
|
const waitingForDeposit = new URLSearchParams(window.location.search).get("waitingForDeposit") === "true";
|
|
332
338
|
if (depositTxs?.length || waitingForDeposit) {
|
|
333
|
-
return ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (0, jsx_runtime_1.jsxs)("div", { className: "relative mt-4 flex w-full flex-col gap-6", children: [(0, jsx_runtime_1.jsx)("div", { className: "bg-b3-react-background absolute bottom-2 left-4 top-2 z-[5] w-2", children: (0, jsx_runtime_1.jsx)(framer_motion_1.motion.div, { className: "from-as-brand/50 absolute left-[2px] top-0 z-10 w-[3px] bg-gradient-to-b from-20% via-purple-500/50 via-80% to-transparent", initial: { height: "0%" }, animate: { height: "100%" }, transition: { duration: 1, ease: "easeInOut" } }) }), (depositTxs || []).map((dTxs, index) => ((0, jsx_runtime_1.jsx)(TransactionDetails, { title:
|
|
339
|
+
return ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (0, jsx_runtime_1.jsxs)("div", { className: "relative mt-4 flex w-full flex-col gap-6", children: [(0, jsx_runtime_1.jsx)("div", { className: "bg-b3-react-background absolute bottom-2 left-4 top-2 z-[5] w-2", children: (0, jsx_runtime_1.jsx)(framer_motion_1.motion.div, { className: "from-as-brand/50 absolute left-[2px] top-0 z-10 w-[3px] bg-gradient-to-b from-20% via-purple-500/50 via-80% to-transparent", initial: { height: "0%" }, animate: { height: "100%" }, transition: { duration: 1, ease: "easeInOut" } }) }), (depositTxs || []).map((dTxs, index) => ((0, jsx_runtime_1.jsx)(TransactionDetails, { title: order.onrampMetadata?.vendor === anyspend_1.OnrampVendor.StripeWeb2
|
|
340
|
+
? `Received payment`
|
|
341
|
+
: `Received ${(0, number_1.formatTokenAmount)(BigInt(dTxs.amount), srcToken.decimals)} ${srcToken.symbol}`, chainId: order.srcChain, tx: dTxs, isProcessing: index < (depositTxs || []).length - 1 ? false : !depositEnoughAmount }, dTxs.txHash))), statusDisplay === "failure" ? ((0, jsx_runtime_1.jsx)(TransactionDetails, { title: statusText, chainId: order.srcChain, tx: null, isProcessing: false, delay: 0.5 })) : depositEnoughAmount ? ((0, jsx_runtime_1.jsx)(TransactionDetails, { title: order.type === anyspend_1.OrderType.Swap
|
|
334
342
|
? "Processing Swap"
|
|
335
343
|
: order.type === anyspend_1.OrderType.MintNFT
|
|
336
344
|
? "Minting NFT"
|
|
@@ -338,7 +346,9 @@ exports.OrderDetails = (0, react_4.memo)(function OrderDetails({ isMainnet, mode
|
|
|
338
346
|
? "Joining Tournament"
|
|
339
347
|
: order.type === anyspend_1.OrderType.FundTournament
|
|
340
348
|
? "Funding Tournament"
|
|
341
|
-
: "Processing Transaction", chainId: order.srcChain, tx: null, isProcessing: true, delay: 0.5 })) : ((0, jsx_runtime_1.jsx)(TransactionDetails, { title:
|
|
349
|
+
: "Processing Transaction", chainId: order.srcChain, tx: null, isProcessing: true, delay: 0.5 })) : ((0, jsx_runtime_1.jsx)(TransactionDetails, { title: order.onrampMetadata?.vendor === anyspend_1.OnrampVendor.StripeWeb2
|
|
350
|
+
? `Waiting for payment`
|
|
351
|
+
: `Waiting for deposit ${formattedDepositDeficit} ${srcToken.symbol}`, chainId: order.srcChain, tx: null, isProcessing: true, delay: 0.5 }))] }) }));
|
|
342
352
|
}
|
|
343
353
|
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [statusDisplay === "failure" && ((0, jsx_runtime_1.jsx)("div", { className: "flex w-full flex-col items-center gap-3 whitespace-nowrap pb-2 text-sm", children: (0, jsx_runtime_1.jsx)("div", { className: "bg-as-light-brand/20 flex w-full flex-col gap-4 rounded-lg p-8", children: (0, jsx_runtime_1.jsx)("div", { className: "text-as-primary", style: { whiteSpace: "normal" }, children: "This order is no longer valid because the order expired." }) }) })), statusDisplay === "processing" && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [order.onrampMetadata ? ((0, jsx_runtime_1.jsx)(PaymentVendorUI_1.default, { isMainnet: isMainnet, order: order, dstTokenSymbol: dstToken.symbol })) : ((0, jsx_runtime_1.jsxs)("div", { className: "relative flex w-full flex-1 flex-col", children: [(0, jsx_runtime_1.jsxs)("div", { className: "flex flex-col gap-1", children: [(0, jsx_runtime_1.jsx)("span", { className: "text-as-primary/50", children: "Please send" }), (0, jsx_runtime_1.jsxs)("div", { className: "flex w-full flex-wrap items-center gap-6 sm:justify-between sm:gap-0", children: [(0, jsx_runtime_1.jsx)(react_1.CopyToClipboard, { text: roundedUpSrcAmount, onCopy: () => {
|
|
344
354
|
sonner_1.toast.success("Copied to clipboard");
|
|
@@ -3,4 +3,11 @@ export declare const useB3EnsName: () => {
|
|
|
3
3
|
getEns: (address: string) => Promise<{
|
|
4
4
|
name: string;
|
|
5
5
|
}>;
|
|
6
|
+
lookupEnsName: (name: `${string}.b3.fun`) => Promise<{
|
|
7
|
+
name: string;
|
|
8
|
+
owner: `0x${string}`;
|
|
9
|
+
addresses: Record<string, `0x${string}`>;
|
|
10
|
+
createdAt: number;
|
|
11
|
+
updatedAt: number;
|
|
12
|
+
}>;
|
|
6
13
|
};
|
|
@@ -31,9 +31,18 @@ const useB3EnsName = () => {
|
|
|
31
31
|
const data = await response.json();
|
|
32
32
|
return data;
|
|
33
33
|
};
|
|
34
|
+
const lookupEnsName = async (name) => {
|
|
35
|
+
const response = await fetch(`${constants_1.ENS_GATEWAY_URL}get/${name}`);
|
|
36
|
+
if (!response.ok) {
|
|
37
|
+
throw new Error(`Failed to fetch ENS lookup: ${response.statusText}`);
|
|
38
|
+
}
|
|
39
|
+
const data = await response.json();
|
|
40
|
+
return data;
|
|
41
|
+
};
|
|
34
42
|
return (0, react_1.useMemo)(() => ({
|
|
35
43
|
registerEns,
|
|
36
44
|
getEns,
|
|
45
|
+
lookupEnsName,
|
|
37
46
|
}), []);
|
|
38
47
|
};
|
|
39
48
|
exports.useB3EnsName = useB3EnsName;
|
|
@@ -231,7 +231,9 @@ export function AnySpendBuySpin({ isMainnet = true, loadOrder, mode = "modal", s
|
|
|
231
231
|
return;
|
|
232
232
|
}
|
|
233
233
|
// Check maximum entries per user (0 means no limit)
|
|
234
|
-
if (paymentConfig &&
|
|
234
|
+
if (paymentConfig &&
|
|
235
|
+
paymentConfig.maxEntriesPerUser > BigInt(0) &&
|
|
236
|
+
BigInt(numValue) > paymentConfig.maxEntriesPerUser) {
|
|
235
237
|
setIsQuantityValid(false);
|
|
236
238
|
setUserSpinQuantity("");
|
|
237
239
|
setValidationError(`Maximum ${paymentConfig.maxEntriesPerUser.toString()} spins allowed`);
|
|
@@ -331,7 +333,7 @@ export function AnySpendBuySpin({ isMainnet = true, loadOrder, mode = "modal", s
|
|
|
331
333
|
// Render quantity input prompt
|
|
332
334
|
if (showAmountPrompt) {
|
|
333
335
|
const pricePerEntry = formatUnits(paymentConfig.pricePerEntry, 18);
|
|
334
|
-
const remainingEntries = wheelInfo ? wheelInfo.totalPrizesAvailable_ - wheelInfo.prizesRequestedCount_ :
|
|
336
|
+
const remainingEntries = wheelInfo ? wheelInfo.totalPrizesAvailable_ - wheelInfo.prizesRequestedCount_ : BigInt(0);
|
|
335
337
|
const wheelStatus = wheelInfo ? getWheelStatus(wheelInfo) : null;
|
|
336
338
|
const isSoldOut = wheelStatus === "sold_out";
|
|
337
339
|
const isActive = wheelStatus === "active";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
|
-
import { ALL_CHAINS, capitalizeFirstLetter, EVM_CHAINS, getChainName, getErrorDisplay, getExplorerTxUrl, getPaymentUrl, getStatusDisplay, isNativeToken, OrderStatus, OrderType, RELAY_ETH_ADDRESS, zNft, zToken, zTournament, } from "../../../../anyspend/index.js";
|
|
3
|
+
import { ALL_CHAINS, capitalizeFirstLetter, EVM_CHAINS, getChainName, getErrorDisplay, getExplorerTxUrl, getPaymentUrl, getStatusDisplay, isNativeToken, OnrampVendor, OrderStatus, OrderType, RELAY_ETH_ADDRESS, zNft, zToken, zTournament, } from "../../../../anyspend/index.js";
|
|
4
4
|
import { Badge, Button, CopyToClipboard, ShinyButton, Skeleton, TextLoop, TextShimmer, useAccountWallet, useChainSwitchWithAction, useModalStore, useOnchainName, } from "../../../../global-account/react/index.js";
|
|
5
5
|
import { cn } from "../../../../shared/utils/index.js";
|
|
6
6
|
import centerTruncate from "../../../../shared/utils/centerTruncate.js";
|
|
@@ -268,14 +268,18 @@ export const OrderDetails = memo(function OrderDetails({ isMainnet, mode = "moda
|
|
|
268
268
|
};
|
|
269
269
|
if (refundTxs) {
|
|
270
270
|
return (_jsxs(_Fragment, { children: [_jsxs("div", { className: "relative mt-4 flex w-full flex-col gap-4", children: [_jsx("div", { className: "bg-b3-react-background absolute bottom-2 left-4 top-2 z-[5] w-2", children: _jsx(motion.div, { className: "from-as-brand/50 absolute left-[2px] top-0 z-10 w-[3px] bg-gradient-to-b from-20% via-purple-500/50 via-80% to-transparent", initial: { height: "0%" }, animate: { height: "100%" }, transition: { duration: 1.5, ease: "easeInOut" } }) }), depositTxs
|
|
271
|
-
? depositTxs.map(dTx => (_jsx(TransactionDetails, { title:
|
|
271
|
+
? depositTxs.map(dTx => (_jsx(TransactionDetails, { title: order.onrampMetadata?.vendor === OnrampVendor.StripeWeb2
|
|
272
|
+
? `Received payment`
|
|
273
|
+
: `Received ${formatTokenAmount(BigInt(dTx.amount), srcToken.decimals)} ${srcToken.symbol}`, chainId: order.srcChain, tx: dTx, isProcessing: false }, dTx.txHash)))
|
|
272
274
|
: null, refundTxs
|
|
273
275
|
? refundTxs.map(rTx => (_jsx(TransactionDetails, { title: `Refunded ${formatTokenAmount(BigInt(rTx.amount), srcToken.decimals)} ${srcToken.symbol}`, chainId: order.srcChain, tx: rTx, isProcessing: false }, rTx.txHash)))
|
|
274
276
|
: null] }), order.errorDetails && (_jsx("div", { className: "flex justify-center", children: _jsx("span", { className: "text-as-primary/50 text-center text-sm", style: { maxWidth: "40ch" }, children: getErrorDisplay(order.errorDetails) }) })), _jsx("button", { className: "bg-as-on-surface-2 text-as-secondary flex w-full items-center justify-center gap-2 rounded-lg p-2", onClick: mode === "page" ? onBack : () => setB3ModalOpen(false), children: mode === "page" ? (_jsxs(_Fragment, { children: ["Return to Home ", _jsx(Home, { className: "ml-2 h-4 w-4" })] })) : ("Close") })] }));
|
|
275
277
|
}
|
|
276
278
|
if (executeTx) {
|
|
277
279
|
return (_jsxs(_Fragment, { children: [_jsxs("div", { className: "relative mt-4 flex w-full flex-col gap-4", children: [_jsx("div", { className: "bg-b3-react-background absolute bottom-2 left-4 top-2 z-[5] w-2", children: _jsx(motion.div, { className: "from-as-brand/50 absolute left-[2px] top-0 z-10 w-[3px] bg-gradient-to-b from-20% via-purple-500/50 via-80% to-transparent", initial: { height: "0%" }, animate: { height: "100%" }, transition: { duration: 1.5, ease: "easeInOut" } }) }), depositTxs
|
|
278
|
-
? depositTxs.map(dTxs => (_jsx(TransactionDetails, { title:
|
|
280
|
+
? depositTxs.map(dTxs => (_jsx(TransactionDetails, { title: order.onrampMetadata?.vendor === OnrampVendor.StripeWeb2
|
|
281
|
+
? `Received payment`
|
|
282
|
+
: `Received ${formatTokenAmount(BigInt(dTxs.amount), srcToken.decimals)} ${srcToken.symbol}`, chainId: order.srcChain, tx: dTxs, isProcessing: false }, dTxs.txHash)))
|
|
279
283
|
: null, _jsx(TransactionDetails, { title: "Processed Transaction", chainId: order.srcChain, tx: relayTx, delay: 0.5, isProcessing: false }), _jsx(TransactionDetails, { title: order.type === OrderType.Swap
|
|
280
284
|
? "Processed Swap"
|
|
281
285
|
: order.type === OrderType.MintNFT
|
|
@@ -295,7 +299,9 @@ export const OrderDetails = memo(function OrderDetails({ isMainnet, mode = "moda
|
|
|
295
299
|
}
|
|
296
300
|
if (relayTx && relayTx.status === "success") {
|
|
297
301
|
return (_jsxs(_Fragment, { children: [_jsxs("div", { className: "relative mt-4 flex w-full flex-col gap-4", children: [_jsx("div", { className: "bg-b3-react-background absolute bottom-2 left-4 top-2 z-[5] w-2", children: _jsx(motion.div, { className: "from-as-brand/50 absolute left-[2px] top-0 z-10 w-[3px] bg-gradient-to-b from-20% via-purple-500/50 via-80% to-transparent", initial: { height: "0%" }, animate: { height: "100%" }, transition: { duration: 1.5, ease: "easeInOut" } }) }), depositTxs
|
|
298
|
-
? depositTxs.map(dTxs => (_jsx(TransactionDetails, { title:
|
|
302
|
+
? depositTxs.map(dTxs => (_jsx(TransactionDetails, { title: order.onrampMetadata?.vendor === OnrampVendor.StripeWeb2
|
|
303
|
+
? `Received payment`
|
|
304
|
+
: `Received ${formatTokenAmount(BigInt(dTxs.amount), srcToken.decimals)} ${srcToken.symbol}`, chainId: order.srcChain, tx: dTxs, isProcessing: false }, dTxs.txHash)))
|
|
299
305
|
: null, order.srcChain === order.dstChain ? (_jsx(TransactionDetails, { title: order.type === OrderType.Swap
|
|
300
306
|
? "Processed Swap"
|
|
301
307
|
: order.type === OrderType.MintNFT
|
|
@@ -324,7 +330,9 @@ export const OrderDetails = memo(function OrderDetails({ isMainnet, mode = "moda
|
|
|
324
330
|
// This boolean indicates that user finish payment, and waiting for the deposit to be confirmed. We get this from query params (waitingForDeposit=true)
|
|
325
331
|
const waitingForDeposit = new URLSearchParams(window.location.search).get("waitingForDeposit") === "true";
|
|
326
332
|
if (depositTxs?.length || waitingForDeposit) {
|
|
327
|
-
return (_jsx(_Fragment, { children: _jsxs("div", { className: "relative mt-4 flex w-full flex-col gap-6", children: [_jsx("div", { className: "bg-b3-react-background absolute bottom-2 left-4 top-2 z-[5] w-2", children: _jsx(motion.div, { className: "from-as-brand/50 absolute left-[2px] top-0 z-10 w-[3px] bg-gradient-to-b from-20% via-purple-500/50 via-80% to-transparent", initial: { height: "0%" }, animate: { height: "100%" }, transition: { duration: 1, ease: "easeInOut" } }) }), (depositTxs || []).map((dTxs, index) => (_jsx(TransactionDetails, { title:
|
|
333
|
+
return (_jsx(_Fragment, { children: _jsxs("div", { className: "relative mt-4 flex w-full flex-col gap-6", children: [_jsx("div", { className: "bg-b3-react-background absolute bottom-2 left-4 top-2 z-[5] w-2", children: _jsx(motion.div, { className: "from-as-brand/50 absolute left-[2px] top-0 z-10 w-[3px] bg-gradient-to-b from-20% via-purple-500/50 via-80% to-transparent", initial: { height: "0%" }, animate: { height: "100%" }, transition: { duration: 1, ease: "easeInOut" } }) }), (depositTxs || []).map((dTxs, index) => (_jsx(TransactionDetails, { title: order.onrampMetadata?.vendor === OnrampVendor.StripeWeb2
|
|
334
|
+
? `Received payment`
|
|
335
|
+
: `Received ${formatTokenAmount(BigInt(dTxs.amount), srcToken.decimals)} ${srcToken.symbol}`, chainId: order.srcChain, tx: dTxs, isProcessing: index < (depositTxs || []).length - 1 ? false : !depositEnoughAmount }, dTxs.txHash))), statusDisplay === "failure" ? (_jsx(TransactionDetails, { title: statusText, chainId: order.srcChain, tx: null, isProcessing: false, delay: 0.5 })) : depositEnoughAmount ? (_jsx(TransactionDetails, { title: order.type === OrderType.Swap
|
|
328
336
|
? "Processing Swap"
|
|
329
337
|
: order.type === OrderType.MintNFT
|
|
330
338
|
? "Minting NFT"
|
|
@@ -332,7 +340,9 @@ export const OrderDetails = memo(function OrderDetails({ isMainnet, mode = "moda
|
|
|
332
340
|
? "Joining Tournament"
|
|
333
341
|
: order.type === OrderType.FundTournament
|
|
334
342
|
? "Funding Tournament"
|
|
335
|
-
: "Processing Transaction", chainId: order.srcChain, tx: null, isProcessing: true, delay: 0.5 })) : (_jsx(TransactionDetails, { title:
|
|
343
|
+
: "Processing Transaction", chainId: order.srcChain, tx: null, isProcessing: true, delay: 0.5 })) : (_jsx(TransactionDetails, { title: order.onrampMetadata?.vendor === OnrampVendor.StripeWeb2
|
|
344
|
+
? `Waiting for payment`
|
|
345
|
+
: `Waiting for deposit ${formattedDepositDeficit} ${srcToken.symbol}`, chainId: order.srcChain, tx: null, isProcessing: true, delay: 0.5 }))] }) }));
|
|
336
346
|
}
|
|
337
347
|
return (_jsxs(_Fragment, { children: [statusDisplay === "failure" && (_jsx("div", { className: "flex w-full flex-col items-center gap-3 whitespace-nowrap pb-2 text-sm", children: _jsx("div", { className: "bg-as-light-brand/20 flex w-full flex-col gap-4 rounded-lg p-8", children: _jsx("div", { className: "text-as-primary", style: { whiteSpace: "normal" }, children: "This order is no longer valid because the order expired." }) }) })), statusDisplay === "processing" && (_jsxs(_Fragment, { children: [order.onrampMetadata ? (_jsx(PaymentVendorUI, { isMainnet: isMainnet, order: order, dstTokenSymbol: dstToken.symbol })) : (_jsxs("div", { className: "relative flex w-full flex-1 flex-col", children: [_jsxs("div", { className: "flex flex-col gap-1", children: [_jsx("span", { className: "text-as-primary/50", children: "Please send" }), _jsxs("div", { className: "flex w-full flex-wrap items-center gap-6 sm:justify-between sm:gap-0", children: [_jsx(CopyToClipboard, { text: roundedUpSrcAmount, onCopy: () => {
|
|
338
348
|
toast.success("Copied to clipboard");
|
|
@@ -3,4 +3,11 @@ export declare const useB3EnsName: () => {
|
|
|
3
3
|
getEns: (address: string) => Promise<{
|
|
4
4
|
name: string;
|
|
5
5
|
}>;
|
|
6
|
+
lookupEnsName: (name: `${string}.b3.fun`) => Promise<{
|
|
7
|
+
name: string;
|
|
8
|
+
owner: `0x${string}`;
|
|
9
|
+
addresses: Record<string, `0x${string}`>;
|
|
10
|
+
createdAt: number;
|
|
11
|
+
updatedAt: number;
|
|
12
|
+
}>;
|
|
6
13
|
};
|
|
@@ -28,8 +28,17 @@ export const useB3EnsName = () => {
|
|
|
28
28
|
const data = await response.json();
|
|
29
29
|
return data;
|
|
30
30
|
};
|
|
31
|
+
const lookupEnsName = async (name) => {
|
|
32
|
+
const response = await fetch(`${ENS_GATEWAY_URL}get/${name}`);
|
|
33
|
+
if (!response.ok) {
|
|
34
|
+
throw new Error(`Failed to fetch ENS lookup: ${response.statusText}`);
|
|
35
|
+
}
|
|
36
|
+
const data = await response.json();
|
|
37
|
+
return data;
|
|
38
|
+
};
|
|
31
39
|
return useMemo(() => ({
|
|
32
40
|
registerEns,
|
|
33
41
|
getEns,
|
|
42
|
+
lookupEnsName,
|
|
34
43
|
}), []);
|
|
35
44
|
};
|
|
@@ -3,4 +3,11 @@ export declare const useB3EnsName: () => {
|
|
|
3
3
|
getEns: (address: string) => Promise<{
|
|
4
4
|
name: string;
|
|
5
5
|
}>;
|
|
6
|
+
lookupEnsName: (name: `${string}.b3.fun`) => Promise<{
|
|
7
|
+
name: string;
|
|
8
|
+
owner: `0x${string}`;
|
|
9
|
+
addresses: Record<string, `0x${string}`>;
|
|
10
|
+
createdAt: number;
|
|
11
|
+
updatedAt: number;
|
|
12
|
+
}>;
|
|
6
13
|
};
|
package/package.json
CHANGED
|
@@ -315,7 +315,11 @@ export function AnySpendBuySpin({
|
|
|
315
315
|
}
|
|
316
316
|
|
|
317
317
|
// Check maximum entries per user (0 means no limit)
|
|
318
|
-
if (
|
|
318
|
+
if (
|
|
319
|
+
paymentConfig &&
|
|
320
|
+
paymentConfig.maxEntriesPerUser > BigInt(0) &&
|
|
321
|
+
BigInt(numValue) > paymentConfig.maxEntriesPerUser
|
|
322
|
+
) {
|
|
319
323
|
setIsQuantityValid(false);
|
|
320
324
|
setUserSpinQuantity("");
|
|
321
325
|
setValidationError(`Maximum ${paymentConfig.maxEntriesPerUser.toString()} spins allowed`);
|
|
@@ -465,7 +469,7 @@ export function AnySpendBuySpin({
|
|
|
465
469
|
// Render quantity input prompt
|
|
466
470
|
if (showAmountPrompt) {
|
|
467
471
|
const pricePerEntry = formatUnits(paymentConfig.pricePerEntry, 18);
|
|
468
|
-
const remainingEntries = wheelInfo ? wheelInfo.totalPrizesAvailable_ - wheelInfo.prizesRequestedCount_ :
|
|
472
|
+
const remainingEntries = wheelInfo ? wheelInfo.totalPrizesAvailable_ - wheelInfo.prizesRequestedCount_ : BigInt(0);
|
|
469
473
|
const wheelStatus = wheelInfo ? getWheelStatus(wheelInfo) : null;
|
|
470
474
|
const isSoldOut = wheelStatus === "sold_out";
|
|
471
475
|
const isActive = wheelStatus === "active";
|
|
@@ -12,6 +12,7 @@ import {
|
|
|
12
12
|
getPaymentUrl,
|
|
13
13
|
getStatusDisplay,
|
|
14
14
|
isNativeToken,
|
|
15
|
+
OnrampVendor,
|
|
15
16
|
Order,
|
|
16
17
|
OrderStatus,
|
|
17
18
|
OrderType,
|
|
@@ -413,7 +414,11 @@ export const OrderDetails = memo(function OrderDetails({
|
|
|
413
414
|
? depositTxs.map(dTx => (
|
|
414
415
|
<TransactionDetails
|
|
415
416
|
key={dTx.txHash}
|
|
416
|
-
title={
|
|
417
|
+
title={
|
|
418
|
+
order.onrampMetadata?.vendor === OnrampVendor.StripeWeb2
|
|
419
|
+
? `Received payment`
|
|
420
|
+
: `Received ${formatTokenAmount(BigInt(dTx.amount), srcToken.decimals)} ${srcToken.symbol}`
|
|
421
|
+
}
|
|
417
422
|
chainId={order.srcChain}
|
|
418
423
|
tx={dTx}
|
|
419
424
|
isProcessing={false}
|
|
@@ -471,7 +476,11 @@ export const OrderDetails = memo(function OrderDetails({
|
|
|
471
476
|
? depositTxs.map(dTxs => (
|
|
472
477
|
<TransactionDetails
|
|
473
478
|
key={dTxs.txHash}
|
|
474
|
-
title={
|
|
479
|
+
title={
|
|
480
|
+
order.onrampMetadata?.vendor === OnrampVendor.StripeWeb2
|
|
481
|
+
? `Received payment`
|
|
482
|
+
: `Received ${formatTokenAmount(BigInt(dTxs.amount), srcToken.decimals)} ${srcToken.symbol}`
|
|
483
|
+
}
|
|
475
484
|
chainId={order.srcChain}
|
|
476
485
|
tx={dTxs}
|
|
477
486
|
isProcessing={false}
|
|
@@ -571,7 +580,11 @@ export const OrderDetails = memo(function OrderDetails({
|
|
|
571
580
|
? depositTxs.map(dTxs => (
|
|
572
581
|
<TransactionDetails
|
|
573
582
|
key={dTxs.txHash}
|
|
574
|
-
title={
|
|
583
|
+
title={
|
|
584
|
+
order.onrampMetadata?.vendor === OnrampVendor.StripeWeb2
|
|
585
|
+
? `Received payment`
|
|
586
|
+
: `Received ${formatTokenAmount(BigInt(dTxs.amount), srcToken.decimals)} ${srcToken.symbol}`
|
|
587
|
+
}
|
|
575
588
|
chainId={order.srcChain}
|
|
576
589
|
tx={dTxs}
|
|
577
590
|
isProcessing={false}
|
|
@@ -696,7 +709,11 @@ export const OrderDetails = memo(function OrderDetails({
|
|
|
696
709
|
{(depositTxs || []).map((dTxs, index) => (
|
|
697
710
|
<TransactionDetails
|
|
698
711
|
key={dTxs.txHash}
|
|
699
|
-
title={
|
|
712
|
+
title={
|
|
713
|
+
order.onrampMetadata?.vendor === OnrampVendor.StripeWeb2
|
|
714
|
+
? `Received payment`
|
|
715
|
+
: `Received ${formatTokenAmount(BigInt(dTxs.amount), srcToken.decimals)} ${srcToken.symbol}`
|
|
716
|
+
}
|
|
700
717
|
chainId={order.srcChain}
|
|
701
718
|
tx={dTxs}
|
|
702
719
|
isProcessing={index < (depositTxs || []).length - 1 ? false : !depositEnoughAmount}
|
|
@@ -730,7 +747,11 @@ export const OrderDetails = memo(function OrderDetails({
|
|
|
730
747
|
/>
|
|
731
748
|
) : (
|
|
732
749
|
<TransactionDetails
|
|
733
|
-
title={
|
|
750
|
+
title={
|
|
751
|
+
order.onrampMetadata?.vendor === OnrampVendor.StripeWeb2
|
|
752
|
+
? `Waiting for payment`
|
|
753
|
+
: `Waiting for deposit ${formattedDepositDeficit} ${srcToken.symbol}`
|
|
754
|
+
}
|
|
734
755
|
chainId={order.srcChain}
|
|
735
756
|
tx={null}
|
|
736
757
|
isProcessing={true}
|
|
@@ -33,10 +33,28 @@ export const useB3EnsName = () => {
|
|
|
33
33
|
return data as { name: string };
|
|
34
34
|
};
|
|
35
35
|
|
|
36
|
+
const lookupEnsName = async (name: `${string}.b3.fun`) => {
|
|
37
|
+
const response = await fetch(`${ENS_GATEWAY_URL}get/${name}`);
|
|
38
|
+
|
|
39
|
+
if (!response.ok) {
|
|
40
|
+
throw new Error(`Failed to fetch ENS lookup: ${response.statusText}`);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const data = await response.json();
|
|
44
|
+
return data as {
|
|
45
|
+
name: string;
|
|
46
|
+
owner: `0x${string}`;
|
|
47
|
+
addresses: Record<string, `0x${string}`>;
|
|
48
|
+
createdAt: number;
|
|
49
|
+
updatedAt: number;
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
|
|
36
53
|
return useMemo(
|
|
37
54
|
() => ({
|
|
38
55
|
registerEns,
|
|
39
56
|
getEns,
|
|
57
|
+
lookupEnsName,
|
|
40
58
|
}),
|
|
41
59
|
[],
|
|
42
60
|
);
|