@ape.swap/bonds-sdk 1.0.424 → 1.0.426

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.
@@ -75,6 +75,7 @@ import useCurrentTime from '../../hooks/useTimer';
75
75
  import { getPendingVesting } from '../../hooks/usePendingVesting';
76
76
  import axios from 'axios';
77
77
  import { fetchUserOwnedBillsDataAsync } from './fetchBillsUser';
78
+ import { Input } from '../uikit-sdk/Input';
78
79
  var YourBonds = function (_a) {
79
80
  var connectionString = _a.connectionString;
80
81
  var _b = useWeb3React(), account = _b.account, isActive = _b.isActive;
@@ -119,7 +120,7 @@ var YourBonds = function (_a) {
119
120
  }
120
121
  });
121
122
  }); };
122
- // Fetch data for user owned bill
123
+ // Fetch data
123
124
  var _d = useState([]), bondData = _d[0], setBondData = _d[1];
124
125
  var _e = useState([]), mappedUserBills = _e[0], setMappedUserBills = _e[1];
125
126
  useEffect(function () {
@@ -209,7 +210,7 @@ var YourBonds = function (_a) {
209
210
  });
210
211
  setSortedBonds(sorted);
211
212
  }, [sortConfig, mappedUserBills]);
212
- // Functions to calculate display values for each row
213
+ // Functions for calculations
213
214
  var chainId = useWeb3React().chainId;
214
215
  var currentTime = useCurrentTime() / 1000;
215
216
  var vestingTimeRemaining = function (userBill) {
@@ -223,6 +224,14 @@ var YourBonds = function (_a) {
223
224
  var _a, _b, _c;
224
225
  return getBalanceNumber(new BigNumber(userBill.pendingRewards), (_c = (_b = (_a = userBill.bond.earnToken) === null || _a === void 0 ? void 0 : _a.decimals) === null || _b === void 0 ? void 0 : _b[chainId]) !== null && _c !== void 0 ? _c : 18);
225
226
  };
227
+ var claimableNumber = function (userBill) {
228
+ var _a;
229
+ var val = (claimable(userBill) * ((_a = parseFloat(earnTokenPrice(userBill.bond))) !== null && _a !== void 0 ? _a : 0));
230
+ return val !== null && val !== void 0 ? val : 0;
231
+ };
232
+ var hasPendingRewards = function (bills) {
233
+ return bills.some(function (bill) { return parseFloat(bill.pendingRewards) > 0; });
234
+ };
226
235
  var earnTokenPrice = function (bond) {
227
236
  var _a;
228
237
  return getFirstNonZeroDigits(parseFloat((_a = bond === null || bond === void 0 ? void 0 : bond.payoutTokenPrice) !== null && _a !== void 0 ? _a : '0'));
@@ -235,21 +244,38 @@ var YourBonds = function (_a) {
235
244
  setIsModalOpen(true);
236
245
  navigate("/YourBonds/?bondAddress=".concat(bill.address, "&bondChain=").concat(bill.bond.chainId), { replace: true });
237
246
  };
238
- var _k = useState(false), bondsRendered = _k[0], setBondsRendered = _k[1];
247
+ // Search logic
248
+ var _k = useState(''), inputValue = _k[0], setInputValue = _k[1];
249
+ var _l = useState(sortedBonds), filteredBonds = _l[0], setFilteredBonds = _l[1];
250
+ useEffect(function () {
251
+ if (inputValue === '') {
252
+ setFilteredBonds(sortedBonds);
253
+ }
254
+ else {
255
+ setFilteredBonds(sortedBonds.filter(function (bond) {
256
+ return bond.bond.showcaseTokenName.toLowerCase().includes(inputValue.toLowerCase());
257
+ }));
258
+ }
259
+ }, [inputValue, sortedBonds]);
260
+ var handleInputChange = function (event) {
261
+ setInputValue(event.target.value);
262
+ };
263
+ // Page render logic
264
+ var _m = useState(false), bondsRendered = _m[0], setBondsRendered = _m[1];
239
265
  useEffect(function () {
240
- if (sortedBonds.length > 0) {
266
+ if (filteredBonds.length > 0) {
241
267
  setBondsRendered(true);
242
268
  }
243
- }, [sortedBonds]);
244
- return (_jsxs(ThemeUIProvider, __assign({ theme: defaultTheme }, { children: [isActive && account && _jsx("p", { children: account }), isActive && account && _jsx("button", __assign({ onClick: handleApprove }, { children: "Approve USDT" })), 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, { className: "column column-tokeninfoname" }) })), _jsxs(Flex, __assign({ className: "column column-bondinfo" }, { children: [_jsxs(Flex, __assign({ className: "column header-claimable" }, { children: [_jsx(Text, __assign({ sx: { opacity: '0.6', fontSize: '12px' } }, { children: "Claimable" })), _jsx(Flex, __assign({ className: "column header-icon", sx: { opacity: '0.6' }, onClick: function () { return handleSort('claimable'); } }, { children: _jsx(Svg, { icon: "sort", width: "12px" }) }))] })), _jsxs(Flex, __assign({ className: "column header-pending" }, { children: [_jsx(Text, __assign({ sx: { opacity: '0.6', fontSize: '12px' } }, { children: "Pending" })), _jsx(Flex, __assign({ className: "column header-icon", sx: { opacity: '0.6' }, onClick: function () { return handleSort('pending'); } }, { children: _jsx(Svg, { icon: "sort", width: "12px" }) }))] })), _jsxs(Flex, __assign({ className: "column header-terms" }, { children: [_jsx(Text, __assign({ sx: { opacity: '0.6', fontSize: '12px' } }, { children: "Terms" })), _jsx(Flex, __assign({ className: "column header-icon", sx: { opacity: '0.6' }, onClick: function () { return handleSort('terms'); } }, { children: _jsx(Svg, { icon: "sort", width: "12px" }) }))] })), _jsx(Flex, __assign({ className: "column header-claimall" }, { children: _jsx(Button, __assign({ disabled: !account, sx: {
269
+ }, [filteredBonds]);
270
+ return (_jsxs(ThemeUIProvider, __assign({ theme: defaultTheme }, { children: [isActive && account && _jsx("p", { children: account }), isActive && account && _jsx("button", __assign({ onClick: handleApprove }, { children: "Approve USDT" })), 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' }, width: '100%', placeholder: 'Search...' }) })) })), _jsxs(Flex, __assign({ className: "column column-bondinfo" }, { children: [_jsxs(Flex, __assign({ className: "column header-claimable" }, { children: [_jsx(Text, __assign({ sx: { opacity: '0.6', fontSize: '12px' } }, { children: "Claimable" })), _jsx(Flex, __assign({ className: "column header-icon", sx: { opacity: '0.6' }, onClick: function () { return handleSort('claimable'); } }, { children: _jsx(Svg, { icon: "sort", width: "12px" }) }))] })), _jsxs(Flex, __assign({ className: "column header-pending" }, { children: [_jsx(Text, __assign({ sx: { opacity: '0.6', fontSize: '12px' } }, { children: "Pending" })), _jsx(Flex, __assign({ className: "column header-icon", sx: { opacity: '0.6' }, onClick: function () { return handleSort('pending'); } }, { children: _jsx(Svg, { icon: "sort", width: "12px" }) }))] })), _jsxs(Flex, __assign({ className: "column header-terms" }, { children: [_jsx(Text, __assign({ sx: { opacity: '0.6', fontSize: '12px' } }, { children: "Terms" })), _jsx(Flex, __assign({ className: "column header-icon", sx: { opacity: '0.6' }, onClick: function () { return handleSort('terms'); } }, { children: _jsx(Svg, { icon: "sort", width: "12px" }) }))] })), _jsx(Flex, __assign({ className: "column header-claimall" }, { children: _jsx(Button, __assign({ disabled: !account && !hasPendingRewards(filteredBonds), sx: {
245
271
  height: ['36px', '36px', '36px', '26px'],
246
272
  lineHeight: '12px',
247
273
  fontSize: '14px',
248
274
  fontWeight: 600,
249
275
  width: '100%',
250
- } }, { children: "CLAIM ALL" })) }))] }))] })), sortedBonds.map(function (bill) {
276
+ } }, { children: "CLAIM ALL" })) }))] }))] })), filteredBonds.map(function (bill) {
251
277
  var _a, _b;
252
- 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, onClick: function (event) {
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) {
253
279
  event.stopPropagation();
254
280
  // Add your claim logic here
255
281
  }, sx: {
@@ -49,6 +49,10 @@
49
49
  width: 40%;
50
50
  }
51
51
 
52
+ .column.column-search {
53
+ padding-bottom: 15px;
54
+ }
55
+
52
56
  .column.column-tokeninfoname {
53
57
  width: 100%;
54
58
  height: 100%;
@@ -43,6 +43,10 @@
43
43
  width: 40%;
44
44
  }
45
45
 
46
+ .column.column-search {
47
+ padding-bottom: 15px;
48
+ }
49
+
46
50
  .column.column-tokeninfoname {
47
51
  width: 100%;
48
52
  height: 100%;
@@ -85,6 +89,7 @@
85
89
  align-items: center;
86
90
  width: 30%;
87
91
  padding-right: 20px;
92
+ padding-bottom: 15px;
88
93
  }
89
94
 
90
95
  .column.column-claimable {
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "description": "Ape Bond SDK",
4
4
  "author": "Ape Bond",
5
5
  "license": "MIT",
6
- "version": "1.0.424",
6
+ "version": "1.0.426",
7
7
  "main": "dist/index.js",
8
8
  "module": "dist/index.es.js",
9
9
  "types": "dist/index.d.ts",