@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
|
@@ -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,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ABI_bondKit = void 0;
|
|
4
|
+
exports.ABI_bondKit = [
|
|
5
|
+
{
|
|
6
|
+
inputs: [
|
|
7
|
+
{ internalType: "address", name: "_recipient", type: "address" },
|
|
8
|
+
{ internalType: "uint256", name: "_minTokensOut", type: "uint256" },
|
|
9
|
+
],
|
|
10
|
+
name: "buyFor",
|
|
11
|
+
outputs: [],
|
|
12
|
+
stateMutability: "payable",
|
|
13
|
+
type: "function",
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
inputs: [],
|
|
17
|
+
name: "name",
|
|
18
|
+
outputs: [{ internalType: "string", name: "", type: "string" }],
|
|
19
|
+
stateMutability: "view",
|
|
20
|
+
type: "function",
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
inputs: [],
|
|
24
|
+
name: "symbol",
|
|
25
|
+
outputs: [{ internalType: "string", name: "", type: "string" }],
|
|
26
|
+
stateMutability: "view",
|
|
27
|
+
type: "function",
|
|
28
|
+
},
|
|
29
|
+
];
|
|
@@ -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";
|
|
@@ -18,7 +18,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
18
18
|
__exportStar(require("./types"), exports);
|
|
19
19
|
__exportStar(require("./types/metadata"), exports);
|
|
20
20
|
__exportStar(require("./types/relay"), exports);
|
|
21
|
-
__exportStar(require("./types/
|
|
21
|
+
__exportStar(require("./types/signatureMint"), exports);
|
|
22
22
|
__exportStar(require("./types/token"), exports);
|
|
23
23
|
// Utils
|
|
24
24
|
__exportStar(require("./utils/address"), exports);
|
|
@@ -31,5 +31,5 @@ __exportStar(require("./utils/token"), exports);
|
|
|
31
31
|
// Constants
|
|
32
32
|
__exportStar(require("./constants"), exports);
|
|
33
33
|
// Abis
|
|
34
|
-
__exportStar(require("./abis/
|
|
35
|
-
__exportStar(require("./abis/
|
|
34
|
+
__exportStar(require("./abis/abiUsdcBase"), exports);
|
|
35
|
+
__exportStar(require("./abis/erc20Staking"), exports);
|
|
@@ -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";
|
|
@@ -31,5 +31,5 @@ __exportStar(require("./utils/token"), exports);
|
|
|
31
31
|
// Constants
|
|
32
32
|
__exportStar(require("./constants"), exports);
|
|
33
33
|
// Abis
|
|
34
|
-
__exportStar(require("./abis/
|
|
35
|
-
__exportStar(require("./abis/
|
|
34
|
+
__exportStar(require("./abis/abiUsdcBase"), exports);
|
|
35
|
+
__exportStar(require("./abis/erc20Staking"), exports);
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AnySpendBondKit = AnySpendBondKit;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const bondkit_1 = require("@b3dotfun/bondkit");
|
|
6
|
+
const anyspend_1 = require("../../../anyspend");
|
|
7
|
+
const react_1 = require("../../../global-account/react");
|
|
8
|
+
const supported_1 = require("../../../shared/constants/chains/supported");
|
|
9
|
+
const framer_motion_1 = require("framer-motion");
|
|
10
|
+
const react_2 = require("react");
|
|
11
|
+
const viem_1 = require("viem");
|
|
12
|
+
const bondKit_1 = require("../../abis/bondKit");
|
|
13
|
+
const AnySpendCustom_1 = require("./AnySpendCustom");
|
|
14
|
+
// Debounce utility function
|
|
15
|
+
function debounce(func, wait) {
|
|
16
|
+
let timeout;
|
|
17
|
+
return (...args) => {
|
|
18
|
+
clearTimeout(timeout);
|
|
19
|
+
timeout = setTimeout(() => func(...args), wait);
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
// Format number with commas
|
|
23
|
+
function formatNumberWithCommas(x) {
|
|
24
|
+
const parts = x.split(".");
|
|
25
|
+
parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, ",");
|
|
26
|
+
return parts.join(".");
|
|
27
|
+
}
|
|
28
|
+
function AnySpendBondKit({ mode = "modal", recipientAddress, contractAddress, minTokensOut = "0", imageUrl, onSuccess, }) {
|
|
29
|
+
const hasMounted = (0, react_1.useHasMounted)();
|
|
30
|
+
const [showAmountPrompt, setShowAmountPrompt] = (0, react_2.useState)(true);
|
|
31
|
+
const [ethAmount, setEthAmount] = (0, react_2.useState)("");
|
|
32
|
+
const [isAmountValid, setIsAmountValid] = (0, react_2.useState)(false);
|
|
33
|
+
const [validationError, setValidationError] = (0, react_2.useState)("");
|
|
34
|
+
const [tokenName, setTokenName] = (0, react_2.useState)("");
|
|
35
|
+
const [tokenSymbol, setTokenSymbol] = (0, react_2.useState)("");
|
|
36
|
+
const [quote, setQuote] = (0, react_2.useState)(null);
|
|
37
|
+
const [isLoadingQuote, setIsLoadingQuote] = (0, react_2.useState)(false);
|
|
38
|
+
// Create BondKit client
|
|
39
|
+
const bondkitTokenClient = (0, react_2.useMemo)(() => {
|
|
40
|
+
if (!contractAddress)
|
|
41
|
+
return null;
|
|
42
|
+
try {
|
|
43
|
+
const client = new bondkit_1.BondkitToken(contractAddress);
|
|
44
|
+
client.connect();
|
|
45
|
+
return client;
|
|
46
|
+
}
|
|
47
|
+
catch (error) {
|
|
48
|
+
console.error("Error creating bondkit client", error);
|
|
49
|
+
return null;
|
|
50
|
+
}
|
|
51
|
+
}, [contractAddress]);
|
|
52
|
+
// Create a public client for reading contract data
|
|
53
|
+
const basePublicClient = (0, viem_1.createPublicClient)({
|
|
54
|
+
chain: supported_1.baseMainnet,
|
|
55
|
+
transport: (0, viem_1.http)(),
|
|
56
|
+
});
|
|
57
|
+
// Fetch token name from contract
|
|
58
|
+
(0, react_2.useEffect)(() => {
|
|
59
|
+
async function fetchTokenName() {
|
|
60
|
+
try {
|
|
61
|
+
const [name, symbol] = await Promise.all([
|
|
62
|
+
basePublicClient.readContract({
|
|
63
|
+
address: contractAddress,
|
|
64
|
+
abi: bondKit_1.ABI_bondKit,
|
|
65
|
+
functionName: "name",
|
|
66
|
+
}),
|
|
67
|
+
basePublicClient.readContract({
|
|
68
|
+
address: contractAddress,
|
|
69
|
+
abi: bondKit_1.ABI_bondKit,
|
|
70
|
+
functionName: "symbol",
|
|
71
|
+
}),
|
|
72
|
+
]);
|
|
73
|
+
setTokenName(name);
|
|
74
|
+
setTokenSymbol(symbol);
|
|
75
|
+
}
|
|
76
|
+
catch (error) {
|
|
77
|
+
console.error("Error fetching token name:", error);
|
|
78
|
+
setTokenName("BondKit Token");
|
|
79
|
+
setTokenSymbol("BOND");
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
if (contractAddress) {
|
|
83
|
+
fetchTokenName();
|
|
84
|
+
}
|
|
85
|
+
}, [contractAddress, basePublicClient]);
|
|
86
|
+
// Get native token data for the chain
|
|
87
|
+
const { data: tokenData, isError: isTokenError, isLoading, } = (0, react_1.useTokenData)(supported_1.baseMainnet.id, "0x0000000000000000000000000000000000000000");
|
|
88
|
+
// Convert token data to AnySpend Token type
|
|
89
|
+
const dstToken = (0, react_2.useMemo)(() => {
|
|
90
|
+
if (!tokenData)
|
|
91
|
+
return null;
|
|
92
|
+
return {
|
|
93
|
+
address: tokenData.address,
|
|
94
|
+
chainId: supported_1.baseMainnet.id,
|
|
95
|
+
name: tokenData.name,
|
|
96
|
+
symbol: tokenData.symbol,
|
|
97
|
+
decimals: tokenData.decimals,
|
|
98
|
+
metadata: {
|
|
99
|
+
logoURI: tokenData.logoURI,
|
|
100
|
+
},
|
|
101
|
+
};
|
|
102
|
+
}, [tokenData]);
|
|
103
|
+
// Debounced quote fetching
|
|
104
|
+
const debouncedGetQuote = (0, react_2.useMemo)(() => debounce(async (val) => {
|
|
105
|
+
if (!val || Number(val) <= 0 || !bondkitTokenClient) {
|
|
106
|
+
setQuote(null);
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
try {
|
|
110
|
+
setIsLoadingQuote(true);
|
|
111
|
+
const parsedAmount = (0, viem_1.parseEther)(val);
|
|
112
|
+
const buyQuote = await bondkitTokenClient.getAmountOfTokensToBuy(parsedAmount);
|
|
113
|
+
setQuote(buyQuote ? (0, viem_1.formatEther)(buyQuote) : null);
|
|
114
|
+
}
|
|
115
|
+
catch (error) {
|
|
116
|
+
console.error("Error getting buy quote:", error);
|
|
117
|
+
setQuote(null);
|
|
118
|
+
}
|
|
119
|
+
finally {
|
|
120
|
+
setIsLoadingQuote(false);
|
|
121
|
+
}
|
|
122
|
+
}, 500), [bondkitTokenClient]);
|
|
123
|
+
const validateAndSetAmount = (value) => {
|
|
124
|
+
// Allow empty input
|
|
125
|
+
if (value === "") {
|
|
126
|
+
setEthAmount("");
|
|
127
|
+
setIsAmountValid(false);
|
|
128
|
+
setValidationError("");
|
|
129
|
+
setQuote(null);
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
// Only allow valid number format (no leading zeros unless decimal)
|
|
133
|
+
if (!/^(0|[1-9]\d*)?\.?\d*$/.test(value)) {
|
|
134
|
+
setIsAmountValid(false);
|
|
135
|
+
setValidationError("Please enter a valid number");
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
// Prevent multiple decimal points
|
|
139
|
+
if ((value.match(/\./g) || []).length > 1) {
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
// Prevent more than 18 decimal places (ETH precision)
|
|
143
|
+
const parts = value.split(".");
|
|
144
|
+
if (parts[1] && parts[1].length > 18) {
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
// Clean the input - remove leading zeros if not decimal
|
|
148
|
+
const cleanedValue = value.startsWith("0") && !value.startsWith("0.") ? value.replace(/^0+/, "0") : value;
|
|
149
|
+
setEthAmount(cleanedValue);
|
|
150
|
+
try {
|
|
151
|
+
const parsedAmount = (0, viem_1.parseEther)(cleanedValue);
|
|
152
|
+
if (parsedAmount <= BigInt(0)) {
|
|
153
|
+
setIsAmountValid(false);
|
|
154
|
+
setValidationError("Amount must be greater than 0");
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
setIsAmountValid(true);
|
|
158
|
+
setValidationError("");
|
|
159
|
+
debouncedGetQuote(cleanedValue);
|
|
160
|
+
}
|
|
161
|
+
catch (error) {
|
|
162
|
+
console.error("Error validating amount:", error);
|
|
163
|
+
setIsAmountValid(false);
|
|
164
|
+
setValidationError("Please enter a valid amount");
|
|
165
|
+
}
|
|
166
|
+
};
|
|
167
|
+
const header = () => ((0, jsx_runtime_1.jsx)("div", { className: "w-full px-6 py-4", children: (0, jsx_runtime_1.jsxs)("div", { className: "flex w-full flex-col items-center space-y-6", children: [(0, jsx_runtime_1.jsxs)("h2", { className: "text-[28px] font-bold", children: ["Buy ", tokenName, " (", tokenSymbol, ")"] }), (0, jsx_runtime_1.jsxs)("div", { className: "flex w-full flex-col items-center space-y-2", children: [(0, jsx_runtime_1.jsxs)("span", { className: "text-[28px] font-bold", children: [ethAmount, " ETH"] }), quote && ((0, jsx_runtime_1.jsxs)("span", { className: "text-lg", children: ["\u2248 ", formatNumberWithCommas(parseFloat(quote).toFixed(4)), " ", tokenSymbol] }))] })] }) }));
|
|
168
|
+
// Show loading state while fetching token data
|
|
169
|
+
if (isLoading) {
|
|
170
|
+
return ((0, jsx_runtime_1.jsx)(react_1.StyleRoot, { children: (0, jsx_runtime_1.jsx)("div", { className: "b3-root b3-modal bg-b3-react-background flex w-full flex-col items-center p-8", children: (0, jsx_runtime_1.jsx)("p", { className: "text-as-primary/70 text-center text-sm", children: "Loading payment information..." }) }) }));
|
|
171
|
+
}
|
|
172
|
+
// If we don't have token data after loading, show error state
|
|
173
|
+
if (!dstToken || isTokenError) {
|
|
174
|
+
return ((0, jsx_runtime_1.jsx)(react_1.StyleRoot, { children: (0, jsx_runtime_1.jsx)("div", { className: "b3-root b3-modal bg-b3-react-background flex w-full flex-col items-center p-8", children: (0, jsx_runtime_1.jsxs)("p", { className: "text-as-red text-center text-sm", children: ["Failed to fetch native token information for chain ", supported_1.baseMainnet.id, ". Please try again."] }) }) }));
|
|
175
|
+
}
|
|
176
|
+
if (showAmountPrompt) {
|
|
177
|
+
return ((0, jsx_runtime_1.jsx)(react_1.StyleRoot, { children: (0, jsx_runtime_1.jsxs)("div", { className: "bg-b3-react-background flex w-full flex-col items-center", children: [(0, jsx_runtime_1.jsxs)("div", { className: "w-full px-4 pb-2 pt-4", children: [(0, jsx_runtime_1.jsx)(framer_motion_1.motion.div, { initial: false, animate: {
|
|
178
|
+
opacity: hasMounted ? 1 : 0,
|
|
179
|
+
y: hasMounted ? 0 : 20,
|
|
180
|
+
filter: hasMounted ? "blur(0px)" : "blur(10px)",
|
|
181
|
+
}, transition: { duration: 0.3, delay: 0, ease: "easeInOut" }, className: "mb-4 flex justify-center", children: imageUrl && ((0, jsx_runtime_1.jsxs)("div", { className: "relative size-16", children: [(0, jsx_runtime_1.jsx)("div", { className: "absolute inset-0 scale-95 rounded-[50%] bg-gradient-to-br from-blue-500/20 to-purple-600/20 blur-xl" }), (0, jsx_runtime_1.jsxs)(react_1.GlareCardRounded, { className: "overflow-hidden rounded-full border-none bg-gradient-to-br from-blue-500/10 to-purple-600/10 backdrop-blur-sm", children: [(0, jsx_runtime_1.jsx)("img", { alt: "token preview", className: "size-full rounded-lg object-cover", src: imageUrl }), (0, jsx_runtime_1.jsx)("div", { className: "absolute inset-0 rounded-[50%] border border-white/20" })] })] })) }), (0, jsx_runtime_1.jsx)(framer_motion_1.motion.div, { initial: false, animate: {
|
|
182
|
+
opacity: hasMounted ? 1 : 0,
|
|
183
|
+
y: hasMounted ? 0 : 20,
|
|
184
|
+
filter: hasMounted ? "blur(0px)" : "blur(10px)",
|
|
185
|
+
}, transition: { duration: 0.3, delay: 0.1, ease: "easeInOut" }, className: "text-center", children: (0, jsx_runtime_1.jsxs)("h2", { className: "font-sf-rounded text-as-primary mb-4 text-2xl font-bold", children: ["Buy ", tokenName] }) })] }), (0, jsx_runtime_1.jsx)(framer_motion_1.motion.div, { initial: false, animate: {
|
|
186
|
+
opacity: hasMounted ? 1 : 0,
|
|
187
|
+
y: hasMounted ? 0 : 20,
|
|
188
|
+
filter: hasMounted ? "blur(0px)" : "blur(10px)",
|
|
189
|
+
}, transition: { duration: 0.3, delay: 0.2, ease: "easeInOut" }, className: "bg-b3-react-background w-full p-6", children: (0, jsx_runtime_1.jsxs)("div", { className: "space-y-4", children: [(0, jsx_runtime_1.jsx)("div", { className: "flex items-center justify-between", children: (0, jsx_runtime_1.jsx)("p", { className: "text-as-primary/70 text-sm font-medium", children: "ETH Amount" }) }), (0, jsx_runtime_1.jsx)("div", { className: "relative", children: (0, jsx_runtime_1.jsx)(react_1.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 && (0, jsx_runtime_1.jsx)("p", { className: "text-as-red text-sm", children: validationError }), (0, jsx_runtime_1.jsxs)("div", { className: "bg-as-on-surface-2/30 rounded-lg border border-white/10 p-4 backdrop-blur-sm", children: [(0, jsx_runtime_1.jsxs)("div", { className: "flex items-center justify-between", children: [(0, jsx_runtime_1.jsx)("span", { className: "text-as-primary/70 text-sm font-medium", children: "Total Cost:" }), (0, jsx_runtime_1.jsx)("div", { className: "flex items-center gap-2", children: (0, jsx_runtime_1.jsxs)("span", { className: "text-as-primary text-lg font-bold", children: [ethAmount || "0", " ETH"] }) })] }), isLoadingQuote ? ((0, jsx_runtime_1.jsx)("div", { className: "mt-2 text-center", children: (0, jsx_runtime_1.jsx)("span", { className: "text-as-primary/70 text-sm", children: "Calculating tokens..." }) })) : quote ? ((0, jsx_runtime_1.jsxs)("div", { className: "mt-2 flex items-center justify-between", children: [(0, jsx_runtime_1.jsx)("span", { className: "text-as-primary/70 text-sm font-medium", children: "You'll receive:" }), (0, jsx_runtime_1.jsxs)("span", { className: "text-as-primary text-sm font-medium", children: ["\u2248 ", formatNumberWithCommas(parseFloat(quote).toFixed(4)), " ", tokenSymbol] })] })) : null] }), (0, jsx_runtime_1.jsx)(react_1.Button, { onClick: () => {
|
|
190
|
+
if (isAmountValid && ethAmount) {
|
|
191
|
+
setShowAmountPrompt(false);
|
|
192
|
+
}
|
|
193
|
+
}, 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" })] }) })] }) }));
|
|
194
|
+
}
|
|
195
|
+
const encodedData = (0, viem_1.encodeFunctionData)({
|
|
196
|
+
abi: bondKit_1.ABI_bondKit,
|
|
197
|
+
functionName: "buyFor",
|
|
198
|
+
args: [recipientAddress, BigInt(minTokensOut)],
|
|
199
|
+
});
|
|
200
|
+
return ((0, jsx_runtime_1.jsx)(AnySpendCustom_1.AnySpendCustom, { isMainnet: true, mode: mode, recipientAddress: recipientAddress, orderType: anyspend_1.OrderType.Custom, dstChainId: supported_1.baseMainnet.id, dstToken: dstToken, dstAmount: (0, viem_1.parseEther)(ethAmount).toString(), contractAddress: contractAddress, encodedData: encodedData, metadata: {
|
|
201
|
+
type: anyspend_1.OrderType.Custom,
|
|
202
|
+
action: "BondKit Buy",
|
|
203
|
+
}, header: header, onSuccess: onSuccess, showRecipient: true }));
|
|
204
|
+
}
|
|
@@ -66,8 +66,6 @@ const SPIN_WHEEL_ABI = [
|
|
|
66
66
|
];
|
|
67
67
|
function getWheelStatus(wheelInfo) {
|
|
68
68
|
const now = BigInt(Math.floor(Date.now() / 1000));
|
|
69
|
-
console.log("@@anyspend-buy-spin:now:", now);
|
|
70
|
-
console.log("@@anyspend-buy-spin:wheelInfo:", wheelInfo);
|
|
71
69
|
if (now < wheelInfo.startTime_) {
|
|
72
70
|
return "not_started";
|
|
73
71
|
}
|
|
@@ -81,7 +79,6 @@ function getWheelStatus(wheelInfo) {
|
|
|
81
79
|
}
|
|
82
80
|
function generateEncodedDataForBuyEntriesAndSpin(user, quantity) {
|
|
83
81
|
(0, invariant_1.default)(BigInt(quantity) > 0, "Quantity must be greater than zero");
|
|
84
|
-
console.log("@@anyspend-buy-spin:encoded-data:", { user, quantity });
|
|
85
82
|
const encodedData = (0, viem_1.encodeFunctionData)({
|
|
86
83
|
abi: SPIN_WHEEL_ABI,
|
|
87
84
|
functionName: "buyEntriesAndSpin",
|
|
@@ -159,7 +156,6 @@ function AnySpendBuySpin({ isMainnet = true, loadOrder, mode = "modal", spinwhee
|
|
|
159
156
|
try {
|
|
160
157
|
setIsLoadingConfig(true);
|
|
161
158
|
setConfigError("");
|
|
162
|
-
console.log("@@anyspend-buy-spin:fetch-config:", { spinwheelContractAddress, chainId });
|
|
163
159
|
const [config, entryModuleAddress, wheelInfo] = await Promise.all([
|
|
164
160
|
basePublicClient.readContract({
|
|
165
161
|
address: spinwheelContractAddress,
|
|
@@ -338,7 +338,7 @@ function AnySpendCustom({ isMainnet = true, loadOrder, mode = "modal", recipient
|
|
|
338
338
|
blockExplorers: [{ name: "B3 Explorer", url: "https://explorer.b3.fun/" }],
|
|
339
339
|
testnet: undefined,
|
|
340
340
|
},
|
|
341
|
-
partnerId: String(process.env.
|
|
341
|
+
partnerId: String(process.env.NEXT_PUBLIC_THIRDWEB_PARTNER_ID),
|
|
342
342
|
type: "signInWithB3",
|
|
343
343
|
showBackButton: false,
|
|
344
344
|
});
|
|
@@ -390,7 +390,7 @@ function AnySpendCustom({ isMainnet = true, loadOrder, mode = "modal", recipient
|
|
|
390
390
|
opacity: hasMounted ? 1 : 0,
|
|
391
391
|
y: hasMounted ? 0 : 20,
|
|
392
392
|
filter: hasMounted ? "blur(0px)" : "blur(10px)",
|
|
393
|
-
}, transition: { duration: 0.3, delay: 0.1, ease: "easeInOut" }, className: "relative flex w-full items-center justify-between", children: [(0, jsx_runtime_1.
|
|
393
|
+
}, transition: { duration: 0.3, delay: 0.1, ease: "easeInOut" }, className: "relative flex w-full items-center justify-between", children: [(0, jsx_runtime_1.jsxs)("span", { className: "font-medium", children: ["Total ", (0, jsx_runtime_1.jsx)("span", { className: "text-sm text-gray-500", children: "(with fee)" })] }), (0, jsx_runtime_1.jsxs)("h2", { className: (0, utils_1.cn)("text-as-primary text-2xl font-semibold"), children: [formattedSrcAmount || "--", " ", srcToken.symbol] })] })] }), recipientSection, (0, jsx_runtime_1.jsx)("div", { className: (0, utils_1.cn)("flex w-full flex-col items-center justify-between gap-2"), children: (0, jsx_runtime_1.jsx)(framer_motion_1.motion.div, { initial: false, animate: {
|
|
394
394
|
opacity: hasMounted ? 1 : 0,
|
|
395
395
|
y: hasMounted ? 0 : 20,
|
|
396
396
|
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";
|
|
@@ -10,7 +10,7 @@ const react_1 = require("../../../global-account/react");
|
|
|
10
10
|
const debug_1 = __importDefault(require("../../../shared/utils/debug"));
|
|
11
11
|
const react_2 = require("react");
|
|
12
12
|
const viem_1 = require("viem");
|
|
13
|
-
const
|
|
13
|
+
const signatureMinting_1 = require("../../abis/signatureMinting");
|
|
14
14
|
const AnySpendCustom_1 = require("./AnySpendCustom");
|
|
15
15
|
// Helper function to determine if URL is a video
|
|
16
16
|
function isVideoURL(url) {
|
|
@@ -36,7 +36,7 @@ function generateEncodedDataForSignatureMint(signatureData) {
|
|
|
36
36
|
uid: payload.uid,
|
|
37
37
|
};
|
|
38
38
|
const encodedData = (0, viem_1.encodeFunctionData)({
|
|
39
|
-
abi: [
|
|
39
|
+
abi: [signatureMinting_1.ABI_SIGNATURE_MINTING[0]],
|
|
40
40
|
functionName: "mintWithSignature",
|
|
41
41
|
args: [mintRequest, signature],
|
|
42
42
|
});
|
|
@@ -45,7 +45,7 @@ function generateEncodedDataForSignatureMint(signatureData) {
|
|
|
45
45
|
function AnyspendSignatureMint({ loadOrder, mode = "modal", signatureData, imageUrl, onSuccess, }) {
|
|
46
46
|
const hasMounted = (0, react_1.useHasMounted)();
|
|
47
47
|
// Get token data
|
|
48
|
-
const { data: tokenData, isError: isTokenError } = (0, react_1.useTokenData)(signatureData.collection.chainId, signatureData.collection.signatureRequestBody?.currency);
|
|
48
|
+
const { data: tokenData, isError: isTokenError, isLoading, } = (0, react_1.useTokenData)(signatureData.collection.chainId, signatureData.collection.signatureRequestBody?.currency);
|
|
49
49
|
// Convert token data to AnySpend Token type
|
|
50
50
|
const dstToken = (0, react_2.useMemo)(() => {
|
|
51
51
|
if (!tokenData)
|
|
@@ -64,7 +64,11 @@ function AnyspendSignatureMint({ loadOrder, mode = "modal", signatureData, image
|
|
|
64
64
|
const mediaUrl = imageUrl || signatureData.payload.metadata.image || "https://cdn.b3.fun/nft-placeholder.png";
|
|
65
65
|
const isVideo = isVideoURL(mediaUrl);
|
|
66
66
|
const header = () => ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("div", { className: "relative mx-auto size-32", children: isVideo ? ((0, jsx_runtime_1.jsxs)("video", { autoPlay: true, loop: true, muted: true, playsInline: true, className: "size-full rounded-lg object-cover", children: [(0, jsx_runtime_1.jsx)("source", { src: mediaUrl, type: `video/${mediaUrl.split(".").pop()}` }), "Your browser does not support the video tag."] })) : ((0, jsx_runtime_1.jsx)("img", { alt: "nft preview", className: "size-full rounded-lg object-cover", src: mediaUrl })) }), (0, jsx_runtime_1.jsxs)("div", { className: "mt-[-60px] w-full rounded-t-lg bg-white", children: [(0, jsx_runtime_1.jsx)("div", { className: "h-[60px] w-full" }), (0, jsx_runtime_1.jsx)("div", { className: "mb-1 flex w-full flex-col items-center gap-2 p-5", children: (0, jsx_runtime_1.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)` : ""] }) })] })] }));
|
|
67
|
-
//
|
|
67
|
+
// Show loading state while fetching token data
|
|
68
|
+
if (isLoading) {
|
|
69
|
+
return ((0, jsx_runtime_1.jsx)(react_1.StyleRoot, { children: (0, jsx_runtime_1.jsx)("div", { className: "b3-root b3-modal bg-b3-react-background flex w-full flex-col items-center p-8", children: (0, jsx_runtime_1.jsx)("p", { className: "text-as-primary/70 text-center text-sm", children: "Loading payment token information..." }) }) }));
|
|
70
|
+
}
|
|
71
|
+
// If we don't have token data after loading, show error state
|
|
68
72
|
if (!dstToken || isTokenError) {
|
|
69
73
|
return ((0, jsx_runtime_1.jsx)(react_1.StyleRoot, { children: (0, jsx_runtime_1.jsx)("div", { className: "b3-root b3-modal bg-b3-react-background flex w-full flex-col items-center p-8", children: (0, jsx_runtime_1.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."] }) }) }));
|
|
70
74
|
}
|
package/dist/cjs/anyspend/react/components/{AnySpendNFTButton.js → common/AnySpendNFTButton.js}
RENAMED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.AnySpendNFTButton = AnySpendNFTButton;
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
-
const constants_1 = require("
|
|
6
|
-
const react_1 = require("
|
|
5
|
+
const constants_1 = require("../../../../anyspend/constants");
|
|
6
|
+
const react_1 = require("../../../../global-account/react");
|
|
7
7
|
function AnySpendNFTButton({ nftContract = constants_1.DEFAULT_NFT_CONTRACT, recipientAddress }) {
|
|
8
8
|
const { setB3ModalOpen, setB3ModalContentType } = (0, react_1.useModalStore)();
|
|
9
9
|
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,23 +1,25 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.WebviewOnrampPayment = exports.WebviewOnrampOrderStatus = exports.TokenBalance = exports.OrderTokenAmount = exports.OrderToken = exports.OrderStatus = exports.OrderHistoryItem = exports.OrderHistory = exports.OrderDetails = exports.ChainTokenIcon = exports.
|
|
3
|
+
exports.WebviewOnrampPayment = exports.WebviewOnrampOrderStatus = exports.TokenBalance = exports.OrderTokenAmount = exports.OrderToken = exports.OrderStatus = exports.OrderHistoryItem = exports.OrderHistory = exports.OrderDetails = exports.ChainTokenIcon = exports.AnySpendNFTButton = exports.AnySpendTournament = exports.AnySpendStakeB3 = exports.AnyspendSignatureMint = exports.AnySpendNFT = exports.AnySpendCustom = exports.AnySpendBuySpin = exports.AnySpendBondKit = exports.AnySpend = void 0;
|
|
4
4
|
// Components
|
|
5
5
|
var AnySpend_1 = require("./AnySpend");
|
|
6
6
|
Object.defineProperty(exports, "AnySpend", { enumerable: true, get: function () { return AnySpend_1.AnySpend; } });
|
|
7
|
+
var AnySpendBondKit_1 = require("./AnySpendBondKit");
|
|
8
|
+
Object.defineProperty(exports, "AnySpendBondKit", { enumerable: true, get: function () { return AnySpendBondKit_1.AnySpendBondKit; } });
|
|
7
9
|
var AnySpendBuySpin_1 = require("./AnySpendBuySpin");
|
|
8
10
|
Object.defineProperty(exports, "AnySpendBuySpin", { enumerable: true, get: function () { return AnySpendBuySpin_1.AnySpendBuySpin; } });
|
|
9
11
|
var AnySpendCustom_1 = require("./AnySpendCustom");
|
|
10
12
|
Object.defineProperty(exports, "AnySpendCustom", { enumerable: true, get: function () { return AnySpendCustom_1.AnySpendCustom; } });
|
|
11
13
|
var AnySpendNFT_1 = require("./AnySpendNFT");
|
|
12
14
|
Object.defineProperty(exports, "AnySpendNFT", { enumerable: true, get: function () { return AnySpendNFT_1.AnySpendNFT; } });
|
|
13
|
-
var AnySpendNFTButton_1 = require("./AnySpendNFTButton");
|
|
14
|
-
Object.defineProperty(exports, "AnySpendNFTButton", { enumerable: true, get: function () { return AnySpendNFTButton_1.AnySpendNFTButton; } });
|
|
15
15
|
var AnyspendSignatureMint_1 = require("./AnyspendSignatureMint");
|
|
16
16
|
Object.defineProperty(exports, "AnyspendSignatureMint", { enumerable: true, get: function () { return AnyspendSignatureMint_1.AnyspendSignatureMint; } });
|
|
17
17
|
var AnySpendStakeB3_1 = require("./AnySpendStakeB3");
|
|
18
18
|
Object.defineProperty(exports, "AnySpendStakeB3", { enumerable: true, get: function () { return AnySpendStakeB3_1.AnySpendStakeB3; } });
|
|
19
19
|
var AnySpendTournament_1 = require("./AnySpendTournament");
|
|
20
20
|
Object.defineProperty(exports, "AnySpendTournament", { enumerable: true, get: function () { return AnySpendTournament_1.AnySpendTournament; } });
|
|
21
|
+
var AnySpendNFTButton_1 = require("./common/AnySpendNFTButton");
|
|
22
|
+
Object.defineProperty(exports, "AnySpendNFTButton", { enumerable: true, get: function () { return AnySpendNFTButton_1.AnySpendNFTButton; } });
|
|
21
23
|
// Common Components
|
|
22
24
|
var ChainTokenIcon_1 = require("./common/ChainTokenIcon");
|
|
23
25
|
Object.defineProperty(exports, "ChainTokenIcon", { enumerable: true, get: function () { return ChainTokenIcon_1.ChainTokenIcon; } });
|
|
@@ -1,13 +1,28 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.useAnyspendOrderAndTransactions = useAnyspendOrderAndTransactions;
|
|
7
4
|
const anyspend_1 = require("../../../anyspend/services/anyspend");
|
|
8
5
|
const react_query_1 = require("@tanstack/react-query");
|
|
9
|
-
const isEqual_js_1 = __importDefault(require("lodash/isEqual.js"));
|
|
10
6
|
const react_1 = require("react");
|
|
7
|
+
// Custom deep equality function that handles BigInt
|
|
8
|
+
function customDeepEqual(oldData, newData) {
|
|
9
|
+
// Handle BigInt comparison
|
|
10
|
+
if (typeof oldData === "bigint" && typeof newData === "bigint") {
|
|
11
|
+
return oldData === newData;
|
|
12
|
+
}
|
|
13
|
+
// Handle arrays
|
|
14
|
+
if (Array.isArray(oldData) && Array.isArray(newData)) {
|
|
15
|
+
return oldData.length === newData.length && oldData.every((item, index) => customDeepEqual(item, newData[index]));
|
|
16
|
+
}
|
|
17
|
+
// Handle objects
|
|
18
|
+
if (oldData && newData && typeof oldData === "object" && typeof newData === "object") {
|
|
19
|
+
const keys1 = Object.keys(oldData);
|
|
20
|
+
const keys2 = Object.keys(newData);
|
|
21
|
+
return keys1.length === keys2.length && keys1.every(key => customDeepEqual(oldData[key], newData[key]));
|
|
22
|
+
}
|
|
23
|
+
// Handle primitive values
|
|
24
|
+
return oldData === newData;
|
|
25
|
+
}
|
|
11
26
|
// Hook to fetch and auto-refresh order status and transaction details
|
|
12
27
|
function useAnyspendOrderAndTransactions(isMainnet, orderId) {
|
|
13
28
|
const selectFn = (0, react_1.useCallback)((data) => {
|
|
@@ -18,12 +33,12 @@ function useAnyspendOrderAndTransactions(isMainnet, orderId) {
|
|
|
18
33
|
const { data, isLoading, refetch, error } = (0, react_query_1.useQuery)({
|
|
19
34
|
queryKey: ["getAnyspendOrderAndTransactions", orderId],
|
|
20
35
|
queryFn: () => anyspend_1.anyspendService.getOrderAndTransactions(isMainnet, orderId),
|
|
21
|
-
enabled:
|
|
36
|
+
enabled: !!orderId,
|
|
22
37
|
refetchInterval: 3000,
|
|
23
38
|
staleTime: 1000,
|
|
24
39
|
select: selectFn,
|
|
25
40
|
structuralSharing: (oldData, newData) => {
|
|
26
|
-
if ((
|
|
41
|
+
if (customDeepEqual(oldData, newData))
|
|
27
42
|
return oldData;
|
|
28
43
|
return newData;
|
|
29
44
|
},
|
|
@@ -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
|
+
}
|
|
@@ -29,6 +29,7 @@ function B3DynamicModal() {
|
|
|
29
29
|
"anySpendOrderHistory",
|
|
30
30
|
"signInWithB3",
|
|
31
31
|
"anySpendSignatureMint",
|
|
32
|
+
"AnySpendBondKit",
|
|
32
33
|
].find(type => contentType?.type === type)) {
|
|
33
34
|
contentClass += " max-h-[90dvh] overflow-y-auto no-scrollbar w-full";
|
|
34
35
|
}
|
|
@@ -39,6 +40,7 @@ function B3DynamicModal() {
|
|
|
39
40
|
"anySpendStakeB3",
|
|
40
41
|
"anySpendBuySpin",
|
|
41
42
|
"anySpendSignatureMint",
|
|
43
|
+
"AnySpendBondKit",
|
|
42
44
|
].find(type => contentType?.type === type)) {
|
|
43
45
|
// Due to the dynamic of (Pay with crypto),(Pay with fiat), we want the height fixed to 90dvh but still scrollable.
|
|
44
46
|
// NOTE: Just leave it here in case we want the fixed height
|
|
@@ -80,6 +82,8 @@ function B3DynamicModal() {
|
|
|
80
82
|
return (0, jsx_runtime_1.jsx)(react_1.AnySpendBuySpin, { ...contentType, mode: "modal" });
|
|
81
83
|
case "anySpendSignatureMint":
|
|
82
84
|
return (0, jsx_runtime_1.jsx)(react_1.AnyspendSignatureMint, { ...contentType, mode: "modal" });
|
|
85
|
+
case "anySpendBondKit":
|
|
86
|
+
return (0, jsx_runtime_1.jsx)(react_1.AnySpendBondKit, { ...contentType });
|
|
83
87
|
// Add other modal types here
|
|
84
88
|
default:
|
|
85
89
|
return null;
|
|
@@ -18,7 +18,7 @@ function SignIn(props) {
|
|
|
18
18
|
const { automaticallySetFirstEoa } = (0, react_1.useB3)();
|
|
19
19
|
const { wallet, address: globalAddress, ensName, connectedSmartWallet, connectedEOAWallet, isActiveSmartWallet, isActiveEOAWallet, smartWalletIcon, eoaWalletIcon, } = (0, react_1.useAccountWallet)();
|
|
20
20
|
const isMobile = (0, react_1.useIsMobile)();
|
|
21
|
-
const { logout } = (0, react_1.useAuthentication)(String(process.env.
|
|
21
|
+
const { logout } = (0, react_1.useAuthentication)(String(process.env.NEXT_PUBLIC_THIRDWEB_PARTNER_ID));
|
|
22
22
|
const onDisconnect = async () => {
|
|
23
23
|
await logout();
|
|
24
24
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ReactNode } from "react";
|
|
1
|
+
import React, { ReactNode } from "react";
|
|
2
2
|
interface TabsRootProps {
|
|
3
3
|
value: string;
|
|
4
4
|
onValueChange: (value: string) => void;
|
|
@@ -18,7 +18,7 @@ interface TabTriggerProps {
|
|
|
18
18
|
icon?: ReactNode;
|
|
19
19
|
disabled?: boolean;
|
|
20
20
|
}
|
|
21
|
-
export declare
|
|
21
|
+
export declare const TabTrigger: React.ForwardRefExoticComponent<TabTriggerProps & React.RefAttributes<HTMLButtonElement>>;
|
|
22
22
|
interface TabsContentProps {
|
|
23
23
|
value: string;
|
|
24
24
|
children: ReactNode;
|