@ape.swap/bonds-sdk 1.0.78-2.test.21 → 1.0.78-2.test.23
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.
- package/dist/components/AccordionText/index.d.ts +9 -0
- package/dist/components/AccordionText/index.js +17 -0
- package/dist/scss/AccordionText.scss +11 -0
- package/dist/scss/BondModal.scss +8 -0
- package/dist/views/BondModal/BondModal.d.ts +3 -0
- package/dist/views/BondModal/BondModal.js +15 -14
- package/package.json +1 -1
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "theme-ui/jsx-runtime";
|
|
2
|
+
import { useState } from 'react';
|
|
3
|
+
import { AnimatePresence, motion } from 'framer-motion';
|
|
4
|
+
import { Flex, Svg } from '../uikit-sdk';
|
|
5
|
+
import '../../scss/AccordionText.scss';
|
|
6
|
+
var AccordionText = function (_a) {
|
|
7
|
+
var title = _a.title, body = _a.body, _b = _a.isVisible, isVisible = _b === void 0 ? false : _b;
|
|
8
|
+
var _c = useState(false), isDropdownExpanded = _c[0], setIsDropdownExpanded = _c[1];
|
|
9
|
+
var toggleDropdown = function () {
|
|
10
|
+
setIsDropdownExpanded(!isDropdownExpanded);
|
|
11
|
+
};
|
|
12
|
+
if (!isVisible) {
|
|
13
|
+
return null;
|
|
14
|
+
}
|
|
15
|
+
return (_jsxs(_Fragment, { children: [_jsxs(Flex, { className: "accordion-header", onClick: toggleDropdown, children: [_jsx(Flex, { className: "accordion-title", children: title }), _jsx(Flex, { className: "accordion-icon", children: _jsx(Svg, { icon: "caret", direction: isDropdownExpanded ? 'down' : 'up' }) })] }), _jsx(AnimatePresence, { children: isDropdownExpanded && (_jsx(motion.div, { initial: { height: 0 }, animate: { height: 'fit-content' }, transition: { opacity: { duration: 0.2 } }, exit: { height: 0 }, sx: { overflow: 'hidden', width: '100%' }, children: _jsx(Flex, { className: "accordion-body", children: body }) })) })] }));
|
|
16
|
+
};
|
|
17
|
+
export default AccordionText;
|
package/dist/scss/BondModal.scss
CHANGED
|
@@ -383,6 +383,12 @@
|
|
|
383
383
|
}
|
|
384
384
|
}
|
|
385
385
|
|
|
386
|
+
.modaltable-container.accordion-container {
|
|
387
|
+
display: flex;
|
|
388
|
+
width: 100%;
|
|
389
|
+
padding-top: 10px;
|
|
390
|
+
}
|
|
391
|
+
|
|
386
392
|
.toast {
|
|
387
393
|
position: fixed;
|
|
388
394
|
top: 50px;
|
|
@@ -392,6 +398,8 @@
|
|
|
392
398
|
font-size: 24px;
|
|
393
399
|
padding: 10px 20px;
|
|
394
400
|
border-radius: 5px;
|
|
401
|
+
height: 75px;
|
|
402
|
+
align-items: center;
|
|
395
403
|
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
|
|
396
404
|
z-index: 9999;
|
|
397
405
|
animation: fadein 0.5s, fadeout 0.5s 4.5s;
|
|
@@ -8,6 +8,9 @@ export interface BondModalProps {
|
|
|
8
8
|
onClose: () => void;
|
|
9
9
|
bondAddress: string | null;
|
|
10
10
|
accountChainId: number;
|
|
11
|
+
accordionTitle: string;
|
|
12
|
+
accordionBody: string;
|
|
13
|
+
accordionVisible: boolean;
|
|
11
14
|
}
|
|
12
15
|
declare const BondModal: React.FC<BondModalProps>;
|
|
13
16
|
export default BondModal;
|
|
@@ -56,25 +56,26 @@ import '../../scss/BondModal.scss';
|
|
|
56
56
|
import { useChainId, useSwitchChain, useWaitForTransactionReceipt, useWriteContract } from "wagmi";
|
|
57
57
|
import { PUBLIC_RPC_URLS } from "../../config/constants/networks";
|
|
58
58
|
import useModal from "../../hooks/useModal";
|
|
59
|
+
import AccordionText from '../../components/AccordionText';
|
|
59
60
|
var BondModal = function (_a) {
|
|
60
|
-
var account = _a.account, isActive = _a.isActive, isOpen = _a.isOpen, accountChainId = _a.accountChainId, onClose = _a.onClose, bondAddress = _a.bondAddress;
|
|
61
|
+
var account = _a.account, isActive = _a.isActive, isOpen = _a.isOpen, accountChainId = _a.accountChainId, onClose = _a.onClose, bondAddress = _a.bondAddress, _b = _a.accordionTitle, accordionTitle = _b === void 0 ? "What are Bonds?" : _b, _c = _a.accordionBody, accordionBody = _c === void 0 ? "Body" : _c, _d = _a.accordionVisible, accordionVisible = _d === void 0 ? false : _d;
|
|
61
62
|
if (!isOpen)
|
|
62
63
|
return null;
|
|
63
64
|
var chainId = useChainId();
|
|
64
|
-
var
|
|
65
|
-
var
|
|
66
|
-
var
|
|
67
|
-
var
|
|
65
|
+
var _e = useSwitchChain(), chains = _e.chains, switchChain = _e.switchChain;
|
|
66
|
+
var _f = useState([]), bondData = _f[0], setBondData = _f[1];
|
|
67
|
+
var _g = useWriteContract(), hash = _g.data, isPending = _g.isPending, writeContract = _g.writeContract, writeContractAsync = _g.writeContractAsync;
|
|
68
|
+
var _h = useWaitForTransactionReceipt({
|
|
68
69
|
confirmations: 4,
|
|
69
70
|
chainId: chainId !== null && chainId !== void 0 ? chainId : accountChainId,
|
|
70
71
|
hash: hash,
|
|
71
|
-
}), isConfirming =
|
|
72
|
-
var
|
|
73
|
-
var
|
|
74
|
-
var
|
|
75
|
-
var
|
|
76
|
-
var
|
|
77
|
-
var
|
|
72
|
+
}), isConfirming = _h.isLoading, isConfirmed = _h.isSuccess;
|
|
73
|
+
var _j = useState(null), approveTx = _j[0], setApproveTx = _j[1];
|
|
74
|
+
var _k = useState(null), toastMessage = _k[0], setToastMessage = _k[1];
|
|
75
|
+
var _l = useState(null), buyTx = _l[0], setBuyTx = _l[1];
|
|
76
|
+
var _m = useState(null), tokenBalance = _m[0], setTokenBalance = _m[1];
|
|
77
|
+
var _o = useState(null), tokenDecimals = _o[0], setTokenDecimals = _o[1];
|
|
78
|
+
var _p = useState(''), inputValue = _p[0], setInputValue = _p[1];
|
|
78
79
|
var handleInputChange = function (event) {
|
|
79
80
|
setInputValue(event.target.value);
|
|
80
81
|
};
|
|
@@ -276,7 +277,7 @@ var BondModal = function (_a) {
|
|
|
276
277
|
!!v.currentTarget.value && isNumber(v.currentTarget.value) && parseFloat(v.currentTarget.value) >= 0
|
|
277
278
|
? v.currentTarget.value
|
|
278
279
|
: v.currentTarget.value.slice(0, v.currentTarget.value.length - 1);
|
|
279
|
-
} }) }), _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.lpToken.symbol) !== null && _o !== void 0 ? _o : bond.earnToken.symbol, size: 30 })] }) }), _jsx(Flex, { className: "title-container
|
|
280
|
+
} }) }), _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.lpToken.symbol) !== null && _o !== void 0 ? _o : bond.earnToken.symbol, size: 30 })] }) }), _jsx(Flex, { className: "title-container bondname-small", children: bond === null || bond === void 0 ? void 0 : bond.lpToken.symbol })] })] }), 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, { className: "max-button", onClick: function () {
|
|
280
281
|
setInputValue(tokenBalance !== null && tokenBalance !== void 0 ? tokenBalance : '0');
|
|
281
282
|
}, children: "Max" }) })] }))] }), _jsxs(Flex, { className: "modaltable-container button-container", children: [_jsx(Flex, { className: "button-container get", children: _jsxs(Button, { className: "action-button", onClick: onAsd, children: ["Get ", bond === null || bond === void 0 ? void 0 : bond.lpToken.symbol] }) }), _jsx(Flex, { className: "button-container buy", children: chainId !== bond.chainId
|
|
282
283
|
?
|
|
@@ -288,7 +289,7 @@ var BondModal = function (_a) {
|
|
|
288
289
|
approveTx != null && isConfirmed ?
|
|
289
290
|
_jsx(Button, { className: "action-button", disabled: isPending || isConfirming || (bond === null || bond === void 0 ? void 0 : bond.soldOut) || !account, onClick: handleBuy, children: getActionButtonText(bond) })
|
|
290
291
|
:
|
|
291
|
-
_jsx(Button, { className: "action-button", disabled: isPending || isConfirming || (bond === null || bond === void 0 ? void 0 : bond.soldOut) || !account, onClick: handleApprove, children: getActionButtonText(bond) }) })] })] })] }) }) }, bond.billAddress));
|
|
292
|
+
_jsx(Button, { className: "action-button", disabled: isPending || isConfirming || (bond === null || bond === void 0 ? void 0 : bond.soldOut) || !account, onClick: handleApprove, children: getActionButtonText(bond) }) })] }), _jsx(Flex, { className: "modaltable-container accordion-container", children: _jsx(AccordionText, { title: accordionTitle, body: accordionBody, isVisible: accordionVisible }) })] })] }) }) }, bond.billAddress));
|
|
292
293
|
}) }));
|
|
293
294
|
};
|
|
294
295
|
export default BondModal;
|