@ape.swap/bonds-sdk 1.0.0 → 1.0.1
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/index.js +27 -3
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/index.js +27 -3
- package/dist/esm/index.js.map +1 -1
- package/package.json +1 -1
package/dist/esm/index.js
CHANGED
|
@@ -80,6 +80,16 @@ function __generator(thisArg, body) {
|
|
|
80
80
|
}
|
|
81
81
|
}
|
|
82
82
|
|
|
83
|
+
function __spreadArray(to, from, pack) {
|
|
84
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
85
|
+
if (ar || !(i in from)) {
|
|
86
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
87
|
+
ar[i] = from[i];
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
91
|
+
}
|
|
92
|
+
|
|
83
93
|
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
84
94
|
var e = new Error(message);
|
|
85
95
|
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
@@ -15320,7 +15330,7 @@ var AvailableFeesComponent = function (_a) {
|
|
|
15320
15330
|
var _c = useState(availableChains[0]), chain = _c[0], setChain = _c[1];
|
|
15321
15331
|
var _d = useState('0x0000000000000000000000000000000000000000'), address = _d[0], setAddress = _d[1];
|
|
15322
15332
|
var feesForSelectedChain = (_b = availableFees === null || availableFees === void 0 ? void 0 : availableFees.feeBalances.find(function (c) { return c.chainId === chain; })) === null || _b === void 0 ? void 0 : _b.tokenBalances;
|
|
15323
|
-
var filteredFees = feesForSelectedChain.filter(function (fees) { return parseFloat(fees.amountUsd) >
|
|
15333
|
+
var filteredFees = feesForSelectedChain.filter(function (fees) { return parseFloat(fees.amountUsd) > 10; });
|
|
15324
15334
|
// Data for the TX request to LiFi smartcontract
|
|
15325
15335
|
var _e = useState(''), data = _e[0], setData = _e[1];
|
|
15326
15336
|
var _f = useState(''), to = _f[0], setTo = _f[1];
|
|
@@ -15345,6 +15355,7 @@ var AvailableFeesComponent = function (_a) {
|
|
|
15345
15355
|
console.error(error);
|
|
15346
15356
|
});
|
|
15347
15357
|
}, [options]);
|
|
15358
|
+
var _g = useState([]), claimedTokens = _g[0], setClaimedTokens = _g[1];
|
|
15348
15359
|
var sendTransactionRequest = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
15349
15360
|
var tx;
|
|
15350
15361
|
return __generator(this, function (_a) {
|
|
@@ -15360,6 +15371,9 @@ var AvailableFeesComponent = function (_a) {
|
|
|
15360
15371
|
.sendTransaction({
|
|
15361
15372
|
to: to,
|
|
15362
15373
|
data: data,
|
|
15374
|
+
})
|
|
15375
|
+
.then(function () {
|
|
15376
|
+
setClaimedTokens(function (prevTokens) { return __spreadArray(__spreadArray([], prevTokens, true), [address], false); });
|
|
15363
15377
|
})
|
|
15364
15378
|
.catch(function (e) {
|
|
15365
15379
|
console.log(e);
|
|
@@ -15377,12 +15391,22 @@ var AvailableFeesComponent = function (_a) {
|
|
|
15377
15391
|
setData('');
|
|
15378
15392
|
setAddress(address);
|
|
15379
15393
|
};
|
|
15394
|
+
var _h = useState(null), tokens = _h[0], setTokens = _h[1];
|
|
15395
|
+
useEffect(function () {
|
|
15396
|
+
axios.get('https://raw.githubusercontent.com/ApeSwapFinance/apeswap-lists/main/config/tokens.json').then(function (response) {
|
|
15397
|
+
setTokens(response.data);
|
|
15398
|
+
});
|
|
15399
|
+
}, []);
|
|
15400
|
+
var exists = Object.values(tokens !== null && tokens !== void 0 ? tokens : {}).some(function (token) { var _a, _b; return ((_b = (_a = token === null || token === void 0 ? void 0 : token.address) === null || _a === void 0 ? void 0 : _a[chain]) === null || _b === void 0 ? void 0 : _b.toLowerCase()) === (address === null || address === void 0 ? void 0 : address.toLowerCase()) || (address === null || address === void 0 ? void 0 : address.toLowerCase()) === '0x0000000000000000000000000000000000000000'; });
|
|
15401
|
+
useEffect(function () {
|
|
15402
|
+
setClaimedTokens([]);
|
|
15403
|
+
}, [chain]);
|
|
15380
15404
|
return (jsxs(Flex, { sx: { mt: '10px', flexDirection: 'column' }, children: [jsx(Text, { children: "SelectChain:" }), jsx(Flex, { sx: { width: '100px' }, children: jsx(Dropdown, { size: "sm", component: jsx(DropdownItem, { size: "sm", sx: { width: '100%' }, children: jsx(Flex, { sx: { width: '100%' }, children: chain }) }), sx: { background: 'white4', display: 'flex', alignItems: 'center' }, children: availableChains.map(function (chain, i) {
|
|
15381
15405
|
return (jsx(DropdownItem, { size: "sm", onClick: function () { return setChain(availableChains[i]); }, sx: { width: '100%' }, children: jsx(Flex, { sx: { width: '100%' }, children: chain }) }, chain));
|
|
15382
15406
|
}) }) }), jsxs(Flex, { sx: { position: 'relative' }, children: [jsxs(Flex, { sx: { flexDirection: 'column', width: '300px' }, children: [jsx(Text, { sx: { my: '15px' }, children: " Available fees to collect: " }), filteredFees.map(function (fee) {
|
|
15383
15407
|
var _a;
|
|
15384
|
-
return (jsxs(Flex, { sx: { justifyContent: 'space-between' }, children: [jsx(Text, { sx: { fontSize: '14px', fontWeight: 400, width: '100px' }, children: (_a = fee.token.coinKey) !== null && _a !== void 0 ? _a : fee.token.symbol }), jsxs(Text, { sx: { fontSize: '14px', fontWeight: 400, width: '75px' }, children: ["$", fee.amountUsd] }), jsx(Button, { onClick: function () { return handleAddressChange(fee.token.address); }, sx: { fontSize: '12px', fontWeight: 500, height: '20px' }, children: "Select" })] }, fee.token.address));
|
|
15385
|
-
})] }), jsx(Flex, { sx: { mt: '10px', ml: '20px' }, children: jsxs(Flex, { sx: { flexDirection: 'column', position: 'sticky', top:
|
|
15408
|
+
return (jsxs(Flex, { sx: { justifyContent: 'space-between' }, children: [jsx(Text, { sx: { fontSize: '14px', fontWeight: 400, width: '100px' }, children: (_a = fee.token.coinKey) !== null && _a !== void 0 ? _a : fee.token.symbol }), jsxs(Text, { sx: { fontSize: '14px', fontWeight: 400, width: '75px' }, children: ["$", fee.amountUsd] }), jsx(Button, { onClick: function () { return handleAddressChange(fee.token.address); }, sx: { fontSize: '12px', fontWeight: 500, height: '20px' }, disabled: claimedTokens.length > 0 ? claimedTokens === null || claimedTokens === void 0 ? void 0 : claimedTokens.some(function (claimedToken) { var _a, _b; return claimedToken.toLowerCase() === ((_b = (_a = fee === null || fee === void 0 ? void 0 : fee.token) === null || _a === void 0 ? void 0 : _a.address) === null || _b === void 0 ? void 0 : _b.toLowerCase()); }) : false, children: "Select" })] }, fee.token.address));
|
|
15409
|
+
})] }), jsx(Flex, { sx: { mt: '10px', ml: '20px' }, children: jsxs(Flex, { sx: { flexDirection: 'column', position: 'sticky', top: '75px', height: 'fit-content' }, children: [jsxs(Text, { sx: { fontSize: '12px', fontWeight: 500 }, children: ["Token Address: ", address] }), jsxs(Text, { sx: { fontSize: '12px', fontWeight: 500 }, children: ["Exists in token list:", jsx(Text, { sx: { color: exists ? 'success' : 'error', ml: '10px' }, children: exists.toString() })] }), jsx(Button, { onClick: sendTransactionRequest, children: "Collect!" })] }) })] })] }));
|
|
15386
15410
|
};
|
|
15387
15411
|
|
|
15388
15412
|
var colorScheme = {
|