@ape.swap/bonds-sdk 1.0.569 → 1.0.571
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.
|
@@ -3,11 +3,11 @@ import React from 'react';
|
|
|
3
3
|
import '../../../scss/BondModal.scss';
|
|
4
4
|
interface BondModalProps {
|
|
5
5
|
account: string;
|
|
6
|
-
accountChainId: number;
|
|
7
6
|
isActive: boolean;
|
|
8
7
|
isOpen: boolean;
|
|
9
8
|
onClose: () => void;
|
|
10
9
|
bondAddress: string | null;
|
|
10
|
+
accountChainId: number;
|
|
11
11
|
}
|
|
12
12
|
declare const BondModal: React.FC<BondModalProps>;
|
|
13
13
|
export default BondModal;
|
|
@@ -58,7 +58,7 @@ import '../../../scss/BondModal.scss';
|
|
|
58
58
|
import { useWaitForTransactionReceipt, useWriteContract } from "wagmi";
|
|
59
59
|
import { PUBLIC_RPC_URLS } from "../../../config/constants/networks";
|
|
60
60
|
var BondModal = function (_a) {
|
|
61
|
-
var account = _a.account,
|
|
61
|
+
var account = _a.account, isActive = _a.isActive, isOpen = _a.isOpen, accountChainId = _a.accountChainId, onClose = _a.onClose, bondAddress = _a.bondAddress;
|
|
62
62
|
if (!isOpen)
|
|
63
63
|
return null;
|
|
64
64
|
var _b = useWriteContract(), hash = _b.data, isPending = _b.isPending, writeContract = _b.writeContract;
|
|
@@ -71,39 +71,31 @@ var BondModal = function (_a) {
|
|
|
71
71
|
//user to buy
|
|
72
72
|
//Check with Fede if this needs to be temp, if we force approval everytime, isn't this fine?
|
|
73
73
|
var handleBuy = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
74
|
-
var billAddress, decimals, maxPrice, amount
|
|
74
|
+
var billAddress, decimals, maxPrice, amount;
|
|
75
75
|
return __generator(this, function (_a) {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
// @ts-ignore
|
|
94
|
-
_a.sent();
|
|
95
|
-
console.log('Transaction:', hash);
|
|
96
|
-
if (hash != null) {
|
|
97
|
-
setBuyTx(hash);
|
|
98
|
-
}
|
|
99
|
-
return [3 /*break*/, 4];
|
|
100
|
-
case 3:
|
|
101
|
-
error_1 = _a.sent();
|
|
102
|
-
console.error('Buy error', error_1);
|
|
103
|
-
alert('Buy Failed');
|
|
104
|
-
return [3 /*break*/, 4];
|
|
105
|
-
case 4: return [2 /*return*/];
|
|
76
|
+
billAddress = bondData[0].billAddress;
|
|
77
|
+
decimals = 18;
|
|
78
|
+
try {
|
|
79
|
+
maxPrice = new BigNumber(bondData[0].trueBillPrice).times(102).div(100);
|
|
80
|
+
amount = convertToTokenValue(inputValue, decimals);
|
|
81
|
+
// @ts-ignore
|
|
82
|
+
writeContract({
|
|
83
|
+
address: billAddress,
|
|
84
|
+
abi: BOND_ABI,
|
|
85
|
+
functionName: 'deposit',
|
|
86
|
+
args: [amount, maxPrice, account],
|
|
87
|
+
});
|
|
88
|
+
console.log('BuyTransaction:', hash);
|
|
89
|
+
if (hash) {
|
|
90
|
+
setBuyTx(hash);
|
|
91
|
+
console.log('setBuyTx:', hash);
|
|
92
|
+
}
|
|
106
93
|
}
|
|
94
|
+
catch (error) {
|
|
95
|
+
console.error('Buy error', error);
|
|
96
|
+
alert('Buy Failed');
|
|
97
|
+
}
|
|
98
|
+
return [2 /*return*/];
|
|
107
99
|
});
|
|
108
100
|
}); };
|
|
109
101
|
var _e = useState(null), buyTx = _e[0], setBuyTx = _e[1];
|
|
@@ -122,7 +114,7 @@ var BondModal = function (_a) {
|
|
|
122
114
|
functionName: 'approve',
|
|
123
115
|
args: [account, amount]
|
|
124
116
|
});
|
|
125
|
-
console.log('
|
|
117
|
+
console.log('ApproveTransaction:', hash);
|
|
126
118
|
if (hash) {
|
|
127
119
|
setApproveTx(hash);
|
|
128
120
|
console.log('setApproveTx:', hash);
|
|
@@ -187,7 +179,7 @@ var BondModal = function (_a) {
|
|
|
187
179
|
}
|
|
188
180
|
}, [isActive, account, bondData]);
|
|
189
181
|
var getTokenBalance = function (chainId, tokenAddress, walletAddress) { return __awaiter(void 0, void 0, void 0, function () {
|
|
190
|
-
var urls, provider, contract, balance, balanceInEther,
|
|
182
|
+
var urls, provider, contract, balance, balanceInEther, error_1;
|
|
191
183
|
return __generator(this, function (_a) {
|
|
192
184
|
switch (_a.label) {
|
|
193
185
|
case 0:
|
|
@@ -205,8 +197,8 @@ var BondModal = function (_a) {
|
|
|
205
197
|
console.log("Token Balance: ".concat(balanceInEther));
|
|
206
198
|
return [2 /*return*/, balanceInEther];
|
|
207
199
|
case 2:
|
|
208
|
-
|
|
209
|
-
console.error('Error fetching token balance',
|
|
200
|
+
error_1 = _a.sent();
|
|
201
|
+
console.error('Error fetching token balance', error_1);
|
|
210
202
|
return [2 /*return*/, 'Error fetching token balance'];
|
|
211
203
|
case 3: return [2 /*return*/];
|
|
212
204
|
}
|