@ape.swap/bonds-sdk 1.0.504 → 1.0.505

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.
@@ -105,39 +105,35 @@ var BondModal = function (_a) {
105
105
  }); };
106
106
  //You approve the token, not the contract (this code will have to be updated for zap)
107
107
  var handleApprove = function () { return __awaiter(void 0, void 0, void 0, function () {
108
- var tokenAddress;
108
+ var tokenAddress, tx, error_2;
109
109
  var _a;
110
110
  return __generator(this, function (_b) {
111
- console.log('handle approve clicked');
112
- if (!window.ethereum) {
113
- console.error('No Ethereum provider found');
114
- alert('No Ethereum provider found');
115
- return [2 /*return*/];
111
+ switch (_b.label) {
112
+ case 0:
113
+ console.log('---!');
114
+ console.log((_a = bondData[0]) === null || _a === void 0 ? void 0 : _a.principalToken);
115
+ console.log(account);
116
+ tokenAddress = bondData[0].principalToken;
117
+ _b.label = 1;
118
+ case 1:
119
+ _b.trys.push([1, 3, , 4]);
120
+ console.log('BBBBB');
121
+ return [4 /*yield*/, writeContract({
122
+ address: tokenAddress,
123
+ abi: ERC_20_ABI,
124
+ functionName: 'approve',
125
+ args: [account, adjustDecimals(inputValue)],
126
+ })];
127
+ case 2:
128
+ tx = _b.sent();
129
+ console.log('Transaction:', tx);
130
+ return [3 /*break*/, 4];
131
+ case 3:
132
+ error_2 = _b.sent();
133
+ console.error('Approval failed:', error_2);
134
+ return [3 /*break*/, 4];
135
+ case 4: return [2 /*return*/];
116
136
  }
117
- console.log('---!');
118
- console.log((_a = bondData[0]) === null || _a === void 0 ? void 0 : _a.principalToken);
119
- //Here we need to approve the token, not the bond
120
- // const provider = new ethers.providers.Web3Provider(window.ethereum);
121
- // const signer = provider.getSigner();
122
- //
123
- // console.log(signer)
124
- console.log(account);
125
- tokenAddress = bondData[0].principalToken;
126
- //
127
- // const { writeAsync, isLoading, isSuccess, error } = useContractWrite({
128
- // addressOrName: tokenAddress,
129
- // contractInterface: ERC_20_ABI,
130
- // functionName: 'approve',
131
- // args: [account, adjustDecimals(inputValue)],
132
- // });
133
- // @ts-ignore
134
- writeContract({
135
- address: tokenAddress,
136
- abi: ERC_20_ABI,
137
- functionName: 'approve',
138
- args: [account, adjustDecimals(inputValue)],
139
- });
140
- return [2 /*return*/];
141
137
  });
142
138
  }); };
143
139
  // Fetch data
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.504",
6
+ "version": "1.0.505",
7
7
  "main": "dist/index.js",
8
8
  "module": "dist/index.es.js",
9
9
  "types": "dist/index.d.ts",