@ape.swap/bonds-sdk 1.0.569 → 1.0.571

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.
@@ -3,11 +3,11 @@ import React from 'react';
3
3
  import '../../../scss/BondModal.scss';
4
4
  interface BondModalProps {
5
5
  account: string;
6
- accountChainId: number;
7
6
  isActive: boolean;
8
7
  isOpen: boolean;
9
8
  onClose: () => void;
10
9
  bondAddress: string | null;
10
+ accountChainId: number;
11
11
  }
12
12
  declare const BondModal: React.FC<BondModalProps>;
13
13
  export default BondModal;
@@ -58,7 +58,7 @@ import '../../../scss/BondModal.scss';
58
58
  import { useWaitForTransactionReceipt, useWriteContract } from "wagmi";
59
59
  import { PUBLIC_RPC_URLS } from "../../../config/constants/networks";
60
60
  var BondModal = function (_a) {
61
- var account = _a.account, accountChainId = _a.accountChainId, isActive = _a.isActive, isOpen = _a.isOpen, onClose = _a.onClose, bondAddress = _a.bondAddress;
61
+ var account = _a.account, isActive = _a.isActive, isOpen = _a.isOpen, accountChainId = _a.accountChainId, onClose = _a.onClose, bondAddress = _a.bondAddress;
62
62
  if (!isOpen)
63
63
  return null;
64
64
  var _b = useWriteContract(), hash = _b.data, isPending = _b.isPending, writeContract = _b.writeContract;
@@ -71,39 +71,31 @@ var BondModal = function (_a) {
71
71
  //user to buy
72
72
  //Check with Fede if this needs to be temp, if we force approval everytime, isn't this fine?
73
73
  var handleBuy = function () { return __awaiter(void 0, void 0, void 0, function () {
74
- var billAddress, decimals, maxPrice, amount, error_1;
74
+ var billAddress, decimals, maxPrice, amount;
75
75
  return __generator(this, function (_a) {
76
- switch (_a.label) {
77
- case 0:
78
- billAddress = bondData[0].billAddress;
79
- decimals = 18;
80
- _a.label = 1;
81
- case 1:
82
- _a.trys.push([1, 3, , 4]);
83
- maxPrice = new BigNumber(bondData[0].trueBillPrice).times(102).div(100);
84
- amount = convertToTokenValue(inputValue, decimals);
85
- // @ts-ignore
86
- return [4 /*yield*/, writeContract({
87
- address: billAddress,
88
- abi: BOND_ABI,
89
- functionName: 'deposit',
90
- args: [amount, maxPrice, account],
91
- })];
92
- case 2:
93
- // @ts-ignore
94
- _a.sent();
95
- console.log('Transaction:', hash);
96
- if (hash != null) {
97
- setBuyTx(hash);
98
- }
99
- return [3 /*break*/, 4];
100
- case 3:
101
- error_1 = _a.sent();
102
- console.error('Buy error', error_1);
103
- alert('Buy Failed');
104
- return [3 /*break*/, 4];
105
- case 4: return [2 /*return*/];
76
+ billAddress = bondData[0].billAddress;
77
+ decimals = 18;
78
+ try {
79
+ maxPrice = new BigNumber(bondData[0].trueBillPrice).times(102).div(100);
80
+ amount = convertToTokenValue(inputValue, decimals);
81
+ // @ts-ignore
82
+ writeContract({
83
+ address: billAddress,
84
+ abi: BOND_ABI,
85
+ functionName: 'deposit',
86
+ args: [amount, maxPrice, account],
87
+ });
88
+ console.log('BuyTransaction:', hash);
89
+ if (hash) {
90
+ setBuyTx(hash);
91
+ console.log('setBuyTx:', hash);
92
+ }
106
93
  }
94
+ catch (error) {
95
+ console.error('Buy error', error);
96
+ alert('Buy Failed');
97
+ }
98
+ return [2 /*return*/];
107
99
  });
108
100
  }); };
109
101
  var _e = useState(null), buyTx = _e[0], setBuyTx = _e[1];
@@ -122,7 +114,7 @@ var BondModal = function (_a) {
122
114
  functionName: 'approve',
123
115
  args: [account, amount]
124
116
  });
125
- console.log('Transaction:', hash);
117
+ console.log('ApproveTransaction:', hash);
126
118
  if (hash) {
127
119
  setApproveTx(hash);
128
120
  console.log('setApproveTx:', hash);
@@ -187,7 +179,7 @@ var BondModal = function (_a) {
187
179
  }
188
180
  }, [isActive, account, bondData]);
189
181
  var getTokenBalance = function (chainId, tokenAddress, walletAddress) { return __awaiter(void 0, void 0, void 0, function () {
190
- var urls, provider, contract, balance, balanceInEther, error_2;
182
+ var urls, provider, contract, balance, balanceInEther, error_1;
191
183
  return __generator(this, function (_a) {
192
184
  switch (_a.label) {
193
185
  case 0:
@@ -205,8 +197,8 @@ var BondModal = function (_a) {
205
197
  console.log("Token Balance: ".concat(balanceInEther));
206
198
  return [2 /*return*/, balanceInEther];
207
199
  case 2:
208
- error_2 = _a.sent();
209
- console.error('Error fetching token balance', error_2);
200
+ error_1 = _a.sent();
201
+ console.error('Error fetching token balance', error_1);
210
202
  return [2 /*return*/, 'Error fetching token balance'];
211
203
  case 3: return [2 /*return*/];
212
204
  }
@@ -90,7 +90,7 @@ var YourBonds = function (_a) {
90
90
  })];
91
91
  case 2:
92
92
  tx = _a.sent();
93
- console.log('Transaction:', tx);
93
+ console.log('ClaimTransaction:', tx);
94
94
  if (tx != null) {
95
95
  setClaimTx(tx);
96
96
  }
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.569",
6
+ "version": "1.0.571",
7
7
  "main": "dist/index.js",
8
8
  "module": "dist/index.es.js",
9
9
  "types": "dist/index.d.ts",