@dynamic-labs/sdk-react-core 1.4.3 → 1.4.5
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 +20 -0
- package/package.cjs +1 -1
- package/package.js +1 -1
- package/package.json +11 -11
- package/src/lib/components/DynamicFooter/DynamicFooter.cjs +8 -1
- package/src/lib/components/DynamicFooter/DynamicFooter.js +8 -1
- package/src/lib/components/Toolkit/Toolkit.cjs +2 -3
- package/src/lib/components/Toolkit/Toolkit.js +2 -3
- package/src/lib/components/Toolkit/components/index.d.ts +0 -1
- package/src/lib/context/DynamicContext/DynamicContext.cjs +13 -12
- package/src/lib/context/DynamicContext/DynamicContext.js +13 -12
- package/src/lib/context/DynamicContext/hooks/index.d.ts +1 -0
- package/src/lib/context/DynamicContext/hooks/useHandleLogout/types.d.ts +0 -1
- package/src/lib/context/DynamicContext/hooks/useHandleLogout/useHandleLogout.cjs +0 -3
- package/src/lib/context/DynamicContext/hooks/useHandleLogout/useHandleLogout.js +1 -4
- package/src/lib/context/DynamicContext/hooks/useMultiWallet/useMultiWallet.cjs +15 -0
- package/src/lib/context/DynamicContext/hooks/useMultiWallet/useMultiWallet.d.ts +6 -0
- package/src/lib/context/DynamicContext/hooks/useMultiWallet/useMultiWallet.js +11 -0
- package/src/lib/context/DynamicContext/hooks/useParentDynamicContextGuard/index.d.ts +1 -0
- package/src/lib/context/DynamicContext/hooks/useParentDynamicContextGuard/useParentDynamicContextGuard.cjs +15 -0
- package/src/lib/context/DynamicContext/hooks/useParentDynamicContextGuard/useParentDynamicContextGuard.d.ts +1 -0
- package/src/lib/context/DynamicContext/hooks/useParentDynamicContextGuard/useParentDynamicContextGuard.js +11 -0
- package/src/lib/context/DynamicContext/types/index.d.ts +4 -1
- package/src/lib/context/DynamicContext/useCustomerCallbacks/useCustomerCallbacks.cjs +4 -2
- package/src/lib/context/DynamicContext/useCustomerCallbacks/useCustomerCallbacks.js +4 -2
- package/src/lib/main.global.cjs +1 -1
- package/src/lib/main.global.js +1 -1
- package/src/lib/shared/utils/hooks/usePreventPageScroll/usePreventPageScroll.cjs +0 -10
- package/src/lib/shared/utils/hooks/usePreventPageScroll/usePreventPageScroll.js +0 -10
- package/src/lib/styles/index.shadow.cjs +1 -1
- package/src/lib/styles/index.shadow.js +1 -1
- package/src/lib/utils/constants/index.d.ts +1 -1
- package/src/lib/utils/constants/localStorage.cjs +0 -2
- package/src/lib/utils/constants/localStorage.d.ts +0 -1
- package/src/lib/utils/constants/localStorage.js +1 -2
- package/src/lib/utils/functions/walletListBuilder/utils/getCalculatedOffset/getCalculatedOffset.cjs +9 -4
- package/src/lib/utils/functions/walletListBuilder/utils/getCalculatedOffset/getCalculatedOffset.js +9 -4
- package/src/lib/utils/functions/walletListBuilder/walletListBuilder.cjs +24 -15
- package/src/lib/utils/functions/walletListBuilder/walletListBuilder.d.ts +13 -0
- package/src/lib/utils/functions/walletListBuilder/walletListBuilder.js +24 -16
- package/src/lib/utils/hooks/authenticationHooks/useConnectAndSignSplitSteps/useConnectAndSignSplitSteps.cjs +16 -1
- package/src/lib/utils/hooks/authenticationHooks/useConnectAndSignSplitSteps/useConnectAndSignSplitSteps.js +16 -1
- package/src/lib/utils/hooks/useAuthLayoutChecks/useAuthLayoutChecks.cjs +2 -0
- package/src/lib/utils/hooks/useAuthLayoutChecks/useAuthLayoutChecks.d.ts +1 -0
- package/src/lib/utils/hooks/useAuthLayoutChecks/useAuthLayoutChecks.js +2 -0
- package/src/lib/utils/hooks/useWalletConnectors/useWalletConnectors.cjs +4 -1
- package/src/lib/utils/hooks/useWalletConnectors/useWalletConnectors.js +4 -1
- package/src/lib/widgets/DynamicEmbeddedWidget/DynamicEmbeddedAuthFlow/DynamicEmbeddedAuthFlow.cjs +11 -1
- package/src/lib/widgets/DynamicEmbeddedWidget/DynamicEmbeddedAuthFlow/DynamicEmbeddedAuthFlow.js +11 -1
- package/src/lib/components/Toolkit/components/MultiWalletSwitch.cjs +0 -18
- package/src/lib/components/Toolkit/components/MultiWalletSwitch.d.ts +0 -6
- package/src/lib/components/Toolkit/components/MultiWalletSwitch.js +0 -14
- package/src/lib/utils/hooks/multiWallet/useMultiWallet/useMultiWallet.cjs +0 -39
- package/src/lib/utils/hooks/multiWallet/useMultiWallet/useMultiWallet.d.ts +0 -9
- package/src/lib/utils/hooks/multiWallet/useMultiWallet/useMultiWallet.js +0 -35
- /package/src/lib/{utils/hooks/multiWallet → context/DynamicContext/hooks}/useMultiWallet/index.d.ts +0 -0
package/src/lib/utils/functions/walletListBuilder/utils/getCalculatedOffset/getCalculatedOffset.js
CHANGED
|
@@ -1,13 +1,18 @@
|
|
|
1
|
+
import '../../../../constants/colors.js';
|
|
2
|
+
import { DEFAULT_NUMBER_OF_WALLETS_TO_SHOW } from '../../../../constants/values.js';
|
|
1
3
|
import { findLastPriorityIndex } from '../findLastWalletIndex/findLastPriorityIndex.js';
|
|
2
4
|
|
|
3
5
|
const getCalculatedOffset = ({ hasWalletFilter, defaultOffset, list, priorityList, }) => {
|
|
4
6
|
const lastPriorityIndex = findLastPriorityIndex(list, priorityList);
|
|
5
|
-
if (
|
|
6
|
-
|
|
7
|
-
|
|
7
|
+
if (defaultOffset === DEFAULT_NUMBER_OF_WALLETS_TO_SHOW &&
|
|
8
|
+
!hasWalletFilter &&
|
|
9
|
+
list.length > defaultOffset &&
|
|
10
|
+
lastPriorityIndex !== -1) {
|
|
11
|
+
return lastPriorityIndex + 1;
|
|
12
|
+
}
|
|
13
|
+
else {
|
|
8
14
|
return defaultOffset;
|
|
9
15
|
}
|
|
10
|
-
return lastPriorityIndex + 1;
|
|
11
16
|
};
|
|
12
17
|
|
|
13
18
|
export { getCalculatedOffset };
|
|
@@ -86,8 +86,10 @@ const walletListBuilder = ({ authMode, connectedWallets, multiWallet, numberOfWa
|
|
|
86
86
|
const finalizedWalletList = groupWallets
|
|
87
87
|
? groupWalletOptions.groupWalletOptions(walletBook, walletsList)
|
|
88
88
|
: walletsList;
|
|
89
|
+
// If a filter has been applied we want to add an offset to the number of wallets
|
|
90
|
+
// to include the installed and last used wallets
|
|
89
91
|
const updatedNumberOfWalletsToShow = showMoreWalletsWithFilter && hasWalletFilter
|
|
90
|
-
?
|
|
92
|
+
? calculateWalletOffsetBasedOnInstalledAndLastUsedWallets(orderedInputList, firstPriorityWallets.concat(installedWallets), numberOfWalletsToShow)
|
|
91
93
|
: numberOfWalletsToShow;
|
|
92
94
|
return {
|
|
93
95
|
numberOfWallets: walletsList.length,
|
|
@@ -104,17 +106,24 @@ const orderAndFilterList = (walletList, walletsFilter, isWalletConnectList) => {
|
|
|
104
106
|
return sortedInputList(walletList);
|
|
105
107
|
}
|
|
106
108
|
};
|
|
109
|
+
const KEEP_WALLETS_NAME_LIST = ['wallet connect'];
|
|
107
110
|
const applySearchFilterToWalletOptionList = (rawSearchFilter, walletOptionList) => {
|
|
108
111
|
const searchFilter = rawSearchFilter.trim().toLowerCase();
|
|
109
|
-
const cleanName = (name) =>
|
|
110
|
-
.trim()
|
|
111
|
-
.
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
112
|
+
const cleanName = (name) => {
|
|
113
|
+
const trimmedLowerName = name.trim().toLowerCase();
|
|
114
|
+
if (KEEP_WALLETS_NAME_LIST.includes(trimmedLowerName)) {
|
|
115
|
+
return trimmedLowerName;
|
|
116
|
+
}
|
|
117
|
+
else {
|
|
118
|
+
return trimmedLowerName
|
|
119
|
+
.replace('wallet', '')
|
|
120
|
+
.replace('evm', '')
|
|
121
|
+
.replace('starknet', '')
|
|
122
|
+
.replace('solana', '')
|
|
123
|
+
.replace('flow', '')
|
|
124
|
+
.replace('bitcoin', '');
|
|
125
|
+
}
|
|
126
|
+
};
|
|
118
127
|
return walletOptionList.filter((walletOption) => {
|
|
119
128
|
var _a;
|
|
120
129
|
return cleanName(walletOption.name).includes(searchFilter) ||
|
|
@@ -145,19 +154,18 @@ const listToDisplay = (finalizedList, searchFilter, isWalletConnectList, numberO
|
|
|
145
154
|
}
|
|
146
155
|
};
|
|
147
156
|
/**
|
|
148
|
-
* When a filter is applied we would like to show the installed + last used wallets
|
|
149
|
-
* in addition to the wallets that the filter has specified.
|
|
150
157
|
* This calculation adds an offset to numberOfWalletsToShow so we will show the
|
|
151
158
|
* intended wallets + installed and last used.
|
|
159
|
+
* We should would only apply the additonal offset if the installed wallets was not in the original list.
|
|
152
160
|
*
|
|
153
161
|
* For example:
|
|
154
162
|
* we want to show 4 wallets: ['metamask', 'rainbow', 'walletconnect', 'coinbase']
|
|
155
163
|
* and someone is using brave with installed phantom he should see
|
|
156
164
|
* [ 'brave injected', phantom ,'metamask', 'rainbow', 'walletconnect', 'coinbase',]
|
|
157
|
-
*
|
|
158
|
-
*
|
|
165
|
+
* And when someone is using metamask and coinbase they should see
|
|
166
|
+
* [ 'metamask', 'coinbase', 'rainbow', 'walletconnect']
|
|
159
167
|
*/
|
|
160
|
-
const
|
|
168
|
+
const calculateWalletOffsetBasedOnInstalledAndLastUsedWallets = (allWalletsOrdered, installedOrUsedWallets, numberOfWalletsToShow) => {
|
|
161
169
|
const filteredWallets = allWalletsOrdered.slice(0, numberOfWalletsToShow);
|
|
162
170
|
const offset = installedOrUsedWallets.filter((wallet) => !filteredWallets.includes(wallet)).length;
|
|
163
171
|
return numberOfWalletsToShow + offset;
|
|
@@ -177,4 +185,5 @@ const getSignWithEmailWallet = (signWithEmailWalletName, inputList) => {
|
|
|
177
185
|
|
|
178
186
|
exports.PRIORITY_WALLET_LIST = PRIORITY_WALLET_LIST;
|
|
179
187
|
exports.SIGN_IN_WITH_EMAIL_WALLET_NAME = SIGN_IN_WITH_EMAIL_WALLET_NAME;
|
|
188
|
+
exports.calculateWalletOffsetBasedOnInstalledAndLastUsedWallets = calculateWalletOffsetBasedOnInstalledAndLastUsedWallets;
|
|
180
189
|
exports.walletListBuilder = walletListBuilder;
|
|
@@ -23,4 +23,17 @@ type BuilderResult = {
|
|
|
23
23
|
export declare const PRIORITY_WALLET_LIST: string[];
|
|
24
24
|
export declare const SIGN_IN_WITH_EMAIL_WALLET_NAME = "Sign In With Email";
|
|
25
25
|
export declare const walletListBuilder: ({ authMode, connectedWallets, multiWallet, numberOfWalletsToShow, inputList, isWalletConnectList, lastUsedWalletKey, signWithEmailWalletName, searchFilter, walletsFilter, loginWithEmail, groupWallets, walletBook, showMoreWalletsWithFilter, }: BuilderParams) => BuilderResult;
|
|
26
|
+
/**
|
|
27
|
+
* This calculation adds an offset to numberOfWalletsToShow so we will show the
|
|
28
|
+
* intended wallets + installed and last used.
|
|
29
|
+
* We should would only apply the additonal offset if the installed wallets was not in the original list.
|
|
30
|
+
*
|
|
31
|
+
* For example:
|
|
32
|
+
* we want to show 4 wallets: ['metamask', 'rainbow', 'walletconnect', 'coinbase']
|
|
33
|
+
* and someone is using brave with installed phantom he should see
|
|
34
|
+
* [ 'brave injected', phantom ,'metamask', 'rainbow', 'walletconnect', 'coinbase',]
|
|
35
|
+
* And when someone is using metamask and coinbase they should see
|
|
36
|
+
* [ 'metamask', 'coinbase', 'rainbow', 'walletconnect']
|
|
37
|
+
*/
|
|
38
|
+
export declare const calculateWalletOffsetBasedOnInstalledAndLastUsedWallets: (allWalletsOrdered: WalletOption[], installedOrUsedWallets: WalletOption[], numberOfWalletsToShow: number) => number;
|
|
26
39
|
export {};
|
|
@@ -82,8 +82,10 @@ const walletListBuilder = ({ authMode, connectedWallets, multiWallet, numberOfWa
|
|
|
82
82
|
const finalizedWalletList = groupWallets
|
|
83
83
|
? groupWalletOptions(walletBook, walletsList)
|
|
84
84
|
: walletsList;
|
|
85
|
+
// If a filter has been applied we want to add an offset to the number of wallets
|
|
86
|
+
// to include the installed and last used wallets
|
|
85
87
|
const updatedNumberOfWalletsToShow = showMoreWalletsWithFilter && hasWalletFilter
|
|
86
|
-
?
|
|
88
|
+
? calculateWalletOffsetBasedOnInstalledAndLastUsedWallets(orderedInputList, firstPriorityWallets.concat(installedWallets), numberOfWalletsToShow)
|
|
87
89
|
: numberOfWalletsToShow;
|
|
88
90
|
return {
|
|
89
91
|
numberOfWallets: walletsList.length,
|
|
@@ -100,17 +102,24 @@ const orderAndFilterList = (walletList, walletsFilter, isWalletConnectList) => {
|
|
|
100
102
|
return sortedInputList(walletList);
|
|
101
103
|
}
|
|
102
104
|
};
|
|
105
|
+
const KEEP_WALLETS_NAME_LIST = ['wallet connect'];
|
|
103
106
|
const applySearchFilterToWalletOptionList = (rawSearchFilter, walletOptionList) => {
|
|
104
107
|
const searchFilter = rawSearchFilter.trim().toLowerCase();
|
|
105
|
-
const cleanName = (name) =>
|
|
106
|
-
.trim()
|
|
107
|
-
.
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
108
|
+
const cleanName = (name) => {
|
|
109
|
+
const trimmedLowerName = name.trim().toLowerCase();
|
|
110
|
+
if (KEEP_WALLETS_NAME_LIST.includes(trimmedLowerName)) {
|
|
111
|
+
return trimmedLowerName;
|
|
112
|
+
}
|
|
113
|
+
else {
|
|
114
|
+
return trimmedLowerName
|
|
115
|
+
.replace('wallet', '')
|
|
116
|
+
.replace('evm', '')
|
|
117
|
+
.replace('starknet', '')
|
|
118
|
+
.replace('solana', '')
|
|
119
|
+
.replace('flow', '')
|
|
120
|
+
.replace('bitcoin', '');
|
|
121
|
+
}
|
|
122
|
+
};
|
|
114
123
|
return walletOptionList.filter((walletOption) => {
|
|
115
124
|
var _a;
|
|
116
125
|
return cleanName(walletOption.name).includes(searchFilter) ||
|
|
@@ -141,19 +150,18 @@ const listToDisplay = (finalizedList, searchFilter, isWalletConnectList, numberO
|
|
|
141
150
|
}
|
|
142
151
|
};
|
|
143
152
|
/**
|
|
144
|
-
* When a filter is applied we would like to show the installed + last used wallets
|
|
145
|
-
* in addition to the wallets that the filter has specified.
|
|
146
153
|
* This calculation adds an offset to numberOfWalletsToShow so we will show the
|
|
147
154
|
* intended wallets + installed and last used.
|
|
155
|
+
* We should would only apply the additonal offset if the installed wallets was not in the original list.
|
|
148
156
|
*
|
|
149
157
|
* For example:
|
|
150
158
|
* we want to show 4 wallets: ['metamask', 'rainbow', 'walletconnect', 'coinbase']
|
|
151
159
|
* and someone is using brave with installed phantom he should see
|
|
152
160
|
* [ 'brave injected', phantom ,'metamask', 'rainbow', 'walletconnect', 'coinbase',]
|
|
153
|
-
*
|
|
154
|
-
*
|
|
161
|
+
* And when someone is using metamask and coinbase they should see
|
|
162
|
+
* [ 'metamask', 'coinbase', 'rainbow', 'walletconnect']
|
|
155
163
|
*/
|
|
156
|
-
const
|
|
164
|
+
const calculateWalletOffsetBasedOnInstalledAndLastUsedWallets = (allWalletsOrdered, installedOrUsedWallets, numberOfWalletsToShow) => {
|
|
157
165
|
const filteredWallets = allWalletsOrdered.slice(0, numberOfWalletsToShow);
|
|
158
166
|
const offset = installedOrUsedWallets.filter((wallet) => !filteredWallets.includes(wallet)).length;
|
|
159
167
|
return numberOfWalletsToShow + offset;
|
|
@@ -171,4 +179,4 @@ const getSignWithEmailWallet = (signWithEmailWalletName, inputList) => {
|
|
|
171
179
|
return walletOverride;
|
|
172
180
|
};
|
|
173
181
|
|
|
174
|
-
export { PRIORITY_WALLET_LIST, SIGN_IN_WITH_EMAIL_WALLET_NAME, walletListBuilder };
|
|
182
|
+
export { PRIORITY_WALLET_LIST, SIGN_IN_WITH_EMAIL_WALLET_NAME, calculateWalletOffsetBasedOnInstalledAndLastUsedWallets, walletListBuilder };
|
|
@@ -23,6 +23,8 @@ require('../../../../shared/consts/index.cjs');
|
|
|
23
23
|
require('../../../../events/dynamicEvents.cjs');
|
|
24
24
|
var ErrorContext = require('../../../../context/ErrorContext/ErrorContext.cjs');
|
|
25
25
|
require('@dynamic-labs/multi-wallet');
|
|
26
|
+
var isProgrammableNetworkSwitchSupported = require('../../../functions/isProgrammableNetworkSwitchSupported/isProgrammableNetworkSwitchSupported.cjs');
|
|
27
|
+
var isSupportedNetwork = require('../../../functions/isSupportedNetwork/isSupportedNetwork.cjs');
|
|
26
28
|
require('viem/chains');
|
|
27
29
|
var useHandleWalletsToConnect = require('../../useHandleWalletsToConnect/useHandleWalletsToConnect.cjs');
|
|
28
30
|
var useVerifyWallet = require('../../useVerifyWallet/useVerifyWallet.cjs');
|
|
@@ -80,7 +82,7 @@ const useConnectAndSignSplitSteps = () => {
|
|
|
80
82
|
const { setView, goToInitialView } = ViewContext.useViewContext();
|
|
81
83
|
const { setErrorMessage } = ErrorContext.useErrorContext();
|
|
82
84
|
const { getCaptchaToken, engageCaptcha } = CaptchaContext.useCaptchaContext();
|
|
83
|
-
const { connectWallet, consumeNonce, displaySiweStatement, projectSettings, environmentId, setIsSingleWalletAccount, setShowAuthFlow, user, authMode, setIsVerificationInProgress, } = useInternalDynamicContext.useInternalDynamicContext();
|
|
85
|
+
const { connectWallet, consumeNonce, displaySiweStatement, projectSettings, environmentId, networkValidationMode, setIsSingleWalletAccount, setShowAuthFlow, user, authMode, setIsVerificationInProgress, } = useInternalDynamicContext.useInternalDynamicContext();
|
|
84
86
|
const { handleWalletsToConnect } = useHandleWalletsToConnect.useHandleWalletsToConnect();
|
|
85
87
|
const verifyWallet = useVerifyWallet.useVerifyWallet({
|
|
86
88
|
consumeNonce,
|
|
@@ -149,6 +151,19 @@ const useConnectAndSignSplitSteps = () => {
|
|
|
149
151
|
if (!(connectionResult === null || connectionResult === void 0 ? void 0 : connectionResult.address)) {
|
|
150
152
|
return;
|
|
151
153
|
}
|
|
154
|
+
const walletNetwork = yield walletConnector.getNetwork();
|
|
155
|
+
const usesSupportedNetwork = isSupportedNetwork.isSupportedNetwork({
|
|
156
|
+
network: walletNetwork,
|
|
157
|
+
walletConnector,
|
|
158
|
+
});
|
|
159
|
+
const isNetworkValidationEnabledForSignIn = networkValidationMode === 'always' ||
|
|
160
|
+
networkValidationMode === 'sign-in';
|
|
161
|
+
if (!usesSupportedNetwork && isNetworkValidationEnabledForSignIn) {
|
|
162
|
+
if (!isProgrammableNetworkSwitchSupported.isProgrammableNetworkSwitchSupported(walletConnector)) {
|
|
163
|
+
return setView('network-not-supported-manual');
|
|
164
|
+
}
|
|
165
|
+
return setView('network-not-supported');
|
|
166
|
+
}
|
|
152
167
|
yield verifyWallet({
|
|
153
168
|
captchaToken: getCaptchaToken(),
|
|
154
169
|
publicWalletAddress: connectionResult.address,
|
|
@@ -19,6 +19,8 @@ import '../../../../shared/consts/index.js';
|
|
|
19
19
|
import '../../../../events/dynamicEvents.js';
|
|
20
20
|
import { useErrorContext } from '../../../../context/ErrorContext/ErrorContext.js';
|
|
21
21
|
import '@dynamic-labs/multi-wallet';
|
|
22
|
+
import { isProgrammableNetworkSwitchSupported } from '../../../functions/isProgrammableNetworkSwitchSupported/isProgrammableNetworkSwitchSupported.js';
|
|
23
|
+
import { isSupportedNetwork } from '../../../functions/isSupportedNetwork/isSupportedNetwork.js';
|
|
22
24
|
import 'viem/chains';
|
|
23
25
|
import { useHandleWalletsToConnect } from '../../useHandleWalletsToConnect/useHandleWalletsToConnect.js';
|
|
24
26
|
import { useVerifyWallet } from '../../useVerifyWallet/useVerifyWallet.js';
|
|
@@ -76,7 +78,7 @@ const useConnectAndSignSplitSteps = () => {
|
|
|
76
78
|
const { setView, goToInitialView } = useViewContext();
|
|
77
79
|
const { setErrorMessage } = useErrorContext();
|
|
78
80
|
const { getCaptchaToken, engageCaptcha } = useCaptchaContext();
|
|
79
|
-
const { connectWallet, consumeNonce, displaySiweStatement, projectSettings, environmentId, setIsSingleWalletAccount, setShowAuthFlow, user, authMode, setIsVerificationInProgress, } = useInternalDynamicContext();
|
|
81
|
+
const { connectWallet, consumeNonce, displaySiweStatement, projectSettings, environmentId, networkValidationMode, setIsSingleWalletAccount, setShowAuthFlow, user, authMode, setIsVerificationInProgress, } = useInternalDynamicContext();
|
|
80
82
|
const { handleWalletsToConnect } = useHandleWalletsToConnect();
|
|
81
83
|
const verifyWallet = useVerifyWallet({
|
|
82
84
|
consumeNonce,
|
|
@@ -145,6 +147,19 @@ const useConnectAndSignSplitSteps = () => {
|
|
|
145
147
|
if (!(connectionResult === null || connectionResult === void 0 ? void 0 : connectionResult.address)) {
|
|
146
148
|
return;
|
|
147
149
|
}
|
|
150
|
+
const walletNetwork = yield walletConnector.getNetwork();
|
|
151
|
+
const usesSupportedNetwork = isSupportedNetwork({
|
|
152
|
+
network: walletNetwork,
|
|
153
|
+
walletConnector,
|
|
154
|
+
});
|
|
155
|
+
const isNetworkValidationEnabledForSignIn = networkValidationMode === 'always' ||
|
|
156
|
+
networkValidationMode === 'sign-in';
|
|
157
|
+
if (!usesSupportedNetwork && isNetworkValidationEnabledForSignIn) {
|
|
158
|
+
if (!isProgrammableNetworkSwitchSupported(walletConnector)) {
|
|
159
|
+
return setView('network-not-supported-manual');
|
|
160
|
+
}
|
|
161
|
+
return setView('network-not-supported');
|
|
162
|
+
}
|
|
148
163
|
yield verifyWallet({
|
|
149
164
|
captchaToken: getCaptchaToken(),
|
|
150
165
|
publicWalletAddress: connectionResult.address,
|
|
@@ -179,9 +179,11 @@ const useAuthLayoutChecks = () => {
|
|
|
179
179
|
view.type === 'farcaster-connect-view' ||
|
|
180
180
|
(view.type === 'merge-user-accounts' && !user);
|
|
181
181
|
const showDefaultFooter = !showConnectedWalletProgress && !showDynamicFooter && !showToSFooter;
|
|
182
|
+
const shouldHideDynamicFooterSeparator = showDynamicFooter && showToSFooter;
|
|
182
183
|
return {
|
|
183
184
|
displayBorderBelowHeader,
|
|
184
185
|
isWalletListTypeView,
|
|
186
|
+
shouldHideDynamicFooterSeparator,
|
|
185
187
|
showBackButton,
|
|
186
188
|
showCloseButton,
|
|
187
189
|
showConnectedWalletProgress,
|
|
@@ -175,9 +175,11 @@ const useAuthLayoutChecks = () => {
|
|
|
175
175
|
view.type === 'farcaster-connect-view' ||
|
|
176
176
|
(view.type === 'merge-user-accounts' && !user);
|
|
177
177
|
const showDefaultFooter = !showConnectedWalletProgress && !showDynamicFooter && !showToSFooter;
|
|
178
|
+
const shouldHideDynamicFooterSeparator = showDynamicFooter && showToSFooter;
|
|
178
179
|
return {
|
|
179
180
|
displayBorderBelowHeader,
|
|
180
181
|
isWalletListTypeView,
|
|
182
|
+
shouldHideDynamicFooterSeparator,
|
|
181
183
|
showBackButton,
|
|
182
184
|
showCloseButton,
|
|
183
185
|
showConnectedWalletProgress,
|
|
@@ -72,7 +72,10 @@ const useWalletConnectors = ({ authMode, authToken, connectedWallets, walletConn
|
|
|
72
72
|
const { setUserWallets } = UserWalletsContext.useInternalUserWallets();
|
|
73
73
|
// Keep userWallets in sync whenever linkedWallets changes
|
|
74
74
|
React.useEffect(() => {
|
|
75
|
-
|
|
75
|
+
// we don't want to set the user wallets until their connected states have been computed
|
|
76
|
+
// but that doesn't matter if the wallets list is empty, and if we return early when
|
|
77
|
+
// the wallets list is empty, we'll never set the user wallets correctly after logout
|
|
78
|
+
if (!didConnectedStateLoad.current && wallets.length)
|
|
76
79
|
return;
|
|
77
80
|
setUserWallets((userWallets) => updateUserWalletsFromLinkedWallets.updateUserWalletsFromLinkedWallets(userWallets, wallets));
|
|
78
81
|
}, [didConnectedStateLoad, setUserWallets, wallets]);
|
|
@@ -68,7 +68,10 @@ const useWalletConnectors = ({ authMode, authToken, connectedWallets, walletConn
|
|
|
68
68
|
const { setUserWallets } = useInternalUserWallets();
|
|
69
69
|
// Keep userWallets in sync whenever linkedWallets changes
|
|
70
70
|
useEffect(() => {
|
|
71
|
-
|
|
71
|
+
// we don't want to set the user wallets until their connected states have been computed
|
|
72
|
+
// but that doesn't matter if the wallets list is empty, and if we return early when
|
|
73
|
+
// the wallets list is empty, we'll never set the user wallets correctly after logout
|
|
74
|
+
if (!didConnectedStateLoad.current && wallets.length)
|
|
72
75
|
return;
|
|
73
76
|
setUserWallets((userWallets) => updateUserWalletsFromLinkedWallets(userWallets, wallets));
|
|
74
77
|
}, [didConnectedStateLoad, setUserWallets, wallets]);
|
package/src/lib/widgets/DynamicEmbeddedWidget/DynamicEmbeddedAuthFlow/DynamicEmbeddedAuthFlow.cjs
CHANGED
|
@@ -74,7 +74,17 @@ var SocialRedirectContext = require('../../../context/SocialRedirectContext/Soci
|
|
|
74
74
|
|
|
75
75
|
const DynamicEmbeddedAuthFlow = ({ background = 'none', className, style, }) => {
|
|
76
76
|
const hide = useIsLoggedIn.useIsLoggedIn();
|
|
77
|
-
const { projectSettings, isRenderingEmbeddedAuthFlow } = useInternalDynamicContext.useInternalDynamicContext();
|
|
77
|
+
const { projectSettings, isRenderingEmbeddedAuthFlow, walletConnectorOptions, } = useInternalDynamicContext.useInternalDynamicContext();
|
|
78
|
+
// This is needed to make sure WalletConnect is initialized for users who are using
|
|
79
|
+
// universal links on mobile. This also happens in useShowAuthFlow, but since this
|
|
80
|
+
// is the embedded auth flow, that hook does not get called.
|
|
81
|
+
// Without initializing WalletConnect here, users end up hitting the iOS app store bug
|
|
82
|
+
// and are redirected to the app store, instead of the wallet
|
|
83
|
+
React.useEffect(() => {
|
|
84
|
+
var _a;
|
|
85
|
+
(_a = walletConnectorOptions
|
|
86
|
+
.find((wallet) => wallet.walletConnector.key === 'walletconnect')) === null || _a === void 0 ? void 0 : _a.walletConnector.init();
|
|
87
|
+
}, [walletConnectorOptions]);
|
|
78
88
|
const { goToInitialView: resetAuthView } = ViewContext.useViewContext();
|
|
79
89
|
// Reset view when user logs out
|
|
80
90
|
React.useEffect(() => {
|
package/src/lib/widgets/DynamicEmbeddedWidget/DynamicEmbeddedAuthFlow/DynamicEmbeddedAuthFlow.js
CHANGED
|
@@ -70,7 +70,17 @@ import { SocialRedirectContextProvider } from '../../../context/SocialRedirectCo
|
|
|
70
70
|
|
|
71
71
|
const DynamicEmbeddedAuthFlow = ({ background = 'none', className, style, }) => {
|
|
72
72
|
const hide = useIsLoggedIn();
|
|
73
|
-
const { projectSettings, isRenderingEmbeddedAuthFlow } = useInternalDynamicContext();
|
|
73
|
+
const { projectSettings, isRenderingEmbeddedAuthFlow, walletConnectorOptions, } = useInternalDynamicContext();
|
|
74
|
+
// This is needed to make sure WalletConnect is initialized for users who are using
|
|
75
|
+
// universal links on mobile. This also happens in useShowAuthFlow, but since this
|
|
76
|
+
// is the embedded auth flow, that hook does not get called.
|
|
77
|
+
// Without initializing WalletConnect here, users end up hitting the iOS app store bug
|
|
78
|
+
// and are redirected to the app store, instead of the wallet
|
|
79
|
+
useEffect(() => {
|
|
80
|
+
var _a;
|
|
81
|
+
(_a = walletConnectorOptions
|
|
82
|
+
.find((wallet) => wallet.walletConnector.key === 'walletconnect')) === null || _a === void 0 ? void 0 : _a.walletConnector.init();
|
|
83
|
+
}, [walletConnectorOptions]);
|
|
74
84
|
const { goToInitialView: resetAuthView } = useViewContext();
|
|
75
85
|
// Reset view when user logs out
|
|
76
86
|
useEffect(() => {
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var jsxRuntime = require('react/jsx-runtime');
|
|
6
|
-
var Switch = require('../../Switch/Switch.cjs');
|
|
7
|
-
|
|
8
|
-
const MultiWalletSwitch = ({ multiWallet, setMultiWallet, }) => (jsxRuntime.jsx(Switch.Switch, { firstButton: {
|
|
9
|
-
active: multiWallet,
|
|
10
|
-
handleButtonClick: () => setMultiWallet(true),
|
|
11
|
-
name: 'True',
|
|
12
|
-
}, secondButton: {
|
|
13
|
-
active: !multiWallet,
|
|
14
|
-
handleButtonClick: () => setMultiWallet(false),
|
|
15
|
-
name: 'False',
|
|
16
|
-
} }));
|
|
17
|
-
|
|
18
|
-
exports.MultiWalletSwitch = MultiWalletSwitch;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { jsx } from 'react/jsx-runtime';
|
|
2
|
-
import { Switch } from '../../Switch/Switch.js';
|
|
3
|
-
|
|
4
|
-
const MultiWalletSwitch = ({ multiWallet, setMultiWallet, }) => (jsx(Switch, { firstButton: {
|
|
5
|
-
active: multiWallet,
|
|
6
|
-
handleButtonClick: () => setMultiWallet(true),
|
|
7
|
-
name: 'True',
|
|
8
|
-
}, secondButton: {
|
|
9
|
-
active: !multiWallet,
|
|
10
|
-
handleButtonClick: () => setMultiWallet(false),
|
|
11
|
-
name: 'False',
|
|
12
|
-
} }));
|
|
13
|
-
|
|
14
|
-
export { MultiWalletSwitch };
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var React = require('react');
|
|
6
|
-
require('@dynamic-labs/sdk-api');
|
|
7
|
-
require('../../../../shared/logger.cjs');
|
|
8
|
-
require('@dynamic-labs/iconic');
|
|
9
|
-
require('@dynamic-labs/wallet-connector-core');
|
|
10
|
-
require('react/jsx-runtime');
|
|
11
|
-
require('../../../../context/ViewContext/ViewContext.cjs');
|
|
12
|
-
require('@dynamic-labs/wallet-book');
|
|
13
|
-
var localStorage = require('../../../constants/localStorage.cjs');
|
|
14
|
-
require('../../../constants/colors.cjs');
|
|
15
|
-
require('../../../constants/values.cjs');
|
|
16
|
-
var localStorage$1 = require('../../../../shared/utils/classes/storage/localStorage.cjs');
|
|
17
|
-
require('viem');
|
|
18
|
-
var useLocalStorage = require('../../../../shared/utils/hooks/useLocalStorage/useLocalStorage.cjs');
|
|
19
|
-
require('@dynamic-labs/utils');
|
|
20
|
-
require('../../../../shared/consts/index.cjs');
|
|
21
|
-
|
|
22
|
-
const useMultiWallet = ({ toolkitEnabled, isBridgeFlow, multiWalletSettings, }) => {
|
|
23
|
-
var _a;
|
|
24
|
-
const isMultiWalletEnabled = (_a = (multiWalletSettings || isBridgeFlow)) !== null && _a !== void 0 ? _a : false;
|
|
25
|
-
const [multiWallet, setMultiWallet] = useLocalStorage.useLocalStorage(localStorage.IS_MULTI_WALLET_ENABLED, isMultiWalletEnabled);
|
|
26
|
-
React.useEffect(() => {
|
|
27
|
-
// don't overwrite toolkit stored value after the refresh
|
|
28
|
-
if (toolkitEnabled &&
|
|
29
|
-
localStorage$1.LocalStorage.getFromLS(localStorage.IS_MULTI_WALLET_ENABLED) !== undefined) {
|
|
30
|
-
return;
|
|
31
|
-
}
|
|
32
|
-
if (multiWalletSettings) {
|
|
33
|
-
setMultiWallet(multiWalletSettings);
|
|
34
|
-
}
|
|
35
|
-
}, [multiWalletSettings]);
|
|
36
|
-
return { multiWallet, setMultiWallet };
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
exports.useMultiWallet = useMultiWallet;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
export type UseMultiWalletProps = {
|
|
2
|
-
toolkitEnabled: boolean;
|
|
3
|
-
isBridgeFlow?: boolean;
|
|
4
|
-
multiWalletSettings?: boolean;
|
|
5
|
-
};
|
|
6
|
-
export declare const useMultiWallet: ({ toolkitEnabled, isBridgeFlow, multiWalletSettings, }: UseMultiWalletProps) => {
|
|
7
|
-
multiWallet: boolean;
|
|
8
|
-
setMultiWallet: (value: boolean | ((val: boolean) => boolean)) => void;
|
|
9
|
-
};
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { useEffect } from 'react';
|
|
2
|
-
import '@dynamic-labs/sdk-api';
|
|
3
|
-
import '../../../../shared/logger.js';
|
|
4
|
-
import '@dynamic-labs/iconic';
|
|
5
|
-
import '@dynamic-labs/wallet-connector-core';
|
|
6
|
-
import 'react/jsx-runtime';
|
|
7
|
-
import '../../../../context/ViewContext/ViewContext.js';
|
|
8
|
-
import '@dynamic-labs/wallet-book';
|
|
9
|
-
import { IS_MULTI_WALLET_ENABLED } from '../../../constants/localStorage.js';
|
|
10
|
-
import '../../../constants/colors.js';
|
|
11
|
-
import '../../../constants/values.js';
|
|
12
|
-
import { LocalStorage } from '../../../../shared/utils/classes/storage/localStorage.js';
|
|
13
|
-
import 'viem';
|
|
14
|
-
import { useLocalStorage } from '../../../../shared/utils/hooks/useLocalStorage/useLocalStorage.js';
|
|
15
|
-
import '@dynamic-labs/utils';
|
|
16
|
-
import '../../../../shared/consts/index.js';
|
|
17
|
-
|
|
18
|
-
const useMultiWallet = ({ toolkitEnabled, isBridgeFlow, multiWalletSettings, }) => {
|
|
19
|
-
var _a;
|
|
20
|
-
const isMultiWalletEnabled = (_a = (multiWalletSettings || isBridgeFlow)) !== null && _a !== void 0 ? _a : false;
|
|
21
|
-
const [multiWallet, setMultiWallet] = useLocalStorage(IS_MULTI_WALLET_ENABLED, isMultiWalletEnabled);
|
|
22
|
-
useEffect(() => {
|
|
23
|
-
// don't overwrite toolkit stored value after the refresh
|
|
24
|
-
if (toolkitEnabled &&
|
|
25
|
-
LocalStorage.getFromLS(IS_MULTI_WALLET_ENABLED) !== undefined) {
|
|
26
|
-
return;
|
|
27
|
-
}
|
|
28
|
-
if (multiWalletSettings) {
|
|
29
|
-
setMultiWallet(multiWalletSettings);
|
|
30
|
-
}
|
|
31
|
-
}, [multiWalletSettings]);
|
|
32
|
-
return { multiWallet, setMultiWallet };
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
export { useMultiWallet };
|
/package/src/lib/{utils/hooks/multiWallet → context/DynamicContext/hooks}/useMultiWallet/index.d.ts
RENAMED
|
File without changes
|