@ape.swap/bonds-sdk 1.0.566 → 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 _b = useWriteContract(), hash = _b.data, writeContract = _b.writeContract;
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 _c = useState([]), bondData = _c[0], setBondData = _c[1];
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,10 +104,10 @@ var BondModal = function (_a) {
101
104
  }
102
105
  });
103
106
  }); };
104
- var _d = useState(null), buyTx = _d[0], setBuyTx = _d[1];
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
- var tokenAddress, decimals, amount, error_2;
110
+ var tokenAddress, decimals, amount, tx, error_2;
108
111
  return __generator(this, function (_a) {
109
112
  switch (_a.label) {
110
113
  case 0:
@@ -122,8 +125,10 @@ var BondModal = function (_a) {
122
125
  args: [account, amount],
123
126
  })];
124
127
  case 2:
125
- _a.sent();
128
+ tx = _a.sent();
126
129
  console.log('Transaction:', hash);
130
+ console.log('IsPending:', isPending);
131
+ console.log('IsConfirmed:', isConfirmed);
127
132
  if (hash != null) {
128
133
  setApproveTx(hash);
129
134
  }
@@ -137,7 +142,7 @@ var BondModal = function (_a) {
137
142
  }
138
143
  });
139
144
  }); };
140
- var _e = useState(null), approveTx = _e[0], setApproveTx = _e[1];
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 _f = useState(''), inputValue = _f[0], setInputValue = _f[1];
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 _g = useState(null), selectedBond = _g[0], setSelectedBond = _g[1];
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 _h = useState(null), tokenBalance = _h[0], setTokenBalance = _h[1];
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) {
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "description": "Ape Bond SDK",
4
4
  "author": "Ape Bond",
5
5
  "license": "MIT",
6
- "version": "1.0.566",
6
+ "version": "1.0.567",
7
7
  "main": "dist/index.js",
8
8
  "module": "dist/index.es.js",
9
9
  "types": "dist/index.d.ts",