@b3dotfun/sdk 0.0.8-alpha.3 → 0.0.8-alpha.5

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 === "") {
@@ -29,7 +29,7 @@ function B3DynamicModal() {
29
29
  "anySpendOrderHistory",
30
30
  "signInWithB3",
31
31
  "anySpendSignatureMint",
32
- "AnySpendBondKit",
32
+ "anySpendBondKit",
33
33
  ].find(type => contentType?.type === type)) {
34
34
  contentClass += " max-h-[90dvh] overflow-y-auto no-scrollbar w-full";
35
35
  }
@@ -40,7 +40,7 @@ function B3DynamicModal() {
40
40
  "anySpendStakeB3",
41
41
  "anySpendBuySpin",
42
42
  "anySpendSignatureMint",
43
- "AnySpendBondKit",
43
+ "anySpendBondKit",
44
44
  ].find(type => contentType?.type === type)) {
45
45
  // Due to the dynamic of (Pay with crypto),(Pay with fiat), we want the height fixed to 90dvh but still scrollable.
46
46
  // NOTE: Just leave it here in case we want the fixed height
@@ -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 === "") {
@@ -26,7 +26,7 @@ export function B3DynamicModal() {
26
26
  "anySpendOrderHistory",
27
27
  "signInWithB3",
28
28
  "anySpendSignatureMint",
29
- "AnySpendBondKit",
29
+ "anySpendBondKit",
30
30
  ].find(type => contentType?.type === type)) {
31
31
  contentClass += " max-h-[90dvh] overflow-y-auto no-scrollbar w-full";
32
32
  }
@@ -37,7 +37,7 @@ export function B3DynamicModal() {
37
37
  "anySpendStakeB3",
38
38
  "anySpendBuySpin",
39
39
  "anySpendSignatureMint",
40
- "AnySpendBondKit",
40
+ "anySpendBondKit",
41
41
  ].find(type => contentType?.type === type)) {
42
42
  // Due to the dynamic of (Pay with crypto),(Pay with fiat), we want the height fixed to 90dvh but still scrollable.
43
43
  // NOTE: Just leave it here in case we want the fixed height
@@ -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.3",
3
+ "version": "0.0.8-alpha.5",
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
@@ -38,7 +38,7 @@ export function B3DynamicModal() {
38
38
  "anySpendOrderHistory",
39
39
  "signInWithB3",
40
40
  "anySpendSignatureMint",
41
- "AnySpendBondKit",
41
+ "anySpendBondKit",
42
42
  ].find(type => contentType?.type === type)
43
43
  ) {
44
44
  contentClass += " max-h-[90dvh] overflow-y-auto no-scrollbar w-full";
@@ -52,7 +52,7 @@ export function B3DynamicModal() {
52
52
  "anySpendStakeB3",
53
53
  "anySpendBuySpin",
54
54
  "anySpendSignatureMint",
55
- "AnySpendBondKit",
55
+ "anySpendBondKit",
56
56
  ].find(type => contentType?.type === type)
57
57
  ) {
58
58
  // Due to the dynamic of (Pay with crypto),(Pay with fiat), we want the height fixed to 90dvh but still scrollable.
@@ -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
  }