@b3dotfun/sdk 0.0.40-test.6 → 0.0.41-test.0
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/constants/index.d.ts +0 -1
- package/dist/cjs/anyspend/constants/index.js +1 -2
- package/dist/cjs/anyspend/react/components/AnySpend.d.ts +10 -1
- package/dist/cjs/anyspend/react/components/AnySpend.js +12 -9
- package/dist/cjs/anyspend/react/components/AnySpendCustom.js +8 -9
- package/dist/cjs/anyspend/react/components/AnyspendDepositHype.d.ts +8 -0
- package/dist/cjs/anyspend/react/components/AnyspendDepositHype.js +10 -8
- package/dist/cjs/anyspend/react/components/common/ConnectWalletPayment.d.ts +2 -1
- package/dist/cjs/anyspend/react/components/common/ConnectWalletPayment.js +7 -4
- 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 +39 -37
- package/dist/cjs/anyspend/react/components/common/OrderDetails.d.ts +2 -0
- package/dist/cjs/anyspend/react/components/common/OrderDetails.js +24 -23
- package/dist/cjs/anyspend/react/components/common/OrderDetailsCollapsible.js +9 -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 +7 -6
- package/dist/cjs/anyspend/react/components/common/PaymentMethodSwitch.d.ts +7 -0
- package/dist/cjs/anyspend/react/components/common/PaymentMethodSwitch.js +24 -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/components/common/TransferCryptoDetails.d.ts +2 -0
- package/dist/cjs/anyspend/react/components/common/TransferCryptoDetails.js +6 -4
- 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 +13 -5
- 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 +10 -0
- package/dist/cjs/anyspend/utils/chain.js +1 -1
- 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 +2 -1
- package/dist/cjs/global-account/react/components/B3Provider/B3Provider.js +14 -19
- 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/useAccountWallet.js +0 -12
- 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 +27 -22
- package/dist/esm/anyspend/constants/index.d.ts +0 -1
- package/dist/esm/anyspend/constants/index.js +0 -1
- package/dist/esm/anyspend/react/components/AnySpend.d.ts +10 -1
- package/dist/esm/anyspend/react/components/AnySpend.js +13 -10
- package/dist/esm/anyspend/react/components/AnySpendCustom.js +8 -9
- package/dist/esm/anyspend/react/components/AnyspendDepositHype.d.ts +8 -0
- package/dist/esm/anyspend/react/components/AnyspendDepositHype.js +11 -9
- package/dist/esm/anyspend/react/components/common/ConnectWalletPayment.d.ts +2 -1
- package/dist/esm/anyspend/react/components/common/ConnectWalletPayment.js +8 -5
- 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 +39 -37
- package/dist/esm/anyspend/react/components/common/OrderDetails.d.ts +2 -0
- package/dist/esm/anyspend/react/components/common/OrderDetails.js +25 -24
- package/dist/esm/anyspend/react/components/common/OrderDetailsCollapsible.js +10 -9
- 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 +7 -6
- package/dist/esm/anyspend/react/components/common/PaymentMethodSwitch.d.ts +7 -0
- package/dist/esm/anyspend/react/components/common/PaymentMethodSwitch.js +21 -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/components/common/TransferCryptoDetails.d.ts +2 -0
- package/dist/esm/anyspend/react/components/common/TransferCryptoDetails.js +6 -4
- 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 +13 -5
- 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 +10 -0
- package/dist/esm/anyspend/utils/chain.js +1 -1
- 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 +2 -1
- package/dist/esm/global-account/react/components/B3Provider/B3Provider.js +14 -19
- 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/useAccountWallet.js +0 -12
- 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 +27 -22
- package/dist/styles/index.css +1 -1
- package/dist/types/anyspend/constants/index.d.ts +0 -1
- package/dist/types/anyspend/react/components/AnySpend.d.ts +10 -1
- package/dist/types/anyspend/react/components/AnyspendDepositHype.d.ts +8 -0
- package/dist/types/anyspend/react/components/common/ConnectWalletPayment.d.ts +2 -1
- 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/OrderDetails.d.ts +2 -0
- 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/PaymentMethodSwitch.d.ts +7 -0
- package/dist/types/anyspend/react/components/common/PointsDetailPanel.d.ts +6 -0
- package/dist/types/anyspend/react/components/common/TransferCryptoDetails.d.ts +2 -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 +10 -0
- 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 +2 -1
- package/package.json +2 -1
- package/src/anyspend/constants/index.ts +0 -2
- package/src/anyspend/react/components/AnySpend.tsx +38 -17
- package/src/anyspend/react/components/AnySpendCustom.tsx +19 -21
- package/src/anyspend/react/components/AnyspendDepositHype.tsx +38 -18
- package/src/anyspend/react/components/common/ConnectWalletPayment.tsx +12 -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 +63 -45
- package/src/anyspend/react/components/common/OrderDetails.tsx +60 -47
- package/src/anyspend/react/components/common/OrderDetailsCollapsible.tsx +62 -41
- 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/PaymentMethodSwitch.tsx +38 -0
- package/src/anyspend/react/components/common/PointsDetailPanel.tsx +55 -0
- package/src/anyspend/react/components/common/TransferCryptoDetails.tsx +65 -43
- package/src/anyspend/react/contexts/FeatureFlagsContext.tsx +34 -0
- package/src/anyspend/react/hooks/useAnyspendFlow.ts +13 -5
- package/src/anyspend/react/providers/AnyspendProvider.tsx +11 -6
- package/src/anyspend/react/providers/index.ts +1 -0
- package/src/anyspend/types/api.ts +10 -0
- package/src/anyspend/types/api_req_res.ts +6 -10
- package/src/anyspend/utils/chain.ts +1 -1
- 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 +17 -19
- 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/useAccountWallet.tsx +0 -13
- 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 +28 -23
- package/dist/cjs/global-account/examples/client-selection-example.d.ts +0 -5
- package/dist/cjs/global-account/examples/client-selection-example.js +0 -96
- package/dist/esm/global-account/examples/client-selection-example.d.ts +0 -5
- package/dist/esm/global-account/examples/client-selection-example.js +0 -93
- package/dist/types/global-account/examples/client-selection-example.d.ts +0 -5
- package/src/global-account/docs/client-selection.md +0 -292
- package/src/global-account/examples/client-selection-example.tsx +0 -197
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { components } from "../../../../anyspend/types/api";
|
|
2
|
+
import { CryptoPaymentMethodType } from "./CryptoPaymentMethod";
|
|
2
3
|
type Order = components["schemas"]["Order"];
|
|
3
4
|
type Token = components["schemas"]["Token"];
|
|
4
5
|
type Tournament = components["schemas"]["Tournament"];
|
|
@@ -11,6 +12,7 @@ interface TransferCryptoDetailsProps {
|
|
|
11
12
|
nft?: NFT;
|
|
12
13
|
onBack: () => void;
|
|
13
14
|
recipientName?: string;
|
|
15
|
+
onPaymentMethodChange?: (method: CryptoPaymentMethodType) => void;
|
|
14
16
|
}
|
|
15
17
|
export declare const TransferCryptoDetails: import("react").NamedExoticComponent<TransferCryptoDetailsProps>;
|
|
16
18
|
export {};
|
|
@@ -13,8 +13,10 @@ const qrcode_react_1 = require("qrcode.react");
|
|
|
13
13
|
const react_3 = require("react");
|
|
14
14
|
const sonner_1 = require("sonner");
|
|
15
15
|
const chains_1 = require("viem/chains");
|
|
16
|
+
const CryptoPaymentMethod_1 = require("./CryptoPaymentMethod");
|
|
16
17
|
const OrderDetailsCollapsible_1 = require("./OrderDetailsCollapsible");
|
|
17
|
-
|
|
18
|
+
const PaymentMethodSwitch_1 = require("./PaymentMethodSwitch");
|
|
19
|
+
exports.TransferCryptoDetails = (0, react_3.memo)(function TransferCryptoDetails({ order, srcToken, dstToken, tournament, nft, onBack, recipientName, onPaymentMethodChange, }) {
|
|
18
20
|
const [timeLeft, setTimeLeft] = (0, react_3.useState)(0);
|
|
19
21
|
(0, react_3.useEffect)(() => {
|
|
20
22
|
const calculateTimeLeft = () => {
|
|
@@ -65,9 +67,9 @@ exports.TransferCryptoDetails = (0, react_3.memo)(function TransferCryptoDetails
|
|
|
65
67
|
navigator.clipboard.writeText(order.globalAddress);
|
|
66
68
|
sonner_1.toast.success("Deposit address copied to clipboard");
|
|
67
69
|
};
|
|
68
|
-
return ((0, jsx_runtime_1.jsxs)("div", { className: "flex w-full flex-col gap-6", children: [(0, jsx_runtime_1.jsxs)("div", { className: "flex items-center justify-between", children: [(0, jsx_runtime_1.jsx)("button", { onClick: onBack, className: "text-as-primary/60 hover:text-as-primary flex h-10 w-10 items-center justify-center rounded-full transition-colors", children: (0, jsx_runtime_1.jsx)(lucide_react_1.ChevronLeft, { size: 24, className: "text-as-quaternary" }) }), (0, jsx_runtime_1.jsx)("h2", { className: "text-as-primary text-lg font-semibold", children: "Transfer crypto" }), (0, jsx_runtime_1.jsxs)("div", { className: "relative flex h-11 w-11 items-center justify-center", children: [(0, jsx_runtime_1.jsxs)("svg", { className: "h-11 w-11 -rotate-90", viewBox: "0 0 44 44", children: [(0, jsx_runtime_1.jsx)("circle", { cx: "22", cy: "22", r: "18", stroke: "currentColor", strokeWidth: "3", fill: "none", className: "text-gray-200" }), (0, jsx_runtime_1.jsx)("circle", { cx: "22", cy: "22", r: "18", stroke: "currentColor", strokeWidth: "3", fill: "none", strokeLinecap: "round", className: "text-blue-500", strokeDasharray: `${2 * Math.PI * 18}`, strokeDashoffset: `${2 * Math.PI * 18 * (1 - timeLeft / totalTime)}`, style: {
|
|
70
|
+
return ((0, jsx_runtime_1.jsxs)("div", { className: "order-transfer-crypto flex w-full flex-col gap-6", children: [(0, jsx_runtime_1.jsxs)("div", { className: "order-transfer-crypto-header flex items-center justify-between", children: [(0, jsx_runtime_1.jsx)("button", { onClick: onBack, className: "order-transfer-crypto-back-btn text-as-primary/60 hover:text-as-primary flex h-10 w-10 items-center justify-center rounded-full transition-colors", children: (0, jsx_runtime_1.jsx)(lucide_react_1.ChevronLeft, { size: 24, className: "text-as-quaternary" }) }), (0, jsx_runtime_1.jsx)("h2", { className: "order-transfer-crypto-title text-as-primary text-lg font-semibold", children: "Transfer crypto" }), (0, jsx_runtime_1.jsxs)("div", { className: "order-transfer-crypto-timer relative flex h-11 w-11 items-center justify-center", children: [(0, jsx_runtime_1.jsxs)("svg", { className: "order-transfer-crypto-timer-svg h-11 w-11 -rotate-90", viewBox: "0 0 44 44", children: [(0, jsx_runtime_1.jsx)("circle", { cx: "22", cy: "22", r: "18", stroke: "currentColor", strokeWidth: "3", fill: "none", className: "order-transfer-crypto-timer-bg text-gray-200" }), (0, jsx_runtime_1.jsx)("circle", { cx: "22", cy: "22", r: "18", stroke: "currentColor", strokeWidth: "3", fill: "none", strokeLinecap: "round", className: "order-transfer-crypto-timer-progress text-blue-500", strokeDasharray: `${2 * Math.PI * 18}`, strokeDashoffset: `${2 * Math.PI * 18 * (1 - timeLeft / totalTime)}`, style: {
|
|
69
71
|
transition: "stroke-dashoffset 1s linear",
|
|
70
|
-
} })] }), (0, jsx_runtime_1.jsx)("div", { className: "absolute inset-0 flex items-center justify-center", children: (0, jsx_runtime_1.jsx)("span", { className: "text-as-primary text-[10px] font-semibold", children: formatTime(timeLeft) }) })] })] }), (0, jsx_runtime_1.jsxs)("div", { className: "flex w-full flex-col gap-4", children: [(0, jsx_runtime_1.jsxs)("div", { className: "flex items-center gap-4", children: [(0, jsx_runtime_1.jsxs)("div", { className: "w-full", children: [(0, jsx_runtime_1.jsx)("span", { className: "text-as-content-secondary text-sm font-medium", children: "Amount" }), (0, jsx_runtime_1.jsx)("div", { className: "border-as-border-primary rounded-lg border p-2 shadow-sm", children: (0, jsx_runtime_1.jsx)(react_1.CopyToClipboard, { text: roundedUpSrcAmount || "", onCopy: () => {
|
|
72
|
+
} })] }), (0, jsx_runtime_1.jsx)("div", { className: "order-transfer-crypto-timer-text absolute inset-0 flex items-center justify-center", children: (0, jsx_runtime_1.jsx)("span", { className: "text-as-primary text-[10px] font-semibold", children: formatTime(timeLeft) }) })] })] }), (0, jsx_runtime_1.jsxs)("div", { className: "order-transfer-crypto-content flex w-full flex-col gap-4", children: [(0, jsx_runtime_1.jsxs)("div", { className: "order-transfer-crypto-cards flex items-center gap-4", children: [(0, jsx_runtime_1.jsxs)("div", { className: "order-transfer-crypto-amount-card w-full", children: [(0, jsx_runtime_1.jsx)("span", { className: "order-transfer-crypto-amount-label text-as-content-secondary text-sm font-medium", children: "Amount" }), (0, jsx_runtime_1.jsx)("div", { className: "order-transfer-crypto-amount-container border-as-border-primary rounded-lg border p-2 shadow-sm", children: (0, jsx_runtime_1.jsx)(react_1.CopyToClipboard, { text: roundedUpSrcAmount || "", onCopy: () => {
|
|
71
73
|
sonner_1.toast.success("Amount copied to clipboard");
|
|
72
|
-
}, children: (0, jsx_runtime_1.jsxs)("div", { className: "flex cursor-pointer items-center justify-between gap-2", children: [(0, jsx_runtime_1.jsxs)("strong", { className: "text-as-primary font-semibold", children: [roundedUpSrcAmount, " ", srcToken.symbol] }), (0, jsx_runtime_1.jsx)(lucide_react_1.Copy, { className: "text-as-primary/50 hover:text-as-primary h-4 w-4 transition-all duration-200" })] }) }) })] }), (0, jsx_runtime_1.jsxs)("div", { className: "w-full", children: [(0, jsx_runtime_1.jsx)("span", { className: "text-as-content-secondary text-sm font-medium", children: "Chain" }), (0, jsx_runtime_1.jsx)("div", { className: "border-as-border-primary rounded-lg border p-2 shadow-sm", children: (0, jsx_runtime_1.jsxs)("div", { className: "flex items-center gap-2", children: [(0, jsx_runtime_1.jsx)("img", { src: anyspend_1.ALL_CHAINS[order.srcChain].logoUrl, alt: (0, anyspend_1.getChainName)(order.srcChain), className: (0, utils_1.cn)("h-6 rounded-full", order.srcChain === chains_1.b3.id && "h-5 rounded-none") }), (0, jsx_runtime_1.jsx)("span", { className: "text-as-primary text-sm font-semibold", children: (0, anyspend_1.getChainName)(order.srcChain) })] }) })] })] }), (0, jsx_runtime_1.jsxs)("div", { className: "border-b3-react-border bg-as-surface-secondary grid h-[220px] grid-cols-2 overflow-hidden rounded-xl border", children: [(0, jsx_runtime_1.jsx)("div", { className: "border-as-border-primary h-full w-full border-r", children: (0, jsx_runtime_1.jsx)("div", { className: "flex justify-center", children: (0, jsx_runtime_1.jsxs)("div", { className: "bg-as-surface-secondary flex flex-col items-center rounded-lg p-6", children: [(0, jsx_runtime_1.jsx)(qrcode_react_1.QRCodeSVG, { value: (0, anyspend_1.getPaymentUrl)(order.globalAddress, BigInt(order.srcAmount), order.srcTokenAddress === anyspend_1.RELAY_ETH_ADDRESS ? "ETH" : order.srcTokenAddress, order.srcChain, srcToken?.decimals), className: "bg-as-surface-secondary max-h-48 max-w-48" }), (0, jsx_runtime_1.jsxs)("div", { className: "mt-3 flex items-center justify-center gap-2 text-sm", children: [(0, jsx_runtime_1.jsx)("span", { className: "text-as-brand/70 text-sm font-medium", children: "SCAN WITH" }), (0, jsx_runtime_1.jsxs)(react_1.TextLoop, { interval: 3, children: [(0, jsx_runtime_1.jsx)(react_2.WalletMetamask, { className: "h-5 w-5", variant: "branded" }), (0, jsx_runtime_1.jsx)(react_2.WalletCoinbase, { className: "h-5 w-5", variant: "branded" }), (0, jsx_runtime_1.jsx)(react_2.WalletPhantom, { className: "h-5 w-5", variant: "branded" }), (0, jsx_runtime_1.jsx)(react_2.WalletTrust, { className: "h-5 w-5", variant: "branded" })] })] })] }) }) }), (0, jsx_runtime_1.jsxs)("div", { className: "flex h-full w-full flex-col gap-2 p-6", children: [(0, jsx_runtime_1.jsx)("span", { className: "text-as-content-secondary text-sm font-medium", children: "Deposit address:" }), (0, jsx_runtime_1.jsxs)("div", { className: "flex h-full cursor-pointer flex-col items-stretch justify-between gap-4", onClick: handleCopyAddress, children: [(0, jsx_runtime_1.jsx)("div", { className: "text-as-primary break-all font-mono text-sm font-semibold leading-relaxed", children: order.globalAddress }), (0, jsx_runtime_1.jsx)("div", { className: "place-self-end", children: (0, jsx_runtime_1.jsx)(lucide_react_1.Copy, { className: "group-hover:text-as-brand text-as-tertiarry h-4 w-4 cursor-pointer transition-all duration-200" }) })] })] })] }), (0, jsx_runtime_1.jsx)(OrderDetailsCollapsible_1.OrderDetailsCollapsible, { order: order, dstToken: dstToken, tournament: tournament, nft: nft, recipientName: recipientName, formattedExpectedDstAmount: formattedExpectedDstAmount })] }), (0, jsx_runtime_1.
|
|
74
|
+
}, children: (0, jsx_runtime_1.jsxs)("div", { className: "order-transfer-crypto-amount-copy flex cursor-pointer items-center justify-between gap-2", children: [(0, jsx_runtime_1.jsxs)("strong", { className: "order-transfer-crypto-amount-text text-as-primary font-semibold", children: [roundedUpSrcAmount, " ", srcToken.symbol] }), (0, jsx_runtime_1.jsx)(lucide_react_1.Copy, { className: "order-transfer-crypto-amount-copy-icon text-as-primary/50 hover:text-as-primary h-4 w-4 transition-all duration-200" })] }) }) })] }), (0, jsx_runtime_1.jsxs)("div", { className: "order-transfer-crypto-chain-card w-full", children: [(0, jsx_runtime_1.jsx)("span", { className: "order-transfer-crypto-chain-label text-as-content-secondary text-sm font-medium", children: "Chain" }), (0, jsx_runtime_1.jsx)("div", { className: "order-transfer-crypto-chain-container border-as-border-primary rounded-lg border p-2 shadow-sm", children: (0, jsx_runtime_1.jsxs)("div", { className: "order-transfer-crypto-chain-info flex items-center gap-2", children: [(0, jsx_runtime_1.jsx)("img", { src: anyspend_1.ALL_CHAINS[order.srcChain].logoUrl, alt: (0, anyspend_1.getChainName)(order.srcChain), className: (0, utils_1.cn)("order-transfer-crypto-chain-logo h-6 rounded-full", order.srcChain === chains_1.b3.id && "h-5 rounded-none") }), (0, jsx_runtime_1.jsx)("span", { className: "order-transfer-crypto-chain-name text-as-primary text-sm font-semibold", children: (0, anyspend_1.getChainName)(order.srcChain) })] }) })] })] }), (0, jsx_runtime_1.jsxs)("div", { className: "order-transfer-crypto-qr-deposit-card border-b3-react-border bg-as-surface-secondary grid h-[220px] grid-cols-2 overflow-hidden rounded-xl border", children: [(0, jsx_runtime_1.jsx)("div", { className: "order-transfer-crypto-qr-section border-as-border-primary h-full w-full border-r", children: (0, jsx_runtime_1.jsx)("div", { className: "order-transfer-crypto-qr-wrapper flex justify-center", children: (0, jsx_runtime_1.jsxs)("div", { className: "order-transfer-crypto-qr-container bg-as-surface-secondary flex flex-col items-center rounded-lg p-6", children: [(0, jsx_runtime_1.jsx)(qrcode_react_1.QRCodeSVG, { value: (0, anyspend_1.getPaymentUrl)(order.globalAddress, BigInt(order.srcAmount), order.srcTokenAddress === anyspend_1.RELAY_ETH_ADDRESS ? "ETH" : order.srcTokenAddress, order.srcChain, srcToken?.decimals), className: "order-transfer-crypto-qr-code bg-as-surface-secondary max-h-48 max-w-48" }), (0, jsx_runtime_1.jsxs)("div", { className: "order-transfer-crypto-wallet-hint mt-3 flex items-center justify-center gap-2 text-sm", children: [(0, jsx_runtime_1.jsx)("span", { className: "order-transfer-crypto-wallet-text text-as-brand/70 text-sm font-medium", children: "SCAN WITH" }), (0, jsx_runtime_1.jsxs)(react_1.TextLoop, { interval: 3, children: [(0, jsx_runtime_1.jsx)(react_2.WalletMetamask, { className: "order-transfer-crypto-wallet-icon h-5 w-5", variant: "branded" }), (0, jsx_runtime_1.jsx)(react_2.WalletCoinbase, { className: "order-transfer-crypto-wallet-icon h-5 w-5", variant: "branded" }), (0, jsx_runtime_1.jsx)(react_2.WalletPhantom, { className: "order-transfer-crypto-wallet-icon h-5 w-5", variant: "branded" }), (0, jsx_runtime_1.jsx)(react_2.WalletTrust, { className: "order-transfer-crypto-wallet-icon h-5 w-5", variant: "branded" })] })] })] }) }) }), (0, jsx_runtime_1.jsxs)("div", { className: "order-transfer-crypto-address-section flex h-full w-full flex-col gap-2 p-6", children: [(0, jsx_runtime_1.jsx)("span", { className: "order-transfer-crypto-address-label text-as-content-secondary text-sm font-medium", children: "Deposit address:" }), (0, jsx_runtime_1.jsxs)("div", { className: "order-transfer-crypto-address-copy flex h-full cursor-pointer flex-col items-stretch justify-between gap-4", onClick: handleCopyAddress, children: [(0, jsx_runtime_1.jsx)("div", { className: "order-transfer-crypto-address-text text-as-primary break-all font-mono text-sm font-semibold leading-relaxed", children: order.globalAddress }), (0, jsx_runtime_1.jsx)("div", { className: "order-transfer-crypto-address-copy-icon-wrapper place-self-end", children: (0, jsx_runtime_1.jsx)(lucide_react_1.Copy, { className: "order-transfer-crypto-address-copy-icon group-hover:text-as-brand text-as-tertiarry h-4 w-4 cursor-pointer transition-all duration-200" }) })] })] })] }), (0, jsx_runtime_1.jsx)(OrderDetailsCollapsible_1.OrderDetailsCollapsible, { order: order, dstToken: dstToken, tournament: tournament, nft: nft, recipientName: recipientName, formattedExpectedDstAmount: formattedExpectedDstAmount })] }), (0, jsx_runtime_1.jsxs)("div", { className: "order-transfer-crypto-actions flex flex-col gap-3", children: [(0, jsx_runtime_1.jsx)(react_1.ShinyButton, { accentColor: "hsl(var(--as-brand))", textColor: "text-white", className: "order-transfer-crypto-copy-btn w-full py-3", onClick: handleCopyAddress, children: "Copy deposit address" }), (0, jsx_runtime_1.jsx)(PaymentMethodSwitch_1.PaymentMethodSwitch, { currentMethod: CryptoPaymentMethod_1.CryptoPaymentMethodType.TRANSFER_CRYPTO, onMethodChange: onPaymentMethodChange })] })] }));
|
|
73
75
|
});
|
|
@@ -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,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
"use client";
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.FeatureFlagsProvider = FeatureFlagsProvider;
|
|
5
|
+
exports.useFeatureFlags = useFeatureFlags;
|
|
6
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
7
|
+
const react_1 = require("react");
|
|
8
|
+
const FeatureFlagsContext = (0, react_1.createContext)(undefined);
|
|
9
|
+
const defaultFeatureFlags = {
|
|
10
|
+
showPoints: false,
|
|
11
|
+
};
|
|
12
|
+
function FeatureFlagsProvider({ children, featureFlags = defaultFeatureFlags }) {
|
|
13
|
+
return (0, jsx_runtime_1.jsx)(FeatureFlagsContext.Provider, { value: { featureFlags }, children: children });
|
|
14
|
+
}
|
|
15
|
+
function useFeatureFlags() {
|
|
16
|
+
const context = (0, react_1.useContext)(FeatureFlagsContext);
|
|
17
|
+
if (!context) {
|
|
18
|
+
return defaultFeatureFlags;
|
|
19
|
+
}
|
|
20
|
+
return context.featureFlags;
|
|
21
|
+
}
|
|
@@ -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;
|
|
@@ -22,6 +22,7 @@ var PanelView;
|
|
|
22
22
|
PanelView[PanelView["RECIPIENT_SELECTION"] = 3] = "RECIPIENT_SELECTION";
|
|
23
23
|
PanelView[PanelView["ORDER_DETAILS"] = 4] = "ORDER_DETAILS";
|
|
24
24
|
PanelView[PanelView["LOADING"] = 5] = "LOADING";
|
|
25
|
+
PanelView[PanelView["POINTS_DETAIL"] = 6] = "POINTS_DETAIL";
|
|
25
26
|
})(PanelView || (exports.PanelView = PanelView = {}));
|
|
26
27
|
function useAnyspendFlow({ paymentType = "crypto", recipientAddress, loadOrder, isDepositMode = false, onOrderSuccess, onTransactionSuccess, sourceTokenAddress, sourceTokenChainId, slippage = 0, disableUrlParamManagement = false, }) {
|
|
27
28
|
const searchParams = (0, react_2.useSearchParamsSSR)();
|
|
@@ -189,12 +190,19 @@ function useAnyspendFlow({ paymentType = "crypto", recipientAddress, loadOrder,
|
|
|
189
190
|
// Handle order completion
|
|
190
191
|
(0, react_3.useEffect)(() => {
|
|
191
192
|
if (oat?.data?.order.status === "executed") {
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
const
|
|
195
|
-
|
|
193
|
+
// get the actualDstAmount if available from custompayload
|
|
194
|
+
const amount = oat.data.order.payload?.actualDstAmount;
|
|
195
|
+
const formattedActualDstAmount = amount
|
|
196
|
+
? (0, number_1.formatTokenAmount)(BigInt(amount), oat.data.order.metadata.dstToken.decimals)
|
|
197
|
+
: undefined;
|
|
198
|
+
onTransactionSuccess?.(formattedActualDstAmount);
|
|
196
199
|
}
|
|
197
|
-
}, [
|
|
200
|
+
}, [
|
|
201
|
+
oat?.data?.order.status,
|
|
202
|
+
oat?.data?.order.payload,
|
|
203
|
+
onTransactionSuccess,
|
|
204
|
+
oat?.data?.order.metadata.dstToken.decimals,
|
|
205
|
+
]);
|
|
198
206
|
return {
|
|
199
207
|
// State
|
|
200
208
|
activePanel,
|
|
@@ -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 {};
|
|
@@ -6,6 +6,7 @@ const jsx_runtime_1 = require("react/jsx-runtime");
|
|
|
6
6
|
const react_1 = require("../../../global-account/react");
|
|
7
7
|
const react_query_1 = require("@tanstack/react-query");
|
|
8
8
|
const react_2 = require("react");
|
|
9
|
+
const FeatureFlagsContext_1 = require("../contexts/FeatureFlagsContext");
|
|
9
10
|
const StripeRedirectHandler_1 = require("./StripeRedirectHandler");
|
|
10
11
|
const defaultQueryClientConfig = {
|
|
11
12
|
defaultOptions: {
|
|
@@ -26,20 +27,21 @@ const defaultQueryClientConfig = {
|
|
|
26
27
|
* - Safe to use at the application root
|
|
27
28
|
* - Configures sensible defaults for query caching
|
|
28
29
|
* - Handles Stripe payment redirects and modal state
|
|
30
|
+
* - Provides feature flags configuration
|
|
29
31
|
*
|
|
30
32
|
* @example
|
|
31
33
|
* ```tsx
|
|
32
34
|
* function App() {
|
|
33
35
|
* return (
|
|
34
|
-
* <AnyspendProvider>
|
|
36
|
+
* <AnyspendProvider featureFlags={{ showPoints: true }}>
|
|
35
37
|
* <YourApp />
|
|
36
38
|
* </AnyspendProvider>
|
|
37
39
|
* );
|
|
38
40
|
* }
|
|
39
41
|
* ```
|
|
40
42
|
*/
|
|
41
|
-
const AnyspendProvider = function AnyspendProvider({ children }) {
|
|
43
|
+
const AnyspendProvider = function AnyspendProvider({ children, featureFlags }) {
|
|
42
44
|
const [queryClient] = (0, react_2.useState)(() => new react_query_1.QueryClient(defaultQueryClientConfig));
|
|
43
|
-
return ((0, jsx_runtime_1.jsx)(react_query_1.QueryClientProvider, { client: queryClient, children: (0, jsx_runtime_1.jsxs)(react_1.TooltipProvider, { children: [(0, jsx_runtime_1.jsx)(StripeRedirectHandler_1.StripeRedirectHandler, {}), children] }) }));
|
|
45
|
+
return ((0, jsx_runtime_1.jsx)(react_query_1.QueryClientProvider, { client: queryClient, children: (0, jsx_runtime_1.jsx)(FeatureFlagsContext_1.FeatureFlagsProvider, { featureFlags: featureFlags, children: (0, jsx_runtime_1.jsxs)(react_1.TooltipProvider, { children: [(0, jsx_runtime_1.jsx)(StripeRedirectHandler_1.StripeRedirectHandler, {}), children] }) }) }));
|
|
44
46
|
};
|
|
45
47
|
exports.AnyspendProvider = AnyspendProvider;
|
|
@@ -14,5 +14,8 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.useFeatureFlags = void 0;
|
|
17
18
|
__exportStar(require("./AnyspendProvider"), exports);
|
|
18
19
|
__exportStar(require("./StripeRedirectHandler"), exports);
|
|
20
|
+
var FeatureFlagsContext_1 = require("../contexts/FeatureFlagsContext");
|
|
21
|
+
Object.defineProperty(exports, "useFeatureFlags", { enumerable: true, get: function () { return FeatureFlagsContext_1.useFeatureFlags; } });
|
|
@@ -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;
|
|
@@ -127,7 +127,7 @@ exports.EVM_MAINNET = {
|
|
|
127
127
|
name: chains_1.bsc.name,
|
|
128
128
|
logoUrl: "https://avatars.githubusercontent.com/u/45615063?s=280&v=4",
|
|
129
129
|
type: chain_1.ChainType.EVM,
|
|
130
|
-
nativeRequired: (0, viem_1.parseEther)("0.
|
|
130
|
+
nativeRequired: (0, viem_1.parseEther)("0.0001"),
|
|
131
131
|
canDepositNative: true,
|
|
132
132
|
defaultToken: (0, token_1.getBnbToken)(),
|
|
133
133
|
nativeToken: (0, token_1.getBnbToken)(),
|
|
@@ -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,
|
|
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
|
-
|
|
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 {};
|
|
@@ -6,6 +6,8 @@ const accounts_1 = require("viem/accounts");
|
|
|
6
6
|
const chains_1 = require("viem/chains");
|
|
7
7
|
const abis_1 = require("./abis");
|
|
8
8
|
const config_1 = require("./config");
|
|
9
|
+
const swapService_1 = require("./swapService");
|
|
10
|
+
const types_1 = require("./types");
|
|
9
11
|
// Event ABI snippets for decoding
|
|
10
12
|
const boughtEventAbi = abis_1.BondkitTokenABI.find(item => item.type === "event" && item.name === "BondingCurveBuy");
|
|
11
13
|
const soldEventAbi = abis_1.BondkitTokenABI.find(item => item.type === "event" && item.name === "BondingCurveSell");
|
|
@@ -14,8 +16,8 @@ const dexMigrationEventAbi = abis_1.BondkitTokenABI.find(item => item.type === "
|
|
|
14
16
|
const OKX_POLLING_MAX_RETRIES = 60; // 5 minutes with 5 second intervals
|
|
15
17
|
const OKX_POLLING_INTERVAL_MS = 5000; // 5 seconds
|
|
16
18
|
class BondkitToken {
|
|
17
|
-
constructor(contractAddress, walletKey) {
|
|
18
|
-
const sdkConfig = (0, config_1.getConfig)(chains_1.base.id);
|
|
19
|
+
constructor(contractAddress, walletKey, rpcUrl) {
|
|
20
|
+
const sdkConfig = (0, config_1.getConfig)(chains_1.base.id, rpcUrl);
|
|
19
21
|
this.chain = sdkConfig.chain;
|
|
20
22
|
this.rpcUrl = sdkConfig.rpcUrl;
|
|
21
23
|
this.apiEndpoint = sdkConfig.apiEndpoint;
|
|
@@ -558,5 +560,269 @@ class BondkitToken {
|
|
|
558
560
|
async renounceTokenOwnership(options) {
|
|
559
561
|
return this.executeWrite("renounceOwnership", [], options);
|
|
560
562
|
}
|
|
563
|
+
// --- DEX Swap Methods ---
|
|
564
|
+
/**
|
|
565
|
+
* Get the swap service instance (lazy initialization)
|
|
566
|
+
*/
|
|
567
|
+
getSwapService() {
|
|
568
|
+
if (!this.swapService) {
|
|
569
|
+
this.swapService = new swapService_1.BondkitSwapService(this.contractAddress);
|
|
570
|
+
}
|
|
571
|
+
return this.swapService;
|
|
572
|
+
}
|
|
573
|
+
/**
|
|
574
|
+
* Check if DEX swapping is available (token must be in Dex phase)
|
|
575
|
+
*/
|
|
576
|
+
async isSwapAvailable() {
|
|
577
|
+
try {
|
|
578
|
+
const status = await this.currentStatus();
|
|
579
|
+
return status === types_1.TokenStatus.Dex;
|
|
580
|
+
}
|
|
581
|
+
catch (error) {
|
|
582
|
+
console.warn("Error checking swap availability:", error);
|
|
583
|
+
return undefined;
|
|
584
|
+
}
|
|
585
|
+
}
|
|
586
|
+
/**
|
|
587
|
+
* Get swap quote for trading token → bondkit token
|
|
588
|
+
*/
|
|
589
|
+
async getSwapQuoteForBondkitToken(amountTradingTokenIn, slippageTolerance = 0.5) {
|
|
590
|
+
try {
|
|
591
|
+
// Check if swapping is available
|
|
592
|
+
const swapAvailable = await this.isSwapAvailable();
|
|
593
|
+
if (!swapAvailable) {
|
|
594
|
+
console.warn("DEX swapping not available - token must be in Dex phase");
|
|
595
|
+
return undefined;
|
|
596
|
+
}
|
|
597
|
+
const tradingTokenAddress = await this.getTradingTokenAddress();
|
|
598
|
+
if (!tradingTokenAddress) {
|
|
599
|
+
console.warn("Trading token address not available");
|
|
600
|
+
return undefined;
|
|
601
|
+
}
|
|
602
|
+
// Get token details for decimals
|
|
603
|
+
const [tradingTokenDecimals, bondkitTokenDecimals] = await Promise.all([
|
|
604
|
+
this.getTradingTokenDecimals(tradingTokenAddress),
|
|
605
|
+
this.decimals(),
|
|
606
|
+
]);
|
|
607
|
+
if (tradingTokenDecimals === undefined || bondkitTokenDecimals === undefined) {
|
|
608
|
+
console.warn("Unable to fetch token decimals");
|
|
609
|
+
return undefined;
|
|
610
|
+
}
|
|
611
|
+
const swapService = this.getSwapService();
|
|
612
|
+
const quote = await swapService.getSwapQuote({
|
|
613
|
+
tokenIn: tradingTokenAddress,
|
|
614
|
+
tokenOut: this.contractAddress,
|
|
615
|
+
amountIn: amountTradingTokenIn,
|
|
616
|
+
tokenInDecimals: tradingTokenDecimals,
|
|
617
|
+
tokenOutDecimals: bondkitTokenDecimals,
|
|
618
|
+
slippageTolerance,
|
|
619
|
+
recipient: this.walletClientInstance.account?.address || "0x0000000000000000000000000000000000000000",
|
|
620
|
+
});
|
|
621
|
+
return quote || undefined;
|
|
622
|
+
}
|
|
623
|
+
catch (error) {
|
|
624
|
+
console.warn("Error getting swap quote for bondkit token:", error);
|
|
625
|
+
return undefined;
|
|
626
|
+
}
|
|
627
|
+
}
|
|
628
|
+
/**
|
|
629
|
+
* Get swap quote for bondkit token → trading token
|
|
630
|
+
*/
|
|
631
|
+
async getSwapQuoteForTradingToken(amountBondkitTokenIn, slippageTolerance = 0.5) {
|
|
632
|
+
try {
|
|
633
|
+
// Check if swapping is available
|
|
634
|
+
const swapAvailable = await this.isSwapAvailable();
|
|
635
|
+
if (!swapAvailable) {
|
|
636
|
+
console.warn("DEX swapping not available - token must be in Dex phase");
|
|
637
|
+
return undefined;
|
|
638
|
+
}
|
|
639
|
+
const tradingTokenAddress = await this.getTradingTokenAddress();
|
|
640
|
+
if (!tradingTokenAddress) {
|
|
641
|
+
console.warn("Trading token address not available");
|
|
642
|
+
return undefined;
|
|
643
|
+
}
|
|
644
|
+
// Get token details for decimals
|
|
645
|
+
const [bondkitTokenDecimals, tradingTokenDecimals] = await Promise.all([
|
|
646
|
+
this.decimals(),
|
|
647
|
+
this.getTradingTokenDecimals(tradingTokenAddress),
|
|
648
|
+
]);
|
|
649
|
+
if (bondkitTokenDecimals === undefined || tradingTokenDecimals === undefined) {
|
|
650
|
+
console.warn("Unable to fetch token decimals");
|
|
651
|
+
return undefined;
|
|
652
|
+
}
|
|
653
|
+
const swapService = this.getSwapService();
|
|
654
|
+
const quote = await swapService.getSwapQuote({
|
|
655
|
+
tokenIn: this.contractAddress,
|
|
656
|
+
tokenOut: tradingTokenAddress,
|
|
657
|
+
amountIn: amountBondkitTokenIn,
|
|
658
|
+
tokenInDecimals: bondkitTokenDecimals,
|
|
659
|
+
tokenOutDecimals: tradingTokenDecimals,
|
|
660
|
+
slippageTolerance,
|
|
661
|
+
recipient: this.walletClientInstance.account?.address || "0x0000000000000000000000000000000000000000",
|
|
662
|
+
});
|
|
663
|
+
return quote || undefined;
|
|
664
|
+
}
|
|
665
|
+
catch (error) {
|
|
666
|
+
console.warn("Error getting swap quote for trading token:", error);
|
|
667
|
+
return undefined;
|
|
668
|
+
}
|
|
669
|
+
}
|
|
670
|
+
/**
|
|
671
|
+
* Swap trading token for bondkit token
|
|
672
|
+
*/
|
|
673
|
+
async swapTradingTokenForBondkitToken(amountTradingTokenIn, slippageTolerance = 0.5, options) {
|
|
674
|
+
try {
|
|
675
|
+
// Check if swapping is available
|
|
676
|
+
const swapAvailable = await this.isSwapAvailable();
|
|
677
|
+
if (!swapAvailable) {
|
|
678
|
+
console.warn("DEX swapping not available - token must be in Dex phase");
|
|
679
|
+
return undefined;
|
|
680
|
+
}
|
|
681
|
+
if (!this.walletClientInstance.account && !this.walletKey) {
|
|
682
|
+
console.warn("Wallet key not set or client not connected for swap operation");
|
|
683
|
+
return undefined;
|
|
684
|
+
}
|
|
685
|
+
const tradingTokenAddress = await this.getTradingTokenAddress();
|
|
686
|
+
if (!tradingTokenAddress) {
|
|
687
|
+
console.warn("Trading token address not available");
|
|
688
|
+
return undefined;
|
|
689
|
+
}
|
|
690
|
+
// Get token details for decimals
|
|
691
|
+
const [tradingTokenDecimals, bondkitTokenDecimals] = await Promise.all([
|
|
692
|
+
this.getTradingTokenDecimals(tradingTokenAddress),
|
|
693
|
+
this.decimals(),
|
|
694
|
+
]);
|
|
695
|
+
if (tradingTokenDecimals === undefined || bondkitTokenDecimals === undefined) {
|
|
696
|
+
console.warn("Unable to fetch token decimals");
|
|
697
|
+
return undefined;
|
|
698
|
+
}
|
|
699
|
+
const recipient = this.walletClientInstance.account?.address ||
|
|
700
|
+
(this.walletKey ? (0, accounts_1.privateKeyToAccount)(this.walletKey).address : undefined);
|
|
701
|
+
if (!recipient) {
|
|
702
|
+
console.warn("Unable to determine recipient address");
|
|
703
|
+
return undefined;
|
|
704
|
+
}
|
|
705
|
+
const swapService = this.getSwapService();
|
|
706
|
+
const txHash = await swapService.executeSwap({
|
|
707
|
+
tokenIn: tradingTokenAddress,
|
|
708
|
+
tokenOut: this.contractAddress,
|
|
709
|
+
amountIn: amountTradingTokenIn,
|
|
710
|
+
tokenInDecimals: tradingTokenDecimals,
|
|
711
|
+
tokenOutDecimals: bondkitTokenDecimals,
|
|
712
|
+
slippageTolerance,
|
|
713
|
+
recipient,
|
|
714
|
+
deadline: (options?.value ? Math.floor(Date.now() / 1000) : 0) + 3600,
|
|
715
|
+
}, this.walletClientInstance);
|
|
716
|
+
return txHash ? txHash : undefined;
|
|
717
|
+
}
|
|
718
|
+
catch (error) {
|
|
719
|
+
console.warn("Error swapping trading token for bondkit token:", error);
|
|
720
|
+
return undefined;
|
|
721
|
+
}
|
|
722
|
+
}
|
|
723
|
+
/**
|
|
724
|
+
* Swap bondkit token for trading token
|
|
725
|
+
*/
|
|
726
|
+
async swapBondkitTokenForTradingToken(amountBondkitTokenIn, slippageTolerance = 0.5, options) {
|
|
727
|
+
try {
|
|
728
|
+
// Check if swapping is available
|
|
729
|
+
const swapAvailable = await this.isSwapAvailable();
|
|
730
|
+
if (!swapAvailable) {
|
|
731
|
+
console.warn("DEX swapping not available - token must be in Dex phase");
|
|
732
|
+
return undefined;
|
|
733
|
+
}
|
|
734
|
+
if (!this.walletClientInstance.account && !this.walletKey) {
|
|
735
|
+
console.warn("Wallet key not set or client not connected for swap operation");
|
|
736
|
+
return undefined;
|
|
737
|
+
}
|
|
738
|
+
const tradingTokenAddress = await this.getTradingTokenAddress();
|
|
739
|
+
if (!tradingTokenAddress) {
|
|
740
|
+
console.warn("Trading token address not available");
|
|
741
|
+
return undefined;
|
|
742
|
+
}
|
|
743
|
+
// Get token details for decimals
|
|
744
|
+
const [bondkitTokenDecimals, tradingTokenDecimals] = await Promise.all([
|
|
745
|
+
this.decimals(),
|
|
746
|
+
this.getTradingTokenDecimals(tradingTokenAddress),
|
|
747
|
+
]);
|
|
748
|
+
if (bondkitTokenDecimals === undefined || tradingTokenDecimals === undefined) {
|
|
749
|
+
console.warn("Unable to fetch token decimals");
|
|
750
|
+
return undefined;
|
|
751
|
+
}
|
|
752
|
+
const recipient = this.walletClientInstance.account?.address ||
|
|
753
|
+
(this.walletKey ? (0, accounts_1.privateKeyToAccount)(this.walletKey).address : undefined);
|
|
754
|
+
if (!recipient) {
|
|
755
|
+
console.warn("Unable to determine recipient address");
|
|
756
|
+
return undefined;
|
|
757
|
+
}
|
|
758
|
+
const swapService = this.getSwapService();
|
|
759
|
+
const txHash = await swapService.executeSwap({
|
|
760
|
+
tokenIn: this.contractAddress,
|
|
761
|
+
tokenOut: tradingTokenAddress,
|
|
762
|
+
amountIn: amountBondkitTokenIn,
|
|
763
|
+
tokenInDecimals: bondkitTokenDecimals,
|
|
764
|
+
tokenOutDecimals: tradingTokenDecimals,
|
|
765
|
+
slippageTolerance,
|
|
766
|
+
recipient,
|
|
767
|
+
deadline: (options?.value ? Math.floor(Date.now() / 1000) : 0) + 3600,
|
|
768
|
+
}, this.walletClientInstance);
|
|
769
|
+
return txHash ? txHash : undefined;
|
|
770
|
+
}
|
|
771
|
+
catch (error) {
|
|
772
|
+
console.warn("Error swapping bondkit token for trading token:", error);
|
|
773
|
+
return undefined;
|
|
774
|
+
}
|
|
775
|
+
}
|
|
776
|
+
/**
|
|
777
|
+
* Helper method to get trading token decimals
|
|
778
|
+
*/
|
|
779
|
+
async getTradingTokenDecimals(tradingTokenAddress) {
|
|
780
|
+
try {
|
|
781
|
+
// ETH has 18 decimals
|
|
782
|
+
if (tradingTokenAddress === "0x0000000000000000000000000000000000000000") {
|
|
783
|
+
return 18;
|
|
784
|
+
}
|
|
785
|
+
// For ERC20 tokens, read decimals from contract
|
|
786
|
+
const tradingTokenContract = (0, viem_1.getContract)({
|
|
787
|
+
address: tradingTokenAddress,
|
|
788
|
+
abi: viem_1.erc20Abi,
|
|
789
|
+
client: this.publicClient,
|
|
790
|
+
});
|
|
791
|
+
const decimals = await tradingTokenContract.read.decimals();
|
|
792
|
+
return Number(decimals);
|
|
793
|
+
}
|
|
794
|
+
catch (error) {
|
|
795
|
+
console.warn("Error fetching trading token decimals:", error);
|
|
796
|
+
return undefined;
|
|
797
|
+
}
|
|
798
|
+
}
|
|
799
|
+
/**
|
|
800
|
+
* Get trading token symbol
|
|
801
|
+
* @param tradingTokenAddress Optional trading token address to avoid fetching it again
|
|
802
|
+
*/
|
|
803
|
+
async getTradingTokenSymbol(tradingTokenAddress) {
|
|
804
|
+
try {
|
|
805
|
+
const tokenAddress = tradingTokenAddress || (await this.getTradingTokenAddress());
|
|
806
|
+
if (!tokenAddress) {
|
|
807
|
+
return undefined;
|
|
808
|
+
}
|
|
809
|
+
// ETH symbol
|
|
810
|
+
if (tokenAddress === "0x0000000000000000000000000000000000000000") {
|
|
811
|
+
return "ETH";
|
|
812
|
+
}
|
|
813
|
+
// For ERC20 tokens, read symbol from contract
|
|
814
|
+
const tradingTokenContract = (0, viem_1.getContract)({
|
|
815
|
+
address: tokenAddress,
|
|
816
|
+
abi: viem_1.erc20Abi,
|
|
817
|
+
client: this.publicClient,
|
|
818
|
+
});
|
|
819
|
+
const symbol = await tradingTokenContract.read.symbol();
|
|
820
|
+
return symbol;
|
|
821
|
+
}
|
|
822
|
+
catch (error) {
|
|
823
|
+
console.warn("Error fetching trading token symbol:", error);
|
|
824
|
+
return undefined;
|
|
825
|
+
}
|
|
826
|
+
}
|
|
561
827
|
}
|
|
562
828
|
exports.BondkitToken = BondkitToken;
|
|
@@ -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.
|
|
@@ -8,14 +8,14 @@ const config_1 = require("./config");
|
|
|
8
8
|
// Define the event ABI snippet for BondkitTokenCreated specifically for decoding
|
|
9
9
|
const bondkitTokenCreatedEventAbi = abis_1.BondkitTokenFactoryABI.find(item => item.type === "event" && item.name === "BondkitTokenCreated");
|
|
10
10
|
class BondkitTokenFactory {
|
|
11
|
-
constructor(chainId, walletKey) {
|
|
11
|
+
constructor(chainId, walletKey, rpcUrl) {
|
|
12
12
|
if (walletKey && !walletKey.startsWith("0x")) {
|
|
13
13
|
this.walletKey = `0x${walletKey}`;
|
|
14
14
|
}
|
|
15
15
|
else if (walletKey) {
|
|
16
16
|
this.walletKey = walletKey;
|
|
17
17
|
}
|
|
18
|
-
const config = (0, config_1.getConfig)(chainId);
|
|
18
|
+
const config = (0, config_1.getConfig)(chainId, rpcUrl);
|
|
19
19
|
this.chain = config.chain;
|
|
20
20
|
this.contractAddress = config.factoryAddress;
|
|
21
21
|
this.rpcUrl = config.rpcUrl;
|