@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
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
console.log('
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
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,
|
|
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
|
-
|
|
205
|
-
console.error('Error fetching token balance',
|
|
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
|
}
|