@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.
@@ -19,8 +19,8 @@ var constants = require('@ethersproject/constants');
19
19
  var ethers = require('ethers');
20
20
  var ArrowDropDownIcon = require('@mui/icons-material/ArrowDropDown');
21
21
  var ArrowDropUpIcon = require('@mui/icons-material/ArrowDropUp');
22
- var notifiFrontendClient = require('@notifi-network/notifi-frontend-client');
23
22
  var Email = require('@mui/icons-material/Email');
23
+ var notifiFrontendClient = require('@notifi-network/notifi-frontend-client');
24
24
  var ArrowForwardIosIcon = require('@mui/icons-material/ArrowForwardIos');
25
25
  var client = require('@apollo/client');
26
26
  var Table = require('@mui/material/Table');
@@ -652,42 +652,42 @@ var selectWidgetState = function selectWidgetState(state) {
652
652
  return state.widget;
653
653
  };
654
654
 
655
- var _path$6;
656
- 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); }
655
+ var _path$7;
656
+ 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); }
657
657
  var SvgReceipt = function SvgReceipt(props) {
658
- return /*#__PURE__*/React__default["default"].createElement("svg", _extends$6({
658
+ return /*#__PURE__*/React__default["default"].createElement("svg", _extends$7({
659
659
  width: 24,
660
660
  height: 24,
661
661
  fill: "none",
662
662
  xmlns: "http://www.w3.org/2000/svg"
663
- }, props), _path$6 || (_path$6 = /*#__PURE__*/React__default["default"].createElement("path", {
663
+ }, props), _path$7 || (_path$7 = /*#__PURE__*/React__default["default"].createElement("path", {
664
664
  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",
665
665
  fill: "#76707E"
666
666
  })));
667
667
  };
668
668
 
669
- var _path$5;
670
- 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); }
669
+ var _path$6;
670
+ 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); }
671
671
  var SvgSeparator = function SvgSeparator(props) {
672
- return /*#__PURE__*/React__default["default"].createElement("svg", _extends$5({
672
+ return /*#__PURE__*/React__default["default"].createElement("svg", _extends$6({
673
673
  width: 2,
674
674
  height: 14,
675
675
  fill: "none",
676
676
  xmlns: "http://www.w3.org/2000/svg"
677
- }, props), _path$5 || (_path$5 = /*#__PURE__*/React__default["default"].createElement("path", {
677
+ }, props), _path$6 || (_path$6 = /*#__PURE__*/React__default["default"].createElement("path", {
678
678
  fill: "#E0E0E0",
679
679
  d: "M0 0h2v14H0z"
680
680
  })));
681
681
  };
682
682
 
683
- 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;
684
- 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); }
683
+ 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;
684
+ 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); }
685
685
  var SvgLoader = function SvgLoader(props) {
686
- return /*#__PURE__*/React__default["default"].createElement("svg", _extends$4({
686
+ return /*#__PURE__*/React__default["default"].createElement("svg", _extends$5({
687
687
  xmlns: "http://www.w3.org/2000/svg",
688
688
  fill: "none",
689
689
  viewBox: "0 0 81 80"
690
- }, props), _path$4 || (_path$4 = /*#__PURE__*/React__default["default"].createElement("path", {
690
+ }, props), _path$5 || (_path$5 = /*#__PURE__*/React__default["default"].createElement("path", {
691
691
  stroke: "url(#loader_svg__a)",
692
692
  strokeMiterlimit: 10,
693
693
  strokeWidth: 0.5,
@@ -1455,10 +1455,10 @@ var SvgLoader = function SvgLoader(props) {
1455
1455
  })))));
1456
1456
  };
1457
1457
 
1458
- var _circle, _path$3, _defs;
1459
- 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); }
1458
+ var _circle, _path$4, _defs;
1459
+ 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); }
1460
1460
  var SvgCheck = function SvgCheck(props) {
1461
- return /*#__PURE__*/React__default["default"].createElement("svg", _extends$3({
1461
+ return /*#__PURE__*/React__default["default"].createElement("svg", _extends$4({
1462
1462
  width: 120,
1463
1463
  height: 120,
1464
1464
  fill: "none",
@@ -1468,7 +1468,7 @@ var SvgCheck = function SvgCheck(props) {
1468
1468
  cy: 60,
1469
1469
  r: 60,
1470
1470
  fill: "#F7F1FF"
1471
- })), _path$3 || (_path$3 = /*#__PURE__*/React__default["default"].createElement("path", {
1471
+ })), _path$4 || (_path$4 = /*#__PURE__*/React__default["default"].createElement("path", {
1472
1472
  fillRule: "evenodd",
1473
1473
  clipRule: "evenodd",
1474
1474
  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",
@@ -1488,15 +1488,15 @@ var SvgCheck = function SvgCheck(props) {
1488
1488
  })))));
1489
1489
  };
1490
1490
 
1491
- var _path$2;
1492
- 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); }
1491
+ var _path$3;
1492
+ 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); }
1493
1493
  var SvgCheckGreen = function SvgCheckGreen(props) {
1494
- return /*#__PURE__*/React__default["default"].createElement("svg", _extends$2({
1494
+ return /*#__PURE__*/React__default["default"].createElement("svg", _extends$3({
1495
1495
  xmlns: "http://www.w3.org/2000/svg",
1496
1496
  width: 24,
1497
1497
  height: 24,
1498
1498
  fill: "none"
1499
- }, props), _path$2 || (_path$2 = /*#__PURE__*/React__default["default"].createElement("path", {
1499
+ }, props), _path$3 || (_path$3 = /*#__PURE__*/React__default["default"].createElement("path", {
1500
1500
  fill: "#45CB71",
1501
1501
  fillRule: "evenodd",
1502
1502
  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",
@@ -1504,28 +1504,28 @@ var SvgCheckGreen = function SvgCheckGreen(props) {
1504
1504
  })));
1505
1505
  };
1506
1506
 
1507
- var _path$1;
1508
- 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); }
1507
+ var _path$2;
1508
+ 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); }
1509
1509
  var SvgCheckCircle = function SvgCheckCircle(props) {
1510
- return /*#__PURE__*/React__default["default"].createElement("svg", _extends$1({
1510
+ return /*#__PURE__*/React__default["default"].createElement("svg", _extends$2({
1511
1511
  xmlns: "http://www.w3.org/2000/svg",
1512
1512
  width: 22,
1513
1513
  height: 22,
1514
1514
  fill: "none"
1515
- }, props), _path$1 || (_path$1 = /*#__PURE__*/React__default["default"].createElement("path", {
1515
+ }, props), _path$2 || (_path$2 = /*#__PURE__*/React__default["default"].createElement("path", {
1516
1516
  fill: "#2E7D32",
1517
1517
  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"
1518
1518
  })));
1519
1519
  };
1520
1520
 
1521
- var _path, _path2, _path3;
1522
- 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); }
1521
+ var _path$1, _path2, _path3;
1522
+ 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); }
1523
1523
  var SvgUsdc = function SvgUsdc(props) {
1524
- return /*#__PURE__*/React__default["default"].createElement("svg", _extends({
1524
+ return /*#__PURE__*/React__default["default"].createElement("svg", _extends$1({
1525
1525
  "data-name": "86977684-12db-4850-8f30-233a7c267d11",
1526
1526
  xmlns: "http://www.w3.org/2000/svg",
1527
1527
  viewBox: "0 0 2000 2000"
1528
- }, props), _path || (_path = /*#__PURE__*/React__default["default"].createElement("path", {
1528
+ }, props), _path$1 || (_path$1 = /*#__PURE__*/React__default["default"].createElement("path", {
1529
1529
  d: "M1000 2000c554.17 0 1000-445.83 1000-1000S1554.17 0 1000 0 0 445.83 0 1000s445.83 1000 1000 1000z",
1530
1530
  fill: "#2775ca"
1531
1531
  })), _path2 || (_path2 = /*#__PURE__*/React__default["default"].createElement("path", {
@@ -1537,6 +1537,28 @@ var SvgUsdc = function SvgUsdc(props) {
1537
1537
  })));
1538
1538
  };
1539
1539
 
1540
+ var _path;
1541
+ 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); }
1542
+ var SvgCelo = function SvgCelo(props) {
1543
+ return /*#__PURE__*/React__default["default"].createElement("svg", _extends({
1544
+ xmlns: "http://www.w3.org/2000/svg",
1545
+ viewBox: "0 0 250 250",
1546
+ style: {
1547
+ enableBackground: "new 0 0 250 250"
1548
+ },
1549
+ xmlSpace: "preserve"
1550
+ }, props), /*#__PURE__*/React__default["default"].createElement("circle", {
1551
+ cx: 125,
1552
+ cy: 125,
1553
+ r: 125,
1554
+ style: {
1555
+ fill: "#fcff52"
1556
+ }
1557
+ }), _path || (_path = /*#__PURE__*/React__default["default"].createElement("path", {
1558
+ 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"
1559
+ })));
1560
+ };
1561
+
1540
1562
  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; }
1541
1563
  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; }
1542
1564
  function ReceiptIcon(props) {
@@ -1560,11 +1582,15 @@ function CheckCircleIcon(props) {
1560
1582
  function UsdcIcon(props) {
1561
1583
  return jsxRuntime.jsx(SvgUsdc, _objectSpread$4({}, props));
1562
1584
  }
1585
+ function CeloIcon(props) {
1586
+ return jsxRuntime.jsx(SvgCelo, _objectSpread$4({}, props));
1587
+ }
1563
1588
  function getIcon(icon) {
1564
- if (icon === 'USDC') {
1565
- return UsdcIcon;
1566
- }
1567
- return null;
1589
+ if (!icon) return null;
1590
+ return {
1591
+ USDC: UsdcIcon,
1592
+ Celo: CeloIcon
1593
+ }[icon] || null;
1568
1594
  }
1569
1595
 
1570
1596
  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)."; }
@@ -2929,6 +2955,140 @@ function Success$6(_ref) {
2929
2955
  });
2930
2956
  }
2931
2957
 
2958
+ var useDoesChainSupportNotifi = function useDoesChainSupportNotifi(account, chainId) {
2959
+ var _useState = React.useState(false),
2960
+ _useState2 = _slicedToArray(_useState, 2),
2961
+ notifiChainSupported = _useState2[0],
2962
+ setNotifiChainSupported = _useState2[1];
2963
+ React.useEffect(function () {
2964
+ var checkNotifiChainSupported = /*#__PURE__*/function () {
2965
+ var _ref = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee() {
2966
+ return regenerator.wrap(function _callee$(_context) {
2967
+ while (1) switch (_context.prev = _context.next) {
2968
+ case 0:
2969
+ if (account != null && chainId != null) {
2970
+ setNotifiChainSupported(shared.doesChainSupportNotifi(chainId, shared.checkIsDev(), account));
2971
+ }
2972
+ case 1:
2973
+ case "end":
2974
+ return _context.stop();
2975
+ }
2976
+ }, _callee);
2977
+ }));
2978
+ return function checkNotifiChainSupported() {
2979
+ return _ref.apply(this, arguments);
2980
+ };
2981
+ }();
2982
+ checkNotifiChainSupported();
2983
+ }, [account, chainId]);
2984
+ return {
2985
+ notifiChainSupported: notifiChainSupported
2986
+ };
2987
+ };
2988
+ var useNotifiClient = function useNotifiClient(account, chainId, isDev) {
2989
+ var _useState3 = React.useState(null),
2990
+ _useState4 = _slicedToArray(_useState3, 2),
2991
+ notifiClient = _useState4[0],
2992
+ setNotifiClient = _useState4[1];
2993
+ var _useDoesChainSupportN = useDoesChainSupportNotifi(account, chainId),
2994
+ notifiChainSupported = _useDoesChainSupportN.notifiChainSupported;
2995
+ React.useEffect(function () {
2996
+ var createNotifiClient = /*#__PURE__*/function () {
2997
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee2() {
2998
+ var client;
2999
+ return regenerator.wrap(function _callee2$(_context2) {
3000
+ while (1) switch (_context2.prev = _context2.next) {
3001
+ case 0:
3002
+ if (!(account != null && chainId != null && notifiChainSupported)) {
3003
+ _context2.next = 5;
3004
+ break;
3005
+ }
3006
+ client = notifiFrontendClient.newFrontendClient({
3007
+ account: {
3008
+ publicKey: account
3009
+ },
3010
+ tenantId: shared.getNotifiDappId(isDev),
3011
+ env: isDev ? 'Development' : 'Production',
3012
+ walletBlockchain: shared.getBlockchainConfigFromChain(chainId)
3013
+ });
3014
+ _context2.next = 4;
3015
+ return client.initialize();
3016
+ case 4:
3017
+ setNotifiClient(client);
3018
+ case 5:
3019
+ case "end":
3020
+ return _context2.stop();
3021
+ }
3022
+ }, _callee2);
3023
+ }));
3024
+ return function createNotifiClient() {
3025
+ return _ref2.apply(this, arguments);
3026
+ };
3027
+ }();
3028
+ createNotifiClient();
3029
+ }, [account, chainId, isDev, notifiChainSupported]);
3030
+ return {
3031
+ notifiClient: notifiClient
3032
+ };
3033
+ };
3034
+ var useIsFirstTimeNotifiUser = function useIsFirstTimeNotifiUser(account, chainId) {
3035
+ var _useState5 = React.useState(false),
3036
+ _useState6 = _slicedToArray(_useState5, 2),
3037
+ isFirstTimeNotifiUser = _useState6[0],
3038
+ setIsFirstTimeNotifiUser = _useState6[1];
3039
+ var _useNotifiClient = useNotifiClient(account, chainId, shared.checkIsDev()),
3040
+ notifiClient = _useNotifiClient.notifiClient;
3041
+ var _useDoesChainSupportN2 = useDoesChainSupportNotifi(account, chainId),
3042
+ notifiChainSupported = _useDoesChainSupportN2.notifiChainSupported;
3043
+ React.useEffect(function () {
3044
+ var checkIsFirstTimeNotifiUser = /*#__PURE__*/function () {
3045
+ var _ref3 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee3() {
3046
+ var userState, _targetGroups$, _targetGroups$$emailT, targetGroups, emailTargets;
3047
+ return regenerator.wrap(function _callee3$(_context3) {
3048
+ while (1) switch (_context3.prev = _context3.next) {
3049
+ case 0:
3050
+ if (!(notifiClient != null && notifiChainSupported)) {
3051
+ _context3.next = 12;
3052
+ break;
3053
+ }
3054
+ userState = notifiClient.userState; // If the user is not authenticated or expired, they are a first time user
3055
+ if (!(userState == null || userState.status !== 'authenticated' && userState.status !== 'expired')) {
3056
+ _context3.next = 6;
3057
+ break;
3058
+ }
3059
+ setIsFirstTimeNotifiUser(true);
3060
+ _context3.next = 12;
3061
+ break;
3062
+ case 6:
3063
+ if (!(userState.status === 'authenticated')) {
3064
+ _context3.next = 12;
3065
+ break;
3066
+ }
3067
+ _context3.next = 9;
3068
+ return notifiClient.getTargetGroups();
3069
+ case 9:
3070
+ targetGroups = _context3.sent;
3071
+ emailTargets = (_targetGroups$ = targetGroups[0]) === null || _targetGroups$ === void 0 ? void 0 : (_targetGroups$$emailT = _targetGroups$.emailTargets) === null || _targetGroups$$emailT === void 0 ? void 0 : _targetGroups$$emailT[0];
3072
+ if (emailTargets == null || emailTargets.emailAddress == null) {
3073
+ setIsFirstTimeNotifiUser(true);
3074
+ }
3075
+ case 12:
3076
+ case "end":
3077
+ return _context3.stop();
3078
+ }
3079
+ }, _callee3);
3080
+ }));
3081
+ return function checkIsFirstTimeNotifiUser() {
3082
+ return _ref3.apply(this, arguments);
3083
+ };
3084
+ }();
3085
+ checkIsFirstTimeNotifiUser();
3086
+ }, [notifiChainSupported, notifiClient]);
3087
+ return {
3088
+ isFirstTimeNotifiUser: isFirstTimeNotifiUser
3089
+ };
3090
+ };
3091
+
2932
3092
  var _templateObject$9, _templateObject2$7, _templateObject3$5, _templateObject4$4, _templateObject5$1;
2933
3093
  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; }
2934
3094
  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; }
@@ -2950,23 +3110,23 @@ function fetchEventTypes(_x) {
2950
3110
  return _fetchEventTypes.apply(this, arguments);
2951
3111
  }
2952
3112
  function _fetchEventTypes() {
2953
- _fetchEventTypes = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee4(notifiClient) {
3113
+ _fetchEventTypes = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee3(notifiClient) {
2954
3114
  var _process$env$REACT_AP, _subscriptionConfig$e;
2955
3115
  var subscribedAlerts, subscriptionConfig, eventTypes;
2956
- return regenerator.wrap(function _callee4$(_context4) {
2957
- while (1) switch (_context4.prev = _context4.next) {
3116
+ return regenerator.wrap(function _callee3$(_context3) {
3117
+ while (1) switch (_context3.prev = _context3.next) {
2958
3118
  case 0:
2959
- _context4.next = 2;
3119
+ _context3.next = 2;
2960
3120
  return notifiClient.getAlerts();
2961
3121
  case 2:
2962
- subscribedAlerts = _context4.sent;
2963
- _context4.next = 5;
3122
+ subscribedAlerts = _context3.sent;
3123
+ _context3.next = 5;
2964
3124
  return notifiClient.fetchSubscriptionCard({
2965
3125
  id: (_process$env$REACT_AP = process.env.REACT_APP_NOTIFI_CONFIG_ID) !== null && _process$env$REACT_AP !== void 0 ? _process$env$REACT_AP : '',
2966
3126
  type: 'SUBSCRIPTION_CARD'
2967
3127
  });
2968
3128
  case 5:
2969
- subscriptionConfig = _context4.sent;
3129
+ subscriptionConfig = _context3.sent;
2970
3130
  eventTypes = subscriptionConfig === null || subscriptionConfig === void 0 ? void 0 : (_subscriptionConfig$e = subscriptionConfig.eventTypes) === null || _subscriptionConfig$e === void 0 ? void 0 : _subscriptionConfig$e.map(function (eventType) {
2971
3131
  var eventTypeId = getIdFromEventType(eventType);
2972
3132
  var enabled = false;
@@ -2981,12 +3141,12 @@ function _fetchEventTypes() {
2981
3141
  enabled: enabled
2982
3142
  });
2983
3143
  });
2984
- return _context4.abrupt("return", eventTypes);
3144
+ return _context3.abrupt("return", eventTypes);
2985
3145
  case 8:
2986
3146
  case "end":
2987
- return _context4.stop();
3147
+ return _context3.stop();
2988
3148
  }
2989
- }, _callee4);
3149
+ }, _callee3);
2990
3150
  }));
2991
3151
  return _fetchEventTypes.apply(this, arguments);
2992
3152
  }
@@ -2999,81 +3159,44 @@ function NotifiSubscriptionModal(_ref) {
2999
3159
  account = _useWeb3React.account,
3000
3160
  chainId = _useWeb3React.chainId,
3001
3161
  provider = _useWeb3React.provider;
3002
- var _useState = React.useState(),
3162
+ var _useState = React.useState(false),
3003
3163
  _useState2 = _slicedToArray(_useState, 2),
3004
- notifiClient = _useState2[0],
3005
- setNotifiClient = _useState2[1];
3164
+ showSuccessScreen = _useState2[0],
3165
+ setShowSuccessScreen = _useState2[1];
3006
3166
  var _useState3 = React.useState(false),
3007
3167
  _useState4 = _slicedToArray(_useState3, 2),
3008
- showSuccessScreen = _useState4[0],
3009
- setShowSuccessScreen = _useState4[1];
3010
- var _useState5 = React.useState(false),
3168
+ isLoading = _useState4[0],
3169
+ setIsLoading = _useState4[1];
3170
+ var _useState5 = React.useState(''),
3011
3171
  _useState6 = _slicedToArray(_useState5, 2),
3012
- isLoading = _useState6[0],
3013
- setIsLoading = _useState6[1];
3014
- var _useState7 = React.useState(''),
3172
+ emailAddress = _useState6[0],
3173
+ setEmailAddress = _useState6[1];
3174
+ var _useState7 = React.useState(),
3015
3175
  _useState8 = _slicedToArray(_useState7, 2),
3016
- emailAddress = _useState8[0],
3017
- setEmailAddress = _useState8[1];
3018
- var _useState9 = React.useState(),
3019
- _useState10 = _slicedToArray(_useState9, 2),
3020
- emailValid = _useState10[0],
3021
- setEmailValid = _useState10[1];
3022
- React.useEffect(function () {
3023
- var initializeClient = /*#__PURE__*/function () {
3024
- var _ref2 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee() {
3025
- var client;
3026
- return regenerator.wrap(function _callee$(_context) {
3027
- while (1) switch (_context.prev = _context.next) {
3028
- case 0:
3029
- if (!(account != null && chainId != null)) {
3030
- _context.next = 5;
3031
- break;
3032
- }
3033
- client = notifiFrontendClient.newFrontendClient({
3034
- account: {
3035
- publicKey: account
3036
- },
3037
- tenantId: shared.getNotifiDappId(shared.checkIsDev()),
3038
- env: shared.checkIsDev() ? 'Development' : 'Production',
3039
- walletBlockchain: shared.getBlockchainConfigFromChain(chainId)
3040
- });
3041
- _context.next = 4;
3042
- return client.initialize();
3043
- case 4:
3044
- setNotifiClient(client);
3045
- case 5:
3046
- case "end":
3047
- return _context.stop();
3048
- }
3049
- }, _callee);
3050
- }));
3051
- return function initializeClient() {
3052
- return _ref2.apply(this, arguments);
3053
- };
3054
- }();
3055
- initializeClient();
3056
- }, [account, chainId]);
3176
+ emailValid = _useState8[0],
3177
+ setEmailValid = _useState8[1];
3178
+ var _useNotifiClient = useNotifiClient(account, chainId, shared.checkIsDev()),
3179
+ notifiClient = _useNotifiClient.notifiClient;
3057
3180
  var signMessage = /*#__PURE__*/function () {
3058
- var _ref3 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee2(message) {
3181
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(message) {
3059
3182
  var signer, signature;
3060
- return regenerator.wrap(function _callee2$(_context2) {
3061
- while (1) switch (_context2.prev = _context2.next) {
3183
+ return regenerator.wrap(function _callee$(_context) {
3184
+ while (1) switch (_context.prev = _context.next) {
3062
3185
  case 0:
3063
3186
  signer = provider.getSigner();
3064
- _context2.next = 3;
3187
+ _context.next = 3;
3065
3188
  return signer.signMessage(Buffer.from(message));
3066
3189
  case 3:
3067
- signature = _context2.sent;
3068
- return _context2.abrupt("return", ethers.ethers.utils.arrayify(signature));
3190
+ signature = _context.sent;
3191
+ return _context.abrupt("return", ethers.ethers.utils.arrayify(signature));
3069
3192
  case 5:
3070
3193
  case "end":
3071
- return _context2.stop();
3194
+ return _context.stop();
3072
3195
  }
3073
- }, _callee2);
3196
+ }, _callee);
3074
3197
  }));
3075
3198
  return function signMessage(_x2) {
3076
- return _ref3.apply(this, arguments);
3199
+ return _ref2.apply(this, arguments);
3077
3200
  };
3078
3201
  }();
3079
3202
  var handleEmailAddressChange = function handleEmailAddressChange(event) {
@@ -3083,38 +3206,38 @@ function NotifiSubscriptionModal(_ref) {
3083
3206
  setEmailAddress(event.target.value);
3084
3207
  };
3085
3208
  var logInAndSubscribe = /*#__PURE__*/function () {
3086
- var _ref4 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee3() {
3209
+ var _ref3 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee2() {
3087
3210
  var fetchedEventTypes, _iterator, _step, eventType;
3088
- return regenerator.wrap(function _callee3$(_context3) {
3089
- while (1) switch (_context3.prev = _context3.next) {
3211
+ return regenerator.wrap(function _callee2$(_context2) {
3212
+ while (1) switch (_context2.prev = _context2.next) {
3090
3213
  case 0:
3091
3214
  if (!(notifiClient != null && chainId != null)) {
3092
- _context3.next = 35;
3215
+ _context2.next = 35;
3093
3216
  break;
3094
3217
  }
3095
3218
  setIsLoading(true);
3096
3219
 
3097
3220
  // Ask user to sign a message to authenticate
3098
- _context3.prev = 2;
3099
- _context3.next = 5;
3221
+ _context2.prev = 2;
3222
+ _context2.next = 5;
3100
3223
  return notifiClient.logIn({
3101
3224
  walletBlockchain: shared.getBlockchainConfigFromChain(chainId),
3102
3225
  signMessage: signMessage
3103
3226
  });
3104
3227
  case 5:
3105
- _context3.next = 11;
3228
+ _context2.next = 11;
3106
3229
  break;
3107
3230
  case 7:
3108
- _context3.prev = 7;
3109
- _context3.t0 = _context3["catch"](2);
3231
+ _context2.prev = 7;
3232
+ _context2.t0 = _context2["catch"](2);
3110
3233
  setIsLoading(false);
3111
- return _context3.abrupt("return");
3234
+ return _context2.abrupt("return");
3112
3235
  case 11:
3113
- _context3.next = 13;
3236
+ _context2.next = 13;
3114
3237
  return fetchEventTypes(notifiClient);
3115
3238
  case 13:
3116
- fetchedEventTypes = _context3.sent;
3117
- _context3.next = 16;
3239
+ fetchedEventTypes = _context2.sent;
3240
+ _context2.next = 16;
3118
3241
  return notifiClient.ensureTargetGroup({
3119
3242
  name: 'Default',
3120
3243
  emailAddress: emailAddress
@@ -3124,44 +3247,44 @@ function NotifiSubscriptionModal(_ref) {
3124
3247
  // multiple calls. Notified their team to fix this.
3125
3248
  // eslint-disable-next-line no-restricted-syntax
3126
3249
  _iterator = _createForOfIteratorHelper(fetchedEventTypes);
3127
- _context3.prev = 17;
3250
+ _context2.prev = 17;
3128
3251
  _iterator.s();
3129
3252
  case 19:
3130
3253
  if ((_step = _iterator.n()).done) {
3131
- _context3.next = 25;
3254
+ _context2.next = 25;
3132
3255
  break;
3133
3256
  }
3134
3257
  eventType = _step.value;
3135
- _context3.next = 23;
3258
+ _context2.next = 23;
3136
3259
  return notifiClient.ensureAlert({
3137
3260
  eventType: eventType,
3138
3261
  inputs: {}
3139
3262
  });
3140
3263
  case 23:
3141
- _context3.next = 19;
3264
+ _context2.next = 19;
3142
3265
  break;
3143
3266
  case 25:
3144
- _context3.next = 30;
3267
+ _context2.next = 30;
3145
3268
  break;
3146
3269
  case 27:
3147
- _context3.prev = 27;
3148
- _context3.t1 = _context3["catch"](17);
3149
- _iterator.e(_context3.t1);
3270
+ _context2.prev = 27;
3271
+ _context2.t1 = _context2["catch"](17);
3272
+ _iterator.e(_context2.t1);
3150
3273
  case 30:
3151
- _context3.prev = 30;
3274
+ _context2.prev = 30;
3152
3275
  _iterator.f();
3153
- return _context3.finish(30);
3276
+ return _context2.finish(30);
3154
3277
  case 33:
3155
3278
  setShowSuccessScreen(true);
3156
3279
  setIsLoading(false);
3157
3280
  case 35:
3158
3281
  case "end":
3159
- return _context3.stop();
3282
+ return _context2.stop();
3160
3283
  }
3161
- }, _callee3, null, [[2, 7], [17, 27, 30, 33]]);
3284
+ }, _callee2, null, [[2, 7], [17, 27, 30, 33]]);
3162
3285
  }));
3163
3286
  return function logInAndSubscribe() {
3164
- return _ref4.apply(this, arguments);
3287
+ return _ref3.apply(this, arguments);
3165
3288
  };
3166
3289
  }();
3167
3290
  var handleCloseModal = React.useCallback(function () {
@@ -3233,101 +3356,6 @@ function Notifications$1(_ref) {
3233
3356
  });
3234
3357
  }
3235
3358
 
3236
- var useIsFirstTimeNotifiUser = function useIsFirstTimeNotifiUser(account, chainId) {
3237
- var _useState = React.useState(false),
3238
- _useState2 = _slicedToArray(_useState, 2),
3239
- isFirstTimeNotifiUser = _useState2[0],
3240
- setIsFirstTimeNotifiUser = _useState2[1];
3241
- React.useEffect(function () {
3242
- var checkIsFirstTimeNotifiUser = /*#__PURE__*/function () {
3243
- var _ref = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee() {
3244
- var client, userState, _targetGroups$, _targetGroups$$emailT, targetGroups, emailTargets;
3245
- return regenerator.wrap(function _callee$(_context) {
3246
- while (1) switch (_context.prev = _context.next) {
3247
- case 0:
3248
- if (!(account != null && chainId != null)) {
3249
- _context.next = 15;
3250
- break;
3251
- }
3252
- client = notifiFrontendClient.newFrontendClient({
3253
- account: {
3254
- publicKey: account
3255
- },
3256
- tenantId: 'humadapp',
3257
- env: shared.checkIsDev() ? 'Development' : 'Production',
3258
- walletBlockchain: shared.getBlockchainConfigFromChain(chainId)
3259
- });
3260
- _context.next = 4;
3261
- return client.initialize();
3262
- case 4:
3263
- userState = _context.sent;
3264
- if (!(userState.status !== 'authenticated' && userState.status !== 'expired')) {
3265
- _context.next = 9;
3266
- break;
3267
- }
3268
- setIsFirstTimeNotifiUser(true);
3269
- _context.next = 15;
3270
- break;
3271
- case 9:
3272
- if (!(userState.status === 'authenticated')) {
3273
- _context.next = 15;
3274
- break;
3275
- }
3276
- _context.next = 12;
3277
- return client.getTargetGroups();
3278
- case 12:
3279
- targetGroups = _context.sent;
3280
- emailTargets = (_targetGroups$ = targetGroups[0]) === null || _targetGroups$ === void 0 ? void 0 : (_targetGroups$$emailT = _targetGroups$.emailTargets) === null || _targetGroups$$emailT === void 0 ? void 0 : _targetGroups$$emailT[0];
3281
- if (emailTargets == null || emailTargets.emailAddress == null) {
3282
- setIsFirstTimeNotifiUser(true);
3283
- }
3284
- case 15:
3285
- case "end":
3286
- return _context.stop();
3287
- }
3288
- }, _callee);
3289
- }));
3290
- return function checkIsFirstTimeNotifiUser() {
3291
- return _ref.apply(this, arguments);
3292
- };
3293
- }();
3294
- checkIsFirstTimeNotifiUser();
3295
- }, [account, chainId]);
3296
- return {
3297
- isFirstTimeNotifiUser: isFirstTimeNotifiUser
3298
- };
3299
- };
3300
- var useDoesChainSupportNotifi = function useDoesChainSupportNotifi(account, chainId) {
3301
- var _useState3 = React.useState(false),
3302
- _useState4 = _slicedToArray(_useState3, 2),
3303
- notifiChainSupported = _useState4[0],
3304
- setNotifiChainSupported = _useState4[1];
3305
- React.useEffect(function () {
3306
- var checkNotifiChainSupported = /*#__PURE__*/function () {
3307
- var _ref2 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee2() {
3308
- return regenerator.wrap(function _callee2$(_context2) {
3309
- while (1) switch (_context2.prev = _context2.next) {
3310
- case 0:
3311
- if (account != null && chainId != null) {
3312
- setNotifiChainSupported(shared.doesChainSupportNotifi(chainId, shared.checkIsDev(), account));
3313
- }
3314
- case 1:
3315
- case "end":
3316
- return _context2.stop();
3317
- }
3318
- }, _callee2);
3319
- }));
3320
- return function checkNotifiChainSupported() {
3321
- return _ref2.apply(this, arguments);
3322
- };
3323
- }();
3324
- checkNotifiChainSupported();
3325
- }, [account, chainId]);
3326
- return {
3327
- notifiChainSupported: notifiChainSupported
3328
- };
3329
- };
3330
-
3331
3359
  function CreditLineBorrow(_ref) {
3332
3360
  var poolNameStr = _ref.poolName,
3333
3361
  poolTypeStr = _ref.poolType,