@ape.swap/bonds-sdk 1.0.342 → 1.0.344
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/components/YourBonds/YourBonds.js +41 -13
- package/dist/components/YourBonds/fetchBillsUser.d.ts +2 -2
- package/dist/components/YourBonds/fetchBillsUser.js +3 -3
- package/dist/state/bills/index.d.ts +10 -1
- package/dist/state/bills/index.js +3 -2
- package/dist/types/yourbonds.d.ts +4 -0
- package/package.json +1 -1
|
@@ -45,6 +45,15 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
45
45
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
46
46
|
}
|
|
47
47
|
};
|
|
48
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
49
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
50
|
+
if (ar || !(i in from)) {
|
|
51
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
52
|
+
ar[i] = from[i];
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
56
|
+
};
|
|
48
57
|
import { jsx as _jsx, jsxs as _jsxs } from "theme-ui/jsx-runtime";
|
|
49
58
|
/** @jsxImportSource theme-ui */
|
|
50
59
|
import { useEffect, useState } from 'react';
|
|
@@ -69,7 +78,7 @@ import { formatNumberSI } from '../../utils/formatNumber';
|
|
|
69
78
|
import useCurrentTime from '../../hooks/useTimer';
|
|
70
79
|
import { getPendingVesting } from '../../hooks/usePendingVesting';
|
|
71
80
|
import axios from 'axios';
|
|
72
|
-
import {
|
|
81
|
+
import { fetchUserOwnedBillNftData } from './fetchBillsUser';
|
|
73
82
|
var YourBonds = function (_a) {
|
|
74
83
|
var connectionString = _a.connectionString;
|
|
75
84
|
var _b = useWeb3React(), account = _b.account, isActive = _b.isActive;
|
|
@@ -176,33 +185,56 @@ var YourBonds = function (_a) {
|
|
|
176
185
|
return getTimePeriods(parseInt(userBill.lastBlockTimestamp) + parseInt(userBill.vesting) - currentTime, true);
|
|
177
186
|
};
|
|
178
187
|
var fetchUserOwnedBillsDataAsync = function (chainId, account) { return __awaiter(void 0, void 0, void 0, function () {
|
|
179
|
-
var
|
|
188
|
+
var bonds_1, userOwnedBills_1, mapUserOwnedBills_1, userOwnedBillsData_1, ownedBillsData, userBillNftData_1, ownedBillsWithNftData, error_2;
|
|
180
189
|
return __generator(this, function (_a) {
|
|
181
190
|
switch (_a.label) {
|
|
182
191
|
case 0:
|
|
183
|
-
_a.trys.push([0,
|
|
184
|
-
|
|
192
|
+
_a.trys.push([0, 3, , 4]);
|
|
193
|
+
bonds_1 = bondData.filter(function (bond) {
|
|
185
194
|
return bond.billVersion !== BillVersion.FixedPrice &&
|
|
186
195
|
(bond === null || bond === void 0 ? void 0 : bond.chainId) === chainId &&
|
|
187
196
|
bond.type !== 'migration' &&
|
|
188
197
|
bond.billAddress.toLowerCase() !== ACF_TO_ABOND.toLowerCase();
|
|
189
198
|
});
|
|
190
|
-
return [4 /*yield*/, fetchUserOwnedBills(chainId, account,
|
|
199
|
+
return [4 /*yield*/, fetchUserOwnedBills(chainId, account, bonds_1)];
|
|
191
200
|
case 1:
|
|
192
201
|
userOwnedBills_1 = _a.sent();
|
|
193
|
-
mapUserOwnedBills_1 =
|
|
202
|
+
mapUserOwnedBills_1 = bonds_1.map(function (bill) {
|
|
194
203
|
return userOwnedBills_1.filter(function (b) { return b.address.toLowerCase() === bill.billAddress.toLowerCase(); });
|
|
195
204
|
});
|
|
196
|
-
userOwnedBillsData_1 =
|
|
205
|
+
userOwnedBillsData_1 = bonds_1.map(function (bill, i) { return ({
|
|
197
206
|
index: bill.index,
|
|
198
207
|
userOwnedBills: mapUserOwnedBills_1[i],
|
|
199
208
|
}); });
|
|
200
|
-
|
|
209
|
+
ownedBillsData = mapUserOwnedBills_1.flatMap(function (bs) {
|
|
210
|
+
return bs.map(function (b) {
|
|
211
|
+
return { id: b.id, billNftAddress: b.billNftAddress, contractAddress: b.address };
|
|
212
|
+
});
|
|
213
|
+
});
|
|
214
|
+
return [4 /*yield*/, fetchUserOwnedBillNftData(ownedBillsData, chainId, bonds_1)];
|
|
201
215
|
case 2:
|
|
216
|
+
userBillNftData_1 = _a.sent();
|
|
217
|
+
ownedBillsWithNftData = mapUserOwnedBills_1.map(function (bs, index) {
|
|
218
|
+
return {
|
|
219
|
+
index: bonds_1[index].index,
|
|
220
|
+
userOwnedBillsNfts: __spreadArray([], bs.map(function (b) {
|
|
221
|
+
var _a;
|
|
222
|
+
return (_a = userBillNftData_1.find(function (nftB) { return parseInt(nftB.id) === parseInt(b.id); })) === null || _a === void 0 ? void 0 : _a.data;
|
|
223
|
+
}), true),
|
|
224
|
+
};
|
|
225
|
+
});
|
|
226
|
+
console.log("ownedBillsWithNftData");
|
|
227
|
+
console.log(ownedBillsWithNftData);
|
|
228
|
+
console.log("ownedBillsWithNftData");
|
|
229
|
+
console.log("userOwnedBillsData");
|
|
230
|
+
console.log(userOwnedBillsData_1);
|
|
231
|
+
console.log("userOwnedBillsData");
|
|
232
|
+
return [2 /*return*/, Promise.resolve(userOwnedBillsData_1)];
|
|
233
|
+
case 3:
|
|
202
234
|
error_2 = _a.sent();
|
|
203
235
|
console.error('Error fetching user owned bills data:', error_2);
|
|
204
236
|
return [2 /*return*/, Promise.reject(error_2)];
|
|
205
|
-
case
|
|
237
|
+
case 4: return [2 /*return*/];
|
|
206
238
|
}
|
|
207
239
|
});
|
|
208
240
|
}); };
|
|
@@ -321,10 +353,6 @@ var YourBonds = function (_a) {
|
|
|
321
353
|
var _a;
|
|
322
354
|
return getFirstNonZeroDigits(parseFloat((_a = bond === null || bond === void 0 ? void 0 : bond.payoutTokenPrice) !== null && _a !== void 0 ? _a : '0'));
|
|
323
355
|
};
|
|
324
|
-
var bills = usePollUserBills();
|
|
325
|
-
console.log("USERBILLS");
|
|
326
|
-
console.log(bills);
|
|
327
|
-
console.log("USERBILLS");
|
|
328
356
|
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: [_jsx(Flex, __assign({ className: "column column-claimable" }, { children: _jsx(Text, { children: "Claimable" }) })), _jsx(Flex, __assign({ className: "column column-pending" }, { children: _jsx(Text, { children: "Pending" }) })), _jsx(Flex, __assign({ className: "column column-term" }, { children: _jsx(Text, { children: "Terms" }) })), _jsx(Flex, __assign({ className: "column column-claimall" }, { children: _jsx(Button, __assign({ disabled: !account, sx: {
|
|
329
357
|
height: ['36px', '36px', '36px', '26px'],
|
|
330
358
|
lineHeight: '12px',
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { BondsDataResponse, CleanedBondsState, UserBill } from '../../types/bonds';
|
|
2
2
|
import { ChainId } from '../../enum/apeswaplists';
|
|
3
3
|
/**
|
|
4
4
|
* Fetches user-owned bill NFT data for a given set of owned bills data, chain ID, and bills.
|
|
@@ -11,5 +11,5 @@ export declare const fetchUserOwnedBillNftData: (ownedBillsData: {
|
|
|
11
11
|
id: string;
|
|
12
12
|
billNftAddress: string;
|
|
13
13
|
contractAddress: string;
|
|
14
|
-
}[], chainId: ChainId, bills:
|
|
14
|
+
}[], chainId: ChainId, bills: BondsDataResponse[]) => Promise<any[]>;
|
|
15
15
|
export declare const fetchUserOwnedBills: (chainId: ChainId, account: string, bills: CleanedBondsState[]) => Promise<UserBill[]>;
|
|
@@ -55,10 +55,10 @@ export var fetchUserOwnedBillNftData = function (ownedBillsData, chainId, bills)
|
|
|
55
55
|
billsFetched = [];
|
|
56
56
|
// Loop through each owned bill and check if it exists in the bills array
|
|
57
57
|
ownedBillsData === null || ownedBillsData === void 0 ? void 0 : ownedBillsData.forEach(function (_a) {
|
|
58
|
-
var _b, _c;
|
|
59
58
|
var id = _a.id, billNftAddress = _a.billNftAddress, contractAddress = _a.contractAddress;
|
|
60
|
-
var bill =
|
|
61
|
-
.find(function (b) { return b.
|
|
59
|
+
var bill = bills
|
|
60
|
+
.find(function (b) { return b.billAddress[chainId] === contractAddress; });
|
|
61
|
+
// ?.userOwnedBillsNftData?.find((u) => +u.tokenId === +id)
|
|
62
62
|
// If the bill exists in the bills array, add it to the billsFetched array
|
|
63
63
|
if (bill) {
|
|
64
64
|
billsFetched.push({ id: id, data: bill });
|
|
@@ -33,7 +33,16 @@ export declare const setBillsList: import("@reduxjs/toolkit").ActionCreatorWithP
|
|
|
33
33
|
}, "Bills/setBillsPublicData">, setUserOwnedBillsData: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "Bills/setUserOwnedBillsData">, setUserOwnedBillsNftData: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "Bills/setUserOwnedBillsNftData">;
|
|
34
34
|
export declare const fetchBondsStats: (tokenPrices: TokenPrices[]) => (dispatch: Dispatch, getState: any) => Promise<void>;
|
|
35
35
|
export declare const fetchSingleBillPublicData: (chainId: ChainId, tokenPrices: TokenPrices[], bondAddress: string) => (dispatch: Dispatch, getState: any) => Promise<void>;
|
|
36
|
-
export declare const fetchUserOwnedBillsDataAsync: (chainId: ChainId, account: string) => (dispatch: Dispatch, getState: any) => Promise<
|
|
36
|
+
export declare const fetchUserOwnedBillsDataAsync: (chainId: ChainId, account: string) => (dispatch: Dispatch, getState: any) => Promise<{
|
|
37
|
+
userOwnedBillsData: {
|
|
38
|
+
index: number;
|
|
39
|
+
userOwnedBills: import("../../types/bonds").UserBill[];
|
|
40
|
+
}[];
|
|
41
|
+
ownedBillsWithNftData: {
|
|
42
|
+
index: number;
|
|
43
|
+
userOwnedBillsNfts: any[];
|
|
44
|
+
}[];
|
|
45
|
+
}>;
|
|
37
46
|
declare const _default: import("redux").Reducer<BillsState, import("redux").UnknownAction, BillsState>;
|
|
38
47
|
export default _default;
|
|
39
48
|
export declare const parseBondApiData: (billApiData: BondsDataResponse) => CleanedBondsState;
|
|
@@ -249,11 +249,12 @@ export var fetchUserOwnedBillsDataAsync = function (chainId, account) {
|
|
|
249
249
|
};
|
|
250
250
|
});
|
|
251
251
|
dispatch(setUserOwnedBillsNftData({ value: ownedBillsWithNftData }));
|
|
252
|
-
|
|
252
|
+
// Return the data
|
|
253
|
+
return [2 /*return*/, { userOwnedBillsData: userOwnedBillsData, ownedBillsWithNftData: ownedBillsWithNftData }];
|
|
253
254
|
case 3:
|
|
254
255
|
error_3 = _a.sent();
|
|
255
256
|
console.warn(error_3);
|
|
256
|
-
return [
|
|
257
|
+
return [2 /*return*/, { userOwnedBillsData: [], ownedBillsWithNftData: [] }];
|
|
257
258
|
case 4: return [2 /*return*/];
|
|
258
259
|
}
|
|
259
260
|
});
|