@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.
Files changed (181) hide show
  1. package/dist/cjs/anyspend/react/components/AnySpend.d.ts +10 -1
  2. package/dist/cjs/anyspend/react/components/AnySpend.js +8 -4
  3. package/dist/cjs/anyspend/react/components/AnySpendBondKit.js +0 -1
  4. package/dist/cjs/anyspend/react/components/AnySpendBuySpin.js +0 -1
  5. package/dist/cjs/anyspend/react/components/AnySpendCustom.d.ts +1 -0
  6. package/dist/cjs/anyspend/react/components/AnySpendCustom.js +26 -10
  7. package/dist/cjs/anyspend/react/components/AnySpendNFT.d.ts +2 -1
  8. package/dist/cjs/anyspend/react/components/AnySpendNFT.js +2 -2
  9. package/dist/cjs/anyspend/react/components/AnySpendStakeB3.js +0 -1
  10. package/dist/cjs/anyspend/react/components/AnyspendDepositHype.d.ts +8 -0
  11. package/dist/cjs/anyspend/react/components/AnyspendDepositHype.js +6 -3
  12. package/dist/cjs/anyspend/react/components/AnyspendSignatureMint.js +0 -1
  13. package/dist/cjs/anyspend/react/components/common/ConnectWalletPayment.js +5 -3
  14. package/dist/cjs/anyspend/react/components/common/CryptoPaySection.d.ts +4 -1
  15. package/dist/cjs/anyspend/react/components/common/CryptoPaySection.js +9 -9
  16. package/dist/cjs/anyspend/react/components/common/CryptoPaymentMethod.js +80 -10
  17. package/dist/cjs/anyspend/react/components/common/CryptoReceiveSection.d.ts +2 -1
  18. package/dist/cjs/anyspend/react/components/common/CryptoReceiveSection.js +40 -37
  19. package/dist/cjs/anyspend/react/components/common/OrderDetails.js +8 -8
  20. package/dist/cjs/anyspend/react/components/common/OrderTokenAmount.d.ts +4 -1
  21. package/dist/cjs/anyspend/react/components/common/OrderTokenAmount.js +23 -9
  22. package/dist/cjs/anyspend/react/components/common/PanelOnramp.d.ts +4 -1
  23. package/dist/cjs/anyspend/react/components/common/PanelOnramp.js +10 -6
  24. package/dist/cjs/anyspend/react/components/common/PointsBadge.d.ts +7 -0
  25. package/dist/cjs/anyspend/react/components/common/PointsBadge.js +7 -0
  26. package/dist/cjs/anyspend/react/components/common/PointsDetailPanel.d.ts +6 -0
  27. package/dist/cjs/anyspend/react/components/common/PointsDetailPanel.js +14 -0
  28. package/dist/cjs/anyspend/react/contexts/FeatureFlagsContext.d.ts +11 -0
  29. package/dist/cjs/anyspend/react/contexts/FeatureFlagsContext.js +21 -0
  30. package/dist/cjs/anyspend/react/hooks/useAnyspendFlow.d.ts +4 -1
  31. package/dist/cjs/anyspend/react/hooks/useAnyspendFlow.js +1 -0
  32. package/dist/cjs/anyspend/react/providers/AnyspendProvider.d.ts +5 -2
  33. package/dist/cjs/anyspend/react/providers/AnyspendProvider.js +5 -3
  34. package/dist/cjs/anyspend/react/providers/index.d.ts +1 -0
  35. package/dist/cjs/anyspend/react/providers/index.js +3 -0
  36. package/dist/cjs/anyspend/types/api.d.ts +11 -1
  37. package/dist/cjs/anyspend/utils/orderPayload.js +1 -0
  38. package/dist/cjs/bondkit/bondkitToken.d.ts +37 -2
  39. package/dist/cjs/bondkit/bondkitToken.js +268 -2
  40. package/dist/cjs/bondkit/bondkitTokenFactory.d.ts +1 -1
  41. package/dist/cjs/bondkit/bondkitTokenFactory.js +2 -2
  42. package/dist/cjs/bondkit/config.d.ts +1 -1
  43. package/dist/cjs/bondkit/config.js +5 -2
  44. package/dist/cjs/bondkit/constants.d.ts +4 -0
  45. package/dist/cjs/bondkit/constants.js +6 -1
  46. package/dist/cjs/bondkit/index.d.ts +1 -0
  47. package/dist/cjs/bondkit/index.js +4 -1
  48. package/dist/cjs/bondkit/swapService.d.ts +43 -0
  49. package/dist/cjs/bondkit/swapService.js +373 -0
  50. package/dist/cjs/bondkit/types.d.ts +10 -4
  51. package/dist/cjs/bondkit/types.js +4 -5
  52. package/dist/cjs/global-account/react/components/B3Provider/B3Provider.d.ts +4 -3
  53. package/dist/cjs/global-account/react/components/B3Provider/B3Provider.js +35 -9
  54. package/dist/cjs/global-account/react/components/LinkAccount/LinkAccount.js +63 -3
  55. package/dist/cjs/global-account/react/components/ManageAccount/ManageAccount.js +35 -2
  56. package/dist/cjs/global-account/react/components/SignInWithB3/steps/LoginStepCustom.js +4 -3
  57. package/dist/cjs/global-account/react/hooks/useAuthentication.js +1 -2
  58. package/dist/cjs/global-account/react/hooks/useSimBalance.js +2 -2
  59. package/dist/cjs/global-account/react/hooks/useUnifiedChainSwitchAndExecute.js +22 -20
  60. package/dist/esm/anyspend/react/components/AnySpend.d.ts +10 -1
  61. package/dist/esm/anyspend/react/components/AnySpend.js +8 -4
  62. package/dist/esm/anyspend/react/components/AnySpendBondKit.js +0 -1
  63. package/dist/esm/anyspend/react/components/AnySpendBuySpin.js +0 -1
  64. package/dist/esm/anyspend/react/components/AnySpendCustom.d.ts +1 -0
  65. package/dist/esm/anyspend/react/components/AnySpendCustom.js +26 -10
  66. package/dist/esm/anyspend/react/components/AnySpendNFT.d.ts +2 -1
  67. package/dist/esm/anyspend/react/components/AnySpendNFT.js +2 -2
  68. package/dist/esm/anyspend/react/components/AnySpendStakeB3.js +0 -1
  69. package/dist/esm/anyspend/react/components/AnyspendDepositHype.d.ts +8 -0
  70. package/dist/esm/anyspend/react/components/AnyspendDepositHype.js +6 -3
  71. package/dist/esm/anyspend/react/components/AnyspendSignatureMint.js +0 -1
  72. package/dist/esm/anyspend/react/components/common/ConnectWalletPayment.js +6 -4
  73. package/dist/esm/anyspend/react/components/common/CryptoPaySection.d.ts +4 -1
  74. package/dist/esm/anyspend/react/components/common/CryptoPaySection.js +9 -9
  75. package/dist/esm/anyspend/react/components/common/CryptoPaymentMethod.js +80 -10
  76. package/dist/esm/anyspend/react/components/common/CryptoReceiveSection.d.ts +2 -1
  77. package/dist/esm/anyspend/react/components/common/CryptoReceiveSection.js +40 -37
  78. package/dist/esm/anyspend/react/components/common/OrderDetails.js +8 -8
  79. package/dist/esm/anyspend/react/components/common/OrderTokenAmount.d.ts +4 -1
  80. package/dist/esm/anyspend/react/components/common/OrderTokenAmount.js +23 -9
  81. package/dist/esm/anyspend/react/components/common/PanelOnramp.d.ts +4 -1
  82. package/dist/esm/anyspend/react/components/common/PanelOnramp.js +10 -6
  83. package/dist/esm/anyspend/react/components/common/PointsBadge.d.ts +7 -0
  84. package/dist/esm/anyspend/react/components/common/PointsBadge.js +4 -0
  85. package/dist/esm/anyspend/react/components/common/PointsDetailPanel.d.ts +6 -0
  86. package/dist/esm/anyspend/react/components/common/PointsDetailPanel.js +8 -0
  87. package/dist/esm/anyspend/react/contexts/FeatureFlagsContext.d.ts +11 -0
  88. package/dist/esm/anyspend/react/contexts/FeatureFlagsContext.js +17 -0
  89. package/dist/esm/anyspend/react/hooks/useAnyspendFlow.d.ts +4 -1
  90. package/dist/esm/anyspend/react/hooks/useAnyspendFlow.js +1 -0
  91. package/dist/esm/anyspend/react/providers/AnyspendProvider.d.ts +5 -2
  92. package/dist/esm/anyspend/react/providers/AnyspendProvider.js +5 -3
  93. package/dist/esm/anyspend/react/providers/index.d.ts +1 -0
  94. package/dist/esm/anyspend/react/providers/index.js +1 -0
  95. package/dist/esm/anyspend/types/api.d.ts +11 -1
  96. package/dist/esm/anyspend/utils/orderPayload.js +1 -0
  97. package/dist/esm/bondkit/bondkitToken.d.ts +37 -2
  98. package/dist/esm/bondkit/bondkitToken.js +268 -2
  99. package/dist/esm/bondkit/bondkitTokenFactory.d.ts +1 -1
  100. package/dist/esm/bondkit/bondkitTokenFactory.js +2 -2
  101. package/dist/esm/bondkit/config.d.ts +1 -1
  102. package/dist/esm/bondkit/config.js +5 -2
  103. package/dist/esm/bondkit/constants.d.ts +4 -0
  104. package/dist/esm/bondkit/constants.js +5 -0
  105. package/dist/esm/bondkit/index.d.ts +1 -0
  106. package/dist/esm/bondkit/index.js +2 -0
  107. package/dist/esm/bondkit/swapService.d.ts +43 -0
  108. package/dist/esm/bondkit/swapService.js +369 -0
  109. package/dist/esm/bondkit/types.d.ts +10 -4
  110. package/dist/esm/bondkit/types.js +4 -5
  111. package/dist/esm/global-account/react/components/B3Provider/B3Provider.d.ts +4 -3
  112. package/dist/esm/global-account/react/components/B3Provider/B3Provider.js +36 -9
  113. package/dist/esm/global-account/react/components/LinkAccount/LinkAccount.js +65 -5
  114. package/dist/esm/global-account/react/components/ManageAccount/ManageAccount.js +35 -2
  115. package/dist/esm/global-account/react/components/SignInWithB3/steps/LoginStepCustom.js +3 -2
  116. package/dist/esm/global-account/react/hooks/useAuthentication.js +1 -2
  117. package/dist/esm/global-account/react/hooks/useSimBalance.js +2 -2
  118. package/dist/esm/global-account/react/hooks/useUnifiedChainSwitchAndExecute.js +22 -20
  119. package/dist/styles/index.css +1 -1
  120. package/dist/types/anyspend/react/components/AnySpend.d.ts +10 -1
  121. package/dist/types/anyspend/react/components/AnySpendCustom.d.ts +1 -0
  122. package/dist/types/anyspend/react/components/AnySpendNFT.d.ts +2 -1
  123. package/dist/types/anyspend/react/components/AnyspendDepositHype.d.ts +8 -0
  124. package/dist/types/anyspend/react/components/common/CryptoPaySection.d.ts +4 -1
  125. package/dist/types/anyspend/react/components/common/CryptoReceiveSection.d.ts +2 -1
  126. package/dist/types/anyspend/react/components/common/OrderTokenAmount.d.ts +4 -1
  127. package/dist/types/anyspend/react/components/common/PanelOnramp.d.ts +4 -1
  128. package/dist/types/anyspend/react/components/common/PointsBadge.d.ts +7 -0
  129. package/dist/types/anyspend/react/components/common/PointsDetailPanel.d.ts +6 -0
  130. package/dist/types/anyspend/react/contexts/FeatureFlagsContext.d.ts +11 -0
  131. package/dist/types/anyspend/react/hooks/useAnyspendFlow.d.ts +4 -1
  132. package/dist/types/anyspend/react/providers/AnyspendProvider.d.ts +5 -2
  133. package/dist/types/anyspend/react/providers/index.d.ts +1 -0
  134. package/dist/types/anyspend/types/api.d.ts +11 -1
  135. package/dist/types/bondkit/bondkitToken.d.ts +37 -2
  136. package/dist/types/bondkit/bondkitTokenFactory.d.ts +1 -1
  137. package/dist/types/bondkit/config.d.ts +1 -1
  138. package/dist/types/bondkit/constants.d.ts +4 -0
  139. package/dist/types/bondkit/index.d.ts +1 -0
  140. package/dist/types/bondkit/swapService.d.ts +43 -0
  141. package/dist/types/bondkit/types.d.ts +10 -4
  142. package/dist/types/global-account/react/components/B3Provider/B3Provider.d.ts +4 -3
  143. package/package.json +6 -5
  144. package/src/anyspend/react/components/AnySpend.tsx +24 -1
  145. package/src/anyspend/react/components/AnySpendBondKit.tsx +0 -1
  146. package/src/anyspend/react/components/AnySpendBuySpin.tsx +0 -1
  147. package/src/anyspend/react/components/AnySpendCustom.tsx +55 -13
  148. package/src/anyspend/react/components/AnySpendNFT.tsx +3 -0
  149. package/src/anyspend/react/components/AnySpendStakeB3.tsx +0 -1
  150. package/src/anyspend/react/components/AnyspendDepositHype.tsx +22 -0
  151. package/src/anyspend/react/components/AnyspendSignatureMint.tsx +0 -1
  152. package/src/anyspend/react/components/common/ConnectWalletPayment.tsx +7 -4
  153. package/src/anyspend/react/components/common/CryptoPaySection.tsx +13 -8
  154. package/src/anyspend/react/components/common/CryptoPaymentMethod.tsx +170 -44
  155. package/src/anyspend/react/components/common/CryptoReceiveSection.tsx +61 -45
  156. package/src/anyspend/react/components/common/OrderDetails.tsx +8 -9
  157. package/src/anyspend/react/components/common/OrderTokenAmount.tsx +28 -8
  158. package/src/anyspend/react/components/common/PanelOnramp.tsx +28 -15
  159. package/src/anyspend/react/components/common/PointsBadge.tsx +20 -0
  160. package/src/anyspend/react/components/common/PointsDetailPanel.tsx +55 -0
  161. package/src/anyspend/react/contexts/FeatureFlagsContext.tsx +34 -0
  162. package/src/anyspend/react/hooks/useAnyspendFlow.ts +1 -0
  163. package/src/anyspend/react/providers/AnyspendProvider.tsx +11 -6
  164. package/src/anyspend/react/providers/index.ts +1 -0
  165. package/src/anyspend/types/api.ts +11 -1
  166. package/src/anyspend/types/api_req_res.ts +6 -10
  167. package/src/anyspend/utils/orderPayload.ts +1 -0
  168. package/src/bondkit/bondkitToken.ts +323 -3
  169. package/src/bondkit/bondkitTokenFactory.ts +2 -2
  170. package/src/bondkit/config.ts +5 -2
  171. package/src/bondkit/constants.ts +7 -0
  172. package/src/bondkit/index.ts +3 -0
  173. package/src/bondkit/swapService.ts +461 -0
  174. package/src/bondkit/types.ts +12 -5
  175. package/src/global-account/react/components/B3Provider/B3Provider.tsx +51 -15
  176. package/src/global-account/react/components/LinkAccount/LinkAccount.tsx +106 -32
  177. package/src/global-account/react/components/ManageAccount/ManageAccount.tsx +60 -5
  178. package/src/global-account/react/components/SignInWithB3/steps/LoginStepCustom.tsx +4 -2
  179. package/src/global-account/react/hooks/useAuthentication.ts +1 -2
  180. package/src/global-account/react/hooks/useSimBalance.ts +2 -2
  181. package/src/global-account/react/hooks/useUnifiedChainSwitchAndExecute.ts +23 -21
@@ -7,9 +7,12 @@ import { formatAddress } from "../../../../shared/utils/formatAddress.js";
7
7
  import { ChevronRight, Wallet } from "lucide-react";
8
8
  import { useRef } from "react";
9
9
  import { toast } from "sonner";
10
+ import { useFeatureFlags } from "../../contexts/FeatureFlagsContext.js";
10
11
  import { FiatPaymentMethod } from "./FiatPaymentMethod.js";
11
12
  import { OrderTokenAmountFiat } from "./OrderTokenAmountFiat.js";
12
- export function PanelOnramp({ srcAmountOnRamp, setSrcAmountOnRamp, selectedPaymentMethod, setActivePanel, _recipientAddress, destinationToken, destinationChainId, destinationAmount, onDestinationTokenChange, onDestinationChainChange, fiatPaymentMethodIndex, recipientSelectionPanelIndex, dstTokenSymbol, hideDstToken = false, }) {
13
+ import { PointsBadge } from "./PointsBadge.js";
14
+ export function PanelOnramp({ srcAmountOnRamp, setSrcAmountOnRamp, selectedPaymentMethod, setActivePanel, _recipientAddress, destinationToken, destinationChainId, destinationAmount, onDestinationTokenChange, onDestinationChainChange, fiatPaymentMethodIndex, recipientSelectionPanelIndex, dstTokenSymbol, hideDstToken = false, anyspendQuote, onShowPointsDetail, }) {
15
+ const featureFlags = useFeatureFlags();
13
16
  // Get geo-based onramp options to access fee information
14
17
  const { stripeWeb2Support } = useGeoOnrampOptions(srcAmountOnRamp);
15
18
  // Helper function to get fees from API data
@@ -70,9 +73,10 @@ export function PanelOnramp({ srcAmountOnRamp, setSrcAmountOnRamp, selectedPayme
70
73
  width: `${Math.max(50, srcAmountOnRamp.length * 34)}px`,
71
74
  } })] }) }), _jsx("div", { className: cn("mx-auto mb-6 inline-grid grid-cols-4 gap-2", hideDstToken && "mb-0"), children: ["5", "10", "20", "25"].map(value => (_jsxs("button", { onClick: () => handleQuickAmount(value), className: `bg-as-surface-secondary border-as-border-secondary hover:border-as-border-secondary h-7 w-14 rounded-lg border text-sm font-medium transition-all duration-200 ${srcAmountOnRamp === value
72
75
  ? "border-as-border-secondary bg-as-surface-secondary"
73
- : "bg-as-surface-secondary hover:bg-as-surface-secondary"}`, children: ["$", value] }, value))) }), destinationToken && destinationChainId && !hideDstToken && (_jsx(OrderTokenAmountFiat, { address: _recipientAddress, context: "to", inputValue: destinationAmount || "0", onChangeInput: () => { }, chainId: destinationChainId, setChainId: onDestinationChainChange || (() => { }), token: destinationToken, setToken: onDestinationTokenChange || (() => { }) }))] }), _jsxs("div", { className: "border-as-border-secondary bg-as-surface-secondary mt-4 flex w-full flex-col gap-3 rounded-xl border p-4", children: [_jsxs("div", { className: "flex w-full items-center justify-between gap-2", children: [_jsx("span", { className: "text-as-tertiarry flex items-center text-sm", children: "Recipient" }), _recipientAddress ? (_jsxs("button", { className: "text-as-tertiarry flex h-7 items-center gap-1 text-sm transition-colors hover:text-blue-700", onClick: () => setActivePanel(recipientSelectionPanelIndex), children: [_jsx("span", { className: "text-sm", children: recipientName ? formatUsername(recipientName) : formatAddress(_recipientAddress) }), _jsx(ChevronRight, { size: 16 })] })) : (_jsxs("button", { className: "text-as-tertiarry flex h-7 items-center gap-1 text-sm transition-colors hover:text-blue-700", onClick: () => setActivePanel(5), children: [_jsx(Wallet, { className: "text-as-brand", size: 16 }), "Select recipient", _jsx(ChevronRight, { size: 16 })] }))] }), _jsx("div", { className: "divider w-full" }), _jsxs("div", { className: "flex items-center justify-between", children: [_jsx("span", { className: "text-as-tertiarry text-sm", children: "Expected to receive" }), _jsxs("div", { className: "flex items-center gap-2", children: [_jsxs("span", { className: "text-as-primary font-semibold", children: [destinationAmount || "0", " ", dstTokenSymbol || destinationToken?.symbol || ""] }), _jsxs("span", { className: "text-as-tertiarry text-sm", children: ["on ", destinationChainId ? ALL_CHAINS[destinationChainId]?.name : ""] }), destinationToken && destinationChainId && destinationToken.metadata?.logoURI && (_jsx("img", { src: ALL_CHAINS[destinationChainId]?.logoUrl, alt: "Chain", className: "h-4 w-4 rounded-full" }))] })] }), _jsx("div", { className: "divider w-full" }), _jsx("div", { className: "", children: _jsx("div", { className: "flex items-center justify-between", children: (() => {
74
- const currentPaymentMethod = selectedPaymentMethod || FiatPaymentMethod.NONE;
75
- const fee = getFeeFromApi(currentPaymentMethod);
76
- return (_jsxs(_Fragment, { children: [_jsx("span", { className: "text-as-tertiarry text-sm", children: fee !== null ? `Total (included $${fee.toFixed(2)} fee)` : "Total" }), _jsxs("span", { className: "text-as-primary font-semibold", children: ["$", getTotalAmount(currentPaymentMethod).toFixed(2)] })] }));
77
- })() }) })] })] }));
76
+ : "bg-as-surface-secondary hover:bg-as-surface-secondary"}`, children: ["$", value] }, value))) }), destinationToken && destinationChainId && !hideDstToken && (_jsx(OrderTokenAmountFiat, { address: _recipientAddress, context: "to", inputValue: destinationAmount || "0", onChangeInput: () => { }, chainId: destinationChainId, setChainId: onDestinationChainChange || (() => { }), token: destinationToken, setToken: onDestinationTokenChange || (() => { }) }))] }), _jsxs("div", { className: "border-as-border-secondary bg-as-surface-secondary mt-4 flex w-full flex-col gap-3 rounded-xl border p-4", children: [_jsxs("div", { className: "flex w-full items-center justify-between gap-2", children: [_jsx("span", { className: "text-as-tertiarry flex items-center text-sm", children: "Recipient" }), _recipientAddress ? (_jsxs("button", { className: "text-as-tertiarry flex h-7 items-center gap-1 text-sm transition-colors hover:text-blue-700", onClick: () => setActivePanel(recipientSelectionPanelIndex), children: [_jsx("span", { className: "text-sm", children: recipientName ? formatUsername(recipientName) : formatAddress(_recipientAddress) }), _jsx(ChevronRight, { size: 16 })] })) : (_jsxs("button", { className: "text-as-tertiarry flex h-7 items-center gap-1 text-sm transition-colors hover:text-blue-700", onClick: () => setActivePanel(5), children: [_jsx(Wallet, { className: "text-as-brand", size: 16 }), "Select recipient", _jsx(ChevronRight, { size: 16 })] }))] }), _jsx("div", { className: "divider w-full" }), _jsxs("div", { className: "flex items-center justify-between", children: [_jsx("span", { className: "text-as-tertiarry text-sm", children: "Expected to receive" }), _jsxs("div", { className: "flex items-center gap-2", children: [_jsxs("span", { className: "text-as-primary font-semibold", children: [destinationAmount || "0", " ", dstTokenSymbol || destinationToken?.symbol || ""] }), _jsxs("span", { className: "text-as-tertiarry text-sm", children: ["on ", destinationChainId ? ALL_CHAINS[destinationChainId]?.name : ""] }), destinationToken && destinationChainId && destinationToken.metadata?.logoURI && (_jsx("img", { src: ALL_CHAINS[destinationChainId]?.logoUrl, alt: "Chain", className: "h-4 w-4 rounded-full" }))] })] }), _jsx("div", { className: "divider w-full" }), _jsx("div", { className: "", children: _jsxs("div", { className: "flex items-center justify-between", children: [_jsxs("div", { className: "flex items-center gap-2", children: [_jsx("span", { className: "text-as-tertiarry text-sm", children: (() => {
77
+ const fee = getFeeFromApi(selectedPaymentMethod || FiatPaymentMethod.NONE);
78
+ return fee !== null ? `Total (included $${fee.toFixed(2)} fee)` : "Total";
79
+ })() }), featureFlags.showPoints &&
80
+ anyspendQuote?.data?.pointsAmount &&
81
+ anyspendQuote?.data?.pointsAmount > 0 && (_jsx(PointsBadge, { pointsAmount: anyspendQuote.data.pointsAmount, pointsMultiplier: anyspendQuote.data.pointsMultiplier, onClick: () => onShowPointsDetail?.() }))] }), _jsxs("span", { className: "text-as-primary font-semibold", children: ["$", getTotalAmount(selectedPaymentMethod || FiatPaymentMethod.NONE).toFixed(2)] })] }) })] })] }));
78
82
  }
@@ -0,0 +1,7 @@
1
+ interface PointsBadgeProps {
2
+ pointsAmount: number;
3
+ pointsMultiplier?: number;
4
+ onClick?: () => void;
5
+ }
6
+ export declare function PointsBadge({ pointsAmount, pointsMultiplier, onClick }: PointsBadgeProps): import("react/jsx-runtime").JSX.Element;
7
+ export {};
@@ -0,0 +1,4 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ export function PointsBadge({ pointsAmount, pointsMultiplier, onClick }) {
3
+ return (_jsxs("button", { 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", onClick: onClick, children: [_jsx("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" }), _jsxs("span", { className: "relative text-xs text-white", children: ["+", pointsAmount.toLocaleString(), " pts", pointsMultiplier && pointsMultiplier > 1 && _jsxs("span", { className: "ml-1 opacity-80", children: ["(", pointsMultiplier, "x)"] })] })] }));
4
+ }
@@ -0,0 +1,6 @@
1
+ interface PointsDetailPanelProps {
2
+ pointsAmount?: number;
3
+ onBack: () => void;
4
+ }
5
+ export declare function PointsDetailPanel({ pointsAmount, onBack }: PointsDetailPanelProps): import("react/jsx-runtime").JSX.Element;
6
+ export {};
@@ -0,0 +1,8 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Button, ShinyButton } from "../../../../global-account/react/index.js";
3
+ import { cn } from "../../../../shared/utils/cn.js";
4
+ import { ArrowDown } from "lucide-react";
5
+ import Link from "next/link";
6
+ export function PointsDetailPanel({ pointsAmount = 0, onBack }) {
7
+ return (_jsxs("div", { className: "mx-auto flex w-[460px] max-w-full flex-col items-center gap-4", children: [_jsx("div", { className: "flex w-full items-center justify-between", children: _jsxs(Button, { variant: "ghost", onClick: onBack, className: "text-as-primary/70 hover:text-as-primary flex items-center gap-2", children: [_jsx(ArrowDown, { className: "h-4 w-4 rotate-90" }), "Back"] }) }), _jsxs("div", { className: "flex flex-col items-center gap-4 text-center", children: [_jsx("h3", { className: "text-as-primary text-xl font-bold", children: "Earn Points with Every Swap" }), _jsxs("p", { className: "text-as-primary/70 text-balance text-sm leading-relaxed", children: ["You'll earn ", _jsxs("span", { className: "text-as-brand font-semibold", children: ["+", pointsAmount.toLocaleString(), " points"] }), " ", "towards the", " ", _jsx(Link, { href: "https://anyspend.com/points", target: "_blank", className: "text-as-brand underline", children: "next AnySpend airdrop" }), " ", "when you complete this transaction."] }), _jsxs("div", { className: "bg-as-surface-primary border-as-border-secondary mt-2 w-full rounded-lg border p-4 text-left", children: [_jsx("h4", { className: "text-as-primary mb-2 font-semibold", children: "How it works:" }), _jsxs("ul", { className: "text-as-primary/70 space-y-1 text-sm", children: [_jsx("li", { children: "\u2022 Points are earned based on transaction volume" }), _jsx("li", { children: "\u2022 Higher volume = more points" }), _jsx("li", { children: "\u2022 Points contribute to future airdrops" }), _jsx("li", { children: "\u2022 Keep swapping to maximize your rewards" })] })] }), _jsx(ShinyButton, { accentColor: "hsl(var(--as-brand))", onClick: onBack, className: cn("as-main-button !bg-as-brand relative w-full"), textClassName: cn("text-white"), children: "Back to Swap" })] })] }));
8
+ }
@@ -0,0 +1,11 @@
1
+ import { ReactNode } from "react";
2
+ export interface FeatureFlags {
3
+ showPoints?: boolean;
4
+ }
5
+ interface FeatureFlagsProviderProps {
6
+ children: ReactNode;
7
+ featureFlags?: FeatureFlags;
8
+ }
9
+ export declare function FeatureFlagsProvider({ children, featureFlags }: FeatureFlagsProviderProps): import("react/jsx-runtime").JSX.Element;
10
+ export declare function useFeatureFlags(): FeatureFlags;
11
+ export {};
@@ -0,0 +1,17 @@
1
+ "use client";
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ import { createContext, useContext } from "react";
4
+ const FeatureFlagsContext = createContext(undefined);
5
+ const defaultFeatureFlags = {
6
+ showPoints: false,
7
+ };
8
+ export function FeatureFlagsProvider({ children, featureFlags = defaultFeatureFlags }) {
9
+ return _jsx(FeatureFlagsContext.Provider, { value: { featureFlags }, children: children });
10
+ }
11
+ export function useFeatureFlags() {
12
+ const context = useContext(FeatureFlagsContext);
13
+ if (!context) {
14
+ return defaultFeatureFlags;
15
+ }
16
+ return context.featureFlags;
17
+ }
@@ -7,7 +7,8 @@ export declare enum PanelView {
7
7
  FIAT_PAYMENT_METHOD = 2,
8
8
  RECIPIENT_SELECTION = 3,
9
9
  ORDER_DETAILS = 4,
10
- LOADING = 5
10
+ LOADING = 5,
11
+ POINTS_DETAIL = 6
11
12
  }
12
13
  interface UseAnyspendFlowProps {
13
14
  paymentType?: "crypto" | "fiat";
@@ -140,6 +141,8 @@ export declare function useAnyspendFlow({ paymentType, recipientAddress, loadOrd
140
141
  };
141
142
  timeEstimate?: number;
142
143
  userBalance?: string;
144
+ pointsAmount?: number;
145
+ pointsMultiplier?: number;
143
146
  };
144
147
  statusCode: number;
145
148
  } | undefined;
@@ -18,6 +18,7 @@ export var PanelView;
18
18
  PanelView[PanelView["RECIPIENT_SELECTION"] = 3] = "RECIPIENT_SELECTION";
19
19
  PanelView[PanelView["ORDER_DETAILS"] = 4] = "ORDER_DETAILS";
20
20
  PanelView[PanelView["LOADING"] = 5] = "LOADING";
21
+ PanelView[PanelView["POINTS_DETAIL"] = 6] = "POINTS_DETAIL";
21
22
  })(PanelView || (PanelView = {}));
22
23
  export function useAnyspendFlow({ paymentType = "crypto", recipientAddress, loadOrder, isDepositMode = false, onOrderSuccess, onTransactionSuccess, sourceTokenAddress, sourceTokenChainId, slippage = 0, disableUrlParamManagement = false, }) {
23
24
  const searchParams = useSearchParamsSSR();
@@ -1,6 +1,8 @@
1
1
  import { ReactNode } from "react";
2
+ import { FeatureFlags } from "../contexts/FeatureFlagsContext";
2
3
  interface AnyspendProviderProps {
3
4
  children: ReactNode;
5
+ featureFlags?: FeatureFlags;
4
6
  }
5
7
  /**
6
8
  * AnyspendProvider is a top-level provider that wraps your application to provide
@@ -12,17 +14,18 @@ interface AnyspendProviderProps {
12
14
  * - Safe to use at the application root
13
15
  * - Configures sensible defaults for query caching
14
16
  * - Handles Stripe payment redirects and modal state
17
+ * - Provides feature flags configuration
15
18
  *
16
19
  * @example
17
20
  * ```tsx
18
21
  * function App() {
19
22
  * return (
20
- * <AnyspendProvider>
23
+ * <AnyspendProvider featureFlags={{ showPoints: true }}>
21
24
  * <YourApp />
22
25
  * </AnyspendProvider>
23
26
  * );
24
27
  * }
25
28
  * ```
26
29
  */
27
- export declare const AnyspendProvider: ({ children }: AnyspendProviderProps) => import("react/jsx-runtime").JSX.Element;
30
+ export declare const AnyspendProvider: ({ children, featureFlags }: AnyspendProviderProps) => import("react/jsx-runtime").JSX.Element;
28
31
  export {};
@@ -3,6 +3,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import { TooltipProvider } from "../../../global-account/react/index.js";
4
4
  import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
5
5
  import { useState } from "react";
6
+ import { FeatureFlagsProvider } from "../contexts/FeatureFlagsContext.js";
6
7
  import { StripeRedirectHandler } from "./StripeRedirectHandler.js";
7
8
  const defaultQueryClientConfig = {
8
9
  defaultOptions: {
@@ -23,19 +24,20 @@ const defaultQueryClientConfig = {
23
24
  * - Safe to use at the application root
24
25
  * - Configures sensible defaults for query caching
25
26
  * - Handles Stripe payment redirects and modal state
27
+ * - Provides feature flags configuration
26
28
  *
27
29
  * @example
28
30
  * ```tsx
29
31
  * function App() {
30
32
  * return (
31
- * <AnyspendProvider>
33
+ * <AnyspendProvider featureFlags={{ showPoints: true }}>
32
34
  * <YourApp />
33
35
  * </AnyspendProvider>
34
36
  * );
35
37
  * }
36
38
  * ```
37
39
  */
38
- export const AnyspendProvider = function AnyspendProvider({ children }) {
40
+ export const AnyspendProvider = function AnyspendProvider({ children, featureFlags }) {
39
41
  const [queryClient] = useState(() => new QueryClient(defaultQueryClientConfig));
40
- return (_jsx(QueryClientProvider, { client: queryClient, children: _jsxs(TooltipProvider, { children: [_jsx(StripeRedirectHandler, {}), children] }) }));
42
+ return (_jsx(QueryClientProvider, { client: queryClient, children: _jsx(FeatureFlagsProvider, { featureFlags: featureFlags, children: _jsxs(TooltipProvider, { children: [_jsx(StripeRedirectHandler, {}), children] }) }) }));
41
43
  };
@@ -1,2 +1,3 @@
1
1
  export * from "./AnyspendProvider";
2
2
  export * from "./StripeRedirectHandler";
3
+ export { useFeatureFlags, type FeatureFlags } from "../contexts/FeatureFlagsContext";
@@ -1,2 +1,3 @@
1
1
  export * from "./AnyspendProvider.js";
2
2
  export * from "./StripeRedirectHandler.js";
3
+ export { useFeatureFlags } from "../contexts/FeatureFlagsContext.js";
@@ -507,7 +507,7 @@ export interface paths {
507
507
  * @description Type of trade execution
508
508
  * @enum {string}
509
509
  */
510
- tradeType: "EXACT_INPUT" | "EXPECTED_OUTPUT" | "EXACT_OUTPUT";
510
+ tradeType: "EXACT_INPUT" | "EXACT_OUTPUT";
511
511
  /**
512
512
  * @description Amount to quote
513
513
  * @example 1000000000000000000
@@ -798,6 +798,16 @@ export interface paths {
798
798
  * @example 0
799
799
  */
800
800
  userBalance?: string;
801
+ /**
802
+ * @description Anyspend points that will be awarded for the order
803
+ * @example 100
804
+ */
805
+ pointsAmount?: number;
806
+ /**
807
+ * @description Multiplier applied to points that will be awarded for the order
808
+ * @example 1.5
809
+ */
810
+ pointsMultiplier?: number;
801
811
  };
802
812
  /** @example 200 */
803
813
  statusCode: number;
@@ -20,6 +20,7 @@ export const buildPayload = (orderType, params) => {
20
20
  return {
21
21
  contractAddress: normalizeAddress(nft.contractAddress),
22
22
  nftPrice: nft?.price || "",
23
+ tokenId: null,
23
24
  contractType: nft?.type,
24
25
  };
25
26
  }
@@ -1,6 +1,7 @@
1
1
  import type { Address, EIP1193Provider, GetContractReturnType, Hex, PublicClient, WalletClient } from "viem";
2
2
  import { BondkitTokenABI } from "./abis";
3
- import type { BondkitTokenInitializationConfig, GetTransactionHistoryOptions, TokenDetails, TokenStatus, TransactionResponse } from "./types";
3
+ import type { BondkitTokenInitializationConfig, GetTransactionHistoryOptions, SwapQuote, TokenDetails, TransactionResponse } from "./types";
4
+ import { TokenStatus } from "./types";
4
5
  type ExecuteWriteOptions = {
5
6
  value?: bigint;
6
7
  gas?: bigint;
@@ -18,7 +19,8 @@ export declare class BondkitToken {
18
19
  private walletClientInstance;
19
20
  private connectedProvider?;
20
21
  private tradingToken?;
21
- constructor(contractAddress: string, walletKey?: string);
22
+ private swapService?;
23
+ constructor(contractAddress: string, walletKey?: string, rpcUrl?: string);
22
24
  connect(provider?: EIP1193Provider): boolean;
23
25
  /**
24
26
  * Connects using an EIP-1193 provider and requests accounts, selecting the first one.
@@ -69,5 +71,38 @@ export declare class BondkitToken {
69
71
  migrateToDex(options?: ExecuteWriteOptions): Promise<Hex | undefined>;
70
72
  transferTokenOwnership(newOwner: Address, options?: ExecuteWriteOptions): Promise<Hex | undefined>;
71
73
  renounceTokenOwnership(options?: ExecuteWriteOptions): Promise<Hex | undefined>;
74
+ /**
75
+ * Get the swap service instance (lazy initialization)
76
+ */
77
+ private getSwapService;
78
+ /**
79
+ * Check if DEX swapping is available (token must be in Dex phase)
80
+ */
81
+ isSwapAvailable(): Promise<boolean | undefined>;
82
+ /**
83
+ * Get swap quote for trading token → bondkit token
84
+ */
85
+ getSwapQuoteForBondkitToken(amountTradingTokenIn: string, slippageTolerance?: number): Promise<SwapQuote | undefined>;
86
+ /**
87
+ * Get swap quote for bondkit token → trading token
88
+ */
89
+ getSwapQuoteForTradingToken(amountBondkitTokenIn: string, slippageTolerance?: number): Promise<SwapQuote | undefined>;
90
+ /**
91
+ * Swap trading token for bondkit token
92
+ */
93
+ swapTradingTokenForBondkitToken(amountTradingTokenIn: string, slippageTolerance?: number, options?: ExecuteWriteOptions): Promise<Hex | undefined>;
94
+ /**
95
+ * Swap bondkit token for trading token
96
+ */
97
+ swapBondkitTokenForTradingToken(amountBondkitTokenIn: string, slippageTolerance?: number, options?: ExecuteWriteOptions): Promise<Hex | undefined>;
98
+ /**
99
+ * Helper method to get trading token decimals
100
+ */
101
+ private getTradingTokenDecimals;
102
+ /**
103
+ * Get trading token symbol
104
+ * @param tradingTokenAddress Optional trading token address to avoid fetching it again
105
+ */
106
+ getTradingTokenSymbol(tradingTokenAddress?: Address): Promise<string | undefined>;
72
107
  }
73
108
  export {};
@@ -3,6 +3,8 @@ import { privateKeyToAccount } from "viem/accounts";
3
3
  import { base } from "viem/chains";
4
4
  import { BondkitTokenABI } from "./abis/index.js";
5
5
  import { getConfig } from "./config.js";
6
+ import { BondkitSwapService } from "./swapService.js";
7
+ import { TokenStatus } from "./types.js";
6
8
  // Event ABI snippets for decoding
7
9
  const boughtEventAbi = BondkitTokenABI.find(item => item.type === "event" && item.name === "BondingCurveBuy");
8
10
  const soldEventAbi = BondkitTokenABI.find(item => item.type === "event" && item.name === "BondingCurveSell");
@@ -11,8 +13,8 @@ const dexMigrationEventAbi = BondkitTokenABI.find(item => item.type === "event"
11
13
  const OKX_POLLING_MAX_RETRIES = 60; // 5 minutes with 5 second intervals
12
14
  const OKX_POLLING_INTERVAL_MS = 5000; // 5 seconds
13
15
  export class BondkitToken {
14
- constructor(contractAddress, walletKey) {
15
- const sdkConfig = getConfig(base.id);
16
+ constructor(contractAddress, walletKey, rpcUrl) {
17
+ const sdkConfig = getConfig(base.id, rpcUrl);
16
18
  this.chain = sdkConfig.chain;
17
19
  this.rpcUrl = sdkConfig.rpcUrl;
18
20
  this.apiEndpoint = sdkConfig.apiEndpoint;
@@ -555,4 +557,268 @@ export class BondkitToken {
555
557
  async renounceTokenOwnership(options) {
556
558
  return this.executeWrite("renounceOwnership", [], options);
557
559
  }
560
+ // --- DEX Swap Methods ---
561
+ /**
562
+ * Get the swap service instance (lazy initialization)
563
+ */
564
+ getSwapService() {
565
+ if (!this.swapService) {
566
+ this.swapService = new BondkitSwapService(this.contractAddress);
567
+ }
568
+ return this.swapService;
569
+ }
570
+ /**
571
+ * Check if DEX swapping is available (token must be in Dex phase)
572
+ */
573
+ async isSwapAvailable() {
574
+ try {
575
+ const status = await this.currentStatus();
576
+ return status === TokenStatus.Dex;
577
+ }
578
+ catch (error) {
579
+ console.warn("Error checking swap availability:", error);
580
+ return undefined;
581
+ }
582
+ }
583
+ /**
584
+ * Get swap quote for trading token → bondkit token
585
+ */
586
+ async getSwapQuoteForBondkitToken(amountTradingTokenIn, slippageTolerance = 0.5) {
587
+ try {
588
+ // Check if swapping is available
589
+ const swapAvailable = await this.isSwapAvailable();
590
+ if (!swapAvailable) {
591
+ console.warn("DEX swapping not available - token must be in Dex phase");
592
+ return undefined;
593
+ }
594
+ const tradingTokenAddress = await this.getTradingTokenAddress();
595
+ if (!tradingTokenAddress) {
596
+ console.warn("Trading token address not available");
597
+ return undefined;
598
+ }
599
+ // Get token details for decimals
600
+ const [tradingTokenDecimals, bondkitTokenDecimals] = await Promise.all([
601
+ this.getTradingTokenDecimals(tradingTokenAddress),
602
+ this.decimals(),
603
+ ]);
604
+ if (tradingTokenDecimals === undefined || bondkitTokenDecimals === undefined) {
605
+ console.warn("Unable to fetch token decimals");
606
+ return undefined;
607
+ }
608
+ const swapService = this.getSwapService();
609
+ const quote = await swapService.getSwapQuote({
610
+ tokenIn: tradingTokenAddress,
611
+ tokenOut: this.contractAddress,
612
+ amountIn: amountTradingTokenIn,
613
+ tokenInDecimals: tradingTokenDecimals,
614
+ tokenOutDecimals: bondkitTokenDecimals,
615
+ slippageTolerance,
616
+ recipient: this.walletClientInstance.account?.address || "0x0000000000000000000000000000000000000000",
617
+ });
618
+ return quote || undefined;
619
+ }
620
+ catch (error) {
621
+ console.warn("Error getting swap quote for bondkit token:", error);
622
+ return undefined;
623
+ }
624
+ }
625
+ /**
626
+ * Get swap quote for bondkit token → trading token
627
+ */
628
+ async getSwapQuoteForTradingToken(amountBondkitTokenIn, slippageTolerance = 0.5) {
629
+ try {
630
+ // Check if swapping is available
631
+ const swapAvailable = await this.isSwapAvailable();
632
+ if (!swapAvailable) {
633
+ console.warn("DEX swapping not available - token must be in Dex phase");
634
+ return undefined;
635
+ }
636
+ const tradingTokenAddress = await this.getTradingTokenAddress();
637
+ if (!tradingTokenAddress) {
638
+ console.warn("Trading token address not available");
639
+ return undefined;
640
+ }
641
+ // Get token details for decimals
642
+ const [bondkitTokenDecimals, tradingTokenDecimals] = await Promise.all([
643
+ this.decimals(),
644
+ this.getTradingTokenDecimals(tradingTokenAddress),
645
+ ]);
646
+ if (bondkitTokenDecimals === undefined || tradingTokenDecimals === undefined) {
647
+ console.warn("Unable to fetch token decimals");
648
+ return undefined;
649
+ }
650
+ const swapService = this.getSwapService();
651
+ const quote = await swapService.getSwapQuote({
652
+ tokenIn: this.contractAddress,
653
+ tokenOut: tradingTokenAddress,
654
+ amountIn: amountBondkitTokenIn,
655
+ tokenInDecimals: bondkitTokenDecimals,
656
+ tokenOutDecimals: tradingTokenDecimals,
657
+ slippageTolerance,
658
+ recipient: this.walletClientInstance.account?.address || "0x0000000000000000000000000000000000000000",
659
+ });
660
+ return quote || undefined;
661
+ }
662
+ catch (error) {
663
+ console.warn("Error getting swap quote for trading token:", error);
664
+ return undefined;
665
+ }
666
+ }
667
+ /**
668
+ * Swap trading token for bondkit token
669
+ */
670
+ async swapTradingTokenForBondkitToken(amountTradingTokenIn, slippageTolerance = 0.5, options) {
671
+ try {
672
+ // Check if swapping is available
673
+ const swapAvailable = await this.isSwapAvailable();
674
+ if (!swapAvailable) {
675
+ console.warn("DEX swapping not available - token must be in Dex phase");
676
+ return undefined;
677
+ }
678
+ if (!this.walletClientInstance.account && !this.walletKey) {
679
+ console.warn("Wallet key not set or client not connected for swap operation");
680
+ return undefined;
681
+ }
682
+ const tradingTokenAddress = await this.getTradingTokenAddress();
683
+ if (!tradingTokenAddress) {
684
+ console.warn("Trading token address not available");
685
+ return undefined;
686
+ }
687
+ // Get token details for decimals
688
+ const [tradingTokenDecimals, bondkitTokenDecimals] = await Promise.all([
689
+ this.getTradingTokenDecimals(tradingTokenAddress),
690
+ this.decimals(),
691
+ ]);
692
+ if (tradingTokenDecimals === undefined || bondkitTokenDecimals === undefined) {
693
+ console.warn("Unable to fetch token decimals");
694
+ return undefined;
695
+ }
696
+ const recipient = this.walletClientInstance.account?.address ||
697
+ (this.walletKey ? privateKeyToAccount(this.walletKey).address : undefined);
698
+ if (!recipient) {
699
+ console.warn("Unable to determine recipient address");
700
+ return undefined;
701
+ }
702
+ const swapService = this.getSwapService();
703
+ const txHash = await swapService.executeSwap({
704
+ tokenIn: tradingTokenAddress,
705
+ tokenOut: this.contractAddress,
706
+ amountIn: amountTradingTokenIn,
707
+ tokenInDecimals: tradingTokenDecimals,
708
+ tokenOutDecimals: bondkitTokenDecimals,
709
+ slippageTolerance,
710
+ recipient,
711
+ deadline: (options?.value ? Math.floor(Date.now() / 1000) : 0) + 3600,
712
+ }, this.walletClientInstance);
713
+ return txHash ? txHash : undefined;
714
+ }
715
+ catch (error) {
716
+ console.warn("Error swapping trading token for bondkit token:", error);
717
+ return undefined;
718
+ }
719
+ }
720
+ /**
721
+ * Swap bondkit token for trading token
722
+ */
723
+ async swapBondkitTokenForTradingToken(amountBondkitTokenIn, slippageTolerance = 0.5, options) {
724
+ try {
725
+ // Check if swapping is available
726
+ const swapAvailable = await this.isSwapAvailable();
727
+ if (!swapAvailable) {
728
+ console.warn("DEX swapping not available - token must be in Dex phase");
729
+ return undefined;
730
+ }
731
+ if (!this.walletClientInstance.account && !this.walletKey) {
732
+ console.warn("Wallet key not set or client not connected for swap operation");
733
+ return undefined;
734
+ }
735
+ const tradingTokenAddress = await this.getTradingTokenAddress();
736
+ if (!tradingTokenAddress) {
737
+ console.warn("Trading token address not available");
738
+ return undefined;
739
+ }
740
+ // Get token details for decimals
741
+ const [bondkitTokenDecimals, tradingTokenDecimals] = await Promise.all([
742
+ this.decimals(),
743
+ this.getTradingTokenDecimals(tradingTokenAddress),
744
+ ]);
745
+ if (bondkitTokenDecimals === undefined || tradingTokenDecimals === undefined) {
746
+ console.warn("Unable to fetch token decimals");
747
+ return undefined;
748
+ }
749
+ const recipient = this.walletClientInstance.account?.address ||
750
+ (this.walletKey ? privateKeyToAccount(this.walletKey).address : undefined);
751
+ if (!recipient) {
752
+ console.warn("Unable to determine recipient address");
753
+ return undefined;
754
+ }
755
+ const swapService = this.getSwapService();
756
+ const txHash = await swapService.executeSwap({
757
+ tokenIn: this.contractAddress,
758
+ tokenOut: tradingTokenAddress,
759
+ amountIn: amountBondkitTokenIn,
760
+ tokenInDecimals: bondkitTokenDecimals,
761
+ tokenOutDecimals: tradingTokenDecimals,
762
+ slippageTolerance,
763
+ recipient,
764
+ deadline: (options?.value ? Math.floor(Date.now() / 1000) : 0) + 3600,
765
+ }, this.walletClientInstance);
766
+ return txHash ? txHash : undefined;
767
+ }
768
+ catch (error) {
769
+ console.warn("Error swapping bondkit token for trading token:", error);
770
+ return undefined;
771
+ }
772
+ }
773
+ /**
774
+ * Helper method to get trading token decimals
775
+ */
776
+ async getTradingTokenDecimals(tradingTokenAddress) {
777
+ try {
778
+ // ETH has 18 decimals
779
+ if (tradingTokenAddress === "0x0000000000000000000000000000000000000000") {
780
+ return 18;
781
+ }
782
+ // For ERC20 tokens, read decimals from contract
783
+ const tradingTokenContract = getContract({
784
+ address: tradingTokenAddress,
785
+ abi: erc20Abi,
786
+ client: this.publicClient,
787
+ });
788
+ const decimals = await tradingTokenContract.read.decimals();
789
+ return Number(decimals);
790
+ }
791
+ catch (error) {
792
+ console.warn("Error fetching trading token decimals:", error);
793
+ return undefined;
794
+ }
795
+ }
796
+ /**
797
+ * Get trading token symbol
798
+ * @param tradingTokenAddress Optional trading token address to avoid fetching it again
799
+ */
800
+ async getTradingTokenSymbol(tradingTokenAddress) {
801
+ try {
802
+ const tokenAddress = tradingTokenAddress || (await this.getTradingTokenAddress());
803
+ if (!tokenAddress) {
804
+ return undefined;
805
+ }
806
+ // ETH symbol
807
+ if (tokenAddress === "0x0000000000000000000000000000000000000000") {
808
+ return "ETH";
809
+ }
810
+ // For ERC20 tokens, read symbol from contract
811
+ const tradingTokenContract = getContract({
812
+ address: tokenAddress,
813
+ abi: erc20Abi,
814
+ client: this.publicClient,
815
+ });
816
+ const symbol = await tradingTokenContract.read.symbol();
817
+ return symbol;
818
+ }
819
+ catch (error) {
820
+ console.warn("Error fetching trading token symbol:", error);
821
+ return undefined;
822
+ }
823
+ }
558
824
  }
@@ -10,7 +10,7 @@ export declare class BondkitTokenFactory {
10
10
  private rpcUrl;
11
11
  private walletClientInstance;
12
12
  private connectedProvider?;
13
- constructor(chainId: SupportedChainId, walletKey?: string);
13
+ constructor(chainId: SupportedChainId, walletKey?: string, rpcUrl?: string);
14
14
  connect(provider?: EIP1193Provider): boolean;
15
15
  /**
16
16
  * Connects using an EIP-1193 provider and requests accounts, selecting the first one.
@@ -5,14 +5,14 @@ import { getConfig } from "./config.js";
5
5
  // Define the event ABI snippet for BondkitTokenCreated specifically for decoding
6
6
  const bondkitTokenCreatedEventAbi = BondkitTokenFactoryABI.find(item => item.type === "event" && item.name === "BondkitTokenCreated");
7
7
  export class BondkitTokenFactory {
8
- constructor(chainId, walletKey) {
8
+ constructor(chainId, walletKey, rpcUrl) {
9
9
  if (walletKey && !walletKey.startsWith("0x")) {
10
10
  this.walletKey = `0x${walletKey}`;
11
11
  }
12
12
  else if (walletKey) {
13
13
  this.walletKey = walletKey;
14
14
  }
15
- const config = getConfig(chainId);
15
+ const config = getConfig(chainId, rpcUrl);
16
16
  this.chain = config.chain;
17
17
  this.contractAddress = config.factoryAddress;
18
18
  this.rpcUrl = config.rpcUrl;
@@ -7,4 +7,4 @@ export interface Config {
7
7
  apiEndpoint: string;
8
8
  }
9
9
  export type SupportedChainId = typeof base.id;
10
- export declare const getConfig: (chainId: number) => Config;
10
+ export declare const getConfig: (chainId: number, rpcUrl?: string) => Config;
@@ -6,9 +6,12 @@ const baseMainnetConfig = {
6
6
  factoryAddress: BaseBondkitTokenFactoryContractAddress,
7
7
  apiEndpoint: "https://api.b3.fun/bondkit-tokens",
8
8
  };
9
- export const getConfig = (chainId) => {
9
+ export const getConfig = (chainId, rpcUrl) => {
10
10
  if (chainId === base.id) {
11
- return baseMainnetConfig;
11
+ return {
12
+ ...baseMainnetConfig,
13
+ rpcUrl: rpcUrl || BaseMainnetRpcUrl,
14
+ };
12
15
  }
13
16
  throw new Error(`Unsupported chainId: ${chainId}. This SDK is configured for Base (Chain ID: ${base.id}) only.`);
14
17
  };