@ape.swap/bonds-sdk 1.0.550 → 1.0.553

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.
@@ -48,7 +48,6 @@ import { jsx as _jsx, jsxs as _jsxs } from "theme-ui/jsx-runtime";
48
48
  import { useEffect, useState } from 'react';
49
49
  import { Flex, ThemeUIProvider } from 'theme-ui';
50
50
  import { useWeb3React } from '@web3-react/core';
51
- import { useSearchParams, useNavigate } from 'react-router-dom';
52
51
  import getTimePeriods from '../../utils/getTimePeriods';
53
52
  import { defaultTheme } from '../../theme';
54
53
  import '../../scss/YourBonds.scss';
@@ -66,59 +65,44 @@ import { fetchUserOwnedBillsDataAsync } from './fetchBillsUser';
66
65
  import { Input } from '../../components/uikit-sdk/Input';
67
66
  import { YourBondsModal } from "../../index";
68
67
  import BOND_ABI from '../../config/abi/bond.json';
68
+ import { useWriteContract } from 'wagmi';
69
69
  var YourBonds = function (_a) {
70
- //const toastError = useToastError()
71
- // const { onClaimBill } = useClaimBill(billAddress, billIds)
72
- var account = _a.account, accountChainId = _a.accountChainId, isActive = _a.isActive;
73
- // const [pendingTrx, setPendingTrx] = useState(false)
74
- // const handleClaim = async (billAddress: string, billIds: string[], chainId: number, event: any) => {
75
- // event?.stopPropagation();
76
- // console.log('CLAIM CLICKED');
77
- // console.log(account);
78
- // if (!account) return;
79
- // const { onClaimBill } = useClaimBill(billAddress, billIds, chainId);
80
- // setPendingTrx(true);
81
- // await onClaimBill().catch((e) => {
82
- // console.error(e);
83
- // //toastError(e);
84
- // setPendingTrx(false);
85
- // });
86
- // setPendingTrx(false);
87
- // };
70
+ var account = _a.account;
71
+ var writeContract = useWriteContract().writeContract;
88
72
  var handleClaim = function (billId, billAddress) { return __awaiter(void 0, void 0, void 0, function () {
89
- var tx, error_1;
73
+ var address, tx, error_1;
90
74
  return __generator(this, function (_a) {
91
75
  switch (_a.label) {
92
76
  case 0:
93
- _a.trys.push([0, 2, , 3]);
77
+ address = billAddress;
78
+ _a.label = 1;
79
+ case 1:
80
+ _a.trys.push([1, 3, , 4]);
94
81
  //const uint256BillId = ethers.BigNumber.from(billId);
95
82
  console.log('claimClicked');
96
83
  // console.log('billId:', uint256BillId);
97
84
  console.log('billAddress:', billAddress);
98
85
  return [4 /*yield*/, writeContract({
99
- address: billAddress,
86
+ address: address,
100
87
  abi: BOND_ABI,
101
88
  functionName: 'redeem',
102
89
  args: [billId],
103
90
  })];
104
- case 1:
91
+ case 2:
105
92
  tx = _a.sent();
106
93
  console.log('Transaction:', tx);
107
- return [3 /*break*/, 3];
108
- case 2:
94
+ return [3 /*break*/, 4];
95
+ case 3:
109
96
  error_1 = _a.sent();
110
97
  console.error('Approval failed:', error_1);
111
- return [3 /*break*/, 3];
112
- case 3: return [2 /*return*/];
98
+ return [3 /*break*/, 4];
99
+ case 4: return [2 /*return*/];
113
100
  }
114
101
  });
115
102
  }); };
116
- // const { account, isActive } = useWeb3React();
117
- var _b = useSearchParams(), searchParams = _b[0], setSearchParams = _b[1];
118
- var navigate = useNavigate();
119
103
  // Fetch data
120
- var _c = useState([]), bondData = _c[0], setBondData = _c[1];
121
- var _d = useState([]), mappedUserBills = _d[0], setMappedUserBills = _d[1];
104
+ var _b = useState([]), bondData = _b[0], setBondData = _b[1];
105
+ var _c = useState([]), mappedUserBills = _c[0], setMappedUserBills = _c[1];
122
106
  useEffect(function () {
123
107
  axios.get('https://realtime-api.ape.bond/bonds').then(function (response) {
124
108
  var bonds = response.data.bonds;
@@ -152,8 +136,8 @@ var YourBonds = function (_a) {
152
136
  }); };
153
137
  fetchData();
154
138
  }, [account, bondData]);
155
- var _e = useState(null), sortConfig = _e[0], setSortConfig = _e[1];
156
- var _f = useState(mappedUserBills), sortedBonds = _f[0], setSortedBonds = _f[1];
139
+ var _d = useState(null), sortConfig = _d[0], setSortConfig = _d[1];
140
+ var _e = useState(mappedUserBills), sortedBonds = _e[0], setSortedBonds = _e[1];
157
141
  var handleSort = function (key) {
158
142
  var direction = 'asc';
159
143
  if ((sortConfig === null || sortConfig === void 0 ? void 0 : sortConfig.key) === key && (sortConfig === null || sortConfig === void 0 ? void 0 : sortConfig.direction) === 'asc') {
@@ -234,8 +218,8 @@ var YourBonds = function (_a) {
234
218
  return getFirstNonZeroDigits(parseFloat((_a = bond === null || bond === void 0 ? void 0 : bond.payoutTokenPrice) !== null && _a !== void 0 ? _a : '0'));
235
219
  };
236
220
  // Modal
237
- var _g = useState(false), isModalOpen = _g[0], setIsModalOpen = _g[1];
238
- var _h = useState(undefined), selectedBill = _h[0], setSelectedBill = _h[1];
221
+ var _f = useState(false), isModalOpen = _f[0], setIsModalOpen = _f[1];
222
+ var _g = useState(undefined), selectedBill = _g[0], setSelectedBill = _g[1];
239
223
  var rowClick = function (bill) {
240
224
  console.log(bill);
241
225
  setSelectedBill(bill);
@@ -243,8 +227,8 @@ var YourBonds = function (_a) {
243
227
  // navigate(`/yourBonds/?bondAddress=${bill.address}&bondChain=${bill.bond.chainId}`, { replace: true });
244
228
  };
245
229
  // Search logic
246
- var _j = useState(''), inputValue = _j[0], setInputValue = _j[1];
247
- var _k = useState(sortedBonds), filteredBonds = _k[0], setFilteredBonds = _k[1];
230
+ var _h = useState(''), inputValue = _h[0], setInputValue = _h[1];
231
+ var _j = useState(sortedBonds), filteredBonds = _j[0], setFilteredBonds = _j[1];
248
232
  useEffect(function () {
249
233
  if (inputValue === '') {
250
234
  setFilteredBonds(sortedBonds);
@@ -259,7 +243,7 @@ var YourBonds = function (_a) {
259
243
  setInputValue(event.target.value);
260
244
  };
261
245
  // Page render logic
262
- var _l = useState(false), bondsRendered = _l[0], setBondsRendered = _l[1];
246
+ var _k = useState(false), bondsRendered = _k[0], setBondsRendered = _k[1];
263
247
  useEffect(function () {
264
248
  if (filteredBonds.length > 0) {
265
249
  setBondsRendered(true);
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.550",
6
+ "version": "1.0.553",
7
7
  "main": "dist/index.js",
8
8
  "module": "dist/index.es.js",
9
9
  "types": "dist/index.d.ts",