@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/cjs/index.cjs
CHANGED
|
@@ -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');
|
|
@@ -2929,6 +2929,136 @@ function Success$6(_ref) {
|
|
|
2929
2929
|
});
|
|
2930
2930
|
}
|
|
2931
2931
|
|
|
2932
|
+
var useNotifiClient = function useNotifiClient(account, chainId, isDev) {
|
|
2933
|
+
var _useState = React.useState(null),
|
|
2934
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
2935
|
+
notifiClient = _useState2[0],
|
|
2936
|
+
setNotifiClient = _useState2[1];
|
|
2937
|
+
React.useEffect(function () {
|
|
2938
|
+
var createNotifiClient = /*#__PURE__*/function () {
|
|
2939
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee() {
|
|
2940
|
+
var client;
|
|
2941
|
+
return regenerator.wrap(function _callee$(_context) {
|
|
2942
|
+
while (1) switch (_context.prev = _context.next) {
|
|
2943
|
+
case 0:
|
|
2944
|
+
if (!(account != null && chainId != null)) {
|
|
2945
|
+
_context.next = 5;
|
|
2946
|
+
break;
|
|
2947
|
+
}
|
|
2948
|
+
client = notifiFrontendClient.newFrontendClient({
|
|
2949
|
+
account: {
|
|
2950
|
+
publicKey: account
|
|
2951
|
+
},
|
|
2952
|
+
tenantId: shared.getNotifiDappId(isDev),
|
|
2953
|
+
env: isDev ? 'Development' : 'Production',
|
|
2954
|
+
walletBlockchain: shared.getBlockchainConfigFromChain(chainId)
|
|
2955
|
+
});
|
|
2956
|
+
_context.next = 4;
|
|
2957
|
+
return client.initialize();
|
|
2958
|
+
case 4:
|
|
2959
|
+
setNotifiClient(client);
|
|
2960
|
+
case 5:
|
|
2961
|
+
case "end":
|
|
2962
|
+
return _context.stop();
|
|
2963
|
+
}
|
|
2964
|
+
}, _callee);
|
|
2965
|
+
}));
|
|
2966
|
+
return function createNotifiClient() {
|
|
2967
|
+
return _ref.apply(this, arguments);
|
|
2968
|
+
};
|
|
2969
|
+
}();
|
|
2970
|
+
createNotifiClient();
|
|
2971
|
+
}, [account, chainId, isDev]);
|
|
2972
|
+
return {
|
|
2973
|
+
notifiClient: notifiClient
|
|
2974
|
+
};
|
|
2975
|
+
};
|
|
2976
|
+
var useIsFirstTimeNotifiUser = function useIsFirstTimeNotifiUser(account, chainId) {
|
|
2977
|
+
var _useState3 = React.useState(false),
|
|
2978
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
2979
|
+
isFirstTimeNotifiUser = _useState4[0],
|
|
2980
|
+
setIsFirstTimeNotifiUser = _useState4[1];
|
|
2981
|
+
var _useNotifiClient = useNotifiClient(account, chainId, shared.checkIsDev()),
|
|
2982
|
+
notifiClient = _useNotifiClient.notifiClient;
|
|
2983
|
+
React.useEffect(function () {
|
|
2984
|
+
var checkIsFirstTimeNotifiUser = /*#__PURE__*/function () {
|
|
2985
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee2() {
|
|
2986
|
+
var userState, _targetGroups$, _targetGroups$$emailT, targetGroups, emailTargets;
|
|
2987
|
+
return regenerator.wrap(function _callee2$(_context2) {
|
|
2988
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
2989
|
+
case 0:
|
|
2990
|
+
if (!(notifiClient != null)) {
|
|
2991
|
+
_context2.next = 12;
|
|
2992
|
+
break;
|
|
2993
|
+
}
|
|
2994
|
+
userState = notifiClient.userState; // If the user is not authenticated or expired, they are a first time user
|
|
2995
|
+
if (!(userState == null || userState.status !== 'authenticated' && userState.status !== 'expired')) {
|
|
2996
|
+
_context2.next = 6;
|
|
2997
|
+
break;
|
|
2998
|
+
}
|
|
2999
|
+
setIsFirstTimeNotifiUser(true);
|
|
3000
|
+
_context2.next = 12;
|
|
3001
|
+
break;
|
|
3002
|
+
case 6:
|
|
3003
|
+
if (!(userState.status === 'authenticated')) {
|
|
3004
|
+
_context2.next = 12;
|
|
3005
|
+
break;
|
|
3006
|
+
}
|
|
3007
|
+
_context2.next = 9;
|
|
3008
|
+
return notifiClient.getTargetGroups();
|
|
3009
|
+
case 9:
|
|
3010
|
+
targetGroups = _context2.sent;
|
|
3011
|
+
emailTargets = (_targetGroups$ = targetGroups[0]) === null || _targetGroups$ === void 0 ? void 0 : (_targetGroups$$emailT = _targetGroups$.emailTargets) === null || _targetGroups$$emailT === void 0 ? void 0 : _targetGroups$$emailT[0];
|
|
3012
|
+
if (emailTargets == null || emailTargets.emailAddress == null) {
|
|
3013
|
+
setIsFirstTimeNotifiUser(true);
|
|
3014
|
+
}
|
|
3015
|
+
case 12:
|
|
3016
|
+
case "end":
|
|
3017
|
+
return _context2.stop();
|
|
3018
|
+
}
|
|
3019
|
+
}, _callee2);
|
|
3020
|
+
}));
|
|
3021
|
+
return function checkIsFirstTimeNotifiUser() {
|
|
3022
|
+
return _ref2.apply(this, arguments);
|
|
3023
|
+
};
|
|
3024
|
+
}();
|
|
3025
|
+
checkIsFirstTimeNotifiUser();
|
|
3026
|
+
}, [notifiClient]);
|
|
3027
|
+
return {
|
|
3028
|
+
isFirstTimeNotifiUser: isFirstTimeNotifiUser
|
|
3029
|
+
};
|
|
3030
|
+
};
|
|
3031
|
+
var useDoesChainSupportNotifi = function useDoesChainSupportNotifi(account, chainId) {
|
|
3032
|
+
var _useState5 = React.useState(false),
|
|
3033
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
3034
|
+
notifiChainSupported = _useState6[0],
|
|
3035
|
+
setNotifiChainSupported = _useState6[1];
|
|
3036
|
+
React.useEffect(function () {
|
|
3037
|
+
var checkNotifiChainSupported = /*#__PURE__*/function () {
|
|
3038
|
+
var _ref3 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee3() {
|
|
3039
|
+
return regenerator.wrap(function _callee3$(_context3) {
|
|
3040
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
3041
|
+
case 0:
|
|
3042
|
+
if (account != null && chainId != null) {
|
|
3043
|
+
setNotifiChainSupported(shared.doesChainSupportNotifi(chainId, shared.checkIsDev(), account));
|
|
3044
|
+
}
|
|
3045
|
+
case 1:
|
|
3046
|
+
case "end":
|
|
3047
|
+
return _context3.stop();
|
|
3048
|
+
}
|
|
3049
|
+
}, _callee3);
|
|
3050
|
+
}));
|
|
3051
|
+
return function checkNotifiChainSupported() {
|
|
3052
|
+
return _ref3.apply(this, arguments);
|
|
3053
|
+
};
|
|
3054
|
+
}();
|
|
3055
|
+
checkNotifiChainSupported();
|
|
3056
|
+
}, [account, chainId]);
|
|
3057
|
+
return {
|
|
3058
|
+
notifiChainSupported: notifiChainSupported
|
|
3059
|
+
};
|
|
3060
|
+
};
|
|
3061
|
+
|
|
2932
3062
|
var _templateObject$9, _templateObject2$7, _templateObject3$5, _templateObject4$4, _templateObject5$1;
|
|
2933
3063
|
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
3064
|
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 +3080,23 @@ function fetchEventTypes(_x) {
|
|
|
2950
3080
|
return _fetchEventTypes.apply(this, arguments);
|
|
2951
3081
|
}
|
|
2952
3082
|
function _fetchEventTypes() {
|
|
2953
|
-
_fetchEventTypes = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function
|
|
3083
|
+
_fetchEventTypes = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee3(notifiClient) {
|
|
2954
3084
|
var _process$env$REACT_AP, _subscriptionConfig$e;
|
|
2955
3085
|
var subscribedAlerts, subscriptionConfig, eventTypes;
|
|
2956
|
-
return regenerator.wrap(function
|
|
2957
|
-
while (1) switch (
|
|
3086
|
+
return regenerator.wrap(function _callee3$(_context3) {
|
|
3087
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
2958
3088
|
case 0:
|
|
2959
|
-
|
|
3089
|
+
_context3.next = 2;
|
|
2960
3090
|
return notifiClient.getAlerts();
|
|
2961
3091
|
case 2:
|
|
2962
|
-
subscribedAlerts =
|
|
2963
|
-
|
|
3092
|
+
subscribedAlerts = _context3.sent;
|
|
3093
|
+
_context3.next = 5;
|
|
2964
3094
|
return notifiClient.fetchSubscriptionCard({
|
|
2965
3095
|
id: (_process$env$REACT_AP = process.env.REACT_APP_NOTIFI_CONFIG_ID) !== null && _process$env$REACT_AP !== void 0 ? _process$env$REACT_AP : '',
|
|
2966
3096
|
type: 'SUBSCRIPTION_CARD'
|
|
2967
3097
|
});
|
|
2968
3098
|
case 5:
|
|
2969
|
-
subscriptionConfig =
|
|
3099
|
+
subscriptionConfig = _context3.sent;
|
|
2970
3100
|
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
3101
|
var eventTypeId = getIdFromEventType(eventType);
|
|
2972
3102
|
var enabled = false;
|
|
@@ -2981,12 +3111,12 @@ function _fetchEventTypes() {
|
|
|
2981
3111
|
enabled: enabled
|
|
2982
3112
|
});
|
|
2983
3113
|
});
|
|
2984
|
-
return
|
|
3114
|
+
return _context3.abrupt("return", eventTypes);
|
|
2985
3115
|
case 8:
|
|
2986
3116
|
case "end":
|
|
2987
|
-
return
|
|
3117
|
+
return _context3.stop();
|
|
2988
3118
|
}
|
|
2989
|
-
},
|
|
3119
|
+
}, _callee3);
|
|
2990
3120
|
}));
|
|
2991
3121
|
return _fetchEventTypes.apply(this, arguments);
|
|
2992
3122
|
}
|
|
@@ -2999,81 +3129,44 @@ function NotifiSubscriptionModal(_ref) {
|
|
|
2999
3129
|
account = _useWeb3React.account,
|
|
3000
3130
|
chainId = _useWeb3React.chainId,
|
|
3001
3131
|
provider = _useWeb3React.provider;
|
|
3002
|
-
var _useState = React.useState(),
|
|
3132
|
+
var _useState = React.useState(false),
|
|
3003
3133
|
_useState2 = _slicedToArray(_useState, 2),
|
|
3004
|
-
|
|
3005
|
-
|
|
3134
|
+
showSuccessScreen = _useState2[0],
|
|
3135
|
+
setShowSuccessScreen = _useState2[1];
|
|
3006
3136
|
var _useState3 = React.useState(false),
|
|
3007
3137
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
3008
|
-
|
|
3009
|
-
|
|
3010
|
-
var _useState5 = React.useState(
|
|
3138
|
+
isLoading = _useState4[0],
|
|
3139
|
+
setIsLoading = _useState4[1];
|
|
3140
|
+
var _useState5 = React.useState(''),
|
|
3011
3141
|
_useState6 = _slicedToArray(_useState5, 2),
|
|
3012
|
-
|
|
3013
|
-
|
|
3014
|
-
var _useState7 = React.useState(
|
|
3142
|
+
emailAddress = _useState6[0],
|
|
3143
|
+
setEmailAddress = _useState6[1];
|
|
3144
|
+
var _useState7 = React.useState(),
|
|
3015
3145
|
_useState8 = _slicedToArray(_useState7, 2),
|
|
3016
|
-
|
|
3017
|
-
|
|
3018
|
-
var
|
|
3019
|
-
|
|
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]);
|
|
3146
|
+
emailValid = _useState8[0],
|
|
3147
|
+
setEmailValid = _useState8[1];
|
|
3148
|
+
var _useNotifiClient = useNotifiClient(account, chainId, shared.checkIsDev()),
|
|
3149
|
+
notifiClient = _useNotifiClient.notifiClient;
|
|
3057
3150
|
var signMessage = /*#__PURE__*/function () {
|
|
3058
|
-
var
|
|
3151
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(message) {
|
|
3059
3152
|
var signer, signature;
|
|
3060
|
-
return regenerator.wrap(function
|
|
3061
|
-
while (1) switch (
|
|
3153
|
+
return regenerator.wrap(function _callee$(_context) {
|
|
3154
|
+
while (1) switch (_context.prev = _context.next) {
|
|
3062
3155
|
case 0:
|
|
3063
3156
|
signer = provider.getSigner();
|
|
3064
|
-
|
|
3157
|
+
_context.next = 3;
|
|
3065
3158
|
return signer.signMessage(Buffer.from(message));
|
|
3066
3159
|
case 3:
|
|
3067
|
-
signature =
|
|
3068
|
-
return
|
|
3160
|
+
signature = _context.sent;
|
|
3161
|
+
return _context.abrupt("return", ethers.ethers.utils.arrayify(signature));
|
|
3069
3162
|
case 5:
|
|
3070
3163
|
case "end":
|
|
3071
|
-
return
|
|
3164
|
+
return _context.stop();
|
|
3072
3165
|
}
|
|
3073
|
-
},
|
|
3166
|
+
}, _callee);
|
|
3074
3167
|
}));
|
|
3075
3168
|
return function signMessage(_x2) {
|
|
3076
|
-
return
|
|
3169
|
+
return _ref2.apply(this, arguments);
|
|
3077
3170
|
};
|
|
3078
3171
|
}();
|
|
3079
3172
|
var handleEmailAddressChange = function handleEmailAddressChange(event) {
|
|
@@ -3083,38 +3176,38 @@ function NotifiSubscriptionModal(_ref) {
|
|
|
3083
3176
|
setEmailAddress(event.target.value);
|
|
3084
3177
|
};
|
|
3085
3178
|
var logInAndSubscribe = /*#__PURE__*/function () {
|
|
3086
|
-
var
|
|
3179
|
+
var _ref3 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee2() {
|
|
3087
3180
|
var fetchedEventTypes, _iterator, _step, eventType;
|
|
3088
|
-
return regenerator.wrap(function
|
|
3089
|
-
while (1) switch (
|
|
3181
|
+
return regenerator.wrap(function _callee2$(_context2) {
|
|
3182
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
3090
3183
|
case 0:
|
|
3091
3184
|
if (!(notifiClient != null && chainId != null)) {
|
|
3092
|
-
|
|
3185
|
+
_context2.next = 35;
|
|
3093
3186
|
break;
|
|
3094
3187
|
}
|
|
3095
3188
|
setIsLoading(true);
|
|
3096
3189
|
|
|
3097
3190
|
// Ask user to sign a message to authenticate
|
|
3098
|
-
|
|
3099
|
-
|
|
3191
|
+
_context2.prev = 2;
|
|
3192
|
+
_context2.next = 5;
|
|
3100
3193
|
return notifiClient.logIn({
|
|
3101
3194
|
walletBlockchain: shared.getBlockchainConfigFromChain(chainId),
|
|
3102
3195
|
signMessage: signMessage
|
|
3103
3196
|
});
|
|
3104
3197
|
case 5:
|
|
3105
|
-
|
|
3198
|
+
_context2.next = 11;
|
|
3106
3199
|
break;
|
|
3107
3200
|
case 7:
|
|
3108
|
-
|
|
3109
|
-
|
|
3201
|
+
_context2.prev = 7;
|
|
3202
|
+
_context2.t0 = _context2["catch"](2);
|
|
3110
3203
|
setIsLoading(false);
|
|
3111
|
-
return
|
|
3204
|
+
return _context2.abrupt("return");
|
|
3112
3205
|
case 11:
|
|
3113
|
-
|
|
3206
|
+
_context2.next = 13;
|
|
3114
3207
|
return fetchEventTypes(notifiClient);
|
|
3115
3208
|
case 13:
|
|
3116
|
-
fetchedEventTypes =
|
|
3117
|
-
|
|
3209
|
+
fetchedEventTypes = _context2.sent;
|
|
3210
|
+
_context2.next = 16;
|
|
3118
3211
|
return notifiClient.ensureTargetGroup({
|
|
3119
3212
|
name: 'Default',
|
|
3120
3213
|
emailAddress: emailAddress
|
|
@@ -3124,44 +3217,44 @@ function NotifiSubscriptionModal(_ref) {
|
|
|
3124
3217
|
// multiple calls. Notified their team to fix this.
|
|
3125
3218
|
// eslint-disable-next-line no-restricted-syntax
|
|
3126
3219
|
_iterator = _createForOfIteratorHelper(fetchedEventTypes);
|
|
3127
|
-
|
|
3220
|
+
_context2.prev = 17;
|
|
3128
3221
|
_iterator.s();
|
|
3129
3222
|
case 19:
|
|
3130
3223
|
if ((_step = _iterator.n()).done) {
|
|
3131
|
-
|
|
3224
|
+
_context2.next = 25;
|
|
3132
3225
|
break;
|
|
3133
3226
|
}
|
|
3134
3227
|
eventType = _step.value;
|
|
3135
|
-
|
|
3228
|
+
_context2.next = 23;
|
|
3136
3229
|
return notifiClient.ensureAlert({
|
|
3137
3230
|
eventType: eventType,
|
|
3138
3231
|
inputs: {}
|
|
3139
3232
|
});
|
|
3140
3233
|
case 23:
|
|
3141
|
-
|
|
3234
|
+
_context2.next = 19;
|
|
3142
3235
|
break;
|
|
3143
3236
|
case 25:
|
|
3144
|
-
|
|
3237
|
+
_context2.next = 30;
|
|
3145
3238
|
break;
|
|
3146
3239
|
case 27:
|
|
3147
|
-
|
|
3148
|
-
|
|
3149
|
-
_iterator.e(
|
|
3240
|
+
_context2.prev = 27;
|
|
3241
|
+
_context2.t1 = _context2["catch"](17);
|
|
3242
|
+
_iterator.e(_context2.t1);
|
|
3150
3243
|
case 30:
|
|
3151
|
-
|
|
3244
|
+
_context2.prev = 30;
|
|
3152
3245
|
_iterator.f();
|
|
3153
|
-
return
|
|
3246
|
+
return _context2.finish(30);
|
|
3154
3247
|
case 33:
|
|
3155
3248
|
setShowSuccessScreen(true);
|
|
3156
3249
|
setIsLoading(false);
|
|
3157
3250
|
case 35:
|
|
3158
3251
|
case "end":
|
|
3159
|
-
return
|
|
3252
|
+
return _context2.stop();
|
|
3160
3253
|
}
|
|
3161
|
-
},
|
|
3254
|
+
}, _callee2, null, [[2, 7], [17, 27, 30, 33]]);
|
|
3162
3255
|
}));
|
|
3163
3256
|
return function logInAndSubscribe() {
|
|
3164
|
-
return
|
|
3257
|
+
return _ref3.apply(this, arguments);
|
|
3165
3258
|
};
|
|
3166
3259
|
}();
|
|
3167
3260
|
var handleCloseModal = React.useCallback(function () {
|
|
@@ -3233,101 +3326,6 @@ function Notifications$1(_ref) {
|
|
|
3233
3326
|
});
|
|
3234
3327
|
}
|
|
3235
3328
|
|
|
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
3329
|
function CreditLineBorrow(_ref) {
|
|
3332
3330
|
var poolNameStr = _ref.poolName,
|
|
3333
3331
|
poolTypeStr = _ref.poolType,
|