@dynamic-labs/sdk-react-core 2.1.2-alpha.0 → 2.1.2
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 +24 -0
- package/package.cjs +1 -1
- package/package.js +1 -1
- package/package.json +13 -13
- package/src/lib/components/PhoneNumberField/PhoneNumberField.cjs +3 -0
- package/src/lib/components/PhoneNumberField/PhoneNumberField.js +3 -0
- package/src/lib/components/PhoneNumberField/usePhoneInputLogic/usePhoneInputLogic.cjs +10 -19
- package/src/lib/components/PhoneNumberField/usePhoneInputLogic/usePhoneInputLogic.d.ts +3 -2
- package/src/lib/components/PhoneNumberField/usePhoneInputLogic/usePhoneInputLogic.js +12 -21
- package/src/lib/components/PhoneNumberField/utils/parseDefaultCountry/index.d.ts +1 -0
- package/src/lib/components/PhoneNumberField/utils/parseDefaultCountry/parseDefaultCountry.cjs +57 -0
- package/src/lib/components/PhoneNumberField/utils/parseDefaultCountry/parseDefaultCountry.d.ts +8 -0
- package/src/lib/components/PhoneNumberField/utils/parseDefaultCountry/parseDefaultCountry.js +53 -0
- package/src/lib/components/Step/index.d.ts +1 -0
- package/src/lib/context/DynamicContext/DynamicContext.cjs +3 -1
- package/src/lib/context/DynamicContext/DynamicContext.d.ts +2 -0
- package/src/lib/context/DynamicContext/DynamicContext.js +3 -1
- package/src/lib/context/DynamicContext/types/index.d.ts +2 -0
- package/src/lib/utils/functions/getOauthLoginUrl/getOauthLoginUrl.cjs +0 -1
- package/src/lib/utils/functions/getOauthLoginUrl/getOauthLoginUrl.js +0 -1
- package/src/lib/utils/functions/walletListBuilder/utils/staticLinkedWalletFilter/index.d.ts +1 -0
- package/src/lib/utils/functions/walletListBuilder/utils/staticLinkedWalletFilter/staticLinkedWalletFilter.cjs +30 -0
- package/src/lib/utils/functions/walletListBuilder/utils/staticLinkedWalletFilter/staticLinkedWalletFilter.d.ts +6 -0
- package/src/lib/utils/functions/walletListBuilder/utils/staticLinkedWalletFilter/staticLinkedWalletFilter.js +26 -0
- package/src/lib/utils/functions/walletListBuilder/walletListBuilder.cjs +5 -1
- package/src/lib/utils/functions/walletListBuilder/walletListBuilder.d.ts +2 -1
- package/src/lib/utils/functions/walletListBuilder/walletListBuilder.js +5 -1
- package/src/lib/views/EmailVerification/EmailVerification.cjs +33 -41
- package/src/lib/views/EmailVerification/EmailVerification.js +33 -41
- package/src/lib/views/LoginView/sections/WalletSignInSection/WalletSimpleSignIn/WalletSimpleSignIn.cjs +2 -1
- package/src/lib/views/LoginView/sections/WalletSignInSection/WalletSimpleSignIn/WalletSimpleSignIn.js +2 -1
- package/src/lib/views/WalletList/WalletList.cjs +2 -1
- package/src/lib/views/WalletList/WalletList.js +2 -1
- package/src/lib/widgets/DynamicMultiWalletPromptsWidget/DynamicMultiWalletPromptsWidget.cjs +9 -2
- package/src/lib/widgets/DynamicMultiWalletPromptsWidget/DynamicMultiWalletPromptsWidget.js +9 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,28 @@
|
|
|
1
1
|
|
|
2
|
+
### [2.1.2](https://github.com/dynamic-labs/DynamicAuth/compare/v2.1.2-alpha.1...v2.1.2) (2024-06-10)
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
### Features
|
|
6
|
+
|
|
7
|
+
* hide wallets from wallet list that can't have multiple accounts linked ([#5935](https://github.com/dynamic-labs/DynamicAuth/issues/5935)) ([20f9b15](https://github.com/dynamic-labs/DynamicAuth/commit/20f9b15b145cbc57519155691b3640149eec3689))
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
### Bug Fixes
|
|
11
|
+
|
|
12
|
+
* ensure sign message will not show 2 times ([#5938](https://github.com/dynamic-labs/DynamicAuth/issues/5938)) ([#5941](https://github.com/dynamic-labs/DynamicAuth/issues/5941)) ([2c5a156](https://github.com/dynamic-labs/DynamicAuth/commit/2c5a156ead565bd25067b3bc2b23cbc704f9b314))
|
|
13
|
+
* improve logic related to embedded wallets and emailVerifcation ([#5947](https://github.com/dynamic-labs/DynamicAuth/issues/5947)) ([b885a14](https://github.com/dynamic-labs/DynamicAuth/commit/b885a14dcf200f05233e4ab42b8b518d877d291a))
|
|
14
|
+
* init coinbase provider adhoc ([#5907](https://github.com/dynamic-labs/DynamicAuth/issues/5907)) ([#5933](https://github.com/dynamic-labs/DynamicAuth/issues/5933)) ([2fa1f52](https://github.com/dynamic-labs/DynamicAuth/commit/2fa1f528b27113ee108252ee874ee7f5ead88329))
|
|
15
|
+
* remove force consent and account selection even for returning google users ([#5912](https://github.com/dynamic-labs/DynamicAuth/issues/5912)) ([26a07f2](https://github.com/dynamic-labs/DynamicAuth/commit/26a07f29bdb8bf32a080396906a21d8b084c202f))
|
|
16
|
+
* resolve the default phone country based on enabled countries ([#5](https://github.com/dynamic-labs/DynamicAuth/issues/5)… ([#5916](https://github.com/dynamic-labs/DynamicAuth/issues/5916)) ([8f27c00](https://github.com/dynamic-labs/DynamicAuth/commit/8f27c0082edb77b964b8402cfa75c6a896b061d3)), closes [#5910](https://github.com/dynamic-labs/DynamicAuth/issues/5910)
|
|
17
|
+
* versioned tx needs address lookup table ([#5909](https://github.com/dynamic-labs/DynamicAuth/issues/5909)) ([#5919](https://github.com/dynamic-labs/DynamicAuth/issues/5919)) ([22e3ca2](https://github.com/dynamic-labs/DynamicAuth/commit/22e3ca2d0b27d15efb50e3092a7bc3a0c0d255a5))
|
|
18
|
+
|
|
19
|
+
### [2.1.2-alpha.1](https://github.com/dynamic-labs/DynamicAuth/compare/v2.1.2-alpha.0...v2.1.2-alpha.1) (2024-06-07)
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
### Bug Fixes
|
|
23
|
+
|
|
24
|
+
* find phantom solana provider when opening dapp on new tab ([#5902](https://github.com/dynamic-labs/DynamicAuth/issues/5902)) ([99daf87](https://github.com/dynamic-labs/DynamicAuth/commit/99daf87f17caed870a76e4f89a257a14da37c7ab)), closes [#5895](https://github.com/dynamic-labs/DynamicAuth/issues/5895) [#5896](https://github.com/dynamic-labs/DynamicAuth/issues/5896) [#5897](https://github.com/dynamic-labs/DynamicAuth/issues/5897)
|
|
25
|
+
|
|
2
26
|
### [2.1.2-alpha.0](https://github.com/dynamic-labs/DynamicAuth/compare/v2.1.1...v2.1.2-alpha.0) (2024-06-07)
|
|
3
27
|
|
|
4
28
|
|
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": "2.1.2
|
|
3
|
+
"version": "2.1.2",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/dynamic-labs/dynamic-auth.git",
|
|
@@ -17,18 +17,18 @@
|
|
|
17
17
|
"react-i18next": "13.5.0",
|
|
18
18
|
"yup": "0.32.11",
|
|
19
19
|
"react-international-phone": "4.2.5",
|
|
20
|
-
"@dynamic-labs/iconic": "2.1.2
|
|
21
|
-
"@dynamic-labs/logger": "2.1.2
|
|
22
|
-
"@dynamic-labs/multi-wallet": "2.1.2
|
|
23
|
-
"@dynamic-labs/rpc-provider-ethereum": "2.1.2
|
|
24
|
-
"@dynamic-labs/rpc-provider-solana": "2.1.2
|
|
25
|
-
"@dynamic-labs/rpc-providers": "2.1.2
|
|
26
|
-
"@dynamic-labs/store": "2.1.2
|
|
27
|
-
"@dynamic-labs/types": "2.1.2
|
|
28
|
-
"@dynamic-labs/utils": "2.1.2
|
|
29
|
-
"@dynamic-labs/viem-utils": "2.1.2
|
|
30
|
-
"@dynamic-labs/wallet-book": "2.1.2
|
|
31
|
-
"@dynamic-labs/wallet-connector-core": "2.1.2
|
|
20
|
+
"@dynamic-labs/iconic": "2.1.2",
|
|
21
|
+
"@dynamic-labs/logger": "2.1.2",
|
|
22
|
+
"@dynamic-labs/multi-wallet": "2.1.2",
|
|
23
|
+
"@dynamic-labs/rpc-provider-ethereum": "2.1.2",
|
|
24
|
+
"@dynamic-labs/rpc-provider-solana": "2.1.2",
|
|
25
|
+
"@dynamic-labs/rpc-providers": "2.1.2",
|
|
26
|
+
"@dynamic-labs/store": "2.1.2",
|
|
27
|
+
"@dynamic-labs/types": "2.1.2",
|
|
28
|
+
"@dynamic-labs/utils": "2.1.2",
|
|
29
|
+
"@dynamic-labs/viem-utils": "2.1.2",
|
|
30
|
+
"@dynamic-labs/wallet-book": "2.1.2",
|
|
31
|
+
"@dynamic-labs/wallet-connector-core": "2.1.2",
|
|
32
32
|
"eventemitter3": "5.0.1"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
@@ -23,6 +23,7 @@ require('../../utils/constants/colors.cjs');
|
|
|
23
23
|
require('../../utils/constants/values.cjs');
|
|
24
24
|
require('../../shared/utils/classes/storage/localStorage.cjs');
|
|
25
25
|
require('../../shared/consts/index.cjs');
|
|
26
|
+
var useInternalDynamicContext = require('../../context/DynamicContext/useDynamicContext/useInternalDynamicContext.cjs');
|
|
26
27
|
require('../../context/CaptchaContext/CaptchaContext.cjs');
|
|
27
28
|
require('../../context/ErrorContext/ErrorContext.cjs');
|
|
28
29
|
require('@dynamic-labs/multi-wallet');
|
|
@@ -87,10 +88,12 @@ const PhoneNumberField = ({ isLoading, disabled, error, label, onUpdate, appendR
|
|
|
87
88
|
const countryInputRef = React.useRef(null);
|
|
88
89
|
const [countryDropdownOpen, setCountryDropdownOpen] = React.useState(false);
|
|
89
90
|
const anchorRef = React.useRef(null);
|
|
91
|
+
const { defaultPhoneInputIso2 } = useInternalDynamicContext.useInternalDynamicContext();
|
|
90
92
|
const [invalidNumberMessage, setInvalidNumberMessage] = React.useState(undefined);
|
|
91
93
|
const { formattedPhone, currentCountry, handleCountryInput, handlePhoneInput, hasInput, inputRef, countryInput, onBlurCountry, filteredCountries, openDropdown, handleCountryKeyDown, closeDropdown, setCountry, onMenuDisplayToggle, onFocusCountry, countryFontSize, } = usePhoneInputLogic.usePhoneInputLogic({
|
|
92
94
|
countries,
|
|
93
95
|
countryInputRef,
|
|
96
|
+
defaultIso2: defaultPhoneInputIso2,
|
|
94
97
|
initialPhone,
|
|
95
98
|
onUpdate,
|
|
96
99
|
setCountryDropdownOpen,
|
|
@@ -19,6 +19,7 @@ import '../../utils/constants/colors.js';
|
|
|
19
19
|
import '../../utils/constants/values.js';
|
|
20
20
|
import '../../shared/utils/classes/storage/localStorage.js';
|
|
21
21
|
import '../../shared/consts/index.js';
|
|
22
|
+
import { useInternalDynamicContext } from '../../context/DynamicContext/useDynamicContext/useInternalDynamicContext.js';
|
|
22
23
|
import '../../context/CaptchaContext/CaptchaContext.js';
|
|
23
24
|
import '../../context/ErrorContext/ErrorContext.js';
|
|
24
25
|
import '@dynamic-labs/multi-wallet';
|
|
@@ -83,10 +84,12 @@ const PhoneNumberField = ({ isLoading, disabled, error, label, onUpdate, appendR
|
|
|
83
84
|
const countryInputRef = useRef(null);
|
|
84
85
|
const [countryDropdownOpen, setCountryDropdownOpen] = useState(false);
|
|
85
86
|
const anchorRef = useRef(null);
|
|
87
|
+
const { defaultPhoneInputIso2 } = useInternalDynamicContext();
|
|
86
88
|
const [invalidNumberMessage, setInvalidNumberMessage] = useState(undefined);
|
|
87
89
|
const { formattedPhone, currentCountry, handleCountryInput, handlePhoneInput, hasInput, inputRef, countryInput, onBlurCountry, filteredCountries, openDropdown, handleCountryKeyDown, closeDropdown, setCountry, onMenuDisplayToggle, onFocusCountry, countryFontSize, } = usePhoneInputLogic({
|
|
88
90
|
countries,
|
|
89
91
|
countryInputRef,
|
|
92
|
+
defaultIso2: defaultPhoneInputIso2,
|
|
90
93
|
initialPhone,
|
|
91
94
|
onUpdate,
|
|
92
95
|
setCountryDropdownOpen,
|
|
@@ -9,33 +9,24 @@ var localStorage = require('../../../shared/utils/classes/storage/localStorage.c
|
|
|
9
9
|
var useThrottle = require('../../../shared/utils/hooks/useThrottle/useThrottle.cjs');
|
|
10
10
|
var localStorage$1 = require('../../../utils/constants/localStorage.cjs');
|
|
11
11
|
var modulo = require('../../../utils/functions/modulo/modulo.cjs');
|
|
12
|
+
var parseDefaultCountry = require('../utils/parseDefaultCountry/parseDefaultCountry.cjs');
|
|
12
13
|
|
|
13
14
|
const MENU_DISPLAY_THROTTLE = 50;
|
|
14
15
|
const COUNTRY_INPUT_SCROLL_DELAY = 20;
|
|
15
|
-
const usePhoneInputLogic = ({ countryInputRef, setCountryDropdownOpen, setInvalidNumberMessage, onUpdate, initialPhone, countries, }) => {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
return countries
|
|
22
|
-
.map(reactInternationalPhone.parseCountry)
|
|
23
|
-
.find(({ iso2 }) => iso2 === defaultCountryIso2);
|
|
24
|
-
};
|
|
25
|
-
const { country: initialCountry } = initialPhone
|
|
26
|
-
? reactInternationalPhone.guessCountryByPartialPhoneNumber({
|
|
27
|
-
countries,
|
|
28
|
-
phone: initialPhone,
|
|
29
|
-
})
|
|
30
|
-
: { country: undefined };
|
|
16
|
+
const usePhoneInputLogic = ({ countryInputRef, setCountryDropdownOpen, setInvalidNumberMessage, onUpdate, initialPhone, countries, defaultIso2, }) => {
|
|
17
|
+
const defaultCountry = React.useMemo(() => parseDefaultCountry.parseDefaultCountry({
|
|
18
|
+
countries,
|
|
19
|
+
defaultIso2,
|
|
20
|
+
initialPhone,
|
|
21
|
+
}), [countries, defaultIso2, initialPhone]);
|
|
31
22
|
const { inputValue: formattedPhone, phone, country: currentCountry, setCountry: setSelectedCountry, handlePhoneValueChange: handlePhoneInput, inputRef, } = reactInternationalPhone.usePhoneInput({
|
|
32
23
|
countries,
|
|
33
|
-
defaultCountry:
|
|
24
|
+
defaultCountry: defaultCountry.iso2,
|
|
34
25
|
disableDialCodeAndPrefix: true,
|
|
35
26
|
value: initialPhone,
|
|
36
27
|
});
|
|
37
28
|
/** What is currently displayed on the country input */
|
|
38
|
-
const [countryInput, setCountryInput] = React.useState(
|
|
29
|
+
const [countryInput, setCountryInput] = React.useState(defaultCountry.dialCode);
|
|
39
30
|
/**
|
|
40
31
|
* This is the same value as phone, except for the following scenario:
|
|
41
32
|
* Since the phone number field hides the "+" char and the country code, when the field
|
|
@@ -93,7 +84,7 @@ const usePhoneInputLogic = ({ countryInputRef, setCountryDropdownOpen, setInvali
|
|
|
93
84
|
// COUNTRY INPUT
|
|
94
85
|
// =================================================================
|
|
95
86
|
/** The last inputted value for country that was valid */
|
|
96
|
-
const lastValidCountry = React.useRef(
|
|
87
|
+
const lastValidCountry = React.useRef(defaultCountry);
|
|
97
88
|
const handleCountryInput = ({ target, }) => {
|
|
98
89
|
const value = target.value.slice(0, 4);
|
|
99
90
|
setCountryInput(value);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ChangeEventHandler, Dispatch, KeyboardEventHandler, RefObject, SetStateAction } from 'react';
|
|
2
|
-
import { CountryData, ParsedCountry } from 'react-international-phone';
|
|
2
|
+
import { CountryData, CountryIso2, ParsedCountry } from 'react-international-phone';
|
|
3
3
|
export type OnUpdatePhoneData = (values: {
|
|
4
4
|
phone: string;
|
|
5
5
|
formattedPhone: string;
|
|
@@ -12,8 +12,9 @@ type UsePhoneLogicProps = {
|
|
|
12
12
|
countries: CountryData[];
|
|
13
13
|
onUpdate?: OnUpdatePhoneData;
|
|
14
14
|
initialPhone?: string;
|
|
15
|
+
defaultIso2?: CountryIso2;
|
|
15
16
|
};
|
|
16
|
-
export declare const usePhoneInputLogic: ({ countryInputRef, setCountryDropdownOpen, setInvalidNumberMessage, onUpdate, initialPhone, countries, }: UsePhoneLogicProps) => {
|
|
17
|
+
export declare const usePhoneInputLogic: ({ countryInputRef, setCountryDropdownOpen, setInvalidNumberMessage, onUpdate, initialPhone, countries, defaultIso2, }: UsePhoneLogicProps) => {
|
|
17
18
|
closeDropdown: () => void;
|
|
18
19
|
countryFontSize: string;
|
|
19
20
|
countryInput: string;
|
|
@@ -1,37 +1,28 @@
|
|
|
1
1
|
'use client'
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { useMemo, useState, useEffect, useCallback, useRef } from 'react';
|
|
3
|
+
import { usePhoneInput, parseCountry, removeDialCode, guessCountryByPartialPhoneNumber } from 'react-international-phone';
|
|
4
4
|
import { LocalStorage } from '../../../shared/utils/classes/storage/localStorage.js';
|
|
5
5
|
import { useThrottle } from '../../../shared/utils/hooks/useThrottle/useThrottle.js';
|
|
6
6
|
import { PHONE_INPUT_DEFAULT_COUNTRY } from '../../../utils/constants/localStorage.js';
|
|
7
7
|
import { modulo } from '../../../utils/functions/modulo/modulo.js';
|
|
8
|
+
import { parseDefaultCountry } from '../utils/parseDefaultCountry/parseDefaultCountry.js';
|
|
8
9
|
|
|
9
10
|
const MENU_DISPLAY_THROTTLE = 50;
|
|
10
11
|
const COUNTRY_INPUT_SCROLL_DELAY = 20;
|
|
11
|
-
const usePhoneInputLogic = ({ countryInputRef, setCountryDropdownOpen, setInvalidNumberMessage, onUpdate, initialPhone, countries, }) => {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
return countries
|
|
18
|
-
.map(parseCountry)
|
|
19
|
-
.find(({ iso2 }) => iso2 === defaultCountryIso2);
|
|
20
|
-
};
|
|
21
|
-
const { country: initialCountry } = initialPhone
|
|
22
|
-
? guessCountryByPartialPhoneNumber({
|
|
23
|
-
countries,
|
|
24
|
-
phone: initialPhone,
|
|
25
|
-
})
|
|
26
|
-
: { country: undefined };
|
|
12
|
+
const usePhoneInputLogic = ({ countryInputRef, setCountryDropdownOpen, setInvalidNumberMessage, onUpdate, initialPhone, countries, defaultIso2, }) => {
|
|
13
|
+
const defaultCountry = useMemo(() => parseDefaultCountry({
|
|
14
|
+
countries,
|
|
15
|
+
defaultIso2,
|
|
16
|
+
initialPhone,
|
|
17
|
+
}), [countries, defaultIso2, initialPhone]);
|
|
27
18
|
const { inputValue: formattedPhone, phone, country: currentCountry, setCountry: setSelectedCountry, handlePhoneValueChange: handlePhoneInput, inputRef, } = usePhoneInput({
|
|
28
19
|
countries,
|
|
29
|
-
defaultCountry:
|
|
20
|
+
defaultCountry: defaultCountry.iso2,
|
|
30
21
|
disableDialCodeAndPrefix: true,
|
|
31
22
|
value: initialPhone,
|
|
32
23
|
});
|
|
33
24
|
/** What is currently displayed on the country input */
|
|
34
|
-
const [countryInput, setCountryInput] = useState(
|
|
25
|
+
const [countryInput, setCountryInput] = useState(defaultCountry.dialCode);
|
|
35
26
|
/**
|
|
36
27
|
* This is the same value as phone, except for the following scenario:
|
|
37
28
|
* Since the phone number field hides the "+" char and the country code, when the field
|
|
@@ -89,7 +80,7 @@ const usePhoneInputLogic = ({ countryInputRef, setCountryDropdownOpen, setInvali
|
|
|
89
80
|
// COUNTRY INPUT
|
|
90
81
|
// =================================================================
|
|
91
82
|
/** The last inputted value for country that was valid */
|
|
92
|
-
const lastValidCountry = useRef(
|
|
83
|
+
const lastValidCountry = useRef(defaultCountry);
|
|
93
84
|
const handleCountryInput = ({ target, }) => {
|
|
94
85
|
const value = target.value.slice(0, 4);
|
|
95
86
|
setCountryInput(value);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { parseDefaultCountry } from './parseDefaultCountry';
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
var reactInternationalPhone = require('react-international-phone');
|
|
7
|
+
require('@dynamic-labs/sdk-api-core');
|
|
8
|
+
require('../../../../shared/logger.cjs');
|
|
9
|
+
require('@dynamic-labs/iconic');
|
|
10
|
+
require('@dynamic-labs/wallet-connector-core');
|
|
11
|
+
require('react/jsx-runtime');
|
|
12
|
+
require('../../../../context/ViewContext/ViewContext.cjs');
|
|
13
|
+
require('react');
|
|
14
|
+
require('@dynamic-labs/wallet-book');
|
|
15
|
+
var localStorage$1 = require('../../../../utils/constants/localStorage.cjs');
|
|
16
|
+
require('../../../../utils/constants/colors.cjs');
|
|
17
|
+
require('../../../../utils/constants/values.cjs');
|
|
18
|
+
var localStorage = require('../../../../shared/utils/classes/storage/localStorage.cjs');
|
|
19
|
+
require('@dynamic-labs/utils');
|
|
20
|
+
require('../../../../shared/consts/index.cjs');
|
|
21
|
+
|
|
22
|
+
const parseDefaultCountry = ({ defaultIso2, countries, initialPhone, }) => {
|
|
23
|
+
// Return the country inferred from the phone number if possible
|
|
24
|
+
if (initialPhone) {
|
|
25
|
+
const { country } = reactInternationalPhone.guessCountryByPartialPhoneNumber({
|
|
26
|
+
countries,
|
|
27
|
+
phone: initialPhone,
|
|
28
|
+
});
|
|
29
|
+
if (country) {
|
|
30
|
+
return country;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
const parsedCountries = countries.map(reactInternationalPhone.parseCountry);
|
|
34
|
+
// If the user has previously selected a country, use that as the default
|
|
35
|
+
const lastUsedCountryIso2 = localStorage.LocalStorage.getFromLS(localStorage$1.PHONE_INPUT_DEFAULT_COUNTRY);
|
|
36
|
+
const lastUsedCountry = parsedCountries.find(({ iso2 }) => iso2 === lastUsedCountryIso2);
|
|
37
|
+
if (lastUsedCountry) {
|
|
38
|
+
return lastUsedCountry;
|
|
39
|
+
}
|
|
40
|
+
// Use default country setting if found in enabled countries
|
|
41
|
+
const defaultCountry = parsedCountries.find(({ iso2 }) => iso2 === defaultIso2);
|
|
42
|
+
if (defaultCountry) {
|
|
43
|
+
return defaultCountry;
|
|
44
|
+
}
|
|
45
|
+
// Return US if it is enabled
|
|
46
|
+
const countryUS = parsedCountries.find(({ iso2 }) => iso2 === 'us');
|
|
47
|
+
if (countryUS) {
|
|
48
|
+
return countryUS;
|
|
49
|
+
}
|
|
50
|
+
// Return the first country in the list as a last resort
|
|
51
|
+
if (parsedCountries[0]) {
|
|
52
|
+
return parsedCountries[0];
|
|
53
|
+
}
|
|
54
|
+
throw new Error('No country list was provided');
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
exports.parseDefaultCountry = parseDefaultCountry;
|
package/src/lib/components/PhoneNumberField/utils/parseDefaultCountry/parseDefaultCountry.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { CountryData, CountryIso2, ParsedCountry } from 'react-international-phone';
|
|
2
|
+
type ParseDefaultCountryProps = {
|
|
3
|
+
initialPhone: string | undefined;
|
|
4
|
+
defaultIso2: CountryIso2 | undefined;
|
|
5
|
+
countries: CountryData[];
|
|
6
|
+
};
|
|
7
|
+
export declare const parseDefaultCountry: ({ defaultIso2, countries, initialPhone, }: ParseDefaultCountryProps) => ParsedCountry;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
import { guessCountryByPartialPhoneNumber, parseCountry } from 'react-international-phone';
|
|
3
|
+
import '@dynamic-labs/sdk-api-core';
|
|
4
|
+
import '../../../../shared/logger.js';
|
|
5
|
+
import '@dynamic-labs/iconic';
|
|
6
|
+
import '@dynamic-labs/wallet-connector-core';
|
|
7
|
+
import 'react/jsx-runtime';
|
|
8
|
+
import '../../../../context/ViewContext/ViewContext.js';
|
|
9
|
+
import 'react';
|
|
10
|
+
import '@dynamic-labs/wallet-book';
|
|
11
|
+
import { PHONE_INPUT_DEFAULT_COUNTRY } from '../../../../utils/constants/localStorage.js';
|
|
12
|
+
import '../../../../utils/constants/colors.js';
|
|
13
|
+
import '../../../../utils/constants/values.js';
|
|
14
|
+
import { LocalStorage } from '../../../../shared/utils/classes/storage/localStorage.js';
|
|
15
|
+
import '@dynamic-labs/utils';
|
|
16
|
+
import '../../../../shared/consts/index.js';
|
|
17
|
+
|
|
18
|
+
const parseDefaultCountry = ({ defaultIso2, countries, initialPhone, }) => {
|
|
19
|
+
// Return the country inferred from the phone number if possible
|
|
20
|
+
if (initialPhone) {
|
|
21
|
+
const { country } = guessCountryByPartialPhoneNumber({
|
|
22
|
+
countries,
|
|
23
|
+
phone: initialPhone,
|
|
24
|
+
});
|
|
25
|
+
if (country) {
|
|
26
|
+
return country;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
const parsedCountries = countries.map(parseCountry);
|
|
30
|
+
// If the user has previously selected a country, use that as the default
|
|
31
|
+
const lastUsedCountryIso2 = LocalStorage.getFromLS(PHONE_INPUT_DEFAULT_COUNTRY);
|
|
32
|
+
const lastUsedCountry = parsedCountries.find(({ iso2 }) => iso2 === lastUsedCountryIso2);
|
|
33
|
+
if (lastUsedCountry) {
|
|
34
|
+
return lastUsedCountry;
|
|
35
|
+
}
|
|
36
|
+
// Use default country setting if found in enabled countries
|
|
37
|
+
const defaultCountry = parsedCountries.find(({ iso2 }) => iso2 === defaultIso2);
|
|
38
|
+
if (defaultCountry) {
|
|
39
|
+
return defaultCountry;
|
|
40
|
+
}
|
|
41
|
+
// Return US if it is enabled
|
|
42
|
+
const countryUS = parsedCountries.find(({ iso2 }) => iso2 === 'us');
|
|
43
|
+
if (countryUS) {
|
|
44
|
+
return countryUS;
|
|
45
|
+
}
|
|
46
|
+
// Return the first country in the list as a last resort
|
|
47
|
+
if (parsedCountries[0]) {
|
|
48
|
+
return parsedCountries[0];
|
|
49
|
+
}
|
|
50
|
+
throw new Error('No country list was provided');
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
export { parseDefaultCountry };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Step } from './Step';
|
|
@@ -137,7 +137,7 @@ const DynamicContext = React.createContext(undefined);
|
|
|
137
137
|
/** The context provider itself we only use internally */
|
|
138
138
|
const InnerDynamicContextProvider = ({ children, theme, settings: settings$1, locale: locale$1, }) => {
|
|
139
139
|
var _a, _b, _c, _d, _e, _f;
|
|
140
|
-
const { accessDeniedMessagePrimary, accessDeniedMessageSecondary, accessDeniedButton, apiBaseUrl, coinbaseWalletPreference, enableConnectOnlyFallback = false, deepLinkPreference: deepLinkPreferenceProp = 'native', bridgeChains, cssOverrides, defaultNumberOfWalletsToShow = values.DEFAULT_NUMBER_OF_WALLETS_TO_SHOW, flowNetwork, initialAuthenticationMode = 'connect-and-sign', debugError = false, displaySiweStatement = true, newToWeb3WalletChainMap, enableVisitTrackingOnConnectOnly = true, environmentId, walletsFilter, logLevel = 'WARN', mobileExperience = 'in-app-browser', notInTheListImageUrl, onboardingImageUrl, policiesConsentInnerComponent, customPrivacyPolicy, privacyPolicyUrl, signWithEmailWalletName, socialMediaLinkText, socialMediaIconUrl, socialMediaUrl, customTermsOfServices, termsOfServiceUrl, toolkitEnabled, siweStatement, shadowDOMEnabled = true, walletConnectors: walletConnectorsProp, socialProvidersFilter, showLockedWalletView = false, walletConnectPreferredChains, walletConnectorExtensions, recommendedWallets, hideEmbeddedWalletTransactionUIs, handlers, headless = false, } = settings$1;
|
|
140
|
+
const { accessDeniedMessagePrimary, accessDeniedMessageSecondary, accessDeniedButton, defaultPhoneInputIso2, apiBaseUrl, coinbaseWalletPreference, enableConnectOnlyFallback = false, deepLinkPreference: deepLinkPreferenceProp = 'native', bridgeChains, cssOverrides, defaultNumberOfWalletsToShow = values.DEFAULT_NUMBER_OF_WALLETS_TO_SHOW, flowNetwork, initialAuthenticationMode = 'connect-and-sign', debugError = false, displaySiweStatement = true, newToWeb3WalletChainMap, enableVisitTrackingOnConnectOnly = true, environmentId, walletsFilter, logLevel = 'WARN', mobileExperience = 'in-app-browser', notInTheListImageUrl, onboardingImageUrl, policiesConsentInnerComponent, customPrivacyPolicy, privacyPolicyUrl, signWithEmailWalletName, socialMediaLinkText, socialMediaIconUrl, socialMediaUrl, customTermsOfServices, termsOfServiceUrl, toolkitEnabled, siweStatement, shadowDOMEnabled = true, walletConnectors: walletConnectorsProp, socialProvidersFilter, showLockedWalletView = false, walletConnectPreferredChains, walletConnectorExtensions, recommendedWallets, hideEmbeddedWalletTransactionUIs, handlers, headless = false, } = settings$1;
|
|
141
141
|
localStorage.LocalStorage.setSuffix(settings$1.localStorageSuffix);
|
|
142
142
|
/**
|
|
143
143
|
* initialize global store
|
|
@@ -441,6 +441,7 @@ const InnerDynamicContextProvider = ({ children, theme, settings: settings$1, lo
|
|
|
441
441
|
customTermsOfServices,
|
|
442
442
|
debugError,
|
|
443
443
|
defaultNumberOfWalletsToShow,
|
|
444
|
+
defaultPhoneInputIso2,
|
|
444
445
|
defaultTabIndex,
|
|
445
446
|
desktopUri,
|
|
446
447
|
disconnectWallet,
|
|
@@ -545,6 +546,7 @@ const InnerDynamicContextProvider = ({ children, theme, settings: settings$1, lo
|
|
|
545
546
|
accessDeniedMessageSecondary,
|
|
546
547
|
accountSwitchState,
|
|
547
548
|
handlers,
|
|
549
|
+
defaultPhoneInputIso2,
|
|
548
550
|
appLogoUrl,
|
|
549
551
|
appName,
|
|
550
552
|
defaultTabIndex,
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { FC, ReactNode } from 'react';
|
|
2
|
+
import { CountryIso2 } from 'react-international-phone';
|
|
2
3
|
import { LogLevel } from '@dynamic-labs/logger';
|
|
3
4
|
import { type CoinbaseWalletPreference, type SocialProviderFilter } from '@dynamic-labs/types';
|
|
4
5
|
import { DeepLinkVariant, WalletConnectorExtension, WalletConnectorsMethod } from '@dynamic-labs/wallet-connector-core';
|
|
@@ -23,6 +24,7 @@ export interface DynamicContextProps {
|
|
|
23
24
|
coinbaseWalletPreference?: CoinbaseWalletPreference;
|
|
24
25
|
cssOverrides?: string | JSX.Element;
|
|
25
26
|
customPrivacyPolicy?: ReactNode;
|
|
27
|
+
defaultPhoneInputIso2?: CountryIso2;
|
|
26
28
|
customTermsOfServices?: ReactNode;
|
|
27
29
|
debugError?: boolean;
|
|
28
30
|
/**
|
|
@@ -133,7 +133,7 @@ const DynamicContext = createContext(undefined);
|
|
|
133
133
|
/** The context provider itself we only use internally */
|
|
134
134
|
const InnerDynamicContextProvider = ({ children, theme, settings, locale, }) => {
|
|
135
135
|
var _a, _b, _c, _d, _e, _f;
|
|
136
|
-
const { accessDeniedMessagePrimary, accessDeniedMessageSecondary, accessDeniedButton, apiBaseUrl, coinbaseWalletPreference, enableConnectOnlyFallback = false, deepLinkPreference: deepLinkPreferenceProp = 'native', bridgeChains, cssOverrides, defaultNumberOfWalletsToShow = DEFAULT_NUMBER_OF_WALLETS_TO_SHOW, flowNetwork, initialAuthenticationMode = 'connect-and-sign', debugError = false, displaySiweStatement = true, newToWeb3WalletChainMap, enableVisitTrackingOnConnectOnly = true, environmentId, walletsFilter, logLevel = 'WARN', mobileExperience = 'in-app-browser', notInTheListImageUrl, onboardingImageUrl, policiesConsentInnerComponent, customPrivacyPolicy, privacyPolicyUrl, signWithEmailWalletName, socialMediaLinkText, socialMediaIconUrl, socialMediaUrl, customTermsOfServices, termsOfServiceUrl, toolkitEnabled, siweStatement, shadowDOMEnabled = true, walletConnectors: walletConnectorsProp, socialProvidersFilter, showLockedWalletView = false, walletConnectPreferredChains, walletConnectorExtensions, recommendedWallets, hideEmbeddedWalletTransactionUIs, handlers, headless = false, } = settings;
|
|
136
|
+
const { accessDeniedMessagePrimary, accessDeniedMessageSecondary, accessDeniedButton, defaultPhoneInputIso2, apiBaseUrl, coinbaseWalletPreference, enableConnectOnlyFallback = false, deepLinkPreference: deepLinkPreferenceProp = 'native', bridgeChains, cssOverrides, defaultNumberOfWalletsToShow = DEFAULT_NUMBER_OF_WALLETS_TO_SHOW, flowNetwork, initialAuthenticationMode = 'connect-and-sign', debugError = false, displaySiweStatement = true, newToWeb3WalletChainMap, enableVisitTrackingOnConnectOnly = true, environmentId, walletsFilter, logLevel = 'WARN', mobileExperience = 'in-app-browser', notInTheListImageUrl, onboardingImageUrl, policiesConsentInnerComponent, customPrivacyPolicy, privacyPolicyUrl, signWithEmailWalletName, socialMediaLinkText, socialMediaIconUrl, socialMediaUrl, customTermsOfServices, termsOfServiceUrl, toolkitEnabled, siweStatement, shadowDOMEnabled = true, walletConnectors: walletConnectorsProp, socialProvidersFilter, showLockedWalletView = false, walletConnectPreferredChains, walletConnectorExtensions, recommendedWallets, hideEmbeddedWalletTransactionUIs, handlers, headless = false, } = settings;
|
|
137
137
|
LocalStorage.setSuffix(settings.localStorageSuffix);
|
|
138
138
|
/**
|
|
139
139
|
* initialize global store
|
|
@@ -437,6 +437,7 @@ const InnerDynamicContextProvider = ({ children, theme, settings, locale, }) =>
|
|
|
437
437
|
customTermsOfServices,
|
|
438
438
|
debugError,
|
|
439
439
|
defaultNumberOfWalletsToShow,
|
|
440
|
+
defaultPhoneInputIso2,
|
|
440
441
|
defaultTabIndex,
|
|
441
442
|
desktopUri,
|
|
442
443
|
disconnectWallet,
|
|
@@ -541,6 +542,7 @@ const InnerDynamicContextProvider = ({ children, theme, settings, locale, }) =>
|
|
|
541
542
|
accessDeniedMessageSecondary,
|
|
542
543
|
accountSwitchState,
|
|
543
544
|
handlers,
|
|
545
|
+
defaultPhoneInputIso2,
|
|
544
546
|
appLogoUrl,
|
|
545
547
|
appName,
|
|
546
548
|
defaultTabIndex,
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Dispatch, MutableRefObject, ReactElement, ReactNode, SetStateAction } from 'react';
|
|
2
2
|
import { changeLanguage } from 'i18next';
|
|
3
|
+
import { CountryIso2 } from 'react-international-phone';
|
|
3
4
|
import { NameServiceData, ProjectSettings, SdkView } from '@dynamic-labs/sdk-api-core';
|
|
4
5
|
import { GenericNetwork, NetworkConfigurationMap, SocialProviderFilter, UserProfile, WalletUiUtils } from '@dynamic-labs/types';
|
|
5
6
|
import { Chain, GetAddressOpts, WalletConnector } from '@dynamic-labs/wallet-connector-core';
|
|
@@ -64,6 +65,7 @@ export interface IDynamicContext {
|
|
|
64
65
|
accountSwitchState: AccountSwitchState;
|
|
65
66
|
appLogoUrl?: string;
|
|
66
67
|
appName?: string;
|
|
68
|
+
defaultPhoneInputIso2?: CountryIso2;
|
|
67
69
|
authMode: AuthModeType;
|
|
68
70
|
authToken: string | undefined;
|
|
69
71
|
authorizationViewDisplayOrder: DisplayOrder;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './staticLinkedWalletFilter';
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* These wallets do not fire events when switching accounts, so we should filter
|
|
8
|
+
* them out of the wallet list if they are already linked to the user profile.
|
|
9
|
+
*/
|
|
10
|
+
const staticListToFilter = [
|
|
11
|
+
'xverse',
|
|
12
|
+
'magiceden',
|
|
13
|
+
'magicedenbtc',
|
|
14
|
+
'magicedensol',
|
|
15
|
+
];
|
|
16
|
+
/**
|
|
17
|
+
* This function is a helper to filter out wallets that should not appear in the wallet list
|
|
18
|
+
* if they are already linked to the user profile.
|
|
19
|
+
*/
|
|
20
|
+
const staticWalletFilter = (linkedWallets, walletOptions) => walletOptions.filter((walletOption) => {
|
|
21
|
+
if (!staticListToFilter.includes(walletOption.key)) {
|
|
22
|
+
return true;
|
|
23
|
+
}
|
|
24
|
+
if (linkedWallets.some((wallet) => wallet.connector.key === walletOption.key)) {
|
|
25
|
+
return false;
|
|
26
|
+
}
|
|
27
|
+
return true;
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
exports.staticWalletFilter = staticWalletFilter;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Wallet, WalletOption } from '../../../../../shared';
|
|
2
|
+
/**
|
|
3
|
+
* This function is a helper to filter out wallets that should not appear in the wallet list
|
|
4
|
+
* if they are already linked to the user profile.
|
|
5
|
+
*/
|
|
6
|
+
export declare const staticWalletFilter: (linkedWallets: Wallet[], walletOptions: WalletOption[]) => WalletOption[];
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
/**
|
|
3
|
+
* These wallets do not fire events when switching accounts, so we should filter
|
|
4
|
+
* them out of the wallet list if they are already linked to the user profile.
|
|
5
|
+
*/
|
|
6
|
+
const staticListToFilter = [
|
|
7
|
+
'xverse',
|
|
8
|
+
'magiceden',
|
|
9
|
+
'magicedenbtc',
|
|
10
|
+
'magicedensol',
|
|
11
|
+
];
|
|
12
|
+
/**
|
|
13
|
+
* This function is a helper to filter out wallets that should not appear in the wallet list
|
|
14
|
+
* if they are already linked to the user profile.
|
|
15
|
+
*/
|
|
16
|
+
const staticWalletFilter = (linkedWallets, walletOptions) => walletOptions.filter((walletOption) => {
|
|
17
|
+
if (!staticListToFilter.includes(walletOption.key)) {
|
|
18
|
+
return true;
|
|
19
|
+
}
|
|
20
|
+
if (linkedWallets.some((wallet) => wallet.connector.key === walletOption.key)) {
|
|
21
|
+
return false;
|
|
22
|
+
}
|
|
23
|
+
return true;
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
export { staticWalletFilter };
|
|
@@ -7,6 +7,7 @@ var walletConnectorCore = require('@dynamic-labs/wallet-connector-core');
|
|
|
7
7
|
var getCalculatedOffset = require('./utils/getCalculatedOffset/getCalculatedOffset.cjs');
|
|
8
8
|
var groupWalletOptions = require('./utils/groupWalletOptions/groupWalletOptions.cjs');
|
|
9
9
|
var filterConnectedWallets = require('./utils/filterConnectedWallets/filterConnectedWallets.cjs');
|
|
10
|
+
var staticLinkedWalletFilter = require('./utils/staticLinkedWalletFilter/staticLinkedWalletFilter.cjs');
|
|
10
11
|
|
|
11
12
|
const PRIORITY_WALLET_LIST = [
|
|
12
13
|
'metamask',
|
|
@@ -56,7 +57,7 @@ const sortedInputList = (inputList, recommendedWalletKeys) => {
|
|
|
56
57
|
...unsortedOtherWallets,
|
|
57
58
|
];
|
|
58
59
|
};
|
|
59
|
-
const walletListBuilder = ({ authMode, connectedWallets, multiWallet, numberOfWalletsToShow, inputList, isWalletConnectList, lastUsedWalletKey, signWithEmailWalletName, searchFilter, walletsFilter, loginWithEmail, groupWallets, walletBook, showMoreWalletsWithFilter, recommendedWallets, }) => {
|
|
60
|
+
const walletListBuilder = ({ authMode, connectedWallets, linkedWallets, multiWallet, numberOfWalletsToShow, inputList, isWalletConnectList, lastUsedWalletKey, signWithEmailWalletName, searchFilter, walletsFilter, loginWithEmail, groupWallets, walletBook, showMoreWalletsWithFilter, recommendedWallets, }) => {
|
|
60
61
|
let walletList = inputList;
|
|
61
62
|
if (isWalletConnectList) {
|
|
62
63
|
walletList = inputList.filter((wallet) => wallet.walletConnector.isWalletConnect &&
|
|
@@ -68,6 +69,9 @@ const walletListBuilder = ({ authMode, connectedWallets, multiWallet, numberOfWa
|
|
|
68
69
|
walletOptions: walletList,
|
|
69
70
|
});
|
|
70
71
|
}
|
|
72
|
+
if (authMode === 'connect-and-sign' && multiWallet) {
|
|
73
|
+
walletList = staticLinkedWalletFilter.staticWalletFilter(linkedWallets, walletList);
|
|
74
|
+
}
|
|
71
75
|
let lastUsedWallet;
|
|
72
76
|
const hasWalletFilter = Boolean(walletsFilter);
|
|
73
77
|
const signWithEmailWallet = getSignWithEmailWallet(signWithEmailWalletName, walletList);
|
|
@@ -3,6 +3,7 @@ import { AuthModeType, RecommendedWallet, Wallet, WalletOption } from '../../../
|
|
|
3
3
|
type BuilderParams = {
|
|
4
4
|
authMode: AuthModeType;
|
|
5
5
|
connectedWallets: Wallet[];
|
|
6
|
+
linkedWallets: Wallet[];
|
|
6
7
|
multiWallet: boolean;
|
|
7
8
|
inputList: WalletOption[];
|
|
8
9
|
isWalletConnectList: boolean;
|
|
@@ -23,7 +24,7 @@ type BuilderResult = {
|
|
|
23
24
|
};
|
|
24
25
|
export declare const PRIORITY_WALLET_LIST: string[];
|
|
25
26
|
export declare const SIGN_IN_WITH_EMAIL_WALLET_NAME = "Sign In With Email";
|
|
26
|
-
export declare const walletListBuilder: ({ authMode, connectedWallets, multiWallet, numberOfWalletsToShow, inputList, isWalletConnectList, lastUsedWalletKey, signWithEmailWalletName, searchFilter, walletsFilter, loginWithEmail, groupWallets, walletBook, showMoreWalletsWithFilter, recommendedWallets, }: BuilderParams) => BuilderResult;
|
|
27
|
+
export declare const walletListBuilder: ({ authMode, connectedWallets, linkedWallets, multiWallet, numberOfWalletsToShow, inputList, isWalletConnectList, lastUsedWalletKey, signWithEmailWalletName, searchFilter, walletsFilter, loginWithEmail, groupWallets, walletBook, showMoreWalletsWithFilter, recommendedWallets, }: BuilderParams) => BuilderResult;
|
|
27
28
|
/**
|
|
28
29
|
* This calculation adds an offset to numberOfWalletsToShow so we will show the
|
|
29
30
|
* intended wallets + installed and last used.
|
|
@@ -3,6 +3,7 @@ import { isEmbeddedConnector } from '@dynamic-labs/wallet-connector-core';
|
|
|
3
3
|
import { getCalculatedOffset } from './utils/getCalculatedOffset/getCalculatedOffset.js';
|
|
4
4
|
import { groupWalletOptions } from './utils/groupWalletOptions/groupWalletOptions.js';
|
|
5
5
|
import { filterConnectedWallets } from './utils/filterConnectedWallets/filterConnectedWallets.js';
|
|
6
|
+
import { staticWalletFilter } from './utils/staticLinkedWalletFilter/staticLinkedWalletFilter.js';
|
|
6
7
|
|
|
7
8
|
const PRIORITY_WALLET_LIST = [
|
|
8
9
|
'metamask',
|
|
@@ -52,7 +53,7 @@ const sortedInputList = (inputList, recommendedWalletKeys) => {
|
|
|
52
53
|
...unsortedOtherWallets,
|
|
53
54
|
];
|
|
54
55
|
};
|
|
55
|
-
const walletListBuilder = ({ authMode, connectedWallets, multiWallet, numberOfWalletsToShow, inputList, isWalletConnectList, lastUsedWalletKey, signWithEmailWalletName, searchFilter, walletsFilter, loginWithEmail, groupWallets, walletBook, showMoreWalletsWithFilter, recommendedWallets, }) => {
|
|
56
|
+
const walletListBuilder = ({ authMode, connectedWallets, linkedWallets, multiWallet, numberOfWalletsToShow, inputList, isWalletConnectList, lastUsedWalletKey, signWithEmailWalletName, searchFilter, walletsFilter, loginWithEmail, groupWallets, walletBook, showMoreWalletsWithFilter, recommendedWallets, }) => {
|
|
56
57
|
let walletList = inputList;
|
|
57
58
|
if (isWalletConnectList) {
|
|
58
59
|
walletList = inputList.filter((wallet) => wallet.walletConnector.isWalletConnect &&
|
|
@@ -64,6 +65,9 @@ const walletListBuilder = ({ authMode, connectedWallets, multiWallet, numberOfWa
|
|
|
64
65
|
walletOptions: walletList,
|
|
65
66
|
});
|
|
66
67
|
}
|
|
68
|
+
if (authMode === 'connect-and-sign' && multiWallet) {
|
|
69
|
+
walletList = staticWalletFilter(linkedWallets, walletList);
|
|
70
|
+
}
|
|
67
71
|
let lastUsedWallet;
|
|
68
72
|
const hasWalletFilter = Boolean(walletsFilter);
|
|
69
73
|
const signWithEmailWallet = getSignWithEmailWallet(signWithEmailWalletName, walletList);
|
|
@@ -103,7 +103,7 @@ const SECONDS_TO_RETRY = 15;
|
|
|
103
103
|
const EmailVerification = ({ isEmailRecoveryFlow = false, showRetryButton: _showRetryButton = true, showTransferMessage: _showTransferMessage = false, }) => {
|
|
104
104
|
var _a, _b, _c, _d;
|
|
105
105
|
const { environmentId, handleLogOut, setPrimaryWalletId, setShowAuthFlow, projectSettings, user, unauthenticatedUser, } = useInternalDynamicContext.useInternalDynamicContext();
|
|
106
|
-
const {
|
|
106
|
+
const { setView, goToInitialView } = ViewContext.useViewContext();
|
|
107
107
|
const { error, setError, setErrorMessage } = ErrorContext.useErrorContext();
|
|
108
108
|
const { loading, setLoading } = LoadingContext.useLoadingContext();
|
|
109
109
|
const [showRetryButton, setShowRetryButton] = React.useState(_showRetryButton);
|
|
@@ -135,7 +135,6 @@ const EmailVerification = ({ isEmailRecoveryFlow = false, showRetryButton: _show
|
|
|
135
135
|
if (!email$1)
|
|
136
136
|
logger.logger.warn("WARNING: emitted emailVerificationResult with incomplete params because useVerification's displayedDestination was undefined");
|
|
137
137
|
});
|
|
138
|
-
const isLoginView = view.type === 'login-with-email-verification';
|
|
139
138
|
const { verifyOtp } = useOtpVerificationRequest.useOtpVerificationRequest();
|
|
140
139
|
const completeSignInFlow = React.useCallback((updateUserProfileResponse) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
141
140
|
var _e, _f, _g, _h, _j;
|
|
@@ -149,9 +148,13 @@ const EmailVerification = ({ isEmailRecoveryFlow = false, showRetryButton: _show
|
|
|
149
148
|
});
|
|
150
149
|
return true;
|
|
151
150
|
}
|
|
151
|
+
if (!isTurnkeyWallet) {
|
|
152
|
+
return false;
|
|
153
|
+
}
|
|
152
154
|
// If the user has a turnkey embedded wallet and no recovery email, add the email as a recovery email
|
|
153
|
-
if
|
|
154
|
-
|
|
155
|
+
// This logic should run even if the turnkey provider is not enabled anymore
|
|
156
|
+
// (e.g. user created the wallet and then the settings were disalbed)
|
|
157
|
+
if (hasTurnkeyVerifiedCredentialAuthenticator &&
|
|
155
158
|
!hasRecoveryEmail &&
|
|
156
159
|
((_e = updateUserProfileResponse === null || updateUserProfileResponse === void 0 ? void 0 : updateUserProfileResponse.user) === null || _e === void 0 ? void 0 : _e.email)) {
|
|
157
160
|
storeAuthTokenAndUser.storeAuthTokenAndUser(updateUserProfileResponse);
|
|
@@ -159,9 +162,11 @@ const EmailVerification = ({ isEmailRecoveryFlow = false, showRetryButton: _show
|
|
|
159
162
|
setShowAuthFlow(false);
|
|
160
163
|
return true;
|
|
161
164
|
}
|
|
165
|
+
// The logic below is needed when we capture an email after a user
|
|
166
|
+
// authenticated with Sms/Twitter etc And we need to capture and email.
|
|
162
167
|
if (isTurnkeyProviderEnabled) {
|
|
163
|
-
const
|
|
164
|
-
const isUsingPregeneratedWallets = Boolean(
|
|
168
|
+
const isAutomaticWalletCreation = (_g = (_f = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk) === null || _f === void 0 ? void 0 : _f.embeddedWallets) === null || _g === void 0 ? void 0 : _g.automaticEmbeddedWalletCreation;
|
|
169
|
+
const isUsingPregeneratedWallets = Boolean(isAutomaticWalletCreation &&
|
|
165
170
|
!((_j = (_h = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk) === null || _h === void 0 ? void 0 : _h.embeddedWallets) === null || _j === void 0 ? void 0 : _j.forceAuthenticatorAtSignup));
|
|
166
171
|
if (isUsingPregeneratedWallets) {
|
|
167
172
|
// Pregenerated wallet was created during an
|
|
@@ -185,7 +190,7 @@ const EmailVerification = ({ isEmailRecoveryFlow = false, showRetryButton: _show
|
|
|
185
190
|
setPrimaryWalletId(embeddedWalletVerifiedCredential.id);
|
|
186
191
|
dynamicEvents.dynamicEvents.emit('embeddedWalletCreated', wallet, embeddedWalletVerifiedCredential, updateUserProfileResponse.jwt, user);
|
|
187
192
|
}
|
|
188
|
-
if (isUsingPregeneratedWallets ||
|
|
193
|
+
if (isUsingPregeneratedWallets || !isAutomaticWalletCreation) {
|
|
189
194
|
setShowAuthFlow(false);
|
|
190
195
|
return true;
|
|
191
196
|
}
|
|
@@ -205,14 +210,25 @@ const EmailVerification = ({ isEmailRecoveryFlow = false, showRetryButton: _show
|
|
|
205
210
|
setView,
|
|
206
211
|
user,
|
|
207
212
|
]);
|
|
208
|
-
const
|
|
213
|
+
const handleEmailVerification = React.useCallback((verificationToken) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
209
214
|
setError(undefined);
|
|
210
215
|
setLoading(true);
|
|
211
|
-
if (!verificationUUID
|
|
212
|
-
|
|
213
|
-
return;
|
|
216
|
+
if (!verificationUUID) {
|
|
217
|
+
return cancelAuth();
|
|
214
218
|
}
|
|
215
|
-
|
|
219
|
+
if (!user && !unauthenticatedUser) {
|
|
220
|
+
return initAuth({
|
|
221
|
+
onVerifySuccess: () => setIsValidated(true),
|
|
222
|
+
options: { email: email$1 },
|
|
223
|
+
showSuccessMessage: true,
|
|
224
|
+
verifyFunction: () => email.signInWithEmailVerification({
|
|
225
|
+
environmentId,
|
|
226
|
+
verificationToken,
|
|
227
|
+
verificationUUID,
|
|
228
|
+
}),
|
|
229
|
+
});
|
|
230
|
+
}
|
|
231
|
+
return completeAuth({
|
|
216
232
|
completeSignInFlow: (updateUserResponse) => _tslib.__awaiter(void 0, void 0, void 0, function* () { return completeSignInFlow(updateUserResponse); }),
|
|
217
233
|
onValidUpdatedJwt: () => {
|
|
218
234
|
// This causes emaiLVerificationSuccess to be raised, so it should be set as soon
|
|
@@ -226,40 +242,16 @@ const EmailVerification = ({ isEmailRecoveryFlow = false, showRetryButton: _show
|
|
|
226
242
|
setError,
|
|
227
243
|
setLoading,
|
|
228
244
|
verificationUUID,
|
|
245
|
+
user,
|
|
246
|
+
unauthenticatedUser,
|
|
229
247
|
completeAuth,
|
|
230
248
|
email$1,
|
|
231
249
|
isEmailRecoveryFlow,
|
|
232
250
|
cancelAuth,
|
|
233
|
-
completeSignInFlow,
|
|
234
|
-
verifyOtp,
|
|
235
|
-
user,
|
|
236
|
-
unauthenticatedUser,
|
|
237
|
-
]);
|
|
238
|
-
const handleEmailLogin = React.useCallback((verificationToken) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
239
|
-
setError(undefined);
|
|
240
|
-
setLoading(true);
|
|
241
|
-
if (!verificationUUID) {
|
|
242
|
-
yield cancelAuth();
|
|
243
|
-
return;
|
|
244
|
-
}
|
|
245
|
-
yield initAuth({
|
|
246
|
-
onVerifySuccess: () => setIsValidated(true),
|
|
247
|
-
options: { email: email$1 },
|
|
248
|
-
showSuccessMessage: true,
|
|
249
|
-
verifyFunction: () => email.signInWithEmailVerification({
|
|
250
|
-
environmentId,
|
|
251
|
-
verificationToken,
|
|
252
|
-
verificationUUID,
|
|
253
|
-
}),
|
|
254
|
-
});
|
|
255
|
-
}), [
|
|
256
|
-
setError,
|
|
257
|
-
setLoading,
|
|
258
|
-
verificationUUID,
|
|
259
251
|
initAuth,
|
|
260
|
-
email$1,
|
|
261
|
-
cancelAuth,
|
|
262
252
|
environmentId,
|
|
253
|
+
completeSignInFlow,
|
|
254
|
+
verifyOtp,
|
|
263
255
|
]);
|
|
264
256
|
const handleRetry = () => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
265
257
|
try {
|
|
@@ -295,7 +287,7 @@ const EmailVerification = ({ isEmailRecoveryFlow = false, showRetryButton: _show
|
|
|
295
287
|
}, []);
|
|
296
288
|
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [error && (jsxRuntime.jsx(ErrorContainer.ErrorContainer, { withIcon: false, className: 'email-verification__error-message', children: error })), jsxRuntime.jsxs("div", { className: classNames.classNames('email-verification__container', {
|
|
297
289
|
'email-verification__container--error': Boolean(error),
|
|
298
|
-
}), children: [showTransferMessage && (jsxRuntime.jsx("div", { className: 'email-verification__transfer-message', copykey: 'dyn_otp_verification.email.complete', children: t('dyn_otp_verification.email.complete') })), isValidated ? (jsxRuntime.jsx("div", { className: 'email-verification__icon-container', children: jsxRuntime.jsx(IconWithStatus.IconWithStatus, { containerClassName: 'email-verification__icon--verified', Icon: EmailIcon, iconSize: 64, InnerIcon: check.ReactComponent }) })) : (jsxRuntime.jsx(IconWithSpinner.IconWithSpinner, { Icon: EmailIcon, iconSize: 96, isSpinning: true, className: 'email-verification__icon-with-spinner' })), jsxRuntime.jsxs("div", { className: 'email-verification__copy-text-container', children: [jsxRuntime.jsx(Typography.Typography, { variant: 'body_normal', weight: 'regular', color: 'secondary', copykey: 'dyn_otp_verification.description', children: t('dyn_otp_verification.description') }), jsxRuntime.jsx(Typography.Typography, { variant: 'body_normal', weight: 'bold', color: 'secondary', children: shortenEmail.shortenEmail(email$1) })] }), jsxRuntime.jsx(PinField.PinField, { initialValue: Array(6).join('.').split('.'), isLoading: loading, handleComplete:
|
|
290
|
+
}), children: [showTransferMessage && (jsxRuntime.jsx("div", { className: 'email-verification__transfer-message', copykey: 'dyn_otp_verification.email.complete', children: t('dyn_otp_verification.email.complete') })), isValidated ? (jsxRuntime.jsx("div", { className: 'email-verification__icon-container', children: jsxRuntime.jsx(IconWithStatus.IconWithStatus, { containerClassName: 'email-verification__icon--verified', Icon: EmailIcon, iconSize: 64, InnerIcon: check.ReactComponent }) })) : (jsxRuntime.jsx(IconWithSpinner.IconWithSpinner, { Icon: EmailIcon, iconSize: 96, isSpinning: true, className: 'email-verification__icon-with-spinner' })), jsxRuntime.jsxs("div", { className: 'email-verification__copy-text-container', children: [jsxRuntime.jsx(Typography.Typography, { variant: 'body_normal', weight: 'regular', color: 'secondary', copykey: 'dyn_otp_verification.description', children: t('dyn_otp_verification.description') }), jsxRuntime.jsx(Typography.Typography, { variant: 'body_normal', weight: 'bold', color: 'secondary', children: shortenEmail.shortenEmail(email$1) })] }), jsxRuntime.jsx(PinField.PinField, { initialValue: Array(6).join('.').split('.'), isLoading: loading, handleComplete: handleEmailVerification, isValidated: isValidated, inputMode: 'numeric', pattern: '[0-9]*', hasError: Boolean(error), onChange: () => setError(undefined) }), showRetryButton && (jsxRuntime.jsx(RetrySendVerificationCodeSection.RetrySendVerificationCodeSection, { className: 'email-verification__retry-container', retryHandler: handleRetry, secondsToRetry: SECONDS_TO_RETRY })), (user || unauthenticatedUser) && !isEmailRecoveryFlow && (jsxRuntime.jsx(TextButton.TextButton, { className: 'email-verification__log-out', onClick: handleLogOut, copykey: 'dyn_otp_verification.log_out_button', children: t('dyn_otp_verification.log_out_button') }))] })] }));
|
|
299
291
|
};
|
|
300
292
|
|
|
301
293
|
exports.EmailVerification = EmailVerification;
|
|
@@ -99,7 +99,7 @@ const SECONDS_TO_RETRY = 15;
|
|
|
99
99
|
const EmailVerification = ({ isEmailRecoveryFlow = false, showRetryButton: _showRetryButton = true, showTransferMessage: _showTransferMessage = false, }) => {
|
|
100
100
|
var _a, _b, _c, _d;
|
|
101
101
|
const { environmentId, handleLogOut, setPrimaryWalletId, setShowAuthFlow, projectSettings, user, unauthenticatedUser, } = useInternalDynamicContext();
|
|
102
|
-
const {
|
|
102
|
+
const { setView, goToInitialView } = useViewContext();
|
|
103
103
|
const { error, setError, setErrorMessage } = useErrorContext();
|
|
104
104
|
const { loading, setLoading } = useLoadingContext();
|
|
105
105
|
const [showRetryButton, setShowRetryButton] = useState(_showRetryButton);
|
|
@@ -131,7 +131,6 @@ const EmailVerification = ({ isEmailRecoveryFlow = false, showRetryButton: _show
|
|
|
131
131
|
if (!email)
|
|
132
132
|
logger.warn("WARNING: emitted emailVerificationResult with incomplete params because useVerification's displayedDestination was undefined");
|
|
133
133
|
});
|
|
134
|
-
const isLoginView = view.type === 'login-with-email-verification';
|
|
135
134
|
const { verifyOtp } = useOtpVerificationRequest();
|
|
136
135
|
const completeSignInFlow = useCallback((updateUserProfileResponse) => __awaiter(void 0, void 0, void 0, function* () {
|
|
137
136
|
var _e, _f, _g, _h, _j;
|
|
@@ -145,9 +144,13 @@ const EmailVerification = ({ isEmailRecoveryFlow = false, showRetryButton: _show
|
|
|
145
144
|
});
|
|
146
145
|
return true;
|
|
147
146
|
}
|
|
147
|
+
if (!isTurnkeyWallet) {
|
|
148
|
+
return false;
|
|
149
|
+
}
|
|
148
150
|
// If the user has a turnkey embedded wallet and no recovery email, add the email as a recovery email
|
|
149
|
-
if
|
|
150
|
-
|
|
151
|
+
// This logic should run even if the turnkey provider is not enabled anymore
|
|
152
|
+
// (e.g. user created the wallet and then the settings were disalbed)
|
|
153
|
+
if (hasTurnkeyVerifiedCredentialAuthenticator &&
|
|
151
154
|
!hasRecoveryEmail &&
|
|
152
155
|
((_e = updateUserProfileResponse === null || updateUserProfileResponse === void 0 ? void 0 : updateUserProfileResponse.user) === null || _e === void 0 ? void 0 : _e.email)) {
|
|
153
156
|
storeAuthTokenAndUser(updateUserProfileResponse);
|
|
@@ -155,9 +158,11 @@ const EmailVerification = ({ isEmailRecoveryFlow = false, showRetryButton: _show
|
|
|
155
158
|
setShowAuthFlow(false);
|
|
156
159
|
return true;
|
|
157
160
|
}
|
|
161
|
+
// The logic below is needed when we capture an email after a user
|
|
162
|
+
// authenticated with Sms/Twitter etc And we need to capture and email.
|
|
158
163
|
if (isTurnkeyProviderEnabled) {
|
|
159
|
-
const
|
|
160
|
-
const isUsingPregeneratedWallets = Boolean(
|
|
164
|
+
const isAutomaticWalletCreation = (_g = (_f = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk) === null || _f === void 0 ? void 0 : _f.embeddedWallets) === null || _g === void 0 ? void 0 : _g.automaticEmbeddedWalletCreation;
|
|
165
|
+
const isUsingPregeneratedWallets = Boolean(isAutomaticWalletCreation &&
|
|
161
166
|
!((_j = (_h = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk) === null || _h === void 0 ? void 0 : _h.embeddedWallets) === null || _j === void 0 ? void 0 : _j.forceAuthenticatorAtSignup));
|
|
162
167
|
if (isUsingPregeneratedWallets) {
|
|
163
168
|
// Pregenerated wallet was created during an
|
|
@@ -181,7 +186,7 @@ const EmailVerification = ({ isEmailRecoveryFlow = false, showRetryButton: _show
|
|
|
181
186
|
setPrimaryWalletId(embeddedWalletVerifiedCredential.id);
|
|
182
187
|
dynamicEvents.emit('embeddedWalletCreated', wallet, embeddedWalletVerifiedCredential, updateUserProfileResponse.jwt, user);
|
|
183
188
|
}
|
|
184
|
-
if (isUsingPregeneratedWallets ||
|
|
189
|
+
if (isUsingPregeneratedWallets || !isAutomaticWalletCreation) {
|
|
185
190
|
setShowAuthFlow(false);
|
|
186
191
|
return true;
|
|
187
192
|
}
|
|
@@ -201,14 +206,25 @@ const EmailVerification = ({ isEmailRecoveryFlow = false, showRetryButton: _show
|
|
|
201
206
|
setView,
|
|
202
207
|
user,
|
|
203
208
|
]);
|
|
204
|
-
const
|
|
209
|
+
const handleEmailVerification = useCallback((verificationToken) => __awaiter(void 0, void 0, void 0, function* () {
|
|
205
210
|
setError(undefined);
|
|
206
211
|
setLoading(true);
|
|
207
|
-
if (!verificationUUID
|
|
208
|
-
|
|
209
|
-
return;
|
|
212
|
+
if (!verificationUUID) {
|
|
213
|
+
return cancelAuth();
|
|
210
214
|
}
|
|
211
|
-
|
|
215
|
+
if (!user && !unauthenticatedUser) {
|
|
216
|
+
return initAuth({
|
|
217
|
+
onVerifySuccess: () => setIsValidated(true),
|
|
218
|
+
options: { email },
|
|
219
|
+
showSuccessMessage: true,
|
|
220
|
+
verifyFunction: () => signInWithEmailVerification({
|
|
221
|
+
environmentId,
|
|
222
|
+
verificationToken,
|
|
223
|
+
verificationUUID,
|
|
224
|
+
}),
|
|
225
|
+
});
|
|
226
|
+
}
|
|
227
|
+
return completeAuth({
|
|
212
228
|
completeSignInFlow: (updateUserResponse) => __awaiter(void 0, void 0, void 0, function* () { return completeSignInFlow(updateUserResponse); }),
|
|
213
229
|
onValidUpdatedJwt: () => {
|
|
214
230
|
// This causes emaiLVerificationSuccess to be raised, so it should be set as soon
|
|
@@ -222,40 +238,16 @@ const EmailVerification = ({ isEmailRecoveryFlow = false, showRetryButton: _show
|
|
|
222
238
|
setError,
|
|
223
239
|
setLoading,
|
|
224
240
|
verificationUUID,
|
|
241
|
+
user,
|
|
242
|
+
unauthenticatedUser,
|
|
225
243
|
completeAuth,
|
|
226
244
|
email,
|
|
227
245
|
isEmailRecoveryFlow,
|
|
228
246
|
cancelAuth,
|
|
229
|
-
completeSignInFlow,
|
|
230
|
-
verifyOtp,
|
|
231
|
-
user,
|
|
232
|
-
unauthenticatedUser,
|
|
233
|
-
]);
|
|
234
|
-
const handleEmailLogin = useCallback((verificationToken) => __awaiter(void 0, void 0, void 0, function* () {
|
|
235
|
-
setError(undefined);
|
|
236
|
-
setLoading(true);
|
|
237
|
-
if (!verificationUUID) {
|
|
238
|
-
yield cancelAuth();
|
|
239
|
-
return;
|
|
240
|
-
}
|
|
241
|
-
yield initAuth({
|
|
242
|
-
onVerifySuccess: () => setIsValidated(true),
|
|
243
|
-
options: { email },
|
|
244
|
-
showSuccessMessage: true,
|
|
245
|
-
verifyFunction: () => signInWithEmailVerification({
|
|
246
|
-
environmentId,
|
|
247
|
-
verificationToken,
|
|
248
|
-
verificationUUID,
|
|
249
|
-
}),
|
|
250
|
-
});
|
|
251
|
-
}), [
|
|
252
|
-
setError,
|
|
253
|
-
setLoading,
|
|
254
|
-
verificationUUID,
|
|
255
247
|
initAuth,
|
|
256
|
-
email,
|
|
257
|
-
cancelAuth,
|
|
258
248
|
environmentId,
|
|
249
|
+
completeSignInFlow,
|
|
250
|
+
verifyOtp,
|
|
259
251
|
]);
|
|
260
252
|
const handleRetry = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
261
253
|
try {
|
|
@@ -291,7 +283,7 @@ const EmailVerification = ({ isEmailRecoveryFlow = false, showRetryButton: _show
|
|
|
291
283
|
}, []);
|
|
292
284
|
return (jsxs(Fragment, { children: [error && (jsx(ErrorContainer, { withIcon: false, className: 'email-verification__error-message', children: error })), jsxs("div", { className: classNames('email-verification__container', {
|
|
293
285
|
'email-verification__container--error': Boolean(error),
|
|
294
|
-
}), children: [showTransferMessage && (jsx("div", { className: 'email-verification__transfer-message', copykey: 'dyn_otp_verification.email.complete', children: t('dyn_otp_verification.email.complete') })), isValidated ? (jsx("div", { className: 'email-verification__icon-container', children: jsx(IconWithStatus, { containerClassName: 'email-verification__icon--verified', Icon: EmailIcon, iconSize: 64, InnerIcon: SvgCheck }) })) : (jsx(IconWithSpinner, { Icon: EmailIcon, iconSize: 96, isSpinning: true, className: 'email-verification__icon-with-spinner' })), jsxs("div", { className: 'email-verification__copy-text-container', children: [jsx(Typography, { variant: 'body_normal', weight: 'regular', color: 'secondary', copykey: 'dyn_otp_verification.description', children: t('dyn_otp_verification.description') }), jsx(Typography, { variant: 'body_normal', weight: 'bold', color: 'secondary', children: shortenEmail(email) })] }), jsx(PinField, { initialValue: Array(6).join('.').split('.'), isLoading: loading, handleComplete:
|
|
286
|
+
}), children: [showTransferMessage && (jsx("div", { className: 'email-verification__transfer-message', copykey: 'dyn_otp_verification.email.complete', children: t('dyn_otp_verification.email.complete') })), isValidated ? (jsx("div", { className: 'email-verification__icon-container', children: jsx(IconWithStatus, { containerClassName: 'email-verification__icon--verified', Icon: EmailIcon, iconSize: 64, InnerIcon: SvgCheck }) })) : (jsx(IconWithSpinner, { Icon: EmailIcon, iconSize: 96, isSpinning: true, className: 'email-verification__icon-with-spinner' })), jsxs("div", { className: 'email-verification__copy-text-container', children: [jsx(Typography, { variant: 'body_normal', weight: 'regular', color: 'secondary', copykey: 'dyn_otp_verification.description', children: t('dyn_otp_verification.description') }), jsx(Typography, { variant: 'body_normal', weight: 'bold', color: 'secondary', children: shortenEmail(email) })] }), jsx(PinField, { initialValue: Array(6).join('.').split('.'), isLoading: loading, handleComplete: handleEmailVerification, isValidated: isValidated, inputMode: 'numeric', pattern: '[0-9]*', hasError: Boolean(error), onChange: () => setError(undefined) }), showRetryButton && (jsx(RetrySendVerificationCodeSection, { className: 'email-verification__retry-container', retryHandler: handleRetry, secondsToRetry: SECONDS_TO_RETRY })), (user || unauthenticatedUser) && !isEmailRecoveryFlow && (jsx(TextButton, { className: 'email-verification__log-out', onClick: handleLogOut, copykey: 'dyn_otp_verification.log_out_button', children: t('dyn_otp_verification.log_out_button') }))] })] }));
|
|
295
287
|
};
|
|
296
288
|
|
|
297
289
|
export { EmailVerification };
|
|
@@ -84,7 +84,7 @@ var useInternalDynamicContext = require('../../../../../context/DynamicContext/u
|
|
|
84
84
|
|
|
85
85
|
const WalletSimpleSignIn = ({ previewWalletsNumber, disabled = false, onshowAllWallets, }) => {
|
|
86
86
|
const { t } = reactI18next.useTranslation();
|
|
87
|
-
const { walletConnectorOptions, projectSettings, walletsFilter, signWithEmailWalletName, authMode, multiWallet, connectedWallets, recommendedWallets, } = useInternalDynamicContext.useInternalDynamicContext();
|
|
87
|
+
const { walletConnectorOptions, projectSettings, walletsFilter, signWithEmailWalletName, authMode, multiWallet, connectedWallets, linkedWallets, recommendedWallets, } = useInternalDynamicContext.useInternalDynamicContext();
|
|
88
88
|
const { walletBook: walletBook$1 } = walletBook.useWalletBookContext();
|
|
89
89
|
const { numberOfWallets, walletsList } = walletListBuilder.walletListBuilder({
|
|
90
90
|
authMode,
|
|
@@ -93,6 +93,7 @@ const WalletSimpleSignIn = ({ previewWalletsNumber, disabled = false, onshowAllW
|
|
|
93
93
|
inputList: walletConnectorOptions,
|
|
94
94
|
isWalletConnectList: false,
|
|
95
95
|
lastUsedWalletKey: localStorage.LocalStorage.getFromLS(localStorage$1.LAST_USED_WALLET),
|
|
96
|
+
linkedWallets,
|
|
96
97
|
loginWithEmail: true,
|
|
97
98
|
multiWallet,
|
|
98
99
|
numberOfWalletsToShow: previewWalletsNumber,
|
|
@@ -80,7 +80,7 @@ import { useInternalDynamicContext } from '../../../../../context/DynamicContext
|
|
|
80
80
|
|
|
81
81
|
const WalletSimpleSignIn = ({ previewWalletsNumber, disabled = false, onshowAllWallets, }) => {
|
|
82
82
|
const { t } = useTranslation();
|
|
83
|
-
const { walletConnectorOptions, projectSettings, walletsFilter, signWithEmailWalletName, authMode, multiWallet, connectedWallets, recommendedWallets, } = useInternalDynamicContext();
|
|
83
|
+
const { walletConnectorOptions, projectSettings, walletsFilter, signWithEmailWalletName, authMode, multiWallet, connectedWallets, linkedWallets, recommendedWallets, } = useInternalDynamicContext();
|
|
84
84
|
const { walletBook } = useWalletBookContext();
|
|
85
85
|
const { numberOfWallets, walletsList } = walletListBuilder({
|
|
86
86
|
authMode,
|
|
@@ -89,6 +89,7 @@ const WalletSimpleSignIn = ({ previewWalletsNumber, disabled = false, onshowAllW
|
|
|
89
89
|
inputList: walletConnectorOptions,
|
|
90
90
|
isWalletConnectList: false,
|
|
91
91
|
lastUsedWalletKey: LocalStorage.getFromLS(LAST_USED_WALLET),
|
|
92
|
+
linkedWallets,
|
|
92
93
|
loginWithEmail: true,
|
|
93
94
|
multiWallet,
|
|
94
95
|
numberOfWalletsToShow: previewWalletsNumber,
|
|
@@ -95,7 +95,7 @@ var getEffectiveRecommendedWallets = require('./utils/getEffectiveRecommendedWal
|
|
|
95
95
|
localStorage.LocalStorage.setToLS(localStorage$1.WALLET_PICKER_SEARCH_KEY, '');
|
|
96
96
|
const WalletList = ({ isWalletConnectList = false, }) => {
|
|
97
97
|
var _a;
|
|
98
|
-
const { walletsFilter, signWithEmailWalletName, walletConnectorOptions, projectSettings, defaultNumberOfWalletsToShow, bridgeChainsToConnect, connectedWallets, authMode, multiWallet, recommendedWallets, } = useInternalDynamicContext.useInternalDynamicContext();
|
|
98
|
+
const { walletsFilter, signWithEmailWalletName, walletConnectorOptions, projectSettings, defaultNumberOfWalletsToShow, bridgeChainsToConnect, connectedWallets, linkedWallets, authMode, multiWallet, recommendedWallets, } = useInternalDynamicContext.useInternalDynamicContext();
|
|
99
99
|
const { selectedTabIndex, setSelectedTabIndex, selectedTabSettings, tabsItems, } = useTabState.useTabState();
|
|
100
100
|
const { walletBook: walletBook$1 } = walletBook.useWalletBookContext();
|
|
101
101
|
const { error } = ErrorContext.useErrorContext();
|
|
@@ -114,6 +114,7 @@ const WalletList = ({ isWalletConnectList = false, }) => {
|
|
|
114
114
|
inputList: filteredBridgeChains || walletConnectorOptions,
|
|
115
115
|
isWalletConnectList,
|
|
116
116
|
lastUsedWalletKey: localStorage.LocalStorage.getFromLS(localStorage$1.LAST_USED_WALLET),
|
|
117
|
+
linkedWallets,
|
|
117
118
|
multiWallet,
|
|
118
119
|
numberOfWalletsToShow: defaultNumberOfWalletsToShow,
|
|
119
120
|
recommendedWallets: effectiveRecommendedWallets,
|
|
@@ -91,7 +91,7 @@ import { getEffectiveRecommendedWallets } from './utils/getEffectiveRecommendedW
|
|
|
91
91
|
LocalStorage.setToLS(WALLET_PICKER_SEARCH_KEY, '');
|
|
92
92
|
const WalletList = ({ isWalletConnectList = false, }) => {
|
|
93
93
|
var _a;
|
|
94
|
-
const { walletsFilter, signWithEmailWalletName, walletConnectorOptions, projectSettings, defaultNumberOfWalletsToShow, bridgeChainsToConnect, connectedWallets, authMode, multiWallet, recommendedWallets, } = useInternalDynamicContext();
|
|
94
|
+
const { walletsFilter, signWithEmailWalletName, walletConnectorOptions, projectSettings, defaultNumberOfWalletsToShow, bridgeChainsToConnect, connectedWallets, linkedWallets, authMode, multiWallet, recommendedWallets, } = useInternalDynamicContext();
|
|
95
95
|
const { selectedTabIndex, setSelectedTabIndex, selectedTabSettings, tabsItems, } = useTabState();
|
|
96
96
|
const { walletBook } = useWalletBookContext();
|
|
97
97
|
const { error } = useErrorContext();
|
|
@@ -110,6 +110,7 @@ const WalletList = ({ isWalletConnectList = false, }) => {
|
|
|
110
110
|
inputList: filteredBridgeChains || walletConnectorOptions,
|
|
111
111
|
isWalletConnectList,
|
|
112
112
|
lastUsedWalletKey: LocalStorage.getFromLS(LAST_USED_WALLET),
|
|
113
|
+
linkedWallets,
|
|
113
114
|
multiWallet,
|
|
114
115
|
numberOfWalletsToShow: defaultNumberOfWalletsToShow,
|
|
115
116
|
recommendedWallets: effectiveRecommendedWallets,
|
|
@@ -22,12 +22,13 @@ require('@dynamic-labs/sdk-api-core');
|
|
|
22
22
|
require('../../shared/logger.cjs');
|
|
23
23
|
require('@dynamic-labs/iconic');
|
|
24
24
|
require('@dynamic-labs/wallet-connector-core');
|
|
25
|
-
require('../../context/ViewContext/ViewContext.cjs');
|
|
25
|
+
var ViewContext = require('../../context/ViewContext/ViewContext.cjs');
|
|
26
26
|
require('@dynamic-labs/wallet-book');
|
|
27
27
|
require('../../utils/constants/colors.cjs');
|
|
28
28
|
require('../../utils/constants/values.cjs');
|
|
29
29
|
require('../../shared/utils/classes/storage/localStorage.cjs');
|
|
30
30
|
require('../../shared/consts/index.cjs');
|
|
31
|
+
var useInternalDynamicContext = require('../../context/DynamicContext/useDynamicContext/useInternalDynamicContext.cjs');
|
|
31
32
|
require('../../context/CaptchaContext/CaptchaContext.cjs');
|
|
32
33
|
require('../../context/ErrorContext/ErrorContext.cjs');
|
|
33
34
|
require('@dynamic-labs/multi-wallet');
|
|
@@ -86,8 +87,12 @@ require('../DynamicWidget/context/DynamicWidgetContext.cjs');
|
|
|
86
87
|
require('../../views/TransactionConfirmationView/helpers/transactionErrorMessage.cjs');
|
|
87
88
|
require('../DynamicWidget/views/ManagePasskeysWidgetView/PasskeyCard/PasskeyCard.cjs');
|
|
88
89
|
|
|
90
|
+
const pendingSignModalView = ['pending-signature', 'wallet-sign'];
|
|
89
91
|
const DynamicMultiWalletPromptsWidget = () => {
|
|
90
92
|
const isLoggedIn = useIsLoggedIn.useIsLoggedIn();
|
|
93
|
+
const { showAuthFlow } = useInternalDynamicContext.useInternalDynamicContext();
|
|
94
|
+
const { view } = ViewContext.useViewContext();
|
|
95
|
+
const isRenderingSignMessageInLinkWalletModal = showAuthFlow && pendingSignModalView.includes(view.type);
|
|
91
96
|
const multiWalletPromptState = useMultiWalletPromptState.useMultiWalletPromptState();
|
|
92
97
|
const mapMultiWalletPromptStateToModalComponent = {
|
|
93
98
|
awaiting_connection: AwaitingConnectionModal.AwaitingConnectionModal,
|
|
@@ -98,7 +103,9 @@ const DynamicMultiWalletPromptsWidget = () => {
|
|
|
98
103
|
primary_not_connected: PrimaryNotConnectedModal.PrimaryNotConnectedModal,
|
|
99
104
|
unlink_wallet: UnlinkWalletPopUp.UnlinkWalletPopUpModal,
|
|
100
105
|
};
|
|
101
|
-
if (multiWalletPromptState === 'idle' ||
|
|
106
|
+
if (multiWalletPromptState === 'idle' ||
|
|
107
|
+
isRenderingSignMessageInLinkWalletModal ||
|
|
108
|
+
!isLoggedIn)
|
|
102
109
|
return null;
|
|
103
110
|
const ModalComponent = mapMultiWalletPromptStateToModalComponent[multiWalletPromptState];
|
|
104
111
|
return (jsxRuntime.jsx(DynamicBaseWidget.DynamicBaseWidget, { children: jsxRuntime.jsx(ModalComponent, {}) }));
|
|
@@ -18,12 +18,13 @@ import '@dynamic-labs/sdk-api-core';
|
|
|
18
18
|
import '../../shared/logger.js';
|
|
19
19
|
import '@dynamic-labs/iconic';
|
|
20
20
|
import '@dynamic-labs/wallet-connector-core';
|
|
21
|
-
import '../../context/ViewContext/ViewContext.js';
|
|
21
|
+
import { useViewContext } from '../../context/ViewContext/ViewContext.js';
|
|
22
22
|
import '@dynamic-labs/wallet-book';
|
|
23
23
|
import '../../utils/constants/colors.js';
|
|
24
24
|
import '../../utils/constants/values.js';
|
|
25
25
|
import '../../shared/utils/classes/storage/localStorage.js';
|
|
26
26
|
import '../../shared/consts/index.js';
|
|
27
|
+
import { useInternalDynamicContext } from '../../context/DynamicContext/useDynamicContext/useInternalDynamicContext.js';
|
|
27
28
|
import '../../context/CaptchaContext/CaptchaContext.js';
|
|
28
29
|
import '../../context/ErrorContext/ErrorContext.js';
|
|
29
30
|
import '@dynamic-labs/multi-wallet';
|
|
@@ -82,8 +83,12 @@ import '../DynamicWidget/context/DynamicWidgetContext.js';
|
|
|
82
83
|
import '../../views/TransactionConfirmationView/helpers/transactionErrorMessage.js';
|
|
83
84
|
import '../DynamicWidget/views/ManagePasskeysWidgetView/PasskeyCard/PasskeyCard.js';
|
|
84
85
|
|
|
86
|
+
const pendingSignModalView = ['pending-signature', 'wallet-sign'];
|
|
85
87
|
const DynamicMultiWalletPromptsWidget = () => {
|
|
86
88
|
const isLoggedIn = useIsLoggedIn();
|
|
89
|
+
const { showAuthFlow } = useInternalDynamicContext();
|
|
90
|
+
const { view } = useViewContext();
|
|
91
|
+
const isRenderingSignMessageInLinkWalletModal = showAuthFlow && pendingSignModalView.includes(view.type);
|
|
87
92
|
const multiWalletPromptState = useMultiWalletPromptState();
|
|
88
93
|
const mapMultiWalletPromptStateToModalComponent = {
|
|
89
94
|
awaiting_connection: AwaitingConnectionModal,
|
|
@@ -94,7 +99,9 @@ const DynamicMultiWalletPromptsWidget = () => {
|
|
|
94
99
|
primary_not_connected: PrimaryNotConnectedModal,
|
|
95
100
|
unlink_wallet: UnlinkWalletPopUpModal,
|
|
96
101
|
};
|
|
97
|
-
if (multiWalletPromptState === 'idle' ||
|
|
102
|
+
if (multiWalletPromptState === 'idle' ||
|
|
103
|
+
isRenderingSignMessageInLinkWalletModal ||
|
|
104
|
+
!isLoggedIn)
|
|
98
105
|
return null;
|
|
99
106
|
const ModalComponent = mapMultiWalletPromptStateToModalComponent[multiWalletPromptState];
|
|
100
107
|
return (jsx(DynamicBaseWidget, { children: jsx(ModalComponent, {}) }));
|