@dynamic-labs/sdk-react-core 0.17.0-RC.4 → 0.17.0-RC.6
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 +16 -0
- package/package.cjs +1 -1
- package/package.js +1 -1
- package/package.json +4 -4
- package/src/lib/utils/hooks/useUpdateUserProfileByJWTCallback/useUpdateUserProfileByJWTCallback.cjs +7 -0
- package/src/lib/utils/hooks/useUpdateUserProfileByJWTCallback/useUpdateUserProfileByJWTCallback.d.ts +7 -0
- package/src/lib/utils/hooks/useUpdateUserProfileByJWTCallback/useUpdateUserProfileByJWTCallback.js +7 -0
- package/src/lib/utils/hooks/useUserUpdateRequest/useUserUpdateRequest.cjs +19 -17
- package/src/lib/utils/hooks/useUserUpdateRequest/useUserUpdateRequest.d.ts +6 -8
- package/src/lib/utils/hooks/useUserUpdateRequest/useUserUpdateRequest.js +19 -17
- package/src/lib/utils/hooks/useVerifyWallet/useVerifyWallet.cjs +24 -26
- package/src/lib/utils/hooks/useVerifyWallet/useVerifyWallet.d.ts +1 -1
- package/src/lib/utils/hooks/useVerifyWallet/useVerifyWallet.js +24 -26
- package/src/lib/views/CollectUserDataView/UserDataForm/UserDataForm.cjs +4 -2
- package/src/lib/views/CollectUserDataView/UserDataForm/UserDataForm.js +4 -2
- package/src/lib/views/EmailVerification/EmailVerification.cjs +2 -0
- package/src/lib/views/EmailVerification/EmailVerification.js +2 -0
- package/src/lib/views/NetworkNotSupported/NetworkNotSupported.cjs +6 -7
- package/src/lib/views/NetworkNotSupported/NetworkNotSupported.js +6 -7
- package/src/lib/views/NetworkNotSupportedSwitchManual/NetworkNotSupportedSwitchManual.cjs +5 -9
- package/src/lib/views/NetworkNotSupportedSwitchManual/NetworkNotSupportedSwitchManual.js +5 -9
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,20 @@
|
|
|
1
1
|
|
|
2
|
+
## [0.17.0-RC.6](https://github.com/dynamic-labs/DynamicAuth/compare/v0.17.0-RC.5...v0.17.0-RC.6) (2023-04-25)
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
### Bug Fixes
|
|
6
|
+
|
|
7
|
+
* pass autoConnect to true on wagmi client ([#1957](https://github.com/dynamic-labs/DynamicAuth/issues/1957)) ([10b9df8](https://github.com/dynamic-labs/DynamicAuth/commit/10b9df87374e9d4c4d85b98110cc10e84ed35cb8))
|
|
8
|
+
* trigger onAuthSuccess on additional flows ([#1953](https://github.com/dynamic-labs/DynamicAuth/issues/1953)) ([a485231](https://github.com/dynamic-labs/DynamicAuth/commit/a4852312bc8a11136b391ca59d38755397c00f76))
|
|
9
|
+
|
|
10
|
+
## [0.17.0-RC.5](https://github.com/dynamic-labs/DynamicAuth/compare/v0.17.0-RC.4...v0.17.0-RC.5) (2023-04-24)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
### Bug Fixes
|
|
14
|
+
|
|
15
|
+
* **Cypress:** add polyfills ([#1945](https://github.com/dynamic-labs/DynamicAuth/issues/1945)) ([4902ecf](https://github.com/dynamic-labs/DynamicAuth/commit/4902ecf74306cc052c2df52796e1b254fb1829e5))
|
|
16
|
+
* **DYN-2261:** hide authorization flow after network switch ([#1942](https://github.com/dynamic-labs/DynamicAuth/issues/1942)) ([cc3ca53](https://github.com/dynamic-labs/DynamicAuth/commit/cc3ca5398191f18046958cc950cec25d6043fab3))
|
|
17
|
+
|
|
2
18
|
## [0.17.0-RC.4](https://github.com/dynamic-labs/DynamicAuth/compare/v0.17.0-RC.3...v0.17.0-RC.4) (2023-04-22)
|
|
3
19
|
|
|
4
20
|
|
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.17.0-RC.
|
|
3
|
+
"version": "0.17.0-RC.6",
|
|
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.17.0-RC.
|
|
21
|
-
"@dynamic-labs/multi-wallet": "0.17.0-RC.
|
|
22
|
-
"@dynamic-labs/wallet-connector-core": "0.17.0-RC.
|
|
20
|
+
"@dynamic-labs/logger": "0.17.0-RC.6",
|
|
21
|
+
"@dynamic-labs/multi-wallet": "0.17.0-RC.6",
|
|
22
|
+
"@dynamic-labs/wallet-connector-core": "0.17.0-RC.6"
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
25
|
"semver": "^7.3.8"
|
package/src/lib/utils/hooks/useUpdateUserProfileByJWTCallback/useUpdateUserProfileByJWTCallback.cjs
CHANGED
|
@@ -6,6 +6,13 @@ var React = require('react');
|
|
|
6
6
|
var useInternalDynamicContext = require('../../../context/DynamicContext/useInternalDynamicContext.cjs');
|
|
7
7
|
var useCreateUserProfileByJWTCallback = require('../useCreateUserProfileByJWTCallback/useCreateUserProfileByJWTCallback.cjs');
|
|
8
8
|
|
|
9
|
+
/**
|
|
10
|
+
* A custom React hook that returns a function to update the user profile using a JSON Web Token (JWT).
|
|
11
|
+
* This hook internally uses the 'useCreateUserProfileByJWTCallback' hook to create the user profile by JWT
|
|
12
|
+
* and the 'useInternalDynamicContext' hook to set the callback for when the user profile is updated.
|
|
13
|
+
* The returned function uses 'useCallback' to memoize the function and optimize performance.
|
|
14
|
+
* @returns An object with the 'updateUserProfileByJWT' function.
|
|
15
|
+
*/
|
|
9
16
|
const useUpdateUserProfileByJWTCallback = () => {
|
|
10
17
|
const { createUserProfileByJWT } = useCreateUserProfileByJWTCallback.useCreateUserProfileByJWTCallback();
|
|
11
18
|
const { setCallback } = useInternalDynamicContext.useInternalDynamicContext();
|
package/src/lib/utils/hooks/useUpdateUserProfileByJWTCallback/useUpdateUserProfileByJWTCallback.d.ts
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A custom React hook that returns a function to update the user profile using a JSON Web Token (JWT).
|
|
3
|
+
* This hook internally uses the 'useCreateUserProfileByJWTCallback' hook to create the user profile by JWT
|
|
4
|
+
* and the 'useInternalDynamicContext' hook to set the callback for when the user profile is updated.
|
|
5
|
+
* The returned function uses 'useCallback' to memoize the function and optimize performance.
|
|
6
|
+
* @returns An object with the 'updateUserProfileByJWT' function.
|
|
7
|
+
*/
|
|
1
8
|
export declare const useUpdateUserProfileByJWTCallback: () => {
|
|
2
9
|
updateUserProfileByJWT: (jwt: string) => void;
|
|
3
10
|
};
|
package/src/lib/utils/hooks/useUpdateUserProfileByJWTCallback/useUpdateUserProfileByJWTCallback.js
CHANGED
|
@@ -2,6 +2,13 @@ import { useCallback } from 'react';
|
|
|
2
2
|
import { useInternalDynamicContext } from '../../../context/DynamicContext/useInternalDynamicContext.js';
|
|
3
3
|
import { useCreateUserProfileByJWTCallback } from '../useCreateUserProfileByJWTCallback/useCreateUserProfileByJWTCallback.js';
|
|
4
4
|
|
|
5
|
+
/**
|
|
6
|
+
* A custom React hook that returns a function to update the user profile using a JSON Web Token (JWT).
|
|
7
|
+
* This hook internally uses the 'useCreateUserProfileByJWTCallback' hook to create the user profile by JWT
|
|
8
|
+
* and the 'useInternalDynamicContext' hook to set the callback for when the user profile is updated.
|
|
9
|
+
* The returned function uses 'useCallback' to memoize the function and optimize performance.
|
|
10
|
+
* @returns An object with the 'updateUserProfileByJWT' function.
|
|
11
|
+
*/
|
|
5
12
|
const useUpdateUserProfileByJWTCallback = () => {
|
|
6
13
|
const { createUserProfileByJWT } = useCreateUserProfileByJWTCallback();
|
|
7
14
|
const { setCallback } = useInternalDynamicContext();
|
|
@@ -32,7 +32,23 @@ 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
|
-
|
|
35
|
+
const handleEmailVerification = () => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
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
|
+
});
|
|
36
52
|
const validatedUserFields = yield userFieldsSchema.validate(userFields, {
|
|
37
53
|
stripUnknown: validationSchemaStripUnknown,
|
|
38
54
|
});
|
|
@@ -42,25 +58,11 @@ const useUserUpdateRequestInternal = ({ validationSchemaStripUnknown, }) => {
|
|
|
42
58
|
// If email verification is not needed then we can update the user profile immediately.
|
|
43
59
|
updateUserProfileByJWT(updateUserProfileResponse.jwt);
|
|
44
60
|
return {
|
|
45
|
-
isEmailVerificationRequired:
|
|
61
|
+
isEmailVerificationRequired: false,
|
|
46
62
|
updateUserProfileResponse,
|
|
47
63
|
};
|
|
48
64
|
}
|
|
49
|
-
|
|
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
|
-
};
|
|
65
|
+
return handleEmailVerification();
|
|
64
66
|
}), [
|
|
65
67
|
environmentId,
|
|
66
68
|
jwtToken,
|
|
@@ -4,23 +4,21 @@ export declare const useUserUpdateRequestInternal: ({ validationSchemaStripUnkno
|
|
|
4
4
|
validationSchemaStripUnknown: boolean;
|
|
5
5
|
}) => {
|
|
6
6
|
updateUser: (userFields: UpdateUserFieldsArg, userEnvironmentId?: string) => Promise<{
|
|
7
|
-
isEmailVerificationRequired:
|
|
7
|
+
isEmailVerificationRequired: boolean;
|
|
8
8
|
updateUserProfileResponse: import("@dynamic-labs/sdk-api").UpdateSelfResponse;
|
|
9
|
-
verifyEmailFn
|
|
9
|
+
verifyEmailFn: (verificationToken: string) => Promise<import("@dynamic-labs/sdk-api").UpdateSelfResponse>;
|
|
10
10
|
} | {
|
|
11
|
-
isEmailVerificationRequired:
|
|
11
|
+
isEmailVerificationRequired: boolean;
|
|
12
12
|
updateUserProfileResponse: import("@dynamic-labs/sdk-api").UpdateSelfResponse;
|
|
13
|
-
verifyEmailFn: (verificationToken: string) => Promise<import("@dynamic-labs/sdk-api").UpdateSelfResponse>;
|
|
14
13
|
}>;
|
|
15
14
|
};
|
|
16
15
|
export declare const useUserUpdateRequest: () => {
|
|
17
16
|
updateUser: (userFields: UpdateUserFieldsArg, userEnvironmentId?: string) => Promise<{
|
|
18
|
-
isEmailVerificationRequired:
|
|
17
|
+
isEmailVerificationRequired: boolean;
|
|
19
18
|
updateUserProfileResponse: import("@dynamic-labs/sdk-api").UpdateSelfResponse;
|
|
20
|
-
verifyEmailFn
|
|
19
|
+
verifyEmailFn: (verificationToken: string) => Promise<import("@dynamic-labs/sdk-api").UpdateSelfResponse>;
|
|
21
20
|
} | {
|
|
22
|
-
isEmailVerificationRequired:
|
|
21
|
+
isEmailVerificationRequired: boolean;
|
|
23
22
|
updateUserProfileResponse: import("@dynamic-labs/sdk-api").UpdateSelfResponse;
|
|
24
|
-
verifyEmailFn: (verificationToken: string) => Promise<import("@dynamic-labs/sdk-api").UpdateSelfResponse>;
|
|
25
23
|
}>;
|
|
26
24
|
};
|
|
@@ -28,7 +28,23 @@ 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
|
-
|
|
31
|
+
const handleEmailVerification = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
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
|
+
});
|
|
32
48
|
const validatedUserFields = yield userFieldsSchema.validate(userFields, {
|
|
33
49
|
stripUnknown: validationSchemaStripUnknown,
|
|
34
50
|
});
|
|
@@ -38,25 +54,11 @@ const useUserUpdateRequestInternal = ({ validationSchemaStripUnknown, }) => {
|
|
|
38
54
|
// If email verification is not needed then we can update the user profile immediately.
|
|
39
55
|
updateUserProfileByJWT(updateUserProfileResponse.jwt);
|
|
40
56
|
return {
|
|
41
|
-
isEmailVerificationRequired:
|
|
57
|
+
isEmailVerificationRequired: false,
|
|
42
58
|
updateUserProfileResponse,
|
|
43
59
|
};
|
|
44
60
|
}
|
|
45
|
-
|
|
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
|
-
};
|
|
61
|
+
return handleEmailVerification();
|
|
60
62
|
}), [
|
|
61
63
|
environmentId,
|
|
62
64
|
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,
|
|
32
|
+
const useVerifyWallet = ({ consumeNonce, displayTermsOfService, environmentId, 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, p
|
|
|
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
|
+
}
|
|
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, decodedJwt) => {
|
|
71
|
+
const newSelectedCredentialWallet = decodedJwt.verifiedCredentials.find((cred) => cred.id === decodedJwt.lastVerifiedCredentialId &&
|
|
72
72
|
cred.format === 'blockchain');
|
|
73
73
|
if (newSelectedCredentialWallet) {
|
|
74
|
-
const currentPrimaryWallet =
|
|
74
|
+
const currentPrimaryWallet = decodedJwt.verifiedCredentials.find((a) => a.id === primaryWalletId);
|
|
75
75
|
if (verifyOnly ||
|
|
76
76
|
primaryWalletId === undefined ||
|
|
77
77
|
(multiWalletWidgetState === 'awaiting_signature' &&
|
|
@@ -128,31 +128,18 @@ const useVerifyWallet = ({ consumeNonce, displayTermsOfService, environmentId, p
|
|
|
128
128
|
const decodedJwt = decodeJwt.decodeJwt(Jwt);
|
|
129
129
|
if (decodedJwt === undefined)
|
|
130
130
|
throw new multiWallet.DynamicError('Invalid token!');
|
|
131
|
-
const user = yield createUserProfile.createUserProfile(decodedJwt);
|
|
132
|
-
const isKycRequired = decodedJwt.missingFields.length;
|
|
133
|
-
setOnboardingOnlyJwt(Jwt);
|
|
134
131
|
setToLS.setToLS(localStorage.LAST_USED_WALLET, walletConnector.name);
|
|
135
|
-
updatePrimaryWalletId(walletConnector,
|
|
136
|
-
|
|
137
|
-
if (
|
|
138
|
-
|
|
139
|
-
!_isSupportedNetwork &&
|
|
140
|
-
!isKycRequired) {
|
|
141
|
-
const _isProgrammableNetworkSwitchSupported = isProgrammableNetworkSwitchSupported.isProgrammableNetworkSwitchSupported(walletConnector);
|
|
142
|
-
if (_isProgrammableNetworkSwitchSupported) {
|
|
143
|
-
return setView('network-not-supported');
|
|
144
|
-
}
|
|
145
|
-
return setView('network-not-supported-manual');
|
|
146
|
-
}
|
|
147
|
-
// TODO: how can projectSettings be undefined?
|
|
148
|
-
if (verifyOnly && projectSettings && isKycRequired) {
|
|
132
|
+
updatePrimaryWalletId(walletConnector, decodedJwt);
|
|
133
|
+
const isKycRequired = decodedJwt.missingFields.length;
|
|
134
|
+
if (verifyOnly && isKycRequired) {
|
|
135
|
+
setOnboardingOnlyJwt(Jwt);
|
|
149
136
|
setShowAuthFlow(true);
|
|
150
|
-
|
|
137
|
+
setView('collect-user-data');
|
|
138
|
+
return;
|
|
151
139
|
}
|
|
140
|
+
const user = yield createUserProfile.createUserProfile(decodedJwt);
|
|
152
141
|
index.storeAuthToken(Jwt);
|
|
153
|
-
setOnboardingOnlyJwt(undefined);
|
|
154
142
|
setUser(user); // The user should only be set if no KYC is needed.
|
|
155
|
-
setShowAuthFlow(false);
|
|
156
143
|
/* istanbul ignore else */
|
|
157
144
|
if (verifyOnly) {
|
|
158
145
|
setCallback('authSuccess');
|
|
@@ -161,6 +148,17 @@ const useVerifyWallet = ({ consumeNonce, displayTermsOfService, environmentId, p
|
|
|
161
148
|
setView('wallet-list');
|
|
162
149
|
setCallback('linkSuccess');
|
|
163
150
|
}
|
|
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);
|
|
164
162
|
}
|
|
165
163
|
catch (e) {
|
|
166
164
|
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,
|
|
8
|
+
export declare const useVerifyWallet: ({ consumeNonce, displayTermsOfService, environmentId, 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,
|
|
28
|
+
const useVerifyWallet = ({ consumeNonce, displayTermsOfService, environmentId, 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, p
|
|
|
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
|
+
}
|
|
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, decodedJwt) => {
|
|
67
|
+
const newSelectedCredentialWallet = decodedJwt.verifiedCredentials.find((cred) => cred.id === decodedJwt.lastVerifiedCredentialId &&
|
|
68
68
|
cred.format === 'blockchain');
|
|
69
69
|
if (newSelectedCredentialWallet) {
|
|
70
|
-
const currentPrimaryWallet =
|
|
70
|
+
const currentPrimaryWallet = decodedJwt.verifiedCredentials.find((a) => a.id === primaryWalletId);
|
|
71
71
|
if (verifyOnly ||
|
|
72
72
|
primaryWalletId === undefined ||
|
|
73
73
|
(multiWalletWidgetState === 'awaiting_signature' &&
|
|
@@ -124,31 +124,18 @@ const useVerifyWallet = ({ consumeNonce, displayTermsOfService, environmentId, p
|
|
|
124
124
|
const decodedJwt = decodeJwt(Jwt);
|
|
125
125
|
if (decodedJwt === undefined)
|
|
126
126
|
throw new DynamicError('Invalid token!');
|
|
127
|
-
const user = yield createUserProfile(decodedJwt);
|
|
128
|
-
const isKycRequired = decodedJwt.missingFields.length;
|
|
129
|
-
setOnboardingOnlyJwt(Jwt);
|
|
130
127
|
setToLS(LAST_USED_WALLET, walletConnector.name);
|
|
131
|
-
updatePrimaryWalletId(walletConnector,
|
|
132
|
-
|
|
133
|
-
if (
|
|
134
|
-
|
|
135
|
-
!_isSupportedNetwork &&
|
|
136
|
-
!isKycRequired) {
|
|
137
|
-
const _isProgrammableNetworkSwitchSupported = isProgrammableNetworkSwitchSupported(walletConnector);
|
|
138
|
-
if (_isProgrammableNetworkSwitchSupported) {
|
|
139
|
-
return setView('network-not-supported');
|
|
140
|
-
}
|
|
141
|
-
return setView('network-not-supported-manual');
|
|
142
|
-
}
|
|
143
|
-
// TODO: how can projectSettings be undefined?
|
|
144
|
-
if (verifyOnly && projectSettings && isKycRequired) {
|
|
128
|
+
updatePrimaryWalletId(walletConnector, decodedJwt);
|
|
129
|
+
const isKycRequired = decodedJwt.missingFields.length;
|
|
130
|
+
if (verifyOnly && isKycRequired) {
|
|
131
|
+
setOnboardingOnlyJwt(Jwt);
|
|
145
132
|
setShowAuthFlow(true);
|
|
146
|
-
|
|
133
|
+
setView('collect-user-data');
|
|
134
|
+
return;
|
|
147
135
|
}
|
|
136
|
+
const user = yield createUserProfile(decodedJwt);
|
|
148
137
|
storeAuthToken(Jwt);
|
|
149
|
-
setOnboardingOnlyJwt(undefined);
|
|
150
138
|
setUser(user); // The user should only be set if no KYC is needed.
|
|
151
|
-
setShowAuthFlow(false);
|
|
152
139
|
/* istanbul ignore else */
|
|
153
140
|
if (verifyOnly) {
|
|
154
141
|
setCallback('authSuccess');
|
|
@@ -157,6 +144,17 @@ const useVerifyWallet = ({ consumeNonce, displayTermsOfService, environmentId, p
|
|
|
157
144
|
setView('wallet-list');
|
|
158
145
|
setCallback('linkSuccess');
|
|
159
146
|
}
|
|
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);
|
|
160
158
|
}
|
|
161
159
|
catch (e) {
|
|
162
160
|
handleError(e, walletConnector);
|
|
@@ -33,8 +33,9 @@ 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
|
|
36
37
|
const UserDataForm = ({ children, userProfile }) => {
|
|
37
|
-
const { policiesConsentInnerComponent, onboardingOnlyJwt, setShowAuthFlow } = useInternalDynamicContext.useInternalDynamicContext();
|
|
38
|
+
const { policiesConsentInnerComponent, onboardingOnlyJwt, setShowAuthFlow, setCallback, } = useInternalDynamicContext.useInternalDynamicContext();
|
|
38
39
|
const { setView } = ViewContext.useViewContext();
|
|
39
40
|
const decodedJwt = decodeJwt.decodeJwt(onboardingOnlyJwt);
|
|
40
41
|
const { updateUser } = useUserUpdateRequest.useUserUpdateRequestInternal({
|
|
@@ -46,8 +47,9 @@ const UserDataForm = ({ children, userProfile }) => {
|
|
|
46
47
|
setView('verify-email');
|
|
47
48
|
return;
|
|
48
49
|
}
|
|
50
|
+
setCallback('authSuccess');
|
|
49
51
|
setShowAuthFlow(false);
|
|
50
|
-
}), [setShowAuthFlow, setView, updateUser]);
|
|
52
|
+
}), [setCallback, setShowAuthFlow, setView, updateUser]);
|
|
51
53
|
const { fetch: loading, formikInitialValues, formikValidationSchema, enforcePolicies, onFormSubmit, } = useUserDataForm.useUserDataForm({
|
|
52
54
|
fields: (decodedJwt === null || decodedJwt === void 0 ? void 0 : decodedJwt.missingFields) || [],
|
|
53
55
|
onSubmit,
|
|
@@ -29,8 +29,9 @@ 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
|
|
32
33
|
const UserDataForm = ({ children, userProfile }) => {
|
|
33
|
-
const { policiesConsentInnerComponent, onboardingOnlyJwt, setShowAuthFlow } = useInternalDynamicContext();
|
|
34
|
+
const { policiesConsentInnerComponent, onboardingOnlyJwt, setShowAuthFlow, setCallback, } = useInternalDynamicContext();
|
|
34
35
|
const { setView } = useViewContext();
|
|
35
36
|
const decodedJwt = decodeJwt(onboardingOnlyJwt);
|
|
36
37
|
const { updateUser } = useUserUpdateRequestInternal({
|
|
@@ -42,8 +43,9 @@ const UserDataForm = ({ children, userProfile }) => {
|
|
|
42
43
|
setView('verify-email');
|
|
43
44
|
return;
|
|
44
45
|
}
|
|
46
|
+
setCallback('authSuccess');
|
|
45
47
|
setShowAuthFlow(false);
|
|
46
|
-
}), [setShowAuthFlow, setView, updateUser]);
|
|
48
|
+
}), [setCallback, setShowAuthFlow, setView, updateUser]);
|
|
47
49
|
const { fetch: loading, formikInitialValues, formikValidationSchema, enforcePolicies, onFormSubmit, } = useUserDataForm({
|
|
48
50
|
fields: (decodedJwt === null || decodedJwt === void 0 ? void 0 : decodedJwt.missingFields) || [],
|
|
49
51
|
onSubmit,
|
|
@@ -71,6 +71,7 @@ const EmailVerification = () => {
|
|
|
71
71
|
const { nextView } = yield verifyEmail(verificationToken, verificationUUID);
|
|
72
72
|
if (onboardingOnlyJwt) {
|
|
73
73
|
setOnboardingOnlyJwt(undefined);
|
|
74
|
+
setCallback('authSuccess');
|
|
74
75
|
}
|
|
75
76
|
setIsValidated(true);
|
|
76
77
|
if (nextView === 'verified-and-transferred') {
|
|
@@ -85,6 +86,7 @@ const EmailVerification = () => {
|
|
|
85
86
|
setLoading(false);
|
|
86
87
|
}
|
|
87
88
|
}), [
|
|
89
|
+
setCallback,
|
|
88
90
|
setError,
|
|
89
91
|
setLoading,
|
|
90
92
|
verificationUUID,
|
|
@@ -67,6 +67,7 @@ const EmailVerification = () => {
|
|
|
67
67
|
const { nextView } = yield verifyEmail(verificationToken, verificationUUID);
|
|
68
68
|
if (onboardingOnlyJwt) {
|
|
69
69
|
setOnboardingOnlyJwt(undefined);
|
|
70
|
+
setCallback('authSuccess');
|
|
70
71
|
}
|
|
71
72
|
setIsValidated(true);
|
|
72
73
|
if (nextView === 'verified-and-transferred') {
|
|
@@ -81,6 +82,7 @@ const EmailVerification = () => {
|
|
|
81
82
|
setLoading(false);
|
|
82
83
|
}
|
|
83
84
|
}), [
|
|
85
|
+
setCallback,
|
|
84
86
|
setError,
|
|
85
87
|
setLoading,
|
|
86
88
|
verificationUUID,
|
|
@@ -14,7 +14,6 @@ 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');
|
|
18
17
|
var isSupportedNetwork = require('../../utils/functions/isSupportedNetwork/isSupportedNetwork.cjs');
|
|
19
18
|
var pixelToRem = require('../../utils/functions/pixelToRem/pixelToRem.cjs');
|
|
20
19
|
require('../../components/ShadowDOM/ShadowDOM.cjs');
|
|
@@ -36,20 +35,20 @@ require('../../components/IconButton/IconButton.cjs');
|
|
|
36
35
|
var ErrorContainer = require('../../components/ErrorContainer/ErrorContainer.cjs');
|
|
37
36
|
var NetworkPicker = require('../../components/NetworkPicker/NetworkPicker.cjs');
|
|
38
37
|
var UserAddress = require('../../components/UserAddress/UserAddress.cjs');
|
|
39
|
-
var useUpdateUserProfileByJWTCallback = require('../../utils/hooks/useUpdateUserProfileByJWTCallback/useUpdateUserProfileByJWTCallback.cjs');
|
|
40
38
|
|
|
41
39
|
const NetworkNotSupported = () => {
|
|
42
40
|
var _a, _b;
|
|
43
|
-
const { handleLogOut,
|
|
44
|
-
const { updateUserProfileByJWT } = useUpdateUserProfileByJWTCallback.useUpdateUserProfileByJWTCallback();
|
|
41
|
+
const { handleLogOut, network, onboardingImageUrl, selectedWalletConnector: walletConnector, setShowAuthFlow, user, } = useInternalDynamicContext.useInternalDynamicContext();
|
|
45
42
|
const [isNetworkPickerOpen, setIsNetworkPickerOpen] = React.useState(false);
|
|
46
|
-
if (!
|
|
43
|
+
if (!walletConnector) {
|
|
47
44
|
return null;
|
|
48
45
|
}
|
|
49
|
-
const
|
|
46
|
+
const onSubmit = () => {
|
|
47
|
+
setShowAuthFlow(false);
|
|
48
|
+
};
|
|
50
49
|
const evmNetworks = walletConnector.evmNetworks || [];
|
|
51
50
|
const _isSupportedNetwork = isSupportedNetwork.isSupportedNetwork({ network, walletConnector });
|
|
52
|
-
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 =
|
|
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 = user === null || user === void 0 ? void 0 : user.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 = user === null || user === void 0 ? void 0 : user.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: user }), 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" }))] }))] }))] })));
|
|
53
52
|
};
|
|
54
53
|
|
|
55
54
|
exports.NetworkNotSupported = NetworkNotSupported;
|
|
@@ -10,7 +10,6 @@ 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';
|
|
14
13
|
import { isSupportedNetwork } from '../../utils/functions/isSupportedNetwork/isSupportedNetwork.js';
|
|
15
14
|
import { pixelToRem } from '../../utils/functions/pixelToRem/pixelToRem.js';
|
|
16
15
|
import '../../components/ShadowDOM/ShadowDOM.js';
|
|
@@ -32,20 +31,20 @@ import '../../components/IconButton/IconButton.js';
|
|
|
32
31
|
import { ErrorContainer } from '../../components/ErrorContainer/ErrorContainer.js';
|
|
33
32
|
import { NetworkPicker } from '../../components/NetworkPicker/NetworkPicker.js';
|
|
34
33
|
import { UserAddress } from '../../components/UserAddress/UserAddress.js';
|
|
35
|
-
import { useUpdateUserProfileByJWTCallback } from '../../utils/hooks/useUpdateUserProfileByJWTCallback/useUpdateUserProfileByJWTCallback.js';
|
|
36
34
|
|
|
37
35
|
const NetworkNotSupported = () => {
|
|
38
36
|
var _a, _b;
|
|
39
|
-
const { handleLogOut,
|
|
40
|
-
const { updateUserProfileByJWT } = useUpdateUserProfileByJWTCallback();
|
|
37
|
+
const { handleLogOut, network, onboardingImageUrl, selectedWalletConnector: walletConnector, setShowAuthFlow, user, } = useInternalDynamicContext();
|
|
41
38
|
const [isNetworkPickerOpen, setIsNetworkPickerOpen] = useState(false);
|
|
42
|
-
if (!
|
|
39
|
+
if (!walletConnector) {
|
|
43
40
|
return null;
|
|
44
41
|
}
|
|
45
|
-
const
|
|
42
|
+
const onSubmit = () => {
|
|
43
|
+
setShowAuthFlow(false);
|
|
44
|
+
};
|
|
46
45
|
const evmNetworks = walletConnector.evmNetworks || [];
|
|
47
46
|
const _isSupportedNetwork = isSupportedNetwork({ network, walletConnector });
|
|
48
|
-
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 =
|
|
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 = user === null || user === void 0 ? void 0 : user.ens) === null || _a === void 0 ? void 0 : _a.avatar) ? (jsx("div", Object.assign({ className: 'network-not-supported__network-container' }, { children: jsx("img", { src: (_b = user === null || user === void 0 ? void 0 : user.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: user }), 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" }))] }))] }))] })));
|
|
49
48
|
};
|
|
50
49
|
|
|
51
50
|
export { NetworkNotSupported };
|
|
@@ -31,14 +31,12 @@ 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');
|
|
35
34
|
|
|
36
35
|
// The component notifies the user about the required manual network change,
|
|
37
36
|
// as the wallet does not support programmatic network change.
|
|
38
37
|
const NetworkNotSupportedSwitchManual = () => {
|
|
39
38
|
var _a, _b;
|
|
40
|
-
const { user, network,
|
|
41
|
-
const { updateUserProfileByJWT } = useUpdateUserProfileByJWTCallback.useUpdateUserProfileByJWTCallback();
|
|
39
|
+
const { user, network, selectedWalletConnector: walletConnector, setShowAuthFlow, } = useInternalDynamicContext.useInternalDynamicContext();
|
|
42
40
|
// Listen for network changes
|
|
43
41
|
React.useEffect(() => {
|
|
44
42
|
if (!walletConnector)
|
|
@@ -49,13 +47,11 @@ const NetworkNotSupportedSwitchManual = () => {
|
|
|
49
47
|
});
|
|
50
48
|
// User has changed network to supported network
|
|
51
49
|
if (_isSupportedNetwork) {
|
|
52
|
-
|
|
53
|
-
if (onboardingOnlyJwt) {
|
|
54
|
-
updateUserProfileByJWT(onboardingOnlyJwt);
|
|
55
|
-
}
|
|
50
|
+
setShowAuthFlow(false);
|
|
56
51
|
}
|
|
57
|
-
|
|
58
|
-
|
|
52
|
+
},
|
|
53
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
54
|
+
[network, walletConnector]);
|
|
59
55
|
const iconSize = 80;
|
|
60
56
|
const icon = (jsxRuntime.jsx(walletBook.WalletIcon, { walletName: walletConnector === null || walletConnector === void 0 ? void 0 : walletConnector.name, style: {
|
|
61
57
|
height: pixelToRem.pixelToRem(iconSize * IconWithSpinner.iconRatio),
|
|
@@ -27,14 +27,12 @@ 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';
|
|
31
30
|
|
|
32
31
|
// The component notifies the user about the required manual network change,
|
|
33
32
|
// as the wallet does not support programmatic network change.
|
|
34
33
|
const NetworkNotSupportedSwitchManual = () => {
|
|
35
34
|
var _a, _b;
|
|
36
|
-
const { user, network,
|
|
37
|
-
const { updateUserProfileByJWT } = useUpdateUserProfileByJWTCallback();
|
|
35
|
+
const { user, network, selectedWalletConnector: walletConnector, setShowAuthFlow, } = useInternalDynamicContext();
|
|
38
36
|
// Listen for network changes
|
|
39
37
|
useEffect(() => {
|
|
40
38
|
if (!walletConnector)
|
|
@@ -45,13 +43,11 @@ const NetworkNotSupportedSwitchManual = () => {
|
|
|
45
43
|
});
|
|
46
44
|
// User has changed network to supported network
|
|
47
45
|
if (_isSupportedNetwork) {
|
|
48
|
-
|
|
49
|
-
if (onboardingOnlyJwt) {
|
|
50
|
-
updateUserProfileByJWT(onboardingOnlyJwt);
|
|
51
|
-
}
|
|
46
|
+
setShowAuthFlow(false);
|
|
52
47
|
}
|
|
53
|
-
|
|
54
|
-
|
|
48
|
+
},
|
|
49
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
50
|
+
[network, walletConnector]);
|
|
55
51
|
const iconSize = 80;
|
|
56
52
|
const icon = (jsx(WalletIcon, { walletName: walletConnector === null || walletConnector === void 0 ? void 0 : walletConnector.name, style: {
|
|
57
53
|
height: pixelToRem(iconSize * iconRatio),
|