@b3dotfun/sdk 0.0.8-alpha.5 → 0.0.8-alpha.7
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.
|
@@ -158,7 +158,7 @@ function AnySpendCustom({ isMainnet = true, loadOrder, mode = "modal", recipient
|
|
|
158
158
|
}
|
|
159
159
|
}
|
|
160
160
|
}, [srcChainId, tokenList, getTokenWithBalance, nativeTokens, fungibleTokens, dirtySelectSrcToken, dstToken.address]);
|
|
161
|
-
const { account: isAuthenticated } =
|
|
161
|
+
// const { account: isAuthenticated } = useB3();
|
|
162
162
|
const getRelayQuoteRequest = (0, react_3.useMemo)(() => {
|
|
163
163
|
return generateGetRelayQuoteRequest({
|
|
164
164
|
orderType: orderType,
|
|
@@ -329,22 +329,22 @@ function AnySpendCustom({ isMainnet = true, loadOrder, mode = "modal", recipient
|
|
|
329
329
|
}
|
|
330
330
|
};
|
|
331
331
|
const handleConfirmOrder = async (onramp) => {
|
|
332
|
-
if (!isAuthenticated) {
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
}
|
|
332
|
+
// if (!isAuthenticated) {
|
|
333
|
+
// // Copied from https://github.com/b3-fun/b3-mono/blob/main/apps/anyspend-web/components/User/index.tsx#L85
|
|
334
|
+
// setB3ModalContentType({
|
|
335
|
+
// chain: {
|
|
336
|
+
// ...b3,
|
|
337
|
+
// rpc: "https://mainnet-rpc.b3.fun",
|
|
338
|
+
// blockExplorers: [{ name: "B3 Explorer", url: "https://explorer.b3.fun/" }],
|
|
339
|
+
// testnet: undefined,
|
|
340
|
+
// },
|
|
341
|
+
// partnerId: String(process.env.NEXT_PUBLIC_THIRDWEB_PARTNER_ID),
|
|
342
|
+
// type: "signInWithB3",
|
|
343
|
+
// showBackButton: false,
|
|
344
|
+
// });
|
|
345
|
+
// setB3ModalOpen(true);
|
|
346
|
+
// return;
|
|
347
|
+
// }
|
|
348
348
|
if (recipientAddress) {
|
|
349
349
|
try {
|
|
350
350
|
await handleCreateOrder(recipientAddress, onramp);
|
|
@@ -355,7 +355,7 @@ function AnySpendCustom({ isMainnet = true, loadOrder, mode = "modal", recipient
|
|
|
355
355
|
}
|
|
356
356
|
}
|
|
357
357
|
};
|
|
358
|
-
const recipientSection = showRecipient &&
|
|
358
|
+
const recipientSection = showRecipient && recipientAddress ? ((0, jsx_runtime_1.jsxs)(framer_motion_1.motion.div, { initial: false, animate: {
|
|
359
359
|
opacity: hasMounted ? 1 : 0,
|
|
360
360
|
y: hasMounted ? 0 : 20,
|
|
361
361
|
filter: hasMounted ? "blur(0px)" : "blur(10px)",
|
|
@@ -394,7 +394,7 @@ function AnySpendCustom({ isMainnet = true, loadOrder, mode = "modal", recipient
|
|
|
394
394
|
opacity: hasMounted ? 1 : 0,
|
|
395
395
|
y: hasMounted ? 0 : 20,
|
|
396
396
|
filter: hasMounted ? "blur(0px)" : "blur(10px)",
|
|
397
|
-
}, transition: { duration: 0.3, delay: 0.3, ease: "easeInOut" }, className: "flex w-full flex-col gap-2", children: (0, jsx_runtime_1.jsx)(react_2.ShinyButton, { accentColor: "hsl(var(--as-brand))", textColor: "text-white", disabled: isCreatingOrder || isLoadingAnyspendQuote || !anyspendQuote, onClick: () => handleConfirmOrder(), className: "relative w-full", children:
|
|
397
|
+
}, transition: { duration: 0.3, delay: 0.3, ease: "easeInOut" }, className: "flex w-full flex-col gap-2", children: (0, jsx_runtime_1.jsx)(react_2.ShinyButton, { accentColor: "hsl(var(--as-brand))", textColor: "text-white", disabled: isCreatingOrder || isLoadingAnyspendQuote || !anyspendQuote, onClick: () => handleConfirmOrder(), className: "relative w-full", children: 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_2.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)
|
|
398
398
|
? metadata.nftContract.type === anyspend_1.NftType.ERC1155
|
|
399
399
|
? {
|
|
400
400
|
type: anyspend_1.NftType.ERC1155,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
2
|
import { eqci, getDefaultToken, isCustomTxMetadata, isNftMetadata, isTournamentMetadata, NftType, OrderStatus, OrderType, RELAY_ETH_ADDRESS, USDC_BASE, } from "../../../anyspend/index.js";
|
|
3
3
|
import { useAnyspendCreateOnrampOrder, useAnyspendCreateOrder, useAnyspendOrderAndTransactions, useAnyspendQuote, useAnyspendTokenList, useGeoOnrampOptions, } from "../../../anyspend/react/index.js";
|
|
4
|
-
import { Badge, Button, Dialog, DialogContent, Input, ShinyButton, Skeleton, StyleRoot, Tabs, TabsContent, TabsList, TabTrigger, TextShimmer, Tooltip, TooltipContent, TooltipTrigger, TransitionPanel, useAccountWallet,
|
|
4
|
+
import { Badge, Button, Dialog, DialogContent, Input, ShinyButton, Skeleton, StyleRoot, Tabs, TabsContent, TabsList, TabTrigger, TextShimmer, Tooltip, TooltipContent, TooltipTrigger, TransitionPanel, useAccountWallet, useBsmntProfile, useHasMounted, useModalStore, useRouter, useSearchParamsSSR, useTokenBalancesByChain, } from "../../../global-account/react/index.js";
|
|
5
5
|
import { cn } from "../../../shared/utils/index.js";
|
|
6
6
|
import centerTruncate from "../../../shared/utils/centerTruncate.js";
|
|
7
7
|
import { formatTokenAmount } from "../../../shared/utils/number.js";
|
|
@@ -11,7 +11,7 @@ import invariant from "invariant";
|
|
|
11
11
|
import { ChevronRightCircle, Loader2 } from "lucide-react";
|
|
12
12
|
import { useCallback, useEffect, useMemo, useState } from "react";
|
|
13
13
|
import { toast } from "sonner";
|
|
14
|
-
import {
|
|
14
|
+
import { base, baseSepolia } from "viem/chains";
|
|
15
15
|
import { OrderDetails } from "./common/OrderDetails.js";
|
|
16
16
|
import { OrderHistory } from "./common/OrderHistory.js";
|
|
17
17
|
import { OrderStatus as OrderStatusDisplay } from "./common/OrderStatus.js";
|
|
@@ -152,7 +152,7 @@ export function AnySpendCustom({ isMainnet = true, loadOrder, mode = "modal", re
|
|
|
152
152
|
}
|
|
153
153
|
}
|
|
154
154
|
}, [srcChainId, tokenList, getTokenWithBalance, nativeTokens, fungibleTokens, dirtySelectSrcToken, dstToken.address]);
|
|
155
|
-
const { account: isAuthenticated } = useB3();
|
|
155
|
+
// const { account: isAuthenticated } = useB3();
|
|
156
156
|
const getRelayQuoteRequest = useMemo(() => {
|
|
157
157
|
return generateGetRelayQuoteRequest({
|
|
158
158
|
orderType: orderType,
|
|
@@ -323,22 +323,22 @@ export function AnySpendCustom({ isMainnet = true, loadOrder, mode = "modal", re
|
|
|
323
323
|
}
|
|
324
324
|
};
|
|
325
325
|
const handleConfirmOrder = async (onramp) => {
|
|
326
|
-
if (!isAuthenticated) {
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
}
|
|
326
|
+
// if (!isAuthenticated) {
|
|
327
|
+
// // Copied from https://github.com/b3-fun/b3-mono/blob/main/apps/anyspend-web/components/User/index.tsx#L85
|
|
328
|
+
// setB3ModalContentType({
|
|
329
|
+
// chain: {
|
|
330
|
+
// ...b3,
|
|
331
|
+
// rpc: "https://mainnet-rpc.b3.fun",
|
|
332
|
+
// blockExplorers: [{ name: "B3 Explorer", url: "https://explorer.b3.fun/" }],
|
|
333
|
+
// testnet: undefined,
|
|
334
|
+
// },
|
|
335
|
+
// partnerId: String(process.env.NEXT_PUBLIC_THIRDWEB_PARTNER_ID),
|
|
336
|
+
// type: "signInWithB3",
|
|
337
|
+
// showBackButton: false,
|
|
338
|
+
// });
|
|
339
|
+
// setB3ModalOpen(true);
|
|
340
|
+
// return;
|
|
341
|
+
// }
|
|
342
342
|
if (recipientAddress) {
|
|
343
343
|
try {
|
|
344
344
|
await handleCreateOrder(recipientAddress, onramp);
|
|
@@ -349,7 +349,7 @@ export function AnySpendCustom({ isMainnet = true, loadOrder, mode = "modal", re
|
|
|
349
349
|
}
|
|
350
350
|
}
|
|
351
351
|
};
|
|
352
|
-
const recipientSection = showRecipient &&
|
|
352
|
+
const recipientSection = showRecipient && recipientAddress ? (_jsxs(motion.div, { initial: false, animate: {
|
|
353
353
|
opacity: hasMounted ? 1 : 0,
|
|
354
354
|
y: hasMounted ? 0 : 20,
|
|
355
355
|
filter: hasMounted ? "blur(0px)" : "blur(10px)",
|
|
@@ -388,7 +388,7 @@ export function AnySpendCustom({ isMainnet = true, loadOrder, mode = "modal", re
|
|
|
388
388
|
opacity: hasMounted ? 1 : 0,
|
|
389
389
|
y: hasMounted ? 0 : 20,
|
|
390
390
|
filter: hasMounted ? "blur(0px)" : "blur(10px)",
|
|
391
|
-
}, transition: { duration: 0.3, delay: 0.3, ease: "easeInOut" }, className: "flex w-full flex-col gap-2", children: _jsx(ShinyButton, { accentColor: "hsl(var(--as-brand))", textColor: "text-white", disabled: isCreatingOrder || isLoadingAnyspendQuote || !anyspendQuote, onClick: () => handleConfirmOrder(), className: "relative w-full", children:
|
|
391
|
+
}, transition: { duration: 0.3, delay: 0.3, ease: "easeInOut" }, className: "flex w-full flex-col gap-2", children: _jsx(ShinyButton, { accentColor: "hsl(var(--as-brand))", textColor: "text-white", disabled: isCreatingOrder || isLoadingAnyspendQuote || !anyspendQuote, onClick: () => handleConfirmOrder(), className: "relative w-full", children: isCreatingOrder ? (_jsxs("div", { className: "flex items-center gap-2", children: [_jsx(Loader2, { className: "size-4 animate-spin" }), _jsx("span", { children: "Creating order..." })] })) : isLoadingAnyspendQuote ? (_jsxs("div", { className: "flex items-center gap-2", children: [_jsx(Loader2, { className: "size-4 animate-spin" }), _jsx("span", { children: "Loading quote..." })] })) : anyspendQuote ? (_jsxs(_Fragment, { children: [_jsx("span", { children: "Checkout" }), _jsx(ChevronRightCircle, { className: "absolute right-0 top-1/2 size-6 -translate-y-1/2 opacity-70" })] })) : ("No quote found") }) }) })] }) }), _jsx(TabsContent, { value: "fiat", children: _jsx("div", { className: "mt-6 flex w-full flex-col gap-6", children: _jsx(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: isNftMetadata(metadata)
|
|
392
392
|
? metadata.nftContract.type === NftType.ERC1155
|
|
393
393
|
? {
|
|
394
394
|
type: NftType.ERC1155,
|
package/package.json
CHANGED
package/src/anyspend/README.md
CHANGED
|
@@ -4,10 +4,11 @@ The fastest way to accept crypto payments and onboard users with zero friction
|
|
|
4
4
|
|
|
5
5
|
AnySpend gives you everything you need to add instant crypto onramps and checkout to your product. Let your users onramp from fiat instantly and pay using any token on any chain, all in one seamless experience.
|
|
6
6
|
|
|
7
|
-
🚀 Instant Onramp
|
|
8
|
-
💸 Pay Anyway
|
|
9
|
-
🧩 One SDK, Any Flow
|
|
10
|
-
👛 Unified Wallet View
|
|
7
|
+
- 🚀 **Instant Onramp:** Users can fund their wallet directly from fiat and start spending in your app right away
|
|
8
|
+
- 💸 **Pay Anyway:** Accept payments in any token across any chain with no bridges, swapping, or network switching required
|
|
9
|
+
- 🧩 **One SDK, Any Flow:** Easily add crypto payments and onramps to any business model or checkout flow
|
|
10
|
+
- 👛 **Unified Wallet View:** Users see and spend their balances from all chains in one place
|
|
11
|
+
|
|
11
12
|
AnySpend makes it simple to reach more users, increase conversions, and future proof your business with modern crypto payments.
|
|
12
13
|
|
|
13
14
|
See the Quickstart below or visit anyspend.com for a live demo
|
|
@@ -44,7 +44,6 @@ import {
|
|
|
44
44
|
TooltipTrigger,
|
|
45
45
|
TransitionPanel,
|
|
46
46
|
useAccountWallet,
|
|
47
|
-
useB3,
|
|
48
47
|
useBsmntProfile,
|
|
49
48
|
useHasMounted,
|
|
50
49
|
useModalStore,
|
|
@@ -61,7 +60,7 @@ import invariant from "invariant";
|
|
|
61
60
|
import { ChevronRightCircle, Loader2 } from "lucide-react";
|
|
62
61
|
import React, { useCallback, useEffect, useMemo, useState } from "react";
|
|
63
62
|
import { toast } from "sonner";
|
|
64
|
-
import {
|
|
63
|
+
import { base, baseSepolia } from "viem/chains";
|
|
65
64
|
import { OrderDetails } from "./common/OrderDetails";
|
|
66
65
|
import { OrderHistory } from "./common/OrderHistory";
|
|
67
66
|
import { OrderStatus as OrderStatusDisplay } from "./common/OrderStatus";
|
|
@@ -287,7 +286,7 @@ export function AnySpendCustom({
|
|
|
287
286
|
}
|
|
288
287
|
}, [srcChainId, tokenList, getTokenWithBalance, nativeTokens, fungibleTokens, dirtySelectSrcToken, dstToken.address]);
|
|
289
288
|
|
|
290
|
-
const { account: isAuthenticated } = useB3();
|
|
289
|
+
// const { account: isAuthenticated } = useB3();
|
|
291
290
|
|
|
292
291
|
const getRelayQuoteRequest = useMemo(() => {
|
|
293
292
|
return generateGetRelayQuoteRequest({
|
|
@@ -479,22 +478,22 @@ export function AnySpendCustom({
|
|
|
479
478
|
};
|
|
480
479
|
|
|
481
480
|
const handleConfirmOrder = async (onramp?: { paymentMethod: string; vendor: OnrampVendor }) => {
|
|
482
|
-
if (!isAuthenticated) {
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
}
|
|
481
|
+
// if (!isAuthenticated) {
|
|
482
|
+
// // Copied from https://github.com/b3-fun/b3-mono/blob/main/apps/anyspend-web/components/User/index.tsx#L85
|
|
483
|
+
// setB3ModalContentType({
|
|
484
|
+
// chain: {
|
|
485
|
+
// ...b3,
|
|
486
|
+
// rpc: "https://mainnet-rpc.b3.fun",
|
|
487
|
+
// blockExplorers: [{ name: "B3 Explorer", url: "https://explorer.b3.fun/" }],
|
|
488
|
+
// testnet: undefined,
|
|
489
|
+
// },
|
|
490
|
+
// partnerId: String(process.env.NEXT_PUBLIC_THIRDWEB_PARTNER_ID),
|
|
491
|
+
// type: "signInWithB3",
|
|
492
|
+
// showBackButton: false,
|
|
493
|
+
// });
|
|
494
|
+
// setB3ModalOpen(true);
|
|
495
|
+
// return;
|
|
496
|
+
// }
|
|
498
497
|
|
|
499
498
|
if (recipientAddress) {
|
|
500
499
|
try {
|
|
@@ -507,7 +506,7 @@ export function AnySpendCustom({
|
|
|
507
506
|
};
|
|
508
507
|
|
|
509
508
|
const recipientSection =
|
|
510
|
-
showRecipient &&
|
|
509
|
+
showRecipient && recipientAddress ? (
|
|
511
510
|
<motion.div
|
|
512
511
|
initial={false}
|
|
513
512
|
animate={{
|
|
@@ -792,9 +791,7 @@ export function AnySpendCustom({
|
|
|
792
791
|
onClick={() => handleConfirmOrder()}
|
|
793
792
|
className="relative w-full"
|
|
794
793
|
>
|
|
795
|
-
{
|
|
796
|
-
"Sign in with B3"
|
|
797
|
-
) : isCreatingOrder ? (
|
|
794
|
+
{isCreatingOrder ? (
|
|
798
795
|
<div className="flex items-center gap-2">
|
|
799
796
|
<Loader2 className="size-4 animate-spin" />
|
|
800
797
|
<span>Creating order...</span>
|