@huma-finance/widgets 0.0.11 → 0.0.12
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/cjs/index.cjs +22 -13
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/index.js +23 -14
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
- package/src/components/ChooseAmountModal.tsx +11 -4
- package/src/components/CreditLine/borrow/3-ChooseAmount.tsx +2 -8
- package/src/components/CreditLine/borrow/{5-Transfer.tsx → 4-Transfer.tsx} +17 -3
- package/src/components/CreditLine/borrow/{4-ApproveAllowance.tsx → 5-ApproveAllowance.tsx} +1 -1
- package/src/components/CreditLine/borrow/index.tsx +2 -2
- package/src/cosmos/SDKTesting.fixture.tsx +79 -21
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { txAtom, useMQ, sendTxAtom, isTxFailed, EARejectionError, EARejectMessage, EARejectReason, downScale, EAService, ChainEnum, EARejectMessageWithAllowList,
|
|
1
|
+
import { txAtom, useMQ, sendTxAtom, isTxFailed, EARejectionError, EARejectMessage, EARejectReason, downScale, EAService, ChainEnum, EARejectMessageWithAllowList, useCLFeeManager, upScale, CHAINS, openInNewTab, usePoolUnderlyingTokenContract, TxStateType, useMount, usePoolContract, useCLPoolAllowance, toBigNumber, timeUtil, POOL_NAME, POOL_TYPE, usePoolInfo, useAccountStats, CreditState, decodeLogs, formatMoney, useFeeManager, isEmpty, useInvoiceNFTContract, useRFPoolAllowance, usePoolAllowance, useLenderApproved, useLenderPosition, useWithdrawlLockoutInSeconds, usePoolUnderlyingTokenBalance, useLastDepositTime, CreditEventText, useERC2612Permit, useMultiSendContract, usePoolUnderlyingToken, hasRFActiveLoan, timestampToLL, getWalletAddressAbbr, useFactoring, PoolMap, PoolContractMap, CreditEvent, Provider as Provider$1 } from '@huma-finance/shared';
|
|
2
2
|
import { useTheme, css, Box, Typography, Tooltip, Button, Dialog, Slider, Input, Divider, TablePagination, LinearProgress, createTheme, ThemeProvider } from '@mui/material';
|
|
3
3
|
import { useAtom, Provider as Provider$2 } from 'jotai';
|
|
4
4
|
import { useSelector, useDispatch, Provider } from 'react-redux';
|
|
@@ -2693,6 +2693,10 @@ function ChooseAmountModal(_ref) {
|
|
|
2693
2693
|
var theme = useTheme();
|
|
2694
2694
|
var _useMQ = useMQ(),
|
|
2695
2695
|
isXsSize = _useMQ.isXsSize;
|
|
2696
|
+
var _useState = useState(false),
|
|
2697
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
2698
|
+
inputTouched = _useState2[0],
|
|
2699
|
+
setInputTouched = _useState2[1];
|
|
2696
2700
|
var styles = {
|
|
2697
2701
|
subTitle: css(_templateObject$c || (_templateObject$c = _taggedTemplateLiteral(["\n font-family: 'Uni-Neue-Regular';\n "]))),
|
|
2698
2702
|
description2: css(_templateObject2$9 || (_templateObject2$9 = _taggedTemplateLiteral(["\n ", ";\n font-family: 'Uni-Neue-Regular';\n font-size: 16px;\n color: #a8a1b2;\n margin-top: 16px;\n "])), theme.cssMixins.rowCentered),
|
|
@@ -2720,6 +2724,7 @@ function ChooseAmountModal(_ref) {
|
|
|
2720
2724
|
handleChangeAmount(newValue);
|
|
2721
2725
|
};
|
|
2722
2726
|
var handleInputChange = function handleInputChange(event) {
|
|
2727
|
+
setInputTouched(true);
|
|
2723
2728
|
// @ts-ignore
|
|
2724
2729
|
handleChangeAmount(event.target.value);
|
|
2725
2730
|
};
|
|
@@ -2784,7 +2789,7 @@ function ChooseAmountModal(_ref) {
|
|
|
2784
2789
|
})]
|
|
2785
2790
|
})
|
|
2786
2791
|
}), jsx(Slider, {
|
|
2787
|
-
max: sliderMax,
|
|
2792
|
+
max: Number(sliderMax),
|
|
2788
2793
|
min: 0,
|
|
2789
2794
|
css: styles.slider,
|
|
2790
2795
|
"aria-label": "Amount",
|
|
@@ -2798,8 +2803,9 @@ function ChooseAmountModal(_ref) {
|
|
|
2798
2803
|
children: [jsx(Input, {
|
|
2799
2804
|
css: styles.inputField,
|
|
2800
2805
|
type: "number",
|
|
2801
|
-
value: currentAmount,
|
|
2802
|
-
onChange: handleInputChange
|
|
2806
|
+
value: !inputTouched && currentAmount === 0 ? '' : currentAmount,
|
|
2807
|
+
onChange: handleInputChange,
|
|
2808
|
+
placeholder: "0"
|
|
2803
2809
|
}), jsx(Button, {
|
|
2804
2810
|
variant: "contained",
|
|
2805
2811
|
css: styles.maxButton,
|
|
@@ -2836,7 +2842,7 @@ function ChooseAmountModal(_ref) {
|
|
|
2836
2842
|
variant: "contained",
|
|
2837
2843
|
css: styles.okButton,
|
|
2838
2844
|
onClick: handleAction,
|
|
2839
|
-
disabled: currentAmount
|
|
2845
|
+
disabled: !currentAmount || Number(currentAmount) <= 0 || Number(currentAmount) > Number(sliderMax),
|
|
2840
2846
|
children: actionText.toUpperCase()
|
|
2841
2847
|
}), !hideTerms && jsxs(Box, {
|
|
2842
2848
|
css: styles.terms,
|
|
@@ -2849,13 +2855,9 @@ function ChooseAmount$6(_ref) {
|
|
|
2849
2855
|
var poolInfo = _ref.poolInfo,
|
|
2850
2856
|
accountStats = _ref.accountStats;
|
|
2851
2857
|
var dispatch = useAppDispatch();
|
|
2852
|
-
var _useWeb3React = useWeb3React(),
|
|
2853
|
-
account = _useWeb3React.account;
|
|
2854
2858
|
var poolUnderlyingToken = poolInfo.poolUnderlyingToken;
|
|
2855
2859
|
var symbol = poolUnderlyingToken.symbol,
|
|
2856
2860
|
decimals = poolUnderlyingToken.decimals;
|
|
2857
|
-
var _useCLPoolAllowance = useCLPoolAllowance(poolInfo.poolName, account),
|
|
2858
|
-
approved = _useCLPoolAllowance.approved;
|
|
2859
2861
|
var _useCLFeeManager = useCLFeeManager(poolInfo.poolName),
|
|
2860
2862
|
getFeesCharged = _useCLFeeManager.getFeesCharged;
|
|
2861
2863
|
var _useState = useState(0),
|
|
@@ -2874,14 +2876,14 @@ function ChooseAmount$6(_ref) {
|
|
|
2874
2876
|
setChargedFees(newChargedFees);
|
|
2875
2877
|
}, [getFeesCharged]);
|
|
2876
2878
|
var handleAction = useCallback(function () {
|
|
2877
|
-
var nextStep =
|
|
2879
|
+
var nextStep = WIDGET_STEP.Transfer;
|
|
2878
2880
|
dispatch(setBorrowInfo({
|
|
2879
2881
|
borrowAmount: currentAmount,
|
|
2880
2882
|
borrowAmountBN: upScale(currentAmount, decimals),
|
|
2881
2883
|
chargedFees: chargedFees,
|
|
2882
2884
|
nextStep: nextStep
|
|
2883
2885
|
}));
|
|
2884
|
-
}, [
|
|
2886
|
+
}, [chargedFees, currentAmount, decimals, dispatch]);
|
|
2885
2887
|
return jsx(ChooseAmountModal, {
|
|
2886
2888
|
title: "Borrow",
|
|
2887
2889
|
description1: "Choose Amount",
|
|
@@ -3008,7 +3010,7 @@ function ApproveAllowance$4(_ref) {
|
|
|
3008
3010
|
var poolInfo = _ref.poolInfo;
|
|
3009
3011
|
var dispatch = useAppDispatch();
|
|
3010
3012
|
var handleSuccess = useCallback(function () {
|
|
3011
|
-
dispatch(setStep(WIDGET_STEP.
|
|
3013
|
+
dispatch(setStep(WIDGET_STEP.Done));
|
|
3012
3014
|
}, [dispatch]);
|
|
3013
3015
|
return jsx(ApproveAllowanceModal, {
|
|
3014
3016
|
poolInfo: poolInfo,
|
|
@@ -3061,11 +3063,18 @@ function TxSendModal(_ref) {
|
|
|
3061
3063
|
function Transfer$6(_ref) {
|
|
3062
3064
|
var poolInfo = _ref.poolInfo;
|
|
3063
3065
|
var dispatch = useAppDispatch();
|
|
3066
|
+
var reset = useResetAtom(txAtom);
|
|
3067
|
+
var _useWeb3React = useWeb3React(),
|
|
3068
|
+
account = _useWeb3React.account;
|
|
3064
3069
|
var _useAppSelector = useAppSelector(selectWidgetState),
|
|
3065
3070
|
borrowAmountBN = _useAppSelector.borrowAmountBN;
|
|
3071
|
+
var _useCLPoolAllowance = useCLPoolAllowance(poolInfo.poolName, account),
|
|
3072
|
+
allowance = _useCLPoolAllowance.allowance;
|
|
3066
3073
|
var handleSuccess = useCallback(function () {
|
|
3067
|
-
|
|
3068
|
-
|
|
3074
|
+
reset();
|
|
3075
|
+
var nextStep = allowance.gte(toBigNumber(borrowAmountBN)) ? WIDGET_STEP.Done : WIDGET_STEP.ApproveAllowance;
|
|
3076
|
+
dispatch(setStep(nextStep));
|
|
3077
|
+
}, [allowance, borrowAmountBN, dispatch, reset]);
|
|
3069
3078
|
return jsx(TxSendModal, {
|
|
3070
3079
|
poolInfo: poolInfo,
|
|
3071
3080
|
method: "drawdown",
|