@ape.swap/bonds-sdk 1.0.572 → 1.0.574

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,30 +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 (hash) {
119
- setApproveTx(hash);
120
- console.log('setApproveTx:', hash);
121
- }
122
- }
123
- catch (error) {
124
- console.error('Approval failed:', error);
125
- 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*/];
126
136
  }
127
- return [2 /*return*/];
128
137
  });
129
138
  }); };
130
139
  var _f = useState(null), approveTx = _f[0], setApproveTx = _f[1];
@@ -179,7 +188,7 @@ var BondModal = function (_a) {
179
188
  }
180
189
  }, [isActive, account, bondData]);
181
190
  var getTokenBalance = function (chainId, tokenAddress, walletAddress) { return __awaiter(void 0, void 0, void 0, function () {
182
- var urls, provider, contract, balance, balanceInEther, error_1;
191
+ var urls, provider, contract, balance, balanceInEther, error_2;
183
192
  return __generator(this, function (_a) {
184
193
  switch (_a.label) {
185
194
  case 0:
@@ -197,8 +206,8 @@ var BondModal = function (_a) {
197
206
  console.log("Token Balance: ".concat(balanceInEther));
198
207
  return [2 /*return*/, balanceInEther];
199
208
  case 2:
200
- error_1 = _a.sent();
201
- console.error('Error fetching token balance', error_1);
209
+ error_2 = _a.sent();
210
+ console.error('Error fetching token balance', error_2);
202
211
  return [2 /*return*/, 'Error fetching token balance'];
203
212
  case 3: return [2 /*return*/];
204
213
  }
@@ -223,7 +232,7 @@ var BondModal = function (_a) {
223
232
  } }) }), _jsxs(Flex, { className: "input-container token", children: [_jsx(Flex, { className: "input-container bondicon", children: _jsxs("div", { className: "icon-container-small", children: [_jsx(Svg, { width: 12, height: 12, icon: (_m = NETWORK_ICONS === null || NETWORK_ICONS === void 0 ? void 0 : NETWORK_ICONS[bond.chainId]) !== null && _m !== void 0 ? _m : 'question' }), _jsx(TokenImage, { symbol: (_o = bond.principalTokenName) !== null && _o !== void 0 ? _o : bond.payoutTokenName, size: 30 })] }) }), _jsx(Flex, { className: "title-container tokenname-small", children: bond === null || bond === void 0 ? void 0 : bond.principalTokenName })] })] }), isActive && account && (_jsxs(Flex, { className: "input-container balancerow", children: [_jsxs(Flex, { className: "balancerow text", children: ["Balance: ", tokenBalance] }), _jsx(Flex, { className: "balancerow max", children: _jsx(Button, { onClick: function () { setInputValue(tokenBalance !== null && tokenBalance !== void 0 ? tokenBalance : '0'); }, children: "Max" }) })] }))] }), _jsxs(Flex, { className: "modal-container button-container", children: [_jsx(Flex, { className: "button-container get", children: _jsxs(Button, { onClick: function () { window.open('https://ape.bond/swap', '_blank'); }, children: ["Get ", bond === null || bond === void 0 ? void 0 : bond.principalTokenName] }) }), _jsx(Flex, { className: "button-container buy", children: approveTx != null ?
224
233
  _jsxs(Button, { onClick: handleBuy, children: ["Buy ", bond === null || bond === void 0 ? void 0 : bond.showcaseTokenName] })
225
234
  :
226
- _jsx(Button, { onClick: handleApprove, children: "Approve" }) })] })] })] }) }) }, bond.billAddress));
235
+ _jsx(Button, { disabled: isPending, onClick: handleApprove, children: "Approve" }) })] })] })] }) }) }, bond.billAddress));
227
236
  }) }));
228
237
  };
229
238
  export default BondModal;
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.572",
6
+ "version": "1.0.574",
7
7
  "main": "dist/index.js",
8
8
  "module": "dist/index.es.js",
9
9
  "types": "dist/index.d.ts",