@b3dotfun/sdk 0.0.8-alpha.0 → 0.0.8-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/anyspend/abis/bondKit.d.ts +35 -0
- package/dist/cjs/anyspend/abis/bondKit.js +29 -0
- package/dist/cjs/anyspend/index.d.ts +3 -3
- package/dist/cjs/anyspend/index.js +3 -3
- package/dist/cjs/anyspend/index.native.d.ts +2 -2
- package/dist/cjs/anyspend/index.native.js +2 -2
- package/dist/cjs/anyspend/react/components/AnySpendBondKit.d.ts +2 -0
- package/dist/cjs/anyspend/react/components/AnySpendBondKit.js +204 -0
- package/dist/cjs/anyspend/react/components/AnySpendBuySpin.js +0 -4
- package/dist/cjs/anyspend/react/components/AnySpendCustom.js +2 -2
- package/dist/cjs/anyspend/react/components/AnyspendSignatureMint.d.ts +1 -1
- package/dist/cjs/anyspend/react/components/AnyspendSignatureMint.js +8 -4
- package/dist/cjs/anyspend/react/components/{AnySpendNFTButton.d.ts → common/AnySpendNFTButton.d.ts} +1 -1
- package/dist/cjs/anyspend/react/components/{AnySpendNFTButton.js → common/AnySpendNFTButton.js} +2 -2
- package/dist/cjs/anyspend/react/components/index.d.ts +2 -1
- package/dist/cjs/anyspend/react/components/index.js +5 -3
- package/dist/cjs/anyspend/react/hooks/useAnyspendOrderAndTransactions.js +21 -6
- package/dist/cjs/anyspend/react/hooks/useSigMint.d.ts +1 -1
- package/dist/cjs/anyspend/types/bondKit.d.ts +12 -0
- package/dist/cjs/anyspend/types/signatureMint.js +2 -0
- package/dist/cjs/global-account/react/components/B3DynamicModal.js +4 -0
- package/dist/cjs/global-account/react/components/SignInWithB3/SignIn.js +1 -1
- package/dist/cjs/global-account/react/components/ui/TabSystem.d.ts +2 -2
- package/dist/cjs/global-account/react/components/ui/TabSystem.js +5 -5
- package/dist/cjs/global-account/react/stores/useModalStore.d.ts +24 -2
- package/dist/esm/anyspend/abis/bondKit.d.ts +35 -0
- package/dist/esm/anyspend/abis/bondKit.js +26 -0
- package/dist/esm/anyspend/index.d.ts +3 -3
- package/dist/esm/anyspend/index.js +3 -3
- package/dist/esm/anyspend/index.native.d.ts +2 -2
- package/dist/esm/anyspend/index.native.js +2 -2
- package/dist/esm/anyspend/react/components/AnySpendBondKit.d.ts +2 -0
- package/dist/esm/anyspend/react/components/AnySpendBondKit.js +201 -0
- package/dist/esm/anyspend/react/components/AnySpendBuySpin.js +0 -4
- package/dist/esm/anyspend/react/components/AnySpendCustom.js +2 -2
- package/dist/esm/anyspend/react/components/AnyspendSignatureMint.d.ts +1 -1
- package/dist/esm/anyspend/react/components/AnyspendSignatureMint.js +7 -3
- package/dist/esm/anyspend/react/components/{AnySpendNFTButton.d.ts → common/AnySpendNFTButton.d.ts} +1 -1
- package/dist/esm/anyspend/react/components/{AnySpendNFTButton.js → common/AnySpendNFTButton.js} +2 -2
- package/dist/esm/anyspend/react/components/index.d.ts +2 -1
- package/dist/esm/anyspend/react/components/index.js +2 -1
- package/dist/esm/anyspend/react/hooks/useAnyspendOrderAndTransactions.js +21 -3
- package/dist/esm/anyspend/react/hooks/useSigMint.d.ts +1 -1
- package/dist/esm/anyspend/types/bondKit.d.ts +12 -0
- package/dist/esm/anyspend/types/signatureMint.js +1 -0
- package/dist/esm/global-account/react/components/B3DynamicModal.js +5 -1
- package/dist/esm/global-account/react/components/SignInWithB3/SignIn.js +1 -1
- package/dist/esm/global-account/react/components/ui/TabSystem.d.ts +2 -2
- package/dist/esm/global-account/react/components/ui/TabSystem.js +4 -4
- package/dist/esm/global-account/react/stores/useModalStore.d.ts +24 -2
- package/dist/styles/index.css +1 -1
- package/dist/types/anyspend/abis/bondKit.d.ts +35 -0
- package/dist/types/anyspend/index.d.ts +3 -3
- package/dist/types/anyspend/index.native.d.ts +2 -2
- package/dist/types/anyspend/react/components/AnySpendBondKit.d.ts +2 -0
- package/dist/types/anyspend/react/components/AnyspendSignatureMint.d.ts +1 -1
- package/dist/types/anyspend/react/components/index.d.ts +2 -1
- package/dist/types/anyspend/react/hooks/useSigMint.d.ts +1 -1
- package/dist/types/anyspend/types/bondKit.d.ts +12 -0
- package/dist/types/global-account/react/components/ui/TabSystem.d.ts +2 -2
- package/dist/types/global-account/react/stores/useModalStore.d.ts +24 -2
- package/package.json +2 -1
- package/src/anyspend/abis/bondKit.ts +26 -0
- package/src/anyspend/index.native.ts +2 -2
- package/src/anyspend/index.ts +3 -3
- package/src/anyspend/react/components/AnySpendBondKit.tsx +372 -0
- package/src/anyspend/react/components/AnySpendBuySpin.tsx +0 -5
- package/src/anyspend/react/components/AnySpendCustom.tsx +4 -2
- package/src/anyspend/react/components/AnyspendSignatureMint.tsx +19 -7
- package/src/anyspend/react/components/index.ts +2 -1
- package/src/anyspend/react/hooks/useAnyspendOrderAndTransactions.ts +26 -4
- package/src/anyspend/react/hooks/useSigMint.tsx +1 -1
- package/src/anyspend/types/bondKit.ts +12 -0
- package/src/global-account/react/components/B3DynamicModal.tsx +6 -1
- package/src/global-account/react/components/SignInWithB3/SignIn.tsx +1 -1
- package/src/global-account/react/components/ui/TabSystem.tsx +36 -33
- package/src/global-account/react/stores/useModalStore.ts +26 -2
- /package/dist/cjs/anyspend/abis/{abi-usdc-base.d.ts → abiUsdcBase.d.ts} +0 -0
- /package/dist/cjs/anyspend/abis/{abi-usdc-base.js → abiUsdcBase.js} +0 -0
- /package/dist/cjs/anyspend/abis/{erc20-staking.d.ts → erc20Staking.d.ts} +0 -0
- /package/dist/cjs/anyspend/abis/{erc20-staking.js → erc20Staking.js} +0 -0
- /package/dist/cjs/anyspend/abis/{signature-minting.d.ts → signatureMinting.d.ts} +0 -0
- /package/dist/cjs/anyspend/abis/{signature-minting.js → signatureMinting.js} +0 -0
- /package/dist/cjs/anyspend/types/{signature-mint.js → bondKit.js} +0 -0
- /package/dist/cjs/anyspend/types/{signature-mint.d.ts → signatureMint.d.ts} +0 -0
- /package/dist/esm/anyspend/abis/{abi-usdc-base.d.ts → abiUsdcBase.d.ts} +0 -0
- /package/dist/esm/anyspend/abis/{abi-usdc-base.js → abiUsdcBase.js} +0 -0
- /package/dist/esm/anyspend/abis/{erc20-staking.d.ts → erc20Staking.d.ts} +0 -0
- /package/dist/esm/anyspend/abis/{erc20-staking.js → erc20Staking.js} +0 -0
- /package/dist/esm/anyspend/abis/{signature-minting.d.ts → signatureMinting.d.ts} +0 -0
- /package/dist/esm/anyspend/abis/{signature-minting.js → signatureMinting.js} +0 -0
- /package/dist/esm/anyspend/types/{signature-mint.js → bondKit.js} +0 -0
- /package/dist/esm/anyspend/types/{signature-mint.d.ts → signatureMint.d.ts} +0 -0
- /package/dist/types/anyspend/abis/{abi-usdc-base.d.ts → abiUsdcBase.d.ts} +0 -0
- /package/dist/types/anyspend/abis/{erc20-staking.d.ts → erc20Staking.d.ts} +0 -0
- /package/dist/types/anyspend/abis/{signature-minting.d.ts → signatureMinting.d.ts} +0 -0
- /package/dist/types/anyspend/react/components/{AnySpendNFTButton.d.ts → common/AnySpendNFTButton.d.ts} +0 -0
- /package/dist/types/anyspend/types/{signature-mint.d.ts → signatureMint.d.ts} +0 -0
- /package/src/anyspend/abis/{abi-usdc-base.ts → abiUsdcBase.ts} +0 -0
- /package/src/anyspend/abis/{erc20-staking.ts → erc20Staking.ts} +0 -0
- /package/src/anyspend/abis/{signature-minting.ts → signatureMinting.ts} +0 -0
- /package/src/anyspend/react/components/{AnySpendNFTButton.tsx → common/AnySpendNFTButton.tsx} +0 -0
- /package/src/anyspend/types/{signature-mint.ts → signatureMint.ts} +0 -0
|
@@ -34,14 +34,14 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
34
34
|
};
|
|
35
35
|
})();
|
|
36
36
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
37
|
+
exports.TabTrigger = void 0;
|
|
37
38
|
exports.Tabs = Tabs;
|
|
38
39
|
exports.TabsList = TabsList;
|
|
39
|
-
exports.TabTrigger = TabTrigger;
|
|
40
40
|
exports.TabsContent = TabsContent;
|
|
41
41
|
exports.TabsTransitionWrapper = TabsTransitionWrapper;
|
|
42
42
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
43
|
-
const cn_1 = require("../../../../shared/utils/cn");
|
|
44
43
|
const react_1 = require("../../../../global-account/react");
|
|
44
|
+
const cn_1 = require("../../../../shared/utils/cn");
|
|
45
45
|
const framer_motion_1 = require("framer-motion");
|
|
46
46
|
const react_2 = __importStar(require("react"));
|
|
47
47
|
const TabsContext = (0, react_2.createContext)(undefined);
|
|
@@ -51,14 +51,14 @@ function Tabs({ value, onValueChange, children, className = "" }) {
|
|
|
51
51
|
function TabsList({ children, className = "", hideGradient = false }) {
|
|
52
52
|
return ((0, jsx_runtime_1.jsxs)("div", { className: "relative w-full", children: [(0, jsx_runtime_1.jsx)("div", { role: "tablist", className: (0, cn_1.cn)("no-scrollbar relative mb-4 flex items-center gap-2 whitespace-nowrap", className), children: children }), (0, jsx_runtime_1.jsx)(framer_motion_1.AnimatePresence, { mode: "wait", children: !hideGradient && ((0, jsx_runtime_1.jsxs)(framer_motion_1.motion.div, { initial: { opacity: 0 }, animate: { opacity: 1 }, exit: { opacity: 0 }, transition: { duration: 0.2, delay: 0.2 }, children: [(0, jsx_runtime_1.jsx)("div", { className: "pointer-events-none absolute bottom-0 left-0 top-0 z-10 w-8 bg-gradient-to-r from-[#15121c] to-transparent md:hidden" }), (0, jsx_runtime_1.jsx)("div", { className: "pointer-events-none absolute bottom-0 right-0 top-0 z-10 w-8 bg-gradient-to-l from-[#15121c] to-transparent md:hidden" })] }, "gradients-container")) })] }));
|
|
53
53
|
}
|
|
54
|
-
|
|
54
|
+
exports.TabTrigger = react_2.default.forwardRef(({ value, children, icon, disabled = false }, ref) => {
|
|
55
55
|
const context = (0, react_2.useContext)(TabsContext);
|
|
56
56
|
if (!context)
|
|
57
57
|
throw new Error("TabTrigger must be used within Tabs");
|
|
58
58
|
const { selectedTab, onTabChange } = context;
|
|
59
59
|
const isSelected = selectedTab === value;
|
|
60
|
-
return ((0, jsx_runtime_1.jsxs)("button", { role: "tab", "aria-selected": isSelected, "aria-controls": `panel-${value}`, id: `tab-${value}`, onClick: () => onTabChange(value), className: `relative rounded-full px-4 py-2 text-sm text-white transition-all duration-200 hover:text-white focus:outline-none`, disabled: disabled, children: [(0, jsx_runtime_1.jsxs)("span", { className: `${isSelected ? "opacity-100" : "opacity-50"} relative z-10 flex items-center gap-2 font-semibold uppercase`, children: [children, icon] }), isSelected && ((0, jsx_runtime_1.jsx)(framer_motion_1.motion.span, { layoutId: "activeTab", transition: { type: "spring", duration: 0.4 }, className: "from-as-light-brand to-as-brand/10 border-as-brand/30 absolute inset-0 z-0 rounded-full border border-t-white/15 bg-gradient-to-b shadow-lg" }))] }));
|
|
61
|
-
}
|
|
60
|
+
return ((0, jsx_runtime_1.jsxs)("button", { ref: ref, role: "tab", "aria-selected": isSelected, "aria-controls": `panel-${value}`, id: `tab-${value}`, onClick: () => onTabChange(value), className: `relative rounded-full px-4 py-2 text-sm text-white transition-all duration-200 hover:text-white focus:outline-none`, disabled: disabled, children: [(0, jsx_runtime_1.jsxs)("span", { className: `${isSelected ? "opacity-100" : "opacity-50"} relative z-10 flex items-center gap-2 font-semibold uppercase`, children: [children, icon] }), isSelected && ((0, jsx_runtime_1.jsx)(framer_motion_1.motion.span, { layoutId: "activeTab", transition: { type: "spring", duration: 0.4 }, className: "from-as-light-brand to-as-brand/10 border-as-brand/30 absolute inset-0 z-0 rounded-full border border-t-white/15 bg-gradient-to-b shadow-lg" }))] }));
|
|
61
|
+
});
|
|
62
62
|
function TabsContent({ value, children }) {
|
|
63
63
|
const context = (0, react_2.useContext)(TabsContext);
|
|
64
64
|
if (!context)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Token, Tournament } from "../../../anyspend";
|
|
2
2
|
import { NftContract } from "../../../anyspend/types";
|
|
3
|
-
import { GenerateSigMintResponse } from "../../../anyspend/types/
|
|
3
|
+
import { GenerateSigMintResponse } from "../../../anyspend/types/signatureMint";
|
|
4
4
|
import { AllowedStrategy } from "../../../global-account/react";
|
|
5
5
|
import { PermissionsConfig } from "../../../global-account/types/permissions";
|
|
6
6
|
import { Address, Chain } from "thirdweb";
|
|
@@ -251,10 +251,32 @@ export interface AnySpendSignatureMintProps extends BaseModalProps {
|
|
|
251
251
|
/** Callback function called when minting is successful */
|
|
252
252
|
onSuccess?: (txHash?: string) => void;
|
|
253
253
|
}
|
|
254
|
+
/**
|
|
255
|
+
* Props for the AnySpend bondKit modal
|
|
256
|
+
* Handles bondKit token purchases
|
|
257
|
+
*/
|
|
258
|
+
export interface AnySpendBondKitProps extends BaseModalProps {
|
|
259
|
+
/** Mode of the modal */
|
|
260
|
+
mode?: "modal" | "page";
|
|
261
|
+
/** Modal type identifier */
|
|
262
|
+
type: "anySpendBondKit";
|
|
263
|
+
/** Recipient address to receive the tokens */
|
|
264
|
+
recipientAddress: string;
|
|
265
|
+
/** bondKit contract address */
|
|
266
|
+
contractAddress: string;
|
|
267
|
+
/** Minimum tokens to receive */
|
|
268
|
+
minTokensOut?: string;
|
|
269
|
+
/** Optional image URL for token preview */
|
|
270
|
+
imageUrl?: string;
|
|
271
|
+
/** Token name to display */
|
|
272
|
+
tokenName?: string;
|
|
273
|
+
/** Callback function called when purchase is successful */
|
|
274
|
+
onSuccess?: (txHash?: string) => void;
|
|
275
|
+
}
|
|
254
276
|
/**
|
|
255
277
|
* Union type of all possible modal content types
|
|
256
278
|
*/
|
|
257
|
-
export type ModalContentType = SignInWithB3ModalProps | RequestPermissionsModalProps | ManageAccountModalProps | AnySpendModalProps | AnyspendOrderDetailsProps | AnySpendNftProps | AnySpendJoinTournamentProps | AnySpendFundTournamentProps | TransakProps | AnySpendOrderHistoryProps | AnySpendStakeB3Props | AnySpendBuySpinProps | AnySpendSignatureMintProps;
|
|
279
|
+
export type ModalContentType = SignInWithB3ModalProps | RequestPermissionsModalProps | ManageAccountModalProps | AnySpendModalProps | AnyspendOrderDetailsProps | AnySpendNftProps | AnySpendJoinTournamentProps | AnySpendFundTournamentProps | TransakProps | AnySpendOrderHistoryProps | AnySpendStakeB3Props | AnySpendBuySpinProps | AnySpendSignatureMintProps | AnySpendBondKitProps;
|
|
258
280
|
/**
|
|
259
281
|
* State interface for the modal store
|
|
260
282
|
*/
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
export declare const ABI_bondKit: readonly [{
|
|
2
|
+
readonly inputs: readonly [{
|
|
3
|
+
readonly internalType: "address";
|
|
4
|
+
readonly name: "_recipient";
|
|
5
|
+
readonly type: "address";
|
|
6
|
+
}, {
|
|
7
|
+
readonly internalType: "uint256";
|
|
8
|
+
readonly name: "_minTokensOut";
|
|
9
|
+
readonly type: "uint256";
|
|
10
|
+
}];
|
|
11
|
+
readonly name: "buyFor";
|
|
12
|
+
readonly outputs: readonly [];
|
|
13
|
+
readonly stateMutability: "payable";
|
|
14
|
+
readonly type: "function";
|
|
15
|
+
}, {
|
|
16
|
+
readonly inputs: readonly [];
|
|
17
|
+
readonly name: "name";
|
|
18
|
+
readonly outputs: readonly [{
|
|
19
|
+
readonly internalType: "string";
|
|
20
|
+
readonly name: "";
|
|
21
|
+
readonly type: "string";
|
|
22
|
+
}];
|
|
23
|
+
readonly stateMutability: "view";
|
|
24
|
+
readonly type: "function";
|
|
25
|
+
}, {
|
|
26
|
+
readonly inputs: readonly [];
|
|
27
|
+
readonly name: "symbol";
|
|
28
|
+
readonly outputs: readonly [{
|
|
29
|
+
readonly internalType: "string";
|
|
30
|
+
readonly name: "";
|
|
31
|
+
readonly type: "string";
|
|
32
|
+
}];
|
|
33
|
+
readonly stateMutability: "view";
|
|
34
|
+
readonly type: "function";
|
|
35
|
+
}];
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export const ABI_bondKit = [
|
|
2
|
+
{
|
|
3
|
+
inputs: [
|
|
4
|
+
{ internalType: "address", name: "_recipient", type: "address" },
|
|
5
|
+
{ internalType: "uint256", name: "_minTokensOut", type: "uint256" },
|
|
6
|
+
],
|
|
7
|
+
name: "buyFor",
|
|
8
|
+
outputs: [],
|
|
9
|
+
stateMutability: "payable",
|
|
10
|
+
type: "function",
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
inputs: [],
|
|
14
|
+
name: "name",
|
|
15
|
+
outputs: [{ internalType: "string", name: "", type: "string" }],
|
|
16
|
+
stateMutability: "view",
|
|
17
|
+
type: "function",
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
inputs: [],
|
|
21
|
+
name: "symbol",
|
|
22
|
+
outputs: [{ internalType: "string", name: "", type: "string" }],
|
|
23
|
+
stateMutability: "view",
|
|
24
|
+
type: "function",
|
|
25
|
+
},
|
|
26
|
+
];
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export * from "./types";
|
|
2
2
|
export * from "./types/metadata";
|
|
3
3
|
export * from "./types/relay";
|
|
4
|
-
export * from "./types/
|
|
4
|
+
export * from "./types/signatureMint";
|
|
5
5
|
export * from "./types/token";
|
|
6
6
|
export * from "./utils/address";
|
|
7
7
|
export * from "./utils/chain";
|
|
@@ -11,5 +11,5 @@ export * from "./utils/number";
|
|
|
11
11
|
export * from "./utils/string";
|
|
12
12
|
export * from "./utils/token";
|
|
13
13
|
export * from "./constants";
|
|
14
|
-
export * from "./abis/
|
|
15
|
-
export * from "./abis/
|
|
14
|
+
export * from "./abis/abiUsdcBase";
|
|
15
|
+
export * from "./abis/erc20Staking";
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
export * from "./types/index.js";
|
|
3
3
|
export * from "./types/metadata.js";
|
|
4
4
|
export * from "./types/relay.js";
|
|
5
|
-
export * from "./types/
|
|
5
|
+
export * from "./types/signatureMint.js";
|
|
6
6
|
export * from "./types/token.js";
|
|
7
7
|
// Utils
|
|
8
8
|
export * from "./utils/address.js";
|
|
@@ -15,5 +15,5 @@ export * from "./utils/token.js";
|
|
|
15
15
|
// Constants
|
|
16
16
|
export * from "./constants/index.js";
|
|
17
17
|
// Abis
|
|
18
|
-
export * from "./abis/
|
|
19
|
-
export * from "./abis/
|
|
18
|
+
export * from "./abis/abiUsdcBase.js";
|
|
19
|
+
export * from "./abis/erc20Staking.js";
|
|
@@ -9,5 +9,5 @@ export * from "./utils/number";
|
|
|
9
9
|
export * from "./utils/string";
|
|
10
10
|
export * from "./utils/token";
|
|
11
11
|
export * from "./constants";
|
|
12
|
-
export * from "./abis/
|
|
13
|
-
export * from "./abis/
|
|
12
|
+
export * from "./abis/abiUsdcBase";
|
|
13
|
+
export * from "./abis/erc20Staking";
|
|
@@ -15,5 +15,5 @@ export * from "./utils/token.js";
|
|
|
15
15
|
// Constants
|
|
16
16
|
export * from "./constants/index.js";
|
|
17
17
|
// Abis
|
|
18
|
-
export * from "./abis/
|
|
19
|
-
export * from "./abis/
|
|
18
|
+
export * from "./abis/abiUsdcBase.js";
|
|
19
|
+
export * from "./abis/erc20Staking.js";
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { BondkitToken } from "@b3dotfun/bondkit";
|
|
3
|
+
import { OrderType } from "../../../anyspend/index.js";
|
|
4
|
+
import { Button, GlareCardRounded, Input, StyleRoot, useHasMounted, useTokenData, } from "../../../global-account/react/index.js";
|
|
5
|
+
import { baseMainnet } from "../../../shared/constants/chains/supported.js";
|
|
6
|
+
import { motion } from "framer-motion";
|
|
7
|
+
import { useEffect, useMemo, useState } from "react";
|
|
8
|
+
import { createPublicClient, encodeFunctionData, formatEther, http, parseEther } from "viem";
|
|
9
|
+
import { ABI_bondKit } from "../../abis/bondKit.js";
|
|
10
|
+
import { AnySpendCustom } from "./AnySpendCustom.js";
|
|
11
|
+
// Debounce utility function
|
|
12
|
+
function debounce(func, wait) {
|
|
13
|
+
let timeout;
|
|
14
|
+
return (...args) => {
|
|
15
|
+
clearTimeout(timeout);
|
|
16
|
+
timeout = setTimeout(() => func(...args), wait);
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
// Format number with commas
|
|
20
|
+
function formatNumberWithCommas(x) {
|
|
21
|
+
const parts = x.split(".");
|
|
22
|
+
parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, ",");
|
|
23
|
+
return parts.join(".");
|
|
24
|
+
}
|
|
25
|
+
export function AnySpendBondKit({ mode = "modal", recipientAddress, contractAddress, minTokensOut = "0", imageUrl, onSuccess, }) {
|
|
26
|
+
const hasMounted = useHasMounted();
|
|
27
|
+
const [showAmountPrompt, setShowAmountPrompt] = useState(true);
|
|
28
|
+
const [ethAmount, setEthAmount] = useState("");
|
|
29
|
+
const [isAmountValid, setIsAmountValid] = useState(false);
|
|
30
|
+
const [validationError, setValidationError] = useState("");
|
|
31
|
+
const [tokenName, setTokenName] = useState("");
|
|
32
|
+
const [tokenSymbol, setTokenSymbol] = useState("");
|
|
33
|
+
const [quote, setQuote] = useState(null);
|
|
34
|
+
const [isLoadingQuote, setIsLoadingQuote] = useState(false);
|
|
35
|
+
// Create BondKit client
|
|
36
|
+
const bondkitTokenClient = useMemo(() => {
|
|
37
|
+
if (!contractAddress)
|
|
38
|
+
return null;
|
|
39
|
+
try {
|
|
40
|
+
const client = new BondkitToken(contractAddress);
|
|
41
|
+
client.connect();
|
|
42
|
+
return client;
|
|
43
|
+
}
|
|
44
|
+
catch (error) {
|
|
45
|
+
console.error("Error creating bondkit client", error);
|
|
46
|
+
return null;
|
|
47
|
+
}
|
|
48
|
+
}, [contractAddress]);
|
|
49
|
+
// Create a public client for reading contract data
|
|
50
|
+
const basePublicClient = createPublicClient({
|
|
51
|
+
chain: baseMainnet,
|
|
52
|
+
transport: http(),
|
|
53
|
+
});
|
|
54
|
+
// Fetch token name from contract
|
|
55
|
+
useEffect(() => {
|
|
56
|
+
async function fetchTokenName() {
|
|
57
|
+
try {
|
|
58
|
+
const [name, symbol] = await Promise.all([
|
|
59
|
+
basePublicClient.readContract({
|
|
60
|
+
address: contractAddress,
|
|
61
|
+
abi: ABI_bondKit,
|
|
62
|
+
functionName: "name",
|
|
63
|
+
}),
|
|
64
|
+
basePublicClient.readContract({
|
|
65
|
+
address: contractAddress,
|
|
66
|
+
abi: ABI_bondKit,
|
|
67
|
+
functionName: "symbol",
|
|
68
|
+
}),
|
|
69
|
+
]);
|
|
70
|
+
setTokenName(name);
|
|
71
|
+
setTokenSymbol(symbol);
|
|
72
|
+
}
|
|
73
|
+
catch (error) {
|
|
74
|
+
console.error("Error fetching token name:", error);
|
|
75
|
+
setTokenName("BondKit Token");
|
|
76
|
+
setTokenSymbol("BOND");
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
if (contractAddress) {
|
|
80
|
+
fetchTokenName();
|
|
81
|
+
}
|
|
82
|
+
}, [contractAddress, basePublicClient]);
|
|
83
|
+
// Get native token data for the chain
|
|
84
|
+
const { data: tokenData, isError: isTokenError, isLoading, } = useTokenData(baseMainnet.id, "0x0000000000000000000000000000000000000000");
|
|
85
|
+
// Convert token data to AnySpend Token type
|
|
86
|
+
const dstToken = useMemo(() => {
|
|
87
|
+
if (!tokenData)
|
|
88
|
+
return null;
|
|
89
|
+
return {
|
|
90
|
+
address: tokenData.address,
|
|
91
|
+
chainId: baseMainnet.id,
|
|
92
|
+
name: tokenData.name,
|
|
93
|
+
symbol: tokenData.symbol,
|
|
94
|
+
decimals: tokenData.decimals,
|
|
95
|
+
metadata: {
|
|
96
|
+
logoURI: tokenData.logoURI,
|
|
97
|
+
},
|
|
98
|
+
};
|
|
99
|
+
}, [tokenData]);
|
|
100
|
+
// Debounced quote fetching
|
|
101
|
+
const debouncedGetQuote = useMemo(() => debounce(async (val) => {
|
|
102
|
+
if (!val || Number(val) <= 0 || !bondkitTokenClient) {
|
|
103
|
+
setQuote(null);
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
try {
|
|
107
|
+
setIsLoadingQuote(true);
|
|
108
|
+
const parsedAmount = parseEther(val);
|
|
109
|
+
const buyQuote = await bondkitTokenClient.getAmountOfTokensToBuy(parsedAmount);
|
|
110
|
+
setQuote(buyQuote ? formatEther(buyQuote) : null);
|
|
111
|
+
}
|
|
112
|
+
catch (error) {
|
|
113
|
+
console.error("Error getting buy quote:", error);
|
|
114
|
+
setQuote(null);
|
|
115
|
+
}
|
|
116
|
+
finally {
|
|
117
|
+
setIsLoadingQuote(false);
|
|
118
|
+
}
|
|
119
|
+
}, 500), [bondkitTokenClient]);
|
|
120
|
+
const validateAndSetAmount = (value) => {
|
|
121
|
+
// Allow empty input
|
|
122
|
+
if (value === "") {
|
|
123
|
+
setEthAmount("");
|
|
124
|
+
setIsAmountValid(false);
|
|
125
|
+
setValidationError("");
|
|
126
|
+
setQuote(null);
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
// Only allow valid number format (no leading zeros unless decimal)
|
|
130
|
+
if (!/^(0|[1-9]\d*)?\.?\d*$/.test(value)) {
|
|
131
|
+
setIsAmountValid(false);
|
|
132
|
+
setValidationError("Please enter a valid number");
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
// Prevent multiple decimal points
|
|
136
|
+
if ((value.match(/\./g) || []).length > 1) {
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
// Prevent more than 18 decimal places (ETH precision)
|
|
140
|
+
const parts = value.split(".");
|
|
141
|
+
if (parts[1] && parts[1].length > 18) {
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
// Clean the input - remove leading zeros if not decimal
|
|
145
|
+
const cleanedValue = value.startsWith("0") && !value.startsWith("0.") ? value.replace(/^0+/, "0") : value;
|
|
146
|
+
setEthAmount(cleanedValue);
|
|
147
|
+
try {
|
|
148
|
+
const parsedAmount = parseEther(cleanedValue);
|
|
149
|
+
if (parsedAmount <= BigInt(0)) {
|
|
150
|
+
setIsAmountValid(false);
|
|
151
|
+
setValidationError("Amount must be greater than 0");
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
setIsAmountValid(true);
|
|
155
|
+
setValidationError("");
|
|
156
|
+
debouncedGetQuote(cleanedValue);
|
|
157
|
+
}
|
|
158
|
+
catch (error) {
|
|
159
|
+
console.error("Error validating amount:", error);
|
|
160
|
+
setIsAmountValid(false);
|
|
161
|
+
setValidationError("Please enter a valid amount");
|
|
162
|
+
}
|
|
163
|
+
};
|
|
164
|
+
const header = () => (_jsx("div", { className: "w-full px-6 py-4", children: _jsxs("div", { className: "flex w-full flex-col items-center space-y-6", children: [_jsxs("h2", { className: "text-[28px] font-bold", children: ["Buy ", tokenName, " (", tokenSymbol, ")"] }), _jsxs("div", { className: "flex w-full flex-col items-center space-y-2", children: [_jsxs("span", { className: "text-[28px] font-bold", children: [ethAmount, " ETH"] }), quote && (_jsxs("span", { className: "text-lg", children: ["\u2248 ", formatNumberWithCommas(parseFloat(quote).toFixed(4)), " ", tokenSymbol] }))] })] }) }));
|
|
165
|
+
// Show loading state while fetching token data
|
|
166
|
+
if (isLoading) {
|
|
167
|
+
return (_jsx(StyleRoot, { children: _jsx("div", { className: "b3-root b3-modal bg-b3-react-background flex w-full flex-col items-center p-8", children: _jsx("p", { className: "text-as-primary/70 text-center text-sm", children: "Loading payment information..." }) }) }));
|
|
168
|
+
}
|
|
169
|
+
// If we don't have token data after loading, show error state
|
|
170
|
+
if (!dstToken || isTokenError) {
|
|
171
|
+
return (_jsx(StyleRoot, { children: _jsx("div", { className: "b3-root b3-modal bg-b3-react-background flex w-full flex-col items-center p-8", children: _jsxs("p", { className: "text-as-red text-center text-sm", children: ["Failed to fetch native token information for chain ", baseMainnet.id, ". Please try again."] }) }) }));
|
|
172
|
+
}
|
|
173
|
+
if (showAmountPrompt) {
|
|
174
|
+
return (_jsx(StyleRoot, { children: _jsxs("div", { className: "bg-b3-react-background flex w-full flex-col items-center", children: [_jsxs("div", { className: "w-full px-4 pb-2 pt-4", children: [_jsx(motion.div, { initial: false, animate: {
|
|
175
|
+
opacity: hasMounted ? 1 : 0,
|
|
176
|
+
y: hasMounted ? 0 : 20,
|
|
177
|
+
filter: hasMounted ? "blur(0px)" : "blur(10px)",
|
|
178
|
+
}, transition: { duration: 0.3, delay: 0, ease: "easeInOut" }, className: "mb-4 flex justify-center", children: imageUrl && (_jsxs("div", { className: "relative size-16", children: [_jsx("div", { className: "absolute inset-0 scale-95 rounded-[50%] bg-gradient-to-br from-blue-500/20 to-purple-600/20 blur-xl" }), _jsxs(GlareCardRounded, { className: "overflow-hidden rounded-full border-none bg-gradient-to-br from-blue-500/10 to-purple-600/10 backdrop-blur-sm", children: [_jsx("img", { alt: "token preview", className: "size-full rounded-lg object-cover", src: imageUrl }), _jsx("div", { className: "absolute inset-0 rounded-[50%] border border-white/20" })] })] })) }), _jsx(motion.div, { initial: false, animate: {
|
|
179
|
+
opacity: hasMounted ? 1 : 0,
|
|
180
|
+
y: hasMounted ? 0 : 20,
|
|
181
|
+
filter: hasMounted ? "blur(0px)" : "blur(10px)",
|
|
182
|
+
}, transition: { duration: 0.3, delay: 0.1, ease: "easeInOut" }, className: "text-center", children: _jsxs("h2", { className: "font-sf-rounded text-as-primary mb-4 text-2xl font-bold", children: ["Buy ", tokenName] }) })] }), _jsx(motion.div, { initial: false, animate: {
|
|
183
|
+
opacity: hasMounted ? 1 : 0,
|
|
184
|
+
y: hasMounted ? 0 : 20,
|
|
185
|
+
filter: hasMounted ? "blur(0px)" : "blur(10px)",
|
|
186
|
+
}, transition: { duration: 0.3, delay: 0.2, ease: "easeInOut" }, className: "bg-b3-react-background w-full p-6", children: _jsxs("div", { className: "space-y-4", children: [_jsx("div", { className: "flex items-center justify-between", children: _jsx("p", { className: "text-as-primary/70 text-sm font-medium", children: "ETH Amount" }) }), _jsx("div", { className: "relative", children: _jsx(Input, { type: "text", inputMode: "decimal", placeholder: "0.1", value: ethAmount, onChange: e => validateAndSetAmount(e.target.value), className: `h-14 px-4 text-lg ${!isAmountValid && ethAmount ? "border-as-red" : "border-b3-react-border"}` }) }), !isAmountValid && ethAmount && _jsx("p", { className: "text-as-red text-sm", children: validationError }), _jsxs("div", { className: "bg-as-on-surface-2/30 rounded-lg border border-white/10 p-4 backdrop-blur-sm", children: [_jsxs("div", { className: "flex items-center justify-between", children: [_jsx("span", { className: "text-as-primary/70 text-sm font-medium", children: "Total Cost:" }), _jsx("div", { className: "flex items-center gap-2", children: _jsxs("span", { className: "text-as-primary text-lg font-bold", children: [ethAmount || "0", " ETH"] }) })] }), isLoadingQuote ? (_jsx("div", { className: "mt-2 text-center", children: _jsx("span", { className: "text-as-primary/70 text-sm", children: "Calculating tokens..." }) })) : quote ? (_jsxs("div", { className: "mt-2 flex items-center justify-between", children: [_jsx("span", { className: "text-as-primary/70 text-sm font-medium", children: "You'll receive:" }), _jsxs("span", { className: "text-as-primary text-sm font-medium", children: ["\u2248 ", formatNumberWithCommas(parseFloat(quote).toFixed(4)), " ", tokenSymbol] })] })) : null] }), _jsx(Button, { onClick: () => {
|
|
187
|
+
if (isAmountValid && ethAmount) {
|
|
188
|
+
setShowAmountPrompt(false);
|
|
189
|
+
}
|
|
190
|
+
}, disabled: !isAmountValid || !ethAmount || isLoadingQuote, className: "bg-as-brand hover:bg-as-brand/90 text-as-primary mt-4 h-14 w-full rounded-xl text-lg font-medium", children: "Continue" })] }) })] }) }));
|
|
191
|
+
}
|
|
192
|
+
const encodedData = encodeFunctionData({
|
|
193
|
+
abi: ABI_bondKit,
|
|
194
|
+
functionName: "buyFor",
|
|
195
|
+
args: [recipientAddress, BigInt(minTokensOut)],
|
|
196
|
+
});
|
|
197
|
+
return (_jsx(AnySpendCustom, { isMainnet: true, mode: mode, recipientAddress: recipientAddress, orderType: OrderType.Custom, dstChainId: baseMainnet.id, dstToken: dstToken, dstAmount: parseEther(ethAmount).toString(), contractAddress: contractAddress, encodedData: encodedData, metadata: {
|
|
198
|
+
type: OrderType.Custom,
|
|
199
|
+
action: "BondKit Buy",
|
|
200
|
+
}, header: header, onSuccess: onSuccess, showRecipient: true }));
|
|
201
|
+
}
|
|
@@ -60,8 +60,6 @@ const SPIN_WHEEL_ABI = [
|
|
|
60
60
|
];
|
|
61
61
|
function getWheelStatus(wheelInfo) {
|
|
62
62
|
const now = BigInt(Math.floor(Date.now() / 1000));
|
|
63
|
-
console.log("@@anyspend-buy-spin:now:", now);
|
|
64
|
-
console.log("@@anyspend-buy-spin:wheelInfo:", wheelInfo);
|
|
65
63
|
if (now < wheelInfo.startTime_) {
|
|
66
64
|
return "not_started";
|
|
67
65
|
}
|
|
@@ -75,7 +73,6 @@ function getWheelStatus(wheelInfo) {
|
|
|
75
73
|
}
|
|
76
74
|
function generateEncodedDataForBuyEntriesAndSpin(user, quantity) {
|
|
77
75
|
invariant(BigInt(quantity) > 0, "Quantity must be greater than zero");
|
|
78
|
-
console.log("@@anyspend-buy-spin:encoded-data:", { user, quantity });
|
|
79
76
|
const encodedData = encodeFunctionData({
|
|
80
77
|
abi: SPIN_WHEEL_ABI,
|
|
81
78
|
functionName: "buyEntriesAndSpin",
|
|
@@ -153,7 +150,6 @@ export function AnySpendBuySpin({ isMainnet = true, loadOrder, mode = "modal", s
|
|
|
153
150
|
try {
|
|
154
151
|
setIsLoadingConfig(true);
|
|
155
152
|
setConfigError("");
|
|
156
|
-
console.log("@@anyspend-buy-spin:fetch-config:", { spinwheelContractAddress, chainId });
|
|
157
153
|
const [config, entryModuleAddress, wheelInfo] = await Promise.all([
|
|
158
154
|
basePublicClient.readContract({
|
|
159
155
|
address: spinwheelContractAddress,
|
|
@@ -332,7 +332,7 @@ export function AnySpendCustom({ isMainnet = true, loadOrder, mode = "modal", re
|
|
|
332
332
|
blockExplorers: [{ name: "B3 Explorer", url: "https://explorer.b3.fun/" }],
|
|
333
333
|
testnet: undefined,
|
|
334
334
|
},
|
|
335
|
-
partnerId: String(process.env.
|
|
335
|
+
partnerId: String(process.env.NEXT_PUBLIC_THIRDWEB_PARTNER_ID),
|
|
336
336
|
type: "signInWithB3",
|
|
337
337
|
showBackButton: false,
|
|
338
338
|
});
|
|
@@ -384,7 +384,7 @@ export function AnySpendCustom({ isMainnet = true, loadOrder, mode = "modal", re
|
|
|
384
384
|
opacity: hasMounted ? 1 : 0,
|
|
385
385
|
y: hasMounted ? 0 : 20,
|
|
386
386
|
filter: hasMounted ? "blur(0px)" : "blur(10px)",
|
|
387
|
-
}, transition: { duration: 0.3, delay: 0.1, ease: "easeInOut" }, className: "relative flex w-full items-center justify-between", children: [
|
|
387
|
+
}, transition: { duration: 0.3, delay: 0.1, ease: "easeInOut" }, className: "relative flex w-full items-center justify-between", children: [_jsxs("span", { className: "font-medium", children: ["Total ", _jsx("span", { className: "text-sm text-gray-500", children: "(with fee)" })] }), _jsxs("h2", { className: cn("text-as-primary text-2xl font-semibold"), children: [formattedSrcAmount || "--", " ", srcToken.symbol] })] })] }), recipientSection, _jsx("div", { className: cn("flex w-full flex-col items-center justify-between gap-2"), children: _jsx(motion.div, { initial: false, animate: {
|
|
388
388
|
opacity: hasMounted ? 1 : 0,
|
|
389
389
|
y: hasMounted ? 0 : 20,
|
|
390
390
|
filter: hasMounted ? "blur(0px)" : "blur(10px)",
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { GenerateSigMintResponse } from "../../types/
|
|
1
|
+
import { GenerateSigMintResponse } from "../../types/signatureMint";
|
|
2
2
|
export declare function AnyspendSignatureMint({ loadOrder, mode, signatureData, imageUrl, onSuccess, }: {
|
|
3
3
|
loadOrder?: string;
|
|
4
4
|
mode?: "modal" | "page";
|
|
@@ -4,7 +4,7 @@ import { StyleRoot, useHasMounted, useTokenData } from "../../../global-account/
|
|
|
4
4
|
import invariant from "../../../shared/utils/debug.js";
|
|
5
5
|
import { useMemo } from "react";
|
|
6
6
|
import { encodeFunctionData, parseEther } from "viem";
|
|
7
|
-
import { ABI_SIGNATURE_MINTING } from "../../abis/
|
|
7
|
+
import { ABI_SIGNATURE_MINTING } from "../../abis/signatureMinting.js";
|
|
8
8
|
import { AnySpendCustom } from "./AnySpendCustom.js";
|
|
9
9
|
// Helper function to determine if URL is a video
|
|
10
10
|
function isVideoURL(url) {
|
|
@@ -39,7 +39,7 @@ function generateEncodedDataForSignatureMint(signatureData) {
|
|
|
39
39
|
export function AnyspendSignatureMint({ loadOrder, mode = "modal", signatureData, imageUrl, onSuccess, }) {
|
|
40
40
|
const hasMounted = useHasMounted();
|
|
41
41
|
// Get token data
|
|
42
|
-
const { data: tokenData, isError: isTokenError } = useTokenData(signatureData.collection.chainId, signatureData.collection.signatureRequestBody?.currency);
|
|
42
|
+
const { data: tokenData, isError: isTokenError, isLoading, } = useTokenData(signatureData.collection.chainId, signatureData.collection.signatureRequestBody?.currency);
|
|
43
43
|
// Convert token data to AnySpend Token type
|
|
44
44
|
const dstToken = useMemo(() => {
|
|
45
45
|
if (!tokenData)
|
|
@@ -58,7 +58,11 @@ export function AnyspendSignatureMint({ loadOrder, mode = "modal", signatureData
|
|
|
58
58
|
const mediaUrl = imageUrl || signatureData.payload.metadata.image || "https://cdn.b3.fun/nft-placeholder.png";
|
|
59
59
|
const isVideo = isVideoURL(mediaUrl);
|
|
60
60
|
const header = () => (_jsxs(_Fragment, { children: [_jsx("div", { className: "relative mx-auto size-32", children: isVideo ? (_jsxs("video", { autoPlay: true, loop: true, muted: true, playsInline: true, className: "size-full rounded-lg object-cover", children: [_jsx("source", { src: mediaUrl, type: `video/${mediaUrl.split(".").pop()}` }), "Your browser does not support the video tag."] })) : (_jsx("img", { alt: "nft preview", className: "size-full rounded-lg object-cover", src: mediaUrl })) }), _jsxs("div", { className: "mt-[-60px] w-full rounded-t-lg bg-white", children: [_jsx("div", { className: "h-[60px] w-full" }), _jsx("div", { className: "mb-1 flex w-full flex-col items-center gap-2 p-5", children: _jsxs("span", { className: "font-sf-rounded text-2xl font-semibold", children: [signatureData.payload.metadata.name || "Mint NFT", " ", Number(signatureData.payload.quantity) > 1 ? `(${signatureData.payload.quantity}x)` : ""] }) })] })] }));
|
|
61
|
-
//
|
|
61
|
+
// Show loading state while fetching token data
|
|
62
|
+
if (isLoading) {
|
|
63
|
+
return (_jsx(StyleRoot, { children: _jsx("div", { className: "b3-root b3-modal bg-b3-react-background flex w-full flex-col items-center p-8", children: _jsx("p", { className: "text-as-primary/70 text-center text-sm", children: "Loading payment token information..." }) }) }));
|
|
64
|
+
}
|
|
65
|
+
// If we don't have token data after loading, show error state
|
|
62
66
|
if (!dstToken || isTokenError) {
|
|
63
67
|
return (_jsx(StyleRoot, { children: _jsx("div", { className: "b3-root b3-modal bg-b3-react-background flex w-full flex-col items-center p-8", children: _jsxs("p", { className: "text-as-red text-center text-sm", children: ["Failed to fetch payment token information for ", signatureData.collection.signatureRequestBody?.currency, " on chain ", signatureData.collection.chainId, ". Please try again."] }) }) }));
|
|
64
68
|
}
|
package/dist/esm/anyspend/react/components/{AnySpendNFTButton.js → common/AnySpendNFTButton.js}
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { DEFAULT_NFT_CONTRACT } from "
|
|
3
|
-
import { Button, useModalStore } from "
|
|
2
|
+
import { DEFAULT_NFT_CONTRACT } from "../../../../anyspend/constants/index.js";
|
|
3
|
+
import { Button, useModalStore } from "../../../../global-account/react/index.js";
|
|
4
4
|
export function AnySpendNFTButton({ nftContract = DEFAULT_NFT_CONTRACT, recipientAddress }) {
|
|
5
5
|
const { setB3ModalOpen, setB3ModalContentType } = useModalStore();
|
|
6
6
|
const handleClick = () => {
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
export { AnySpend } from "./AnySpend";
|
|
2
|
+
export { AnySpendBondKit } from "./AnySpendBondKit";
|
|
2
3
|
export { AnySpendBuySpin } from "./AnySpendBuySpin";
|
|
3
4
|
export { AnySpendCustom } from "./AnySpendCustom";
|
|
4
5
|
export { AnySpendNFT } from "./AnySpendNFT";
|
|
5
|
-
export { AnySpendNFTButton } from "./AnySpendNFTButton";
|
|
6
6
|
export { AnyspendSignatureMint } from "./AnyspendSignatureMint";
|
|
7
7
|
export { AnySpendStakeB3 } from "./AnySpendStakeB3";
|
|
8
8
|
export { AnySpendTournament } from "./AnySpendTournament";
|
|
9
|
+
export { AnySpendNFTButton } from "./common/AnySpendNFTButton";
|
|
9
10
|
export { ChainTokenIcon } from "./common/ChainTokenIcon";
|
|
10
11
|
export { OrderDetails } from "./common/OrderDetails";
|
|
11
12
|
export { OrderHistory } from "./common/OrderHistory";
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
// Components
|
|
2
2
|
export { AnySpend } from "./AnySpend.js";
|
|
3
|
+
export { AnySpendBondKit } from "./AnySpendBondKit.js";
|
|
3
4
|
export { AnySpendBuySpin } from "./AnySpendBuySpin.js";
|
|
4
5
|
export { AnySpendCustom } from "./AnySpendCustom.js";
|
|
5
6
|
export { AnySpendNFT } from "./AnySpendNFT.js";
|
|
6
|
-
export { AnySpendNFTButton } from "./AnySpendNFTButton.js";
|
|
7
7
|
export { AnyspendSignatureMint } from "./AnyspendSignatureMint.js";
|
|
8
8
|
export { AnySpendStakeB3 } from "./AnySpendStakeB3.js";
|
|
9
9
|
export { AnySpendTournament } from "./AnySpendTournament.js";
|
|
10
|
+
export { AnySpendNFTButton } from "./common/AnySpendNFTButton.js";
|
|
10
11
|
// Common Components
|
|
11
12
|
export { ChainTokenIcon } from "./common/ChainTokenIcon.js";
|
|
12
13
|
export { OrderDetails } from "./common/OrderDetails.js";
|
|
@@ -1,7 +1,25 @@
|
|
|
1
1
|
import { anyspendService } from "../../../anyspend/services/anyspend.js";
|
|
2
2
|
import { useQuery } from "@tanstack/react-query";
|
|
3
|
-
import isEqual from "lodash/isEqual.js";
|
|
4
3
|
import { useCallback, useMemo } from "react";
|
|
4
|
+
// Custom deep equality function that handles BigInt
|
|
5
|
+
function customDeepEqual(oldData, newData) {
|
|
6
|
+
// Handle BigInt comparison
|
|
7
|
+
if (typeof oldData === "bigint" && typeof newData === "bigint") {
|
|
8
|
+
return oldData === newData;
|
|
9
|
+
}
|
|
10
|
+
// Handle arrays
|
|
11
|
+
if (Array.isArray(oldData) && Array.isArray(newData)) {
|
|
12
|
+
return oldData.length === newData.length && oldData.every((item, index) => customDeepEqual(item, newData[index]));
|
|
13
|
+
}
|
|
14
|
+
// Handle objects
|
|
15
|
+
if (oldData && newData && typeof oldData === "object" && typeof newData === "object") {
|
|
16
|
+
const keys1 = Object.keys(oldData);
|
|
17
|
+
const keys2 = Object.keys(newData);
|
|
18
|
+
return keys1.length === keys2.length && keys1.every(key => customDeepEqual(oldData[key], newData[key]));
|
|
19
|
+
}
|
|
20
|
+
// Handle primitive values
|
|
21
|
+
return oldData === newData;
|
|
22
|
+
}
|
|
5
23
|
// Hook to fetch and auto-refresh order status and transaction details
|
|
6
24
|
export function useAnyspendOrderAndTransactions(isMainnet, orderId) {
|
|
7
25
|
const selectFn = useCallback((data) => {
|
|
@@ -12,12 +30,12 @@ export function useAnyspendOrderAndTransactions(isMainnet, orderId) {
|
|
|
12
30
|
const { data, isLoading, refetch, error } = useQuery({
|
|
13
31
|
queryKey: ["getAnyspendOrderAndTransactions", orderId],
|
|
14
32
|
queryFn: () => anyspendService.getOrderAndTransactions(isMainnet, orderId),
|
|
15
|
-
enabled:
|
|
33
|
+
enabled: !!orderId,
|
|
16
34
|
refetchInterval: 3000,
|
|
17
35
|
staleTime: 1000,
|
|
18
36
|
select: selectFn,
|
|
19
37
|
structuralSharing: (oldData, newData) => {
|
|
20
|
-
if (
|
|
38
|
+
if (customDeepEqual(oldData, newData))
|
|
21
39
|
return oldData;
|
|
22
40
|
return newData;
|
|
23
41
|
},
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FindByAddressParams, GenerateSigMintParams, IsMintEligibleParams } from "../../types/
|
|
1
|
+
import { FindByAddressParams, GenerateSigMintParams, IsMintEligibleParams } from "../../types/signatureMint";
|
|
2
2
|
/**
|
|
3
3
|
* Hook to generate signature for minting
|
|
4
4
|
*/
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export interface bondKitBuyForParams {
|
|
2
|
+
recipientAddress: string;
|
|
3
|
+
contractAddress: string;
|
|
4
|
+
chainId: number;
|
|
5
|
+
minTokensOut: string;
|
|
6
|
+
ethAmount: string;
|
|
7
|
+
imageUrl?: string;
|
|
8
|
+
tokenName?: string;
|
|
9
|
+
loadOrder?: string;
|
|
10
|
+
mode?: "modal" | "page";
|
|
11
|
+
onSuccess?: (txHash?: string) => void;
|
|
12
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|