@b3dotfun/sdk 0.0.8-alpha.4 → 0.0.8-alpha.6

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.
@@ -1,2 +1,2 @@
1
1
  import { AnySpendBondKitProps } from "../../../global-account/react/stores/useModalStore";
2
- export declare function AnySpendBondKit({ mode, recipientAddress, contractAddress, minTokensOut, imageUrl, onSuccess, }: AnySpendBondKitProps): import("react/jsx-runtime").JSX.Element;
2
+ export declare function AnySpendBondKit({ mode, recipientAddress, contractAddress, minTokensOut, imageUrl, ethAmount: initialEthAmount, onSuccess, }: AnySpendBondKitProps): import("react/jsx-runtime").JSX.Element;
@@ -25,11 +25,11 @@ function formatNumberWithCommas(x) {
25
25
  parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, ",");
26
26
  return parts.join(".");
27
27
  }
28
- function AnySpendBondKit({ mode = "modal", recipientAddress, contractAddress, minTokensOut = "0", imageUrl, onSuccess, }) {
28
+ function AnySpendBondKit({ mode = "modal", recipientAddress, contractAddress, minTokensOut = "0", imageUrl, ethAmount: initialEthAmount, onSuccess, }) {
29
29
  const hasMounted = (0, react_1.useHasMounted)();
30
- const [showAmountPrompt, setShowAmountPrompt] = (0, react_2.useState)(true);
31
- const [ethAmount, setEthAmount] = (0, react_2.useState)("");
32
- const [isAmountValid, setIsAmountValid] = (0, react_2.useState)(false);
30
+ const [showAmountPrompt, setShowAmountPrompt] = (0, react_2.useState)(!initialEthAmount);
31
+ const [ethAmount, setEthAmount] = (0, react_2.useState)(initialEthAmount || "");
32
+ const [isAmountValid, setIsAmountValid] = (0, react_2.useState)(!!initialEthAmount);
33
33
  const [validationError, setValidationError] = (0, react_2.useState)("");
34
34
  const [tokenName, setTokenName] = (0, react_2.useState)("");
35
35
  const [tokenSymbol, setTokenSymbol] = (0, react_2.useState)("");
@@ -120,6 +120,12 @@ function AnySpendBondKit({ mode = "modal", recipientAddress, contractAddress, mi
120
120
  setIsLoadingQuote(false);
121
121
  }
122
122
  }, 500), [bondkitTokenClient]);
123
+ // Fetch initial quote if ethAmount is provided
124
+ (0, react_2.useEffect)(() => {
125
+ if (initialEthAmount && bondkitTokenClient) {
126
+ debouncedGetQuote(initialEthAmount);
127
+ }
128
+ }, [initialEthAmount, bondkitTokenClient, debouncedGetQuote]);
123
129
  const validateAndSetAmount = (value) => {
124
130
  // Allow empty input
125
131
  if (value === "") {
@@ -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 } = (0, react_2.useB3)();
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
- // Copied from https://github.com/b3-fun/b3-mono/blob/main/apps/anyspend-web/components/User/index.tsx#L85
334
- setB3ModalContentType({
335
- chain: {
336
- ...chains_1.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
- }
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 && isAuthenticated && recipientAddress ? ((0, jsx_runtime_1.jsxs)(framer_motion_1.motion.div, { initial: false, animate: {
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: !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_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)
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,
@@ -270,6 +270,8 @@ export interface AnySpendBondKitProps extends BaseModalProps {
270
270
  imageUrl?: string;
271
271
  /** Token name to display */
272
272
  tokenName?: string;
273
+ /** Optional pre-filled ETH amount */
274
+ ethAmount?: string;
273
275
  /** Callback function called when purchase is successful */
274
276
  onSuccess?: (txHash?: string) => void;
275
277
  }
@@ -1,2 +1,2 @@
1
1
  import { AnySpendBondKitProps } from "../../../global-account/react/stores/useModalStore";
2
- export declare function AnySpendBondKit({ mode, recipientAddress, contractAddress, minTokensOut, imageUrl, onSuccess, }: AnySpendBondKitProps): import("react/jsx-runtime").JSX.Element;
2
+ export declare function AnySpendBondKit({ mode, recipientAddress, contractAddress, minTokensOut, imageUrl, ethAmount: initialEthAmount, onSuccess, }: AnySpendBondKitProps): import("react/jsx-runtime").JSX.Element;
@@ -22,11 +22,11 @@ function formatNumberWithCommas(x) {
22
22
  parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, ",");
23
23
  return parts.join(".");
24
24
  }
25
- export function AnySpendBondKit({ mode = "modal", recipientAddress, contractAddress, minTokensOut = "0", imageUrl, onSuccess, }) {
25
+ export function AnySpendBondKit({ mode = "modal", recipientAddress, contractAddress, minTokensOut = "0", imageUrl, ethAmount: initialEthAmount, onSuccess, }) {
26
26
  const hasMounted = useHasMounted();
27
- const [showAmountPrompt, setShowAmountPrompt] = useState(true);
28
- const [ethAmount, setEthAmount] = useState("");
29
- const [isAmountValid, setIsAmountValid] = useState(false);
27
+ const [showAmountPrompt, setShowAmountPrompt] = useState(!initialEthAmount);
28
+ const [ethAmount, setEthAmount] = useState(initialEthAmount || "");
29
+ const [isAmountValid, setIsAmountValid] = useState(!!initialEthAmount);
30
30
  const [validationError, setValidationError] = useState("");
31
31
  const [tokenName, setTokenName] = useState("");
32
32
  const [tokenSymbol, setTokenSymbol] = useState("");
@@ -117,6 +117,12 @@ export function AnySpendBondKit({ mode = "modal", recipientAddress, contractAddr
117
117
  setIsLoadingQuote(false);
118
118
  }
119
119
  }, 500), [bondkitTokenClient]);
120
+ // Fetch initial quote if ethAmount is provided
121
+ useEffect(() => {
122
+ if (initialEthAmount && bondkitTokenClient) {
123
+ debouncedGetQuote(initialEthAmount);
124
+ }
125
+ }, [initialEthAmount, bondkitTokenClient, debouncedGetQuote]);
120
126
  const validateAndSetAmount = (value) => {
121
127
  // Allow empty input
122
128
  if (value === "") {
@@ -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, useB3, useBsmntProfile, useHasMounted, useModalStore, useRouter, useSearchParamsSSR, useTokenBalancesByChain, } from "../../../global-account/react/index.js";
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 { b3, base, baseSepolia } from "viem/chains";
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
- // 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
- }
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 && isAuthenticated && recipientAddress ? (_jsxs(motion.div, { initial: false, animate: {
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: !isAuthenticated ? ("Sign in with B3") : 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)
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,
@@ -270,6 +270,8 @@ export interface AnySpendBondKitProps extends BaseModalProps {
270
270
  imageUrl?: string;
271
271
  /** Token name to display */
272
272
  tokenName?: string;
273
+ /** Optional pre-filled ETH amount */
274
+ ethAmount?: string;
273
275
  /** Callback function called when purchase is successful */
274
276
  onSuccess?: (txHash?: string) => void;
275
277
  }
@@ -1,2 +1,2 @@
1
1
  import { AnySpendBondKitProps } from "@b3dotfun/sdk/global-account/react/stores/useModalStore";
2
- export declare function AnySpendBondKit({ mode, recipientAddress, contractAddress, minTokensOut, imageUrl, onSuccess, }: AnySpendBondKitProps): import("react/jsx-runtime").JSX.Element;
2
+ export declare function AnySpendBondKit({ mode, recipientAddress, contractAddress, minTokensOut, imageUrl, ethAmount: initialEthAmount, onSuccess, }: AnySpendBondKitProps): import("react/jsx-runtime").JSX.Element;
@@ -270,6 +270,8 @@ export interface AnySpendBondKitProps extends BaseModalProps {
270
270
  imageUrl?: string;
271
271
  /** Token name to display */
272
272
  tokenName?: string;
273
+ /** Optional pre-filled ETH amount */
274
+ ethAmount?: string;
273
275
  /** Callback function called when purchase is successful */
274
276
  onSuccess?: (txHash?: string) => void;
275
277
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@b3dotfun/sdk",
3
- "version": "0.0.8-alpha.4",
3
+ "version": "0.0.8-alpha.6",
4
4
  "source": "src/index.ts",
5
5
  "main": "./dist/cjs/index.js",
6
6
  "react-native": "./dist/cjs/index.native.js",
@@ -38,12 +38,13 @@ export function AnySpendBondKit({
38
38
  contractAddress,
39
39
  minTokensOut = "0",
40
40
  imageUrl,
41
+ ethAmount: initialEthAmount,
41
42
  onSuccess,
42
43
  }: AnySpendBondKitProps) {
43
44
  const hasMounted = useHasMounted();
44
- const [showAmountPrompt, setShowAmountPrompt] = useState(true);
45
- const [ethAmount, setEthAmount] = useState("");
46
- const [isAmountValid, setIsAmountValid] = useState(false);
45
+ const [showAmountPrompt, setShowAmountPrompt] = useState(!initialEthAmount);
46
+ const [ethAmount, setEthAmount] = useState(initialEthAmount || "");
47
+ const [isAmountValid, setIsAmountValid] = useState(!!initialEthAmount);
47
48
  const [validationError, setValidationError] = useState("");
48
49
  const [tokenName, setTokenName] = useState<string>("");
49
50
  const [tokenSymbol, setTokenSymbol] = useState<string>("");
@@ -144,6 +145,12 @@ export function AnySpendBondKit({
144
145
  }, 500),
145
146
  [bondkitTokenClient],
146
147
  );
148
+ // Fetch initial quote if ethAmount is provided
149
+ useEffect(() => {
150
+ if (initialEthAmount && bondkitTokenClient) {
151
+ debouncedGetQuote(initialEthAmount);
152
+ }
153
+ }, [initialEthAmount, bondkitTokenClient, debouncedGetQuote]);
147
154
 
148
155
  const validateAndSetAmount = (value: string) => {
149
156
  // Allow empty input
@@ -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 { b3, base, baseSepolia } from "viem/chains";
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
- // Copied from https://github.com/b3-fun/b3-mono/blob/main/apps/anyspend-web/components/User/index.tsx#L85
484
- setB3ModalContentType({
485
- chain: {
486
- ...b3,
487
- rpc: "https://mainnet-rpc.b3.fun",
488
- blockExplorers: [{ name: "B3 Explorer", url: "https://explorer.b3.fun/" }],
489
- testnet: undefined,
490
- },
491
- partnerId: String(process.env.NEXT_PUBLIC_THIRDWEB_PARTNER_ID),
492
- type: "signInWithB3",
493
- showBackButton: false,
494
- });
495
- setB3ModalOpen(true);
496
- return;
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 && isAuthenticated && recipientAddress ? (
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
- {!isAuthenticated ? (
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>
@@ -286,6 +286,8 @@ export interface AnySpendBondKitProps extends BaseModalProps {
286
286
  imageUrl?: string;
287
287
  /** Token name to display */
288
288
  tokenName?: string;
289
+ /** Optional pre-filled ETH amount */
290
+ ethAmount?: string;
289
291
  /** Callback function called when purchase is successful */
290
292
  onSuccess?: (txHash?: string) => void;
291
293
  }