@ape.swap/bonds-sdk 1.0.468 → 1.0.470
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.
|
@@ -77,9 +77,9 @@ import axios from 'axios';
|
|
|
77
77
|
import { fetchUserOwnedBillsDataAsync } from './fetchBillsUser';
|
|
78
78
|
import { Input } from '../../components/uikit-sdk/Input';
|
|
79
79
|
var YourBonds = function (_a) {
|
|
80
|
-
var
|
|
81
|
-
|
|
82
|
-
var
|
|
80
|
+
var account = _a.account, accountChainId = _a.accountChainId, isActive = _a.isActive;
|
|
81
|
+
// const { account, isActive } = useWeb3React();
|
|
82
|
+
var _b = useSearchParams(), searchParams = _b[0], setSearchParams = _b[1];
|
|
83
83
|
var navigate = useNavigate();
|
|
84
84
|
var USDT_ABI = [
|
|
85
85
|
// The ERC-20 approve function ABI
|
|
@@ -121,8 +121,8 @@ var YourBonds = function (_a) {
|
|
|
121
121
|
});
|
|
122
122
|
}); };
|
|
123
123
|
// Fetch data
|
|
124
|
-
var
|
|
125
|
-
var
|
|
124
|
+
var _c = useState([]), bondData = _c[0], setBondData = _c[1];
|
|
125
|
+
var _d = useState([]), mappedUserBills = _d[0], setMappedUserBills = _d[1];
|
|
126
126
|
useEffect(function () {
|
|
127
127
|
axios.get('https://realtime-api.ape.bond/bonds').then(function (response) {
|
|
128
128
|
var bonds = response.data.bonds;
|
|
@@ -135,6 +135,8 @@ var YourBonds = function (_a) {
|
|
|
135
135
|
return __generator(this, function (_a) {
|
|
136
136
|
switch (_a.label) {
|
|
137
137
|
case 0:
|
|
138
|
+
console.log("ACCOUNT");
|
|
139
|
+
console.log(account);
|
|
138
140
|
if (!account) return [3 /*break*/, 4];
|
|
139
141
|
_a.label = 1;
|
|
140
142
|
case 1:
|
|
@@ -144,6 +146,7 @@ var YourBonds = function (_a) {
|
|
|
144
146
|
results = _a.sent();
|
|
145
147
|
mappedBills = results.flat().flatMap(function (results) { return results.userOwnedBills; });
|
|
146
148
|
setMappedUserBills(mappedBills);
|
|
149
|
+
console.log('User owned bills data:', mappedBills);
|
|
147
150
|
return [3 /*break*/, 4];
|
|
148
151
|
case 3:
|
|
149
152
|
error_2 = _a.sent();
|
|
@@ -155,8 +158,8 @@ var YourBonds = function (_a) {
|
|
|
155
158
|
}); };
|
|
156
159
|
fetchData();
|
|
157
160
|
}, [account]);
|
|
158
|
-
var
|
|
159
|
-
var
|
|
161
|
+
var _e = useState(null), sortConfig = _e[0], setSortConfig = _e[1];
|
|
162
|
+
var _f = useState(mappedUserBills), sortedBonds = _f[0], setSortedBonds = _f[1];
|
|
160
163
|
var handleSort = function (key) {
|
|
161
164
|
var direction = 'asc';
|
|
162
165
|
if ((sortConfig === null || sortConfig === void 0 ? void 0 : sortConfig.key) === key && (sortConfig === null || sortConfig === void 0 ? void 0 : sortConfig.direction) === 'asc') {
|
|
@@ -237,16 +240,16 @@ var YourBonds = function (_a) {
|
|
|
237
240
|
return getFirstNonZeroDigits(parseFloat((_a = bond === null || bond === void 0 ? void 0 : bond.payoutTokenPrice) !== null && _a !== void 0 ? _a : '0'));
|
|
238
241
|
};
|
|
239
242
|
// Modal
|
|
240
|
-
var
|
|
241
|
-
var
|
|
243
|
+
var _g = useState(false), isModalOpen = _g[0], setIsModalOpen = _g[1];
|
|
244
|
+
var _h = useState(null), selectedBill = _h[0], setSelectedBill = _h[1];
|
|
242
245
|
var rowClick = function (bill) {
|
|
243
246
|
setSelectedBill(bill);
|
|
244
247
|
setIsModalOpen(true);
|
|
245
248
|
navigate("/YourBonds/?bondAddress=".concat(bill.address, "&bondChain=").concat(bill.bond.chainId), { replace: true });
|
|
246
249
|
};
|
|
247
250
|
// Search logic
|
|
248
|
-
var
|
|
249
|
-
var
|
|
251
|
+
var _j = useState(''), inputValue = _j[0], setInputValue = _j[1];
|
|
252
|
+
var _k = useState(sortedBonds), filteredBonds = _k[0], setFilteredBonds = _k[1];
|
|
250
253
|
useEffect(function () {
|
|
251
254
|
if (inputValue === '') {
|
|
252
255
|
setFilteredBonds(sortedBonds);
|
|
@@ -261,30 +264,30 @@ var YourBonds = function (_a) {
|
|
|
261
264
|
setInputValue(event.target.value);
|
|
262
265
|
};
|
|
263
266
|
// Page render logic
|
|
264
|
-
var
|
|
267
|
+
var _l = useState(false), bondsRendered = _l[0], setBondsRendered = _l[1];
|
|
265
268
|
useEffect(function () {
|
|
266
269
|
if (filteredBonds.length > 0) {
|
|
267
270
|
setBondsRendered(true);
|
|
268
271
|
}
|
|
269
272
|
}, [filteredBonds]);
|
|
270
|
-
return (
|
|
273
|
+
return (_jsx(ThemeUIProvider, __assign({ theme: defaultTheme }, { children: bondsRendered && (_jsxs(Flex, __assign({ className: "container table-container" }, { children: [_jsxs(Flex, __assign({ className: "container header-container" }, { children: [_jsx(Flex, __assign({ className: "column column-tokens" }, { children: _jsx(Flex, __assign({ className: "column column-search", sx: { width: '100%', maxWidth: ['200px', '200px', '200px', '340px'] } }, { children: _jsx(Input, { value: inputValue, onChange: handleInputChange, variant: "search", sx: { fontWeight: 400, background: 'white2', height: '30px', fontSize: '14px', color: 'white' }, width: '100%', placeholder: 'Search...' }) })) })), _jsxs(Flex, __assign({ className: "column column-bondinfo" }, { children: [_jsxs(Flex, __assign({ className: "column header-claimable" }, { children: [_jsx(Text, __assign({ sx: { fontSize: '11px', color: 'textDisabledButton' } }, { children: "CLAIMABLE" })), _jsx(Flex, __assign({ className: "column header-icon", onClick: function () { return handleSort('claimable'); } }, { children: _jsx(Svg, { icon: "sort", width: "12px", color: "textDisabledButton" }) }))] })), _jsxs(Flex, __assign({ className: "column header-pending" }, { children: [_jsx(Text, __assign({ sx: { fontSize: '11px', color: 'textDisabledButton' } }, { children: "PENDING" })), _jsx(Flex, __assign({ className: "column header-icon", onClick: function () { return handleSort('pending'); } }, { children: _jsx(Svg, { icon: "sort", width: "12px", color: "textDisabledButton" }) }))] })), _jsxs(Flex, __assign({ className: "column header-terms" }, { children: [_jsx(Text, __assign({ sx: { fontSize: '11px', color: 'textDisabledButton' } }, { children: "TERMS" })), _jsx(Flex, __assign({ className: "column header-icon", onClick: function () { return handleSort('terms'); } }, { children: _jsx(Svg, { icon: "sort", width: "12px", color: "textDisabledButton" }) }))] })), _jsx(Flex, __assign({ className: "column header-claimall" }, { children: _jsx(Button, __assign({ disabled: !account && !hasPendingRewards(filteredBonds), sx: {
|
|
274
|
+
height: ['36px', '36px', '36px', '26px'],
|
|
275
|
+
lineHeight: '12px',
|
|
276
|
+
fontSize: '14px',
|
|
277
|
+
fontWeight: 600,
|
|
278
|
+
width: '100%',
|
|
279
|
+
} }, { children: "CLAIM ALL" })) }))] }))] })), filteredBonds.map(function (bill) {
|
|
280
|
+
var _a, _b;
|
|
281
|
+
return (_jsxs(Flex, __assign({ className: "container bondrow-container", onClick: function () { return rowClick(bill); } }, { children: [_jsx(Flex, __assign({ className: "column column-tokens" }, { children: _jsx(Flex, __assign({ className: "column column-tokeninfoname" }, { children: _jsx(TokenInfoAndName, { bill: bill.bond, vestEnds: "Ends in ".concat(getPendingVesting(bill.lastBlockTimestamp, bill.vesting)) }) })) })), _jsxs(Flex, __assign({ className: "column column-bondinfo" }, { children: [_jsxs(Flex, __assign({ className: "column column-claimable" }, { children: [formatNumberSI(parseFloat(claimable(bill).toFixed(3)), 0), _jsx(Text, __assign({ sx: { opacity: '0.6', fontSize: '12px', paddingLeft: '5px' } }, { children: "($".concat((claimable(bill) * ((_a = parseFloat(earnTokenPrice(bill.bond))) !== null && _a !== void 0 ? _a : 0)).toFixed(2), ")") }))] })), _jsxs(Flex, __assign({ className: "column column-pending" }, { children: [formatNumberSI(parseFloat(totalPending(bill).toFixed(0)), 0), _jsx(Text, __assign({ sx: { opacity: '0.6', fontSize: '12px', paddingLeft: '5px' } }, { children: "($".concat((totalPending(bill) * ((_b = parseFloat(earnTokenPrice(bill.bond))) !== null && _b !== void 0 ? _b : 0)).toFixed(2), ")") }))] })), _jsx(Flex, __assign({ className: "column column-terms" }, { children: "".concat(vestingTimeRemaining(bill).days, "d, ").concat(vestingTimeRemaining(bill).hours, "h, ").concat(vestingTimeRemaining(bill).minutes, "m") })), _jsx(Flex, __assign({ className: "column column-claimall" }, { children: _jsx(Button, __assign({ disabled: !account && (claimableNumber(bill) === 0), onClick: function (event) {
|
|
282
|
+
event.stopPropagation();
|
|
283
|
+
// Add your claim logic here
|
|
284
|
+
}, sx: {
|
|
271
285
|
height: ['36px', '36px', '36px', '26px'],
|
|
272
286
|
lineHeight: '12px',
|
|
273
287
|
fontSize: '14px',
|
|
274
288
|
fontWeight: 600,
|
|
275
289
|
width: '100%',
|
|
276
|
-
} }, { children: "
|
|
277
|
-
|
|
278
|
-
return (_jsxs(Flex, __assign({ className: "container bondrow-container", onClick: function () { return rowClick(bill); } }, { children: [_jsx(Flex, __assign({ className: "column column-tokens" }, { children: _jsx(Flex, __assign({ className: "column column-tokeninfoname" }, { children: _jsx(TokenInfoAndName, { bill: bill.bond, vestEnds: "Ends in ".concat(getPendingVesting(bill.lastBlockTimestamp, bill.vesting)) }) })) })), _jsxs(Flex, __assign({ className: "column column-bondinfo" }, { children: [_jsxs(Flex, __assign({ className: "column column-claimable" }, { children: [formatNumberSI(parseFloat(claimable(bill).toFixed(3)), 0), _jsx(Text, __assign({ sx: { opacity: '0.6', fontSize: '12px', paddingLeft: '5px' } }, { children: "($".concat((claimable(bill) * ((_a = parseFloat(earnTokenPrice(bill.bond))) !== null && _a !== void 0 ? _a : 0)).toFixed(2), ")") }))] })), _jsxs(Flex, __assign({ className: "column column-pending" }, { children: [formatNumberSI(parseFloat(totalPending(bill).toFixed(0)), 0), _jsx(Text, __assign({ sx: { opacity: '0.6', fontSize: '12px', paddingLeft: '5px' } }, { children: "($".concat((totalPending(bill) * ((_b = parseFloat(earnTokenPrice(bill.bond))) !== null && _b !== void 0 ? _b : 0)).toFixed(2), ")") }))] })), _jsx(Flex, __assign({ className: "column column-terms" }, { children: "".concat(vestingTimeRemaining(bill).days, "d, ").concat(vestingTimeRemaining(bill).hours, "h, ").concat(vestingTimeRemaining(bill).minutes, "m") })), _jsx(Flex, __assign({ className: "column column-claimall" }, { children: _jsx(Button, __assign({ disabled: !account && (claimableNumber(bill) === 0), onClick: function (event) {
|
|
279
|
-
event.stopPropagation();
|
|
280
|
-
// Add your claim logic here
|
|
281
|
-
}, sx: {
|
|
282
|
-
height: ['36px', '36px', '36px', '26px'],
|
|
283
|
-
lineHeight: '12px',
|
|
284
|
-
fontSize: '14px',
|
|
285
|
-
fontWeight: 600,
|
|
286
|
-
width: '100%',
|
|
287
|
-
} }, { children: "Claim" })) }))] }))] }), bill.bond.billAddress));
|
|
288
|
-
})] })))] })));
|
|
290
|
+
} }, { children: "Claim" })) }))] }))] }), bill.bond.billAddress));
|
|
291
|
+
})] }))) })));
|
|
289
292
|
};
|
|
290
293
|
export default YourBonds;
|