@ape.swap/bonds-sdk 1.0.398 → 1.0.400
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.
|
@@ -121,10 +121,9 @@ var YourBonds = function (_a) {
|
|
|
121
121
|
}); };
|
|
122
122
|
// Fetch data for user owned bill
|
|
123
123
|
var _d = useState([]), bondData = _d[0], setBondData = _d[1];
|
|
124
|
-
var _e = useState([]),
|
|
125
|
-
var _f = useState(
|
|
126
|
-
var _g = useState(
|
|
127
|
-
var _h = useState(null), selectedBill = _h[0], setSelectedBill = _h[1];
|
|
124
|
+
var _e = useState([]), mappedUserBills = _e[0], setMappedUserBills = _e[1];
|
|
125
|
+
var _f = useState(false), isModalOpen = _f[0], setIsModalOpen = _f[1];
|
|
126
|
+
var _g = useState(null), selectedBill = _g[0], setSelectedBill = _g[1];
|
|
128
127
|
useEffect(function () {
|
|
129
128
|
axios.get('https://realtime-api.ape.bond/bonds').then(function (response) {
|
|
130
129
|
var bonds = response.data.bonds;
|
|
@@ -144,12 +143,8 @@ var YourBonds = function (_a) {
|
|
|
144
143
|
return [4 /*yield*/, Promise.all(MAINNET_CHAINS.map(function (chain) { return fetchUserOwnedBillsDataAsync(chain, account, bondData); }))];
|
|
145
144
|
case 2:
|
|
146
145
|
results = _a.sent();
|
|
147
|
-
setUserOwnedBillsData(results);
|
|
148
146
|
mappedBills = results.flat().flatMap(function (results) { return results.userOwnedBills; });
|
|
149
147
|
setMappedUserBills(mappedBills);
|
|
150
|
-
console.log('MAPPEDBILLS');
|
|
151
|
-
console.log(mappedBills);
|
|
152
|
-
console.log('MAPPEDBILLS');
|
|
153
148
|
return [3 /*break*/, 4];
|
|
154
149
|
case 3:
|
|
155
150
|
error_2 = _a.sent();
|
|
@@ -160,9 +155,9 @@ var YourBonds = function (_a) {
|
|
|
160
155
|
});
|
|
161
156
|
}); };
|
|
162
157
|
fetchData();
|
|
163
|
-
}, [account
|
|
164
|
-
var
|
|
165
|
-
var
|
|
158
|
+
}, [account]);
|
|
159
|
+
var _h = useState(null), sortConfig = _h[0], setSortConfig = _h[1];
|
|
160
|
+
var _j = useState(mappedUserBills), sortedBonds = _j[0], setSortedBonds = _j[1];
|
|
166
161
|
var handleSort = function (key) {
|
|
167
162
|
var direction = 'asc';
|
|
168
163
|
if ((sortConfig === null || sortConfig === void 0 ? void 0 : sortConfig.key) === key && (sortConfig === null || sortConfig === void 0 ? void 0 : sortConfig.direction) === 'asc') {
|
|
@@ -196,8 +191,14 @@ var YourBonds = function (_a) {
|
|
|
196
191
|
bValue = parseFloat(totalPending(b).toFixed(0));
|
|
197
192
|
}
|
|
198
193
|
else if (sortConfig.key === 'terms') {
|
|
199
|
-
|
|
200
|
-
|
|
194
|
+
var aRemainingTime = vestingTimeRemaining(a).days * 24 * 3600 +
|
|
195
|
+
vestingTimeRemaining(a).hours * 3600 +
|
|
196
|
+
vestingTimeRemaining(a).minutes * 60;
|
|
197
|
+
var bRemainingTime = vestingTimeRemaining(b).days * 24 * 3600 +
|
|
198
|
+
vestingTimeRemaining(b).hours * 3600 +
|
|
199
|
+
vestingTimeRemaining(b).minutes * 60;
|
|
200
|
+
aValue = aRemainingTime;
|
|
201
|
+
bValue = bRemainingTime;
|
|
201
202
|
}
|
|
202
203
|
else {
|
|
203
204
|
aValue = a[sortConfig.key];
|
|
@@ -213,11 +214,6 @@ var YourBonds = function (_a) {
|
|
|
213
214
|
});
|
|
214
215
|
setSortedBonds(sorted);
|
|
215
216
|
}, [sortConfig, mappedUserBills]);
|
|
216
|
-
var rowClick = function (bill) {
|
|
217
|
-
setSelectedBill(bill);
|
|
218
|
-
setIsModalOpen(true);
|
|
219
|
-
navigate("/YourBonds/?bondAddress=".concat(bill.address, "&bondChain=").concat(bill.bond.chainId), { replace: true });
|
|
220
|
-
};
|
|
221
217
|
// Functions to calculate display values for each row
|
|
222
218
|
var chainId = useWeb3React().chainId;
|
|
223
219
|
var currentTime = useCurrentTime() / 1000;
|
|
@@ -236,15 +232,20 @@ var YourBonds = function (_a) {
|
|
|
236
232
|
var _a;
|
|
237
233
|
return getFirstNonZeroDigits(parseFloat((_a = bond === null || bond === void 0 ? void 0 : bond.payoutTokenPrice) !== null && _a !== void 0 ? _a : '0'));
|
|
238
234
|
};
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
235
|
+
var rowClick = function (bill) {
|
|
236
|
+
setSelectedBill(bill);
|
|
237
|
+
setIsModalOpen(true);
|
|
238
|
+
navigate("/YourBonds/?bondAddress=".concat(bill.address, "&bondChain=").concat(bill.bond.chainId), { replace: true });
|
|
239
|
+
};
|
|
240
|
+
return (_jsxs(ThemeUIProvider, __assign({ theme: defaultTheme }, { children: [isActive && account && _jsx("p", { children: account }), isActive && account && _jsx("button", __assign({ onClick: handleApprove }, { children: "Approve USDT" })), _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 column-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 column-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 column-term" }, { 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 column-claimall" }, { children: _jsx(Flex, __assign({ className: "column-claimall button" }, { children: _jsx(Button, __assign({ disabled: !account, sx: {
|
|
241
|
+
height: ['36px', '36px', '36px', '26px'],
|
|
242
|
+
lineHeight: '12px',
|
|
243
|
+
fontSize: '14px',
|
|
244
|
+
fontWeight: 600,
|
|
245
|
+
width: '100%',
|
|
246
|
+
} }, { children: "Claim" })) })) }))] }))] })), sortedBonds.map(function (bill) {
|
|
246
247
|
var _a, _b;
|
|
247
|
-
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), "($".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), "($".concat((totalPending(bill) * ((_b = parseFloat(earnTokenPrice(bill.bond))) !== null && _b !== void 0 ? _b : 0)).toFixed(2), ")")] })), _jsx(Flex, __assign({ className: "column column-
|
|
248
|
+
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(Flex, __assign({ className: "column-claimall button" }, { children: _jsx(Button, __assign({ disabled: !account, sx: {
|
|
248
249
|
height: ['36px', '36px', '36px', '26px'],
|
|
249
250
|
lineHeight: '12px',
|
|
250
251
|
fontSize: '14px',
|
package/dist/scss/YourBonds.scss
CHANGED
|
@@ -65,21 +65,21 @@
|
|
|
65
65
|
}
|
|
66
66
|
|
|
67
67
|
.column.column-claimable {
|
|
68
|
-
flex-direction:
|
|
68
|
+
flex-direction: row;
|
|
69
69
|
justify-content: center;
|
|
70
70
|
align-items: center;
|
|
71
71
|
width: 20%;
|
|
72
72
|
}
|
|
73
73
|
|
|
74
74
|
.column.column-pending {
|
|
75
|
-
flex-direction:
|
|
75
|
+
flex-direction: row;
|
|
76
76
|
justify-content: center;
|
|
77
77
|
align-items: center;
|
|
78
78
|
width: 20%;
|
|
79
79
|
}
|
|
80
80
|
|
|
81
|
-
.column.column-
|
|
82
|
-
flex-direction:
|
|
81
|
+
.column.column-terms {
|
|
82
|
+
flex-direction: row;
|
|
83
83
|
justify-content: center;
|
|
84
84
|
align-items: center;
|
|
85
85
|
width: 20%;
|