@ape.swap/bonds-sdk 1.0.564 → 1.0.567
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.
|
@@ -55,15 +55,18 @@ import ERC_20_ABI from '../../../config/abi/erc20.json';
|
|
|
55
55
|
import { NETWORK_ICONS } from '../../../config/constants/chains';
|
|
56
56
|
import { formatUSDNumber, getPremiumColor, premium, youGet, youGetUSD, youSpend, youSpendUSD } from './helper';
|
|
57
57
|
import '../../../scss/BondModal.scss';
|
|
58
|
-
import { useWriteContract } from "wagmi";
|
|
58
|
+
import { useWaitForTransactionReceipt, useWriteContract } from "wagmi";
|
|
59
59
|
import { PUBLIC_RPC_URLS } from "../../../config/constants/networks";
|
|
60
60
|
var BondModal = function (_a) {
|
|
61
61
|
var account = _a.account, accountChainId = _a.accountChainId, isActive = _a.isActive, isOpen = _a.isOpen, onClose = _a.onClose, bondAddress = _a.bondAddress;
|
|
62
62
|
if (!isOpen)
|
|
63
63
|
return null;
|
|
64
|
-
var
|
|
64
|
+
var _b = useWriteContract(), hash = _b.data, isPending = _b.isPending, writeContract = _b.writeContract;
|
|
65
|
+
var _c = useWaitForTransactionReceipt({
|
|
66
|
+
hash: hash,
|
|
67
|
+
}), isConfirming = _c.isLoading, isConfirmed = _c.isSuccess;
|
|
65
68
|
//const { account, isActive } = useWeb3React();
|
|
66
|
-
var
|
|
69
|
+
var _d = useState([]), bondData = _d[0], setBondData = _d[1];
|
|
67
70
|
//This is a temp solution, but we will force approval each time, and then once set we will set status here and allow
|
|
68
71
|
//user to buy
|
|
69
72
|
//Check with Fede if this needs to be temp, if we force approval everytime, isn't this fine?
|
|
@@ -101,7 +104,7 @@ var BondModal = function (_a) {
|
|
|
101
104
|
}
|
|
102
105
|
});
|
|
103
106
|
}); };
|
|
104
|
-
var
|
|
107
|
+
var _e = useState(null), buyTx = _e[0], setBuyTx = _e[1];
|
|
105
108
|
//You approve the token, not the contract (this code will have to be updated for zap)
|
|
106
109
|
var handleApprove = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
107
110
|
var tokenAddress, decimals, amount, tx, error_2;
|
|
@@ -123,9 +126,11 @@ var BondModal = function (_a) {
|
|
|
123
126
|
})];
|
|
124
127
|
case 2:
|
|
125
128
|
tx = _a.sent();
|
|
126
|
-
console.log('Transaction:',
|
|
127
|
-
|
|
128
|
-
|
|
129
|
+
console.log('Transaction:', hash);
|
|
130
|
+
console.log('IsPending:', isPending);
|
|
131
|
+
console.log('IsConfirmed:', isConfirmed);
|
|
132
|
+
if (hash != null) {
|
|
133
|
+
setApproveTx(hash);
|
|
129
134
|
}
|
|
130
135
|
return [3 /*break*/, 4];
|
|
131
136
|
case 3:
|
|
@@ -137,7 +142,7 @@ var BondModal = function (_a) {
|
|
|
137
142
|
}
|
|
138
143
|
});
|
|
139
144
|
}); };
|
|
140
|
-
var
|
|
145
|
+
var _f = useState(null), approveTx = _f[0], setApproveTx = _f[1];
|
|
141
146
|
// Fetch data
|
|
142
147
|
useEffect(function () {
|
|
143
148
|
axios.get('https://realtime-api.ape.bond/bonds').then(function (response) {
|
|
@@ -170,17 +175,17 @@ var BondModal = function (_a) {
|
|
|
170
175
|
var singlePurchaseLimit = new BigNumber((_c = bond === null || bond === void 0 ? void 0 : bond.maxPayout) !== null && _c !== void 0 ? _c : 0).div(new BigNumber(10).pow((_d = bond === null || bond === void 0 ? void 0 : bond.payoutTokenDecimals) !== null && _d !== void 0 ? _d : 18));
|
|
171
176
|
return !available ? 0 : (singlePurchaseLimit.lt(safeAvailable) ? singlePurchaseLimit : safeAvailable);
|
|
172
177
|
};
|
|
173
|
-
var
|
|
178
|
+
var _g = useState(''), inputValue = _g[0], setInputValue = _g[1];
|
|
174
179
|
var handleInputChange = function (event) {
|
|
175
180
|
setInputValue(event.target.value);
|
|
176
181
|
};
|
|
177
|
-
var
|
|
182
|
+
var _h = useState(null), selectedBond = _h[0], setSelectedBond = _h[1];
|
|
178
183
|
var navigate = useNavigate();
|
|
179
184
|
var projectInfo = function (bond) {
|
|
180
185
|
setSelectedBond(bond);
|
|
181
186
|
navigate("/bondsingle/".concat(bond.billAddress));
|
|
182
187
|
};
|
|
183
|
-
var
|
|
188
|
+
var _j = useState(null), tokenBalance = _j[0], setTokenBalance = _j[1];
|
|
184
189
|
useEffect(function () {
|
|
185
190
|
if (isActive && account && bondData.length > 0) {
|
|
186
191
|
getTokenBalance(bondData[0].chainId, bondData[0].principalToken, account).then(function (balance) {
|