@dynamic-labs/sdk-react-core 3.0.0-alpha.42 → 3.0.0-alpha.44
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 +30 -0
- package/package.cjs +1 -1
- package/package.js +1 -1
- package/package.json +12 -12
- package/src/index.cjs +2 -0
- package/src/index.d.ts +1 -0
- package/src/index.js +1 -0
- package/src/lib/components/NeedHelpSection/NeedHelpSection.cjs +2 -1
- package/src/lib/components/NeedHelpSection/NeedHelpSection.js +2 -1
- package/src/lib/components/SecureEmbeddedWalletCard/SecureEmbeddedWalletCard.cjs +2 -1
- package/src/lib/components/SecureEmbeddedWalletCard/SecureEmbeddedWalletCard.js +2 -1
- package/src/lib/components/UserProfile/parts/UserProfileSocialAccount/UserProfileSocialAccount.cjs +0 -1
- package/src/lib/components/UserProfile/parts/UserProfileSocialAccount/UserProfileSocialAccount.js +0 -1
- package/src/lib/context/DynamicContext/DynamicContext.cjs +1 -2
- package/src/lib/context/DynamicContext/DynamicContext.js +1 -2
- package/src/lib/context/DynamicContext/types/IDynamicContext.d.ts +0 -1
- package/src/lib/context/DynamicContext/useCustomerCallbacks/useCustomerCallbacks.cjs +2 -1
- package/src/lib/context/DynamicContext/useCustomerCallbacks/useCustomerCallbacks.js +2 -1
- package/src/lib/context/DynamicContext/useDynamicContext/useDynamicContext.cjs +1 -2
- package/src/lib/context/DynamicContext/useDynamicContext/useDynamicContext.d.ts +1 -1
- package/src/lib/context/DynamicContext/useDynamicContext/useDynamicContext.js +1 -2
- package/src/lib/modals/SignMessageConfirmationModal/SignMessageConfirmationModal.cjs +5 -4
- package/src/lib/modals/SignMessageConfirmationModal/SignMessageConfirmationModal.js +5 -4
- package/src/lib/styles/index.shadow.cjs +1 -1
- package/src/lib/styles/index.shadow.js +1 -1
- package/src/lib/utils/functions/createUserProfile/createUserProfile.cjs +1 -4
- package/src/lib/utils/functions/createUserProfile/createUserProfile.js +1 -4
- package/src/lib/utils/functions/index.d.ts +1 -0
- package/src/lib/utils/functions/isAuthenticatedWithAWallet/index.d.ts +1 -0
- package/src/lib/utils/functions/isAuthenticatedWithAWallet/isAuthenticatedWithAWallet.cjs +14 -0
- package/src/lib/utils/functions/isAuthenticatedWithAWallet/isAuthenticatedWithAWallet.d.ts +2 -0
- package/src/lib/utils/functions/isAuthenticatedWithAWallet/isAuthenticatedWithAWallet.js +10 -0
- package/src/lib/utils/functions/isMultiAssetSupportedNetwork/isMultiAssetSupportedNetwork.d.ts +1 -1
- package/src/lib/utils/hooks/useConnectWallet/useConnectWallet.cjs +2 -0
- package/src/lib/utils/hooks/useConnectWallet/useConnectWallet.js +2 -0
- package/src/lib/utils/hooks/useEmbeddedWallet/useMPCEmbeddedWallet/useCoinbaseMPC/useCoinbaseMPC.cjs +2 -0
- package/src/lib/utils/hooks/useEmbeddedWallet/useMPCEmbeddedWallet/useCoinbaseMPC/useCoinbaseMPC.js +2 -0
- package/src/lib/utils/hooks/useEmbeddedWallet/useSecureEnclaveEmbeddedWallet/useSecureEnclaveEmbeddedWallet.cjs +5 -4
- package/src/lib/utils/hooks/useEmbeddedWallet/useSecureEnclaveEmbeddedWallet/useSecureEnclaveEmbeddedWallet.js +5 -4
- package/src/lib/utils/hooks/useEmbeddedWallet/useSecureEnclaveEmbeddedWallet/useTurnkey/useTurnkey.cjs +9 -3
- package/src/lib/utils/hooks/useEmbeddedWallet/useSecureEnclaveEmbeddedWallet/useTurnkey/useTurnkey.js +9 -3
- package/src/lib/utils/hooks/useTokenBalances/useTokenBalances.cjs +2 -1
- package/src/lib/utils/hooks/useTokenBalances/useTokenBalances.js +2 -1
- package/src/lib/utils/hooks/useWalletConnectors/utils/createLinkedWalletsFromWalletOptions/createLinkedWalletsFromWalletOptions.cjs +1 -0
- package/src/lib/utils/hooks/useWalletConnectors/utils/createLinkedWalletsFromWalletOptions/createLinkedWalletsFromWalletOptions.js +1 -0
- package/src/lib/views/EmailVerification/EmailVerification.cjs +3 -1
- package/src/lib/views/EmailVerification/EmailVerification.js +3 -1
- package/src/lib/views/LoginView/LoginViewSection/LoginViewSection.cjs +20 -16
- package/src/lib/views/LoginView/LoginViewSection/LoginViewSection.js +20 -16
- package/src/lib/views/LoginView/sections/ToggleableSection/ToggleableSection.d.ts +1 -2
- package/src/lib/views/viewToComponentMap.d.ts +1 -1
- package/src/lib/widgets/DynamicWidget/components/ActiveWalletInformation/ActiveWalletInformation.cjs +3 -2
- package/src/lib/widgets/DynamicWidget/components/ActiveWalletInformation/ActiveWalletInformation.js +3 -2
|
@@ -3,11 +3,8 @@
|
|
|
3
3
|
|
|
4
4
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
5
|
|
|
6
|
-
var index = require('../../../shared/utils/functions/lastAuthenticatedAccount/index.cjs');
|
|
7
|
-
|
|
8
6
|
const createUserProfileFromSdkUser = (user) => {
|
|
9
7
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x;
|
|
10
|
-
const wallet = index.lastAuthenticatedAccount(user);
|
|
11
8
|
const kyc = {
|
|
12
9
|
alias: (_a = user.alias) !== null && _a !== void 0 ? _a : undefined,
|
|
13
10
|
btcWallet: (_b = user.btcWallet) !== null && _b !== void 0 ? _b : undefined,
|
|
@@ -30,7 +27,7 @@ const createUserProfileFromSdkUser = (user) => {
|
|
|
30
27
|
team: (_u = user.team) !== null && _u !== void 0 ? _u : undefined,
|
|
31
28
|
username: (_v = user.username) !== null && _v !== void 0 ? _v : undefined,
|
|
32
29
|
};
|
|
33
|
-
const userProfile = Object.assign({
|
|
30
|
+
const userProfile = Object.assign({ environmentId: user.projectEnvironmentId, lastVerifiedCredentialId: (_w = user.lastVerifiedCredentialId) !== null && _w !== void 0 ? _w : undefined, lists: user.lists, metadata: user.metadata, mfaBackupCodeAcknowledgement: user.mfaBackupCodeAcknowledgement, missingFields: user.missingFields, newUser: user.newUser, scope: user.scope, sessionId: (_x = user.sessionId) !== null && _x !== void 0 ? _x : 'missing-sessionId', userId: user.id, verifiedCredentials: user.verifiedCredentials || [] }, kyc);
|
|
34
31
|
return userProfile;
|
|
35
32
|
};
|
|
36
33
|
|
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
'use client'
|
|
2
|
-
import { lastAuthenticatedAccount } from '../../../shared/utils/functions/lastAuthenticatedAccount/index.js';
|
|
3
|
-
|
|
4
2
|
const createUserProfileFromSdkUser = (user) => {
|
|
5
3
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x;
|
|
6
|
-
const wallet = lastAuthenticatedAccount(user);
|
|
7
4
|
const kyc = {
|
|
8
5
|
alias: (_a = user.alias) !== null && _a !== void 0 ? _a : undefined,
|
|
9
6
|
btcWallet: (_b = user.btcWallet) !== null && _b !== void 0 ? _b : undefined,
|
|
@@ -26,7 +23,7 @@ const createUserProfileFromSdkUser = (user) => {
|
|
|
26
23
|
team: (_u = user.team) !== null && _u !== void 0 ? _u : undefined,
|
|
27
24
|
username: (_v = user.username) !== null && _v !== void 0 ? _v : undefined,
|
|
28
25
|
};
|
|
29
|
-
const userProfile = Object.assign({
|
|
26
|
+
const userProfile = Object.assign({ environmentId: user.projectEnvironmentId, lastVerifiedCredentialId: (_w = user.lastVerifiedCredentialId) !== null && _w !== void 0 ? _w : undefined, lists: user.lists, metadata: user.metadata, mfaBackupCodeAcknowledgement: user.mfaBackupCodeAcknowledgement, missingFields: user.missingFields, newUser: user.newUser, scope: user.scope, sessionId: (_x = user.sessionId) !== null && _x !== void 0 ? _x : 'missing-sessionId', userId: user.id, verifiedCredentials: user.verifiedCredentials || [] }, kyc);
|
|
30
27
|
return userProfile;
|
|
31
28
|
};
|
|
32
29
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { isAuthenticatedWithAWallet } from './isAuthenticatedWithAWallet';
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
var sdkApiCore = require('@dynamic-labs/sdk-api-core');
|
|
7
|
+
|
|
8
|
+
const isAuthenticatedWithAWallet = (user) => {
|
|
9
|
+
const lastVerifiedCredential = user.verifiedCredentials.find((vc) => vc.id === user.lastVerifiedCredentialId);
|
|
10
|
+
return ((lastVerifiedCredential === null || lastVerifiedCredential === void 0 ? void 0 : lastVerifiedCredential.format) ===
|
|
11
|
+
sdkApiCore.JwtVerifiedCredentialFormatEnum.Blockchain);
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
exports.isAuthenticatedWithAWallet = isAuthenticatedWithAWallet;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
import { JwtVerifiedCredentialFormatEnum } from '@dynamic-labs/sdk-api-core';
|
|
3
|
+
|
|
4
|
+
const isAuthenticatedWithAWallet = (user) => {
|
|
5
|
+
const lastVerifiedCredential = user.verifiedCredentials.find((vc) => vc.id === user.lastVerifiedCredentialId);
|
|
6
|
+
return ((lastVerifiedCredential === null || lastVerifiedCredential === void 0 ? void 0 : lastVerifiedCredential.format) ===
|
|
7
|
+
JwtVerifiedCredentialFormatEnum.Blockchain);
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export { isAuthenticatedWithAWallet };
|
package/src/lib/utils/functions/isMultiAssetSupportedNetwork/isMultiAssetSupportedNetwork.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { WalletConnector } from '@dynamic-labs/wallet-connector-core';
|
|
2
|
-
export declare const isMultiAssetSupportedNetwork: (walletConnector: WalletConnector |
|
|
2
|
+
export declare const isMultiAssetSupportedNetwork: (walletConnector: WalletConnector | undefined, network: string | number | undefined) => boolean;
|
|
@@ -165,6 +165,7 @@ const useConnectWallet = ({ authMode, clearPrimaryWalletId, enableVisitTrackingO
|
|
|
165
165
|
connector: walletConnector,
|
|
166
166
|
id: storedConnectedWalletInfo.id,
|
|
167
167
|
isAuthenticated: false,
|
|
168
|
+
isPrimary: primaryWalletId === storedConnectedWalletInfo.id,
|
|
168
169
|
key: walletConnector.key,
|
|
169
170
|
network: walletNetwork,
|
|
170
171
|
});
|
|
@@ -176,6 +177,7 @@ const useConnectWallet = ({ authMode, clearPrimaryWalletId, enableVisitTrackingO
|
|
|
176
177
|
disconnectWallet,
|
|
177
178
|
setConnectedWallets,
|
|
178
179
|
walletConnectorOptions,
|
|
180
|
+
primaryWalletId,
|
|
179
181
|
]);
|
|
180
182
|
// Generate the connectedWallets list when connectedWalletsInfo (localStorage) or memoized wallet connector updates
|
|
181
183
|
React.useEffect(() => {
|
|
@@ -161,6 +161,7 @@ const useConnectWallet = ({ authMode, clearPrimaryWalletId, enableVisitTrackingO
|
|
|
161
161
|
connector: walletConnector,
|
|
162
162
|
id: storedConnectedWalletInfo.id,
|
|
163
163
|
isAuthenticated: false,
|
|
164
|
+
isPrimary: primaryWalletId === storedConnectedWalletInfo.id,
|
|
164
165
|
key: walletConnector.key,
|
|
165
166
|
network: walletNetwork,
|
|
166
167
|
});
|
|
@@ -172,6 +173,7 @@ const useConnectWallet = ({ authMode, clearPrimaryWalletId, enableVisitTrackingO
|
|
|
172
173
|
disconnectWallet,
|
|
173
174
|
setConnectedWallets,
|
|
174
175
|
walletConnectorOptions,
|
|
176
|
+
primaryWalletId,
|
|
175
177
|
]);
|
|
176
178
|
// Generate the connectedWallets list when connectedWalletsInfo (localStorage) or memoized wallet connector updates
|
|
177
179
|
useEffect(() => {
|
package/src/lib/utils/hooks/useEmbeddedWallet/useMPCEmbeddedWallet/useCoinbaseMPC/useCoinbaseMPC.cjs
CHANGED
|
@@ -112,6 +112,7 @@ const useCoinbaseMPC = () => {
|
|
|
112
112
|
connector,
|
|
113
113
|
id: embeddedWalletVerifiedCredential.id,
|
|
114
114
|
isAuthenticated: true,
|
|
115
|
+
isPrimary: true,
|
|
115
116
|
key: (_a = embeddedWalletVerifiedCredential.walletName) !== null && _a !== void 0 ? _a : connector.key,
|
|
116
117
|
});
|
|
117
118
|
return coinbaseMPCWallet;
|
|
@@ -178,6 +179,7 @@ const useCoinbaseMPC = () => {
|
|
|
178
179
|
connector,
|
|
179
180
|
id: newSelectedCredentialWallet.id,
|
|
180
181
|
isAuthenticated: true,
|
|
182
|
+
isPrimary: true,
|
|
181
183
|
key: (_c = newSelectedCredentialWallet.walletName) !== null && _c !== void 0 ? _c : connector.key,
|
|
182
184
|
});
|
|
183
185
|
dynamicEvents.dynamicEvents.emit('embeddedWalletCreated', coinbaseMPCWallet, newSelectedCredentialWallet, updatedUser);
|
package/src/lib/utils/hooks/useEmbeddedWallet/useMPCEmbeddedWallet/useCoinbaseMPC/useCoinbaseMPC.js
CHANGED
|
@@ -108,6 +108,7 @@ const useCoinbaseMPC = () => {
|
|
|
108
108
|
connector,
|
|
109
109
|
id: embeddedWalletVerifiedCredential.id,
|
|
110
110
|
isAuthenticated: true,
|
|
111
|
+
isPrimary: true,
|
|
111
112
|
key: (_a = embeddedWalletVerifiedCredential.walletName) !== null && _a !== void 0 ? _a : connector.key,
|
|
112
113
|
});
|
|
113
114
|
return coinbaseMPCWallet;
|
|
@@ -174,6 +175,7 @@ const useCoinbaseMPC = () => {
|
|
|
174
175
|
connector,
|
|
175
176
|
id: newSelectedCredentialWallet.id,
|
|
176
177
|
isAuthenticated: true,
|
|
178
|
+
isPrimary: true,
|
|
177
179
|
key: (_c = newSelectedCredentialWallet.walletName) !== null && _c !== void 0 ? _c : connector.key,
|
|
178
180
|
});
|
|
179
181
|
dynamicEvents.emit('embeddedWalletCreated', coinbaseMPCWallet, newSelectedCredentialWallet, updatedUser);
|
|
@@ -126,12 +126,13 @@ var useInternalDynamicContext = require('../../../../context/DynamicContext/useD
|
|
|
126
126
|
*/
|
|
127
127
|
const useSecureEnclaveEmbeddedWallet = () => {
|
|
128
128
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
129
|
-
const { projectSettings, primaryWallet, user: user$1, environmentId, walletConnectorOptions,
|
|
129
|
+
const { projectSettings, primaryWallet, user: user$1, environmentId, walletConnectorOptions, } = useInternalDynamicContext.useInternalDynamicContext();
|
|
130
130
|
const { createTurnkeyWallet } = useTurnkey.useTurnkey();
|
|
131
131
|
const { hasRecoveryEmail } = useIsTurnkeyWallet.useIsTurnkeyWallet();
|
|
132
132
|
const { createRootElement } = useElementById.useElementById();
|
|
133
133
|
const { isLoadingEmbeddedWallet, setIsLoadingEmbeddedWallet } = WalletContext.useWalletContext();
|
|
134
134
|
const wallet = getEOAWallet.getEOAWallet(primaryWallet, (user$1 === null || user$1 === void 0 ? void 0 : user$1.verifiedCredentials) || []);
|
|
135
|
+
const primaryConnector = primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.connector;
|
|
135
136
|
const userHasEmbeddedWallet = React.useCallback(() => hasEmbeddedWallet.hasEmbeddedWallet(user$1, 'turnkey'), [user$1]);
|
|
136
137
|
const getWalletVersion = () => {
|
|
137
138
|
if (walletConnectorCore.isSessionKeyCompatibleWalletConnector(wallet === null || wallet === void 0 ? void 0 : wallet.connector)) {
|
|
@@ -347,9 +348,9 @@ const useSecureEnclaveEmbeddedWallet = () => {
|
|
|
347
348
|
const isSessionKeySessionAAActive = ((_e = wallet === null || wallet === void 0 ? void 0 : wallet.connector) === null || _e === void 0 ? void 0 : _e.key) === 'zerodev' &&
|
|
348
349
|
walletConnectorCore.isSessionKeyCompatibleWalletConnector((wallet === null || wallet === void 0 ? void 0 : wallet.connector).getEOAConnector()) &&
|
|
349
350
|
((_h = (_g = (_f = wallet === null || wallet === void 0 ? void 0 : wallet.connector) === null || _f === void 0 ? void 0 : _f.getEOAConnector()) === null || _g === void 0 ? void 0 : _g.sessionKeys) === null || _h === void 0 ? void 0 : _h.publicKey);
|
|
350
|
-
const isSessionKeySessionActive = (_k = Boolean(
|
|
351
|
-
walletConnectorCore.isSessionKeyCompatibleWalletConnector(
|
|
352
|
-
((_j =
|
|
351
|
+
const isSessionKeySessionActive = (_k = Boolean(primaryConnector &&
|
|
352
|
+
walletConnectorCore.isSessionKeyCompatibleWalletConnector(primaryConnector) &&
|
|
353
|
+
((_j = primaryConnector.sessionKeys) === null || _j === void 0 ? void 0 : _j.publicKey))) !== null && _k !== void 0 ? _k : false;
|
|
353
354
|
/**
|
|
354
355
|
* Checks if the embedded wallet session is active
|
|
355
356
|
* @returns boolean
|
|
@@ -122,12 +122,13 @@ import { useInternalDynamicContext } from '../../../../context/DynamicContext/us
|
|
|
122
122
|
*/
|
|
123
123
|
const useSecureEnclaveEmbeddedWallet = () => {
|
|
124
124
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
125
|
-
const { projectSettings, primaryWallet, user, environmentId, walletConnectorOptions,
|
|
125
|
+
const { projectSettings, primaryWallet, user, environmentId, walletConnectorOptions, } = useInternalDynamicContext();
|
|
126
126
|
const { createTurnkeyWallet } = useTurnkey();
|
|
127
127
|
const { hasRecoveryEmail } = useIsTurnkeyWallet();
|
|
128
128
|
const { createRootElement } = useElementById();
|
|
129
129
|
const { isLoadingEmbeddedWallet, setIsLoadingEmbeddedWallet } = useWalletContext();
|
|
130
130
|
const wallet = getEOAWallet(primaryWallet, (user === null || user === void 0 ? void 0 : user.verifiedCredentials) || []);
|
|
131
|
+
const primaryConnector = primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.connector;
|
|
131
132
|
const userHasEmbeddedWallet = useCallback(() => hasEmbeddedWallet(user, 'turnkey'), [user]);
|
|
132
133
|
const getWalletVersion = () => {
|
|
133
134
|
if (isSessionKeyCompatibleWalletConnector(wallet === null || wallet === void 0 ? void 0 : wallet.connector)) {
|
|
@@ -343,9 +344,9 @@ const useSecureEnclaveEmbeddedWallet = () => {
|
|
|
343
344
|
const isSessionKeySessionAAActive = ((_e = wallet === null || wallet === void 0 ? void 0 : wallet.connector) === null || _e === void 0 ? void 0 : _e.key) === 'zerodev' &&
|
|
344
345
|
isSessionKeyCompatibleWalletConnector((wallet === null || wallet === void 0 ? void 0 : wallet.connector).getEOAConnector()) &&
|
|
345
346
|
((_h = (_g = (_f = wallet === null || wallet === void 0 ? void 0 : wallet.connector) === null || _f === void 0 ? void 0 : _f.getEOAConnector()) === null || _g === void 0 ? void 0 : _g.sessionKeys) === null || _h === void 0 ? void 0 : _h.publicKey);
|
|
346
|
-
const isSessionKeySessionActive = (_k = Boolean(
|
|
347
|
-
isSessionKeyCompatibleWalletConnector(
|
|
348
|
-
((_j =
|
|
347
|
+
const isSessionKeySessionActive = (_k = Boolean(primaryConnector &&
|
|
348
|
+
isSessionKeyCompatibleWalletConnector(primaryConnector) &&
|
|
349
|
+
((_j = primaryConnector.sessionKeys) === null || _j === void 0 ? void 0 : _j.publicKey))) !== null && _k !== void 0 ? _k : false;
|
|
349
350
|
/**
|
|
350
351
|
* Checks if the embedded wallet session is active
|
|
351
352
|
* @returns boolean
|
|
@@ -100,8 +100,9 @@ var useInternalDynamicContext = require('../../../../../context/DynamicContext/u
|
|
|
100
100
|
|
|
101
101
|
// Hook exposed to customers and used internally to trigger embedded wallet creation
|
|
102
102
|
const useTurnkey = () => {
|
|
103
|
-
const { projectSettings, setPrimaryWalletId, walletConnectorOptions,
|
|
103
|
+
const { projectSettings, setPrimaryWalletId, walletConnectorOptions, setShowAuthFlow, environmentId, user, primaryWallet, } = useInternalDynamicContext.useInternalDynamicContext();
|
|
104
104
|
const { setView } = ViewContext.useViewContext();
|
|
105
|
+
const walletConnector = primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.connector;
|
|
105
106
|
const { createDynamicEmbeddedWalletMutation } = useCreateDynamicEmbeddedWalletMutation.useCreateDynamicEmbeddedWalletMutation();
|
|
106
107
|
const startHeadlessEmbeddedWalletCreationFlow = React.useCallback((chains, options) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
107
108
|
yield createDynamicEmbeddedWalletMutation({
|
|
@@ -147,6 +148,7 @@ const useTurnkey = () => {
|
|
|
147
148
|
var _a, _b, _c, _d;
|
|
148
149
|
const { chain } = embeddedWalletVerifiedCredential;
|
|
149
150
|
const turnkeyWallet = findTurnkeyWallet.findTurnkeyWalletByChain(walletConnectorOptions, chain);
|
|
151
|
+
let newPrimaryWalletId = null;
|
|
150
152
|
// if user already has embedded wallet, set it as primary wallet
|
|
151
153
|
if (user) {
|
|
152
154
|
(_a = turnkeyWallet === null || turnkeyWallet === void 0 ? void 0 : turnkeyWallet.walletConnector) === null || _a === void 0 ? void 0 : _a.setVerifiedCredentials(user.verifiedCredentials);
|
|
@@ -157,12 +159,14 @@ const useTurnkey = () => {
|
|
|
157
159
|
verifiedCredentials: user.verifiedCredentials,
|
|
158
160
|
walletConnectorOptions,
|
|
159
161
|
});
|
|
160
|
-
|
|
162
|
+
newPrimaryWalletId = smartWallet$1.id;
|
|
161
163
|
}
|
|
162
164
|
else {
|
|
163
|
-
|
|
165
|
+
newPrimaryWalletId = embeddedWalletVerifiedCredential.id;
|
|
164
166
|
}
|
|
165
167
|
}
|
|
168
|
+
if (newPrimaryWalletId)
|
|
169
|
+
setPrimaryWalletId(newPrimaryWalletId);
|
|
166
170
|
/** It's not authenticated if it still hasn't created a passkey */
|
|
167
171
|
const isAuthenticated = Boolean((_b = embeddedWalletVerifiedCredential.walletProperties) === null || _b === void 0 ? void 0 : _b.isAuthenticatorAttached);
|
|
168
172
|
const passkeyWallet = new walletConnectorCore.Wallet({
|
|
@@ -171,6 +175,7 @@ const useTurnkey = () => {
|
|
|
171
175
|
connector: (turnkeyWallet === null || turnkeyWallet === void 0 ? void 0 : turnkeyWallet.walletConnector) || {},
|
|
172
176
|
id: embeddedWalletVerifiedCredential.id,
|
|
173
177
|
isAuthenticated,
|
|
178
|
+
isPrimary: newPrimaryWalletId === embeddedWalletVerifiedCredential.id,
|
|
174
179
|
key: embeddedWalletVerifiedCredential.walletName ||
|
|
175
180
|
(turnkeyWallet === null || turnkeyWallet === void 0 ? void 0 : turnkeyWallet.walletConnector.key) ||
|
|
176
181
|
'',
|
|
@@ -223,6 +228,7 @@ const useTurnkey = () => {
|
|
|
223
228
|
connector: walletConnector,
|
|
224
229
|
id: embeddedWalletVerifiedCredential.id,
|
|
225
230
|
isAuthenticated: Boolean((_h = embeddedWalletVerifiedCredential === null || embeddedWalletVerifiedCredential === void 0 ? void 0 : embeddedWalletVerifiedCredential.walletProperties) === null || _h === void 0 ? void 0 : _h.isAuthenticatorAttached),
|
|
231
|
+
isPrimary: true,
|
|
226
232
|
key: (_j = embeddedWalletVerifiedCredential.walletName) !== null && _j !== void 0 ? _j : walletConnector.key,
|
|
227
233
|
});
|
|
228
234
|
setPrimaryWalletId(embeddedWalletVerifiedCredential.id);
|
|
@@ -96,8 +96,9 @@ import { useInternalDynamicContext } from '../../../../../context/DynamicContext
|
|
|
96
96
|
|
|
97
97
|
// Hook exposed to customers and used internally to trigger embedded wallet creation
|
|
98
98
|
const useTurnkey = () => {
|
|
99
|
-
const { projectSettings, setPrimaryWalletId, walletConnectorOptions,
|
|
99
|
+
const { projectSettings, setPrimaryWalletId, walletConnectorOptions, setShowAuthFlow, environmentId, user, primaryWallet, } = useInternalDynamicContext();
|
|
100
100
|
const { setView } = useViewContext();
|
|
101
|
+
const walletConnector = primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.connector;
|
|
101
102
|
const { createDynamicEmbeddedWalletMutation } = useCreateDynamicEmbeddedWalletMutation();
|
|
102
103
|
const startHeadlessEmbeddedWalletCreationFlow = useCallback((chains, options) => __awaiter(void 0, void 0, void 0, function* () {
|
|
103
104
|
yield createDynamicEmbeddedWalletMutation({
|
|
@@ -143,6 +144,7 @@ const useTurnkey = () => {
|
|
|
143
144
|
var _a, _b, _c, _d;
|
|
144
145
|
const { chain } = embeddedWalletVerifiedCredential;
|
|
145
146
|
const turnkeyWallet = findTurnkeyWalletByChain(walletConnectorOptions, chain);
|
|
147
|
+
let newPrimaryWalletId = null;
|
|
146
148
|
// if user already has embedded wallet, set it as primary wallet
|
|
147
149
|
if (user) {
|
|
148
150
|
(_a = turnkeyWallet === null || turnkeyWallet === void 0 ? void 0 : turnkeyWallet.walletConnector) === null || _a === void 0 ? void 0 : _a.setVerifiedCredentials(user.verifiedCredentials);
|
|
@@ -153,12 +155,14 @@ const useTurnkey = () => {
|
|
|
153
155
|
verifiedCredentials: user.verifiedCredentials,
|
|
154
156
|
walletConnectorOptions,
|
|
155
157
|
});
|
|
156
|
-
|
|
158
|
+
newPrimaryWalletId = smartWallet.id;
|
|
157
159
|
}
|
|
158
160
|
else {
|
|
159
|
-
|
|
161
|
+
newPrimaryWalletId = embeddedWalletVerifiedCredential.id;
|
|
160
162
|
}
|
|
161
163
|
}
|
|
164
|
+
if (newPrimaryWalletId)
|
|
165
|
+
setPrimaryWalletId(newPrimaryWalletId);
|
|
162
166
|
/** It's not authenticated if it still hasn't created a passkey */
|
|
163
167
|
const isAuthenticated = Boolean((_b = embeddedWalletVerifiedCredential.walletProperties) === null || _b === void 0 ? void 0 : _b.isAuthenticatorAttached);
|
|
164
168
|
const passkeyWallet = new Wallet({
|
|
@@ -167,6 +171,7 @@ const useTurnkey = () => {
|
|
|
167
171
|
connector: (turnkeyWallet === null || turnkeyWallet === void 0 ? void 0 : turnkeyWallet.walletConnector) || {},
|
|
168
172
|
id: embeddedWalletVerifiedCredential.id,
|
|
169
173
|
isAuthenticated,
|
|
174
|
+
isPrimary: newPrimaryWalletId === embeddedWalletVerifiedCredential.id,
|
|
170
175
|
key: embeddedWalletVerifiedCredential.walletName ||
|
|
171
176
|
(turnkeyWallet === null || turnkeyWallet === void 0 ? void 0 : turnkeyWallet.walletConnector.key) ||
|
|
172
177
|
'',
|
|
@@ -219,6 +224,7 @@ const useTurnkey = () => {
|
|
|
219
224
|
connector: walletConnector,
|
|
220
225
|
id: embeddedWalletVerifiedCredential.id,
|
|
221
226
|
isAuthenticated: Boolean((_h = embeddedWalletVerifiedCredential === null || embeddedWalletVerifiedCredential === void 0 ? void 0 : embeddedWalletVerifiedCredential.walletProperties) === null || _h === void 0 ? void 0 : _h.isAuthenticatorAttached),
|
|
227
|
+
isPrimary: true,
|
|
222
228
|
key: (_j = embeddedWalletVerifiedCredential.walletName) !== null && _j !== void 0 ? _j : walletConnector.key,
|
|
223
229
|
});
|
|
224
230
|
setPrimaryWalletId(embeddedWalletVerifiedCredential.id);
|
|
@@ -96,7 +96,8 @@ const useTokenBalances = ({ accountAddress, networkId, chainName = sdkApiCore.Ch
|
|
|
96
96
|
const [tokenBalancesData, setTokenBalancesData] = React.useState(undefined);
|
|
97
97
|
const [isLoading, setIsLoading] = React.useState(false);
|
|
98
98
|
const [error, setError] = React.useState(undefined);
|
|
99
|
-
const { primaryWallet, environmentId, network,
|
|
99
|
+
const { primaryWallet, environmentId, network, user } = useInternalDynamicContext.useInternalDynamicContext();
|
|
100
|
+
const walletConnector = primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.connector;
|
|
100
101
|
const requestChainName = chainName !== null && chainName !== void 0 ? chainName : walletConnector === null || walletConnector === void 0 ? void 0 : walletConnector.connectedChain;
|
|
101
102
|
const requestAccount = accountAddress !== null && accountAddress !== void 0 ? accountAddress : primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.address;
|
|
102
103
|
const requestNetwork = networkId !== null && networkId !== void 0 ? networkId : network;
|
|
@@ -92,7 +92,8 @@ const useTokenBalances = ({ accountAddress, networkId, chainName = ChainEnum.Evm
|
|
|
92
92
|
const [tokenBalancesData, setTokenBalancesData] = useState(undefined);
|
|
93
93
|
const [isLoading, setIsLoading] = useState(false);
|
|
94
94
|
const [error, setError] = useState(undefined);
|
|
95
|
-
const { primaryWallet, environmentId, network,
|
|
95
|
+
const { primaryWallet, environmentId, network, user } = useInternalDynamicContext();
|
|
96
|
+
const walletConnector = primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.connector;
|
|
96
97
|
const requestChainName = chainName !== null && chainName !== void 0 ? chainName : walletConnector === null || walletConnector === void 0 ? void 0 : walletConnector.connectedChain;
|
|
97
98
|
const requestAccount = accountAddress !== null && accountAddress !== void 0 ? accountAddress : primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.address;
|
|
98
99
|
const requestNetwork = networkId !== null && networkId !== void 0 ? networkId : network;
|
|
@@ -131,6 +131,7 @@ const createLinkedWalletsFromWalletOptions = ({ user, walletConnectorOptions, pr
|
|
|
131
131
|
connector: wallet.walletConnector,
|
|
132
132
|
id: account.id,
|
|
133
133
|
isAuthenticated: true,
|
|
134
|
+
isPrimary: account.id === primaryWalletId,
|
|
134
135
|
key: (_a = account.walletName) !== null && _a !== void 0 ? _a : wallet.walletConnector.key,
|
|
135
136
|
});
|
|
136
137
|
}
|
|
@@ -127,6 +127,7 @@ const createLinkedWalletsFromWalletOptions = ({ user, walletConnectorOptions, pr
|
|
|
127
127
|
connector: wallet.walletConnector,
|
|
128
128
|
id: account.id,
|
|
129
129
|
isAuthenticated: true,
|
|
130
|
+
isPrimary: account.id === primaryWalletId,
|
|
130
131
|
key: (_a = account.walletName) !== null && _a !== void 0 ? _a : wallet.walletConnector.key,
|
|
131
132
|
});
|
|
132
133
|
}
|
|
@@ -114,10 +114,11 @@ require('qrcode');
|
|
|
114
114
|
const SECONDS_TO_RETRY = 15;
|
|
115
115
|
const EmailVerification = ({ isEmailRecoveryFlow = false, showRetryButton: _showRetryButton = true, showTransferMessage: _showTransferMessage = false, }) => {
|
|
116
116
|
var _a, _b, _c, _d;
|
|
117
|
-
const { environmentId, handleLogOut, setPrimaryWalletId, setShowAuthFlow, projectSettings, user, userWithMissingInfo, walletConnectorOptions,
|
|
117
|
+
const { environmentId, handleLogOut, setPrimaryWalletId, setShowAuthFlow, projectSettings, user, userWithMissingInfo, walletConnectorOptions, primaryWallet, } = useInternalDynamicContext.useInternalDynamicContext();
|
|
118
118
|
const { setView, goToInitialView } = ViewContext.useViewContext();
|
|
119
119
|
const { error, setError, setErrorMessage } = ErrorContext.useErrorContext();
|
|
120
120
|
const { loading, setLoading } = LoadingContext.useLoadingContext();
|
|
121
|
+
const walletConnector = primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.connector;
|
|
121
122
|
const [showRetryButton, setShowRetryButton] = React.useState(_showRetryButton);
|
|
122
123
|
const [showTransferMessage, setShowTransferMessage] = React.useState(_showTransferMessage);
|
|
123
124
|
// Use a state to ensure UI is updated, but also a ref to access in effect cleanup
|
|
@@ -203,6 +204,7 @@ const EmailVerification = ({ isEmailRecoveryFlow = false, showRetryButton: _show
|
|
|
203
204
|
connector: walletOption.walletConnector,
|
|
204
205
|
id: embeddedWalletVerifiedCredential.id,
|
|
205
206
|
isAuthenticated: false,
|
|
207
|
+
isPrimary: true,
|
|
206
208
|
key: (_k = embeddedWalletVerifiedCredential.walletName) !== null && _k !== void 0 ? _k : '',
|
|
207
209
|
});
|
|
208
210
|
setPrimaryWalletId(embeddedWalletVerifiedCredential.id);
|
|
@@ -110,10 +110,11 @@ import 'qrcode';
|
|
|
110
110
|
const SECONDS_TO_RETRY = 15;
|
|
111
111
|
const EmailVerification = ({ isEmailRecoveryFlow = false, showRetryButton: _showRetryButton = true, showTransferMessage: _showTransferMessage = false, }) => {
|
|
112
112
|
var _a, _b, _c, _d;
|
|
113
|
-
const { environmentId, handleLogOut, setPrimaryWalletId, setShowAuthFlow, projectSettings, user, userWithMissingInfo, walletConnectorOptions,
|
|
113
|
+
const { environmentId, handleLogOut, setPrimaryWalletId, setShowAuthFlow, projectSettings, user, userWithMissingInfo, walletConnectorOptions, primaryWallet, } = useInternalDynamicContext();
|
|
114
114
|
const { setView, goToInitialView } = useViewContext();
|
|
115
115
|
const { error, setError, setErrorMessage } = useErrorContext();
|
|
116
116
|
const { loading, setLoading } = useLoadingContext();
|
|
117
|
+
const walletConnector = primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.connector;
|
|
117
118
|
const [showRetryButton, setShowRetryButton] = useState(_showRetryButton);
|
|
118
119
|
const [showTransferMessage, setShowTransferMessage] = useState(_showTransferMessage);
|
|
119
120
|
// Use a state to ensure UI is updated, but also a ref to access in effect cleanup
|
|
@@ -199,6 +200,7 @@ const EmailVerification = ({ isEmailRecoveryFlow = false, showRetryButton: _show
|
|
|
199
200
|
connector: walletOption.walletConnector,
|
|
200
201
|
id: embeddedWalletVerifiedCredential.id,
|
|
201
202
|
isAuthenticated: false,
|
|
203
|
+
isPrimary: true,
|
|
202
204
|
key: (_k = embeddedWalletVerifiedCredential.walletName) !== null && _k !== void 0 ? _k : '',
|
|
203
205
|
});
|
|
204
206
|
setPrimaryWalletId(embeddedWalletVerifiedCredential.id);
|
|
@@ -108,22 +108,26 @@ const LoginViewSection = ({ viewSection, index, walletCount, gotToWalletList, })
|
|
|
108
108
|
case sdkApiCore.SdkViewSectionType.Phone:
|
|
109
109
|
return (jsxRuntime.jsx(PhoneNumberSignInSection.PhoneNumberSignInSection, { onSubmit: () => setIsLoading(true), onSubmitError: () => setIsLoading(false), isLoading: isLoading }));
|
|
110
110
|
case sdkApiCore.SdkViewSectionType.EmailAndPhone:
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
111
|
+
// eslint-disable-next-line no-case-declarations
|
|
112
|
+
const sections = [
|
|
113
|
+
{
|
|
114
|
+
button: t('dyn_login.email_or_phone.use_phone'),
|
|
115
|
+
buttonCopyKey: 'dyn_login.email_or_phone.use_phone',
|
|
116
|
+
component: (jsxRuntime.jsx(LoginEmailForm.LoginEmailForm, { onSubmit: () => setIsLoading(true), onSubmitError: () => setIsLoading(false), isLoading: isLoading })),
|
|
117
|
+
label: t('dyn_login.email_or_phone.prefer_phone'),
|
|
118
|
+
labelCopyKey: 'dyn_login.email_or_phone.prefer_phone',
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
button: t('dyn_login.email_or_phone.use_email'),
|
|
122
|
+
buttonCopyKey: 'dyn_login.email_or_phone.use_email',
|
|
123
|
+
component: (jsxRuntime.jsx(PhoneNumberSignInSection.PhoneNumberSignInSection, { onSubmit: () => setIsLoading(true), onSubmitError: () => setIsLoading(false), isLoading: isLoading })),
|
|
124
|
+
label: t('dyn_login.email_or_phone.prefer_email'),
|
|
125
|
+
labelCopyKey: 'dyn_login.email_or_phone.prefer_email',
|
|
126
|
+
},
|
|
127
|
+
];
|
|
128
|
+
if (viewSection.defaultItem === 'phone')
|
|
129
|
+
sections.reverse();
|
|
130
|
+
return jsxRuntime.jsx(ToggleableSection.ToggleableSection, { sections: sections });
|
|
127
131
|
case sdkApiCore.SdkViewSectionType.Wallet:
|
|
128
132
|
return (jsxRuntime.jsx(WalletSignInSection.WalletSignInSection, { numberOfItensToShow: viewSection.numOfItemsToDisplay || 0, onSubmit: () => {
|
|
129
133
|
// this view is just to show the back button
|
|
@@ -104,22 +104,26 @@ const LoginViewSection = ({ viewSection, index, walletCount, gotToWalletList, })
|
|
|
104
104
|
case SdkViewSectionType.Phone:
|
|
105
105
|
return (jsx(PhoneNumberSignInSection, { onSubmit: () => setIsLoading(true), onSubmitError: () => setIsLoading(false), isLoading: isLoading }));
|
|
106
106
|
case SdkViewSectionType.EmailAndPhone:
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
107
|
+
// eslint-disable-next-line no-case-declarations
|
|
108
|
+
const sections = [
|
|
109
|
+
{
|
|
110
|
+
button: t('dyn_login.email_or_phone.use_phone'),
|
|
111
|
+
buttonCopyKey: 'dyn_login.email_or_phone.use_phone',
|
|
112
|
+
component: (jsx(LoginEmailForm, { onSubmit: () => setIsLoading(true), onSubmitError: () => setIsLoading(false), isLoading: isLoading })),
|
|
113
|
+
label: t('dyn_login.email_or_phone.prefer_phone'),
|
|
114
|
+
labelCopyKey: 'dyn_login.email_or_phone.prefer_phone',
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
button: t('dyn_login.email_or_phone.use_email'),
|
|
118
|
+
buttonCopyKey: 'dyn_login.email_or_phone.use_email',
|
|
119
|
+
component: (jsx(PhoneNumberSignInSection, { onSubmit: () => setIsLoading(true), onSubmitError: () => setIsLoading(false), isLoading: isLoading })),
|
|
120
|
+
label: t('dyn_login.email_or_phone.prefer_email'),
|
|
121
|
+
labelCopyKey: 'dyn_login.email_or_phone.prefer_email',
|
|
122
|
+
},
|
|
123
|
+
];
|
|
124
|
+
if (viewSection.defaultItem === 'phone')
|
|
125
|
+
sections.reverse();
|
|
126
|
+
return jsx(ToggleableSection, { sections: sections });
|
|
123
127
|
case SdkViewSectionType.Wallet:
|
|
124
128
|
return (jsx(WalletSignInSection, { numberOfItensToShow: viewSection.numOfItemsToDisplay || 0, onSubmit: () => {
|
|
125
129
|
// this view is just to show the back button
|
|
@@ -6,8 +6,7 @@ export type Section = {
|
|
|
6
6
|
buttonCopyKey?: string;
|
|
7
7
|
labelCopyKey?: string;
|
|
8
8
|
};
|
|
9
|
-
type ToggleableSectionProps = {
|
|
9
|
+
export type ToggleableSectionProps = {
|
|
10
10
|
sections: [Section, Section];
|
|
11
11
|
};
|
|
12
12
|
export declare const ToggleableSection: FC<ToggleableSectionProps>;
|
|
13
|
-
export {};
|
|
@@ -9,7 +9,7 @@ export declare const viewToComponentMap: {
|
|
|
9
9
|
'chainalysis-blocked-wallet': () => JSX.Element;
|
|
10
10
|
'collect-user-data': () => JSX.Element | null;
|
|
11
11
|
'collect-user-data-login-no-wallet': import("react").FC<{
|
|
12
|
-
userIdentification: keyof import("@dynamic-labs/sdk-api-core").UserFields | "
|
|
12
|
+
userIdentification: keyof import("@dynamic-labs/sdk-api-core").UserFields | "environmentId" | "lastVerifiedCredentialId" | "lists" | "newUser" | "sessionId" | "userId" | "verifiedCredentials" | "scope" | "missingFields";
|
|
13
13
|
userIdentificationOverride?: string | undefined;
|
|
14
14
|
}>;
|
|
15
15
|
'create-password-view': import("react").FC<import("./CreatePasswordView/CreatePasswordView").CreatePasswordViewProps>;
|
package/src/lib/widgets/DynamicWidget/components/ActiveWalletInformation/ActiveWalletInformation.cjs
CHANGED
|
@@ -115,7 +115,7 @@ const ActiveWalletInformation = ({ isLoading = false, }) => {
|
|
|
115
115
|
const [balanceIsExpanded, setBalanceIsExpanded] = React.useState(false);
|
|
116
116
|
const [hasShadow, setHasShadow] = React.useState(false);
|
|
117
117
|
const contentRef = React.useRef(null);
|
|
118
|
-
const { primaryWallet, network, projectSettings, user,
|
|
118
|
+
const { primaryWallet, network, projectSettings, user, authMode, showFiat, multiAsset, } = useInternalDynamicContext.useInternalDynamicContext();
|
|
119
119
|
const { setDynamicWidgetView } = DynamicWidgetContext.useWidgetContext();
|
|
120
120
|
const { isTurnkeyWalletWithoutAuthenticator } = useIsTurnkeyWallet.useIsTurnkeyWallet();
|
|
121
121
|
const { isLoading: isLoadingTokenBalances, tokenBalances, error: errorTokenBalances, } = useTokenBalances.useTokenBalances({
|
|
@@ -123,6 +123,7 @@ const ActiveWalletInformation = ({ isLoading = false, }) => {
|
|
|
123
123
|
includeFiat: showFiat,
|
|
124
124
|
includeNativeBalance: true,
|
|
125
125
|
});
|
|
126
|
+
const primaryConnector = primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.connector;
|
|
126
127
|
const filteredTokenBalances = (tokenBalances === null || tokenBalances === void 0 ? void 0 : tokenBalances.filter((token) => token.name)) || [];
|
|
127
128
|
const address = primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.address;
|
|
128
129
|
const nameService = useFetchNameService.useFetchNameService(address);
|
|
@@ -176,7 +177,7 @@ const ActiveWalletInformation = ({ isLoading = false, }) => {
|
|
|
176
177
|
}
|
|
177
178
|
};
|
|
178
179
|
const enableMultiAsset = authMode === 'connect-and-sign' && multiAsset;
|
|
179
|
-
const isNetworkMultiAssetSupported = isMultiAssetSupportedNetwork.isMultiAssetSupportedNetwork(
|
|
180
|
+
const isNetworkMultiAssetSupported = isMultiAssetSupportedNetwork.isMultiAssetSupportedNetwork(primaryConnector, network);
|
|
180
181
|
const isTooManyRequests = errorTokenBalances === 'Too many requests fetching balances';
|
|
181
182
|
const showMultiAsset = !isTooManyRequests && isNetworkMultiAssetSupported && enableMultiAsset;
|
|
182
183
|
filteredTokenBalances.sort((a, b) => ((b === null || b === void 0 ? void 0 : b.marketValue) || 0) - ((a === null || a === void 0 ? void 0 : a.marketValue) || 0));
|
package/src/lib/widgets/DynamicWidget/components/ActiveWalletInformation/ActiveWalletInformation.js
CHANGED
|
@@ -111,7 +111,7 @@ const ActiveWalletInformation = ({ isLoading = false, }) => {
|
|
|
111
111
|
const [balanceIsExpanded, setBalanceIsExpanded] = useState(false);
|
|
112
112
|
const [hasShadow, setHasShadow] = useState(false);
|
|
113
113
|
const contentRef = useRef(null);
|
|
114
|
-
const { primaryWallet, network, projectSettings, user,
|
|
114
|
+
const { primaryWallet, network, projectSettings, user, authMode, showFiat, multiAsset, } = useInternalDynamicContext();
|
|
115
115
|
const { setDynamicWidgetView } = useWidgetContext();
|
|
116
116
|
const { isTurnkeyWalletWithoutAuthenticator } = useIsTurnkeyWallet();
|
|
117
117
|
const { isLoading: isLoadingTokenBalances, tokenBalances, error: errorTokenBalances, } = useTokenBalances({
|
|
@@ -119,6 +119,7 @@ const ActiveWalletInformation = ({ isLoading = false, }) => {
|
|
|
119
119
|
includeFiat: showFiat,
|
|
120
120
|
includeNativeBalance: true,
|
|
121
121
|
});
|
|
122
|
+
const primaryConnector = primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.connector;
|
|
122
123
|
const filteredTokenBalances = (tokenBalances === null || tokenBalances === void 0 ? void 0 : tokenBalances.filter((token) => token.name)) || [];
|
|
123
124
|
const address = primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.address;
|
|
124
125
|
const nameService = useFetchNameService(address);
|
|
@@ -172,7 +173,7 @@ const ActiveWalletInformation = ({ isLoading = false, }) => {
|
|
|
172
173
|
}
|
|
173
174
|
};
|
|
174
175
|
const enableMultiAsset = authMode === 'connect-and-sign' && multiAsset;
|
|
175
|
-
const isNetworkMultiAssetSupported = isMultiAssetSupportedNetwork(
|
|
176
|
+
const isNetworkMultiAssetSupported = isMultiAssetSupportedNetwork(primaryConnector, network);
|
|
176
177
|
const isTooManyRequests = errorTokenBalances === 'Too many requests fetching balances';
|
|
177
178
|
const showMultiAsset = !isTooManyRequests && isNetworkMultiAssetSupported && enableMultiAsset;
|
|
178
179
|
filteredTokenBalances.sort((a, b) => ((b === null || b === void 0 ? void 0 : b.marketValue) || 0) - ((a === null || a === void 0 ? void 0 : a.marketValue) || 0));
|