@ape.swap/bonds-sdk 1.0.606 → 1.0.608

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.
@@ -54,21 +54,17 @@ import ERC_20_ABI from '../../../config/abi/erc20.json';
54
54
  import { NETWORK_ICONS } from '../../../config/constants/chains';
55
55
  import { formatUSDNumber, getPremiumColor, premium, youGet, youGetUSD, youSpend, youSpendUSD } from './helper';
56
56
  import '../../../scss/BondModal.scss';
57
- import { useWriteContract } from "wagmi";
57
+ import { useWaitForTransactionReceipt, useWriteContract } from "wagmi";
58
58
  import { PUBLIC_RPC_URLS } from "../../../config/constants/networks";
59
59
  var BondModal = function (_a) {
60
60
  var account = _a.account, isActive = _a.isActive, isOpen = _a.isOpen, accountChainId = _a.accountChainId, onClose = _a.onClose, bondAddress = _a.bondAddress;
61
61
  if (!isOpen)
62
62
  return null;
63
63
  var _b = useWriteContract(), hash = _b.data, isPending = _b.isPending, writeContract = _b.writeContract, writeContractAsync = _b.writeContractAsync;
64
- // const transactionReceipt = async (txHash: `0x${string}`) => {
65
- // return useWaitForTransactionReceipt({
66
- // confirmations: 4,
67
- // hash: txHash,
68
- // pollingInterval: 1_000
69
- // });
70
- // }
71
- var _c = useState([]), bondData = _c[0], setBondData = _c[1];
64
+ var _c = useWaitForTransactionReceipt({
65
+ hash: hash
66
+ }), isConfirming = _c.isLoading, isConfirmed = _c.isSuccess;
67
+ var _d = useState([]), bondData = _d[0], setBondData = _d[1];
72
68
  //This is a temp solution, but we will force approval each time, and then once set we will set status here and allow
73
69
  //user to buy
74
70
  //Check with Fede if this needs to be temp, if we force approval everytime, isn't this fine?
@@ -111,7 +107,7 @@ var BondModal = function (_a) {
111
107
  }
112
108
  });
113
109
  }); };
114
- var _d = useState(null), buyTx = _d[0], setBuyTx = _d[1];
110
+ var _e = useState(null), buyTx = _e[0], setBuyTx = _e[1];
115
111
  //You approve the token, not the contract (this code will have to be updated for zap)
116
112
  var handleApprove = function () { return __awaiter(void 0, void 0, void 0, function () {
117
113
  var tokenAddress, decimals, amount, tx, error_2;
@@ -135,6 +131,7 @@ var BondModal = function (_a) {
135
131
  tx = _a.sent();
136
132
  // const receipt = useWaitForTransactionReceipt({
137
133
  // confirmations: 4,
134
+ // chainId: accountChainId,
138
135
  // hash: tx,
139
136
  // pollingInterval: 1_000
140
137
  // });
@@ -157,10 +154,10 @@ var BondModal = function (_a) {
157
154
  }
158
155
  });
159
156
  }); };
160
- var _e = useState(null), receiptTx = _e[0], setReceiptTx = _e[1];
161
- var _f = useState(null), approveTx = _f[0], setApproveTx = _f[1];
162
- var _g = useState(null), tokenBalance = _g[0], setTokenBalance = _g[1];
163
- var _h = useState(null), tokenDecimals = _h[0], setTokenDecimals = _h[1];
157
+ var _f = useState(null), receiptTx = _f[0], setReceiptTx = _f[1];
158
+ var _g = useState(null), approveTx = _g[0], setApproveTx = _g[1];
159
+ var _h = useState(null), tokenBalance = _h[0], setTokenBalance = _h[1];
160
+ var _j = useState(null), tokenDecimals = _j[0], setTokenDecimals = _j[1];
164
161
  useEffect(function () {
165
162
  if (isActive && account && bondData.length > 0) {
166
163
  getTokenBalance(bondData[0].chainId, bondData[0].principalToken, account).then(function (_a) {
@@ -233,7 +230,7 @@ var BondModal = function (_a) {
233
230
  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));
234
231
  return !available ? 0 : (singlePurchaseLimit.lt(safeAvailable) ? singlePurchaseLimit : safeAvailable);
235
232
  };
236
- var _j = useState(''), inputValue = _j[0], setInputValue = _j[1];
233
+ var _k = useState(''), inputValue = _k[0], setInputValue = _k[1];
237
234
  var handleInputChange = function (event) {
238
235
  setInputValue(event.target.value);
239
236
  };
@@ -253,10 +250,10 @@ var BondModal = function (_a) {
253
250
  !!v.currentTarget.value && isNumber(v.currentTarget.value) && parseFloat(v.currentTarget.value) >= 0
254
251
  ? v.currentTarget.value
255
252
  : v.currentTarget.value.slice(0, v.currentTarget.value.length - 1);
256
- } }) }), _jsxs(Flex, { className: "input-container token", children: [_jsx(Flex, { className: "input-container bondicon", children: _jsxs("div", { className: "icon-container-small", children: [_jsx(Svg, { width: 12, height: 12, icon: (_m = NETWORK_ICONS === null || NETWORK_ICONS === void 0 ? void 0 : NETWORK_ICONS[bond.chainId]) !== null && _m !== void 0 ? _m : 'question' }), _jsx(TokenImage, { symbol: (_o = bond.principalTokenName) !== null && _o !== void 0 ? _o : bond.payoutTokenName, size: 30 })] }) }), _jsx(Flex, { className: "title-container tokenname-small", children: bond === null || bond === void 0 ? void 0 : bond.principalTokenName })] })] }), isActive && account && (_jsxs(Flex, { className: "input-container balancerow", children: [_jsxs(Flex, { className: "balancerow text", children: ["Balance: ", tokenBalance] }), _jsx(Flex, { className: "balancerow max", children: _jsx(Button, { onClick: function () { setInputValue(tokenBalance !== null && tokenBalance !== void 0 ? tokenBalance : '0'); }, children: "Max" }) })] }))] }), _jsxs(Flex, { className: "modal-container button-container", children: [_jsx(Flex, { className: "button-container get", children: _jsxs(Button, { onClick: function () { window.open('https://ape.bond/swap', '_blank'); }, children: ["Get ", bond === null || bond === void 0 ? void 0 : bond.principalTokenName] }) }), _jsx(Flex, { className: "button-container buy", children: approveTx != null && receiptTx != null ?
257
- _jsxs(Button, { disabled: isPending, onClick: handleBuy, children: ["Buy ", bond === null || bond === void 0 ? void 0 : bond.showcaseTokenName] })
253
+ } }) }), _jsxs(Flex, { className: "input-container token", children: [_jsx(Flex, { className: "input-container bondicon", children: _jsxs("div", { className: "icon-container-small", children: [_jsx(Svg, { width: 12, height: 12, icon: (_m = NETWORK_ICONS === null || NETWORK_ICONS === void 0 ? void 0 : NETWORK_ICONS[bond.chainId]) !== null && _m !== void 0 ? _m : 'question' }), _jsx(TokenImage, { symbol: (_o = bond.principalTokenName) !== null && _o !== void 0 ? _o : bond.payoutTokenName, size: 30 })] }) }), _jsx(Flex, { className: "title-container tokenname-small", children: bond === null || bond === void 0 ? void 0 : bond.principalTokenName })] })] }), isActive && account && (_jsxs(Flex, { className: "input-container balancerow", children: [_jsxs(Flex, { className: "balancerow text", children: ["Balance: ", tokenBalance] }), _jsx(Flex, { className: "balancerow max", children: _jsx(Button, { onClick: function () { setInputValue(tokenBalance !== null && tokenBalance !== void 0 ? tokenBalance : '0'); }, children: "Max" }) })] }))] }), _jsxs(Flex, { className: "modal-container button-container", children: [_jsx(Flex, { className: "button-container get", children: _jsxs(Button, { onClick: function () { window.open('https://ape.bond/swap', '_blank'); }, children: ["Get ", bond === null || bond === void 0 ? void 0 : bond.principalTokenName] }) }), _jsx(Flex, { className: "button-container buy", children: approveTx != null && isConfirmed ?
254
+ _jsxs(Button, { disabled: isPending || isConfirming, onClick: handleBuy, children: ["Buy ", bond === null || bond === void 0 ? void 0 : bond.showcaseTokenName] })
258
255
  :
259
- _jsx(Button, { disabled: isPending, onClick: handleApprove, children: "Approve" }) })] })] })] }) }) }, bond.billAddress));
256
+ _jsx(Button, { disabled: isPending || isConfirming, onClick: handleApprove, children: "Approve" }) })] })] })] }) }) }, bond.billAddress));
260
257
  }) }));
261
258
  };
262
259
  export default BondModal;
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.606",
6
+ "version": "1.0.608",
7
7
  "main": "dist/index.js",
8
8
  "module": "dist/index.es.js",
9
9
  "types": "dist/index.d.ts",