@ape.swap/bonds-sdk 1.0.573 → 1.0.575

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.
@@ -101,34 +101,39 @@ var BondModal = function (_a) {
101
101
  var _e = useState(null), buyTx = _e[0], setBuyTx = _e[1];
102
102
  //You approve the token, not the contract (this code will have to be updated for zap)
103
103
  var handleApprove = function () { return __awaiter(void 0, void 0, void 0, function () {
104
- var tokenAddress, decimals, amount;
104
+ var tokenAddress, decimals, amount, result, error_1;
105
105
  return __generator(this, function (_a) {
106
- tokenAddress = bondData[0].principalToken;
107
- decimals = 18;
108
- try {
109
- amount = convertToTokenValue(inputValue, decimals);
110
- console.log('Amount:', amount);
111
- writeContract({
112
- address: tokenAddress,
113
- abi: ERC_20_ABI,
114
- functionName: 'approve',
115
- args: [account, amount]
116
- });
117
- console.log('ApproveTransaction:', hash);
118
- if (isConfirmed && hash) {
119
- console.log('IsConfirmedApproveTransaction:', hash);
120
- setApproveTx(hash);
121
- }
122
- if (hash) {
123
- setApproveTx(hash);
124
- console.log('setApproveTx:', hash);
125
- }
126
- }
127
- catch (error) {
128
- console.error('Approval failed:', error);
129
- alert('Approval Failed');
106
+ switch (_a.label) {
107
+ case 0:
108
+ tokenAddress = bondData[0].principalToken;
109
+ decimals = 18;
110
+ _a.label = 1;
111
+ case 1:
112
+ _a.trys.push([1, 3, , 4]);
113
+ amount = convertToTokenValue(inputValue, decimals);
114
+ console.log('Amount:', amount);
115
+ return [4 /*yield*/, writeContract({
116
+ address: tokenAddress,
117
+ abi: ERC_20_ABI,
118
+ functionName: 'approve',
119
+ args: [account, amount]
120
+ })];
121
+ case 2:
122
+ result = _a.sent();
123
+ console.log('Result:', result);
124
+ console.log('ApproveTransaction:', hash);
125
+ if (hash) {
126
+ setApproveTx(hash);
127
+ console.log('setApproveTx:', hash);
128
+ }
129
+ return [3 /*break*/, 4];
130
+ case 3:
131
+ error_1 = _a.sent();
132
+ console.error('Approval failed:', error_1);
133
+ alert('Approval Failed');
134
+ return [3 /*break*/, 4];
135
+ case 4: return [2 /*return*/];
130
136
  }
131
- return [2 /*return*/];
132
137
  });
133
138
  }); };
134
139
  var _f = useState(null), approveTx = _f[0], setApproveTx = _f[1];
@@ -183,7 +188,7 @@ var BondModal = function (_a) {
183
188
  }
184
189
  }, [isActive, account, bondData]);
185
190
  var getTokenBalance = function (chainId, tokenAddress, walletAddress) { return __awaiter(void 0, void 0, void 0, function () {
186
- var urls, provider, contract, balance, balanceInEther, error_1;
191
+ var urls, provider, contract, balance, balanceInEther, error_2;
187
192
  return __generator(this, function (_a) {
188
193
  switch (_a.label) {
189
194
  case 0:
@@ -201,8 +206,8 @@ var BondModal = function (_a) {
201
206
  console.log("Token Balance: ".concat(balanceInEther));
202
207
  return [2 /*return*/, balanceInEther];
203
208
  case 2:
204
- error_1 = _a.sent();
205
- console.error('Error fetching token balance', error_1);
209
+ error_2 = _a.sent();
210
+ console.error('Error fetching token balance', error_2);
206
211
  return [2 /*return*/, 'Error fetching token balance'];
207
212
  case 3: return [2 /*return*/];
208
213
  }
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.573",
6
+ "version": "1.0.575",
7
7
  "main": "dist/index.js",
8
8
  "module": "dist/index.es.js",
9
9
  "types": "dist/index.d.ts",