@ape.swap/bonds-sdk 1.0.567 → 1.0.569

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.
@@ -71,7 +71,7 @@ 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, tx, error_1;
74
+ var billAddress, decimals, maxPrice, amount, error_1;
75
75
  return __generator(this, function (_a) {
76
76
  switch (_a.label) {
77
77
  case 0:
@@ -82,6 +82,7 @@ var BondModal = function (_a) {
82
82
  _a.trys.push([1, 3, , 4]);
83
83
  maxPrice = new BigNumber(bondData[0].trueBillPrice).times(102).div(100);
84
84
  amount = convertToTokenValue(inputValue, decimals);
85
+ // @ts-ignore
85
86
  return [4 /*yield*/, writeContract({
86
87
  address: billAddress,
87
88
  abi: BOND_ABI,
@@ -89,10 +90,11 @@ var BondModal = function (_a) {
89
90
  args: [amount, maxPrice, account],
90
91
  })];
91
92
  case 2:
92
- tx = _a.sent();
93
- console.log('Transaction:', tx);
94
- if (tx != null) {
95
- setBuyTx(tx);
93
+ // @ts-ignore
94
+ _a.sent();
95
+ console.log('Transaction:', hash);
96
+ if (hash != null) {
97
+ setBuyTx(hash);
96
98
  }
97
99
  return [3 /*break*/, 4];
98
100
  case 3:
@@ -107,39 +109,30 @@ var BondModal = function (_a) {
107
109
  var _e = useState(null), buyTx = _e[0], setBuyTx = _e[1];
108
110
  //You approve the token, not the contract (this code will have to be updated for zap)
109
111
  var handleApprove = function () { return __awaiter(void 0, void 0, void 0, function () {
110
- var tokenAddress, decimals, amount, tx, error_2;
112
+ var tokenAddress, decimals, amount;
111
113
  return __generator(this, function (_a) {
112
- switch (_a.label) {
113
- case 0:
114
- tokenAddress = bondData[0].principalToken;
115
- decimals = 18;
116
- _a.label = 1;
117
- case 1:
118
- _a.trys.push([1, 3, , 4]);
119
- amount = convertToTokenValue(inputValue, decimals);
120
- console.log('Amount:', amount);
121
- return [4 /*yield*/, writeContract({
122
- address: tokenAddress,
123
- abi: ERC_20_ABI,
124
- functionName: 'approve',
125
- args: [account, amount],
126
- })];
127
- case 2:
128
- tx = _a.sent();
129
- console.log('Transaction:', hash);
130
- console.log('IsPending:', isPending);
131
- console.log('IsConfirmed:', isConfirmed);
132
- if (hash != null) {
133
- setApproveTx(hash);
134
- }
135
- return [3 /*break*/, 4];
136
- case 3:
137
- error_2 = _a.sent();
138
- console.error('Approval failed:', error_2);
139
- alert('Approval Failed');
140
- return [3 /*break*/, 4];
141
- case 4: return [2 /*return*/];
114
+ tokenAddress = bondData[0].principalToken;
115
+ decimals = 18;
116
+ try {
117
+ amount = convertToTokenValue(inputValue, decimals);
118
+ console.log('Amount:', amount);
119
+ writeContract({
120
+ address: tokenAddress,
121
+ abi: ERC_20_ABI,
122
+ functionName: 'approve',
123
+ args: [account, amount]
124
+ });
125
+ console.log('Transaction:', hash);
126
+ if (hash) {
127
+ setApproveTx(hash);
128
+ console.log('setApproveTx:', hash);
129
+ }
142
130
  }
131
+ catch (error) {
132
+ console.error('Approval failed:', error);
133
+ alert('Approval Failed');
134
+ }
135
+ return [2 /*return*/];
143
136
  });
144
137
  }); };
145
138
  var _f = useState(null), approveTx = _f[0], setApproveTx = _f[1];
@@ -194,7 +187,7 @@ var BondModal = function (_a) {
194
187
  }
195
188
  }, [isActive, account, bondData]);
196
189
  var getTokenBalance = function (chainId, tokenAddress, walletAddress) { return __awaiter(void 0, void 0, void 0, function () {
197
- var urls, provider, contract, balance, balanceInEther, error_3;
190
+ var urls, provider, contract, balance, balanceInEther, error_2;
198
191
  return __generator(this, function (_a) {
199
192
  switch (_a.label) {
200
193
  case 0:
@@ -212,8 +205,8 @@ var BondModal = function (_a) {
212
205
  console.log("Token Balance: ".concat(balanceInEther));
213
206
  return [2 /*return*/, balanceInEther];
214
207
  case 2:
215
- error_3 = _a.sent();
216
- console.error('Error fetching token balance', error_3);
208
+ error_2 = _a.sent();
209
+ console.error('Error fetching token balance', error_2);
217
210
  return [2 /*return*/, 'Error fetching token balance'];
218
211
  case 3: return [2 /*return*/];
219
212
  }
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.567",
6
+ "version": "1.0.569",
7
7
  "main": "dist/index.js",
8
8
  "module": "dist/index.es.js",
9
9
  "types": "dist/index.d.ts",