@huma-finance/widgets 0.0.43-beta.114 → 0.0.43-beta.125

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/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { txAtom, useMQ, supportedChainId, sendTxAtom, isTxFailed, getExplorerUrl, openInNewTab, usePoolUnderlyingTokenContract, TxStateType, useMount, decodeLogs, ERC20_ABI, downScale, formatMoney, POOL_NAME, POOL_TYPE, usePoolInfo, useAccountStats, useAuthErrorHandling, checkIsDev, EARejectionError, EARejectMessage, EARejectReason, EAService, useCLFeeManager, useCLPoolAllowance, upScale, usePoolContract, timeUtil, getNotifiDappId, getBlockchainConfigFromChain, doesChainSupportNotifi, CreditState, toBigNumber, TRANSFER_ABI, useFeeManager, combineStyles, isEmpty, useInvoiceNFTContract, useRFPoolAllowance, useParamsSearch, IdentityService, CHAINS, configUtil, usePoolAllowance, useLenderApproved, useLenderPosition, useWithdrawlLockoutInSeconds, usePoolUnderlyingTokenBalance, useLastDepositTime, CreditEventText, useERC2612Permit, ERC2612_ABI, SuperfluidPoolProcessor_ABI, useMultiSendContract, usePoolUnderlyingToken, hasRFActiveLoan, timestampToLL, getWalletAddressAbbr, useFactoring, PoolMap, PoolSubgraphMap, CreditEvent, Provider as Provider$1 } from '@huma-finance/shared';
1
+ import { txAtom, useMQ, supportedChainId, sendTxAtom, isTxFailed, getExplorerUrl, openInNewTab, usePoolUnderlyingTokenContract, TxStateType, useMount, decodeLogs, ERC20_ABI, downScale, formatMoney, POOL_NAME, POOL_TYPE, usePoolInfo, useAccountStats, useAuthErrorHandling, checkIsDev, EARejectionError, EARejectMessage, EARejectReason, EAService, useCLFeeManager, useCLPoolAllowance, upScale, usePoolContract, timeUtil, doesChainSupportNotifi, getNotifiDappId, getBlockchainConfigFromChain, CreditState, toBigNumber, TRANSFER_ABI, useFeeManager, combineStyles, isEmpty, useInvoiceNFTContract, useRFPoolAllowance, useParamsSearch, IdentityService, CHAINS, configUtil, usePoolAllowance, useLenderApproved, useLenderPosition, useWithdrawlLockoutInSeconds, usePoolUnderlyingTokenBalance, useLastDepositTime, CreditEventText, useERC2612Permit, ERC2612_ABI, SuperfluidPoolProcessor_ABI, useMultiSendContract, usePoolUnderlyingToken, hasRFActiveLoan, timestampToLL, getWalletAddressAbbr, useFactoring, PoolMap, PoolSubgraphMap, CreditEvent, Provider as Provider$1 } from '@huma-finance/shared';
2
2
  import { useTheme, css, Box, Typography, Tooltip, Button, Dialog, Slider, Input, Divider, InputAdornment, Snackbar, Alert, Skeleton, 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';
@@ -16,8 +16,8 @@ import { MaxUint256 } from '@ethersproject/constants';
16
16
  import { BigNumber, ethers, Contract } from 'ethers';
17
17
  import ArrowDropDownIcon from '@mui/icons-material/ArrowDropDown';
18
18
  import ArrowDropUpIcon from '@mui/icons-material/ArrowDropUp';
19
- import { newFrontendClient } from '@notifi-network/notifi-frontend-client';
20
19
  import Email from '@mui/icons-material/Email';
20
+ import { newFrontendClient } from '@notifi-network/notifi-frontend-client';
21
21
  import ArrowForwardIosIcon from '@mui/icons-material/ArrowForwardIos';
22
22
  import { gql, useQuery, ApolloClient, InMemoryCache, ApolloProvider } from '@apollo/client';
23
23
  import Table from '@mui/material/Table';
@@ -613,42 +613,42 @@ var selectWidgetState = function selectWidgetState(state) {
613
613
  return state.widget;
614
614
  };
615
615
 
616
- var _path$6;
617
- function _extends$6() { _extends$6 = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$6.apply(this, arguments); }
616
+ var _path$7;
617
+ function _extends$7() { _extends$7 = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$7.apply(this, arguments); }
618
618
  var SvgReceipt = function SvgReceipt(props) {
619
- return /*#__PURE__*/React__default.createElement("svg", _extends$6({
619
+ return /*#__PURE__*/React__default.createElement("svg", _extends$7({
620
620
  width: 24,
621
621
  height: 24,
622
622
  fill: "none",
623
623
  xmlns: "http://www.w3.org/2000/svg"
624
- }, props), _path$6 || (_path$6 = /*#__PURE__*/React__default.createElement("path", {
624
+ }, props), _path$7 || (_path$7 = /*#__PURE__*/React__default.createElement("path", {
625
625
  d: "M18 17H6v-2h12v2Zm0-4H6v-2h12v2Zm0-4H6V7h12v2ZM3 22l1.5-1.5L6 22l1.5-1.5L9 22l1.5-1.5L12 22l1.5-1.5L15 22l1.5-1.5L18 22l1.5-1.5L21 22V2l-1.5 1.5L18 2l-1.5 1.5L15 2l-1.5 1.5L12 2l-1.5 1.5L9 2 7.5 3.5 6 2 4.5 3.5 3 2v20Z",
626
626
  fill: "#76707E"
627
627
  })));
628
628
  };
629
629
 
630
- var _path$5;
631
- function _extends$5() { _extends$5 = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$5.apply(this, arguments); }
630
+ var _path$6;
631
+ function _extends$6() { _extends$6 = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$6.apply(this, arguments); }
632
632
  var SvgSeparator = function SvgSeparator(props) {
633
- return /*#__PURE__*/React__default.createElement("svg", _extends$5({
633
+ return /*#__PURE__*/React__default.createElement("svg", _extends$6({
634
634
  width: 2,
635
635
  height: 14,
636
636
  fill: "none",
637
637
  xmlns: "http://www.w3.org/2000/svg"
638
- }, props), _path$5 || (_path$5 = /*#__PURE__*/React__default.createElement("path", {
638
+ }, props), _path$6 || (_path$6 = /*#__PURE__*/React__default.createElement("path", {
639
639
  fill: "#E0E0E0",
640
640
  d: "M0 0h2v14H0z"
641
641
  })));
642
642
  };
643
643
 
644
- var _path$4, _path2$1, _path3$1, _path4, _path5, _path6, _path7, _path8, _path9, _path10, _path11, _path12, _path13, _path14, _path15, _path16, _path17, _path18, _path19, _path20, _path21, _path22, _path23, _path24, _path25, _path26, _path27, _path28, _path29, _path30, _path31, _path32, _path33, _path34, _path35, _path36, _path37, _path38, _path39, _path40, _path41, _path42, _path43, _path44, _path45, _defs$1;
645
- function _extends$4() { _extends$4 = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$4.apply(this, arguments); }
644
+ var _path$5, _path2$1, _path3$1, _path4, _path5, _path6, _path7, _path8, _path9, _path10, _path11, _path12, _path13, _path14, _path15, _path16, _path17, _path18, _path19, _path20, _path21, _path22, _path23, _path24, _path25, _path26, _path27, _path28, _path29, _path30, _path31, _path32, _path33, _path34, _path35, _path36, _path37, _path38, _path39, _path40, _path41, _path42, _path43, _path44, _path45, _defs$1;
645
+ function _extends$5() { _extends$5 = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$5.apply(this, arguments); }
646
646
  var SvgLoader = function SvgLoader(props) {
647
- return /*#__PURE__*/React__default.createElement("svg", _extends$4({
647
+ return /*#__PURE__*/React__default.createElement("svg", _extends$5({
648
648
  xmlns: "http://www.w3.org/2000/svg",
649
649
  fill: "none",
650
650
  viewBox: "0 0 81 80"
651
- }, props), _path$4 || (_path$4 = /*#__PURE__*/React__default.createElement("path", {
651
+ }, props), _path$5 || (_path$5 = /*#__PURE__*/React__default.createElement("path", {
652
652
  stroke: "url(#loader_svg__a)",
653
653
  strokeMiterlimit: 10,
654
654
  strokeWidth: 0.5,
@@ -1416,10 +1416,10 @@ var SvgLoader = function SvgLoader(props) {
1416
1416
  })))));
1417
1417
  };
1418
1418
 
1419
- var _circle, _path$3, _defs;
1420
- function _extends$3() { _extends$3 = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$3.apply(this, arguments); }
1419
+ var _circle, _path$4, _defs;
1420
+ function _extends$4() { _extends$4 = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$4.apply(this, arguments); }
1421
1421
  var SvgCheck = function SvgCheck(props) {
1422
- return /*#__PURE__*/React__default.createElement("svg", _extends$3({
1422
+ return /*#__PURE__*/React__default.createElement("svg", _extends$4({
1423
1423
  width: 120,
1424
1424
  height: 120,
1425
1425
  fill: "none",
@@ -1429,7 +1429,7 @@ var SvgCheck = function SvgCheck(props) {
1429
1429
  cy: 60,
1430
1430
  r: 60,
1431
1431
  fill: "#F7F1FF"
1432
- })), _path$3 || (_path$3 = /*#__PURE__*/React__default.createElement("path", {
1432
+ })), _path$4 || (_path$4 = /*#__PURE__*/React__default.createElement("path", {
1433
1433
  fillRule: "evenodd",
1434
1434
  clipRule: "evenodd",
1435
1435
  d: "M83.701 47.556 69.216 62.053 54.73 76.55c-.234.164-.445.281-.726.281-.28 0-.491-.117-.726-.28l-16.98-17.004a1.004 1.004 0 0 1 0-1.428l3.64-3.775c.374-.375 1.053-.375 1.428 0l12.638 12.5L78.446 42.28c.375-.375 1.054-.375 1.429 0l3.826 3.846a1.004 1.004 0 0 1 0 1.429Z",
@@ -1449,15 +1449,15 @@ var SvgCheck = function SvgCheck(props) {
1449
1449
  })))));
1450
1450
  };
1451
1451
 
1452
- var _path$2;
1453
- function _extends$2() { _extends$2 = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$2.apply(this, arguments); }
1452
+ var _path$3;
1453
+ function _extends$3() { _extends$3 = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$3.apply(this, arguments); }
1454
1454
  var SvgCheckGreen = function SvgCheckGreen(props) {
1455
- return /*#__PURE__*/React__default.createElement("svg", _extends$2({
1455
+ return /*#__PURE__*/React__default.createElement("svg", _extends$3({
1456
1456
  xmlns: "http://www.w3.org/2000/svg",
1457
1457
  width: 24,
1458
1458
  height: 24,
1459
1459
  fill: "none"
1460
- }, props), _path$2 || (_path$2 = /*#__PURE__*/React__default.createElement("path", {
1460
+ }, props), _path$3 || (_path$3 = /*#__PURE__*/React__default.createElement("path", {
1461
1461
  fill: "#45CB71",
1462
1462
  fillRule: "evenodd",
1463
1463
  d: "m20.888 7.333-5.432 5.437-5.432 5.436a.458.458 0 0 1-.272.106.458.458 0 0 1-.273-.106L3.112 11.83a.376.376 0 0 1 0-.536L4.477 9.88c.14-.14.395-.14.535 0l4.74 4.687 9.165-9.21a.392.392 0 0 1 .536 0l1.435 1.442c.15.14.15.395 0 .535Z",
@@ -1465,28 +1465,28 @@ var SvgCheckGreen = function SvgCheckGreen(props) {
1465
1465
  })));
1466
1466
  };
1467
1467
 
1468
- var _path$1;
1469
- function _extends$1() { _extends$1 = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$1.apply(this, arguments); }
1468
+ var _path$2;
1469
+ function _extends$2() { _extends$2 = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$2.apply(this, arguments); }
1470
1470
  var SvgCheckCircle = function SvgCheckCircle(props) {
1471
- return /*#__PURE__*/React__default.createElement("svg", _extends$1({
1471
+ return /*#__PURE__*/React__default.createElement("svg", _extends$2({
1472
1472
  xmlns: "http://www.w3.org/2000/svg",
1473
1473
  width: 22,
1474
1474
  height: 22,
1475
1475
  fill: "none"
1476
- }, props), _path$1 || (_path$1 = /*#__PURE__*/React__default.createElement("path", {
1476
+ }, props), _path$2 || (_path$2 = /*#__PURE__*/React__default.createElement("path", {
1477
1477
  fill: "#2E7D32",
1478
1478
  d: "m15.207 6.948-6.04 6.041-3.291-3.282L4.583 11l4.583 4.583L16.5 8.25l-1.293-1.302ZM11 1.833C5.94 1.833 1.833 5.94 1.833 11S5.94 20.167 11 20.167 20.166 16.06 20.166 11 16.06 1.833 11 1.833Zm0 16.5A7.331 7.331 0 0 1 3.666 11 7.331 7.331 0 0 1 11 3.667 7.331 7.331 0 0 1 18.333 11 7.331 7.331 0 0 1 11 18.333Z"
1479
1479
  })));
1480
1480
  };
1481
1481
 
1482
- var _path, _path2, _path3;
1483
- function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
1482
+ var _path$1, _path2, _path3;
1483
+ function _extends$1() { _extends$1 = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$1.apply(this, arguments); }
1484
1484
  var SvgUsdc = function SvgUsdc(props) {
1485
- return /*#__PURE__*/React__default.createElement("svg", _extends({
1485
+ return /*#__PURE__*/React__default.createElement("svg", _extends$1({
1486
1486
  "data-name": "86977684-12db-4850-8f30-233a7c267d11",
1487
1487
  xmlns: "http://www.w3.org/2000/svg",
1488
1488
  viewBox: "0 0 2000 2000"
1489
- }, props), _path || (_path = /*#__PURE__*/React__default.createElement("path", {
1489
+ }, props), _path$1 || (_path$1 = /*#__PURE__*/React__default.createElement("path", {
1490
1490
  d: "M1000 2000c554.17 0 1000-445.83 1000-1000S1554.17 0 1000 0 0 445.83 0 1000s445.83 1000 1000 1000z",
1491
1491
  fill: "#2775ca"
1492
1492
  })), _path2 || (_path2 = /*#__PURE__*/React__default.createElement("path", {
@@ -1498,6 +1498,28 @@ var SvgUsdc = function SvgUsdc(props) {
1498
1498
  })));
1499
1499
  };
1500
1500
 
1501
+ var _path;
1502
+ function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
1503
+ var SvgCelo = function SvgCelo(props) {
1504
+ return /*#__PURE__*/React__default.createElement("svg", _extends({
1505
+ xmlns: "http://www.w3.org/2000/svg",
1506
+ viewBox: "0 0 250 250",
1507
+ style: {
1508
+ enableBackground: "new 0 0 250 250"
1509
+ },
1510
+ xmlSpace: "preserve"
1511
+ }, props), /*#__PURE__*/React__default.createElement("circle", {
1512
+ cx: 125,
1513
+ cy: 125,
1514
+ r: 125,
1515
+ style: {
1516
+ fill: "#fcff52"
1517
+ }
1518
+ }), _path || (_path = /*#__PURE__*/React__default.createElement("path", {
1519
+ d: "M188.9 60.7H60.7v128.2h128.2v-44.8h-21.3c-7.3 16.3-23.8 27.7-42.7 27.7-26 0-47.1-21.3-47.1-47.1 0-25.9 21.1-47 47.1-47 19.3 0 35.8 11.7 43.1 28.4h20.9V60.7z"
1520
+ })));
1521
+ };
1522
+
1501
1523
  function ownKeys$4(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; }
1502
1524
  function _objectSpread$4(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$4(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$4(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
1503
1525
  function ReceiptIcon(props) {
@@ -1521,11 +1543,15 @@ function CheckCircleIcon(props) {
1521
1543
  function UsdcIcon(props) {
1522
1544
  return jsx(SvgUsdc, _objectSpread$4({}, props));
1523
1545
  }
1546
+ function CeloIcon(props) {
1547
+ return jsx(SvgCelo, _objectSpread$4({}, props));
1548
+ }
1524
1549
  function getIcon(icon) {
1525
- if (icon === 'USDC') {
1526
- return UsdcIcon;
1527
- }
1528
- return null;
1550
+ if (!icon) return null;
1551
+ return {
1552
+ USDC: UsdcIcon,
1553
+ Celo: CeloIcon
1554
+ }[icon] || null;
1529
1555
  }
1530
1556
 
1531
1557
  function _EMOTION_STRINGIFIED_CSS_ERROR__$4() { return "You have tried to stringify object returned from `css` function. It isn't supposed to be used directly (e.g. as value of the `className` prop), but rather handed to emotion so it can handle it (e.g. as value of `css` prop)."; }
@@ -2890,6 +2916,140 @@ function Success$6(_ref) {
2890
2916
  });
2891
2917
  }
2892
2918
 
2919
+ var useDoesChainSupportNotifi = function useDoesChainSupportNotifi(account, chainId) {
2920
+ var _useState = useState(false),
2921
+ _useState2 = _slicedToArray(_useState, 2),
2922
+ notifiChainSupported = _useState2[0],
2923
+ setNotifiChainSupported = _useState2[1];
2924
+ useEffect(function () {
2925
+ var checkNotifiChainSupported = /*#__PURE__*/function () {
2926
+ var _ref = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee() {
2927
+ return regenerator.wrap(function _callee$(_context) {
2928
+ while (1) switch (_context.prev = _context.next) {
2929
+ case 0:
2930
+ if (account != null && chainId != null) {
2931
+ setNotifiChainSupported(doesChainSupportNotifi(chainId, checkIsDev(), account));
2932
+ }
2933
+ case 1:
2934
+ case "end":
2935
+ return _context.stop();
2936
+ }
2937
+ }, _callee);
2938
+ }));
2939
+ return function checkNotifiChainSupported() {
2940
+ return _ref.apply(this, arguments);
2941
+ };
2942
+ }();
2943
+ checkNotifiChainSupported();
2944
+ }, [account, chainId]);
2945
+ return {
2946
+ notifiChainSupported: notifiChainSupported
2947
+ };
2948
+ };
2949
+ var useNotifiClient = function useNotifiClient(account, chainId, isDev) {
2950
+ var _useState3 = useState(null),
2951
+ _useState4 = _slicedToArray(_useState3, 2),
2952
+ notifiClient = _useState4[0],
2953
+ setNotifiClient = _useState4[1];
2954
+ var _useDoesChainSupportN = useDoesChainSupportNotifi(account, chainId),
2955
+ notifiChainSupported = _useDoesChainSupportN.notifiChainSupported;
2956
+ useEffect(function () {
2957
+ var createNotifiClient = /*#__PURE__*/function () {
2958
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee2() {
2959
+ var client;
2960
+ return regenerator.wrap(function _callee2$(_context2) {
2961
+ while (1) switch (_context2.prev = _context2.next) {
2962
+ case 0:
2963
+ if (!(account != null && chainId != null && notifiChainSupported)) {
2964
+ _context2.next = 5;
2965
+ break;
2966
+ }
2967
+ client = newFrontendClient({
2968
+ account: {
2969
+ publicKey: account
2970
+ },
2971
+ tenantId: getNotifiDappId(isDev),
2972
+ env: isDev ? 'Development' : 'Production',
2973
+ walletBlockchain: getBlockchainConfigFromChain(chainId)
2974
+ });
2975
+ _context2.next = 4;
2976
+ return client.initialize();
2977
+ case 4:
2978
+ setNotifiClient(client);
2979
+ case 5:
2980
+ case "end":
2981
+ return _context2.stop();
2982
+ }
2983
+ }, _callee2);
2984
+ }));
2985
+ return function createNotifiClient() {
2986
+ return _ref2.apply(this, arguments);
2987
+ };
2988
+ }();
2989
+ createNotifiClient();
2990
+ }, [account, chainId, isDev, notifiChainSupported]);
2991
+ return {
2992
+ notifiClient: notifiClient
2993
+ };
2994
+ };
2995
+ var useIsFirstTimeNotifiUser = function useIsFirstTimeNotifiUser(account, chainId) {
2996
+ var _useState5 = useState(false),
2997
+ _useState6 = _slicedToArray(_useState5, 2),
2998
+ isFirstTimeNotifiUser = _useState6[0],
2999
+ setIsFirstTimeNotifiUser = _useState6[1];
3000
+ var _useNotifiClient = useNotifiClient(account, chainId, checkIsDev()),
3001
+ notifiClient = _useNotifiClient.notifiClient;
3002
+ var _useDoesChainSupportN2 = useDoesChainSupportNotifi(account, chainId),
3003
+ notifiChainSupported = _useDoesChainSupportN2.notifiChainSupported;
3004
+ useEffect(function () {
3005
+ var checkIsFirstTimeNotifiUser = /*#__PURE__*/function () {
3006
+ var _ref3 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee3() {
3007
+ var userState, _targetGroups$, _targetGroups$$emailT, targetGroups, emailTargets;
3008
+ return regenerator.wrap(function _callee3$(_context3) {
3009
+ while (1) switch (_context3.prev = _context3.next) {
3010
+ case 0:
3011
+ if (!(notifiClient != null && notifiChainSupported)) {
3012
+ _context3.next = 12;
3013
+ break;
3014
+ }
3015
+ userState = notifiClient.userState; // If the user is not authenticated or expired, they are a first time user
3016
+ if (!(userState == null || userState.status !== 'authenticated' && userState.status !== 'expired')) {
3017
+ _context3.next = 6;
3018
+ break;
3019
+ }
3020
+ setIsFirstTimeNotifiUser(true);
3021
+ _context3.next = 12;
3022
+ break;
3023
+ case 6:
3024
+ if (!(userState.status === 'authenticated')) {
3025
+ _context3.next = 12;
3026
+ break;
3027
+ }
3028
+ _context3.next = 9;
3029
+ return notifiClient.getTargetGroups();
3030
+ case 9:
3031
+ targetGroups = _context3.sent;
3032
+ emailTargets = (_targetGroups$ = targetGroups[0]) === null || _targetGroups$ === void 0 ? void 0 : (_targetGroups$$emailT = _targetGroups$.emailTargets) === null || _targetGroups$$emailT === void 0 ? void 0 : _targetGroups$$emailT[0];
3033
+ if (emailTargets == null || emailTargets.emailAddress == null) {
3034
+ setIsFirstTimeNotifiUser(true);
3035
+ }
3036
+ case 12:
3037
+ case "end":
3038
+ return _context3.stop();
3039
+ }
3040
+ }, _callee3);
3041
+ }));
3042
+ return function checkIsFirstTimeNotifiUser() {
3043
+ return _ref3.apply(this, arguments);
3044
+ };
3045
+ }();
3046
+ checkIsFirstTimeNotifiUser();
3047
+ }, [notifiChainSupported, notifiClient]);
3048
+ return {
3049
+ isFirstTimeNotifiUser: isFirstTimeNotifiUser
3050
+ };
3051
+ };
3052
+
2893
3053
  var _templateObject$9, _templateObject2$7, _templateObject3$5, _templateObject4$4, _templateObject5$1;
2894
3054
  function ownKeys$2(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; }
2895
3055
  function _objectSpread$2(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$2(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$2(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
@@ -2911,23 +3071,23 @@ function fetchEventTypes(_x) {
2911
3071
  return _fetchEventTypes.apply(this, arguments);
2912
3072
  }
2913
3073
  function _fetchEventTypes() {
2914
- _fetchEventTypes = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee4(notifiClient) {
3074
+ _fetchEventTypes = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee3(notifiClient) {
2915
3075
  var _process$env$REACT_AP, _subscriptionConfig$e;
2916
3076
  var subscribedAlerts, subscriptionConfig, eventTypes;
2917
- return regenerator.wrap(function _callee4$(_context4) {
2918
- while (1) switch (_context4.prev = _context4.next) {
3077
+ return regenerator.wrap(function _callee3$(_context3) {
3078
+ while (1) switch (_context3.prev = _context3.next) {
2919
3079
  case 0:
2920
- _context4.next = 2;
3080
+ _context3.next = 2;
2921
3081
  return notifiClient.getAlerts();
2922
3082
  case 2:
2923
- subscribedAlerts = _context4.sent;
2924
- _context4.next = 5;
3083
+ subscribedAlerts = _context3.sent;
3084
+ _context3.next = 5;
2925
3085
  return notifiClient.fetchSubscriptionCard({
2926
3086
  id: (_process$env$REACT_AP = process.env.REACT_APP_NOTIFI_CONFIG_ID) !== null && _process$env$REACT_AP !== void 0 ? _process$env$REACT_AP : '',
2927
3087
  type: 'SUBSCRIPTION_CARD'
2928
3088
  });
2929
3089
  case 5:
2930
- subscriptionConfig = _context4.sent;
3090
+ subscriptionConfig = _context3.sent;
2931
3091
  eventTypes = subscriptionConfig === null || subscriptionConfig === void 0 ? void 0 : (_subscriptionConfig$e = subscriptionConfig.eventTypes) === null || _subscriptionConfig$e === void 0 ? void 0 : _subscriptionConfig$e.map(function (eventType) {
2932
3092
  var eventTypeId = getIdFromEventType(eventType);
2933
3093
  var enabled = false;
@@ -2942,12 +3102,12 @@ function _fetchEventTypes() {
2942
3102
  enabled: enabled
2943
3103
  });
2944
3104
  });
2945
- return _context4.abrupt("return", eventTypes);
3105
+ return _context3.abrupt("return", eventTypes);
2946
3106
  case 8:
2947
3107
  case "end":
2948
- return _context4.stop();
3108
+ return _context3.stop();
2949
3109
  }
2950
- }, _callee4);
3110
+ }, _callee3);
2951
3111
  }));
2952
3112
  return _fetchEventTypes.apply(this, arguments);
2953
3113
  }
@@ -2960,81 +3120,44 @@ function NotifiSubscriptionModal(_ref) {
2960
3120
  account = _useWeb3React.account,
2961
3121
  chainId = _useWeb3React.chainId,
2962
3122
  provider = _useWeb3React.provider;
2963
- var _useState = useState(),
3123
+ var _useState = useState(false),
2964
3124
  _useState2 = _slicedToArray(_useState, 2),
2965
- notifiClient = _useState2[0],
2966
- setNotifiClient = _useState2[1];
3125
+ showSuccessScreen = _useState2[0],
3126
+ setShowSuccessScreen = _useState2[1];
2967
3127
  var _useState3 = useState(false),
2968
3128
  _useState4 = _slicedToArray(_useState3, 2),
2969
- showSuccessScreen = _useState4[0],
2970
- setShowSuccessScreen = _useState4[1];
2971
- var _useState5 = useState(false),
3129
+ isLoading = _useState4[0],
3130
+ setIsLoading = _useState4[1];
3131
+ var _useState5 = useState(''),
2972
3132
  _useState6 = _slicedToArray(_useState5, 2),
2973
- isLoading = _useState6[0],
2974
- setIsLoading = _useState6[1];
2975
- var _useState7 = useState(''),
3133
+ emailAddress = _useState6[0],
3134
+ setEmailAddress = _useState6[1];
3135
+ var _useState7 = useState(),
2976
3136
  _useState8 = _slicedToArray(_useState7, 2),
2977
- emailAddress = _useState8[0],
2978
- setEmailAddress = _useState8[1];
2979
- var _useState9 = useState(),
2980
- _useState10 = _slicedToArray(_useState9, 2),
2981
- emailValid = _useState10[0],
2982
- setEmailValid = _useState10[1];
2983
- useEffect(function () {
2984
- var initializeClient = /*#__PURE__*/function () {
2985
- var _ref2 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee() {
2986
- var client;
2987
- return regenerator.wrap(function _callee$(_context) {
2988
- while (1) switch (_context.prev = _context.next) {
2989
- case 0:
2990
- if (!(account != null && chainId != null)) {
2991
- _context.next = 5;
2992
- break;
2993
- }
2994
- client = newFrontendClient({
2995
- account: {
2996
- publicKey: account
2997
- },
2998
- tenantId: getNotifiDappId(checkIsDev()),
2999
- env: checkIsDev() ? 'Development' : 'Production',
3000
- walletBlockchain: getBlockchainConfigFromChain(chainId)
3001
- });
3002
- _context.next = 4;
3003
- return client.initialize();
3004
- case 4:
3005
- setNotifiClient(client);
3006
- case 5:
3007
- case "end":
3008
- return _context.stop();
3009
- }
3010
- }, _callee);
3011
- }));
3012
- return function initializeClient() {
3013
- return _ref2.apply(this, arguments);
3014
- };
3015
- }();
3016
- initializeClient();
3017
- }, [account, chainId]);
3137
+ emailValid = _useState8[0],
3138
+ setEmailValid = _useState8[1];
3139
+ var _useNotifiClient = useNotifiClient(account, chainId, checkIsDev()),
3140
+ notifiClient = _useNotifiClient.notifiClient;
3018
3141
  var signMessage = /*#__PURE__*/function () {
3019
- var _ref3 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee2(message) {
3142
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(message) {
3020
3143
  var signer, signature;
3021
- return regenerator.wrap(function _callee2$(_context2) {
3022
- while (1) switch (_context2.prev = _context2.next) {
3144
+ return regenerator.wrap(function _callee$(_context) {
3145
+ while (1) switch (_context.prev = _context.next) {
3023
3146
  case 0:
3024
3147
  signer = provider.getSigner();
3025
- _context2.next = 3;
3148
+ _context.next = 3;
3026
3149
  return signer.signMessage(Buffer.from(message));
3027
3150
  case 3:
3028
- signature = _context2.sent;
3029
- return _context2.abrupt("return", ethers.utils.arrayify(signature));
3151
+ signature = _context.sent;
3152
+ return _context.abrupt("return", ethers.utils.arrayify(signature));
3030
3153
  case 5:
3031
3154
  case "end":
3032
- return _context2.stop();
3155
+ return _context.stop();
3033
3156
  }
3034
- }, _callee2);
3157
+ }, _callee);
3035
3158
  }));
3036
3159
  return function signMessage(_x2) {
3037
- return _ref3.apply(this, arguments);
3160
+ return _ref2.apply(this, arguments);
3038
3161
  };
3039
3162
  }();
3040
3163
  var handleEmailAddressChange = function handleEmailAddressChange(event) {
@@ -3044,38 +3167,38 @@ function NotifiSubscriptionModal(_ref) {
3044
3167
  setEmailAddress(event.target.value);
3045
3168
  };
3046
3169
  var logInAndSubscribe = /*#__PURE__*/function () {
3047
- var _ref4 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee3() {
3170
+ var _ref3 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee2() {
3048
3171
  var fetchedEventTypes, _iterator, _step, eventType;
3049
- return regenerator.wrap(function _callee3$(_context3) {
3050
- while (1) switch (_context3.prev = _context3.next) {
3172
+ return regenerator.wrap(function _callee2$(_context2) {
3173
+ while (1) switch (_context2.prev = _context2.next) {
3051
3174
  case 0:
3052
3175
  if (!(notifiClient != null && chainId != null)) {
3053
- _context3.next = 35;
3176
+ _context2.next = 35;
3054
3177
  break;
3055
3178
  }
3056
3179
  setIsLoading(true);
3057
3180
 
3058
3181
  // Ask user to sign a message to authenticate
3059
- _context3.prev = 2;
3060
- _context3.next = 5;
3182
+ _context2.prev = 2;
3183
+ _context2.next = 5;
3061
3184
  return notifiClient.logIn({
3062
3185
  walletBlockchain: getBlockchainConfigFromChain(chainId),
3063
3186
  signMessage: signMessage
3064
3187
  });
3065
3188
  case 5:
3066
- _context3.next = 11;
3189
+ _context2.next = 11;
3067
3190
  break;
3068
3191
  case 7:
3069
- _context3.prev = 7;
3070
- _context3.t0 = _context3["catch"](2);
3192
+ _context2.prev = 7;
3193
+ _context2.t0 = _context2["catch"](2);
3071
3194
  setIsLoading(false);
3072
- return _context3.abrupt("return");
3195
+ return _context2.abrupt("return");
3073
3196
  case 11:
3074
- _context3.next = 13;
3197
+ _context2.next = 13;
3075
3198
  return fetchEventTypes(notifiClient);
3076
3199
  case 13:
3077
- fetchedEventTypes = _context3.sent;
3078
- _context3.next = 16;
3200
+ fetchedEventTypes = _context2.sent;
3201
+ _context2.next = 16;
3079
3202
  return notifiClient.ensureTargetGroup({
3080
3203
  name: 'Default',
3081
3204
  emailAddress: emailAddress
@@ -3085,44 +3208,44 @@ function NotifiSubscriptionModal(_ref) {
3085
3208
  // multiple calls. Notified their team to fix this.
3086
3209
  // eslint-disable-next-line no-restricted-syntax
3087
3210
  _iterator = _createForOfIteratorHelper(fetchedEventTypes);
3088
- _context3.prev = 17;
3211
+ _context2.prev = 17;
3089
3212
  _iterator.s();
3090
3213
  case 19:
3091
3214
  if ((_step = _iterator.n()).done) {
3092
- _context3.next = 25;
3215
+ _context2.next = 25;
3093
3216
  break;
3094
3217
  }
3095
3218
  eventType = _step.value;
3096
- _context3.next = 23;
3219
+ _context2.next = 23;
3097
3220
  return notifiClient.ensureAlert({
3098
3221
  eventType: eventType,
3099
3222
  inputs: {}
3100
3223
  });
3101
3224
  case 23:
3102
- _context3.next = 19;
3225
+ _context2.next = 19;
3103
3226
  break;
3104
3227
  case 25:
3105
- _context3.next = 30;
3228
+ _context2.next = 30;
3106
3229
  break;
3107
3230
  case 27:
3108
- _context3.prev = 27;
3109
- _context3.t1 = _context3["catch"](17);
3110
- _iterator.e(_context3.t1);
3231
+ _context2.prev = 27;
3232
+ _context2.t1 = _context2["catch"](17);
3233
+ _iterator.e(_context2.t1);
3111
3234
  case 30:
3112
- _context3.prev = 30;
3235
+ _context2.prev = 30;
3113
3236
  _iterator.f();
3114
- return _context3.finish(30);
3237
+ return _context2.finish(30);
3115
3238
  case 33:
3116
3239
  setShowSuccessScreen(true);
3117
3240
  setIsLoading(false);
3118
3241
  case 35:
3119
3242
  case "end":
3120
- return _context3.stop();
3243
+ return _context2.stop();
3121
3244
  }
3122
- }, _callee3, null, [[2, 7], [17, 27, 30, 33]]);
3245
+ }, _callee2, null, [[2, 7], [17, 27, 30, 33]]);
3123
3246
  }));
3124
3247
  return function logInAndSubscribe() {
3125
- return _ref4.apply(this, arguments);
3248
+ return _ref3.apply(this, arguments);
3126
3249
  };
3127
3250
  }();
3128
3251
  var handleCloseModal = useCallback(function () {
@@ -3194,101 +3317,6 @@ function Notifications$1(_ref) {
3194
3317
  });
3195
3318
  }
3196
3319
 
3197
- var useIsFirstTimeNotifiUser = function useIsFirstTimeNotifiUser(account, chainId) {
3198
- var _useState = useState(false),
3199
- _useState2 = _slicedToArray(_useState, 2),
3200
- isFirstTimeNotifiUser = _useState2[0],
3201
- setIsFirstTimeNotifiUser = _useState2[1];
3202
- useEffect(function () {
3203
- var checkIsFirstTimeNotifiUser = /*#__PURE__*/function () {
3204
- var _ref = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee() {
3205
- var client, userState, _targetGroups$, _targetGroups$$emailT, targetGroups, emailTargets;
3206
- return regenerator.wrap(function _callee$(_context) {
3207
- while (1) switch (_context.prev = _context.next) {
3208
- case 0:
3209
- if (!(account != null && chainId != null)) {
3210
- _context.next = 15;
3211
- break;
3212
- }
3213
- client = newFrontendClient({
3214
- account: {
3215
- publicKey: account
3216
- },
3217
- tenantId: 'humadapp',
3218
- env: checkIsDev() ? 'Development' : 'Production',
3219
- walletBlockchain: getBlockchainConfigFromChain(chainId)
3220
- });
3221
- _context.next = 4;
3222
- return client.initialize();
3223
- case 4:
3224
- userState = _context.sent;
3225
- if (!(userState.status !== 'authenticated' && userState.status !== 'expired')) {
3226
- _context.next = 9;
3227
- break;
3228
- }
3229
- setIsFirstTimeNotifiUser(true);
3230
- _context.next = 15;
3231
- break;
3232
- case 9:
3233
- if (!(userState.status === 'authenticated')) {
3234
- _context.next = 15;
3235
- break;
3236
- }
3237
- _context.next = 12;
3238
- return client.getTargetGroups();
3239
- case 12:
3240
- targetGroups = _context.sent;
3241
- emailTargets = (_targetGroups$ = targetGroups[0]) === null || _targetGroups$ === void 0 ? void 0 : (_targetGroups$$emailT = _targetGroups$.emailTargets) === null || _targetGroups$$emailT === void 0 ? void 0 : _targetGroups$$emailT[0];
3242
- if (emailTargets == null || emailTargets.emailAddress == null) {
3243
- setIsFirstTimeNotifiUser(true);
3244
- }
3245
- case 15:
3246
- case "end":
3247
- return _context.stop();
3248
- }
3249
- }, _callee);
3250
- }));
3251
- return function checkIsFirstTimeNotifiUser() {
3252
- return _ref.apply(this, arguments);
3253
- };
3254
- }();
3255
- checkIsFirstTimeNotifiUser();
3256
- }, [account, chainId]);
3257
- return {
3258
- isFirstTimeNotifiUser: isFirstTimeNotifiUser
3259
- };
3260
- };
3261
- var useDoesChainSupportNotifi = function useDoesChainSupportNotifi(account, chainId) {
3262
- var _useState3 = useState(false),
3263
- _useState4 = _slicedToArray(_useState3, 2),
3264
- notifiChainSupported = _useState4[0],
3265
- setNotifiChainSupported = _useState4[1];
3266
- useEffect(function () {
3267
- var checkNotifiChainSupported = /*#__PURE__*/function () {
3268
- var _ref2 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee2() {
3269
- return regenerator.wrap(function _callee2$(_context2) {
3270
- while (1) switch (_context2.prev = _context2.next) {
3271
- case 0:
3272
- if (account != null && chainId != null) {
3273
- setNotifiChainSupported(doesChainSupportNotifi(chainId, checkIsDev(), account));
3274
- }
3275
- case 1:
3276
- case "end":
3277
- return _context2.stop();
3278
- }
3279
- }, _callee2);
3280
- }));
3281
- return function checkNotifiChainSupported() {
3282
- return _ref2.apply(this, arguments);
3283
- };
3284
- }();
3285
- checkNotifiChainSupported();
3286
- }, [account, chainId]);
3287
- return {
3288
- notifiChainSupported: notifiChainSupported
3289
- };
3290
- };
3291
-
3292
3320
  function CreditLineBorrow(_ref) {
3293
3321
  var poolNameStr = _ref.poolName,
3294
3322
  poolTypeStr = _ref.poolType,