@b3dotfun/sdk 0.0.28 → 0.0.29-alpha.1
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/abis/escrow.d.ts +987 -0
- package/dist/cjs/anyspend/abis/escrow.js +1275 -0
- package/dist/cjs/anyspend/react/components/AnySpend.js +10 -168
- package/dist/cjs/anyspend/react/components/AnySpendBondKit.d.ts +1 -1
- package/dist/cjs/anyspend/react/components/AnySpendBondKit.js +23 -24
- package/dist/cjs/anyspend/react/components/AnySpendCustom.js +2 -2
- package/dist/cjs/anyspend/react/components/AnyspendDepositHype.d.ts +10 -0
- package/dist/cjs/anyspend/react/components/AnyspendDepositHype.js +263 -0
- package/dist/cjs/anyspend/react/components/common/CryptoReceiveSection.d.ts +17 -0
- package/dist/cjs/anyspend/react/components/common/CryptoReceiveSection.js +53 -0
- package/dist/cjs/anyspend/react/components/common/ErrorSection.d.ts +6 -0
- package/dist/cjs/anyspend/react/components/common/ErrorSection.js +12 -0
- package/dist/cjs/anyspend/react/components/common/PanelOnramp.d.ts +2 -1
- package/dist/cjs/anyspend/react/components/common/PanelOnramp.js +2 -2
- package/dist/cjs/anyspend/react/components/common/PaySection.d.ts +20 -0
- package/dist/cjs/anyspend/react/components/common/PaySection.js +58 -0
- package/dist/cjs/anyspend/react/components/common/TabSection.d.ts +10 -0
- package/dist/cjs/anyspend/react/components/common/TabSection.js +18 -0
- package/dist/cjs/anyspend/react/components/index.d.ts +2 -0
- package/dist/cjs/anyspend/react/components/index.js +5 -1
- package/dist/cjs/anyspend/react/hooks/useAnyspendFlow.d.ts +165 -0
- package/dist/cjs/anyspend/react/hooks/useAnyspendFlow.js +184 -0
- package/dist/cjs/anyspend/react/hooks/useSigMint.d.ts +2 -2
- package/dist/cjs/bondkit/abis/BondkitTokenABI.d.ts +2 -5
- package/dist/cjs/bondkit/abis/BondkitTokenABI.js +2 -3
- package/dist/cjs/global-account/react/components/B3DynamicModal.js +3 -0
- package/dist/cjs/global-account/react/components/custom/Button.d.ts +1 -1
- package/dist/cjs/global-account/react/components/ui/button.d.ts +1 -1
- package/dist/cjs/global-account/react/components/ui/command.d.ts +2 -2
- package/dist/cjs/global-account/react/hooks/useSiwe.native.d.ts +4 -0
- package/dist/cjs/global-account/react/hooks/useSiwe.native.js +40 -0
- package/dist/cjs/global-account/react/stores/useModalStore.d.ts +19 -3
- package/dist/cjs/shared/constants/chains/b3Chain.d.ts +1 -1
- package/dist/cjs/shared/constants/chains/supported.d.ts +3 -3
- package/dist/esm/anyspend/abis/escrow.d.ts +987 -0
- package/dist/esm/anyspend/abis/escrow.js +1272 -0
- package/dist/esm/anyspend/react/components/AnySpend.js +12 -170
- package/dist/esm/anyspend/react/components/AnySpendBondKit.d.ts +1 -1
- package/dist/esm/anyspend/react/components/AnySpendBondKit.js +23 -24
- package/dist/esm/anyspend/react/components/AnySpendCustom.js +3 -3
- package/dist/esm/anyspend/react/components/AnyspendDepositHype.d.ts +10 -0
- package/dist/esm/anyspend/react/components/AnyspendDepositHype.js +257 -0
- package/dist/esm/anyspend/react/components/common/CryptoReceiveSection.d.ts +17 -0
- package/dist/esm/anyspend/react/components/common/CryptoReceiveSection.js +50 -0
- package/dist/esm/anyspend/react/components/common/ErrorSection.d.ts +6 -0
- package/dist/esm/anyspend/react/components/common/ErrorSection.js +9 -0
- package/dist/esm/anyspend/react/components/common/PanelOnramp.d.ts +2 -1
- package/dist/esm/anyspend/react/components/common/PanelOnramp.js +2 -2
- package/dist/esm/anyspend/react/components/common/PaySection.d.ts +20 -0
- package/dist/esm/anyspend/react/components/common/PaySection.js +55 -0
- package/dist/esm/anyspend/react/components/common/TabSection.d.ts +10 -0
- package/dist/esm/anyspend/react/components/common/TabSection.js +15 -0
- package/dist/esm/anyspend/react/components/index.d.ts +2 -0
- package/dist/esm/anyspend/react/components/index.js +2 -0
- package/dist/esm/anyspend/react/hooks/useAnyspendFlow.d.ts +165 -0
- package/dist/esm/anyspend/react/hooks/useAnyspendFlow.js +180 -0
- package/dist/esm/anyspend/react/hooks/useSigMint.d.ts +2 -2
- package/dist/esm/bondkit/abis/BondkitTokenABI.d.ts +2 -5
- package/dist/esm/bondkit/abis/BondkitTokenABI.js +2 -3
- package/dist/esm/global-account/react/components/B3DynamicModal.js +3 -0
- package/dist/esm/global-account/react/components/custom/Button.d.ts +1 -1
- package/dist/esm/global-account/react/components/ui/button.d.ts +1 -1
- package/dist/esm/global-account/react/components/ui/command.d.ts +2 -2
- package/dist/esm/global-account/react/hooks/useSiwe.native.d.ts +4 -0
- package/dist/esm/global-account/react/hooks/useSiwe.native.js +34 -0
- package/dist/esm/global-account/react/stores/useModalStore.d.ts +19 -3
- package/dist/esm/shared/constants/chains/b3Chain.d.ts +1 -1
- package/dist/esm/shared/constants/chains/supported.d.ts +3 -3
- package/dist/styles/index.css +1 -1
- package/dist/types/anyspend/abis/escrow.d.ts +987 -0
- package/dist/types/anyspend/react/components/AnySpendBondKit.d.ts +1 -1
- package/dist/types/anyspend/react/components/AnyspendDepositHype.d.ts +10 -0
- package/dist/types/anyspend/react/components/common/CryptoReceiveSection.d.ts +17 -0
- package/dist/types/anyspend/react/components/common/ErrorSection.d.ts +6 -0
- package/dist/types/anyspend/react/components/common/PanelOnramp.d.ts +2 -1
- package/dist/types/anyspend/react/components/common/PaySection.d.ts +20 -0
- package/dist/types/anyspend/react/components/common/TabSection.d.ts +10 -0
- package/dist/types/anyspend/react/components/index.d.ts +2 -0
- package/dist/types/anyspend/react/hooks/useAnyspendFlow.d.ts +165 -0
- package/dist/types/anyspend/react/hooks/useSigMint.d.ts +2 -2
- package/dist/types/bondkit/abis/BondkitTokenABI.d.ts +2 -5
- package/dist/types/global-account/react/components/custom/Button.d.ts +1 -1
- package/dist/types/global-account/react/components/ui/button.d.ts +1 -1
- package/dist/types/global-account/react/components/ui/command.d.ts +2 -2
- package/dist/types/global-account/react/hooks/useSiwe.native.d.ts +4 -0
- package/dist/types/global-account/react/stores/useModalStore.d.ts +19 -3
- package/dist/types/shared/constants/chains/b3Chain.d.ts +1 -1
- package/dist/types/shared/constants/chains/supported.d.ts +3 -3
- package/package.json +13 -1
- package/src/anyspend/abis/escrow.ts +1272 -0
- package/src/anyspend/react/components/AnySpend.tsx +48 -389
- package/src/anyspend/react/components/AnySpendBondKit.tsx +28 -28
- package/src/anyspend/react/components/AnySpendCustom.tsx +2 -10
- package/src/anyspend/react/components/AnyspendDepositHype.tsx +525 -0
- package/src/anyspend/react/components/common/CryptoReceiveSection.tsx +152 -0
- package/src/anyspend/react/components/common/ErrorSection.tsx +21 -0
- package/src/anyspend/react/components/common/PanelOnramp.tsx +4 -2
- package/src/anyspend/react/components/common/PaySection.tsx +222 -0
- package/src/anyspend/react/components/common/TabSection.tsx +58 -0
- package/src/anyspend/react/components/index.ts +2 -0
- package/src/anyspend/react/hooks/useAnyspendFlow.ts +226 -0
- package/src/bondkit/abis/BondkitTokenABI.ts +2 -3
- package/src/global-account/react/components/B3DynamicModal.tsx +3 -0
- package/src/global-account/react/hooks/useSiwe.native.tsx +40 -0
- package/src/global-account/react/stores/useModalStore.ts +21 -3
- package/dist/cjs/anyspend/abis/bondKit.d.ts +0 -35
- package/dist/cjs/anyspend/abis/bondKit.js +0 -29
- package/dist/esm/anyspend/abis/bondKit.d.ts +0 -35
- package/dist/esm/anyspend/abis/bondKit.js +0 -26
- package/dist/types/anyspend/abis/bondKit.d.ts +0 -35
- package/src/anyspend/abis/bondKit.ts +0 -26
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { BondkitToken } from "../../../bondkit";
|
|
2
1
|
import {
|
|
3
2
|
Button,
|
|
4
3
|
GlareCardRounded,
|
|
@@ -12,7 +11,7 @@ import { baseMainnet } from "@b3dotfun/sdk/shared/constants/chains/supported";
|
|
|
12
11
|
import { motion } from "motion/react";
|
|
13
12
|
import { useEffect, useMemo, useState } from "react";
|
|
14
13
|
import { createPublicClient, encodeFunctionData, formatEther, http, parseEther } from "viem";
|
|
15
|
-
import {
|
|
14
|
+
import { BondkitToken, BondkitTokenABI } from "../../../bondkit";
|
|
16
15
|
import { AnySpendCustom } from "./AnySpendCustom";
|
|
17
16
|
|
|
18
17
|
// Debounce utility function
|
|
@@ -37,13 +36,13 @@ export function AnySpendBondKit({
|
|
|
37
36
|
contractAddress,
|
|
38
37
|
minTokensOut = "0",
|
|
39
38
|
imageUrl,
|
|
40
|
-
|
|
39
|
+
b3Amount: initialB3Amount,
|
|
41
40
|
onSuccess,
|
|
42
41
|
}: AnySpendBondKitProps) {
|
|
43
42
|
const hasMounted = useHasMounted();
|
|
44
|
-
const [showAmountPrompt, setShowAmountPrompt] = useState(!
|
|
45
|
-
const [
|
|
46
|
-
const [isAmountValid, setIsAmountValid] = useState(!!
|
|
43
|
+
const [showAmountPrompt, setShowAmountPrompt] = useState(!initialB3Amount);
|
|
44
|
+
const [b3Amount, setB3Amount] = useState(initialB3Amount || "");
|
|
45
|
+
const [isAmountValid, setIsAmountValid] = useState(!!initialB3Amount);
|
|
47
46
|
const [validationError, setValidationError] = useState("");
|
|
48
47
|
const [tokenName, setTokenName] = useState<string>("");
|
|
49
48
|
const [tokenSymbol, setTokenSymbol] = useState<string>("");
|
|
@@ -76,12 +75,12 @@ export function AnySpendBondKit({
|
|
|
76
75
|
const [name, symbol] = await Promise.all([
|
|
77
76
|
basePublicClient.readContract({
|
|
78
77
|
address: contractAddress as `0x${string}`,
|
|
79
|
-
abi:
|
|
78
|
+
abi: BondkitTokenABI,
|
|
80
79
|
functionName: "name",
|
|
81
80
|
}),
|
|
82
81
|
basePublicClient.readContract({
|
|
83
82
|
address: contractAddress as `0x${string}`,
|
|
84
|
-
abi:
|
|
83
|
+
abi: BondkitTokenABI,
|
|
85
84
|
functionName: "symbol",
|
|
86
85
|
}),
|
|
87
86
|
]);
|
|
@@ -99,12 +98,12 @@ export function AnySpendBondKit({
|
|
|
99
98
|
}
|
|
100
99
|
}, [contractAddress, basePublicClient]);
|
|
101
100
|
|
|
102
|
-
// Get
|
|
101
|
+
// Get b3 token data
|
|
103
102
|
const {
|
|
104
103
|
data: tokenData,
|
|
105
104
|
isError: isTokenError,
|
|
106
105
|
isLoading,
|
|
107
|
-
} = useTokenData(baseMainnet.id, "
|
|
106
|
+
} = useTokenData(baseMainnet.id, "0xB3B32F9f8827D4634fE7d973Fa1034Ec9fdDB3B3");
|
|
108
107
|
|
|
109
108
|
// Convert token data to AnySpend Token type
|
|
110
109
|
const dstToken = useMemo(() => {
|
|
@@ -144,17 +143,18 @@ export function AnySpendBondKit({
|
|
|
144
143
|
}, 500),
|
|
145
144
|
[bondkitTokenClient],
|
|
146
145
|
);
|
|
147
|
-
|
|
146
|
+
|
|
147
|
+
// Fetch initial quote if b3Amount is provided
|
|
148
148
|
useEffect(() => {
|
|
149
|
-
if (
|
|
150
|
-
debouncedGetQuote(
|
|
149
|
+
if (initialB3Amount && bondkitTokenClient) {
|
|
150
|
+
debouncedGetQuote(initialB3Amount);
|
|
151
151
|
}
|
|
152
|
-
}, [
|
|
152
|
+
}, [initialB3Amount, bondkitTokenClient, debouncedGetQuote]);
|
|
153
153
|
|
|
154
154
|
const validateAndSetAmount = (value: string) => {
|
|
155
155
|
// Allow empty input
|
|
156
156
|
if (value === "") {
|
|
157
|
-
|
|
157
|
+
setB3Amount("");
|
|
158
158
|
setIsAmountValid(false);
|
|
159
159
|
setValidationError("");
|
|
160
160
|
setQuote(null);
|
|
@@ -173,7 +173,7 @@ export function AnySpendBondKit({
|
|
|
173
173
|
return;
|
|
174
174
|
}
|
|
175
175
|
|
|
176
|
-
// Prevent more than 18 decimal places (
|
|
176
|
+
// Prevent more than 18 decimal places (B3 precision)
|
|
177
177
|
const parts = value.split(".");
|
|
178
178
|
if (parts[1] && parts[1].length > 18) {
|
|
179
179
|
return;
|
|
@@ -181,7 +181,7 @@ export function AnySpendBondKit({
|
|
|
181
181
|
|
|
182
182
|
// Clean the input - remove leading zeros if not decimal
|
|
183
183
|
const cleanedValue = value.startsWith("0") && !value.startsWith("0.") ? value.replace(/^0+/, "0") : value;
|
|
184
|
-
|
|
184
|
+
setB3Amount(cleanedValue);
|
|
185
185
|
|
|
186
186
|
try {
|
|
187
187
|
const parsedAmount = parseEther(cleanedValue);
|
|
@@ -208,7 +208,7 @@ export function AnySpendBondKit({
|
|
|
208
208
|
Buy {tokenName} ({tokenSymbol})
|
|
209
209
|
</h2>
|
|
210
210
|
<div className="flex w-full flex-col items-center space-y-2">
|
|
211
|
-
<span className="text-[28px] font-bold">{
|
|
211
|
+
<span className="text-[28px] font-bold">{b3Amount} B3</span>
|
|
212
212
|
{quote && (
|
|
213
213
|
<span className="text-lg">
|
|
214
214
|
≈ {formatNumberWithCommas(parseFloat(quote).toFixed(4))} {tokenSymbol}
|
|
@@ -294,7 +294,7 @@ export function AnySpendBondKit({
|
|
|
294
294
|
>
|
|
295
295
|
<div className="space-y-4">
|
|
296
296
|
<div className="flex items-center justify-between">
|
|
297
|
-
<p className="text-as-primary/70 text-sm font-medium">
|
|
297
|
+
<p className="text-as-primary/70 text-sm font-medium">B3 Amount</p>
|
|
298
298
|
</div>
|
|
299
299
|
|
|
300
300
|
<div className="relative">
|
|
@@ -302,19 +302,19 @@ export function AnySpendBondKit({
|
|
|
302
302
|
type="text"
|
|
303
303
|
inputMode="decimal"
|
|
304
304
|
placeholder="0.1"
|
|
305
|
-
value={
|
|
305
|
+
value={b3Amount}
|
|
306
306
|
onChange={e => validateAndSetAmount(e.target.value)}
|
|
307
|
-
className={`h-14 px-4 text-lg ${!isAmountValid &&
|
|
307
|
+
className={`h-14 px-4 text-lg ${!isAmountValid && b3Amount ? "border-as-red" : "border-b3-react-border"}`}
|
|
308
308
|
/>
|
|
309
309
|
</div>
|
|
310
310
|
|
|
311
|
-
{!isAmountValid &&
|
|
311
|
+
{!isAmountValid && b3Amount && <p className="text-as-red text-sm">{validationError}</p>}
|
|
312
312
|
|
|
313
313
|
<div className="bg-as-on-surface-2/30 rounded-lg border border-white/10 p-4 backdrop-blur-sm">
|
|
314
314
|
<div className="flex items-center justify-between">
|
|
315
315
|
<span className="text-as-primary/70 text-sm font-medium">Total Cost:</span>
|
|
316
316
|
<div className="flex items-center gap-2">
|
|
317
|
-
<span className="text-as-primary text-lg font-bold">{
|
|
317
|
+
<span className="text-as-primary text-lg font-bold">{b3Amount || "0"} B3</span>
|
|
318
318
|
</div>
|
|
319
319
|
</div>
|
|
320
320
|
{isLoadingQuote ? (
|
|
@@ -333,11 +333,11 @@ export function AnySpendBondKit({
|
|
|
333
333
|
|
|
334
334
|
<Button
|
|
335
335
|
onClick={() => {
|
|
336
|
-
if (isAmountValid &&
|
|
336
|
+
if (isAmountValid && b3Amount) {
|
|
337
337
|
setShowAmountPrompt(false);
|
|
338
338
|
}
|
|
339
339
|
}}
|
|
340
|
-
disabled={!isAmountValid || !
|
|
340
|
+
disabled={!isAmountValid || !b3Amount || isLoadingQuote}
|
|
341
341
|
className="bg-as-brand hover:bg-as-brand/90 text-as-primary mt-4 h-14 w-full rounded-xl text-lg font-medium"
|
|
342
342
|
>
|
|
343
343
|
Continue
|
|
@@ -350,9 +350,9 @@ export function AnySpendBondKit({
|
|
|
350
350
|
}
|
|
351
351
|
|
|
352
352
|
const encodedData = encodeFunctionData({
|
|
353
|
-
abi:
|
|
353
|
+
abi: BondkitTokenABI,
|
|
354
354
|
functionName: "buyFor",
|
|
355
|
-
args: [recipientAddress as `0x${string}`, BigInt(minTokensOut)],
|
|
355
|
+
args: [recipientAddress as `0x${string}`, parseEther(b3Amount), BigInt(minTokensOut)],
|
|
356
356
|
});
|
|
357
357
|
|
|
358
358
|
return (
|
|
@@ -362,7 +362,7 @@ export function AnySpendBondKit({
|
|
|
362
362
|
orderType={"custom"}
|
|
363
363
|
dstChainId={baseMainnet.id}
|
|
364
364
|
dstToken={dstToken}
|
|
365
|
-
dstAmount={parseEther(
|
|
365
|
+
dstAmount={parseEther(b3Amount).toString()}
|
|
366
366
|
contractAddress={contractAddress}
|
|
367
367
|
encodedData={encodedData}
|
|
368
368
|
metadata={{
|
|
@@ -605,16 +605,8 @@ function AnySpendCustomInner({
|
|
|
605
605
|
onClick={() => setActivePanel(PanelView.RECIPIENT_SELECTION)}
|
|
606
606
|
>
|
|
607
607
|
<>
|
|
608
|
-
{recipientProfile && (
|
|
609
|
-
<img
|
|
610
|
-
src={recipientProfile.data?.avatar || ""}
|
|
611
|
-
alt={recipientProfile.data?.name || ""}
|
|
612
|
-
className="bg-b3-react-foreground size-6 rounded-full object-cover opacity-100"
|
|
613
|
-
/>
|
|
614
|
-
)}
|
|
615
608
|
<div className="text-as-tertiarry flex items-center gap-1 text-sm">
|
|
616
|
-
{recipientName
|
|
617
|
-
<span>{shortenAddress(recipientAddress)}</span>
|
|
609
|
+
<span>{recipientName ? formatUsername(recipientName) : shortenAddress(recipientAddress)}</span>
|
|
618
610
|
</div>
|
|
619
611
|
</>
|
|
620
612
|
</button>
|
|
@@ -651,7 +643,7 @@ function AnySpendCustomInner({
|
|
|
651
643
|
const orderDetailsView = (
|
|
652
644
|
<div
|
|
653
645
|
className={cn(
|
|
654
|
-
"mx-auto flex w-full flex-col items-center gap-4
|
|
646
|
+
"mx-auto flex w-full flex-col items-center gap-4",
|
|
655
647
|
mode === "modal" && "bg-b3-react-background rounded-xl",
|
|
656
648
|
)}
|
|
657
649
|
>
|