@huma-finance/widgets 0.0.27 → 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.
@@ -2444,7 +2444,7 @@ function WidgetWrapper(_ref) {
2444
2444
  }
2445
2445
 
2446
2446
  var checkIsDev = function checkIsDev() {
2447
- return !!(window.REACT_APP_FORCE_DEV_PREFIX_FOR_URLS || window.location.hostname.startsWith('dev'));
2447
+ return !!(window.location.hostname.startsWith('dev') || window.location.hostname.startsWith('deploy-preview') || process.env.NODE_ENV === 'development');
2448
2448
  };
2449
2449
  var envUtil = {
2450
2450
  checkIsDev: checkIsDev
@@ -2850,6 +2850,8 @@ function ChooseAmount$6(_ref) {
2850
2850
  var _templateObject$a;
2851
2851
  function BottomButton(_ref) {
2852
2852
  var variant = _ref.variant,
2853
+ _ref$disabled = _ref.disabled,
2854
+ disabled = _ref$disabled === void 0 ? false : _ref$disabled,
2853
2855
  onClick = _ref.onClick,
2854
2856
  children = _ref.children;
2855
2857
  var styles = material.css(_templateObject$a || (_templateObject$a = _taggedTemplateLiteral(["\n & .MuiButtonBase-root {\n width: 100%;\n position: absolute;\n bottom: 0;\n }\n "])));
@@ -2858,6 +2860,7 @@ function BottomButton(_ref) {
2858
2860
  children: jsxRuntime.jsx(material.Button, {
2859
2861
  variant: variant,
2860
2862
  onClick: onClick,
2863
+ disabled: disabled,
2861
2864
  children: children
2862
2865
  })
2863
2866
  });
@@ -3537,7 +3540,7 @@ function ConfirmTransfer$1() {
3537
3540
  leftText: "".concat(borrowAmountNet, " ").concat(approval === null || approval === void 0 ? void 0 : approval.token.symbol),
3538
3541
  rightText: 'You'
3539
3542
  }],
3540
- actionText: "Approve Transfer",
3543
+ actionText: "APPROVE TRANSFER",
3541
3544
  handleAction: handleAction
3542
3545
  });
3543
3546
  }
@@ -3807,10 +3810,12 @@ function InvoiceFactoringPayment(_ref) {
3807
3810
 
3808
3811
  var _templateObject$6, _templateObject2$4;
3809
3812
  function Evaluation$1(_ref) {
3813
+ var _poolInfo$extra;
3810
3814
  var poolInfo = _ref.poolInfo,
3811
3815
  handleApproveSuccess = _ref.handleApproveSuccess;
3812
3816
  var theme = material.useTheme();
3813
3817
  var dispatch = useAppDispatch();
3818
+ var isDev = envUtil.checkIsDev();
3814
3819
  var _useWeb3React = core.useWeb3React(),
3815
3820
  account = _useWeb3React.account,
3816
3821
  chainId = _useWeb3React.chainId;
@@ -3818,65 +3823,154 @@ function Evaluation$1(_ref) {
3818
3823
  _useState2 = _slicedToArray(_useState, 2),
3819
3824
  loading = _useState2[0],
3820
3825
  setLoading = _useState2[1];
3826
+ var _useState3 = React.useState(),
3827
+ _useState4 = _slicedToArray(_useState3, 2),
3828
+ description = _useState4[0],
3829
+ setDescription = _useState4[1];
3830
+ var _useState5 = React.useState(),
3831
+ _useState6 = _slicedToArray(_useState5, 2),
3832
+ KYCVerifyStatus = _useState6[0],
3833
+ setKYCVerifyStatus = _useState6[1];
3834
+ var lenderApprovalProvider = (_poolInfo$extra = poolInfo.extra) === null || _poolInfo$extra === void 0 ? void 0 : _poolInfo$extra.lenderApprovalProvider;
3835
+ var isKYC = (lenderApprovalProvider === null || lenderApprovalProvider === void 0 ? void 0 : lenderApprovalProvider.type) === 'KYC';
3836
+ var _useState7 = React.useState('This pool requires lender approval'),
3837
+ _useState8 = _slicedToArray(_useState7, 2),
3838
+ subTitle = _useState8[0],
3839
+ setSubTitle = _useState8[1];
3840
+ var _useState9 = React.useState('GET APPROVED'),
3841
+ _useState10 = _slicedToArray(_useState9, 2),
3842
+ buttonText = _useState10[0],
3843
+ setButtonText = _useState10[1];
3821
3844
  var styles = {
3822
3845
  iconWrapper: material.css(_templateObject$6 || (_templateObject$6 = _taggedTemplateLiteral(["\n ", ";\n margin-top: 30px;\n "])), theme.cssMixins.rowCentered),
3823
3846
  description: material.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)
3824
3847
  };
3825
- var approveLender = /*#__PURE__*/function () {
3826
- var _ref2 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee() {
3848
+ React.useEffect(function () {
3849
+ if (isKYC) {
3850
+ setDescription("Approval process is run by ".concat(lenderApprovalProvider.provider));
3851
+ }
3852
+ }, [lenderApprovalProvider === null || lenderApprovalProvider === void 0 ? void 0 : lenderApprovalProvider.provider, isKYC]);
3853
+ React.useEffect(function () {
3854
+ var fetchData = /*#__PURE__*/function () {
3855
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee() {
3856
+ var verificationStatus;
3857
+ return regenerator.wrap(function _callee$(_context) {
3858
+ while (1) switch (_context.prev = _context.next) {
3859
+ case 0:
3860
+ if (!(account && chainId && isKYC)) {
3861
+ _context.next = 11;
3862
+ break;
3863
+ }
3864
+ _context.prev = 1;
3865
+ setLoading(true);
3866
+ _context.next = 5;
3867
+ return shared.IdentityService.getVerificationStatus(account, poolInfo.pool, chainId, isDev);
3868
+ case 5:
3869
+ verificationStatus = _context.sent;
3870
+ setKYCVerifyStatus(verificationStatus);
3871
+ if (verificationStatus.isVerified) {
3872
+ setSubTitle('Approval process in progress. Please contact Pool Owner.');
3873
+ setButtonText('CONTACT POOL OWNER');
3874
+ }
3875
+ case 8:
3876
+ _context.prev = 8;
3877
+ setLoading(false);
3878
+ return _context.finish(8);
3879
+ case 11:
3880
+ case "end":
3881
+ return _context.stop();
3882
+ }
3883
+ }, _callee, null, [[1,, 8, 11]]);
3884
+ }));
3885
+ return function fetchData() {
3886
+ return _ref2.apply(this, arguments);
3887
+ };
3888
+ }();
3889
+ fetchData();
3890
+ }, [account, chainId, isDev, isKYC, poolInfo.pool]);
3891
+ var approveLenderByEA = /*#__PURE__*/function () {
3892
+ var _ref3 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee2() {
3827
3893
  var payload, error;
3828
- return regenerator.wrap(function _callee$(_context) {
3829
- while (1) switch (_context.prev = _context.next) {
3894
+ return regenerator.wrap(function _callee2$(_context2) {
3895
+ while (1) switch (_context2.prev = _context2.next) {
3830
3896
  case 0:
3831
- if (!account) {
3832
- _context.next = 16;
3833
- break;
3834
- }
3835
- _context.prev = 1;
3897
+ _context2.prev = 0;
3836
3898
  setLoading(true);
3837
3899
  payload = {
3838
3900
  poolAddress: poolInfo.pool,
3839
3901
  lenderWalletAddress: account
3840
3902
  };
3841
- _context.next = 6;
3903
+ _context2.next = 5;
3842
3904
  return shared.EAService.approveLender(payload, chainId);
3843
- case 6:
3905
+ case 5:
3844
3906
  handleApproveSuccess();
3845
3907
  setLoading(false);
3846
3908
  dispatch(setStep(WIDGET_STEP.ChooseAmount));
3847
- _context.next = 16;
3909
+ _context2.next = 15;
3848
3910
  break;
3849
- case 11:
3850
- _context.prev = 11;
3851
- _context.t0 = _context["catch"](1);
3852
- error = _context.t0;
3911
+ case 10:
3912
+ _context2.prev = 10;
3913
+ _context2.t0 = _context2["catch"](0);
3914
+ error = _context2.t0;
3853
3915
  setLoading(false);
3854
3916
  dispatch(setError({
3855
3917
  errorMessage: error.message
3856
3918
  }));
3857
- case 16:
3919
+ case 15:
3858
3920
  case "end":
3859
- return _context.stop();
3921
+ return _context2.stop();
3860
3922
  }
3861
- }, _callee, null, [[1, 11]]);
3923
+ }, _callee2, null, [[0, 10]]);
3862
3924
  }));
3863
- return function approveLender() {
3864
- return _ref2.apply(this, arguments);
3925
+ return function approveLenderByEA() {
3926
+ return _ref3.apply(this, arguments);
3865
3927
  };
3866
3928
  }();
3929
+ var approveLenderByKYC = function approveLenderByKYC() {
3930
+ switch (lenderApprovalProvider === null || lenderApprovalProvider === void 0 ? void 0 : lenderApprovalProvider.provider) {
3931
+ case 'Securitize':
3932
+ {
3933
+ var issuerId = '53a66b32-583e-40e7-ba90-baf516d2cadd';
3934
+ var baseUrl = "https://id".concat(isDev ? '.sandbox' : '', ".securitize.io");
3935
+ var originUrl = window.location.href.split('?')[0];
3936
+ var redirectUrl = "".concat(originUrl, "?type=KYC&pool=").concat(poolInfo.pool);
3937
+ var providerAuthorizeUrl = "".concat(baseUrl, "/#/authorize?issuerId=").concat(issuerId, "&scope=details&details=verification&redirectUrl=").concat(redirectUrl);
3938
+ var _ref4 = KYCVerifyStatus || {},
3939
+ isNotOnboarded = _ref4.isNotOnboarded;
3940
+ var providerUrl = isNotOnboarded ? providerAuthorizeUrl : baseUrl;
3941
+ window.location.href = providerUrl;
3942
+ }
3943
+ break;
3944
+ }
3945
+ };
3946
+ var approveLender = function approveLender() {
3947
+ switch (lenderApprovalProvider === null || lenderApprovalProvider === void 0 ? void 0 : lenderApprovalProvider.type) {
3948
+ case 'EA':
3949
+ approveLenderByEA();
3950
+ break;
3951
+ case 'KYC':
3952
+ approveLenderByKYC();
3953
+ break;
3954
+ default:
3955
+ approveLenderByEA();
3956
+ break;
3957
+ }
3958
+ };
3867
3959
  if (!loading) {
3868
3960
  return jsxRuntime.jsxs(WrapperModal, {
3869
3961
  title: "Lender Approval",
3870
- subTitle: "This pool requires lender approval",
3962
+ subTitle: subTitle,
3871
3963
  children: [jsxRuntime.jsx(material.Box, {
3872
3964
  css: styles.iconWrapper,
3873
3965
  children: jsxRuntime.jsx(ApproveLenderIcon, {})
3874
3966
  }), jsxRuntime.jsx(material.Box, {
3875
- css: styles.description
3967
+ css: styles.description,
3968
+ children: description
3876
3969
  }), jsxRuntime.jsx(BottomButton, {
3877
3970
  variant: "contained",
3878
3971
  onClick: approveLender,
3879
- children: "GET APPROVED"
3972
+ disabled: KYCVerifyStatus === null || KYCVerifyStatus === void 0 ? void 0 : KYCVerifyStatus.isVerified,
3973
+ children: buttonText
3880
3974
  })]
3881
3975
  });
3882
3976
  }
@@ -4379,7 +4473,12 @@ var columns = [{
4379
4473
  noSeparator: true
4380
4474
  }, {
4381
4475
  title: 'Amount',
4382
- dataIndex: 'amount'
4476
+ action: function action(record) {
4477
+ if (shared.isEmpty(record.amount) || Number.isNaN(record.amount)) {
4478
+ return '';
4479
+ }
4480
+ return Number(record.amount).toFixed(2);
4481
+ }
4383
4482
  }, {
4384
4483
  title: 'Date',
4385
4484
  dataIndex: 'timestamp'
@@ -4594,7 +4693,7 @@ function ConfirmTransfer() {
4594
4693
  leftText: "".concat(borrowAmount.toFixed(2), " ").concat(approval === null || approval === void 0 ? void 0 : approval.token.symbol),
4595
4694
  rightText: 'You'
4596
4695
  }],
4597
- actionText: "Approve Transfer",
4696
+ actionText: "APPROVE TRANSFER",
4598
4697
  handleAction: handleAction
4599
4698
  });
4600
4699
  }
@@ -6597,11 +6696,12 @@ var themeHuma = material.createTheme(themeBase, {
6597
6696
  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; }
6598
6697
  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; }
6599
6698
  function Widget(props) {
6600
- var _window$ethereum;
6601
6699
  var children = props.children,
6602
6700
  desiredChainId = props.desiredChainId;
6701
+ var _window = window,
6702
+ ethereum = _window.ethereum;
6603
6703
  // @ts-ignore
6604
- var netWorkVersion = (_window$ethereum = window.ethereum) === null || _window$ethereum === void 0 ? void 0 : _window$ethereum.networkVersion;
6704
+ var netWorkVersion = (ethereum === null || ethereum === void 0 ? void 0 : ethereum.networkVersion) || (ethereum === null || ethereum === void 0 ? void 0 : ethereum.chainId);
6605
6705
  var _useState = React.useState(netWorkVersion ? Number(netWorkVersion) : undefined),
6606
6706
  _useState2 = _slicedToArray(_useState, 2),
6607
6707
  currentChainId = _useState2[0],
@@ -6626,15 +6726,15 @@ function Widget(props) {
6626
6726
  setCurrentChainId(chainId);
6627
6727
  };
6628
6728
  if (window.ethereum) {
6629
- var _window$ethereum2;
6729
+ var _window$ethereum;
6630
6730
  // @ts-ignore
6631
- (_window$ethereum2 = window.ethereum) === null || _window$ethereum2 === void 0 ? void 0 : _window$ethereum2.on('chainChanged', chainChangeListener);
6731
+ (_window$ethereum = window.ethereum) === null || _window$ethereum === void 0 ? void 0 : _window$ethereum.on('chainChanged', chainChangeListener);
6632
6732
  }
6633
6733
  return function () {
6634
6734
  if (window.ethereum) {
6635
- var _window$ethereum3;
6735
+ var _window$ethereum2;
6636
6736
  // @ts-ignore
6637
- (_window$ethereum3 = window.ethereum) === null || _window$ethereum3 === void 0 ? void 0 : _window$ethereum3.removeListener('chainChanged', chainChangeListener);
6737
+ (_window$ethereum2 = window.ethereum) === null || _window$ethereum2 === void 0 ? void 0 : _window$ethereum2.removeListener('chainChanged', chainChangeListener);
6638
6738
  }
6639
6739
  };
6640
6740
  }, []);