@dynamic-labs/sdk-react-core 0.16.8 → 0.16.9-RC.0
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/CHANGELOG.md +13 -0
- package/package.cjs +1 -1
- package/package.js +1 -1
- package/package.json +4 -4
- package/src/lib/context/DynamicContext/DynamicContext.cjs +17 -5
- package/src/lib/context/DynamicContext/DynamicContext.d.ts +1 -0
- package/src/lib/context/DynamicContext/DynamicContext.js +17 -5
- package/src/lib/context/DynamicContext/useDynamicContext.cjs +2 -1
- package/src/lib/context/DynamicContext/useDynamicContext.d.ts +1 -1
- package/src/lib/context/DynamicContext/useDynamicContext.js +2 -1
- package/src/lib/shared/utils/hooks/useGlobalLoading/index.d.ts +1 -0
- package/src/lib/shared/utils/hooks/useGlobalLoading/useGlobalLoading.cjs +35 -0
- package/src/lib/shared/utils/hooks/useGlobalLoading/useGlobalLoading.d.ts +17 -0
- package/src/lib/shared/utils/hooks/useGlobalLoading/useGlobalLoading.js +31 -0
- package/src/lib/utils/hooks/useConnectWallet/useConnectWallet.d.ts +1 -2
- package/src/lib/utils/hooks/useUserUpdateRequest/useUserUpdateRequest.cjs +17 -19
- package/src/lib/utils/hooks/useUserUpdateRequest/useUserUpdateRequest.d.ts +8 -6
- package/src/lib/utils/hooks/useUserUpdateRequest/useUserUpdateRequest.js +17 -19
- package/src/lib/utils/hooks/useVerifyWallet/useVerifyWallet.cjs +26 -24
- package/src/lib/utils/hooks/useVerifyWallet/useVerifyWallet.d.ts +1 -1
- package/src/lib/utils/hooks/useVerifyWallet/useVerifyWallet.js +26 -24
- package/src/lib/views/CollectUserDataView/UserDataForm/UserDataForm.cjs +1 -2
- package/src/lib/views/CollectUserDataView/UserDataForm/UserDataForm.js +1 -2
- package/src/lib/views/EmailVerification/EmailVerification.cjs +1 -1
- package/src/lib/views/EmailVerification/EmailVerification.js +1 -1
- package/src/lib/views/NetworkNotSupported/NetworkNotSupported.cjs +11 -3
- package/src/lib/views/NetworkNotSupported/NetworkNotSupported.js +11 -3
- package/src/lib/views/NetworkNotSupportedSwitchManual/NetworkNotSupportedSwitchManual.cjs +10 -5
- package/src/lib/views/NetworkNotSupportedSwitchManual/NetworkNotSupportedSwitchManual.js +10 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,17 @@
|
|
|
1
1
|
|
|
2
|
+
### [0.16.9-RC.0](https://github.com/dynamic-labs/DynamicAuth/compare/v0.16.8...v0.16.9-RC.0) (2023-04-26)
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
### Features
|
|
6
|
+
|
|
7
|
+
* **DYN-2092:** add and expose global loading state ([#1962](https://github.com/dynamic-labs/DynamicAuth/issues/1962)) ([533d6f8](https://github.com/dynamic-labs/DynamicAuth/commit/533d6f8c94cd4cfdc2d20810bfc2b0a95f751502))
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
### Bug Fixes
|
|
11
|
+
|
|
12
|
+
* call authSucces in missing places ([#1961](https://github.com/dynamic-labs/DynamicAuth/issues/1961)) ([c3c1559](https://github.com/dynamic-labs/DynamicAuth/commit/c3c155912066fd4cfcf1c399def233b71c09af65)), closes [#1963](https://github.com/dynamic-labs/DynamicAuth/issues/1963)
|
|
13
|
+
* revert trigger onAuthSuccess on additional flows ([#1953](https://github.com/dynamic-labs/DynamicAuth/issues/1953)) ([#1960](https://github.com/dynamic-labs/DynamicAuth/issues/1960)) ([96cfb38](https://github.com/dynamic-labs/DynamicAuth/commit/96cfb3829314e931a79dfc2fe06469bdd291fd18))
|
|
14
|
+
|
|
2
15
|
### [0.16.8](https://github.com/dynamic-labs/DynamicAuth/compare/v0.16.7...v0.16.8) (2023-04-25)
|
|
3
16
|
|
|
4
17
|
|
package/package.cjs
CHANGED
package/package.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dynamic-labs/sdk-react-core",
|
|
3
|
-
"version": "0.16.
|
|
3
|
+
"version": "0.16.9-RC.0",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/dynamic-labs/DynamicAuth.git",
|
|
@@ -17,9 +17,9 @@
|
|
|
17
17
|
"formik": "^2.2.9",
|
|
18
18
|
"qrcode": "1.5.1",
|
|
19
19
|
"ethers": "^5.7.2",
|
|
20
|
-
"@dynamic-labs/logger": "0.16.
|
|
21
|
-
"@dynamic-labs/multi-wallet": "0.16.
|
|
22
|
-
"@dynamic-labs/wallet-connector-core": "0.16.
|
|
20
|
+
"@dynamic-labs/logger": "0.16.9-RC.0",
|
|
21
|
+
"@dynamic-labs/multi-wallet": "0.16.9-RC.0",
|
|
22
|
+
"@dynamic-labs/wallet-connector-core": "0.16.9-RC.0"
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
25
|
"semver": "^7.3.8"
|
|
@@ -53,6 +53,7 @@ require('../../components/Transition/SlideInUpTransition/SlideInUpTransition.cjs
|
|
|
53
53
|
require('../../components/Transition/OpacityTransition/OpacityTransition.cjs');
|
|
54
54
|
require('../../components/ShadowDOM/ShadowDOM.cjs');
|
|
55
55
|
require('../../components/IconButton/IconButton.cjs');
|
|
56
|
+
var useGlobalLoading = require('../../shared/utils/hooks/useGlobalLoading/useGlobalLoading.cjs');
|
|
56
57
|
var helpers = require('./helpers.cjs');
|
|
57
58
|
var validators = require('./validators.cjs');
|
|
58
59
|
var useCustomerCallbacks = require('./useCustomerCallbacks/useCustomerCallbacks.cjs');
|
|
@@ -105,7 +106,7 @@ const DynamicContextProvider = ({ settings: { accessDeniedMessagePrimary, access
|
|
|
105
106
|
walletUiUtils,
|
|
106
107
|
});
|
|
107
108
|
const [authMode, setAuthMode] = useLocalStorage.useLocalStorage(localStorage$1.AUTH_MODE, initialAuthenticationMode);
|
|
108
|
-
const { connectWallet, removeConnectedInfo, connectedWallet, setConnectedWallet, connectWalletByAddressAndChain, } = useConnectWallet.useConnectWallet(wallets, authMode, environmentId, enableVisitTrackingOnConnectOnly);
|
|
109
|
+
const { connectWallet, removeConnectedInfo, connectedInfo, connectedWallet, setConnectedWallet, connectWalletByAddressAndChain, } = useConnectWallet.useConnectWallet(wallets, authMode, environmentId, enableVisitTrackingOnConnectOnly);
|
|
109
110
|
const [selectedWalletConnector, setSelectedWalletConnector] = React.useState(null);
|
|
110
111
|
const removeAuthTokenAndUser = React.useCallback(() => {
|
|
111
112
|
localStorage.removeItem(localStorage$1.AUTH_TOKEN);
|
|
@@ -119,6 +120,14 @@ const DynamicContextProvider = ({ settings: { accessDeniedMessagePrimary, access
|
|
|
119
120
|
setQrcodeUri,
|
|
120
121
|
wallets,
|
|
121
122
|
});
|
|
123
|
+
const { sdkHasLoaded, setSdkHasLoaded } = useGlobalLoading.useGlobalLoading({
|
|
124
|
+
authMode,
|
|
125
|
+
connectedInfo,
|
|
126
|
+
connectedWallet,
|
|
127
|
+
primaryWallet,
|
|
128
|
+
projectSettings,
|
|
129
|
+
user,
|
|
130
|
+
});
|
|
122
131
|
const walletForUserFacingContext = authMode === 'connect-and-sign' || user ? primaryWallet : connectedWallet;
|
|
123
132
|
useSyncPrimaryWallet.useSyncPrimaryWallet({
|
|
124
133
|
multiWalletWidgetState,
|
|
@@ -291,6 +300,7 @@ const DynamicContextProvider = ({ settings: { accessDeniedMessagePrimary, access
|
|
|
291
300
|
projectSettings,
|
|
292
301
|
qrcodeUri,
|
|
293
302
|
rpcProviders,
|
|
303
|
+
sdkHasLoaded,
|
|
294
304
|
secondaryWallets,
|
|
295
305
|
selectedWalletConnector,
|
|
296
306
|
setAuthMode,
|
|
@@ -306,6 +316,7 @@ const DynamicContextProvider = ({ settings: { accessDeniedMessagePrimary, access
|
|
|
306
316
|
setPrimaryWallet,
|
|
307
317
|
setPrimaryWalletId,
|
|
308
318
|
setQrcodeUri,
|
|
319
|
+
setSdkHasLoaded,
|
|
309
320
|
setSelectedWalletConnector,
|
|
310
321
|
setShowAuthFlow,
|
|
311
322
|
setShowDynamicUserProfile,
|
|
@@ -334,9 +345,7 @@ const DynamicContextProvider = ({ settings: { accessDeniedMessagePrimary, access
|
|
|
334
345
|
accessDeniedMessagePrimary,
|
|
335
346
|
accessDeniedMessageSecondary,
|
|
336
347
|
accountSwitchState,
|
|
337
|
-
appLogo,
|
|
338
348
|
appLogoUrl,
|
|
339
|
-
displayName,
|
|
340
349
|
appName,
|
|
341
350
|
authMode,
|
|
342
351
|
authorizationViewDisplayOrder,
|
|
@@ -345,20 +354,20 @@ const DynamicContextProvider = ({ settings: { accessDeniedMessagePrimary, access
|
|
|
345
354
|
computeConnectedStateForWallets,
|
|
346
355
|
connectWallet,
|
|
347
356
|
connectedWallet,
|
|
348
|
-
defaultNumberOfWalletsToShow,
|
|
349
357
|
primaryWallet,
|
|
350
358
|
secondaryWallets,
|
|
351
359
|
consumeNonce,
|
|
352
360
|
cssOverrides,
|
|
353
361
|
debugError,
|
|
354
362
|
onboardingOnlyJwt,
|
|
363
|
+
defaultNumberOfWalletsToShow,
|
|
355
364
|
desktopUri,
|
|
356
365
|
displayTermsOfService,
|
|
357
366
|
environmentId,
|
|
358
367
|
eventsCallbacks,
|
|
359
368
|
handleLogOut,
|
|
360
369
|
handleUnlinkWallet,
|
|
361
|
-
|
|
370
|
+
isAuthenticated,
|
|
362
371
|
isProjectSettingsLoading,
|
|
363
372
|
isSingleWalletAccount,
|
|
364
373
|
isVerifying,
|
|
@@ -380,6 +389,7 @@ const DynamicContextProvider = ({ settings: { accessDeniedMessagePrimary, access
|
|
|
380
389
|
projectSettings,
|
|
381
390
|
qrcodeUri,
|
|
382
391
|
rpcProviders,
|
|
392
|
+
sdkHasLoaded,
|
|
383
393
|
selectedWalletConnector,
|
|
384
394
|
setAuthMode,
|
|
385
395
|
setAuthorizationViewDisplayOrder,
|
|
@@ -389,6 +399,7 @@ const DynamicContextProvider = ({ settings: { accessDeniedMessagePrimary, access
|
|
|
389
399
|
setNetwork,
|
|
390
400
|
setPrimaryWallet,
|
|
391
401
|
setPrimaryWalletId,
|
|
402
|
+
setSdkHasLoaded,
|
|
392
403
|
setShowQrcodeModal,
|
|
393
404
|
setUser,
|
|
394
405
|
shadowDOMEnabled,
|
|
@@ -403,6 +414,7 @@ const DynamicContextProvider = ({ settings: { accessDeniedMessagePrimary, access
|
|
|
403
414
|
termsOfServiceUrl,
|
|
404
415
|
theme,
|
|
405
416
|
toolkitEnabled,
|
|
417
|
+
user,
|
|
406
418
|
vendorCredentials,
|
|
407
419
|
walletUiUtils,
|
|
408
420
|
wallets,
|
|
@@ -56,6 +56,7 @@ export interface IDynamicContext {
|
|
|
56
56
|
projectSettings: ProjectSettings | undefined;
|
|
57
57
|
qrcodeUri: string;
|
|
58
58
|
rpcProviders: DynamicRPCProviders;
|
|
59
|
+
sdkHasLoaded: boolean;
|
|
59
60
|
secondaryWallets: Wallet[];
|
|
60
61
|
selectedWalletConnector: WalletConnector | null;
|
|
61
62
|
setAuthMode: Dispatch<SetStateAction<AuthModeType>>;
|
|
@@ -49,6 +49,7 @@ import '../../components/Transition/SlideInUpTransition/SlideInUpTransition.js';
|
|
|
49
49
|
import '../../components/Transition/OpacityTransition/OpacityTransition.js';
|
|
50
50
|
import '../../components/ShadowDOM/ShadowDOM.js';
|
|
51
51
|
import '../../components/IconButton/IconButton.js';
|
|
52
|
+
import { useGlobalLoading } from '../../shared/utils/hooks/useGlobalLoading/useGlobalLoading.js';
|
|
52
53
|
import { initExpirationTime } from './helpers.js';
|
|
53
54
|
import { validateAuthUser } from './validators.js';
|
|
54
55
|
import { useCustomerCallbacks } from './useCustomerCallbacks/useCustomerCallbacks.js';
|
|
@@ -101,7 +102,7 @@ const DynamicContextProvider = ({ settings: { accessDeniedMessagePrimary, access
|
|
|
101
102
|
walletUiUtils,
|
|
102
103
|
});
|
|
103
104
|
const [authMode, setAuthMode] = useLocalStorage(AUTH_MODE, initialAuthenticationMode);
|
|
104
|
-
const { connectWallet, removeConnectedInfo, connectedWallet, setConnectedWallet, connectWalletByAddressAndChain, } = useConnectWallet(wallets, authMode, environmentId, enableVisitTrackingOnConnectOnly);
|
|
105
|
+
const { connectWallet, removeConnectedInfo, connectedInfo, connectedWallet, setConnectedWallet, connectWalletByAddressAndChain, } = useConnectWallet(wallets, authMode, environmentId, enableVisitTrackingOnConnectOnly);
|
|
105
106
|
const [selectedWalletConnector, setSelectedWalletConnector] = useState(null);
|
|
106
107
|
const removeAuthTokenAndUser = useCallback(() => {
|
|
107
108
|
localStorage.removeItem(AUTH_TOKEN);
|
|
@@ -115,6 +116,14 @@ const DynamicContextProvider = ({ settings: { accessDeniedMessagePrimary, access
|
|
|
115
116
|
setQrcodeUri,
|
|
116
117
|
wallets,
|
|
117
118
|
});
|
|
119
|
+
const { sdkHasLoaded, setSdkHasLoaded } = useGlobalLoading({
|
|
120
|
+
authMode,
|
|
121
|
+
connectedInfo,
|
|
122
|
+
connectedWallet,
|
|
123
|
+
primaryWallet,
|
|
124
|
+
projectSettings,
|
|
125
|
+
user,
|
|
126
|
+
});
|
|
118
127
|
const walletForUserFacingContext = authMode === 'connect-and-sign' || user ? primaryWallet : connectedWallet;
|
|
119
128
|
useSyncPrimaryWallet({
|
|
120
129
|
multiWalletWidgetState,
|
|
@@ -287,6 +296,7 @@ const DynamicContextProvider = ({ settings: { accessDeniedMessagePrimary, access
|
|
|
287
296
|
projectSettings,
|
|
288
297
|
qrcodeUri,
|
|
289
298
|
rpcProviders,
|
|
299
|
+
sdkHasLoaded,
|
|
290
300
|
secondaryWallets,
|
|
291
301
|
selectedWalletConnector,
|
|
292
302
|
setAuthMode,
|
|
@@ -302,6 +312,7 @@ const DynamicContextProvider = ({ settings: { accessDeniedMessagePrimary, access
|
|
|
302
312
|
setPrimaryWallet,
|
|
303
313
|
setPrimaryWalletId,
|
|
304
314
|
setQrcodeUri,
|
|
315
|
+
setSdkHasLoaded,
|
|
305
316
|
setSelectedWalletConnector,
|
|
306
317
|
setShowAuthFlow,
|
|
307
318
|
setShowDynamicUserProfile,
|
|
@@ -330,9 +341,7 @@ const DynamicContextProvider = ({ settings: { accessDeniedMessagePrimary, access
|
|
|
330
341
|
accessDeniedMessagePrimary,
|
|
331
342
|
accessDeniedMessageSecondary,
|
|
332
343
|
accountSwitchState,
|
|
333
|
-
appLogo,
|
|
334
344
|
appLogoUrl,
|
|
335
|
-
displayName,
|
|
336
345
|
appName,
|
|
337
346
|
authMode,
|
|
338
347
|
authorizationViewDisplayOrder,
|
|
@@ -341,20 +350,20 @@ const DynamicContextProvider = ({ settings: { accessDeniedMessagePrimary, access
|
|
|
341
350
|
computeConnectedStateForWallets,
|
|
342
351
|
connectWallet,
|
|
343
352
|
connectedWallet,
|
|
344
|
-
defaultNumberOfWalletsToShow,
|
|
345
353
|
primaryWallet,
|
|
346
354
|
secondaryWallets,
|
|
347
355
|
consumeNonce,
|
|
348
356
|
cssOverrides,
|
|
349
357
|
debugError,
|
|
350
358
|
onboardingOnlyJwt,
|
|
359
|
+
defaultNumberOfWalletsToShow,
|
|
351
360
|
desktopUri,
|
|
352
361
|
displayTermsOfService,
|
|
353
362
|
environmentId,
|
|
354
363
|
eventsCallbacks,
|
|
355
364
|
handleLogOut,
|
|
356
365
|
handleUnlinkWallet,
|
|
357
|
-
|
|
366
|
+
isAuthenticated,
|
|
358
367
|
isProjectSettingsLoading,
|
|
359
368
|
isSingleWalletAccount,
|
|
360
369
|
isVerifying,
|
|
@@ -376,6 +385,7 @@ const DynamicContextProvider = ({ settings: { accessDeniedMessagePrimary, access
|
|
|
376
385
|
projectSettings,
|
|
377
386
|
qrcodeUri,
|
|
378
387
|
rpcProviders,
|
|
388
|
+
sdkHasLoaded,
|
|
379
389
|
selectedWalletConnector,
|
|
380
390
|
setAuthMode,
|
|
381
391
|
setAuthorizationViewDisplayOrder,
|
|
@@ -385,6 +395,7 @@ const DynamicContextProvider = ({ settings: { accessDeniedMessagePrimary, access
|
|
|
385
395
|
setNetwork,
|
|
386
396
|
setPrimaryWallet,
|
|
387
397
|
setPrimaryWalletId,
|
|
398
|
+
setSdkHasLoaded,
|
|
388
399
|
setShowQrcodeModal,
|
|
389
400
|
setUser,
|
|
390
401
|
shadowDOMEnabled,
|
|
@@ -399,6 +410,7 @@ const DynamicContextProvider = ({ settings: { accessDeniedMessagePrimary, access
|
|
|
399
410
|
termsOfServiceUrl,
|
|
400
411
|
theme,
|
|
401
412
|
toolkitEnabled,
|
|
413
|
+
user,
|
|
402
414
|
vendorCredentials,
|
|
403
415
|
walletUiUtils,
|
|
404
416
|
wallets,
|
|
@@ -11,7 +11,7 @@ const useDynamicContext = () => {
|
|
|
11
11
|
if (context === undefined) {
|
|
12
12
|
throw new Error('useDynamicContext must be used within a DynamicContextProvider');
|
|
13
13
|
}
|
|
14
|
-
const { accountSwitchState, awaitingSignatureState, authMode, authToken, connectedWallets, handleLogOut, handleUnlinkWallet, isAuthenticated, loadingNetwork, multiWalletWidgetState, network, networkConfigurations, primaryWallet, qrcodeUri, rpcProviders, secondaryWallets, setShowAuthFlow, setNetwork, showAuthFlow, showQrcodeModal, setMultiWalletWidgetState, setShowQrcodeModal, setPrimaryWallet, setShowDynamicUserProfile, user, walletConnector, wallets, shadowDOMEnabled, } = context;
|
|
14
|
+
const { accountSwitchState, awaitingSignatureState, authMode, authToken, connectedWallets, handleLogOut, handleUnlinkWallet, isAuthenticated, loadingNetwork, multiWalletWidgetState, network, networkConfigurations, primaryWallet, qrcodeUri, rpcProviders, sdkHasLoaded, secondaryWallets, setShowAuthFlow, setNetwork, showAuthFlow, showQrcodeModal, setMultiWalletWidgetState, setShowQrcodeModal, setPrimaryWallet, setShowDynamicUserProfile, user, walletConnector, wallets, shadowDOMEnabled, } = context;
|
|
15
15
|
return {
|
|
16
16
|
accountSwitchState,
|
|
17
17
|
authMode,
|
|
@@ -28,6 +28,7 @@ const useDynamicContext = () => {
|
|
|
28
28
|
primaryWallet,
|
|
29
29
|
qrcodeUri,
|
|
30
30
|
rpcProviders,
|
|
31
|
+
sdkHasLoaded,
|
|
31
32
|
secondaryWallets,
|
|
32
33
|
setMultiWalletWidgetState,
|
|
33
34
|
setNetwork,
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { IDynamicContext } from './DynamicContext';
|
|
2
|
-
export type UseDynamicContext = Pick<IDynamicContext, 'accountSwitchState' | 'authMode' | 'authToken' | 'awaitingSignatureState' | 'connectedWallets' | 'handleLogOut' | 'handleUnlinkWallet' | 'isAuthenticated' | 'loadingNetwork' | 'multiWalletWidgetState' | 'network' | 'networkConfigurations' | 'primaryWallet' | 'qrcodeUri' | 'rpcProviders' | 'secondaryWallets' | 'setMultiWalletWidgetState' | 'setNetwork' | 'setPrimaryWallet' | 'setShowAuthFlow' | 'setShowQrcodeModal' | 'shadowDOMEnabled' | 'showAuthFlow' | 'showQrcodeModal' | 'setShowDynamicUserProfile' | 'user' | 'walletConnector' | 'wallets'>;
|
|
2
|
+
export type UseDynamicContext = Pick<IDynamicContext, 'accountSwitchState' | 'authMode' | 'authToken' | 'awaitingSignatureState' | 'connectedWallets' | 'handleLogOut' | 'handleUnlinkWallet' | 'isAuthenticated' | 'loadingNetwork' | 'multiWalletWidgetState' | 'network' | 'networkConfigurations' | 'primaryWallet' | 'qrcodeUri' | 'rpcProviders' | 'secondaryWallets' | 'setMultiWalletWidgetState' | 'setNetwork' | 'setPrimaryWallet' | 'setShowAuthFlow' | 'setShowQrcodeModal' | 'shadowDOMEnabled' | 'sdkHasLoaded' | 'showAuthFlow' | 'showQrcodeModal' | 'setShowDynamicUserProfile' | 'user' | 'walletConnector' | 'wallets'>;
|
|
3
3
|
export declare const useDynamicContext: () => UseDynamicContext;
|
|
@@ -7,7 +7,7 @@ const useDynamicContext = () => {
|
|
|
7
7
|
if (context === undefined) {
|
|
8
8
|
throw new Error('useDynamicContext must be used within a DynamicContextProvider');
|
|
9
9
|
}
|
|
10
|
-
const { accountSwitchState, awaitingSignatureState, authMode, authToken, connectedWallets, handleLogOut, handleUnlinkWallet, isAuthenticated, loadingNetwork, multiWalletWidgetState, network, networkConfigurations, primaryWallet, qrcodeUri, rpcProviders, secondaryWallets, setShowAuthFlow, setNetwork, showAuthFlow, showQrcodeModal, setMultiWalletWidgetState, setShowQrcodeModal, setPrimaryWallet, setShowDynamicUserProfile, user, walletConnector, wallets, shadowDOMEnabled, } = context;
|
|
10
|
+
const { accountSwitchState, awaitingSignatureState, authMode, authToken, connectedWallets, handleLogOut, handleUnlinkWallet, isAuthenticated, loadingNetwork, multiWalletWidgetState, network, networkConfigurations, primaryWallet, qrcodeUri, rpcProviders, sdkHasLoaded, secondaryWallets, setShowAuthFlow, setNetwork, showAuthFlow, showQrcodeModal, setMultiWalletWidgetState, setShowQrcodeModal, setPrimaryWallet, setShowDynamicUserProfile, user, walletConnector, wallets, shadowDOMEnabled, } = context;
|
|
11
11
|
return {
|
|
12
12
|
accountSwitchState,
|
|
13
13
|
authMode,
|
|
@@ -24,6 +24,7 @@ const useDynamicContext = () => {
|
|
|
24
24
|
primaryWallet,
|
|
25
25
|
qrcodeUri,
|
|
26
26
|
rpcProviders,
|
|
27
|
+
sdkHasLoaded,
|
|
27
28
|
secondaryWallets,
|
|
28
29
|
setMultiWalletWidgetState,
|
|
29
30
|
setNetwork,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { useGlobalLoading } from './useGlobalLoading';
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var React = require('react');
|
|
6
|
+
var index = require('../../functions/lastAuthenticatedAccount/index.cjs');
|
|
7
|
+
|
|
8
|
+
const useGlobalLoading = ({ authMode, connectedInfo, connectedWallet, projectSettings, primaryWallet, user, }) => {
|
|
9
|
+
var _a;
|
|
10
|
+
const [sdkHasLoaded, setSdkHasLoaded] = React.useState(false);
|
|
11
|
+
const primaryWalletIsLoading = user &&
|
|
12
|
+
((_a = index.lastAuthenticatedAccount(user)) === null || _a === void 0 ? void 0 : _a.format) === 'blockchain' &&
|
|
13
|
+
!primaryWallet;
|
|
14
|
+
const connectOnlyUserIsLoading = authMode === 'connect-only' && connectedInfo && !connectedWallet;
|
|
15
|
+
React.useEffect(() => {
|
|
16
|
+
if (projectSettings) {
|
|
17
|
+
if (primaryWalletIsLoading || connectOnlyUserIsLoading) {
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
setSdkHasLoaded(true);
|
|
21
|
+
}
|
|
22
|
+
}, [
|
|
23
|
+
projectSettings,
|
|
24
|
+
primaryWallet,
|
|
25
|
+
user,
|
|
26
|
+
primaryWalletIsLoading,
|
|
27
|
+
connectOnlyUserIsLoading,
|
|
28
|
+
]);
|
|
29
|
+
return {
|
|
30
|
+
sdkHasLoaded,
|
|
31
|
+
setSdkHasLoaded,
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
exports.useGlobalLoading = useGlobalLoading;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { ProjectSettings } from '@dynamic-labs/sdk-api';
|
|
3
|
+
import { UserProfile, Wallet } from '../../../types';
|
|
4
|
+
import { ConnectedWalletConnectorType } from '../../../../utils/hooks/useConnectWallet/useConnectWallet';
|
|
5
|
+
type Props = {
|
|
6
|
+
authMode: string;
|
|
7
|
+
connectedInfo: ConnectedWalletConnectorType | null;
|
|
8
|
+
connectedWallet: Wallet | null;
|
|
9
|
+
primaryWallet: Wallet | null;
|
|
10
|
+
projectSettings: ProjectSettings | undefined;
|
|
11
|
+
user: UserProfile | undefined;
|
|
12
|
+
};
|
|
13
|
+
export declare const useGlobalLoading: ({ authMode, connectedInfo, connectedWallet, projectSettings, primaryWallet, user, }: Props) => {
|
|
14
|
+
sdkHasLoaded: boolean;
|
|
15
|
+
setSdkHasLoaded: import("react").Dispatch<import("react").SetStateAction<boolean>>;
|
|
16
|
+
};
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { useState, useEffect } from 'react';
|
|
2
|
+
import { lastAuthenticatedAccount } from '../../functions/lastAuthenticatedAccount/index.js';
|
|
3
|
+
|
|
4
|
+
const useGlobalLoading = ({ authMode, connectedInfo, connectedWallet, projectSettings, primaryWallet, user, }) => {
|
|
5
|
+
var _a;
|
|
6
|
+
const [sdkHasLoaded, setSdkHasLoaded] = useState(false);
|
|
7
|
+
const primaryWalletIsLoading = user &&
|
|
8
|
+
((_a = lastAuthenticatedAccount(user)) === null || _a === void 0 ? void 0 : _a.format) === 'blockchain' &&
|
|
9
|
+
!primaryWallet;
|
|
10
|
+
const connectOnlyUserIsLoading = authMode === 'connect-only' && connectedInfo && !connectedWallet;
|
|
11
|
+
useEffect(() => {
|
|
12
|
+
if (projectSettings) {
|
|
13
|
+
if (primaryWalletIsLoading || connectOnlyUserIsLoading) {
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
setSdkHasLoaded(true);
|
|
17
|
+
}
|
|
18
|
+
}, [
|
|
19
|
+
projectSettings,
|
|
20
|
+
primaryWallet,
|
|
21
|
+
user,
|
|
22
|
+
primaryWalletIsLoading,
|
|
23
|
+
connectOnlyUserIsLoading,
|
|
24
|
+
]);
|
|
25
|
+
return {
|
|
26
|
+
sdkHasLoaded,
|
|
27
|
+
setSdkHasLoaded,
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export { useGlobalLoading };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import type { Chain, FetchPublicAddressOpts, WalletConnector } from '@dynamic-labs/wallet-connector-core';
|
|
3
3
|
import { AuthModeType, Wallet, WalletOption } from '../../../shared';
|
|
4
|
-
type ConnectedWalletConnectorType = {
|
|
4
|
+
export type ConnectedWalletConnectorType = {
|
|
5
5
|
chain: Chain | undefined;
|
|
6
6
|
name: string;
|
|
7
7
|
provider: string;
|
|
@@ -16,4 +16,3 @@ export declare const useConnectWallet: (wallets: WalletOption[], authMode: AuthM
|
|
|
16
16
|
setConnectedInfo: (value: ConnectedWalletConnectorType | ((val: ConnectedWalletConnectorType | null) => ConnectedWalletConnectorType | null) | null) => void;
|
|
17
17
|
setConnectedWallet: import("react").Dispatch<import("react").SetStateAction<Wallet | null>>;
|
|
18
18
|
};
|
|
19
|
-
export {};
|
|
@@ -32,23 +32,7 @@ const useUserUpdateRequestInternal = ({ validationSchemaStripUnknown, }) => {
|
|
|
32
32
|
const { verifyEmail: verifyEmailFn } = useEmailVerificationRequest.useEmailVerificationRequest();
|
|
33
33
|
const { updateUserProfileByJWT } = useUpdateUserProfileByJWTCallback.useUpdateUserProfileByJWTCallback();
|
|
34
34
|
const updateUser = React.useCallback((userFields, userEnvironmentId) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
35
|
-
|
|
36
|
-
var _a, _b;
|
|
37
|
-
setEmail((_a = updateUserProfileResponse.emailVerification) === null || _a === void 0 ? void 0 : _a.email);
|
|
38
|
-
setVerificationUUID((_b = updateUserProfileResponse.emailVerification) === null || _b === void 0 ? void 0 : _b.verificationUUID);
|
|
39
|
-
// DYN-2046 - Customers have the opportunity to programmatically use our email verification and profile editing.
|
|
40
|
-
// VerifyEmailFN was scoped to bypass the problem with memoization of the state at the beginning of Promise.
|
|
41
|
-
// setEmail and setVerificationUUID in the above lines will are not visible in this promise.
|
|
42
|
-
const scopedVerifyEmailFn = (verificationToken) => {
|
|
43
|
-
var _a;
|
|
44
|
-
return verifyEmailFn(verificationToken, (_a = updateUserProfileResponse.emailVerification) === null || _a === void 0 ? void 0 : _a.verificationUUID);
|
|
45
|
-
};
|
|
46
|
-
return {
|
|
47
|
-
isEmailVerificationRequired: _isEmailVerificationRequired,
|
|
48
|
-
updateUserProfileResponse,
|
|
49
|
-
verifyEmailFn: scopedVerifyEmailFn,
|
|
50
|
-
};
|
|
51
|
-
});
|
|
35
|
+
var _a, _b;
|
|
52
36
|
const validatedUserFields = yield userFieldsSchema.validate(userFields, {
|
|
53
37
|
stripUnknown: validationSchemaStripUnknown,
|
|
54
38
|
});
|
|
@@ -58,11 +42,25 @@ const useUserUpdateRequestInternal = ({ validationSchemaStripUnknown, }) => {
|
|
|
58
42
|
// If email verification is not needed then we can update the user profile immediately.
|
|
59
43
|
updateUserProfileByJWT(updateUserProfileResponse.jwt);
|
|
60
44
|
return {
|
|
61
|
-
isEmailVerificationRequired:
|
|
45
|
+
isEmailVerificationRequired: _isEmailVerificationRequired,
|
|
62
46
|
updateUserProfileResponse,
|
|
63
47
|
};
|
|
64
48
|
}
|
|
65
|
-
|
|
49
|
+
// We update EmailContext to use this information in the Email Verification view
|
|
50
|
+
setEmail((_a = updateUserProfileResponse.emailVerification) === null || _a === void 0 ? void 0 : _a.email);
|
|
51
|
+
setVerificationUUID((_b = updateUserProfileResponse.emailVerification) === null || _b === void 0 ? void 0 : _b.verificationUUID);
|
|
52
|
+
// DYN-2046 - Customers have the opportunity to programmatically use our email verification and profile editing.
|
|
53
|
+
// VerifyEmailFN was scoped to bypass the problem with memoization of the state at the beginning of Promise.
|
|
54
|
+
// setEmail and setVerificationUUID in the above lines will are not visible in this promise.
|
|
55
|
+
const scopedVerifyEmailFn = (verificationToken) => {
|
|
56
|
+
var _a;
|
|
57
|
+
return verifyEmailFn(verificationToken, (_a = updateUserProfileResponse.emailVerification) === null || _a === void 0 ? void 0 : _a.verificationUUID);
|
|
58
|
+
};
|
|
59
|
+
return {
|
|
60
|
+
isEmailVerificationRequired: _isEmailVerificationRequired,
|
|
61
|
+
updateUserProfileResponse,
|
|
62
|
+
verifyEmailFn: scopedVerifyEmailFn,
|
|
63
|
+
};
|
|
66
64
|
}), [
|
|
67
65
|
environmentId,
|
|
68
66
|
jwtToken,
|
|
@@ -4,21 +4,23 @@ export declare const useUserUpdateRequestInternal: ({ validationSchemaStripUnkno
|
|
|
4
4
|
validationSchemaStripUnknown: boolean;
|
|
5
5
|
}) => {
|
|
6
6
|
updateUser: (userFields: UpdateUserFieldsArg, userEnvironmentId?: string) => Promise<{
|
|
7
|
-
isEmailVerificationRequired:
|
|
7
|
+
isEmailVerificationRequired: false;
|
|
8
8
|
updateUserProfileResponse: import("@dynamic-labs/sdk-api").UpdateSelfResponse;
|
|
9
|
-
verifyEmailFn
|
|
9
|
+
verifyEmailFn?: undefined;
|
|
10
10
|
} | {
|
|
11
|
-
isEmailVerificationRequired:
|
|
11
|
+
isEmailVerificationRequired: true;
|
|
12
12
|
updateUserProfileResponse: import("@dynamic-labs/sdk-api").UpdateSelfResponse;
|
|
13
|
+
verifyEmailFn: (verificationToken: string) => Promise<import("@dynamic-labs/sdk-api").UpdateSelfResponse>;
|
|
13
14
|
}>;
|
|
14
15
|
};
|
|
15
16
|
export declare const useUserUpdateRequest: () => {
|
|
16
17
|
updateUser: (userFields: UpdateUserFieldsArg, userEnvironmentId?: string) => Promise<{
|
|
17
|
-
isEmailVerificationRequired:
|
|
18
|
+
isEmailVerificationRequired: false;
|
|
18
19
|
updateUserProfileResponse: import("@dynamic-labs/sdk-api").UpdateSelfResponse;
|
|
19
|
-
verifyEmailFn
|
|
20
|
+
verifyEmailFn?: undefined;
|
|
20
21
|
} | {
|
|
21
|
-
isEmailVerificationRequired:
|
|
22
|
+
isEmailVerificationRequired: true;
|
|
22
23
|
updateUserProfileResponse: import("@dynamic-labs/sdk-api").UpdateSelfResponse;
|
|
24
|
+
verifyEmailFn: (verificationToken: string) => Promise<import("@dynamic-labs/sdk-api").UpdateSelfResponse>;
|
|
23
25
|
}>;
|
|
24
26
|
};
|
|
@@ -28,23 +28,7 @@ const useUserUpdateRequestInternal = ({ validationSchemaStripUnknown, }) => {
|
|
|
28
28
|
const { verifyEmail: verifyEmailFn } = useEmailVerificationRequest();
|
|
29
29
|
const { updateUserProfileByJWT } = useUpdateUserProfileByJWTCallback();
|
|
30
30
|
const updateUser = useCallback((userFields, userEnvironmentId) => __awaiter(void 0, void 0, void 0, function* () {
|
|
31
|
-
|
|
32
|
-
var _a, _b;
|
|
33
|
-
setEmail((_a = updateUserProfileResponse.emailVerification) === null || _a === void 0 ? void 0 : _a.email);
|
|
34
|
-
setVerificationUUID((_b = updateUserProfileResponse.emailVerification) === null || _b === void 0 ? void 0 : _b.verificationUUID);
|
|
35
|
-
// DYN-2046 - Customers have the opportunity to programmatically use our email verification and profile editing.
|
|
36
|
-
// VerifyEmailFN was scoped to bypass the problem with memoization of the state at the beginning of Promise.
|
|
37
|
-
// setEmail and setVerificationUUID in the above lines will are not visible in this promise.
|
|
38
|
-
const scopedVerifyEmailFn = (verificationToken) => {
|
|
39
|
-
var _a;
|
|
40
|
-
return verifyEmailFn(verificationToken, (_a = updateUserProfileResponse.emailVerification) === null || _a === void 0 ? void 0 : _a.verificationUUID);
|
|
41
|
-
};
|
|
42
|
-
return {
|
|
43
|
-
isEmailVerificationRequired: _isEmailVerificationRequired,
|
|
44
|
-
updateUserProfileResponse,
|
|
45
|
-
verifyEmailFn: scopedVerifyEmailFn,
|
|
46
|
-
};
|
|
47
|
-
});
|
|
31
|
+
var _a, _b;
|
|
48
32
|
const validatedUserFields = yield userFieldsSchema.validate(userFields, {
|
|
49
33
|
stripUnknown: validationSchemaStripUnknown,
|
|
50
34
|
});
|
|
@@ -54,11 +38,25 @@ const useUserUpdateRequestInternal = ({ validationSchemaStripUnknown, }) => {
|
|
|
54
38
|
// If email verification is not needed then we can update the user profile immediately.
|
|
55
39
|
updateUserProfileByJWT(updateUserProfileResponse.jwt);
|
|
56
40
|
return {
|
|
57
|
-
isEmailVerificationRequired:
|
|
41
|
+
isEmailVerificationRequired: _isEmailVerificationRequired,
|
|
58
42
|
updateUserProfileResponse,
|
|
59
43
|
};
|
|
60
44
|
}
|
|
61
|
-
|
|
45
|
+
// We update EmailContext to use this information in the Email Verification view
|
|
46
|
+
setEmail((_a = updateUserProfileResponse.emailVerification) === null || _a === void 0 ? void 0 : _a.email);
|
|
47
|
+
setVerificationUUID((_b = updateUserProfileResponse.emailVerification) === null || _b === void 0 ? void 0 : _b.verificationUUID);
|
|
48
|
+
// DYN-2046 - Customers have the opportunity to programmatically use our email verification and profile editing.
|
|
49
|
+
// VerifyEmailFN was scoped to bypass the problem with memoization of the state at the beginning of Promise.
|
|
50
|
+
// setEmail and setVerificationUUID in the above lines will are not visible in this promise.
|
|
51
|
+
const scopedVerifyEmailFn = (verificationToken) => {
|
|
52
|
+
var _a;
|
|
53
|
+
return verifyEmailFn(verificationToken, (_a = updateUserProfileResponse.emailVerification) === null || _a === void 0 ? void 0 : _a.verificationUUID);
|
|
54
|
+
};
|
|
55
|
+
return {
|
|
56
|
+
isEmailVerificationRequired: _isEmailVerificationRequired,
|
|
57
|
+
updateUserProfileResponse,
|
|
58
|
+
verifyEmailFn: scopedVerifyEmailFn,
|
|
59
|
+
};
|
|
62
60
|
}), [
|
|
63
61
|
environmentId,
|
|
64
62
|
jwtToken,
|
|
@@ -29,7 +29,7 @@ require('../../../shared/consts/index.cjs');
|
|
|
29
29
|
// This logic is used to both verify or link a wallet
|
|
30
30
|
// Since we are re-using the different screens to authenticate or link the wallet.
|
|
31
31
|
// This logic is the best place to determine whether we should verify or verify and link.
|
|
32
|
-
const useVerifyWallet = ({ consumeNonce, displayTermsOfService, environmentId, setIsSingleWalletAccount, }) => {
|
|
32
|
+
const useVerifyWallet = ({ consumeNonce, displayTermsOfService, environmentId, projectSettings, setIsSingleWalletAccount, }) => {
|
|
33
33
|
const { setView } = ViewContext.useViewContext();
|
|
34
34
|
const { setErrorMessage, setError } = ErrorContext.useErrorContext();
|
|
35
35
|
const { setUser, multiWalletWidgetState, debugError, multiWallet: multiWalletEnabled, appName, primaryWalletId, setCallback, setShowAuthFlow, setPrimaryWalletId, siweStatement, connectedWallet, authMode, setOnboardingOnlyJwt, authToken, loginWithEmail, } = useInternalDynamicContext.useInternalDynamicContext();
|
|
@@ -58,20 +58,20 @@ const useVerifyWallet = ({ consumeNonce, displayTermsOfService, environmentId, s
|
|
|
58
58
|
else {
|
|
59
59
|
Jwt = yield api.linkWallet(environmentId, verifyArgs, authToken);
|
|
60
60
|
}
|
|
61
|
-
if (Jwt === undefined)
|
|
61
|
+
if (Jwt === undefined)
|
|
62
62
|
throw new multiWallet.DynamicError('Could not obtain a valid JWT');
|
|
63
|
-
|
|
63
|
+
// TODO DYN-523: add verification here that the JWT is valid with the publicKey
|
|
64
64
|
return Jwt;
|
|
65
65
|
});
|
|
66
66
|
// Overrides the stored primary wallet id when the
|
|
67
67
|
// user logs in for the first time.
|
|
68
68
|
// Or when the user is linking an additional
|
|
69
69
|
// account on the same wallet as the primary wallet.
|
|
70
|
-
const updatePrimaryWalletId = (walletConnector,
|
|
71
|
-
const newSelectedCredentialWallet =
|
|
70
|
+
const updatePrimaryWalletId = (walletConnector, user) => {
|
|
71
|
+
const newSelectedCredentialWallet = user.verifiedCredentials.find((cred) => cred.id === user.lastVerifiedCredentialId &&
|
|
72
72
|
cred.format === 'blockchain');
|
|
73
73
|
if (newSelectedCredentialWallet) {
|
|
74
|
-
const currentPrimaryWallet =
|
|
74
|
+
const currentPrimaryWallet = user.verifiedCredentials.find((a) => a.id === primaryWalletId);
|
|
75
75
|
if (verifyOnly ||
|
|
76
76
|
primaryWalletId === undefined ||
|
|
77
77
|
(multiWalletWidgetState === 'awaiting_signature' &&
|
|
@@ -129,18 +129,31 @@ const useVerifyWallet = ({ consumeNonce, displayTermsOfService, environmentId, s
|
|
|
129
129
|
const decodedJwt = decodeJwt.decodeJwt(Jwt);
|
|
130
130
|
if (decodedJwt === undefined)
|
|
131
131
|
throw new multiWallet.DynamicError('Invalid token!');
|
|
132
|
-
|
|
133
|
-
updatePrimaryWalletId(walletConnector, decodedJwt);
|
|
132
|
+
const user = yield createUserProfile.createUserProfile(decodedJwt);
|
|
134
133
|
const isKycRequired = decodedJwt.missingFields.length;
|
|
135
|
-
|
|
136
|
-
|
|
134
|
+
setOnboardingOnlyJwt(Jwt);
|
|
135
|
+
setToLS.setToLS(localStorage.LAST_USED_WALLET, walletConnector.name);
|
|
136
|
+
updatePrimaryWalletId(walletConnector, user);
|
|
137
|
+
// Routes user to "Not Supported Network" screen if the user is not on the supported network
|
|
138
|
+
if (projectSettings &&
|
|
139
|
+
verifyOnly &&
|
|
140
|
+
!_isSupportedNetwork &&
|
|
141
|
+
!isKycRequired) {
|
|
142
|
+
const _isProgrammableNetworkSwitchSupported = isProgrammableNetworkSwitchSupported.isProgrammableNetworkSwitchSupported(walletConnector);
|
|
143
|
+
if (_isProgrammableNetworkSwitchSupported) {
|
|
144
|
+
return setView('network-not-supported');
|
|
145
|
+
}
|
|
146
|
+
return setView('network-not-supported-manual');
|
|
147
|
+
}
|
|
148
|
+
// TODO: how can projectSettings be undefined?
|
|
149
|
+
if (verifyOnly && projectSettings && isKycRequired) {
|
|
137
150
|
setShowAuthFlow(true);
|
|
138
|
-
setView('collect-user-data');
|
|
139
|
-
return;
|
|
151
|
+
return setView('collect-user-data');
|
|
140
152
|
}
|
|
141
|
-
const user = yield createUserProfile.createUserProfile(decodedJwt);
|
|
142
153
|
index.storeAuthToken(Jwt);
|
|
154
|
+
setOnboardingOnlyJwt(undefined);
|
|
143
155
|
setUser(user); // The user should only be set if no KYC is needed.
|
|
156
|
+
setShowAuthFlow(false);
|
|
144
157
|
/* istanbul ignore else */
|
|
145
158
|
if (verifyOnly) {
|
|
146
159
|
setCallback('authSuccess');
|
|
@@ -148,17 +161,6 @@ const useVerifyWallet = ({ consumeNonce, displayTermsOfService, environmentId, s
|
|
|
148
161
|
else {
|
|
149
162
|
setCallback('linkSuccess');
|
|
150
163
|
}
|
|
151
|
-
// Routes user to "Not Supported Network" screen if the user is not on the supported network
|
|
152
|
-
if (!_isSupportedNetwork) {
|
|
153
|
-
if (isProgrammableNetworkSwitchSupported.isProgrammableNetworkSwitchSupported(walletConnector)) {
|
|
154
|
-
setView('network-not-supported');
|
|
155
|
-
}
|
|
156
|
-
else {
|
|
157
|
-
setView('network-not-supported-manual');
|
|
158
|
-
}
|
|
159
|
-
return;
|
|
160
|
-
}
|
|
161
|
-
setShowAuthFlow(false);
|
|
162
164
|
}
|
|
163
165
|
catch (e) {
|
|
164
166
|
handleError(e, walletConnector);
|
|
@@ -5,5 +5,5 @@ type UseVerifyWalletArgs = VerifyProps & ProjectSettingsProps & {
|
|
|
5
5
|
displayTermsOfService: boolean;
|
|
6
6
|
setIsSingleWalletAccount: Dispatch<SetStateAction<boolean>>;
|
|
7
7
|
};
|
|
8
|
-
export declare const useVerifyWallet: ({ consumeNonce, displayTermsOfService, environmentId, setIsSingleWalletAccount, }: UseVerifyWalletArgs) => ({ walletConnector, fetchPublicAddressOpts, publicWalletAddress, captchaToken, }: VerifyCallbackArgs) => Promise<void>;
|
|
8
|
+
export declare const useVerifyWallet: ({ consumeNonce, displayTermsOfService, environmentId, projectSettings, setIsSingleWalletAccount, }: UseVerifyWalletArgs) => ({ walletConnector, fetchPublicAddressOpts, publicWalletAddress, captchaToken, }: VerifyCallbackArgs) => Promise<void>;
|
|
9
9
|
export {};
|
|
@@ -25,7 +25,7 @@ import '../../../shared/consts/index.js';
|
|
|
25
25
|
// This logic is used to both verify or link a wallet
|
|
26
26
|
// Since we are re-using the different screens to authenticate or link the wallet.
|
|
27
27
|
// This logic is the best place to determine whether we should verify or verify and link.
|
|
28
|
-
const useVerifyWallet = ({ consumeNonce, displayTermsOfService, environmentId, setIsSingleWalletAccount, }) => {
|
|
28
|
+
const useVerifyWallet = ({ consumeNonce, displayTermsOfService, environmentId, projectSettings, setIsSingleWalletAccount, }) => {
|
|
29
29
|
const { setView } = useViewContext();
|
|
30
30
|
const { setErrorMessage, setError } = useErrorContext();
|
|
31
31
|
const { setUser, multiWalletWidgetState, debugError, multiWallet: multiWalletEnabled, appName, primaryWalletId, setCallback, setShowAuthFlow, setPrimaryWalletId, siweStatement, connectedWallet, authMode, setOnboardingOnlyJwt, authToken, loginWithEmail, } = useInternalDynamicContext();
|
|
@@ -54,20 +54,20 @@ const useVerifyWallet = ({ consumeNonce, displayTermsOfService, environmentId, s
|
|
|
54
54
|
else {
|
|
55
55
|
Jwt = yield linkWallet(environmentId, verifyArgs, authToken);
|
|
56
56
|
}
|
|
57
|
-
if (Jwt === undefined)
|
|
57
|
+
if (Jwt === undefined)
|
|
58
58
|
throw new DynamicError('Could not obtain a valid JWT');
|
|
59
|
-
|
|
59
|
+
// TODO DYN-523: add verification here that the JWT is valid with the publicKey
|
|
60
60
|
return Jwt;
|
|
61
61
|
});
|
|
62
62
|
// Overrides the stored primary wallet id when the
|
|
63
63
|
// user logs in for the first time.
|
|
64
64
|
// Or when the user is linking an additional
|
|
65
65
|
// account on the same wallet as the primary wallet.
|
|
66
|
-
const updatePrimaryWalletId = (walletConnector,
|
|
67
|
-
const newSelectedCredentialWallet =
|
|
66
|
+
const updatePrimaryWalletId = (walletConnector, user) => {
|
|
67
|
+
const newSelectedCredentialWallet = user.verifiedCredentials.find((cred) => cred.id === user.lastVerifiedCredentialId &&
|
|
68
68
|
cred.format === 'blockchain');
|
|
69
69
|
if (newSelectedCredentialWallet) {
|
|
70
|
-
const currentPrimaryWallet =
|
|
70
|
+
const currentPrimaryWallet = user.verifiedCredentials.find((a) => a.id === primaryWalletId);
|
|
71
71
|
if (verifyOnly ||
|
|
72
72
|
primaryWalletId === undefined ||
|
|
73
73
|
(multiWalletWidgetState === 'awaiting_signature' &&
|
|
@@ -125,18 +125,31 @@ const useVerifyWallet = ({ consumeNonce, displayTermsOfService, environmentId, s
|
|
|
125
125
|
const decodedJwt = decodeJwt(Jwt);
|
|
126
126
|
if (decodedJwt === undefined)
|
|
127
127
|
throw new DynamicError('Invalid token!');
|
|
128
|
-
|
|
129
|
-
updatePrimaryWalletId(walletConnector, decodedJwt);
|
|
128
|
+
const user = yield createUserProfile(decodedJwt);
|
|
130
129
|
const isKycRequired = decodedJwt.missingFields.length;
|
|
131
|
-
|
|
132
|
-
|
|
130
|
+
setOnboardingOnlyJwt(Jwt);
|
|
131
|
+
setToLS(LAST_USED_WALLET, walletConnector.name);
|
|
132
|
+
updatePrimaryWalletId(walletConnector, user);
|
|
133
|
+
// Routes user to "Not Supported Network" screen if the user is not on the supported network
|
|
134
|
+
if (projectSettings &&
|
|
135
|
+
verifyOnly &&
|
|
136
|
+
!_isSupportedNetwork &&
|
|
137
|
+
!isKycRequired) {
|
|
138
|
+
const _isProgrammableNetworkSwitchSupported = isProgrammableNetworkSwitchSupported(walletConnector);
|
|
139
|
+
if (_isProgrammableNetworkSwitchSupported) {
|
|
140
|
+
return setView('network-not-supported');
|
|
141
|
+
}
|
|
142
|
+
return setView('network-not-supported-manual');
|
|
143
|
+
}
|
|
144
|
+
// TODO: how can projectSettings be undefined?
|
|
145
|
+
if (verifyOnly && projectSettings && isKycRequired) {
|
|
133
146
|
setShowAuthFlow(true);
|
|
134
|
-
setView('collect-user-data');
|
|
135
|
-
return;
|
|
147
|
+
return setView('collect-user-data');
|
|
136
148
|
}
|
|
137
|
-
const user = yield createUserProfile(decodedJwt);
|
|
138
149
|
storeAuthToken(Jwt);
|
|
150
|
+
setOnboardingOnlyJwt(undefined);
|
|
139
151
|
setUser(user); // The user should only be set if no KYC is needed.
|
|
152
|
+
setShowAuthFlow(false);
|
|
140
153
|
/* istanbul ignore else */
|
|
141
154
|
if (verifyOnly) {
|
|
142
155
|
setCallback('authSuccess');
|
|
@@ -144,17 +157,6 @@ const useVerifyWallet = ({ consumeNonce, displayTermsOfService, environmentId, s
|
|
|
144
157
|
else {
|
|
145
158
|
setCallback('linkSuccess');
|
|
146
159
|
}
|
|
147
|
-
// Routes user to "Not Supported Network" screen if the user is not on the supported network
|
|
148
|
-
if (!_isSupportedNetwork) {
|
|
149
|
-
if (isProgrammableNetworkSwitchSupported(walletConnector)) {
|
|
150
|
-
setView('network-not-supported');
|
|
151
|
-
}
|
|
152
|
-
else {
|
|
153
|
-
setView('network-not-supported-manual');
|
|
154
|
-
}
|
|
155
|
-
return;
|
|
156
|
-
}
|
|
157
|
-
setShowAuthFlow(false);
|
|
158
160
|
}
|
|
159
161
|
catch (e) {
|
|
160
162
|
handleError(e, walletConnector);
|
|
@@ -33,7 +33,6 @@ require('../../../components/IconButton/IconButton.cjs');
|
|
|
33
33
|
var index = require('../UserDataFields/index.cjs');
|
|
34
34
|
var useUserDataForm = require('../../../utils/hooks/useUserDataForm/useUserDataForm.cjs');
|
|
35
35
|
|
|
36
|
-
// TODO rename to OnboardingUserDataForm
|
|
37
36
|
const UserDataForm = ({ children, userProfile }) => {
|
|
38
37
|
const { policiesConsentInnerComponent, onboardingOnlyJwt, setShowAuthFlow, setCallback, } = useInternalDynamicContext.useInternalDynamicContext();
|
|
39
38
|
const { setView } = ViewContext.useViewContext();
|
|
@@ -47,8 +46,8 @@ const UserDataForm = ({ children, userProfile }) => {
|
|
|
47
46
|
setView('verify-email');
|
|
48
47
|
return;
|
|
49
48
|
}
|
|
50
|
-
setCallback('authSuccess');
|
|
51
49
|
setShowAuthFlow(false);
|
|
50
|
+
setCallback('authSuccess');
|
|
52
51
|
}), [setCallback, setShowAuthFlow, setView, updateUser]);
|
|
53
52
|
const { fetch: loading, formikInitialValues, formikValidationSchema, enforcePolicies, onFormSubmit, } = useUserDataForm.useUserDataForm({
|
|
54
53
|
fields: (decodedJwt === null || decodedJwt === void 0 ? void 0 : decodedJwt.missingFields) || [],
|
|
@@ -29,7 +29,6 @@ import '../../../components/IconButton/IconButton.js';
|
|
|
29
29
|
import { UserDataFields } from '../UserDataFields/index.js';
|
|
30
30
|
import { useUserDataForm } from '../../../utils/hooks/useUserDataForm/useUserDataForm.js';
|
|
31
31
|
|
|
32
|
-
// TODO rename to OnboardingUserDataForm
|
|
33
32
|
const UserDataForm = ({ children, userProfile }) => {
|
|
34
33
|
const { policiesConsentInnerComponent, onboardingOnlyJwt, setShowAuthFlow, setCallback, } = useInternalDynamicContext();
|
|
35
34
|
const { setView } = useViewContext();
|
|
@@ -43,8 +42,8 @@ const UserDataForm = ({ children, userProfile }) => {
|
|
|
43
42
|
setView('verify-email');
|
|
44
43
|
return;
|
|
45
44
|
}
|
|
46
|
-
setCallback('authSuccess');
|
|
47
45
|
setShowAuthFlow(false);
|
|
46
|
+
setCallback('authSuccess');
|
|
48
47
|
}), [setCallback, setShowAuthFlow, setView, updateUser]);
|
|
49
48
|
const { fetch: loading, formikInitialValues, formikValidationSchema, enforcePolicies, onFormSubmit, } = useUserDataForm({
|
|
50
49
|
fields: (decodedJwt === null || decodedJwt === void 0 ? void 0 : decodedJwt.missingFields) || [],
|
|
@@ -86,7 +86,6 @@ const EmailVerification = () => {
|
|
|
86
86
|
setLoading(false);
|
|
87
87
|
}
|
|
88
88
|
}), [
|
|
89
|
-
setCallback,
|
|
90
89
|
setError,
|
|
91
90
|
setLoading,
|
|
92
91
|
verificationUUID,
|
|
@@ -97,6 +96,7 @@ const EmailVerification = () => {
|
|
|
97
96
|
verifyEmail,
|
|
98
97
|
setShowAuthFlow,
|
|
99
98
|
setOnboardingOnlyJwt,
|
|
99
|
+
setCallback,
|
|
100
100
|
setErrorMessage,
|
|
101
101
|
]);
|
|
102
102
|
const handleEmailLogin = React.useCallback((verificationToken) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -82,7 +82,6 @@ const EmailVerification = () => {
|
|
|
82
82
|
setLoading(false);
|
|
83
83
|
}
|
|
84
84
|
}), [
|
|
85
|
-
setCallback,
|
|
86
85
|
setError,
|
|
87
86
|
setLoading,
|
|
88
87
|
verificationUUID,
|
|
@@ -93,6 +92,7 @@ const EmailVerification = () => {
|
|
|
93
92
|
verifyEmail,
|
|
94
93
|
setShowAuthFlow,
|
|
95
94
|
setOnboardingOnlyJwt,
|
|
95
|
+
setCallback,
|
|
96
96
|
setErrorMessage,
|
|
97
97
|
]);
|
|
98
98
|
const handleEmailLogin = useCallback((verificationToken) => __awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -14,6 +14,7 @@ require('../../context/ViewContext/ViewContext.cjs');
|
|
|
14
14
|
require('../../utils/constants/colors.cjs');
|
|
15
15
|
require('../../shared/consts/index.cjs');
|
|
16
16
|
var useInternalDynamicContext = require('../../context/DynamicContext/useInternalDynamicContext.cjs');
|
|
17
|
+
var createUserProfile = require('../../utils/functions/createUserProfile/createUserProfile.cjs');
|
|
17
18
|
var isSupportedNetwork = require('../../utils/functions/isSupportedNetwork/isSupportedNetwork.cjs');
|
|
18
19
|
var pixelToRem = require('../../utils/functions/pixelToRem/pixelToRem.cjs');
|
|
19
20
|
require('../../components/ShadowDOM/ShadowDOM.cjs');
|
|
@@ -35,20 +36,27 @@ require('../../components/IconButton/IconButton.cjs');
|
|
|
35
36
|
var ErrorContainer = require('../../components/ErrorContainer/ErrorContainer.cjs');
|
|
36
37
|
var NetworkPicker = require('../../components/NetworkPicker/NetworkPicker.cjs');
|
|
37
38
|
var UserAddress = require('../../components/UserAddress/UserAddress.cjs');
|
|
39
|
+
var useUpdateUserProfileByJWTCallback = require('../../utils/hooks/useUpdateUserProfileByJWTCallback/useUpdateUserProfileByJWTCallback.cjs');
|
|
38
40
|
|
|
39
41
|
const NetworkNotSupported = () => {
|
|
40
42
|
var _a, _b;
|
|
41
|
-
const { handleLogOut, network, onboardingImageUrl, selectedWalletConnector: walletConnector, setShowAuthFlow,
|
|
43
|
+
const { handleLogOut, onboardingOnlyJwt, network, onboardingImageUrl, selectedWalletConnector: walletConnector, decodedOnboardingOnlyToken, setShowAuthFlow, setCallback, } = useInternalDynamicContext.useInternalDynamicContext();
|
|
44
|
+
const { updateUserProfileByJWT } = useUpdateUserProfileByJWTCallback.useUpdateUserProfileByJWTCallback();
|
|
42
45
|
const [isNetworkPickerOpen, setIsNetworkPickerOpen] = React.useState(false);
|
|
43
|
-
if (!walletConnector) {
|
|
46
|
+
if (!decodedOnboardingOnlyToken || !walletConnector) {
|
|
44
47
|
return null;
|
|
45
48
|
}
|
|
46
49
|
const onSubmit = () => {
|
|
50
|
+
if (!onboardingOnlyJwt)
|
|
51
|
+
return;
|
|
52
|
+
setCallback('authSuccess');
|
|
53
|
+
updateUserProfileByJWT(onboardingOnlyJwt);
|
|
47
54
|
setShowAuthFlow(false);
|
|
48
55
|
};
|
|
56
|
+
const userProfile = createUserProfile.createUserProfile(decodedOnboardingOnlyToken);
|
|
49
57
|
const evmNetworks = walletConnector.evmNetworks || [];
|
|
50
58
|
const _isSupportedNetwork = isSupportedNetwork.isSupportedNetwork({ network, walletConnector });
|
|
51
|
-
return (jsxRuntime.jsxs("div", Object.assign({ className: 'network-not-supported', "data-testid": 'network-not-supported' }, { children: [onboardingImageUrl && (jsxRuntime.jsx("img", { className: 'network-not-supported__main-img', src: onboardingImageUrl, alt: 'onboarding' })), !_isSupportedNetwork && (jsxRuntime.jsx(ErrorContainer.ErrorContainer, Object.assign({ withIcon: false, className: 'network-not-supported__error--not-supported' }, { children: "This network is not available, please update." }))), jsxRuntime.jsxs("div", Object.assign({ className: 'network-not-supported__content-container' }, { children: [jsxRuntime.jsx("div", Object.assign({ className: 'network-not-supported__img-container' }, { children: ((_a =
|
|
59
|
+
return (jsxRuntime.jsxs("div", Object.assign({ className: 'network-not-supported', "data-testid": 'network-not-supported' }, { children: [onboardingImageUrl && (jsxRuntime.jsx("img", { className: 'network-not-supported__main-img', src: onboardingImageUrl, alt: 'onboarding' })), !_isSupportedNetwork && (jsxRuntime.jsx(ErrorContainer.ErrorContainer, Object.assign({ withIcon: false, className: 'network-not-supported__error--not-supported' }, { children: "This network is not available, please update." }))), jsxRuntime.jsxs("div", Object.assign({ className: 'network-not-supported__content-container' }, { children: [jsxRuntime.jsx("div", Object.assign({ className: 'network-not-supported__img-container' }, { children: ((_a = userProfile === null || userProfile === void 0 ? void 0 : userProfile.ens) === null || _a === void 0 ? void 0 : _a.avatar) ? (jsxRuntime.jsx("div", Object.assign({ className: 'network-not-supported__network-container' }, { children: jsxRuntime.jsx("img", { src: (_b = userProfile === null || userProfile === void 0 ? void 0 : userProfile.ens) === null || _b === void 0 ? void 0 : _b.avatar, alt: 'user ens avatar', className: 'network-not-supported__img' }) }))) : (jsxRuntime.jsx("div", Object.assign({ className: 'network-not-supported__network-container' }, { children: jsxRuntime.jsx(walletBook.WalletIcon, { walletName: walletConnector.name, style: { height: pixelToRem.pixelToRem(64), width: pixelToRem.pixelToRem(64) } }) }))) })), jsxRuntime.jsx(UserAddress.UserAddress, { userProfile: userProfile }), jsxRuntime.jsx("div", Object.assign({ className: 'network-not-supported__network-container' }, { children: jsxRuntime.jsx(NetworkPicker.NetworkPicker, { evmNetworks: evmNetworks, connector: walletConnector, isNetworkPickerOpen: isNetworkPickerOpen, setIsNetworkPickerOpen: setIsNetworkPickerOpen, showNetworkName: true, buttonClassName: 'network-not-supported__network-picker-button', mainClassName: 'network-not-supported__network-picker' }) })), jsxRuntime.jsxs("div", Object.assign({ className: 'network-not-supported__welcome-container' }, { children: [jsxRuntime.jsx(Typography.Typography, Object.assign({ variant: 'title', color: 'primary', className: 'network-not-supported__welcome-title' }, { children: "Update Network" })), jsxRuntime.jsx(Typography.Typography, Object.assign({ variant: 'body_normal', weight: 'regular', color: 'secondary' }, { children: "Your wallet is not connected to a supported network. Please update before continuing." })), jsxRuntime.jsx(Button.Button, Object.assign({ type: 'submit', buttonVariant: 'primary', expanded: true, buttonRounded: 'default', buttonPadding: 'large', disabled: !_isSupportedNetwork, onClick: onSubmit, buttonClassName: 'network-not-supported__continue' }, { children: "Continue" })), jsxRuntime.jsx(TextButton.TextButton, Object.assign({ className: 'network-not-supported__log-out', onClick: () => handleLogOut() }, { children: "Log out" }))] }))] }))] })));
|
|
52
60
|
};
|
|
53
61
|
|
|
54
62
|
exports.NetworkNotSupported = NetworkNotSupported;
|
|
@@ -10,6 +10,7 @@ import '../../context/ViewContext/ViewContext.js';
|
|
|
10
10
|
import '../../utils/constants/colors.js';
|
|
11
11
|
import '../../shared/consts/index.js';
|
|
12
12
|
import { useInternalDynamicContext } from '../../context/DynamicContext/useInternalDynamicContext.js';
|
|
13
|
+
import { createUserProfile } from '../../utils/functions/createUserProfile/createUserProfile.js';
|
|
13
14
|
import { isSupportedNetwork } from '../../utils/functions/isSupportedNetwork/isSupportedNetwork.js';
|
|
14
15
|
import { pixelToRem } from '../../utils/functions/pixelToRem/pixelToRem.js';
|
|
15
16
|
import '../../components/ShadowDOM/ShadowDOM.js';
|
|
@@ -31,20 +32,27 @@ import '../../components/IconButton/IconButton.js';
|
|
|
31
32
|
import { ErrorContainer } from '../../components/ErrorContainer/ErrorContainer.js';
|
|
32
33
|
import { NetworkPicker } from '../../components/NetworkPicker/NetworkPicker.js';
|
|
33
34
|
import { UserAddress } from '../../components/UserAddress/UserAddress.js';
|
|
35
|
+
import { useUpdateUserProfileByJWTCallback } from '../../utils/hooks/useUpdateUserProfileByJWTCallback/useUpdateUserProfileByJWTCallback.js';
|
|
34
36
|
|
|
35
37
|
const NetworkNotSupported = () => {
|
|
36
38
|
var _a, _b;
|
|
37
|
-
const { handleLogOut, network, onboardingImageUrl, selectedWalletConnector: walletConnector, setShowAuthFlow,
|
|
39
|
+
const { handleLogOut, onboardingOnlyJwt, network, onboardingImageUrl, selectedWalletConnector: walletConnector, decodedOnboardingOnlyToken, setShowAuthFlow, setCallback, } = useInternalDynamicContext();
|
|
40
|
+
const { updateUserProfileByJWT } = useUpdateUserProfileByJWTCallback();
|
|
38
41
|
const [isNetworkPickerOpen, setIsNetworkPickerOpen] = useState(false);
|
|
39
|
-
if (!walletConnector) {
|
|
42
|
+
if (!decodedOnboardingOnlyToken || !walletConnector) {
|
|
40
43
|
return null;
|
|
41
44
|
}
|
|
42
45
|
const onSubmit = () => {
|
|
46
|
+
if (!onboardingOnlyJwt)
|
|
47
|
+
return;
|
|
48
|
+
setCallback('authSuccess');
|
|
49
|
+
updateUserProfileByJWT(onboardingOnlyJwt);
|
|
43
50
|
setShowAuthFlow(false);
|
|
44
51
|
};
|
|
52
|
+
const userProfile = createUserProfile(decodedOnboardingOnlyToken);
|
|
45
53
|
const evmNetworks = walletConnector.evmNetworks || [];
|
|
46
54
|
const _isSupportedNetwork = isSupportedNetwork({ network, walletConnector });
|
|
47
|
-
return (jsxs("div", Object.assign({ className: 'network-not-supported', "data-testid": 'network-not-supported' }, { children: [onboardingImageUrl && (jsx("img", { className: 'network-not-supported__main-img', src: onboardingImageUrl, alt: 'onboarding' })), !_isSupportedNetwork && (jsx(ErrorContainer, Object.assign({ withIcon: false, className: 'network-not-supported__error--not-supported' }, { children: "This network is not available, please update." }))), jsxs("div", Object.assign({ className: 'network-not-supported__content-container' }, { children: [jsx("div", Object.assign({ className: 'network-not-supported__img-container' }, { children: ((_a =
|
|
55
|
+
return (jsxs("div", Object.assign({ className: 'network-not-supported', "data-testid": 'network-not-supported' }, { children: [onboardingImageUrl && (jsx("img", { className: 'network-not-supported__main-img', src: onboardingImageUrl, alt: 'onboarding' })), !_isSupportedNetwork && (jsx(ErrorContainer, Object.assign({ withIcon: false, className: 'network-not-supported__error--not-supported' }, { children: "This network is not available, please update." }))), jsxs("div", Object.assign({ className: 'network-not-supported__content-container' }, { children: [jsx("div", Object.assign({ className: 'network-not-supported__img-container' }, { children: ((_a = userProfile === null || userProfile === void 0 ? void 0 : userProfile.ens) === null || _a === void 0 ? void 0 : _a.avatar) ? (jsx("div", Object.assign({ className: 'network-not-supported__network-container' }, { children: jsx("img", { src: (_b = userProfile === null || userProfile === void 0 ? void 0 : userProfile.ens) === null || _b === void 0 ? void 0 : _b.avatar, alt: 'user ens avatar', className: 'network-not-supported__img' }) }))) : (jsx("div", Object.assign({ className: 'network-not-supported__network-container' }, { children: jsx(WalletIcon, { walletName: walletConnector.name, style: { height: pixelToRem(64), width: pixelToRem(64) } }) }))) })), jsx(UserAddress, { userProfile: userProfile }), jsx("div", Object.assign({ className: 'network-not-supported__network-container' }, { children: jsx(NetworkPicker, { evmNetworks: evmNetworks, connector: walletConnector, isNetworkPickerOpen: isNetworkPickerOpen, setIsNetworkPickerOpen: setIsNetworkPickerOpen, showNetworkName: true, buttonClassName: 'network-not-supported__network-picker-button', mainClassName: 'network-not-supported__network-picker' }) })), jsxs("div", Object.assign({ className: 'network-not-supported__welcome-container' }, { children: [jsx(Typography, Object.assign({ variant: 'title', color: 'primary', className: 'network-not-supported__welcome-title' }, { children: "Update Network" })), jsx(Typography, Object.assign({ variant: 'body_normal', weight: 'regular', color: 'secondary' }, { children: "Your wallet is not connected to a supported network. Please update before continuing." })), jsx(Button, Object.assign({ type: 'submit', buttonVariant: 'primary', expanded: true, buttonRounded: 'default', buttonPadding: 'large', disabled: !_isSupportedNetwork, onClick: onSubmit, buttonClassName: 'network-not-supported__continue' }, { children: "Continue" })), jsx(TextButton, Object.assign({ className: 'network-not-supported__log-out', onClick: () => handleLogOut() }, { children: "Log out" }))] }))] }))] })));
|
|
48
56
|
};
|
|
49
57
|
|
|
50
58
|
export { NetworkNotSupported };
|
|
@@ -31,12 +31,14 @@ require('../../context/CaptchaContext/CaptchaContext.cjs');
|
|
|
31
31
|
require('../../utils/hooks/useUserUpdateRequest/useUserUpdateRequest.cjs');
|
|
32
32
|
require('../../components/IconButton/IconButton.cjs');
|
|
33
33
|
var IconWithSpinner = require('../../components/IconWithSpinner/IconWithSpinner.cjs');
|
|
34
|
+
var useUpdateUserProfileByJWTCallback = require('../../utils/hooks/useUpdateUserProfileByJWTCallback/useUpdateUserProfileByJWTCallback.cjs');
|
|
34
35
|
|
|
35
36
|
// The component notifies the user about the required manual network change,
|
|
36
37
|
// as the wallet does not support programmatic network change.
|
|
37
38
|
const NetworkNotSupportedSwitchManual = () => {
|
|
38
39
|
var _a, _b;
|
|
39
|
-
const { user, network, selectedWalletConnector: walletConnector, setShowAuthFlow, } = useInternalDynamicContext.useInternalDynamicContext();
|
|
40
|
+
const { user, network, onboardingOnlyJwt, selectedWalletConnector: walletConnector, setShowAuthFlow, } = useInternalDynamicContext.useInternalDynamicContext();
|
|
41
|
+
const { updateUserProfileByJWT } = useUpdateUserProfileByJWTCallback.useUpdateUserProfileByJWTCallback();
|
|
40
42
|
// Listen for network changes
|
|
41
43
|
React.useEffect(() => {
|
|
42
44
|
if (!walletConnector)
|
|
@@ -47,11 +49,14 @@ const NetworkNotSupportedSwitchManual = () => {
|
|
|
47
49
|
});
|
|
48
50
|
// User has changed network to supported network
|
|
49
51
|
if (_isSupportedNetwork) {
|
|
50
|
-
|
|
52
|
+
// The user had an incorrect network at the time of authorization. We finish the user's authorization.
|
|
53
|
+
if (onboardingOnlyJwt) {
|
|
54
|
+
updateUserProfileByJWT(onboardingOnlyJwt);
|
|
55
|
+
setShowAuthFlow(false);
|
|
56
|
+
}
|
|
51
57
|
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
[network, walletConnector]);
|
|
58
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
59
|
+
}, [network, onboardingOnlyJwt, walletConnector, updateUserProfileByJWT]);
|
|
55
60
|
const iconSize = 80;
|
|
56
61
|
const icon = (jsxRuntime.jsx(walletBook.WalletIcon, { walletName: walletConnector === null || walletConnector === void 0 ? void 0 : walletConnector.name, style: {
|
|
57
62
|
height: pixelToRem.pixelToRem(iconSize * IconWithSpinner.iconRatio),
|
|
@@ -27,12 +27,14 @@ import '../../context/CaptchaContext/CaptchaContext.js';
|
|
|
27
27
|
import '../../utils/hooks/useUserUpdateRequest/useUserUpdateRequest.js';
|
|
28
28
|
import '../../components/IconButton/IconButton.js';
|
|
29
29
|
import { IconWithSpinner, iconRatio } from '../../components/IconWithSpinner/IconWithSpinner.js';
|
|
30
|
+
import { useUpdateUserProfileByJWTCallback } from '../../utils/hooks/useUpdateUserProfileByJWTCallback/useUpdateUserProfileByJWTCallback.js';
|
|
30
31
|
|
|
31
32
|
// The component notifies the user about the required manual network change,
|
|
32
33
|
// as the wallet does not support programmatic network change.
|
|
33
34
|
const NetworkNotSupportedSwitchManual = () => {
|
|
34
35
|
var _a, _b;
|
|
35
|
-
const { user, network, selectedWalletConnector: walletConnector, setShowAuthFlow, } = useInternalDynamicContext();
|
|
36
|
+
const { user, network, onboardingOnlyJwt, selectedWalletConnector: walletConnector, setShowAuthFlow, } = useInternalDynamicContext();
|
|
37
|
+
const { updateUserProfileByJWT } = useUpdateUserProfileByJWTCallback();
|
|
36
38
|
// Listen for network changes
|
|
37
39
|
useEffect(() => {
|
|
38
40
|
if (!walletConnector)
|
|
@@ -43,11 +45,14 @@ const NetworkNotSupportedSwitchManual = () => {
|
|
|
43
45
|
});
|
|
44
46
|
// User has changed network to supported network
|
|
45
47
|
if (_isSupportedNetwork) {
|
|
46
|
-
|
|
48
|
+
// The user had an incorrect network at the time of authorization. We finish the user's authorization.
|
|
49
|
+
if (onboardingOnlyJwt) {
|
|
50
|
+
updateUserProfileByJWT(onboardingOnlyJwt);
|
|
51
|
+
setShowAuthFlow(false);
|
|
52
|
+
}
|
|
47
53
|
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
[network, walletConnector]);
|
|
54
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
55
|
+
}, [network, onboardingOnlyJwt, walletConnector, updateUserProfileByJWT]);
|
|
51
56
|
const iconSize = 80;
|
|
52
57
|
const icon = (jsx(WalletIcon, { walletName: walletConnector === null || walletConnector === void 0 ? void 0 : walletConnector.name, style: {
|
|
53
58
|
height: pixelToRem(iconSize * iconRatio),
|