@b3dotfun/sdk 0.0.40-alpha.2 → 0.0.40-alpha.21
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/AnySpend.d.ts +10 -1
- package/dist/cjs/anyspend/react/components/AnySpend.js +8 -4
- package/dist/cjs/anyspend/react/components/AnySpendBondKit.js +0 -1
- package/dist/cjs/anyspend/react/components/AnySpendBuySpin.js +0 -1
- package/dist/cjs/anyspend/react/components/AnySpendCustom.d.ts +1 -0
- package/dist/cjs/anyspend/react/components/AnySpendCustom.js +26 -10
- package/dist/cjs/anyspend/react/components/AnySpendNFT.d.ts +2 -1
- package/dist/cjs/anyspend/react/components/AnySpendNFT.js +2 -2
- package/dist/cjs/anyspend/react/components/AnySpendStakeB3.js +0 -1
- package/dist/cjs/anyspend/react/components/AnyspendDepositHype.d.ts +8 -0
- package/dist/cjs/anyspend/react/components/AnyspendDepositHype.js +6 -3
- package/dist/cjs/anyspend/react/components/AnyspendSignatureMint.js +0 -1
- package/dist/cjs/anyspend/react/components/common/ConnectWalletPayment.js +5 -3
- package/dist/cjs/anyspend/react/components/common/CryptoPaySection.d.ts +4 -1
- package/dist/cjs/anyspend/react/components/common/CryptoPaySection.js +9 -9
- package/dist/cjs/anyspend/react/components/common/CryptoPaymentMethod.js +80 -10
- package/dist/cjs/anyspend/react/components/common/CryptoReceiveSection.d.ts +2 -1
- package/dist/cjs/anyspend/react/components/common/CryptoReceiveSection.js +40 -37
- package/dist/cjs/anyspend/react/components/common/OrderDetails.js +8 -8
- package/dist/cjs/anyspend/react/components/common/OrderTokenAmount.d.ts +4 -1
- package/dist/cjs/anyspend/react/components/common/OrderTokenAmount.js +23 -9
- package/dist/cjs/anyspend/react/components/common/PanelOnramp.d.ts +4 -1
- package/dist/cjs/anyspend/react/components/common/PanelOnramp.js +10 -6
- package/dist/cjs/anyspend/react/components/common/PointsBadge.d.ts +7 -0
- package/dist/cjs/anyspend/react/components/common/PointsBadge.js +7 -0
- package/dist/cjs/anyspend/react/components/common/PointsDetailPanel.d.ts +6 -0
- package/dist/cjs/anyspend/react/components/common/PointsDetailPanel.js +14 -0
- package/dist/cjs/anyspend/react/contexts/FeatureFlagsContext.d.ts +11 -0
- package/dist/cjs/anyspend/react/contexts/FeatureFlagsContext.js +21 -0
- package/dist/cjs/anyspend/react/hooks/useAnyspendFlow.d.ts +4 -1
- package/dist/cjs/anyspend/react/hooks/useAnyspendFlow.js +1 -0
- package/dist/cjs/anyspend/react/providers/AnyspendProvider.d.ts +5 -2
- package/dist/cjs/anyspend/react/providers/AnyspendProvider.js +5 -3
- package/dist/cjs/anyspend/react/providers/index.d.ts +1 -0
- package/dist/cjs/anyspend/react/providers/index.js +3 -0
- package/dist/cjs/anyspend/types/api.d.ts +11 -1
- package/dist/cjs/anyspend/utils/orderPayload.js +1 -0
- package/dist/cjs/bondkit/bondkitToken.d.ts +37 -2
- package/dist/cjs/bondkit/bondkitToken.js +268 -2
- package/dist/cjs/bondkit/bondkitTokenFactory.d.ts +1 -1
- package/dist/cjs/bondkit/bondkitTokenFactory.js +2 -2
- package/dist/cjs/bondkit/config.d.ts +1 -1
- package/dist/cjs/bondkit/config.js +5 -2
- package/dist/cjs/bondkit/constants.d.ts +4 -0
- package/dist/cjs/bondkit/constants.js +6 -1
- package/dist/cjs/bondkit/index.d.ts +1 -0
- package/dist/cjs/bondkit/index.js +4 -1
- package/dist/cjs/bondkit/swapService.d.ts +43 -0
- package/dist/cjs/bondkit/swapService.js +373 -0
- package/dist/cjs/bondkit/types.d.ts +10 -4
- package/dist/cjs/bondkit/types.js +4 -5
- package/dist/cjs/global-account/react/components/B3Provider/B3Provider.d.ts +4 -3
- package/dist/cjs/global-account/react/components/B3Provider/B3Provider.js +35 -9
- package/dist/cjs/global-account/react/components/LinkAccount/LinkAccount.js +63 -3
- package/dist/cjs/global-account/react/components/ManageAccount/ManageAccount.js +35 -2
- package/dist/cjs/global-account/react/components/SignInWithB3/steps/LoginStepCustom.js +4 -3
- package/dist/cjs/global-account/react/hooks/useAuthentication.js +1 -2
- package/dist/cjs/global-account/react/hooks/useSimBalance.js +2 -2
- package/dist/cjs/global-account/react/hooks/useUnifiedChainSwitchAndExecute.js +22 -20
- package/dist/esm/anyspend/react/components/AnySpend.d.ts +10 -1
- package/dist/esm/anyspend/react/components/AnySpend.js +8 -4
- package/dist/esm/anyspend/react/components/AnySpendBondKit.js +0 -1
- package/dist/esm/anyspend/react/components/AnySpendBuySpin.js +0 -1
- package/dist/esm/anyspend/react/components/AnySpendCustom.d.ts +1 -0
- package/dist/esm/anyspend/react/components/AnySpendCustom.js +26 -10
- package/dist/esm/anyspend/react/components/AnySpendNFT.d.ts +2 -1
- package/dist/esm/anyspend/react/components/AnySpendNFT.js +2 -2
- package/dist/esm/anyspend/react/components/AnySpendStakeB3.js +0 -1
- package/dist/esm/anyspend/react/components/AnyspendDepositHype.d.ts +8 -0
- package/dist/esm/anyspend/react/components/AnyspendDepositHype.js +6 -3
- package/dist/esm/anyspend/react/components/AnyspendSignatureMint.js +0 -1
- package/dist/esm/anyspend/react/components/common/ConnectWalletPayment.js +6 -4
- package/dist/esm/anyspend/react/components/common/CryptoPaySection.d.ts +4 -1
- package/dist/esm/anyspend/react/components/common/CryptoPaySection.js +9 -9
- package/dist/esm/anyspend/react/components/common/CryptoPaymentMethod.js +80 -10
- package/dist/esm/anyspend/react/components/common/CryptoReceiveSection.d.ts +2 -1
- package/dist/esm/anyspend/react/components/common/CryptoReceiveSection.js +40 -37
- package/dist/esm/anyspend/react/components/common/OrderDetails.js +8 -8
- package/dist/esm/anyspend/react/components/common/OrderTokenAmount.d.ts +4 -1
- package/dist/esm/anyspend/react/components/common/OrderTokenAmount.js +23 -9
- package/dist/esm/anyspend/react/components/common/PanelOnramp.d.ts +4 -1
- package/dist/esm/anyspend/react/components/common/PanelOnramp.js +10 -6
- package/dist/esm/anyspend/react/components/common/PointsBadge.d.ts +7 -0
- package/dist/esm/anyspend/react/components/common/PointsBadge.js +4 -0
- package/dist/esm/anyspend/react/components/common/PointsDetailPanel.d.ts +6 -0
- package/dist/esm/anyspend/react/components/common/PointsDetailPanel.js +8 -0
- package/dist/esm/anyspend/react/contexts/FeatureFlagsContext.d.ts +11 -0
- package/dist/esm/anyspend/react/contexts/FeatureFlagsContext.js +17 -0
- package/dist/esm/anyspend/react/hooks/useAnyspendFlow.d.ts +4 -1
- package/dist/esm/anyspend/react/hooks/useAnyspendFlow.js +1 -0
- package/dist/esm/anyspend/react/providers/AnyspendProvider.d.ts +5 -2
- package/dist/esm/anyspend/react/providers/AnyspendProvider.js +5 -3
- package/dist/esm/anyspend/react/providers/index.d.ts +1 -0
- package/dist/esm/anyspend/react/providers/index.js +1 -0
- package/dist/esm/anyspend/types/api.d.ts +11 -1
- package/dist/esm/anyspend/utils/orderPayload.js +1 -0
- package/dist/esm/bondkit/bondkitToken.d.ts +37 -2
- package/dist/esm/bondkit/bondkitToken.js +268 -2
- package/dist/esm/bondkit/bondkitTokenFactory.d.ts +1 -1
- package/dist/esm/bondkit/bondkitTokenFactory.js +2 -2
- package/dist/esm/bondkit/config.d.ts +1 -1
- package/dist/esm/bondkit/config.js +5 -2
- package/dist/esm/bondkit/constants.d.ts +4 -0
- package/dist/esm/bondkit/constants.js +5 -0
- package/dist/esm/bondkit/index.d.ts +1 -0
- package/dist/esm/bondkit/index.js +2 -0
- package/dist/esm/bondkit/swapService.d.ts +43 -0
- package/dist/esm/bondkit/swapService.js +369 -0
- package/dist/esm/bondkit/types.d.ts +10 -4
- package/dist/esm/bondkit/types.js +4 -5
- package/dist/esm/global-account/react/components/B3Provider/B3Provider.d.ts +4 -3
- package/dist/esm/global-account/react/components/B3Provider/B3Provider.js +36 -9
- package/dist/esm/global-account/react/components/LinkAccount/LinkAccount.js +65 -5
- package/dist/esm/global-account/react/components/ManageAccount/ManageAccount.js +35 -2
- package/dist/esm/global-account/react/components/SignInWithB3/steps/LoginStepCustom.js +3 -2
- package/dist/esm/global-account/react/hooks/useAuthentication.js +1 -2
- package/dist/esm/global-account/react/hooks/useSimBalance.js +2 -2
- package/dist/esm/global-account/react/hooks/useUnifiedChainSwitchAndExecute.js +22 -20
- package/dist/styles/index.css +1 -1
- package/dist/types/anyspend/react/components/AnySpend.d.ts +10 -1
- package/dist/types/anyspend/react/components/AnySpendCustom.d.ts +1 -0
- package/dist/types/anyspend/react/components/AnySpendNFT.d.ts +2 -1
- package/dist/types/anyspend/react/components/AnyspendDepositHype.d.ts +8 -0
- package/dist/types/anyspend/react/components/common/CryptoPaySection.d.ts +4 -1
- package/dist/types/anyspend/react/components/common/CryptoReceiveSection.d.ts +2 -1
- package/dist/types/anyspend/react/components/common/OrderTokenAmount.d.ts +4 -1
- package/dist/types/anyspend/react/components/common/PanelOnramp.d.ts +4 -1
- package/dist/types/anyspend/react/components/common/PointsBadge.d.ts +7 -0
- package/dist/types/anyspend/react/components/common/PointsDetailPanel.d.ts +6 -0
- package/dist/types/anyspend/react/contexts/FeatureFlagsContext.d.ts +11 -0
- package/dist/types/anyspend/react/hooks/useAnyspendFlow.d.ts +4 -1
- package/dist/types/anyspend/react/providers/AnyspendProvider.d.ts +5 -2
- package/dist/types/anyspend/react/providers/index.d.ts +1 -0
- package/dist/types/anyspend/types/api.d.ts +11 -1
- package/dist/types/bondkit/bondkitToken.d.ts +37 -2
- package/dist/types/bondkit/bondkitTokenFactory.d.ts +1 -1
- package/dist/types/bondkit/config.d.ts +1 -1
- package/dist/types/bondkit/constants.d.ts +4 -0
- package/dist/types/bondkit/index.d.ts +1 -0
- package/dist/types/bondkit/swapService.d.ts +43 -0
- package/dist/types/bondkit/types.d.ts +10 -4
- package/dist/types/global-account/react/components/B3Provider/B3Provider.d.ts +4 -3
- package/package.json +6 -5
- package/src/anyspend/react/components/AnySpend.tsx +24 -1
- package/src/anyspend/react/components/AnySpendBondKit.tsx +0 -1
- package/src/anyspend/react/components/AnySpendBuySpin.tsx +0 -1
- package/src/anyspend/react/components/AnySpendCustom.tsx +55 -13
- package/src/anyspend/react/components/AnySpendNFT.tsx +3 -0
- package/src/anyspend/react/components/AnySpendStakeB3.tsx +0 -1
- package/src/anyspend/react/components/AnyspendDepositHype.tsx +22 -0
- package/src/anyspend/react/components/AnyspendSignatureMint.tsx +0 -1
- package/src/anyspend/react/components/common/ConnectWalletPayment.tsx +7 -4
- package/src/anyspend/react/components/common/CryptoPaySection.tsx +13 -8
- package/src/anyspend/react/components/common/CryptoPaymentMethod.tsx +170 -44
- package/src/anyspend/react/components/common/CryptoReceiveSection.tsx +61 -45
- package/src/anyspend/react/components/common/OrderDetails.tsx +8 -9
- package/src/anyspend/react/components/common/OrderTokenAmount.tsx +28 -8
- package/src/anyspend/react/components/common/PanelOnramp.tsx +28 -15
- package/src/anyspend/react/components/common/PointsBadge.tsx +20 -0
- package/src/anyspend/react/components/common/PointsDetailPanel.tsx +55 -0
- package/src/anyspend/react/contexts/FeatureFlagsContext.tsx +34 -0
- package/src/anyspend/react/hooks/useAnyspendFlow.ts +1 -0
- package/src/anyspend/react/providers/AnyspendProvider.tsx +11 -6
- package/src/anyspend/react/providers/index.ts +1 -0
- package/src/anyspend/types/api.ts +11 -1
- package/src/anyspend/types/api_req_res.ts +6 -10
- package/src/anyspend/utils/orderPayload.ts +1 -0
- package/src/bondkit/bondkitToken.ts +323 -3
- package/src/bondkit/bondkitTokenFactory.ts +2 -2
- package/src/bondkit/config.ts +5 -2
- package/src/bondkit/constants.ts +7 -0
- package/src/bondkit/index.ts +3 -0
- package/src/bondkit/swapService.ts +461 -0
- package/src/bondkit/types.ts +12 -5
- package/src/global-account/react/components/B3Provider/B3Provider.tsx +51 -15
- package/src/global-account/react/components/LinkAccount/LinkAccount.tsx +106 -32
- package/src/global-account/react/components/ManageAccount/ManageAccount.tsx +60 -5
- package/src/global-account/react/components/SignInWithB3/steps/LoginStepCustom.tsx +4 -2
- package/src/global-account/react/hooks/useAuthentication.ts +1 -2
- package/src/global-account/react/hooks/useSimBalance.ts +2 -2
- package/src/global-account/react/hooks/useUnifiedChainSwitchAndExecute.ts +23 -21
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { useCoinbaseOnrampOptions, useGeoOnrampOptions } from "@b3dotfun/sdk/anyspend/react";
|
|
2
2
|
import { components } from "@b3dotfun/sdk/anyspend/types/api";
|
|
3
|
+
import { GetQuoteResponse } from "@b3dotfun/sdk/anyspend/types/api_req_res";
|
|
3
4
|
import { ALL_CHAINS } from "@b3dotfun/sdk/anyspend/utils/chain";
|
|
4
5
|
import { Input, useGetGeo, useProfile } from "@b3dotfun/sdk/global-account/react";
|
|
5
6
|
import { cn, formatUsername } from "@b3dotfun/sdk/shared/utils";
|
|
@@ -7,8 +8,10 @@ import { formatAddress } from "@b3dotfun/sdk/shared/utils/formatAddress";
|
|
|
7
8
|
import { ChevronRight, Wallet } from "lucide-react";
|
|
8
9
|
import { useRef } from "react";
|
|
9
10
|
import { toast } from "sonner";
|
|
11
|
+
import { useFeatureFlags } from "../../contexts/FeatureFlagsContext";
|
|
10
12
|
import { FiatPaymentMethod } from "./FiatPaymentMethod";
|
|
11
13
|
import { OrderTokenAmountFiat } from "./OrderTokenAmountFiat";
|
|
14
|
+
import { PointsBadge } from "./PointsBadge";
|
|
12
15
|
|
|
13
16
|
export function PanelOnramp({
|
|
14
17
|
srcAmountOnRamp,
|
|
@@ -25,6 +28,8 @@ export function PanelOnramp({
|
|
|
25
28
|
recipientSelectionPanelIndex,
|
|
26
29
|
dstTokenSymbol,
|
|
27
30
|
hideDstToken = false,
|
|
31
|
+
anyspendQuote,
|
|
32
|
+
onShowPointsDetail,
|
|
28
33
|
}: {
|
|
29
34
|
srcAmountOnRamp: string;
|
|
30
35
|
setSrcAmountOnRamp: (amount: string) => void;
|
|
@@ -40,7 +45,10 @@ export function PanelOnramp({
|
|
|
40
45
|
recipientSelectionPanelIndex: number;
|
|
41
46
|
dstTokenSymbol?: string;
|
|
42
47
|
hideDstToken?: boolean;
|
|
48
|
+
anyspendQuote?: GetQuoteResponse;
|
|
49
|
+
onShowPointsDetail?: () => void;
|
|
43
50
|
}) {
|
|
51
|
+
const featureFlags = useFeatureFlags();
|
|
44
52
|
// Get geo-based onramp options to access fee information
|
|
45
53
|
const { stripeWeb2Support } = useGeoOnrampOptions(srcAmountOnRamp);
|
|
46
54
|
|
|
@@ -245,21 +253,26 @@ export function PanelOnramp({
|
|
|
245
253
|
|
|
246
254
|
<div className="">
|
|
247
255
|
<div className="flex items-center justify-between">
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
256
|
+
<div className="flex items-center gap-2">
|
|
257
|
+
<span className="text-as-tertiarry text-sm">
|
|
258
|
+
{(() => {
|
|
259
|
+
const fee = getFeeFromApi(selectedPaymentMethod || FiatPaymentMethod.NONE);
|
|
260
|
+
return fee !== null ? `Total (included $${fee.toFixed(2)} fee)` : "Total";
|
|
261
|
+
})()}
|
|
262
|
+
</span>
|
|
263
|
+
{featureFlags.showPoints &&
|
|
264
|
+
anyspendQuote?.data?.pointsAmount &&
|
|
265
|
+
anyspendQuote?.data?.pointsAmount > 0 && (
|
|
266
|
+
<PointsBadge
|
|
267
|
+
pointsAmount={anyspendQuote.data.pointsAmount}
|
|
268
|
+
pointsMultiplier={anyspendQuote.data.pointsMultiplier}
|
|
269
|
+
onClick={() => onShowPointsDetail?.()}
|
|
270
|
+
/>
|
|
271
|
+
)}
|
|
272
|
+
</div>
|
|
273
|
+
<span className="text-as-primary font-semibold">
|
|
274
|
+
${getTotalAmount(selectedPaymentMethod || FiatPaymentMethod.NONE).toFixed(2)}
|
|
275
|
+
</span>
|
|
263
276
|
</div>
|
|
264
277
|
</div>
|
|
265
278
|
</div>
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
interface PointsBadgeProps {
|
|
2
|
+
pointsAmount: number;
|
|
3
|
+
pointsMultiplier?: number;
|
|
4
|
+
onClick?: () => void;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export function PointsBadge({ pointsAmount, pointsMultiplier, onClick }: PointsBadgeProps) {
|
|
8
|
+
return (
|
|
9
|
+
<button
|
|
10
|
+
className="bg-as-brand hover:scale-102 active:scale-98 relative flex cursor-pointer items-center gap-1 rounded-lg px-2 py-1 transition-all"
|
|
11
|
+
onClick={onClick}
|
|
12
|
+
>
|
|
13
|
+
<div className="pointer-events-none absolute inset-0 h-full w-full rounded-lg border border-white/10 border-t-white/20 bg-gradient-to-b from-white/10 to-white/0" />
|
|
14
|
+
<span className="relative text-xs text-white">
|
|
15
|
+
+{pointsAmount.toLocaleString()} pts
|
|
16
|
+
{pointsMultiplier && pointsMultiplier > 1 && <span className="ml-1 opacity-80">({pointsMultiplier}x)</span>}
|
|
17
|
+
</span>
|
|
18
|
+
</button>
|
|
19
|
+
);
|
|
20
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { Button, ShinyButton } from "@b3dotfun/sdk/global-account/react";
|
|
2
|
+
import { cn } from "@b3dotfun/sdk/shared/utils/cn";
|
|
3
|
+
import { ArrowDown } from "lucide-react";
|
|
4
|
+
import Link from "next/link";
|
|
5
|
+
|
|
6
|
+
interface PointsDetailPanelProps {
|
|
7
|
+
pointsAmount?: number;
|
|
8
|
+
onBack: () => void;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export function PointsDetailPanel({ pointsAmount = 0, onBack }: PointsDetailPanelProps) {
|
|
12
|
+
return (
|
|
13
|
+
<div className="mx-auto flex w-[460px] max-w-full flex-col items-center gap-4">
|
|
14
|
+
<div className="flex w-full items-center justify-between">
|
|
15
|
+
<Button
|
|
16
|
+
variant="ghost"
|
|
17
|
+
onClick={onBack}
|
|
18
|
+
className="text-as-primary/70 hover:text-as-primary flex items-center gap-2"
|
|
19
|
+
>
|
|
20
|
+
<ArrowDown className="h-4 w-4 rotate-90" />
|
|
21
|
+
Back
|
|
22
|
+
</Button>
|
|
23
|
+
</div>
|
|
24
|
+
|
|
25
|
+
<div className="flex flex-col items-center gap-4 text-center">
|
|
26
|
+
<h3 className="text-as-primary text-xl font-bold">Earn Points with Every Swap</h3>
|
|
27
|
+
<p className="text-as-primary/70 text-balance text-sm leading-relaxed">
|
|
28
|
+
You'll earn <span className="text-as-brand font-semibold">+{pointsAmount.toLocaleString()} points</span>{" "}
|
|
29
|
+
towards the{" "}
|
|
30
|
+
<Link href="https://anyspend.com/points" target="_blank" className="text-as-brand underline">
|
|
31
|
+
next AnySpend airdrop
|
|
32
|
+
</Link>{" "}
|
|
33
|
+
when you complete this transaction.
|
|
34
|
+
</p>
|
|
35
|
+
<div className="bg-as-surface-primary border-as-border-secondary mt-2 w-full rounded-lg border p-4 text-left">
|
|
36
|
+
<h4 className="text-as-primary mb-2 font-semibold">How it works:</h4>
|
|
37
|
+
<ul className="text-as-primary/70 space-y-1 text-sm">
|
|
38
|
+
<li>• Points are earned based on transaction volume</li>
|
|
39
|
+
<li>• Higher volume = more points</li>
|
|
40
|
+
<li>• Points contribute to future airdrops</li>
|
|
41
|
+
<li>• Keep swapping to maximize your rewards</li>
|
|
42
|
+
</ul>
|
|
43
|
+
</div>
|
|
44
|
+
<ShinyButton
|
|
45
|
+
accentColor={"hsl(var(--as-brand))"}
|
|
46
|
+
onClick={onBack}
|
|
47
|
+
className={cn("as-main-button !bg-as-brand relative w-full")}
|
|
48
|
+
textClassName={cn("text-white")}
|
|
49
|
+
>
|
|
50
|
+
Back to Swap
|
|
51
|
+
</ShinyButton>
|
|
52
|
+
</div>
|
|
53
|
+
</div>
|
|
54
|
+
);
|
|
55
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { createContext, useContext, ReactNode } from "react";
|
|
4
|
+
|
|
5
|
+
export interface FeatureFlags {
|
|
6
|
+
showPoints?: boolean;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
interface FeatureFlagsContextType {
|
|
10
|
+
featureFlags: FeatureFlags;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const FeatureFlagsContext = createContext<FeatureFlagsContextType | undefined>(undefined);
|
|
14
|
+
|
|
15
|
+
interface FeatureFlagsProviderProps {
|
|
16
|
+
children: ReactNode;
|
|
17
|
+
featureFlags?: FeatureFlags;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const defaultFeatureFlags: FeatureFlags = {
|
|
21
|
+
showPoints: false,
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export function FeatureFlagsProvider({ children, featureFlags = defaultFeatureFlags }: FeatureFlagsProviderProps) {
|
|
25
|
+
return <FeatureFlagsContext.Provider value={{ featureFlags }}>{children}</FeatureFlagsContext.Provider>;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export function useFeatureFlags(): FeatureFlags {
|
|
29
|
+
const context = useContext(FeatureFlagsContext);
|
|
30
|
+
if (!context) {
|
|
31
|
+
return defaultFeatureFlags;
|
|
32
|
+
}
|
|
33
|
+
return context.featureFlags;
|
|
34
|
+
}
|
|
@@ -3,10 +3,12 @@
|
|
|
3
3
|
import { TooltipProvider } from "@b3dotfun/sdk/global-account/react";
|
|
4
4
|
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
|
|
5
5
|
import { ReactNode, useState } from "react";
|
|
6
|
+
import { FeatureFlags, FeatureFlagsProvider } from "../contexts/FeatureFlagsContext";
|
|
6
7
|
import { StripeRedirectHandler } from "./StripeRedirectHandler";
|
|
7
8
|
|
|
8
9
|
interface AnyspendProviderProps {
|
|
9
10
|
children: ReactNode;
|
|
11
|
+
featureFlags?: FeatureFlags;
|
|
10
12
|
}
|
|
11
13
|
|
|
12
14
|
const defaultQueryClientConfig = {
|
|
@@ -29,27 +31,30 @@ const defaultQueryClientConfig = {
|
|
|
29
31
|
* - Safe to use at the application root
|
|
30
32
|
* - Configures sensible defaults for query caching
|
|
31
33
|
* - Handles Stripe payment redirects and modal state
|
|
34
|
+
* - Provides feature flags configuration
|
|
32
35
|
*
|
|
33
36
|
* @example
|
|
34
37
|
* ```tsx
|
|
35
38
|
* function App() {
|
|
36
39
|
* return (
|
|
37
|
-
* <AnyspendProvider>
|
|
40
|
+
* <AnyspendProvider featureFlags={{ showPoints: true }}>
|
|
38
41
|
* <YourApp />
|
|
39
42
|
* </AnyspendProvider>
|
|
40
43
|
* );
|
|
41
44
|
* }
|
|
42
45
|
* ```
|
|
43
46
|
*/
|
|
44
|
-
export const AnyspendProvider = function AnyspendProvider({ children }: AnyspendProviderProps) {
|
|
47
|
+
export const AnyspendProvider = function AnyspendProvider({ children, featureFlags }: AnyspendProviderProps) {
|
|
45
48
|
const [queryClient] = useState(() => new QueryClient(defaultQueryClientConfig));
|
|
46
49
|
|
|
47
50
|
return (
|
|
48
51
|
<QueryClientProvider client={queryClient}>
|
|
49
|
-
<
|
|
50
|
-
<
|
|
51
|
-
|
|
52
|
-
|
|
52
|
+
<FeatureFlagsProvider featureFlags={featureFlags}>
|
|
53
|
+
<TooltipProvider>
|
|
54
|
+
<StripeRedirectHandler />
|
|
55
|
+
{children}
|
|
56
|
+
</TooltipProvider>
|
|
57
|
+
</FeatureFlagsProvider>
|
|
53
58
|
</QueryClientProvider>
|
|
54
59
|
);
|
|
55
60
|
};
|
|
@@ -509,7 +509,7 @@ export interface paths {
|
|
|
509
509
|
* @description Type of trade execution
|
|
510
510
|
* @enum {string}
|
|
511
511
|
*/
|
|
512
|
-
tradeType: "EXACT_INPUT" | "
|
|
512
|
+
tradeType: "EXACT_INPUT" | "EXACT_OUTPUT";
|
|
513
513
|
/**
|
|
514
514
|
* @description Amount to quote
|
|
515
515
|
* @example 1000000000000000000
|
|
@@ -805,6 +805,16 @@ export interface paths {
|
|
|
805
805
|
* @example 0
|
|
806
806
|
*/
|
|
807
807
|
userBalance?: string;
|
|
808
|
+
/**
|
|
809
|
+
* @description Anyspend points that will be awarded for the order
|
|
810
|
+
* @example 100
|
|
811
|
+
*/
|
|
812
|
+
pointsAmount?: number;
|
|
813
|
+
/**
|
|
814
|
+
* @description Multiplier applied to points that will be awarded for the order
|
|
815
|
+
* @example 1.5
|
|
816
|
+
*/
|
|
817
|
+
pointsMultiplier?: number;
|
|
808
818
|
};
|
|
809
819
|
/** @example 200 */
|
|
810
820
|
statusCode: number;
|
|
@@ -1,16 +1,12 @@
|
|
|
1
1
|
import { paths } from "./api";
|
|
2
2
|
|
|
3
|
-
export type GetOrderAndTxsResponse =
|
|
4
|
-
paths["/orders/{orderId}"]["get"]["responses"]["200"]["content"]["application/json"];
|
|
3
|
+
export type GetOrderAndTxsResponse = paths["/orders/{orderId}"]["get"]["responses"]["200"]["content"]["application/json"];
|
|
5
4
|
export type GetQuoteRequest = paths["/orders/quote"]["post"]["requestBody"]["content"]["application/json"];
|
|
6
5
|
export type GetQuoteResponse = paths["/orders/quote"]["post"]["responses"]["200"]["content"]["application/json"];
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
|
|
7
|
+
export type GetCoinbaseOnrampOptionsResponse = paths["/onramp/coinbase/options"]["get"]["responses"]["200"]["content"]["application/json"];
|
|
9
8
|
export type GetOrderHistoryResponse = paths["/orders"]["get"]["responses"]["200"]["content"]["application/json"];
|
|
10
|
-
export type GetTokenListResponse =
|
|
11
|
-
paths["/chains/{chainId}/tokens"]["get"]["responses"]["200"]["content"]["application/json"];
|
|
9
|
+
export type GetTokenListResponse = paths["/chains/{chainId}/tokens"]["get"]["responses"]["200"]["content"]["application/json"];
|
|
12
10
|
export type CreateOrderResponse = paths["/orders"]["post"]["responses"]["200"]["content"]["application/json"];
|
|
13
|
-
export type GetStripeSupportedResponse =
|
|
14
|
-
|
|
15
|
-
export type GetStripeClientSecret =
|
|
16
|
-
paths["/stripe/clientSecret"]["get"]["responses"]["200"]["content"]["application/json"];
|
|
11
|
+
export type GetStripeSupportedResponse = paths["/onramp/stripe/supported"]["get"]["responses"]["200"]["content"]["application/json"];
|
|
12
|
+
export type GetStripeClientSecret = paths["/stripe/clientSecret"]["get"]["responses"]["200"]["content"]["application/json"];
|
|
@@ -13,13 +13,15 @@ import { privateKeyToAccount } from "viem/accounts";
|
|
|
13
13
|
import { base } from "viem/chains";
|
|
14
14
|
import { BondkitTokenABI } from "./abis";
|
|
15
15
|
import { getConfig } from "./config";
|
|
16
|
+
import { BondkitSwapService } from "./swapService";
|
|
16
17
|
import type {
|
|
17
18
|
BondkitTokenInitializationConfig,
|
|
18
19
|
GetTransactionHistoryOptions,
|
|
20
|
+
SwapQuote,
|
|
19
21
|
TokenDetails,
|
|
20
|
-
TokenStatus,
|
|
21
22
|
TransactionResponse,
|
|
22
23
|
} from "./types";
|
|
24
|
+
import { TokenStatus } from "./types";
|
|
23
25
|
|
|
24
26
|
// Event ABI snippets for decoding
|
|
25
27
|
const boughtEventAbi = BondkitTokenABI.find(item => item.type === "event" && item.name === "BondingCurveBuy");
|
|
@@ -53,9 +55,10 @@ export class BondkitToken {
|
|
|
53
55
|
private walletClientInstance: WalletClient;
|
|
54
56
|
private connectedProvider?: EIP1193Provider;
|
|
55
57
|
private tradingToken?: Address;
|
|
58
|
+
private swapService?: BondkitSwapService;
|
|
56
59
|
|
|
57
|
-
constructor(contractAddress: string, walletKey?: string) {
|
|
58
|
-
const sdkConfig = getConfig(base.id);
|
|
60
|
+
constructor(contractAddress: string, walletKey?: string, rpcUrl?: string) {
|
|
61
|
+
const sdkConfig = getConfig(base.id, rpcUrl);
|
|
59
62
|
this.chain = sdkConfig.chain;
|
|
60
63
|
this.rpcUrl = sdkConfig.rpcUrl;
|
|
61
64
|
this.apiEndpoint = sdkConfig.apiEndpoint;
|
|
@@ -657,6 +660,323 @@ export class BondkitToken {
|
|
|
657
660
|
return this.executeWrite("renounceOwnership", [], options);
|
|
658
661
|
}
|
|
659
662
|
|
|
663
|
+
// --- DEX Swap Methods ---
|
|
664
|
+
|
|
665
|
+
/**
|
|
666
|
+
* Get the swap service instance (lazy initialization)
|
|
667
|
+
*/
|
|
668
|
+
private getSwapService(): BondkitSwapService {
|
|
669
|
+
if (!this.swapService) {
|
|
670
|
+
this.swapService = new BondkitSwapService(this.contractAddress);
|
|
671
|
+
}
|
|
672
|
+
return this.swapService;
|
|
673
|
+
}
|
|
674
|
+
|
|
675
|
+
/**
|
|
676
|
+
* Check if DEX swapping is available (token must be in Dex phase)
|
|
677
|
+
*/
|
|
678
|
+
public async isSwapAvailable(): Promise<boolean | undefined> {
|
|
679
|
+
try {
|
|
680
|
+
const status = await this.currentStatus();
|
|
681
|
+
return status === TokenStatus.Dex;
|
|
682
|
+
} catch (error) {
|
|
683
|
+
console.warn("Error checking swap availability:", error);
|
|
684
|
+
return undefined;
|
|
685
|
+
}
|
|
686
|
+
}
|
|
687
|
+
|
|
688
|
+
/**
|
|
689
|
+
* Get swap quote for trading token → bondkit token
|
|
690
|
+
*/
|
|
691
|
+
public async getSwapQuoteForBondkitToken(
|
|
692
|
+
amountTradingTokenIn: string,
|
|
693
|
+
slippageTolerance = 0.5,
|
|
694
|
+
): Promise<SwapQuote | undefined> {
|
|
695
|
+
try {
|
|
696
|
+
// Check if swapping is available
|
|
697
|
+
const swapAvailable = await this.isSwapAvailable();
|
|
698
|
+
if (!swapAvailable) {
|
|
699
|
+
console.warn("DEX swapping not available - token must be in Dex phase");
|
|
700
|
+
return undefined;
|
|
701
|
+
}
|
|
702
|
+
|
|
703
|
+
const tradingTokenAddress = await this.getTradingTokenAddress();
|
|
704
|
+
if (!tradingTokenAddress) {
|
|
705
|
+
console.warn("Trading token address not available");
|
|
706
|
+
return undefined;
|
|
707
|
+
}
|
|
708
|
+
|
|
709
|
+
// Get token details for decimals
|
|
710
|
+
const [tradingTokenDecimals, bondkitTokenDecimals] = await Promise.all([
|
|
711
|
+
this.getTradingTokenDecimals(tradingTokenAddress),
|
|
712
|
+
this.decimals(),
|
|
713
|
+
]);
|
|
714
|
+
|
|
715
|
+
if (tradingTokenDecimals === undefined || bondkitTokenDecimals === undefined) {
|
|
716
|
+
console.warn("Unable to fetch token decimals");
|
|
717
|
+
return undefined;
|
|
718
|
+
}
|
|
719
|
+
|
|
720
|
+
const swapService = this.getSwapService();
|
|
721
|
+
const quote = await swapService.getSwapQuote({
|
|
722
|
+
tokenIn: tradingTokenAddress,
|
|
723
|
+
tokenOut: this.contractAddress,
|
|
724
|
+
amountIn: amountTradingTokenIn,
|
|
725
|
+
tokenInDecimals: tradingTokenDecimals,
|
|
726
|
+
tokenOutDecimals: bondkitTokenDecimals,
|
|
727
|
+
slippageTolerance,
|
|
728
|
+
recipient: this.walletClientInstance.account?.address || "0x0000000000000000000000000000000000000000",
|
|
729
|
+
});
|
|
730
|
+
return quote || undefined;
|
|
731
|
+
} catch (error) {
|
|
732
|
+
console.warn("Error getting swap quote for bondkit token:", error);
|
|
733
|
+
return undefined;
|
|
734
|
+
}
|
|
735
|
+
}
|
|
736
|
+
|
|
737
|
+
/**
|
|
738
|
+
* Get swap quote for bondkit token → trading token
|
|
739
|
+
*/
|
|
740
|
+
public async getSwapQuoteForTradingToken(
|
|
741
|
+
amountBondkitTokenIn: string,
|
|
742
|
+
slippageTolerance = 0.5,
|
|
743
|
+
): Promise<SwapQuote | undefined> {
|
|
744
|
+
try {
|
|
745
|
+
// Check if swapping is available
|
|
746
|
+
const swapAvailable = await this.isSwapAvailable();
|
|
747
|
+
if (!swapAvailable) {
|
|
748
|
+
console.warn("DEX swapping not available - token must be in Dex phase");
|
|
749
|
+
return undefined;
|
|
750
|
+
}
|
|
751
|
+
|
|
752
|
+
const tradingTokenAddress = await this.getTradingTokenAddress();
|
|
753
|
+
if (!tradingTokenAddress) {
|
|
754
|
+
console.warn("Trading token address not available");
|
|
755
|
+
return undefined;
|
|
756
|
+
}
|
|
757
|
+
|
|
758
|
+
// Get token details for decimals
|
|
759
|
+
const [bondkitTokenDecimals, tradingTokenDecimals] = await Promise.all([
|
|
760
|
+
this.decimals(),
|
|
761
|
+
this.getTradingTokenDecimals(tradingTokenAddress),
|
|
762
|
+
]);
|
|
763
|
+
|
|
764
|
+
if (bondkitTokenDecimals === undefined || tradingTokenDecimals === undefined) {
|
|
765
|
+
console.warn("Unable to fetch token decimals");
|
|
766
|
+
return undefined;
|
|
767
|
+
}
|
|
768
|
+
|
|
769
|
+
const swapService = this.getSwapService();
|
|
770
|
+
const quote = await swapService.getSwapQuote({
|
|
771
|
+
tokenIn: this.contractAddress,
|
|
772
|
+
tokenOut: tradingTokenAddress,
|
|
773
|
+
amountIn: amountBondkitTokenIn,
|
|
774
|
+
tokenInDecimals: bondkitTokenDecimals,
|
|
775
|
+
tokenOutDecimals: tradingTokenDecimals,
|
|
776
|
+
slippageTolerance,
|
|
777
|
+
recipient: this.walletClientInstance.account?.address || "0x0000000000000000000000000000000000000000",
|
|
778
|
+
});
|
|
779
|
+
return quote || undefined;
|
|
780
|
+
} catch (error) {
|
|
781
|
+
console.warn("Error getting swap quote for trading token:", error);
|
|
782
|
+
return undefined;
|
|
783
|
+
}
|
|
784
|
+
}
|
|
785
|
+
|
|
786
|
+
/**
|
|
787
|
+
* Swap trading token for bondkit token
|
|
788
|
+
*/
|
|
789
|
+
public async swapTradingTokenForBondkitToken(
|
|
790
|
+
amountTradingTokenIn: string,
|
|
791
|
+
slippageTolerance = 0.5,
|
|
792
|
+
options?: ExecuteWriteOptions,
|
|
793
|
+
): Promise<Hex | undefined> {
|
|
794
|
+
try {
|
|
795
|
+
// Check if swapping is available
|
|
796
|
+
const swapAvailable = await this.isSwapAvailable();
|
|
797
|
+
if (!swapAvailable) {
|
|
798
|
+
console.warn("DEX swapping not available - token must be in Dex phase");
|
|
799
|
+
return undefined;
|
|
800
|
+
}
|
|
801
|
+
|
|
802
|
+
if (!this.walletClientInstance.account && !this.walletKey) {
|
|
803
|
+
console.warn("Wallet key not set or client not connected for swap operation");
|
|
804
|
+
return undefined;
|
|
805
|
+
}
|
|
806
|
+
|
|
807
|
+
const tradingTokenAddress = await this.getTradingTokenAddress();
|
|
808
|
+
if (!tradingTokenAddress) {
|
|
809
|
+
console.warn("Trading token address not available");
|
|
810
|
+
return undefined;
|
|
811
|
+
}
|
|
812
|
+
|
|
813
|
+
// Get token details for decimals
|
|
814
|
+
const [tradingTokenDecimals, bondkitTokenDecimals] = await Promise.all([
|
|
815
|
+
this.getTradingTokenDecimals(tradingTokenAddress),
|
|
816
|
+
this.decimals(),
|
|
817
|
+
]);
|
|
818
|
+
|
|
819
|
+
if (tradingTokenDecimals === undefined || bondkitTokenDecimals === undefined) {
|
|
820
|
+
console.warn("Unable to fetch token decimals");
|
|
821
|
+
return undefined;
|
|
822
|
+
}
|
|
823
|
+
|
|
824
|
+
const recipient =
|
|
825
|
+
this.walletClientInstance.account?.address ||
|
|
826
|
+
(this.walletKey ? privateKeyToAccount(this.walletKey).address : undefined);
|
|
827
|
+
|
|
828
|
+
if (!recipient) {
|
|
829
|
+
console.warn("Unable to determine recipient address");
|
|
830
|
+
return undefined;
|
|
831
|
+
}
|
|
832
|
+
|
|
833
|
+
const swapService = this.getSwapService();
|
|
834
|
+
const txHash = await swapService.executeSwap(
|
|
835
|
+
{
|
|
836
|
+
tokenIn: tradingTokenAddress,
|
|
837
|
+
tokenOut: this.contractAddress,
|
|
838
|
+
amountIn: amountTradingTokenIn,
|
|
839
|
+
tokenInDecimals: tradingTokenDecimals,
|
|
840
|
+
tokenOutDecimals: bondkitTokenDecimals,
|
|
841
|
+
slippageTolerance,
|
|
842
|
+
recipient,
|
|
843
|
+
deadline: (options?.value ? Math.floor(Date.now() / 1000) : 0) + 3600,
|
|
844
|
+
},
|
|
845
|
+
this.walletClientInstance,
|
|
846
|
+
);
|
|
847
|
+
|
|
848
|
+
return txHash ? (txHash as Hex) : undefined;
|
|
849
|
+
} catch (error) {
|
|
850
|
+
console.warn("Error swapping trading token for bondkit token:", error);
|
|
851
|
+
return undefined;
|
|
852
|
+
}
|
|
853
|
+
}
|
|
854
|
+
|
|
855
|
+
/**
|
|
856
|
+
* Swap bondkit token for trading token
|
|
857
|
+
*/
|
|
858
|
+
public async swapBondkitTokenForTradingToken(
|
|
859
|
+
amountBondkitTokenIn: string,
|
|
860
|
+
slippageTolerance = 0.5,
|
|
861
|
+
options?: ExecuteWriteOptions,
|
|
862
|
+
): Promise<Hex | undefined> {
|
|
863
|
+
try {
|
|
864
|
+
// Check if swapping is available
|
|
865
|
+
const swapAvailable = await this.isSwapAvailable();
|
|
866
|
+
if (!swapAvailable) {
|
|
867
|
+
console.warn("DEX swapping not available - token must be in Dex phase");
|
|
868
|
+
return undefined;
|
|
869
|
+
}
|
|
870
|
+
|
|
871
|
+
if (!this.walletClientInstance.account && !this.walletKey) {
|
|
872
|
+
console.warn("Wallet key not set or client not connected for swap operation");
|
|
873
|
+
return undefined;
|
|
874
|
+
}
|
|
875
|
+
|
|
876
|
+
const tradingTokenAddress = await this.getTradingTokenAddress();
|
|
877
|
+
if (!tradingTokenAddress) {
|
|
878
|
+
console.warn("Trading token address not available");
|
|
879
|
+
return undefined;
|
|
880
|
+
}
|
|
881
|
+
|
|
882
|
+
// Get token details for decimals
|
|
883
|
+
const [bondkitTokenDecimals, tradingTokenDecimals] = await Promise.all([
|
|
884
|
+
this.decimals(),
|
|
885
|
+
this.getTradingTokenDecimals(tradingTokenAddress),
|
|
886
|
+
]);
|
|
887
|
+
|
|
888
|
+
if (bondkitTokenDecimals === undefined || tradingTokenDecimals === undefined) {
|
|
889
|
+
console.warn("Unable to fetch token decimals");
|
|
890
|
+
return undefined;
|
|
891
|
+
}
|
|
892
|
+
|
|
893
|
+
const recipient =
|
|
894
|
+
this.walletClientInstance.account?.address ||
|
|
895
|
+
(this.walletKey ? privateKeyToAccount(this.walletKey).address : undefined);
|
|
896
|
+
|
|
897
|
+
if (!recipient) {
|
|
898
|
+
console.warn("Unable to determine recipient address");
|
|
899
|
+
return undefined;
|
|
900
|
+
}
|
|
901
|
+
|
|
902
|
+
const swapService = this.getSwapService();
|
|
903
|
+
const txHash = await swapService.executeSwap(
|
|
904
|
+
{
|
|
905
|
+
tokenIn: this.contractAddress,
|
|
906
|
+
tokenOut: tradingTokenAddress,
|
|
907
|
+
amountIn: amountBondkitTokenIn,
|
|
908
|
+
tokenInDecimals: bondkitTokenDecimals,
|
|
909
|
+
tokenOutDecimals: tradingTokenDecimals,
|
|
910
|
+
slippageTolerance,
|
|
911
|
+
recipient,
|
|
912
|
+
deadline: (options?.value ? Math.floor(Date.now() / 1000) : 0) + 3600,
|
|
913
|
+
},
|
|
914
|
+
this.walletClientInstance,
|
|
915
|
+
);
|
|
916
|
+
|
|
917
|
+
return txHash ? (txHash as Hex) : undefined;
|
|
918
|
+
} catch (error) {
|
|
919
|
+
console.warn("Error swapping bondkit token for trading token:", error);
|
|
920
|
+
return undefined;
|
|
921
|
+
}
|
|
922
|
+
}
|
|
923
|
+
|
|
924
|
+
/**
|
|
925
|
+
* Helper method to get trading token decimals
|
|
926
|
+
*/
|
|
927
|
+
private async getTradingTokenDecimals(tradingTokenAddress: Address): Promise<number | undefined> {
|
|
928
|
+
try {
|
|
929
|
+
// ETH has 18 decimals
|
|
930
|
+
if (tradingTokenAddress === "0x0000000000000000000000000000000000000000") {
|
|
931
|
+
return 18;
|
|
932
|
+
}
|
|
933
|
+
|
|
934
|
+
// For ERC20 tokens, read decimals from contract
|
|
935
|
+
const tradingTokenContract = getContract({
|
|
936
|
+
address: tradingTokenAddress,
|
|
937
|
+
abi: erc20Abi,
|
|
938
|
+
client: this.publicClient,
|
|
939
|
+
});
|
|
940
|
+
|
|
941
|
+
const decimals = await tradingTokenContract.read.decimals();
|
|
942
|
+
return Number(decimals);
|
|
943
|
+
} catch (error) {
|
|
944
|
+
console.warn("Error fetching trading token decimals:", error);
|
|
945
|
+
return undefined;
|
|
946
|
+
}
|
|
947
|
+
}
|
|
948
|
+
|
|
949
|
+
/**
|
|
950
|
+
* Get trading token symbol
|
|
951
|
+
* @param tradingTokenAddress Optional trading token address to avoid fetching it again
|
|
952
|
+
*/
|
|
953
|
+
public async getTradingTokenSymbol(tradingTokenAddress?: Address): Promise<string | undefined> {
|
|
954
|
+
try {
|
|
955
|
+
const tokenAddress = tradingTokenAddress || (await this.getTradingTokenAddress());
|
|
956
|
+
if (!tokenAddress) {
|
|
957
|
+
return undefined;
|
|
958
|
+
}
|
|
959
|
+
|
|
960
|
+
// ETH symbol
|
|
961
|
+
if (tokenAddress === "0x0000000000000000000000000000000000000000") {
|
|
962
|
+
return "ETH";
|
|
963
|
+
}
|
|
964
|
+
|
|
965
|
+
// For ERC20 tokens, read symbol from contract
|
|
966
|
+
const tradingTokenContract = getContract({
|
|
967
|
+
address: tokenAddress,
|
|
968
|
+
abi: erc20Abi,
|
|
969
|
+
client: this.publicClient,
|
|
970
|
+
});
|
|
971
|
+
|
|
972
|
+
const symbol = await tradingTokenContract.read.symbol();
|
|
973
|
+
return symbol;
|
|
974
|
+
} catch (error) {
|
|
975
|
+
console.warn("Error fetching trading token symbol:", error);
|
|
976
|
+
return undefined;
|
|
977
|
+
}
|
|
978
|
+
}
|
|
979
|
+
|
|
660
980
|
// TODO: Add other specific write methods from BondkitTokenABI.ts
|
|
661
981
|
// e.g., setBondingCurve (if it exists and is external), updateArtistAddress, etc.
|
|
662
982
|
}
|