@ape.swap/bonds-sdk 1.0.494 → 1.0.495

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.
@@ -1,9 +1,9 @@
1
1
  /** @jsxImportSource theme-ui */
2
2
  import React from 'react';
3
3
  import '../../../scss/YourBondsModal.scss';
4
- declare const YourBondsModal: ({ isOpen, onClose, bondAddress }: {
4
+ declare const YourBondsModal: ({ isOpen, onClose, bond }: {
5
5
  isOpen: boolean;
6
6
  onClose: () => void;
7
- bondAddress: string | null;
7
+ bond: any | null;
8
8
  }) => React.JSX.Element | null;
9
9
  export default YourBondsModal;
@@ -9,97 +9,49 @@ var __assign = (this && this.__assign) || function () {
9
9
  };
10
10
  return __assign.apply(this, arguments);
11
11
  };
12
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
13
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
14
- return new (P || (P = Promise))(function (resolve, reject) {
15
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
16
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
17
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
18
- step((generator = generator.apply(thisArg, _arguments || [])).next());
19
- });
20
- };
21
- var __generator = (this && this.__generator) || function (thisArg, body) {
22
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
23
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
24
- function verb(n) { return function (v) { return step([n, v]); }; }
25
- function step(op) {
26
- if (f) throw new TypeError("Generator is already executing.");
27
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
28
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
29
- if (y = 0, t) op = [op[0] & 2, t.value];
30
- switch (op[0]) {
31
- case 0: case 1: t = op; break;
32
- case 4: _.label++; return { value: op[1], done: false };
33
- case 5: _.label++; y = op[1]; op = [0]; continue;
34
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
35
- default:
36
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
37
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
38
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
39
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
40
- if (t[2]) _.ops.pop();
41
- _.trys.pop(); continue;
42
- }
43
- op = body.call(thisArg, _);
44
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
45
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
46
- }
47
- };
48
12
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "theme-ui/jsx-runtime";
49
13
  /** @jsxImportSource theme-ui */
50
14
  import { useEffect, useState } from 'react';
51
- import { Flex, ThemeUIProvider } from 'theme-ui';
15
+ import { Flex } from 'theme-ui';
52
16
  import { useWeb3React } from '@web3-react/core';
53
- import axios from 'axios';
54
17
  import { BigNumber } from 'bignumber.js';
55
- import { MAINNET_CHAINS } from '../../../config/constants/chains';
56
- import { fetchUserOwnedBillsDataAsync } from '../../../pages/YourBonds/fetchBillsUser';
57
18
  import { getBalanceNumber } from '../../../utils/getBalanceNumber';
58
19
  import { getFirstNonZeroDigits } from '../../../utils/roundNumber';
59
- import { defaultTheme } from '../../../theme';
60
20
  import '../../../scss/YourBondsModal.scss';
61
21
  var YourBondsModal = function (_a) {
62
- var isOpen = _a.isOpen, onClose = _a.onClose, bondAddress = _a.bondAddress;
22
+ var isOpen = _a.isOpen, onClose = _a.onClose, bond = _a.bond;
63
23
  if (!isOpen)
64
24
  return null;
65
25
  var _b = useWeb3React(), account = _b.account, chainId = _b.chainId, isActive = _b.isActive;
66
26
  // Fetch data for user owned bill
67
27
  var _c = useState([]), bondData = _c[0], setBondData = _c[1];
68
28
  var _d = useState([]), userOwnedBillsData = _d[0], setUserOwnedBillsData = _d[1];
69
- useEffect(function () {
70
- console.log('HIT BOND ADDRESS');
71
- axios.get('https://realtime-api.ape.bond/bonds').then(function (response) {
72
- var bond = response.data.bonds.filter(function (x) {
73
- return x.billAddress.toLowerCase() === (bondAddress === null || bondAddress === void 0 ? void 0 : bondAddress.toLowerCase());
74
- });
75
- setBondData(bond);
76
- });
77
- }, [bondAddress]);
78
- useEffect(function () {
79
- var fetchData = function () { return __awaiter(void 0, void 0, void 0, function () {
80
- var results, error_1;
81
- return __generator(this, function (_a) {
82
- switch (_a.label) {
83
- case 0:
84
- if (!account) return [3 /*break*/, 4];
85
- _a.label = 1;
86
- case 1:
87
- _a.trys.push([1, 3, , 4]);
88
- return [4 /*yield*/, Promise.all(MAINNET_CHAINS.map(function (chain) { return fetchUserOwnedBillsDataAsync(chain, account, bondData); }))];
89
- case 2:
90
- results = _a.sent();
91
- setUserOwnedBillsData(results);
92
- return [3 /*break*/, 4];
93
- case 3:
94
- error_1 = _a.sent();
95
- console.error('Error fetching user owned bills data:', error_1);
96
- return [3 /*break*/, 4];
97
- case 4: return [2 /*return*/];
98
- }
99
- });
100
- }); };
101
- fetchData();
102
- }, [account]);
29
+ // useEffect(() => {
30
+ // console.log('HIT BOND ADDRESS')
31
+ // axios.get('https://realtime-api.ape.bond/bonds').then(response => {
32
+ // const bond = response.data.bonds.filter((x: any) =>
33
+ // x.billAddress.toLowerCase() === bondAddress?.toLowerCase()
34
+ // );
35
+ // setBondData(bond);
36
+ // });
37
+ // }, [bondAddress]);
38
+ // useEffect(() => {
39
+ // const fetchData = async () => {
40
+ // if (account) {
41
+ // try {
42
+ // const results = await Promise.all(
43
+ // MAINNET_CHAINS.map((chain) => fetchUserOwnedBillsDataAsync(chain as number, account, bondData))
44
+ // );
45
+ // setUserOwnedBillsData(results);
46
+ // } catch (error) {
47
+ // console.error('Error fetching user owned bills data:', error);
48
+ // }
49
+ // }
50
+ // };
51
+ //
52
+ // fetchData();
53
+ //
54
+ // }, [account]);
103
55
  // Functions to calculate display values for modal
104
56
  var totalPending = function (userBill) {
105
57
  var _a, _b, _c, _d;
@@ -122,6 +74,6 @@ var YourBondsModal = function (_a) {
122
74
  setBillRendered(true);
123
75
  }
124
76
  }, [userOwnedBillsData]);
125
- return (_jsx(ThemeUIProvider, __assign({ theme: defaultTheme }, { children: _jsxs(_Fragment, { children: [" ", _jsx(Flex, __assign({ className: "modal modal-backdrop" }, { children: _jsxs(Flex, __assign({ className: "modal modal-content" }, { children: [_jsx(Flex, __assign({ className: "modal modal-header" }, { children: "AA" })), _jsx(Flex, __assign({ className: "modal-container table-container" }, { children: "SCOTT TEST" }))] })) }))] }) })));
77
+ return (_jsxs(_Fragment, { children: [" ", _jsx(Flex, __assign({ className: "modal modal-backdrop" }, { children: _jsxs(Flex, __assign({ className: "modal modal-content" }, { children: [_jsx(Flex, __assign({ className: "modal modal-header" }, { children: "AA" })), _jsx(Flex, __assign({ className: "modal-container table-container" }, { children: "SCOTT TEST" }))] })) }))] }));
126
78
  };
127
79
  export default YourBondsModal;
@@ -77,6 +77,7 @@ import axios from 'axios';
77
77
  import { fetchUserOwnedBillsDataAsync } from './fetchBillsUser';
78
78
  import { Input } from '../../components/uikit-sdk/Input';
79
79
  import useClaimBill from '../../hooks/useClaimBill';
80
+ import { YourBondsModal } from "../../index";
80
81
  var YourBonds = function (_a) {
81
82
  //const toastError = useToastError()
82
83
  // const { onClaimBill } = useClaimBill(billAddress, billIds)
@@ -271,9 +272,10 @@ var YourBonds = function (_a) {
271
272
  var _h = useState(false), isModalOpen = _h[0], setIsModalOpen = _h[1];
272
273
  var _j = useState(null), selectedBill = _j[0], setSelectedBill = _j[1];
273
274
  var rowClick = function (bill) {
275
+ console.log(bill);
274
276
  setSelectedBill(bill);
275
277
  setIsModalOpen(true);
276
- navigate("/yourBonds/?bondAddress=".concat(bill.address, "&bondChain=").concat(bill.bond.chainId), { replace: true });
278
+ // navigate(`/yourBonds/?bondAddress=${bill.address}&bondChain=${bill.bond.chainId}`, { replace: true });
277
279
  };
278
280
  // Search logic
279
281
  var _k = useState(''), inputValue = _k[0], setInputValue = _k[1];
@@ -298,25 +300,26 @@ var YourBonds = function (_a) {
298
300
  setBondsRendered(true);
299
301
  }
300
302
  }, [filteredBonds]);
301
- 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: {
302
- height: ['36px', '36px', '36px', '26px'],
303
- lineHeight: '12px',
304
- fontSize: '14px',
305
- fontWeight: 600,
306
- width: '100%',
307
- } }, { children: "CLAIM ALL" })) }))] }))] })), filteredBonds.map(function (bill) {
308
- var _a, _b;
309
- 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) {
310
- // event.stopPropagation();
311
- // Add your claim logic here
312
- handleClaim(bill.bond.billAddress, [bill.id], bill.bond.chainId, event);
313
- }, sx: {
303
+ return (_jsxs(ThemeUIProvider, __assign({ theme: defaultTheme }, { children: [isModalOpen &&
304
+ _jsx(YourBondsModal, { isOpen: true, onClose: function () { console.log('CLOSED'); }, bond: selectedBill }), 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: {
314
305
  height: ['36px', '36px', '36px', '26px'],
315
306
  lineHeight: '12px',
316
307
  fontSize: '14px',
317
308
  fontWeight: 600,
318
309
  width: '100%',
319
- } }, { children: "Claim" })) }))] }))] }), bill.id));
320
- })] }))) })));
310
+ } }, { children: "CLAIM ALL" })) }))] }))] })), filteredBonds.map(function (bill) {
311
+ var _a, _b;
312
+ 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) {
313
+ // event.stopPropagation();
314
+ // Add your claim logic here
315
+ handleClaim(bill.bond.billAddress, [bill.id], bill.bond.chainId, event);
316
+ }, sx: {
317
+ height: ['36px', '36px', '36px', '26px'],
318
+ lineHeight: '12px',
319
+ fontSize: '14px',
320
+ fontWeight: 600,
321
+ width: '100%',
322
+ } }, { children: "Claim" })) }))] }))] }), bill.id));
323
+ })] })))] })));
321
324
  };
322
325
  export default YourBonds;
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.494",
6
+ "version": "1.0.495",
7
7
  "main": "dist/index.js",
8
8
  "module": "dist/index.es.js",
9
9
  "types": "dist/index.d.ts",