@ape.swap/bonds-sdk 1.0.607 → 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.
@@ -61,14 +61,10 @@ var BondModal = function (_a) {
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,10 +107,10 @@ 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
- var tokenAddress, decimals, amount, tx, receipt, error_2;
113
+ var tokenAddress, decimals, amount, tx, error_2;
118
114
  return __generator(this, function (_a) {
119
115
  switch (_a.label) {
120
116
  case 0:
@@ -133,17 +129,17 @@ var BondModal = function (_a) {
133
129
  })];
134
130
  case 2:
135
131
  tx = _a.sent();
136
- receipt = useWaitForTransactionReceipt({
137
- confirmations: 4,
138
- chainId: accountChainId,
139
- hash: tx,
140
- pollingInterval: 1000
141
- });
142
- console.log('Receipt', receipt);
143
- if (receipt.isSuccess) {
144
- setReceiptTx(receipt.data.transactionHash);
145
- console.log('Receipt:', receipt);
146
- }
132
+ // const receipt = useWaitForTransactionReceipt({
133
+ // confirmations: 4,
134
+ // chainId: accountChainId,
135
+ // hash: tx,
136
+ // pollingInterval: 1_000
137
+ // });
138
+ // console.log('Receipt',receipt);
139
+ // if(receipt.isSuccess) {
140
+ // setReceiptTx(receipt.data.transactionHash);
141
+ // console.log('Receipt:', receipt);
142
+ // }
147
143
  if (tx) {
148
144
  setApproveTx(tx);
149
145
  console.log('setApproveTx:', tx);
@@ -158,10 +154,10 @@ var BondModal = function (_a) {
158
154
  }
159
155
  });
160
156
  }); };
161
- var _e = useState(null), receiptTx = _e[0], setReceiptTx = _e[1];
162
- var _f = useState(null), approveTx = _f[0], setApproveTx = _f[1];
163
- var _g = useState(null), tokenBalance = _g[0], setTokenBalance = _g[1];
164
- 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];
165
161
  useEffect(function () {
166
162
  if (isActive && account && bondData.length > 0) {
167
163
  getTokenBalance(bondData[0].chainId, bondData[0].principalToken, account).then(function (_a) {
@@ -234,7 +230,7 @@ var BondModal = function (_a) {
234
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));
235
231
  return !available ? 0 : (singlePurchaseLimit.lt(safeAvailable) ? singlePurchaseLimit : safeAvailable);
236
232
  };
237
- var _j = useState(''), inputValue = _j[0], setInputValue = _j[1];
233
+ var _k = useState(''), inputValue = _k[0], setInputValue = _k[1];
238
234
  var handleInputChange = function (event) {
239
235
  setInputValue(event.target.value);
240
236
  };
@@ -254,10 +250,10 @@ var BondModal = function (_a) {
254
250
  !!v.currentTarget.value && isNumber(v.currentTarget.value) && parseFloat(v.currentTarget.value) >= 0
255
251
  ? v.currentTarget.value
256
252
  : v.currentTarget.value.slice(0, v.currentTarget.value.length - 1);
257
- } }) }), _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 ?
258
- _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] })
259
255
  :
260
- _jsx(Button, { disabled: isPending, onClick: handleApprove, children: "Approve" }) })] })] })] }) }) }, bond.billAddress));
256
+ _jsx(Button, { disabled: isPending || isConfirming, onClick: handleApprove, children: "Approve" }) })] })] })] }) }) }, bond.billAddress));
261
257
  }) }));
262
258
  };
263
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.607",
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",