@huma-finance/widgets 0.0.43-beta.114 → 0.0.43-beta.122
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 +189 -191
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/index.js +190 -192
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
- package/src/components/Notifi/NotifiSubscriptionModal.tsx +3 -23
- package/src/hooks/useNotifi.ts +38 -11
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,
|
|
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';
|
|
@@ -2890,6 +2890,136 @@ function Success$6(_ref) {
|
|
|
2890
2890
|
});
|
|
2891
2891
|
}
|
|
2892
2892
|
|
|
2893
|
+
var useNotifiClient = function useNotifiClient(account, chainId, isDev) {
|
|
2894
|
+
var _useState = useState(null),
|
|
2895
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
2896
|
+
notifiClient = _useState2[0],
|
|
2897
|
+
setNotifiClient = _useState2[1];
|
|
2898
|
+
useEffect(function () {
|
|
2899
|
+
var createNotifiClient = /*#__PURE__*/function () {
|
|
2900
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee() {
|
|
2901
|
+
var client;
|
|
2902
|
+
return regenerator.wrap(function _callee$(_context) {
|
|
2903
|
+
while (1) switch (_context.prev = _context.next) {
|
|
2904
|
+
case 0:
|
|
2905
|
+
if (!(account != null && chainId != null)) {
|
|
2906
|
+
_context.next = 5;
|
|
2907
|
+
break;
|
|
2908
|
+
}
|
|
2909
|
+
client = newFrontendClient({
|
|
2910
|
+
account: {
|
|
2911
|
+
publicKey: account
|
|
2912
|
+
},
|
|
2913
|
+
tenantId: getNotifiDappId(isDev),
|
|
2914
|
+
env: isDev ? 'Development' : 'Production',
|
|
2915
|
+
walletBlockchain: getBlockchainConfigFromChain(chainId)
|
|
2916
|
+
});
|
|
2917
|
+
_context.next = 4;
|
|
2918
|
+
return client.initialize();
|
|
2919
|
+
case 4:
|
|
2920
|
+
setNotifiClient(client);
|
|
2921
|
+
case 5:
|
|
2922
|
+
case "end":
|
|
2923
|
+
return _context.stop();
|
|
2924
|
+
}
|
|
2925
|
+
}, _callee);
|
|
2926
|
+
}));
|
|
2927
|
+
return function createNotifiClient() {
|
|
2928
|
+
return _ref.apply(this, arguments);
|
|
2929
|
+
};
|
|
2930
|
+
}();
|
|
2931
|
+
createNotifiClient();
|
|
2932
|
+
}, [account, chainId, isDev]);
|
|
2933
|
+
return {
|
|
2934
|
+
notifiClient: notifiClient
|
|
2935
|
+
};
|
|
2936
|
+
};
|
|
2937
|
+
var useIsFirstTimeNotifiUser = function useIsFirstTimeNotifiUser(account, chainId) {
|
|
2938
|
+
var _useState3 = useState(false),
|
|
2939
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
2940
|
+
isFirstTimeNotifiUser = _useState4[0],
|
|
2941
|
+
setIsFirstTimeNotifiUser = _useState4[1];
|
|
2942
|
+
var _useNotifiClient = useNotifiClient(account, chainId, checkIsDev()),
|
|
2943
|
+
notifiClient = _useNotifiClient.notifiClient;
|
|
2944
|
+
useEffect(function () {
|
|
2945
|
+
var checkIsFirstTimeNotifiUser = /*#__PURE__*/function () {
|
|
2946
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee2() {
|
|
2947
|
+
var userState, _targetGroups$, _targetGroups$$emailT, targetGroups, emailTargets;
|
|
2948
|
+
return regenerator.wrap(function _callee2$(_context2) {
|
|
2949
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
2950
|
+
case 0:
|
|
2951
|
+
if (!(notifiClient != null)) {
|
|
2952
|
+
_context2.next = 12;
|
|
2953
|
+
break;
|
|
2954
|
+
}
|
|
2955
|
+
userState = notifiClient.userState; // If the user is not authenticated or expired, they are a first time user
|
|
2956
|
+
if (!(userState == null || userState.status !== 'authenticated' && userState.status !== 'expired')) {
|
|
2957
|
+
_context2.next = 6;
|
|
2958
|
+
break;
|
|
2959
|
+
}
|
|
2960
|
+
setIsFirstTimeNotifiUser(true);
|
|
2961
|
+
_context2.next = 12;
|
|
2962
|
+
break;
|
|
2963
|
+
case 6:
|
|
2964
|
+
if (!(userState.status === 'authenticated')) {
|
|
2965
|
+
_context2.next = 12;
|
|
2966
|
+
break;
|
|
2967
|
+
}
|
|
2968
|
+
_context2.next = 9;
|
|
2969
|
+
return notifiClient.getTargetGroups();
|
|
2970
|
+
case 9:
|
|
2971
|
+
targetGroups = _context2.sent;
|
|
2972
|
+
emailTargets = (_targetGroups$ = targetGroups[0]) === null || _targetGroups$ === void 0 ? void 0 : (_targetGroups$$emailT = _targetGroups$.emailTargets) === null || _targetGroups$$emailT === void 0 ? void 0 : _targetGroups$$emailT[0];
|
|
2973
|
+
if (emailTargets == null || emailTargets.emailAddress == null) {
|
|
2974
|
+
setIsFirstTimeNotifiUser(true);
|
|
2975
|
+
}
|
|
2976
|
+
case 12:
|
|
2977
|
+
case "end":
|
|
2978
|
+
return _context2.stop();
|
|
2979
|
+
}
|
|
2980
|
+
}, _callee2);
|
|
2981
|
+
}));
|
|
2982
|
+
return function checkIsFirstTimeNotifiUser() {
|
|
2983
|
+
return _ref2.apply(this, arguments);
|
|
2984
|
+
};
|
|
2985
|
+
}();
|
|
2986
|
+
checkIsFirstTimeNotifiUser();
|
|
2987
|
+
}, [notifiClient]);
|
|
2988
|
+
return {
|
|
2989
|
+
isFirstTimeNotifiUser: isFirstTimeNotifiUser
|
|
2990
|
+
};
|
|
2991
|
+
};
|
|
2992
|
+
var useDoesChainSupportNotifi = function useDoesChainSupportNotifi(account, chainId) {
|
|
2993
|
+
var _useState5 = useState(false),
|
|
2994
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
2995
|
+
notifiChainSupported = _useState6[0],
|
|
2996
|
+
setNotifiChainSupported = _useState6[1];
|
|
2997
|
+
useEffect(function () {
|
|
2998
|
+
var checkNotifiChainSupported = /*#__PURE__*/function () {
|
|
2999
|
+
var _ref3 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee3() {
|
|
3000
|
+
return regenerator.wrap(function _callee3$(_context3) {
|
|
3001
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
3002
|
+
case 0:
|
|
3003
|
+
if (account != null && chainId != null) {
|
|
3004
|
+
setNotifiChainSupported(doesChainSupportNotifi(chainId, checkIsDev(), account));
|
|
3005
|
+
}
|
|
3006
|
+
case 1:
|
|
3007
|
+
case "end":
|
|
3008
|
+
return _context3.stop();
|
|
3009
|
+
}
|
|
3010
|
+
}, _callee3);
|
|
3011
|
+
}));
|
|
3012
|
+
return function checkNotifiChainSupported() {
|
|
3013
|
+
return _ref3.apply(this, arguments);
|
|
3014
|
+
};
|
|
3015
|
+
}();
|
|
3016
|
+
checkNotifiChainSupported();
|
|
3017
|
+
}, [account, chainId]);
|
|
3018
|
+
return {
|
|
3019
|
+
notifiChainSupported: notifiChainSupported
|
|
3020
|
+
};
|
|
3021
|
+
};
|
|
3022
|
+
|
|
2893
3023
|
var _templateObject$9, _templateObject2$7, _templateObject3$5, _templateObject4$4, _templateObject5$1;
|
|
2894
3024
|
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
3025
|
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 +3041,23 @@ function fetchEventTypes(_x) {
|
|
|
2911
3041
|
return _fetchEventTypes.apply(this, arguments);
|
|
2912
3042
|
}
|
|
2913
3043
|
function _fetchEventTypes() {
|
|
2914
|
-
_fetchEventTypes = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function
|
|
3044
|
+
_fetchEventTypes = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee3(notifiClient) {
|
|
2915
3045
|
var _process$env$REACT_AP, _subscriptionConfig$e;
|
|
2916
3046
|
var subscribedAlerts, subscriptionConfig, eventTypes;
|
|
2917
|
-
return regenerator.wrap(function
|
|
2918
|
-
while (1) switch (
|
|
3047
|
+
return regenerator.wrap(function _callee3$(_context3) {
|
|
3048
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
2919
3049
|
case 0:
|
|
2920
|
-
|
|
3050
|
+
_context3.next = 2;
|
|
2921
3051
|
return notifiClient.getAlerts();
|
|
2922
3052
|
case 2:
|
|
2923
|
-
subscribedAlerts =
|
|
2924
|
-
|
|
3053
|
+
subscribedAlerts = _context3.sent;
|
|
3054
|
+
_context3.next = 5;
|
|
2925
3055
|
return notifiClient.fetchSubscriptionCard({
|
|
2926
3056
|
id: (_process$env$REACT_AP = process.env.REACT_APP_NOTIFI_CONFIG_ID) !== null && _process$env$REACT_AP !== void 0 ? _process$env$REACT_AP : '',
|
|
2927
3057
|
type: 'SUBSCRIPTION_CARD'
|
|
2928
3058
|
});
|
|
2929
3059
|
case 5:
|
|
2930
|
-
subscriptionConfig =
|
|
3060
|
+
subscriptionConfig = _context3.sent;
|
|
2931
3061
|
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
3062
|
var eventTypeId = getIdFromEventType(eventType);
|
|
2933
3063
|
var enabled = false;
|
|
@@ -2942,12 +3072,12 @@ function _fetchEventTypes() {
|
|
|
2942
3072
|
enabled: enabled
|
|
2943
3073
|
});
|
|
2944
3074
|
});
|
|
2945
|
-
return
|
|
3075
|
+
return _context3.abrupt("return", eventTypes);
|
|
2946
3076
|
case 8:
|
|
2947
3077
|
case "end":
|
|
2948
|
-
return
|
|
3078
|
+
return _context3.stop();
|
|
2949
3079
|
}
|
|
2950
|
-
},
|
|
3080
|
+
}, _callee3);
|
|
2951
3081
|
}));
|
|
2952
3082
|
return _fetchEventTypes.apply(this, arguments);
|
|
2953
3083
|
}
|
|
@@ -2960,81 +3090,44 @@ function NotifiSubscriptionModal(_ref) {
|
|
|
2960
3090
|
account = _useWeb3React.account,
|
|
2961
3091
|
chainId = _useWeb3React.chainId,
|
|
2962
3092
|
provider = _useWeb3React.provider;
|
|
2963
|
-
var _useState = useState(),
|
|
3093
|
+
var _useState = useState(false),
|
|
2964
3094
|
_useState2 = _slicedToArray(_useState, 2),
|
|
2965
|
-
|
|
2966
|
-
|
|
3095
|
+
showSuccessScreen = _useState2[0],
|
|
3096
|
+
setShowSuccessScreen = _useState2[1];
|
|
2967
3097
|
var _useState3 = useState(false),
|
|
2968
3098
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
2969
|
-
|
|
2970
|
-
|
|
2971
|
-
var _useState5 = useState(
|
|
3099
|
+
isLoading = _useState4[0],
|
|
3100
|
+
setIsLoading = _useState4[1];
|
|
3101
|
+
var _useState5 = useState(''),
|
|
2972
3102
|
_useState6 = _slicedToArray(_useState5, 2),
|
|
2973
|
-
|
|
2974
|
-
|
|
2975
|
-
var _useState7 = useState(
|
|
3103
|
+
emailAddress = _useState6[0],
|
|
3104
|
+
setEmailAddress = _useState6[1];
|
|
3105
|
+
var _useState7 = useState(),
|
|
2976
3106
|
_useState8 = _slicedToArray(_useState7, 2),
|
|
2977
|
-
|
|
2978
|
-
|
|
2979
|
-
var
|
|
2980
|
-
|
|
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]);
|
|
3107
|
+
emailValid = _useState8[0],
|
|
3108
|
+
setEmailValid = _useState8[1];
|
|
3109
|
+
var _useNotifiClient = useNotifiClient(account, chainId, checkIsDev()),
|
|
3110
|
+
notifiClient = _useNotifiClient.notifiClient;
|
|
3018
3111
|
var signMessage = /*#__PURE__*/function () {
|
|
3019
|
-
var
|
|
3112
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(message) {
|
|
3020
3113
|
var signer, signature;
|
|
3021
|
-
return regenerator.wrap(function
|
|
3022
|
-
while (1) switch (
|
|
3114
|
+
return regenerator.wrap(function _callee$(_context) {
|
|
3115
|
+
while (1) switch (_context.prev = _context.next) {
|
|
3023
3116
|
case 0:
|
|
3024
3117
|
signer = provider.getSigner();
|
|
3025
|
-
|
|
3118
|
+
_context.next = 3;
|
|
3026
3119
|
return signer.signMessage(Buffer.from(message));
|
|
3027
3120
|
case 3:
|
|
3028
|
-
signature =
|
|
3029
|
-
return
|
|
3121
|
+
signature = _context.sent;
|
|
3122
|
+
return _context.abrupt("return", ethers.utils.arrayify(signature));
|
|
3030
3123
|
case 5:
|
|
3031
3124
|
case "end":
|
|
3032
|
-
return
|
|
3125
|
+
return _context.stop();
|
|
3033
3126
|
}
|
|
3034
|
-
},
|
|
3127
|
+
}, _callee);
|
|
3035
3128
|
}));
|
|
3036
3129
|
return function signMessage(_x2) {
|
|
3037
|
-
return
|
|
3130
|
+
return _ref2.apply(this, arguments);
|
|
3038
3131
|
};
|
|
3039
3132
|
}();
|
|
3040
3133
|
var handleEmailAddressChange = function handleEmailAddressChange(event) {
|
|
@@ -3044,38 +3137,38 @@ function NotifiSubscriptionModal(_ref) {
|
|
|
3044
3137
|
setEmailAddress(event.target.value);
|
|
3045
3138
|
};
|
|
3046
3139
|
var logInAndSubscribe = /*#__PURE__*/function () {
|
|
3047
|
-
var
|
|
3140
|
+
var _ref3 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee2() {
|
|
3048
3141
|
var fetchedEventTypes, _iterator, _step, eventType;
|
|
3049
|
-
return regenerator.wrap(function
|
|
3050
|
-
while (1) switch (
|
|
3142
|
+
return regenerator.wrap(function _callee2$(_context2) {
|
|
3143
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
3051
3144
|
case 0:
|
|
3052
3145
|
if (!(notifiClient != null && chainId != null)) {
|
|
3053
|
-
|
|
3146
|
+
_context2.next = 35;
|
|
3054
3147
|
break;
|
|
3055
3148
|
}
|
|
3056
3149
|
setIsLoading(true);
|
|
3057
3150
|
|
|
3058
3151
|
// Ask user to sign a message to authenticate
|
|
3059
|
-
|
|
3060
|
-
|
|
3152
|
+
_context2.prev = 2;
|
|
3153
|
+
_context2.next = 5;
|
|
3061
3154
|
return notifiClient.logIn({
|
|
3062
3155
|
walletBlockchain: getBlockchainConfigFromChain(chainId),
|
|
3063
3156
|
signMessage: signMessage
|
|
3064
3157
|
});
|
|
3065
3158
|
case 5:
|
|
3066
|
-
|
|
3159
|
+
_context2.next = 11;
|
|
3067
3160
|
break;
|
|
3068
3161
|
case 7:
|
|
3069
|
-
|
|
3070
|
-
|
|
3162
|
+
_context2.prev = 7;
|
|
3163
|
+
_context2.t0 = _context2["catch"](2);
|
|
3071
3164
|
setIsLoading(false);
|
|
3072
|
-
return
|
|
3165
|
+
return _context2.abrupt("return");
|
|
3073
3166
|
case 11:
|
|
3074
|
-
|
|
3167
|
+
_context2.next = 13;
|
|
3075
3168
|
return fetchEventTypes(notifiClient);
|
|
3076
3169
|
case 13:
|
|
3077
|
-
fetchedEventTypes =
|
|
3078
|
-
|
|
3170
|
+
fetchedEventTypes = _context2.sent;
|
|
3171
|
+
_context2.next = 16;
|
|
3079
3172
|
return notifiClient.ensureTargetGroup({
|
|
3080
3173
|
name: 'Default',
|
|
3081
3174
|
emailAddress: emailAddress
|
|
@@ -3085,44 +3178,44 @@ function NotifiSubscriptionModal(_ref) {
|
|
|
3085
3178
|
// multiple calls. Notified their team to fix this.
|
|
3086
3179
|
// eslint-disable-next-line no-restricted-syntax
|
|
3087
3180
|
_iterator = _createForOfIteratorHelper(fetchedEventTypes);
|
|
3088
|
-
|
|
3181
|
+
_context2.prev = 17;
|
|
3089
3182
|
_iterator.s();
|
|
3090
3183
|
case 19:
|
|
3091
3184
|
if ((_step = _iterator.n()).done) {
|
|
3092
|
-
|
|
3185
|
+
_context2.next = 25;
|
|
3093
3186
|
break;
|
|
3094
3187
|
}
|
|
3095
3188
|
eventType = _step.value;
|
|
3096
|
-
|
|
3189
|
+
_context2.next = 23;
|
|
3097
3190
|
return notifiClient.ensureAlert({
|
|
3098
3191
|
eventType: eventType,
|
|
3099
3192
|
inputs: {}
|
|
3100
3193
|
});
|
|
3101
3194
|
case 23:
|
|
3102
|
-
|
|
3195
|
+
_context2.next = 19;
|
|
3103
3196
|
break;
|
|
3104
3197
|
case 25:
|
|
3105
|
-
|
|
3198
|
+
_context2.next = 30;
|
|
3106
3199
|
break;
|
|
3107
3200
|
case 27:
|
|
3108
|
-
|
|
3109
|
-
|
|
3110
|
-
_iterator.e(
|
|
3201
|
+
_context2.prev = 27;
|
|
3202
|
+
_context2.t1 = _context2["catch"](17);
|
|
3203
|
+
_iterator.e(_context2.t1);
|
|
3111
3204
|
case 30:
|
|
3112
|
-
|
|
3205
|
+
_context2.prev = 30;
|
|
3113
3206
|
_iterator.f();
|
|
3114
|
-
return
|
|
3207
|
+
return _context2.finish(30);
|
|
3115
3208
|
case 33:
|
|
3116
3209
|
setShowSuccessScreen(true);
|
|
3117
3210
|
setIsLoading(false);
|
|
3118
3211
|
case 35:
|
|
3119
3212
|
case "end":
|
|
3120
|
-
return
|
|
3213
|
+
return _context2.stop();
|
|
3121
3214
|
}
|
|
3122
|
-
},
|
|
3215
|
+
}, _callee2, null, [[2, 7], [17, 27, 30, 33]]);
|
|
3123
3216
|
}));
|
|
3124
3217
|
return function logInAndSubscribe() {
|
|
3125
|
-
return
|
|
3218
|
+
return _ref3.apply(this, arguments);
|
|
3126
3219
|
};
|
|
3127
3220
|
}();
|
|
3128
3221
|
var handleCloseModal = useCallback(function () {
|
|
@@ -3194,101 +3287,6 @@ function Notifications$1(_ref) {
|
|
|
3194
3287
|
});
|
|
3195
3288
|
}
|
|
3196
3289
|
|
|
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
3290
|
function CreditLineBorrow(_ref) {
|
|
3293
3291
|
var poolNameStr = _ref.poolName,
|
|
3294
3292
|
poolTypeStr = _ref.poolType,
|