@ape.swap/bonds-sdk 1.0.568 → 1.0.569
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.
|
@@ -109,38 +109,30 @@ var BondModal = function (_a) {
|
|
|
109
109
|
var _e = useState(null), buyTx = _e[0], setBuyTx = _e[1];
|
|
110
110
|
//You approve the token, not the contract (this code will have to be updated for zap)
|
|
111
111
|
var handleApprove = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
112
|
-
var tokenAddress, decimals, amount
|
|
112
|
+
var tokenAddress, decimals, amount;
|
|
113
113
|
return __generator(this, function (_a) {
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
_a.sent();
|
|
131
|
-
console.log('Transaction:', hash);
|
|
132
|
-
if (hash != null) {
|
|
133
|
-
setApproveTx(hash);
|
|
134
|
-
console.log('setApproveTx:', hash);
|
|
135
|
-
}
|
|
136
|
-
return [3 /*break*/, 4];
|
|
137
|
-
case 3:
|
|
138
|
-
error_2 = _a.sent();
|
|
139
|
-
console.error('Approval failed:', error_2);
|
|
140
|
-
alert('Approval Failed');
|
|
141
|
-
return [3 /*break*/, 4];
|
|
142
|
-
case 4: return [2 /*return*/];
|
|
114
|
+
tokenAddress = bondData[0].principalToken;
|
|
115
|
+
decimals = 18;
|
|
116
|
+
try {
|
|
117
|
+
amount = convertToTokenValue(inputValue, decimals);
|
|
118
|
+
console.log('Amount:', amount);
|
|
119
|
+
writeContract({
|
|
120
|
+
address: tokenAddress,
|
|
121
|
+
abi: ERC_20_ABI,
|
|
122
|
+
functionName: 'approve',
|
|
123
|
+
args: [account, amount]
|
|
124
|
+
});
|
|
125
|
+
console.log('Transaction:', hash);
|
|
126
|
+
if (hash) {
|
|
127
|
+
setApproveTx(hash);
|
|
128
|
+
console.log('setApproveTx:', hash);
|
|
129
|
+
}
|
|
143
130
|
}
|
|
131
|
+
catch (error) {
|
|
132
|
+
console.error('Approval failed:', error);
|
|
133
|
+
alert('Approval Failed');
|
|
134
|
+
}
|
|
135
|
+
return [2 /*return*/];
|
|
144
136
|
});
|
|
145
137
|
}); };
|
|
146
138
|
var _f = useState(null), approveTx = _f[0], setApproveTx = _f[1];
|
|
@@ -195,7 +187,7 @@ var BondModal = function (_a) {
|
|
|
195
187
|
}
|
|
196
188
|
}, [isActive, account, bondData]);
|
|
197
189
|
var getTokenBalance = function (chainId, tokenAddress, walletAddress) { return __awaiter(void 0, void 0, void 0, function () {
|
|
198
|
-
var urls, provider, contract, balance, balanceInEther,
|
|
190
|
+
var urls, provider, contract, balance, balanceInEther, error_2;
|
|
199
191
|
return __generator(this, function (_a) {
|
|
200
192
|
switch (_a.label) {
|
|
201
193
|
case 0:
|
|
@@ -213,8 +205,8 @@ var BondModal = function (_a) {
|
|
|
213
205
|
console.log("Token Balance: ".concat(balanceInEther));
|
|
214
206
|
return [2 /*return*/, balanceInEther];
|
|
215
207
|
case 2:
|
|
216
|
-
|
|
217
|
-
console.error('Error fetching token balance',
|
|
208
|
+
error_2 = _a.sent();
|
|
209
|
+
console.error('Error fetching token balance', error_2);
|
|
218
210
|
return [2 /*return*/, 'Error fetching token balance'];
|
|
219
211
|
case 3: return [2 /*return*/];
|
|
220
212
|
}
|