@ape.swap/bonds-sdk 1.0.598 → 1.0.599

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