@dynamic-labs/sdk-react-core 2.1.2-alpha.1 → 2.1.3
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 +32 -0
- package/package.cjs +1 -1
- package/package.js +1 -1
- package/package.json +13 -13
- package/src/lib/components/AuthProviderIcon/AuthProviderIcon.cjs +1 -1
- package/src/lib/components/AuthProviderIcon/AuthProviderIcon.js +1 -1
- 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/SignMessagePreview/SignMessagePreview.cjs +13 -5
- package/src/lib/components/SignMessagePreview/SignMessagePreview.js +13 -5
- package/src/lib/components/SignMessagePreview/SignMessagePreview.types.d.ts +3 -0
- package/src/lib/components/SignMessagePreview/utils/containsSpecialCharacters/containsSpecialCharacters.cjs +12 -0
- package/src/lib/components/SignMessagePreview/utils/containsSpecialCharacters/containsSpecialCharacters.d.ts +1 -0
- package/src/lib/components/SignMessagePreview/utils/containsSpecialCharacters/containsSpecialCharacters.js +8 -0
- package/src/lib/components/SignMessagePreview/utils/containsSpecialCharacters/index.d.ts +1 -0
- package/src/lib/components/SignMessagePreview/utils/index.d.ts +1 -0
- package/src/lib/components/SignMessagePreview/utils/isRawMessage/index.d.ts +1 -0
- package/src/lib/components/SignMessagePreview/utils/isRawMessage/isRawMessage.cjs +13 -0
- package/src/lib/components/SignMessagePreview/utils/isRawMessage/isRawMessage.d.ts +2 -0
- package/src/lib/components/SignMessagePreview/utils/isRawMessage/isRawMessage.js +9 -0
- package/src/lib/context/DynamicContext/DynamicContext.cjs +6 -4
- package/src/lib/context/DynamicContext/DynamicContext.d.ts +5 -0
- package/src/lib/context/DynamicContext/DynamicContext.js +6 -4
- package/src/lib/context/DynamicContext/types/index.d.ts +2 -0
- package/src/lib/shared/types/wallets.d.ts +1 -0
- package/src/lib/styles/index.shadow.cjs +1 -1
- package/src/lib/styles/index.shadow.js +1 -1
- package/src/lib/utils/functions/createOwnerWallet/createOwnerWallet.cjs +1 -0
- package/src/lib/utils/functions/createOwnerWallet/createOwnerWallet.js +1 -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/applyMultiWalletFilters/applyMultiWalletFilters.cjs +24 -0
- package/src/lib/utils/functions/walletListBuilder/utils/applyMultiWalletFilters/applyMultiWalletFilters.d.ts +6 -0
- package/src/lib/utils/functions/walletListBuilder/utils/applyMultiWalletFilters/applyMultiWalletFilters.js +20 -0
- package/src/lib/utils/functions/walletListBuilder/utils/applyMultiWalletFilters/index.d.ts +1 -0
- package/src/lib/utils/functions/walletListBuilder/utils/filterConnectedWallets/filterConnectedWallets.cjs +2 -2
- package/src/lib/utils/functions/walletListBuilder/utils/filterConnectedWallets/filterConnectedWallets.d.ts +2 -2
- package/src/lib/utils/functions/walletListBuilder/utils/filterConnectedWallets/filterConnectedWallets.js +2 -2
- package/src/lib/utils/functions/walletListBuilder/utils/filterWalletConnectWallets/filterWalletConnectWallets.cjs +20 -0
- package/src/lib/utils/functions/walletListBuilder/utils/filterWalletConnectWallets/filterWalletConnectWallets.d.ts +9 -0
- package/src/lib/utils/functions/walletListBuilder/utils/filterWalletConnectWallets/filterWalletConnectWallets.js +16 -0
- package/src/lib/utils/functions/walletListBuilder/utils/filterWalletConnectWallets/index.d.ts +1 -0
- 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 +6 -5
- package/src/lib/utils/functions/walletListBuilder/walletListBuilder.d.ts +2 -2
- package/src/lib/utils/functions/walletListBuilder/walletListBuilder.js +6 -5
- package/src/lib/utils/hooks/useConnectWallet/useConnectWallet.cjs +1 -0
- package/src/lib/utils/hooks/useConnectWallet/useConnectWallet.js +1 -0
- package/src/lib/utils/hooks/useCreateDynamicEmbeddedWalletMutation/useCreateDynamicEmbeddedWalletMutation.cjs +1 -0
- package/src/lib/utils/hooks/useCreateDynamicEmbeddedWalletMutation/useCreateDynamicEmbeddedWalletMutation.js +1 -0
- package/src/lib/utils/hooks/useEmbeddedWallet/useMPCEmbeddedWallet/useCoinbaseMPC/useCoinbaseMPC.cjs +7 -3
- package/src/lib/utils/hooks/useEmbeddedWallet/useMPCEmbeddedWallet/useCoinbaseMPC/useCoinbaseMPC.js +7 -3
- package/src/lib/utils/hooks/useEmbeddedWallet/useSecureEnclaveEmbeddedWallet/useTurnkey/useTurnkey.cjs +5 -1
- package/src/lib/utils/hooks/useEmbeddedWallet/useSecureEnclaveEmbeddedWallet/useTurnkey/useTurnkey.js +5 -1
- package/src/lib/utils/hooks/useNetworkNotSupported/useNetworkNotSupported.cjs +14 -8
- package/src/lib/utils/hooks/useNetworkNotSupported/useNetworkNotSupported.js +14 -8
- package/src/lib/utils/hooks/useSwitchWallet/useSwitchWallet.cjs +1 -1
- package/src/lib/utils/hooks/useSwitchWallet/useSwitchWallet.js +1 -1
- package/src/lib/utils/hooks/useWalletConnectors/utils/createLinkedWalletsFromWalletOptions/createLinkedWalletsFromWalletOptions.cjs +2 -0
- package/src/lib/utils/hooks/useWalletConnectors/utils/createLinkedWalletsFromWalletOptions/createLinkedWalletsFromWalletOptions.js +2 -0
- package/src/lib/utils/hooks/useWalletConnectors/utils/findWallet/findWallet.cjs +4 -1
- package/src/lib/utils/hooks/useWalletConnectors/utils/findWallet/findWallet.js +4 -1
- package/src/lib/utils/hooks/useWalletUiUtils/useWalletUiUtils.cjs +1 -1
- package/src/lib/utils/hooks/useWalletUiUtils/useWalletUiUtils.js +1 -1
- package/src/lib/views/EmailVerification/EmailVerification.cjs +35 -42
- package/src/lib/views/EmailVerification/EmailVerification.js +35 -42
- package/src/lib/views/LoginView/sections/WalletSignInSection/WalletSimpleSignIn/WalletSimpleSignIn.cjs +4 -3
- package/src/lib/views/LoginView/sections/WalletSignInSection/WalletSimpleSignIn/WalletSimpleSignIn.js +4 -3
- package/src/lib/views/WalletList/WalletList.cjs +4 -3
- package/src/lib/views/WalletList/WalletList.js +4 -3
- package/src/lib/widgets/DynamicMultiWalletPromptsWidget/DynamicMultiWalletPromptsWidget.cjs +9 -2
- package/src/lib/widgets/DynamicMultiWalletPromptsWidget/DynamicMultiWalletPromptsWidget.js +9 -2
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
var filterConnectedWallets = require('../filterConnectedWallets/filterConnectedWallets.cjs');
|
|
7
|
+
var staticLinkedWalletFilter = require('../staticLinkedWalletFilter/staticLinkedWalletFilter.cjs');
|
|
8
|
+
var filterWalletConnectWallets = require('../filterWalletConnectWallets/filterWalletConnectWallets.cjs');
|
|
9
|
+
|
|
10
|
+
const applyMultiWalletFilters = ({ authMode, userWallets, walletOptions, }) => {
|
|
11
|
+
const walletList = filterWalletConnectWallets.filterWalletConnectWallets({
|
|
12
|
+
userWallets,
|
|
13
|
+
walletOptions,
|
|
14
|
+
});
|
|
15
|
+
if (authMode === 'connect-only') {
|
|
16
|
+
return filterConnectedWallets.filterConnectedWallets({
|
|
17
|
+
userWallets,
|
|
18
|
+
walletOptions: walletList,
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
return staticLinkedWalletFilter.staticWalletFilter(userWallets, walletList);
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
exports.applyMultiWalletFilters = applyMultiWalletFilters;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { AuthModeType, Wallet, WalletOption } from '../../../../../shared';
|
|
2
|
+
export declare const applyMultiWalletFilters: ({ authMode, userWallets, walletOptions, }: {
|
|
3
|
+
authMode: AuthModeType;
|
|
4
|
+
userWallets: Wallet[];
|
|
5
|
+
walletOptions: WalletOption[];
|
|
6
|
+
}) => WalletOption[];
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
import { filterConnectedWallets } from '../filterConnectedWallets/filterConnectedWallets.js';
|
|
3
|
+
import { staticWalletFilter } from '../staticLinkedWalletFilter/staticLinkedWalletFilter.js';
|
|
4
|
+
import { filterWalletConnectWallets } from '../filterWalletConnectWallets/filterWalletConnectWallets.js';
|
|
5
|
+
|
|
6
|
+
const applyMultiWalletFilters = ({ authMode, userWallets, walletOptions, }) => {
|
|
7
|
+
const walletList = filterWalletConnectWallets({
|
|
8
|
+
userWallets,
|
|
9
|
+
walletOptions,
|
|
10
|
+
});
|
|
11
|
+
if (authMode === 'connect-only') {
|
|
12
|
+
return filterConnectedWallets({
|
|
13
|
+
userWallets,
|
|
14
|
+
walletOptions: walletList,
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
return staticWalletFilter(userWallets, walletList);
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export { applyMultiWalletFilters };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './applyMultiWalletFilters';
|
|
@@ -8,8 +8,8 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
8
8
|
* This is useful for connect-only multi-wallet, where we want users to only connect new wallets,
|
|
9
9
|
* not additional accounts from the same wallet
|
|
10
10
|
*/
|
|
11
|
-
const filterConnectedWallets = ({ walletOptions,
|
|
12
|
-
const connectedWalletKeys = new Set(
|
|
11
|
+
const filterConnectedWallets = ({ walletOptions, userWallets, }) => {
|
|
12
|
+
const connectedWalletKeys = new Set(userWallets.map((connectedWallet) => connectedWallet.connector.key));
|
|
13
13
|
/**
|
|
14
14
|
* Phantom and Phantom Ledger are the same wallet, so we have to filter both of them
|
|
15
15
|
* if one is present, because the next connection will not work, it will just connect the
|
|
@@ -4,7 +4,7 @@ import { Wallet, WalletOption } from '../../../../../shared';
|
|
|
4
4
|
* This is useful for connect-only multi-wallet, where we want users to only connect new wallets,
|
|
5
5
|
* not additional accounts from the same wallet
|
|
6
6
|
*/
|
|
7
|
-
export declare const filterConnectedWallets: ({ walletOptions,
|
|
7
|
+
export declare const filterConnectedWallets: ({ walletOptions, userWallets, }: {
|
|
8
8
|
walletOptions: WalletOption[];
|
|
9
|
-
|
|
9
|
+
userWallets: Wallet[];
|
|
10
10
|
}) => WalletOption[];
|
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
* This is useful for connect-only multi-wallet, where we want users to only connect new wallets,
|
|
5
5
|
* not additional accounts from the same wallet
|
|
6
6
|
*/
|
|
7
|
-
const filterConnectedWallets = ({ walletOptions,
|
|
8
|
-
const connectedWalletKeys = new Set(
|
|
7
|
+
const filterConnectedWallets = ({ walletOptions, userWallets, }) => {
|
|
8
|
+
const connectedWalletKeys = new Set(userWallets.map((connectedWallet) => connectedWallet.connector.key));
|
|
9
9
|
/**
|
|
10
10
|
* Phantom and Phantom Ledger are the same wallet, so we have to filter both of them
|
|
11
11
|
* if one is present, because the next connection will not work, it will just connect the
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Used to filter out WalletConnect wallets if user has already a WalletConnect wallet connected/linked
|
|
8
|
+
* This is useful for multi-wallet on mobile, since WalletConnect doesn't work very well with multiwallet
|
|
9
|
+
*/
|
|
10
|
+
const filterWalletConnectWallets = ({ walletOptions, userWallets, }) => {
|
|
11
|
+
const hasWCWallet = userWallets.some((wallet) => wallet.connector.isWalletConnect);
|
|
12
|
+
// user doesn't have any WalletConnect wallet connected/linked, so we don't need to filter anything
|
|
13
|
+
if (!hasWCWallet) {
|
|
14
|
+
return walletOptions;
|
|
15
|
+
}
|
|
16
|
+
// filter out WalletConnect wallets
|
|
17
|
+
return walletOptions.filter((walletOption) => !walletOption.walletConnector.isWalletConnect);
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
exports.filterWalletConnectWallets = filterWalletConnectWallets;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Wallet, WalletOption } from '../../../../../shared';
|
|
2
|
+
/**
|
|
3
|
+
* Used to filter out WalletConnect wallets if user has already a WalletConnect wallet connected/linked
|
|
4
|
+
* This is useful for multi-wallet on mobile, since WalletConnect doesn't work very well with multiwallet
|
|
5
|
+
*/
|
|
6
|
+
export declare const filterWalletConnectWallets: ({ walletOptions, userWallets, }: {
|
|
7
|
+
walletOptions: WalletOption[];
|
|
8
|
+
userWallets: Wallet[];
|
|
9
|
+
}) => WalletOption[];
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
/**
|
|
3
|
+
* Used to filter out WalletConnect wallets if user has already a WalletConnect wallet connected/linked
|
|
4
|
+
* This is useful for multi-wallet on mobile, since WalletConnect doesn't work very well with multiwallet
|
|
5
|
+
*/
|
|
6
|
+
const filterWalletConnectWallets = ({ walletOptions, userWallets, }) => {
|
|
7
|
+
const hasWCWallet = userWallets.some((wallet) => wallet.connector.isWalletConnect);
|
|
8
|
+
// user doesn't have any WalletConnect wallet connected/linked, so we don't need to filter anything
|
|
9
|
+
if (!hasWCWallet) {
|
|
10
|
+
return walletOptions;
|
|
11
|
+
}
|
|
12
|
+
// filter out WalletConnect wallets
|
|
13
|
+
return walletOptions.filter((walletOption) => !walletOption.walletConnector.isWalletConnect);
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export { filterWalletConnectWallets };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './filterWalletConnectWallets';
|
|
@@ -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 };
|
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
6
6
|
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
|
-
var
|
|
9
|
+
var applyMultiWalletFilters = require('./utils/applyMultiWalletFilters/applyMultiWalletFilters.cjs');
|
|
10
10
|
|
|
11
11
|
const PRIORITY_WALLET_LIST = [
|
|
12
12
|
'metamask',
|
|
@@ -56,15 +56,16 @@ const sortedInputList = (inputList, recommendedWalletKeys) => {
|
|
|
56
56
|
...unsortedOtherWallets,
|
|
57
57
|
];
|
|
58
58
|
};
|
|
59
|
-
const walletListBuilder = ({ authMode,
|
|
59
|
+
const walletListBuilder = ({ authMode, userWallets, multiWallet, numberOfWalletsToShow, inputList, isWalletConnectList, lastUsedWalletKey, signWithEmailWalletName, searchFilter, walletsFilter, loginWithEmail, groupWallets, walletBook, showMoreWalletsWithFilter, recommendedWallets, }) => {
|
|
60
60
|
let walletList = inputList;
|
|
61
61
|
if (isWalletConnectList) {
|
|
62
62
|
walletList = inputList.filter((wallet) => wallet.walletConnector.isWalletConnect &&
|
|
63
63
|
wallet.key !== 'walletconnect');
|
|
64
64
|
}
|
|
65
|
-
if (
|
|
66
|
-
walletList =
|
|
67
|
-
|
|
65
|
+
if (multiWallet) {
|
|
66
|
+
walletList = applyMultiWalletFilters.applyMultiWalletFilters({
|
|
67
|
+
authMode,
|
|
68
|
+
userWallets,
|
|
68
69
|
walletOptions: walletList,
|
|
69
70
|
});
|
|
70
71
|
}
|
|
@@ -2,7 +2,7 @@ import { WalletBookSchema } from '@dynamic-labs/wallet-book';
|
|
|
2
2
|
import { AuthModeType, RecommendedWallet, Wallet, WalletOption } from '../../../shared/types';
|
|
3
3
|
type BuilderParams = {
|
|
4
4
|
authMode: AuthModeType;
|
|
5
|
-
|
|
5
|
+
userWallets: Wallet[];
|
|
6
6
|
multiWallet: boolean;
|
|
7
7
|
inputList: WalletOption[];
|
|
8
8
|
isWalletConnectList: boolean;
|
|
@@ -23,7 +23,7 @@ type BuilderResult = {
|
|
|
23
23
|
};
|
|
24
24
|
export declare const PRIORITY_WALLET_LIST: string[];
|
|
25
25
|
export declare const SIGN_IN_WITH_EMAIL_WALLET_NAME = "Sign In With Email";
|
|
26
|
-
export declare const walletListBuilder: ({ authMode,
|
|
26
|
+
export declare const walletListBuilder: ({ authMode, userWallets, multiWallet, numberOfWalletsToShow, inputList, isWalletConnectList, lastUsedWalletKey, signWithEmailWalletName, searchFilter, walletsFilter, loginWithEmail, groupWallets, walletBook, showMoreWalletsWithFilter, recommendedWallets, }: BuilderParams) => BuilderResult;
|
|
27
27
|
/**
|
|
28
28
|
* This calculation adds an offset to numberOfWalletsToShow so we will show the
|
|
29
29
|
* intended wallets + installed and last used.
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
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
|
-
import {
|
|
5
|
+
import { applyMultiWalletFilters } from './utils/applyMultiWalletFilters/applyMultiWalletFilters.js';
|
|
6
6
|
|
|
7
7
|
const PRIORITY_WALLET_LIST = [
|
|
8
8
|
'metamask',
|
|
@@ -52,15 +52,16 @@ const sortedInputList = (inputList, recommendedWalletKeys) => {
|
|
|
52
52
|
...unsortedOtherWallets,
|
|
53
53
|
];
|
|
54
54
|
};
|
|
55
|
-
const walletListBuilder = ({ authMode,
|
|
55
|
+
const walletListBuilder = ({ authMode, userWallets, multiWallet, numberOfWalletsToShow, inputList, isWalletConnectList, lastUsedWalletKey, signWithEmailWalletName, searchFilter, walletsFilter, loginWithEmail, groupWallets, walletBook, showMoreWalletsWithFilter, recommendedWallets, }) => {
|
|
56
56
|
let walletList = inputList;
|
|
57
57
|
if (isWalletConnectList) {
|
|
58
58
|
walletList = inputList.filter((wallet) => wallet.walletConnector.isWalletConnect &&
|
|
59
59
|
wallet.key !== 'walletconnect');
|
|
60
60
|
}
|
|
61
|
-
if (
|
|
62
|
-
walletList =
|
|
63
|
-
|
|
61
|
+
if (multiWallet) {
|
|
62
|
+
walletList = applyMultiWalletFilters({
|
|
63
|
+
authMode,
|
|
64
|
+
userWallets,
|
|
64
65
|
walletOptions: walletList,
|
|
65
66
|
});
|
|
66
67
|
}
|
|
@@ -103,6 +103,7 @@ const useConnectWallet = ({ authMode, clearPrimaryWalletId, enableVisitTrackingO
|
|
|
103
103
|
connected: true,
|
|
104
104
|
connector: walletConnector,
|
|
105
105
|
id: storedConnectedWalletInfo.id,
|
|
106
|
+
key: walletConnector.key,
|
|
106
107
|
network: walletNetwork,
|
|
107
108
|
};
|
|
108
109
|
return walletObject;
|
|
@@ -99,6 +99,7 @@ const useConnectWallet = ({ authMode, clearPrimaryWalletId, enableVisitTrackingO
|
|
|
99
99
|
connected: true,
|
|
100
100
|
connector: walletConnector,
|
|
101
101
|
id: storedConnectedWalletInfo.id,
|
|
102
|
+
key: walletConnector.key,
|
|
102
103
|
network: walletNetwork,
|
|
103
104
|
};
|
|
104
105
|
return walletObject;
|
|
@@ -119,6 +119,7 @@ const useCreateDynamicEmbeddedWalletMutation = () => {
|
|
|
119
119
|
connected: true,
|
|
120
120
|
connector: walletConnector,
|
|
121
121
|
id: embeddedWalletVerifiedCredential.id,
|
|
122
|
+
key: embeddedWalletVerifiedCredential.walletName || walletConnector.key,
|
|
122
123
|
};
|
|
123
124
|
const smartWallet$1 = smartWallet.findSmartWallet(embeddedWalletVerifiedCredential, updatedUser.verifiedCredentials);
|
|
124
125
|
if (!smartWallet$1) {
|
|
@@ -115,6 +115,7 @@ const useCreateDynamicEmbeddedWalletMutation = () => {
|
|
|
115
115
|
connected: true,
|
|
116
116
|
connector: walletConnector,
|
|
117
117
|
id: embeddedWalletVerifiedCredential.id,
|
|
118
|
+
key: embeddedWalletVerifiedCredential.walletName || walletConnector.key,
|
|
118
119
|
};
|
|
119
120
|
const smartWallet = findSmartWallet(embeddedWalletVerifiedCredential, updatedUser.verifiedCredentials);
|
|
120
121
|
if (!smartWallet) {
|
package/src/lib/utils/hooks/useEmbeddedWallet/useMPCEmbeddedWallet/useCoinbaseMPC/useCoinbaseMPC.cjs
CHANGED
|
@@ -92,6 +92,7 @@ const useCoinbaseMPC = () => {
|
|
|
92
92
|
const { user, setPrimaryWalletId, walletConnectorOptions, environmentId, consumeNonce, displaySiweStatement, appName, siweStatement, handleLogOut, setShowAuthFlow, } = useInternalDynamicContext.useInternalDynamicContext();
|
|
93
93
|
const { setError } = ErrorContext.useErrorContext();
|
|
94
94
|
const returnExistingCoinbaseMPCWallet = React.useCallback((validatedUser, connector, embeddedWalletVerifiedCredential) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
95
|
+
var _a;
|
|
95
96
|
connector.setVerifiedCredentials(validatedUser.verifiedCredentials);
|
|
96
97
|
setPrimaryWalletId(embeddedWalletVerifiedCredential.id);
|
|
97
98
|
const coinbaseMPCWallet = {
|
|
@@ -101,10 +102,11 @@ const useCoinbaseMPC = () => {
|
|
|
101
102
|
connected: true,
|
|
102
103
|
connector,
|
|
103
104
|
id: embeddedWalletVerifiedCredential.id,
|
|
105
|
+
key: (_a = embeddedWalletVerifiedCredential.walletName) !== null && _a !== void 0 ? _a : connector.key,
|
|
104
106
|
};
|
|
105
107
|
return coinbaseMPCWallet;
|
|
106
108
|
}), [setPrimaryWalletId]);
|
|
107
|
-
const linkCoinbaseMPCWallet = React.useCallback((
|
|
109
|
+
const linkCoinbaseMPCWallet = React.useCallback((_b) => _tslib.__awaiter(void 0, [_b], void 0, function* ({ connector, backupCode, password, source, }) {
|
|
108
110
|
const nonce = consumeNonce();
|
|
109
111
|
if (nonce === undefined)
|
|
110
112
|
throw new utils.DynamicError('Missing nonce');
|
|
@@ -145,6 +147,7 @@ const useCoinbaseMPC = () => {
|
|
|
145
147
|
siweStatement,
|
|
146
148
|
]);
|
|
147
149
|
const createNewCoinbaseMPCWallet = React.useCallback((connector, password) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
150
|
+
var _c;
|
|
148
151
|
const initialWalletPassword = password
|
|
149
152
|
? password
|
|
150
153
|
: generateRandomPassword.generateRandomPassword(DYNAMIC_PASSWORD_LENGTH);
|
|
@@ -166,6 +169,7 @@ const useCoinbaseMPC = () => {
|
|
|
166
169
|
connected: true,
|
|
167
170
|
connector,
|
|
168
171
|
id: newSelectedCredentialWallet.id,
|
|
172
|
+
key: (_c = newSelectedCredentialWallet.walletName) !== null && _c !== void 0 ? _c : connector.key,
|
|
169
173
|
};
|
|
170
174
|
dynamicEvents.dynamicEvents.emit('embeddedWalletCreated', coinbaseMPCWallet, newSelectedCredentialWallet, getAuthToken.getAuthToken(), updatedUser);
|
|
171
175
|
return coinbaseMPCWallet;
|
|
@@ -181,11 +185,11 @@ const useCoinbaseMPC = () => {
|
|
|
181
185
|
return undefined;
|
|
182
186
|
}), [linkCoinbaseMPCWallet, handleLogOut, setError]);
|
|
183
187
|
const createCoinbaseMPCWallet = React.useCallback((...args_1) => _tslib.__awaiter(void 0, [...args_1], void 0, function* (chains = [sdkApiCore.ChainEnum.Evm], password) {
|
|
184
|
-
var
|
|
188
|
+
var _d;
|
|
185
189
|
if (!user) {
|
|
186
190
|
throw new utils.DynamicError(errors.USER_NOT_LOGGED_IN);
|
|
187
191
|
}
|
|
188
|
-
const connector = (
|
|
192
|
+
const connector = (_d = findCoinbaseMPCWallet.findCoinbaseMPCWallet(walletConnectorOptions)) === null || _d === void 0 ? void 0 : _d.walletConnector;
|
|
189
193
|
if (!connector || !walletConnectorCore.isCoinbaseMpcWalletConnector(connector)) {
|
|
190
194
|
const error = new utils.DynamicError('CoinbaseWaaSWalletConnectors not found');
|
|
191
195
|
logger.logger.error('Failed to create embedded wallet', error);
|
package/src/lib/utils/hooks/useEmbeddedWallet/useMPCEmbeddedWallet/useCoinbaseMPC/useCoinbaseMPC.js
CHANGED
|
@@ -88,6 +88,7 @@ const useCoinbaseMPC = () => {
|
|
|
88
88
|
const { user, setPrimaryWalletId, walletConnectorOptions, environmentId, consumeNonce, displaySiweStatement, appName, siweStatement, handleLogOut, setShowAuthFlow, } = useInternalDynamicContext();
|
|
89
89
|
const { setError } = useErrorContext();
|
|
90
90
|
const returnExistingCoinbaseMPCWallet = useCallback((validatedUser, connector, embeddedWalletVerifiedCredential) => __awaiter(void 0, void 0, void 0, function* () {
|
|
91
|
+
var _a;
|
|
91
92
|
connector.setVerifiedCredentials(validatedUser.verifiedCredentials);
|
|
92
93
|
setPrimaryWalletId(embeddedWalletVerifiedCredential.id);
|
|
93
94
|
const coinbaseMPCWallet = {
|
|
@@ -97,10 +98,11 @@ const useCoinbaseMPC = () => {
|
|
|
97
98
|
connected: true,
|
|
98
99
|
connector,
|
|
99
100
|
id: embeddedWalletVerifiedCredential.id,
|
|
101
|
+
key: (_a = embeddedWalletVerifiedCredential.walletName) !== null && _a !== void 0 ? _a : connector.key,
|
|
100
102
|
};
|
|
101
103
|
return coinbaseMPCWallet;
|
|
102
104
|
}), [setPrimaryWalletId]);
|
|
103
|
-
const linkCoinbaseMPCWallet = useCallback((
|
|
105
|
+
const linkCoinbaseMPCWallet = useCallback((_b) => __awaiter(void 0, [_b], void 0, function* ({ connector, backupCode, password, source, }) {
|
|
104
106
|
const nonce = consumeNonce();
|
|
105
107
|
if (nonce === undefined)
|
|
106
108
|
throw new DynamicError('Missing nonce');
|
|
@@ -141,6 +143,7 @@ const useCoinbaseMPC = () => {
|
|
|
141
143
|
siweStatement,
|
|
142
144
|
]);
|
|
143
145
|
const createNewCoinbaseMPCWallet = useCallback((connector, password) => __awaiter(void 0, void 0, void 0, function* () {
|
|
146
|
+
var _c;
|
|
144
147
|
const initialWalletPassword = password
|
|
145
148
|
? password
|
|
146
149
|
: generateRandomPassword(DYNAMIC_PASSWORD_LENGTH);
|
|
@@ -162,6 +165,7 @@ const useCoinbaseMPC = () => {
|
|
|
162
165
|
connected: true,
|
|
163
166
|
connector,
|
|
164
167
|
id: newSelectedCredentialWallet.id,
|
|
168
|
+
key: (_c = newSelectedCredentialWallet.walletName) !== null && _c !== void 0 ? _c : connector.key,
|
|
165
169
|
};
|
|
166
170
|
dynamicEvents.emit('embeddedWalletCreated', coinbaseMPCWallet, newSelectedCredentialWallet, getAuthToken(), updatedUser);
|
|
167
171
|
return coinbaseMPCWallet;
|
|
@@ -177,11 +181,11 @@ const useCoinbaseMPC = () => {
|
|
|
177
181
|
return undefined;
|
|
178
182
|
}), [linkCoinbaseMPCWallet, handleLogOut, setError]);
|
|
179
183
|
const createCoinbaseMPCWallet = useCallback((...args_1) => __awaiter(void 0, [...args_1], void 0, function* (chains = [ChainEnum.Evm], password) {
|
|
180
|
-
var
|
|
184
|
+
var _d;
|
|
181
185
|
if (!user) {
|
|
182
186
|
throw new DynamicError(USER_NOT_LOGGED_IN);
|
|
183
187
|
}
|
|
184
|
-
const connector = (
|
|
188
|
+
const connector = (_d = findCoinbaseMPCWallet(walletConnectorOptions)) === null || _d === void 0 ? void 0 : _d.walletConnector;
|
|
185
189
|
if (!connector || !isCoinbaseMpcWalletConnector(connector)) {
|
|
186
190
|
const error = new DynamicError('CoinbaseWaaSWalletConnectors not found');
|
|
187
191
|
logger.error('Failed to create embedded wallet', error);
|
|
@@ -161,11 +161,14 @@ const useTurnkey = () => {
|
|
|
161
161
|
connected: true,
|
|
162
162
|
connector: (turnkeyWallet === null || turnkeyWallet === void 0 ? void 0 : turnkeyWallet.walletConnector) || {},
|
|
163
163
|
id: embeddedWalletVerifiedCredential.id,
|
|
164
|
+
key: embeddedWalletVerifiedCredential.walletName ||
|
|
165
|
+
(turnkeyWallet === null || turnkeyWallet === void 0 ? void 0 : turnkeyWallet.walletConnector.key) ||
|
|
166
|
+
'',
|
|
164
167
|
};
|
|
165
168
|
return Promise.resolve(passkeyWallet);
|
|
166
169
|
}), [setPrimaryWalletId, walletConnectorOptions, user]);
|
|
167
170
|
const createTurnkeyWallet = React.useCallback((chains, options) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
168
|
-
var _e, _f, _g, _h;
|
|
171
|
+
var _e, _f, _g, _h, _j;
|
|
169
172
|
if (!user) {
|
|
170
173
|
throw new Error(errors.USER_NOT_LOGGED_IN);
|
|
171
174
|
}
|
|
@@ -207,6 +210,7 @@ const useTurnkey = () => {
|
|
|
207
210
|
connected: true,
|
|
208
211
|
connector: walletConnector,
|
|
209
212
|
id: embeddedWalletVerifiedCredential.id,
|
|
213
|
+
key: (_j = embeddedWalletVerifiedCredential.walletName) !== null && _j !== void 0 ? _j : walletConnector.key,
|
|
210
214
|
};
|
|
211
215
|
setPrimaryWalletId(embeddedWalletVerifiedCredential.id);
|
|
212
216
|
dynamicEvents.dynamicEvents.emit('embeddedWalletCreated', wallet, embeddedWalletVerifiedCredential, getAuthToken.getAuthToken(), user);
|
|
@@ -157,11 +157,14 @@ const useTurnkey = () => {
|
|
|
157
157
|
connected: true,
|
|
158
158
|
connector: (turnkeyWallet === null || turnkeyWallet === void 0 ? void 0 : turnkeyWallet.walletConnector) || {},
|
|
159
159
|
id: embeddedWalletVerifiedCredential.id,
|
|
160
|
+
key: embeddedWalletVerifiedCredential.walletName ||
|
|
161
|
+
(turnkeyWallet === null || turnkeyWallet === void 0 ? void 0 : turnkeyWallet.walletConnector.key) ||
|
|
162
|
+
'',
|
|
160
163
|
};
|
|
161
164
|
return Promise.resolve(passkeyWallet);
|
|
162
165
|
}), [setPrimaryWalletId, walletConnectorOptions, user]);
|
|
163
166
|
const createTurnkeyWallet = useCallback((chains, options) => __awaiter(void 0, void 0, void 0, function* () {
|
|
164
|
-
var _e, _f, _g, _h;
|
|
167
|
+
var _e, _f, _g, _h, _j;
|
|
165
168
|
if (!user) {
|
|
166
169
|
throw new Error(USER_NOT_LOGGED_IN);
|
|
167
170
|
}
|
|
@@ -203,6 +206,7 @@ const useTurnkey = () => {
|
|
|
203
206
|
connected: true,
|
|
204
207
|
connector: walletConnector,
|
|
205
208
|
id: embeddedWalletVerifiedCredential.id,
|
|
209
|
+
key: (_j = embeddedWalletVerifiedCredential.walletName) !== null && _j !== void 0 ? _j : walletConnector.key,
|
|
206
210
|
};
|
|
207
211
|
setPrimaryWalletId(embeddedWalletVerifiedCredential.id);
|
|
208
212
|
dynamicEvents.emit('embeddedWalletCreated', wallet, embeddedWalletVerifiedCredential, getAuthToken(), user);
|
|
@@ -81,7 +81,7 @@ require('../../../widgets/DynamicWidget/views/ManagePasskeysWidgetView/PasskeyCa
|
|
|
81
81
|
var useInternalDynamicContext = require('../../../context/DynamicContext/useDynamicContext/useInternalDynamicContext.cjs');
|
|
82
82
|
|
|
83
83
|
const useNetworkNotSupported = () => {
|
|
84
|
-
const { selectedWalletConnector: walletConnector, setShowAuthFlow, bridgeChainsToConnect, bridgeOnboardingCompleted, } = useInternalDynamicContext.useInternalDynamicContext();
|
|
84
|
+
const { selectedWalletConnector: walletConnector, setShowAuthFlow, bridgeChainsToConnect, bridgeOnboardingCompleted, isBridgeFlow, } = useInternalDynamicContext.useInternalDynamicContext();
|
|
85
85
|
const { network: walletConnectorNetwork } = useWalletConnectorNetwork.useWalletConnectorNetwork(walletConnector);
|
|
86
86
|
const finishConnectAndSign = useConnectAndSign.useConnectAndSign({
|
|
87
87
|
shouldCallCallback: false,
|
|
@@ -95,15 +95,21 @@ const useNetworkNotSupported = () => {
|
|
|
95
95
|
finishConnectAndSign({
|
|
96
96
|
walletConnector: walletConnector,
|
|
97
97
|
});
|
|
98
|
-
//
|
|
99
|
-
//
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
if (bridgeOnboardingCompleted) {
|
|
98
|
+
// we're checking for bridgeChainsToConnect because in some scenarios,
|
|
99
|
+
// bridgeOnboardingCompleted might have not been set yet
|
|
100
|
+
if (!isBridgeFlow ||
|
|
101
|
+
bridgeOnboardingCompleted ||
|
|
102
|
+
!(bridgeChainsToConnect === null || bridgeChainsToConnect === void 0 ? void 0 : bridgeChainsToConnect.length)) {
|
|
104
103
|
setShowAuthFlow(false);
|
|
105
104
|
}
|
|
106
|
-
}, [
|
|
105
|
+
}, [
|
|
106
|
+
isBridgeFlow,
|
|
107
|
+
walletConnectorNetwork,
|
|
108
|
+
setShowAuthFlow,
|
|
109
|
+
bridgeOnboardingCompleted,
|
|
110
|
+
finishConnectAndSign,
|
|
111
|
+
bridgeChainsToConnect,
|
|
112
|
+
]);
|
|
107
113
|
return { currentNetwork: walletConnectorNetwork };
|
|
108
114
|
};
|
|
109
115
|
|
|
@@ -77,7 +77,7 @@ import '../../../widgets/DynamicWidget/views/ManagePasskeysWidgetView/PasskeyCar
|
|
|
77
77
|
import { useInternalDynamicContext } from '../../../context/DynamicContext/useDynamicContext/useInternalDynamicContext.js';
|
|
78
78
|
|
|
79
79
|
const useNetworkNotSupported = () => {
|
|
80
|
-
const { selectedWalletConnector: walletConnector, setShowAuthFlow, bridgeChainsToConnect, bridgeOnboardingCompleted, } = useInternalDynamicContext();
|
|
80
|
+
const { selectedWalletConnector: walletConnector, setShowAuthFlow, bridgeChainsToConnect, bridgeOnboardingCompleted, isBridgeFlow, } = useInternalDynamicContext();
|
|
81
81
|
const { network: walletConnectorNetwork } = useWalletConnectorNetwork(walletConnector);
|
|
82
82
|
const finishConnectAndSign = useConnectAndSign({
|
|
83
83
|
shouldCallCallback: false,
|
|
@@ -91,15 +91,21 @@ const useNetworkNotSupported = () => {
|
|
|
91
91
|
finishConnectAndSign({
|
|
92
92
|
walletConnector: walletConnector,
|
|
93
93
|
});
|
|
94
|
-
//
|
|
95
|
-
//
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
if (bridgeOnboardingCompleted) {
|
|
94
|
+
// we're checking for bridgeChainsToConnect because in some scenarios,
|
|
95
|
+
// bridgeOnboardingCompleted might have not been set yet
|
|
96
|
+
if (!isBridgeFlow ||
|
|
97
|
+
bridgeOnboardingCompleted ||
|
|
98
|
+
!(bridgeChainsToConnect === null || bridgeChainsToConnect === void 0 ? void 0 : bridgeChainsToConnect.length)) {
|
|
100
99
|
setShowAuthFlow(false);
|
|
101
100
|
}
|
|
102
|
-
}, [
|
|
101
|
+
}, [
|
|
102
|
+
isBridgeFlow,
|
|
103
|
+
walletConnectorNetwork,
|
|
104
|
+
setShowAuthFlow,
|
|
105
|
+
bridgeOnboardingCompleted,
|
|
106
|
+
finishConnectAndSign,
|
|
107
|
+
bridgeChainsToConnect,
|
|
108
|
+
]);
|
|
103
109
|
return { currentNetwork: walletConnectorNetwork };
|
|
104
110
|
};
|
|
105
111
|
|
|
@@ -112,7 +112,7 @@ const useSwitchWallet = () => {
|
|
|
112
112
|
throw new Error(`Wallet with id ${walletId} not found`);
|
|
113
113
|
}
|
|
114
114
|
if (((_a = wallet.connector) === null || _a === void 0 ? void 0 : _a.key) === 'unknown') {
|
|
115
|
-
throw new Error(
|
|
115
|
+
throw new Error("Cannot switch to this wallet, as it doesn't have an initialized wallet connector on this platform (desktop/mobile)");
|
|
116
116
|
}
|
|
117
117
|
const { connector } = wallet;
|
|
118
118
|
const email = (_b = user === null || user === void 0 ? void 0 : user.verifiedCredentials.find((verifiedCredential) => verifiedCredential.format === 'email')) === null || _b === void 0 ? void 0 : _b.email;
|
|
@@ -108,7 +108,7 @@ const useSwitchWallet = () => {
|
|
|
108
108
|
throw new Error(`Wallet with id ${walletId} not found`);
|
|
109
109
|
}
|
|
110
110
|
if (((_a = wallet.connector) === null || _a === void 0 ? void 0 : _a.key) === 'unknown') {
|
|
111
|
-
throw new Error(
|
|
111
|
+
throw new Error("Cannot switch to this wallet, as it doesn't have an initialized wallet connector on this platform (desktop/mobile)");
|
|
112
112
|
}
|
|
113
113
|
const { connector } = wallet;
|
|
114
114
|
const email = (_b = user === null || user === void 0 ? void 0 : user.verifiedCredentials.find((verifiedCredential) => verifiedCredential.format === 'email')) === null || _b === void 0 ? void 0 : _b.email;
|