@huma-finance/widgets 0.0.26 → 0.0.28
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 +134 -34
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/index.js +135 -35
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
- package/src/components/BottomButton.tsx +3 -1
- package/src/components/Lend/supply/1-Evaluation.tsx +110 -25
- package/src/index.tsx +2 -1
- package/src/utils/env.ts +3 -2
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { txAtom, useMQ, sendTxAtom, isTxFailed, EARejectionError, EARejectMessage, EARejectReason, EAService, useCLFeeManager, upScale, CHAINS, openInNewTab, usePoolUnderlyingTokenContract, TxStateType, useMount, usePoolContract, useCLPoolAllowance, toBigNumber, timeUtil, POOL_NAME, POOL_TYPE, usePoolInfo, useAccountStats, CreditState, decodeLogs, downScale, formatMoney, useFeeManager, combineStyles, isEmpty, useInvoiceNFTContract, useRFPoolAllowance, usePoolAllowance, useLenderApproved, useLenderPosition, useWithdrawlLockoutInSeconds, usePoolUnderlyingTokenBalance, useLastDepositTime, CreditEventText, useERC2612Permit, useMultiSendContract, usePoolUnderlyingToken, hasRFActiveLoan, timestampToLL, getWalletAddressAbbr, useFactoring, PoolMap, PoolContractMap, CreditEvent, supportedChainId, Provider as Provider$1 } from '@huma-finance/shared';
|
|
1
|
+
import { txAtom, useMQ, sendTxAtom, isTxFailed, EARejectionError, EARejectMessage, EARejectReason, EAService, useCLFeeManager, upScale, CHAINS, openInNewTab, usePoolUnderlyingTokenContract, TxStateType, useMount, usePoolContract, useCLPoolAllowance, toBigNumber, timeUtil, POOL_NAME, POOL_TYPE, usePoolInfo, useAccountStats, CreditState, decodeLogs, downScale, formatMoney, useFeeManager, combineStyles, isEmpty, useInvoiceNFTContract, useRFPoolAllowance, IdentityService, usePoolAllowance, useLenderApproved, useLenderPosition, useWithdrawlLockoutInSeconds, usePoolUnderlyingTokenBalance, useLastDepositTime, CreditEventText, useERC2612Permit, useMultiSendContract, usePoolUnderlyingToken, hasRFActiveLoan, timestampToLL, getWalletAddressAbbr, useFactoring, PoolMap, PoolContractMap, CreditEvent, supportedChainId, 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 * as React from 'react';
|
|
@@ -2406,7 +2406,7 @@ function WidgetWrapper(_ref) {
|
|
|
2406
2406
|
}
|
|
2407
2407
|
|
|
2408
2408
|
var checkIsDev = function checkIsDev() {
|
|
2409
|
-
return !!(window.
|
|
2409
|
+
return !!(window.location.hostname.startsWith('dev') || window.location.hostname.startsWith('deploy-preview') || process.env.NODE_ENV === 'development');
|
|
2410
2410
|
};
|
|
2411
2411
|
var envUtil = {
|
|
2412
2412
|
checkIsDev: checkIsDev
|
|
@@ -2812,6 +2812,8 @@ function ChooseAmount$6(_ref) {
|
|
|
2812
2812
|
var _templateObject$a;
|
|
2813
2813
|
function BottomButton(_ref) {
|
|
2814
2814
|
var variant = _ref.variant,
|
|
2815
|
+
_ref$disabled = _ref.disabled,
|
|
2816
|
+
disabled = _ref$disabled === void 0 ? false : _ref$disabled,
|
|
2815
2817
|
onClick = _ref.onClick,
|
|
2816
2818
|
children = _ref.children;
|
|
2817
2819
|
var styles = css(_templateObject$a || (_templateObject$a = _taggedTemplateLiteral(["\n & .MuiButtonBase-root {\n width: 100%;\n position: absolute;\n bottom: 0;\n }\n "])));
|
|
@@ -2820,6 +2822,7 @@ function BottomButton(_ref) {
|
|
|
2820
2822
|
children: jsx(Button, {
|
|
2821
2823
|
variant: variant,
|
|
2822
2824
|
onClick: onClick,
|
|
2825
|
+
disabled: disabled,
|
|
2823
2826
|
children: children
|
|
2824
2827
|
})
|
|
2825
2828
|
});
|
|
@@ -3499,7 +3502,7 @@ function ConfirmTransfer$1() {
|
|
|
3499
3502
|
leftText: "".concat(borrowAmountNet, " ").concat(approval === null || approval === void 0 ? void 0 : approval.token.symbol),
|
|
3500
3503
|
rightText: 'You'
|
|
3501
3504
|
}],
|
|
3502
|
-
actionText: "
|
|
3505
|
+
actionText: "APPROVE TRANSFER",
|
|
3503
3506
|
handleAction: handleAction
|
|
3504
3507
|
});
|
|
3505
3508
|
}
|
|
@@ -3769,10 +3772,12 @@ function InvoiceFactoringPayment(_ref) {
|
|
|
3769
3772
|
|
|
3770
3773
|
var _templateObject$6, _templateObject2$4;
|
|
3771
3774
|
function Evaluation$1(_ref) {
|
|
3775
|
+
var _poolInfo$extra;
|
|
3772
3776
|
var poolInfo = _ref.poolInfo,
|
|
3773
3777
|
handleApproveSuccess = _ref.handleApproveSuccess;
|
|
3774
3778
|
var theme = useTheme();
|
|
3775
3779
|
var dispatch = useAppDispatch();
|
|
3780
|
+
var isDev = envUtil.checkIsDev();
|
|
3776
3781
|
var _useWeb3React = useWeb3React(),
|
|
3777
3782
|
account = _useWeb3React.account,
|
|
3778
3783
|
chainId = _useWeb3React.chainId;
|
|
@@ -3780,65 +3785,154 @@ function Evaluation$1(_ref) {
|
|
|
3780
3785
|
_useState2 = _slicedToArray(_useState, 2),
|
|
3781
3786
|
loading = _useState2[0],
|
|
3782
3787
|
setLoading = _useState2[1];
|
|
3788
|
+
var _useState3 = useState(),
|
|
3789
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
3790
|
+
description = _useState4[0],
|
|
3791
|
+
setDescription = _useState4[1];
|
|
3792
|
+
var _useState5 = useState(),
|
|
3793
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
3794
|
+
KYCVerifyStatus = _useState6[0],
|
|
3795
|
+
setKYCVerifyStatus = _useState6[1];
|
|
3796
|
+
var lenderApprovalProvider = (_poolInfo$extra = poolInfo.extra) === null || _poolInfo$extra === void 0 ? void 0 : _poolInfo$extra.lenderApprovalProvider;
|
|
3797
|
+
var isKYC = (lenderApprovalProvider === null || lenderApprovalProvider === void 0 ? void 0 : lenderApprovalProvider.type) === 'KYC';
|
|
3798
|
+
var _useState7 = useState('This pool requires lender approval'),
|
|
3799
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
|
3800
|
+
subTitle = _useState8[0],
|
|
3801
|
+
setSubTitle = _useState8[1];
|
|
3802
|
+
var _useState9 = useState('GET APPROVED'),
|
|
3803
|
+
_useState10 = _slicedToArray(_useState9, 2),
|
|
3804
|
+
buttonText = _useState10[0],
|
|
3805
|
+
setButtonText = _useState10[1];
|
|
3783
3806
|
var styles = {
|
|
3784
3807
|
iconWrapper: css(_templateObject$6 || (_templateObject$6 = _taggedTemplateLiteral(["\n ", ";\n margin-top: 30px;\n "])), theme.cssMixins.rowCentered),
|
|
3785
3808
|
description: css(_templateObject2$4 || (_templateObject2$4 = _taggedTemplateLiteral(["\n ", ";\n margin-top: 50px;\n font-family: 'Uni-Neue-Regular';\n font-size: 16px;\n color: #a8a1b2;\n "])), theme.cssMixins.rowCentered)
|
|
3786
3809
|
};
|
|
3787
|
-
|
|
3788
|
-
|
|
3810
|
+
useEffect(function () {
|
|
3811
|
+
if (isKYC) {
|
|
3812
|
+
setDescription("Approval process is run by ".concat(lenderApprovalProvider.provider));
|
|
3813
|
+
}
|
|
3814
|
+
}, [lenderApprovalProvider === null || lenderApprovalProvider === void 0 ? void 0 : lenderApprovalProvider.provider, isKYC]);
|
|
3815
|
+
useEffect(function () {
|
|
3816
|
+
var fetchData = /*#__PURE__*/function () {
|
|
3817
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee() {
|
|
3818
|
+
var verificationStatus;
|
|
3819
|
+
return regenerator.wrap(function _callee$(_context) {
|
|
3820
|
+
while (1) switch (_context.prev = _context.next) {
|
|
3821
|
+
case 0:
|
|
3822
|
+
if (!(account && chainId && isKYC)) {
|
|
3823
|
+
_context.next = 11;
|
|
3824
|
+
break;
|
|
3825
|
+
}
|
|
3826
|
+
_context.prev = 1;
|
|
3827
|
+
setLoading(true);
|
|
3828
|
+
_context.next = 5;
|
|
3829
|
+
return IdentityService.getVerificationStatus(account, poolInfo.pool, chainId, isDev);
|
|
3830
|
+
case 5:
|
|
3831
|
+
verificationStatus = _context.sent;
|
|
3832
|
+
setKYCVerifyStatus(verificationStatus);
|
|
3833
|
+
if (verificationStatus.isVerified) {
|
|
3834
|
+
setSubTitle('Approval process in progress. Please contact Pool Owner.');
|
|
3835
|
+
setButtonText('CONTACT POOL OWNER');
|
|
3836
|
+
}
|
|
3837
|
+
case 8:
|
|
3838
|
+
_context.prev = 8;
|
|
3839
|
+
setLoading(false);
|
|
3840
|
+
return _context.finish(8);
|
|
3841
|
+
case 11:
|
|
3842
|
+
case "end":
|
|
3843
|
+
return _context.stop();
|
|
3844
|
+
}
|
|
3845
|
+
}, _callee, null, [[1,, 8, 11]]);
|
|
3846
|
+
}));
|
|
3847
|
+
return function fetchData() {
|
|
3848
|
+
return _ref2.apply(this, arguments);
|
|
3849
|
+
};
|
|
3850
|
+
}();
|
|
3851
|
+
fetchData();
|
|
3852
|
+
}, [account, chainId, isDev, isKYC, poolInfo.pool]);
|
|
3853
|
+
var approveLenderByEA = /*#__PURE__*/function () {
|
|
3854
|
+
var _ref3 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee2() {
|
|
3789
3855
|
var payload, error;
|
|
3790
|
-
return regenerator.wrap(function
|
|
3791
|
-
while (1) switch (
|
|
3856
|
+
return regenerator.wrap(function _callee2$(_context2) {
|
|
3857
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
3792
3858
|
case 0:
|
|
3793
|
-
|
|
3794
|
-
_context.next = 16;
|
|
3795
|
-
break;
|
|
3796
|
-
}
|
|
3797
|
-
_context.prev = 1;
|
|
3859
|
+
_context2.prev = 0;
|
|
3798
3860
|
setLoading(true);
|
|
3799
3861
|
payload = {
|
|
3800
3862
|
poolAddress: poolInfo.pool,
|
|
3801
3863
|
lenderWalletAddress: account
|
|
3802
3864
|
};
|
|
3803
|
-
|
|
3865
|
+
_context2.next = 5;
|
|
3804
3866
|
return EAService.approveLender(payload, chainId);
|
|
3805
|
-
case
|
|
3867
|
+
case 5:
|
|
3806
3868
|
handleApproveSuccess();
|
|
3807
3869
|
setLoading(false);
|
|
3808
3870
|
dispatch(setStep(WIDGET_STEP.ChooseAmount));
|
|
3809
|
-
|
|
3871
|
+
_context2.next = 15;
|
|
3810
3872
|
break;
|
|
3811
|
-
case
|
|
3812
|
-
|
|
3813
|
-
|
|
3814
|
-
error =
|
|
3873
|
+
case 10:
|
|
3874
|
+
_context2.prev = 10;
|
|
3875
|
+
_context2.t0 = _context2["catch"](0);
|
|
3876
|
+
error = _context2.t0;
|
|
3815
3877
|
setLoading(false);
|
|
3816
3878
|
dispatch(setError({
|
|
3817
3879
|
errorMessage: error.message
|
|
3818
3880
|
}));
|
|
3819
|
-
case
|
|
3881
|
+
case 15:
|
|
3820
3882
|
case "end":
|
|
3821
|
-
return
|
|
3883
|
+
return _context2.stop();
|
|
3822
3884
|
}
|
|
3823
|
-
},
|
|
3885
|
+
}, _callee2, null, [[0, 10]]);
|
|
3824
3886
|
}));
|
|
3825
|
-
return function
|
|
3826
|
-
return
|
|
3887
|
+
return function approveLenderByEA() {
|
|
3888
|
+
return _ref3.apply(this, arguments);
|
|
3827
3889
|
};
|
|
3828
3890
|
}();
|
|
3891
|
+
var approveLenderByKYC = function approveLenderByKYC() {
|
|
3892
|
+
switch (lenderApprovalProvider === null || lenderApprovalProvider === void 0 ? void 0 : lenderApprovalProvider.provider) {
|
|
3893
|
+
case 'Securitize':
|
|
3894
|
+
{
|
|
3895
|
+
var issuerId = '53a66b32-583e-40e7-ba90-baf516d2cadd';
|
|
3896
|
+
var baseUrl = "https://id".concat(isDev ? '.sandbox' : '', ".securitize.io");
|
|
3897
|
+
var originUrl = window.location.href.split('?')[0];
|
|
3898
|
+
var redirectUrl = "".concat(originUrl, "?type=KYC&pool=").concat(poolInfo.pool);
|
|
3899
|
+
var providerAuthorizeUrl = "".concat(baseUrl, "/#/authorize?issuerId=").concat(issuerId, "&scope=details&details=verification&redirectUrl=").concat(redirectUrl);
|
|
3900
|
+
var _ref4 = KYCVerifyStatus || {},
|
|
3901
|
+
isNotOnboarded = _ref4.isNotOnboarded;
|
|
3902
|
+
var providerUrl = isNotOnboarded ? providerAuthorizeUrl : baseUrl;
|
|
3903
|
+
window.location.href = providerUrl;
|
|
3904
|
+
}
|
|
3905
|
+
break;
|
|
3906
|
+
}
|
|
3907
|
+
};
|
|
3908
|
+
var approveLender = function approveLender() {
|
|
3909
|
+
switch (lenderApprovalProvider === null || lenderApprovalProvider === void 0 ? void 0 : lenderApprovalProvider.type) {
|
|
3910
|
+
case 'EA':
|
|
3911
|
+
approveLenderByEA();
|
|
3912
|
+
break;
|
|
3913
|
+
case 'KYC':
|
|
3914
|
+
approveLenderByKYC();
|
|
3915
|
+
break;
|
|
3916
|
+
default:
|
|
3917
|
+
approveLenderByEA();
|
|
3918
|
+
break;
|
|
3919
|
+
}
|
|
3920
|
+
};
|
|
3829
3921
|
if (!loading) {
|
|
3830
3922
|
return jsxs(WrapperModal, {
|
|
3831
3923
|
title: "Lender Approval",
|
|
3832
|
-
subTitle:
|
|
3924
|
+
subTitle: subTitle,
|
|
3833
3925
|
children: [jsx(Box, {
|
|
3834
3926
|
css: styles.iconWrapper,
|
|
3835
3927
|
children: jsx(ApproveLenderIcon, {})
|
|
3836
3928
|
}), jsx(Box, {
|
|
3837
|
-
css: styles.description
|
|
3929
|
+
css: styles.description,
|
|
3930
|
+
children: description
|
|
3838
3931
|
}), jsx(BottomButton, {
|
|
3839
3932
|
variant: "contained",
|
|
3840
3933
|
onClick: approveLender,
|
|
3841
|
-
|
|
3934
|
+
disabled: KYCVerifyStatus === null || KYCVerifyStatus === void 0 ? void 0 : KYCVerifyStatus.isVerified,
|
|
3935
|
+
children: buttonText
|
|
3842
3936
|
})]
|
|
3843
3937
|
});
|
|
3844
3938
|
}
|
|
@@ -4341,7 +4435,12 @@ var columns = [{
|
|
|
4341
4435
|
noSeparator: true
|
|
4342
4436
|
}, {
|
|
4343
4437
|
title: 'Amount',
|
|
4344
|
-
|
|
4438
|
+
action: function action(record) {
|
|
4439
|
+
if (isEmpty(record.amount) || Number.isNaN(record.amount)) {
|
|
4440
|
+
return '';
|
|
4441
|
+
}
|
|
4442
|
+
return Number(record.amount).toFixed(2);
|
|
4443
|
+
}
|
|
4345
4444
|
}, {
|
|
4346
4445
|
title: 'Date',
|
|
4347
4446
|
dataIndex: 'timestamp'
|
|
@@ -4556,7 +4655,7 @@ function ConfirmTransfer() {
|
|
|
4556
4655
|
leftText: "".concat(borrowAmount.toFixed(2), " ").concat(approval === null || approval === void 0 ? void 0 : approval.token.symbol),
|
|
4557
4656
|
rightText: 'You'
|
|
4558
4657
|
}],
|
|
4559
|
-
actionText: "
|
|
4658
|
+
actionText: "APPROVE TRANSFER",
|
|
4560
4659
|
handleAction: handleAction
|
|
4561
4660
|
});
|
|
4562
4661
|
}
|
|
@@ -6559,11 +6658,12 @@ var themeHuma = createTheme(themeBase, {
|
|
|
6559
6658
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
6560
6659
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
6561
6660
|
function Widget(props) {
|
|
6562
|
-
var _window$ethereum;
|
|
6563
6661
|
var children = props.children,
|
|
6564
6662
|
desiredChainId = props.desiredChainId;
|
|
6663
|
+
var _window = window,
|
|
6664
|
+
ethereum = _window.ethereum;
|
|
6565
6665
|
// @ts-ignore
|
|
6566
|
-
var netWorkVersion = (
|
|
6666
|
+
var netWorkVersion = (ethereum === null || ethereum === void 0 ? void 0 : ethereum.networkVersion) || (ethereum === null || ethereum === void 0 ? void 0 : ethereum.chainId);
|
|
6567
6667
|
var _useState = useState(netWorkVersion ? Number(netWorkVersion) : undefined),
|
|
6568
6668
|
_useState2 = _slicedToArray(_useState, 2),
|
|
6569
6669
|
currentChainId = _useState2[0],
|
|
@@ -6588,15 +6688,15 @@ function Widget(props) {
|
|
|
6588
6688
|
setCurrentChainId(chainId);
|
|
6589
6689
|
};
|
|
6590
6690
|
if (window.ethereum) {
|
|
6591
|
-
var _window$
|
|
6691
|
+
var _window$ethereum;
|
|
6592
6692
|
// @ts-ignore
|
|
6593
|
-
(_window$
|
|
6693
|
+
(_window$ethereum = window.ethereum) === null || _window$ethereum === void 0 ? void 0 : _window$ethereum.on('chainChanged', chainChangeListener);
|
|
6594
6694
|
}
|
|
6595
6695
|
return function () {
|
|
6596
6696
|
if (window.ethereum) {
|
|
6597
|
-
var _window$
|
|
6697
|
+
var _window$ethereum2;
|
|
6598
6698
|
// @ts-ignore
|
|
6599
|
-
(_window$
|
|
6699
|
+
(_window$ethereum2 = window.ethereum) === null || _window$ethereum2 === void 0 ? void 0 : _window$ethereum2.removeListener('chainChanged', chainChangeListener);
|
|
6600
6700
|
}
|
|
6601
6701
|
};
|
|
6602
6702
|
}, []);
|