@ape.swap/bonds-sdk 1.0.598 → 1.0.600
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,39 @@ 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
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
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
|
+
return [4 /*yield*/, writeContract({
|
|
117
|
+
address: tokenAddress,
|
|
118
|
+
abi: ERC_20_ABI,
|
|
119
|
+
functionName: 'approve',
|
|
120
|
+
args: [account, amount]
|
|
121
|
+
})];
|
|
122
|
+
case 2:
|
|
123
|
+
hash_1 = _a.sent();
|
|
124
|
+
alert(hash_1);
|
|
125
|
+
console.log(hash_1);
|
|
126
|
+
console.log('ApproveTransaction Hash__!:', hash_1);
|
|
127
|
+
if (hash_1 != null) {
|
|
128
|
+
setApproveTx(hash_1);
|
|
129
|
+
console.log('setApproveTx:', hash_1);
|
|
130
|
+
}
|
|
131
|
+
return [3 /*break*/, 4];
|
|
132
|
+
case 3:
|
|
133
|
+
error_1 = _a.sent();
|
|
134
|
+
console.error('Approval failed:', error_1);
|
|
135
|
+
alert('Approval Failed');
|
|
136
|
+
return [3 /*break*/, 4];
|
|
137
|
+
case 4: return [2 /*return*/];
|
|
128
138
|
}
|
|
129
|
-
return [2 /*return*/];
|
|
130
139
|
});
|
|
131
140
|
}); };
|
|
132
141
|
var _f = useState(null), approveTx = _f[0], setApproveTx = _f[1];
|
|
@@ -175,7 +184,7 @@ var BondModal = function (_a) {
|
|
|
175
184
|
}
|
|
176
185
|
}, [isActive, account, bondData]);
|
|
177
186
|
var getTokenBalance = function (chainId, tokenAddress, walletAddress) { return __awaiter(void 0, void 0, void 0, function () {
|
|
178
|
-
var urls, provider, contract, balance, balanceInEther,
|
|
187
|
+
var urls, provider, contract, balance, balanceInEther, error_2;
|
|
179
188
|
return __generator(this, function (_a) {
|
|
180
189
|
switch (_a.label) {
|
|
181
190
|
case 0:
|
|
@@ -193,8 +202,8 @@ var BondModal = function (_a) {
|
|
|
193
202
|
console.log("Token Balance: ".concat(balanceInEther));
|
|
194
203
|
return [2 /*return*/, balanceInEther];
|
|
195
204
|
case 2:
|
|
196
|
-
|
|
197
|
-
console.error('Error fetching token balance',
|
|
205
|
+
error_2 = _a.sent();
|
|
206
|
+
console.error('Error fetching token balance', error_2);
|
|
198
207
|
return [2 /*return*/, 'Error fetching token balance'];
|
|
199
208
|
case 3: return [2 /*return*/];
|
|
200
209
|
}
|