@dynamic-labs/sdk-react-core 4.17.0 → 4.18.1
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 +25 -0
- package/package.cjs +2 -2
- package/package.js +2 -2
- package/package.json +12 -12
- package/src/lib/components/AppOriginTile/AppOriginTile.cjs +14 -14
- package/src/lib/components/AppOriginTile/AppOriginTile.d.ts +2 -2
- package/src/lib/components/AppOriginTile/AppOriginTile.js +16 -16
- package/src/lib/components/Chip/Chip.cjs +14 -0
- package/src/lib/components/Chip/Chip.js +10 -0
- package/src/lib/components/InlineSubmitButton/InlineSubmitButton.cjs +2 -2
- package/src/lib/components/InlineSubmitButton/InlineSubmitButton.js +2 -2
- package/src/lib/context/DynamicContext/hooks/useHandleLogout/useHandleLogout.cjs +0 -1
- package/src/lib/context/DynamicContext/hooks/useHandleLogout/useHandleLogout.js +1 -2
- package/src/lib/context/SocialRedirectContext/SocialRedirectContext.cjs +1 -1
- package/src/lib/context/SocialRedirectContext/SocialRedirectContext.js +1 -1
- package/src/lib/context/ViewContext/ViewContext.cjs +7 -2
- package/src/lib/context/ViewContext/ViewContext.js +7 -2
- package/src/lib/data/api/embeddedWallets/embeddedWallets.cjs +8 -3
- package/src/lib/data/api/embeddedWallets/embeddedWallets.d.ts +4 -2
- package/src/lib/data/api/embeddedWallets/embeddedWallets.js +8 -3
- package/src/lib/locale/en/translation.cjs +8 -4
- package/src/lib/locale/en/translation.d.ts +6 -2
- package/src/lib/locale/en/translation.js +8 -4
- package/src/lib/modals/SignMessageConfirmationModal/SignMessageConfirmationModal.cjs +8 -8
- package/src/lib/modals/SignMessageConfirmationModal/SignMessageConfirmationModal.js +9 -9
- package/src/lib/shared/utils/functions/getGlobalWalletContext/getGlobalWalletContext.cjs +15 -0
- package/src/lib/shared/utils/functions/getGlobalWalletContext/getGlobalWalletContext.d.ts +11 -0
- package/src/lib/shared/utils/functions/getGlobalWalletContext/getGlobalWalletContext.js +11 -0
- package/src/lib/shared/utils/functions/getGlobalWalletContext/index.d.ts +1 -0
- package/src/lib/shared/utils/functions/shortenWalletAddress/shortenWalletAddress.cjs +2 -0
- package/src/lib/shared/utils/functions/shortenWalletAddress/shortenWalletAddress.js +2 -0
- package/src/lib/styles/index.shadow.cjs +1 -1
- package/src/lib/styles/index.shadow.js +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/getPrimaryTurnkeyWalletId/getPrimaryTurnkeyWalletId.cjs +33 -0
- package/src/lib/utils/functions/getPrimaryTurnkeyWalletId/getPrimaryTurnkeyWalletId.d.ts +7 -0
- package/src/lib/utils/functions/getPrimaryTurnkeyWalletId/getPrimaryTurnkeyWalletId.js +29 -0
- package/src/lib/utils/functions/getPrimaryTurnkeyWalletId/inedex.d.ts +1 -0
- package/src/lib/utils/hooks/useDynamicWaas/useDynamicWaas.cjs +1 -1
- package/src/lib/utils/hooks/useDynamicWaas/useDynamicWaas.js +1 -1
- package/src/lib/utils/hooks/useEmbeddedWallet/useEmbeddedWallet.cjs +1 -1
- package/src/lib/utils/hooks/useEmbeddedWallet/useEmbeddedWallet.js +1 -1
- package/src/lib/utils/hooks/useEmbeddedWallet/useSecureEnclaveEmbeddedWallet/useSecureEnclaveEmbeddedWallet.cjs +6 -1
- package/src/lib/utils/hooks/useEmbeddedWallet/useSecureEnclaveEmbeddedWallet/useSecureEnclaveEmbeddedWallet.js +6 -1
- package/src/lib/utils/hooks/useEmbeddedWalletSessionKeys/useEmbeddedWalletSessionKeys.cjs +8 -1
- package/src/lib/utils/hooks/useEmbeddedWalletSessionKeys/useEmbeddedWalletSessionKeys.js +8 -1
- package/src/lib/utils/hooks/useTransferWallet/useTransferWallet.cjs +1 -1
- package/src/lib/utils/hooks/useTransferWallet/useTransferWallet.js +1 -1
- package/src/lib/views/EmbeddedDeleteView/EmbeddedDeleteView.cjs +3 -0
- package/src/lib/views/EmbeddedDeleteView/EmbeddedDeleteView.js +3 -0
- package/src/lib/views/EmbeddedReveal/EmbeddedRevealView/EmbeddedRevealView.cjs +7 -1
- package/src/lib/views/EmbeddedReveal/EmbeddedRevealView/EmbeddedRevealView.js +7 -1
- package/src/lib/views/EmbeddedReveal/utils/turnkeyExport/turnkeyExport.cjs +1 -1
- package/src/lib/views/EmbeddedReveal/utils/turnkeyExport/turnkeyExport.js +1 -1
- package/src/lib/views/Passkey/utils/passkeyRecovery/passkeyRecovery.cjs +4 -4
- package/src/lib/views/Passkey/utils/passkeyRecovery/passkeyRecovery.js +4 -4
- package/src/lib/views/TransactionConfirmationView/TransactionConfirmationView.cjs +17 -16
- package/src/lib/views/TransactionConfirmationView/TransactionConfirmationView.js +18 -17
- package/src/lib/widgets/DynamicWidget/components/EmailOTPConnectorPendingSignModalContent/EmailOTPConnectorPendingSignModalContent.cjs +1 -1
- package/src/lib/widgets/DynamicWidget/components/EmailOTPConnectorPendingSignModalContent/EmailOTPConnectorPendingSignModalContent.js +1 -1
- package/src/lib/widgets/DynamicWidget/views/AccountAndSecuritySettingsView/AccountAndSecuritySettingsView.cjs +2 -1
- package/src/lib/widgets/DynamicWidget/views/AccountAndSecuritySettingsView/AccountAndSecuritySettingsView.js +2 -1
- package/src/lib/components/AppOriginTile/AppOriginTile.types.d.ts +0 -7
|
@@ -18,7 +18,6 @@ const EMBEDDED_WALLET_SESSION_SETTINGS = 'dynamic_embedded_wallet_session_settin
|
|
|
18
18
|
const EMBEDDED_WALLET_SECURE_BANNER = 'dynamic_embedded_secure_banner';
|
|
19
19
|
const PHONE_INPUT_DEFAULT_COUNTRY = 'dynamic_phone_input_default_country';
|
|
20
20
|
const CAPTCHA_TOKEN = 'dynamic_captcha_token';
|
|
21
|
-
const ZERODEV_AUTHORIZATION = 'zerodev_authorization';
|
|
22
21
|
/**
|
|
23
22
|
* Used to identify the purpose of a signature after phantom redirects back to the app in mobile
|
|
24
23
|
*/
|
|
@@ -48,4 +47,3 @@ exports.SECURE_ENCLAVE_WALLET_SESSION_KEYS_STORAGE_OPTIONS = SECURE_ENCLAVE_WALL
|
|
|
48
47
|
exports.STORE_STORAGE_KEY = STORE_STORAGE_KEY;
|
|
49
48
|
exports.WAGMI_LAST_SESSION_SETTINGS = WAGMI_LAST_SESSION_SETTINGS;
|
|
50
49
|
exports.WALLET_PICKER_SEARCH_KEY = WALLET_PICKER_SEARCH_KEY;
|
|
51
|
-
exports.ZERODEV_AUTHORIZATION = ZERODEV_AUTHORIZATION;
|
|
@@ -16,7 +16,6 @@ export declare const EMBEDDED_WALLET_SESSION_SETTINGS = "dynamic_embedded_wallet
|
|
|
16
16
|
export declare const EMBEDDED_WALLET_SECURE_BANNER = "dynamic_embedded_secure_banner";
|
|
17
17
|
export declare const PHONE_INPUT_DEFAULT_COUNTRY = "dynamic_phone_input_default_country";
|
|
18
18
|
export declare const CAPTCHA_TOKEN = "dynamic_captcha_token";
|
|
19
|
-
export declare const ZERODEV_AUTHORIZATION = "zerodev_authorization";
|
|
20
19
|
export type PhantomSignatureState = {
|
|
21
20
|
/**
|
|
22
21
|
* Whether the user has agreed to transfer a wallet even if that means
|
|
@@ -14,7 +14,6 @@ const EMBEDDED_WALLET_SESSION_SETTINGS = 'dynamic_embedded_wallet_session_settin
|
|
|
14
14
|
const EMBEDDED_WALLET_SECURE_BANNER = 'dynamic_embedded_secure_banner';
|
|
15
15
|
const PHONE_INPUT_DEFAULT_COUNTRY = 'dynamic_phone_input_default_country';
|
|
16
16
|
const CAPTCHA_TOKEN = 'dynamic_captcha_token';
|
|
17
|
-
const ZERODEV_AUTHORIZATION = 'zerodev_authorization';
|
|
18
17
|
/**
|
|
19
18
|
* Used to identify the purpose of a signature after phantom redirects back to the app in mobile
|
|
20
19
|
*/
|
|
@@ -25,4 +24,4 @@ const SECURE_ENCLAVE_WALLET_SESSION_KEYS_STORAGE_OPTIONS = {
|
|
|
25
24
|
priority: ['secureStorage', 'localStorage'],
|
|
26
25
|
};
|
|
27
26
|
|
|
28
|
-
export { AUTH_EXPIRES_AT, AUTH_MIN_TOKEN, AUTH_TOKEN, BRIDGE_ONBOARDING_COMPLETED, CAPTCHA_TOKEN, CONNECTED_WALLET_NAME_SERVICE, DEVICE_FINGERPRINT, DYNAMIC_CONTEXT_LAST_SESSION_SETTINGS, EMBEDDED_WALLET_SECURE_BANNER, EMBEDDED_WALLET_SESSION_SETTINGS, LAST_USED_WALLET, NEWTOWEB3_WALLET_EXTENSION_FLAG_KEY, PHANTOM_SIGNATURE_STATE, PHONE_INPUT_DEFAULT_COUNTRY, SECURE_ENCLAVE_WALLET_SESSION_KEYS, SECURE_ENCLAVE_WALLET_SESSION_KEYS_STORAGE_OPTIONS, STORE_STORAGE_KEY, WAGMI_LAST_SESSION_SETTINGS, WALLET_PICKER_SEARCH_KEY
|
|
27
|
+
export { AUTH_EXPIRES_AT, AUTH_MIN_TOKEN, AUTH_TOKEN, BRIDGE_ONBOARDING_COMPLETED, CAPTCHA_TOKEN, CONNECTED_WALLET_NAME_SERVICE, DEVICE_FINGERPRINT, DYNAMIC_CONTEXT_LAST_SESSION_SETTINGS, EMBEDDED_WALLET_SECURE_BANNER, EMBEDDED_WALLET_SESSION_SETTINGS, LAST_USED_WALLET, NEWTOWEB3_WALLET_EXTENSION_FLAG_KEY, PHANTOM_SIGNATURE_STATE, PHONE_INPUT_DEFAULT_COUNTRY, SECURE_ENCLAVE_WALLET_SESSION_KEYS, SECURE_ENCLAVE_WALLET_SESSION_KEYS_STORAGE_OPTIONS, STORE_STORAGE_KEY, WAGMI_LAST_SESSION_SETTINGS, WALLET_PICKER_SEARCH_KEY };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* returns the id of the primary turnkey wallet
|
|
8
|
+
* if the primary wallet is a turnkey wallet, it returns the id of the primary wallet
|
|
9
|
+
* if the primary wallet is a zerodev wallet, it returns corresponding turnkey wallet id
|
|
10
|
+
*/
|
|
11
|
+
const getPrimaryTurnkeyWalletId = (primaryWalletId, verifiedCredentials) => {
|
|
12
|
+
const primaryWallet = verifiedCredentials === null || verifiedCredentials === void 0 ? void 0 : verifiedCredentials.find(({ id }) => id === primaryWalletId);
|
|
13
|
+
if (!primaryWallet) {
|
|
14
|
+
throw new Error('Primary wallet not found');
|
|
15
|
+
}
|
|
16
|
+
const walletName = primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.walletName;
|
|
17
|
+
if (!walletName) {
|
|
18
|
+
throw new Error('Wallet name not found');
|
|
19
|
+
}
|
|
20
|
+
let turnkeyWalletId;
|
|
21
|
+
if (walletName.startsWith('zerodev')) {
|
|
22
|
+
turnkeyWalletId = primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.signerRefId;
|
|
23
|
+
}
|
|
24
|
+
else if (walletName.startsWith('turnkey')) {
|
|
25
|
+
turnkeyWalletId = primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.id;
|
|
26
|
+
}
|
|
27
|
+
if (!turnkeyWalletId) {
|
|
28
|
+
throw new Error(`Invalid wallet type: ${walletName}, expecting one of 'turnkey' or 'zerodev'`);
|
|
29
|
+
}
|
|
30
|
+
return turnkeyWalletId;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
exports.getPrimaryTurnkeyWalletId = getPrimaryTurnkeyWalletId;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { JwtVerifiedCredential } from '@dynamic-labs/sdk-api-core';
|
|
2
|
+
/**
|
|
3
|
+
* returns the id of the primary turnkey wallet
|
|
4
|
+
* if the primary wallet is a turnkey wallet, it returns the id of the primary wallet
|
|
5
|
+
* if the primary wallet is a zerodev wallet, it returns corresponding turnkey wallet id
|
|
6
|
+
*/
|
|
7
|
+
export declare const getPrimaryTurnkeyWalletId: (primaryWalletId: string, verifiedCredentials: JwtVerifiedCredential[]) => string;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
/**
|
|
3
|
+
* returns the id of the primary turnkey wallet
|
|
4
|
+
* if the primary wallet is a turnkey wallet, it returns the id of the primary wallet
|
|
5
|
+
* if the primary wallet is a zerodev wallet, it returns corresponding turnkey wallet id
|
|
6
|
+
*/
|
|
7
|
+
const getPrimaryTurnkeyWalletId = (primaryWalletId, verifiedCredentials) => {
|
|
8
|
+
const primaryWallet = verifiedCredentials === null || verifiedCredentials === void 0 ? void 0 : verifiedCredentials.find(({ id }) => id === primaryWalletId);
|
|
9
|
+
if (!primaryWallet) {
|
|
10
|
+
throw new Error('Primary wallet not found');
|
|
11
|
+
}
|
|
12
|
+
const walletName = primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.walletName;
|
|
13
|
+
if (!walletName) {
|
|
14
|
+
throw new Error('Wallet name not found');
|
|
15
|
+
}
|
|
16
|
+
let turnkeyWalletId;
|
|
17
|
+
if (walletName.startsWith('zerodev')) {
|
|
18
|
+
turnkeyWalletId = primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.signerRefId;
|
|
19
|
+
}
|
|
20
|
+
else if (walletName.startsWith('turnkey')) {
|
|
21
|
+
turnkeyWalletId = primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.id;
|
|
22
|
+
}
|
|
23
|
+
if (!turnkeyWalletId) {
|
|
24
|
+
throw new Error(`Invalid wallet type: ${walletName}, expecting one of 'turnkey' or 'zerodev'`);
|
|
25
|
+
}
|
|
26
|
+
return turnkeyWalletId;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export { getPrimaryTurnkeyWalletId };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './getPrimaryTurnkeyWalletId';
|
|
@@ -42,13 +42,13 @@ require('../../../context/VerificationContext/VerificationContext.cjs');
|
|
|
42
42
|
require('react-dom');
|
|
43
43
|
var smartWallet = require('../useWalletConnectors/utils/smartWallet/smartWallet.cjs');
|
|
44
44
|
require('../../../views/Passkey/utils/findPrimaryEmbeddedChain/findPrimaryEmbeddedChain.cjs');
|
|
45
|
+
require('../../../store/state/primaryWalletId/primaryWalletId.cjs');
|
|
45
46
|
require('../../../context/ThemeContext/ThemeContext.cjs');
|
|
46
47
|
require('../../functions/compareChains/compareChains.cjs');
|
|
47
48
|
require('../useUserUpdateRequest/useUpdateUser/userFieldsSchema.cjs');
|
|
48
49
|
require('bs58');
|
|
49
50
|
require('@dynamic-labs/types');
|
|
50
51
|
require('../../../context/SocialRedirectContext/SocialRedirectContext.cjs');
|
|
51
|
-
require('../../../store/state/primaryWalletId/primaryWalletId.cjs');
|
|
52
52
|
require('../../../context/LoadingContext/LoadingContext.cjs');
|
|
53
53
|
require('../../../context/WalletContext/WalletContext.cjs');
|
|
54
54
|
require('../useEmbeddedWallet/useSecureEnclaveEmbeddedWallet/constants.cjs');
|
|
@@ -38,13 +38,13 @@ import '../../../context/VerificationContext/VerificationContext.js';
|
|
|
38
38
|
import 'react-dom';
|
|
39
39
|
import { findSmartWallet } from '../useWalletConnectors/utils/smartWallet/smartWallet.js';
|
|
40
40
|
import '../../../views/Passkey/utils/findPrimaryEmbeddedChain/findPrimaryEmbeddedChain.js';
|
|
41
|
+
import '../../../store/state/primaryWalletId/primaryWalletId.js';
|
|
41
42
|
import '../../../context/ThemeContext/ThemeContext.js';
|
|
42
43
|
import '../../functions/compareChains/compareChains.js';
|
|
43
44
|
import '../useUserUpdateRequest/useUpdateUser/userFieldsSchema.js';
|
|
44
45
|
import 'bs58';
|
|
45
46
|
import '@dynamic-labs/types';
|
|
46
47
|
import '../../../context/SocialRedirectContext/SocialRedirectContext.js';
|
|
47
|
-
import '../../../store/state/primaryWalletId/primaryWalletId.js';
|
|
48
48
|
import '../../../context/LoadingContext/LoadingContext.js';
|
|
49
49
|
import '../../../context/WalletContext/WalletContext.js';
|
|
50
50
|
import '../useEmbeddedWallet/useSecureEnclaveEmbeddedWallet/constants.js';
|
|
@@ -41,13 +41,13 @@ require('../../../context/VerificationContext/VerificationContext.cjs');
|
|
|
41
41
|
require('react-dom');
|
|
42
42
|
require('../../functions/compareChains/compareChains.cjs');
|
|
43
43
|
var findPrimaryEmbeddedChain = require('../../../views/Passkey/utils/findPrimaryEmbeddedChain/findPrimaryEmbeddedChain.cjs');
|
|
44
|
+
var primaryWalletId = require('../../../store/state/primaryWalletId/primaryWalletId.cjs');
|
|
44
45
|
require('../../../context/ThemeContext/ThemeContext.cjs');
|
|
45
46
|
require('../useUserUpdateRequest/useUpdateUser/userFieldsSchema.cjs');
|
|
46
47
|
var useIsTurnkeyWallet = require('../useIsTurnkeyWallet/useIsTurnkeyWallet.cjs');
|
|
47
48
|
require('bs58');
|
|
48
49
|
require('@dynamic-labs/types');
|
|
49
50
|
require('../../../context/SocialRedirectContext/SocialRedirectContext.cjs');
|
|
50
|
-
var primaryWalletId = require('../../../store/state/primaryWalletId/primaryWalletId.cjs');
|
|
51
51
|
require('../../../context/LoadingContext/LoadingContext.cjs');
|
|
52
52
|
var WalletContext = require('../../../context/WalletContext/WalletContext.cjs');
|
|
53
53
|
var useSecureEnclaveEmbeddedWallet = require('./useSecureEnclaveEmbeddedWallet/useSecureEnclaveEmbeddedWallet.cjs');
|
|
@@ -37,13 +37,13 @@ import '../../../context/VerificationContext/VerificationContext.js';
|
|
|
37
37
|
import 'react-dom';
|
|
38
38
|
import '../../functions/compareChains/compareChains.js';
|
|
39
39
|
import { findPrimaryEmbeddedChain } from '../../../views/Passkey/utils/findPrimaryEmbeddedChain/findPrimaryEmbeddedChain.js';
|
|
40
|
+
import { getPrimaryWalletId } from '../../../store/state/primaryWalletId/primaryWalletId.js';
|
|
40
41
|
import '../../../context/ThemeContext/ThemeContext.js';
|
|
41
42
|
import '../useUserUpdateRequest/useUpdateUser/userFieldsSchema.js';
|
|
42
43
|
import { useIsTurnkeyWallet } from '../useIsTurnkeyWallet/useIsTurnkeyWallet.js';
|
|
43
44
|
import 'bs58';
|
|
44
45
|
import '@dynamic-labs/types';
|
|
45
46
|
import '../../../context/SocialRedirectContext/SocialRedirectContext.js';
|
|
46
|
-
import { getPrimaryWalletId } from '../../../store/state/primaryWalletId/primaryWalletId.js';
|
|
47
47
|
import '../../../context/LoadingContext/LoadingContext.js';
|
|
48
48
|
import { useWalletContext } from '../../../context/WalletContext/WalletContext.js';
|
|
49
49
|
import { useSecureEnclaveEmbeddedWallet } from './useSecureEnclaveEmbeddedWallet/useSecureEnclaveEmbeddedWallet.js';
|
|
@@ -51,6 +51,7 @@ require('react-dom');
|
|
|
51
51
|
var useElementById = require('../../useElementById/useElementById.cjs');
|
|
52
52
|
require('../../../functions/compareChains/compareChains.cjs');
|
|
53
53
|
var findPrimaryEmbeddedChain = require('../../../../views/Passkey/utils/findPrimaryEmbeddedChain/findPrimaryEmbeddedChain.cjs');
|
|
54
|
+
var getPrimaryTurnkeyWalletId = require('../../../functions/getPrimaryTurnkeyWalletId/getPrimaryTurnkeyWalletId.cjs');
|
|
54
55
|
require('../../../../context/ThemeContext/ThemeContext.cjs');
|
|
55
56
|
var useSmartWallets = require('../../useSmartWallets/useSmartWallets.cjs');
|
|
56
57
|
require('../../useUserUpdateRequest/useUpdateUser/userFieldsSchema.cjs');
|
|
@@ -283,7 +284,11 @@ const useSecureEnclaveEmbeddedWallet = () => {
|
|
|
283
284
|
if (!userHasEmbeddedWallet() || !hasRecoveryEmail) {
|
|
284
285
|
throw new utils.DynamicError('User does not have a secure enclave wallet or a verified email', errors.INVALID_WALLET_DATA);
|
|
285
286
|
}
|
|
286
|
-
|
|
287
|
+
if (!primaryWallet) {
|
|
288
|
+
throw new utils.DynamicError('No primary wallet found');
|
|
289
|
+
}
|
|
290
|
+
const primaryTurnkeyWalletId = getPrimaryTurnkeyWalletId.getPrimaryTurnkeyWalletId(primaryWallet.id, (user$1 === null || user$1 === void 0 ? void 0 : user$1.verifiedCredentials) || []);
|
|
291
|
+
const organizationId = (_r = (_q = (_p = user$1 === null || user$1 === void 0 ? void 0 : user$1.verifiedCredentials) === null || _p === void 0 ? void 0 : _p.find(({ walletName, id }) => (walletName === null || walletName === void 0 ? void 0 : walletName.startsWith('turnkey')) && id === primaryTurnkeyWalletId)) === null || _q === void 0 ? void 0 : _q.walletProperties) === null || _r === void 0 ? void 0 : _r.turnkeySubOrganizationId;
|
|
287
292
|
yield turnkeyRecoveryHandler.verifyRecoveryCode(options.oneTimeCode, organizationId);
|
|
288
293
|
const sessionSettings = {
|
|
289
294
|
createdAt: new Date().getTime(),
|
|
@@ -47,6 +47,7 @@ import 'react-dom';
|
|
|
47
47
|
import { useElementById } from '../../useElementById/useElementById.js';
|
|
48
48
|
import '../../../functions/compareChains/compareChains.js';
|
|
49
49
|
import { findPrimaryEmbeddedChain } from '../../../../views/Passkey/utils/findPrimaryEmbeddedChain/findPrimaryEmbeddedChain.js';
|
|
50
|
+
import { getPrimaryTurnkeyWalletId } from '../../../functions/getPrimaryTurnkeyWalletId/getPrimaryTurnkeyWalletId.js';
|
|
50
51
|
import '../../../../context/ThemeContext/ThemeContext.js';
|
|
51
52
|
import { useSmartWallets } from '../../useSmartWallets/useSmartWallets.js';
|
|
52
53
|
import '../../useUserUpdateRequest/useUpdateUser/userFieldsSchema.js';
|
|
@@ -279,7 +280,11 @@ const useSecureEnclaveEmbeddedWallet = () => {
|
|
|
279
280
|
if (!userHasEmbeddedWallet() || !hasRecoveryEmail) {
|
|
280
281
|
throw new DynamicError('User does not have a secure enclave wallet or a verified email', INVALID_WALLET_DATA);
|
|
281
282
|
}
|
|
282
|
-
|
|
283
|
+
if (!primaryWallet) {
|
|
284
|
+
throw new DynamicError('No primary wallet found');
|
|
285
|
+
}
|
|
286
|
+
const primaryTurnkeyWalletId = getPrimaryTurnkeyWalletId(primaryWallet.id, (user === null || user === void 0 ? void 0 : user.verifiedCredentials) || []);
|
|
287
|
+
const organizationId = (_r = (_q = (_p = user === null || user === void 0 ? void 0 : user.verifiedCredentials) === null || _p === void 0 ? void 0 : _p.find(({ walletName, id }) => (walletName === null || walletName === void 0 ? void 0 : walletName.startsWith('turnkey')) && id === primaryTurnkeyWalletId)) === null || _q === void 0 ? void 0 : _q.walletProperties) === null || _r === void 0 ? void 0 : _r.turnkeySubOrganizationId;
|
|
283
288
|
yield turnkeyRecoveryHandler.verifyRecoveryCode(options.oneTimeCode, organizationId);
|
|
284
289
|
const sessionSettings = {
|
|
285
290
|
createdAt: new Date().getTime(),
|
|
@@ -24,11 +24,12 @@ require('@dynamic-labs/wallet-book');
|
|
|
24
24
|
require('../../../shared/consts/index.cjs');
|
|
25
25
|
require('../../../store/state/nonce/nonce.cjs');
|
|
26
26
|
require('../../../store/state/dynamicContextProps/dynamicContextProps.cjs');
|
|
27
|
-
require('../../../store/state/primaryWalletId/primaryWalletId.cjs');
|
|
27
|
+
var primaryWalletId = require('../../../store/state/primaryWalletId/primaryWalletId.cjs');
|
|
28
28
|
var user = require('../../../store/state/user/user.cjs');
|
|
29
29
|
var embeddedWallets = require('../../../data/api/embeddedWallets/embeddedWallets.cjs');
|
|
30
30
|
require('../../../locale/locale.cjs');
|
|
31
31
|
var dynamicEvents = require('../../../events/dynamicEvents.cjs');
|
|
32
|
+
var getPrimaryTurnkeyWalletId = require('../../functions/getPrimaryTurnkeyWalletId/getPrimaryTurnkeyWalletId.cjs');
|
|
32
33
|
|
|
33
34
|
const useEmbeddedWalletSessionKeys = ({ environmentId, projectSettings, }) => {
|
|
34
35
|
const { user: user$1 } = user.useUser();
|
|
@@ -74,11 +75,17 @@ const useEmbeddedWalletSessionKeys = ({ environmentId, projectSettings, }) => {
|
|
|
74
75
|
prevSessionKeySignature = yield utils$1.p256Sign(decodedSessionKeys.privateKeyJwk, user$1.sessionId);
|
|
75
76
|
}
|
|
76
77
|
let resp;
|
|
78
|
+
const primaryWalletId$1 = primaryWalletId.getPrimaryWalletId();
|
|
79
|
+
if (!primaryWalletId$1) {
|
|
80
|
+
throw new Error('Primary wallet ID not found');
|
|
81
|
+
}
|
|
82
|
+
const turnkeyWalletId = getPrimaryTurnkeyWalletId.getPrimaryTurnkeyWalletId(primaryWalletId$1, user$1.verifiedCredentials);
|
|
77
83
|
try {
|
|
78
84
|
resp = yield embeddedWallets.registerSessionKey({
|
|
79
85
|
environmentId,
|
|
80
86
|
prevSessionKeySignature,
|
|
81
87
|
publicKey,
|
|
88
|
+
walletId: turnkeyWalletId,
|
|
82
89
|
});
|
|
83
90
|
}
|
|
84
91
|
catch (error) {
|
|
@@ -20,11 +20,12 @@ import '@dynamic-labs/wallet-book';
|
|
|
20
20
|
import '../../../shared/consts/index.js';
|
|
21
21
|
import '../../../store/state/nonce/nonce.js';
|
|
22
22
|
import '../../../store/state/dynamicContextProps/dynamicContextProps.js';
|
|
23
|
-
import '../../../store/state/primaryWalletId/primaryWalletId.js';
|
|
23
|
+
import { getPrimaryWalletId } from '../../../store/state/primaryWalletId/primaryWalletId.js';
|
|
24
24
|
import { useUser } from '../../../store/state/user/user.js';
|
|
25
25
|
import { registerSessionKey } from '../../../data/api/embeddedWallets/embeddedWallets.js';
|
|
26
26
|
import '../../../locale/locale.js';
|
|
27
27
|
import { dynamicEvents } from '../../../events/dynamicEvents.js';
|
|
28
|
+
import { getPrimaryTurnkeyWalletId } from '../../functions/getPrimaryTurnkeyWalletId/getPrimaryTurnkeyWalletId.js';
|
|
28
29
|
|
|
29
30
|
const useEmbeddedWalletSessionKeys = ({ environmentId, projectSettings, }) => {
|
|
30
31
|
const { user } = useUser();
|
|
@@ -70,11 +71,17 @@ const useEmbeddedWalletSessionKeys = ({ environmentId, projectSettings, }) => {
|
|
|
70
71
|
prevSessionKeySignature = yield p256Sign(decodedSessionKeys.privateKeyJwk, user.sessionId);
|
|
71
72
|
}
|
|
72
73
|
let resp;
|
|
74
|
+
const primaryWalletId = getPrimaryWalletId();
|
|
75
|
+
if (!primaryWalletId) {
|
|
76
|
+
throw new Error('Primary wallet ID not found');
|
|
77
|
+
}
|
|
78
|
+
const turnkeyWalletId = getPrimaryTurnkeyWalletId(primaryWalletId, user.verifiedCredentials);
|
|
73
79
|
try {
|
|
74
80
|
resp = yield registerSessionKey({
|
|
75
81
|
environmentId,
|
|
76
82
|
prevSessionKeySignature,
|
|
77
83
|
publicKey,
|
|
84
|
+
walletId: turnkeyWalletId,
|
|
78
85
|
});
|
|
79
86
|
}
|
|
80
87
|
catch (error) {
|
|
@@ -40,12 +40,12 @@ require('../../../store/state/nonce/nonce.cjs');
|
|
|
40
40
|
require('react-dom');
|
|
41
41
|
require('../../functions/compareChains/compareChains.cjs');
|
|
42
42
|
require('../../../views/Passkey/utils/findPrimaryEmbeddedChain/findPrimaryEmbeddedChain.cjs');
|
|
43
|
+
require('../../../store/state/primaryWalletId/primaryWalletId.cjs');
|
|
43
44
|
require('../../../context/ThemeContext/ThemeContext.cjs');
|
|
44
45
|
require('../useUserUpdateRequest/useUpdateUser/userFieldsSchema.cjs');
|
|
45
46
|
require('bs58');
|
|
46
47
|
require('@dynamic-labs/types');
|
|
47
48
|
require('../../../context/SocialRedirectContext/SocialRedirectContext.cjs');
|
|
48
|
-
require('../../../store/state/primaryWalletId/primaryWalletId.cjs');
|
|
49
49
|
require('../../../context/LoadingContext/LoadingContext.cjs');
|
|
50
50
|
require('../../../context/WalletContext/WalletContext.cjs');
|
|
51
51
|
require('../useEmbeddedWallet/useSecureEnclaveEmbeddedWallet/constants.cjs');
|
|
@@ -36,12 +36,12 @@ import '../../../store/state/nonce/nonce.js';
|
|
|
36
36
|
import 'react-dom';
|
|
37
37
|
import '../../functions/compareChains/compareChains.js';
|
|
38
38
|
import '../../../views/Passkey/utils/findPrimaryEmbeddedChain/findPrimaryEmbeddedChain.js';
|
|
39
|
+
import '../../../store/state/primaryWalletId/primaryWalletId.js';
|
|
39
40
|
import '../../../context/ThemeContext/ThemeContext.js';
|
|
40
41
|
import '../useUserUpdateRequest/useUpdateUser/userFieldsSchema.js';
|
|
41
42
|
import 'bs58';
|
|
42
43
|
import '@dynamic-labs/types';
|
|
43
44
|
import '../../../context/SocialRedirectContext/SocialRedirectContext.js';
|
|
44
|
-
import '../../../store/state/primaryWalletId/primaryWalletId.js';
|
|
45
45
|
import '../../../context/LoadingContext/LoadingContext.js';
|
|
46
46
|
import '../../../context/WalletContext/WalletContext.js';
|
|
47
47
|
import '../useEmbeddedWallet/useSecureEnclaveEmbeddedWallet/constants.js';
|
|
@@ -44,6 +44,7 @@ require('../../context/VerificationContext/VerificationContext.cjs');
|
|
|
44
44
|
require('react-dom');
|
|
45
45
|
require('../../utils/functions/compareChains/compareChains.cjs');
|
|
46
46
|
require('../Passkey/utils/findPrimaryEmbeddedChain/findPrimaryEmbeddedChain.cjs');
|
|
47
|
+
var getPrimaryTurnkeyWalletId = require('../../utils/functions/getPrimaryTurnkeyWalletId/getPrimaryTurnkeyWalletId.cjs');
|
|
47
48
|
require('../../context/ThemeContext/ThemeContext.cjs');
|
|
48
49
|
var useSmartWallets = require('../../utils/hooks/useSmartWallets/useSmartWallets.cjs');
|
|
49
50
|
require('../../utils/hooks/useUserUpdateRequest/useUpdateUser/userFieldsSchema.cjs');
|
|
@@ -131,8 +132,10 @@ const EmbeddedDeleteView = () => {
|
|
|
131
132
|
}
|
|
132
133
|
setIsLoading(true);
|
|
133
134
|
try {
|
|
135
|
+
const primaryTurnkeyWalletId = getPrimaryTurnkeyWalletId.getPrimaryTurnkeyWalletId(primaryWallet.id, (user === null || user === void 0 ? void 0 : user.verifiedCredentials) || []);
|
|
134
136
|
const deleteEmbeddedWalletsRawPayload = yield embeddedWallets.getDeleteEmbeddedWalletsRequest({
|
|
135
137
|
environmentId,
|
|
138
|
+
walletId: primaryTurnkeyWalletId,
|
|
136
139
|
});
|
|
137
140
|
const connector = isSmartWallet(primaryWallet)
|
|
138
141
|
? (_a = getEOAWallet(primaryWallet)) === null || _a === void 0 ? void 0 : _a.connector
|
|
@@ -40,6 +40,7 @@ import '../../context/VerificationContext/VerificationContext.js';
|
|
|
40
40
|
import 'react-dom';
|
|
41
41
|
import '../../utils/functions/compareChains/compareChains.js';
|
|
42
42
|
import '../Passkey/utils/findPrimaryEmbeddedChain/findPrimaryEmbeddedChain.js';
|
|
43
|
+
import { getPrimaryTurnkeyWalletId } from '../../utils/functions/getPrimaryTurnkeyWalletId/getPrimaryTurnkeyWalletId.js';
|
|
43
44
|
import '../../context/ThemeContext/ThemeContext.js';
|
|
44
45
|
import { useSmartWallets } from '../../utils/hooks/useSmartWallets/useSmartWallets.js';
|
|
45
46
|
import '../../utils/hooks/useUserUpdateRequest/useUpdateUser/userFieldsSchema.js';
|
|
@@ -127,8 +128,10 @@ const EmbeddedDeleteView = () => {
|
|
|
127
128
|
}
|
|
128
129
|
setIsLoading(true);
|
|
129
130
|
try {
|
|
131
|
+
const primaryTurnkeyWalletId = getPrimaryTurnkeyWalletId(primaryWallet.id, (user === null || user === void 0 ? void 0 : user.verifiedCredentials) || []);
|
|
130
132
|
const deleteEmbeddedWalletsRawPayload = yield getDeleteEmbeddedWalletsRequest({
|
|
131
133
|
environmentId,
|
|
134
|
+
walletId: primaryTurnkeyWalletId,
|
|
132
135
|
});
|
|
133
136
|
const connector = isSmartWallet(primaryWallet)
|
|
134
137
|
? (_a = getEOAWallet(primaryWallet)) === null || _a === void 0 ? void 0 : _a.connector
|
|
@@ -34,6 +34,7 @@ require('../../../shared/consts/index.cjs');
|
|
|
34
34
|
var dynamicEvents = require('../../../events/dynamicEvents.cjs');
|
|
35
35
|
require('../../../context/CaptchaContext/CaptchaContext.cjs');
|
|
36
36
|
require('../../../context/ErrorContext/ErrorContext.cjs');
|
|
37
|
+
var errors = require('../../../utils/constants/errors.cjs');
|
|
37
38
|
require('@dynamic-labs/multi-wallet');
|
|
38
39
|
require('react-international-phone');
|
|
39
40
|
require('../../../store/state/nonce/nonce.cjs');
|
|
@@ -51,6 +52,7 @@ require('../../../context/VerificationContext/VerificationContext.cjs');
|
|
|
51
52
|
require('react-dom');
|
|
52
53
|
require('../../../utils/functions/compareChains/compareChains.cjs');
|
|
53
54
|
require('../../Passkey/utils/findPrimaryEmbeddedChain/findPrimaryEmbeddedChain.cjs');
|
|
55
|
+
var getPrimaryTurnkeyWalletId = require('../../../utils/functions/getPrimaryTurnkeyWalletId/getPrimaryTurnkeyWalletId.cjs');
|
|
54
56
|
require('../../../context/ThemeContext/ThemeContext.cjs');
|
|
55
57
|
var useSmartWallets = require('../../../utils/hooks/useSmartWallets/useSmartWallets.cjs');
|
|
56
58
|
require('../../../utils/hooks/useUserUpdateRequest/useUpdateUser/userFieldsSchema.cjs');
|
|
@@ -125,7 +127,11 @@ const EmbeddedRevealView = ({ exportPrivateKey, isPromptForExport = false, }) =>
|
|
|
125
127
|
const { getEOAWallet, isSmartWallet } = useSmartWallets.useSmartWallets();
|
|
126
128
|
const [acknowledgement1, setAcknowledgement1] = React.useState(false);
|
|
127
129
|
const iframeContainerRef = React.useRef(null);
|
|
128
|
-
|
|
130
|
+
if (!primaryWallet) {
|
|
131
|
+
throw new utils.DynamicError('No primary wallet found', errors.INVALID_WALLET_DATA);
|
|
132
|
+
}
|
|
133
|
+
const primaryTurnkeyWalletId = getPrimaryTurnkeyWalletId.getPrimaryTurnkeyWalletId(primaryWallet.id, (user === null || user === void 0 ? void 0 : user.verifiedCredentials) || []);
|
|
134
|
+
const walletProperties = (_b = (_a = user === null || user === void 0 ? void 0 : user.verifiedCredentials) === null || _a === void 0 ? void 0 : _a.find(({ walletName, id }) => (walletName === null || walletName === void 0 ? void 0 : walletName.startsWith('turnkey')) && id === primaryTurnkeyWalletId)) === null || _b === void 0 ? void 0 : _b.walletProperties;
|
|
129
135
|
const isTurnkeyHDWallet = walletProperties === null || walletProperties === void 0 ? void 0 : walletProperties.turnkeyHDWalletId;
|
|
130
136
|
const wallet = (_c = (primaryWallet && getEOAWallet(primaryWallet))) !== null && _c !== void 0 ? _c : primaryWallet;
|
|
131
137
|
// eslint-disable-next-line arrow-body-style
|
|
@@ -30,6 +30,7 @@ import '../../../shared/consts/index.js';
|
|
|
30
30
|
import { dynamicEvents } from '../../../events/dynamicEvents.js';
|
|
31
31
|
import '../../../context/CaptchaContext/CaptchaContext.js';
|
|
32
32
|
import '../../../context/ErrorContext/ErrorContext.js';
|
|
33
|
+
import { INVALID_WALLET_DATA } from '../../../utils/constants/errors.js';
|
|
33
34
|
import '@dynamic-labs/multi-wallet';
|
|
34
35
|
import 'react-international-phone';
|
|
35
36
|
import '../../../store/state/nonce/nonce.js';
|
|
@@ -47,6 +48,7 @@ import '../../../context/VerificationContext/VerificationContext.js';
|
|
|
47
48
|
import 'react-dom';
|
|
48
49
|
import '../../../utils/functions/compareChains/compareChains.js';
|
|
49
50
|
import '../../Passkey/utils/findPrimaryEmbeddedChain/findPrimaryEmbeddedChain.js';
|
|
51
|
+
import { getPrimaryTurnkeyWalletId } from '../../../utils/functions/getPrimaryTurnkeyWalletId/getPrimaryTurnkeyWalletId.js';
|
|
50
52
|
import '../../../context/ThemeContext/ThemeContext.js';
|
|
51
53
|
import { useSmartWallets } from '../../../utils/hooks/useSmartWallets/useSmartWallets.js';
|
|
52
54
|
import '../../../utils/hooks/useUserUpdateRequest/useUpdateUser/userFieldsSchema.js';
|
|
@@ -121,7 +123,11 @@ const EmbeddedRevealView = ({ exportPrivateKey, isPromptForExport = false, }) =>
|
|
|
121
123
|
const { getEOAWallet, isSmartWallet } = useSmartWallets();
|
|
122
124
|
const [acknowledgement1, setAcknowledgement1] = useState(false);
|
|
123
125
|
const iframeContainerRef = useRef(null);
|
|
124
|
-
|
|
126
|
+
if (!primaryWallet) {
|
|
127
|
+
throw new DynamicError('No primary wallet found', INVALID_WALLET_DATA);
|
|
128
|
+
}
|
|
129
|
+
const primaryTurnkeyWalletId = getPrimaryTurnkeyWalletId(primaryWallet.id, (user === null || user === void 0 ? void 0 : user.verifiedCredentials) || []);
|
|
130
|
+
const walletProperties = (_b = (_a = user === null || user === void 0 ? void 0 : user.verifiedCredentials) === null || _a === void 0 ? void 0 : _a.find(({ walletName, id }) => (walletName === null || walletName === void 0 ? void 0 : walletName.startsWith('turnkey')) && id === primaryTurnkeyWalletId)) === null || _b === void 0 ? void 0 : _b.walletProperties;
|
|
125
131
|
const isTurnkeyHDWallet = walletProperties === null || walletProperties === void 0 ? void 0 : walletProperties.turnkeyHDWalletId;
|
|
126
132
|
const wallet = (_c = (primaryWallet && getEOAWallet(primaryWallet))) !== null && _c !== void 0 ? _c : primaryWallet;
|
|
127
133
|
// eslint-disable-next-line arrow-body-style
|
|
@@ -54,7 +54,7 @@ const handleExportInitCheck = ({ user, wallet, }) => {
|
|
|
54
54
|
}
|
|
55
55
|
const connector = wallet.connector;
|
|
56
56
|
connector.setEmail(user.email);
|
|
57
|
-
const walletProperties = (_b = (_a = user.verifiedCredentials) === null || _a === void 0 ? void 0 : _a.find(({ walletName }) => walletName === null || walletName === void 0 ? void 0 : walletName.startsWith('turnkey'))) === null || _b === void 0 ? void 0 : _b.walletProperties;
|
|
57
|
+
const walletProperties = (_b = (_a = user.verifiedCredentials) === null || _a === void 0 ? void 0 : _a.find(({ walletName, id }) => (walletName === null || walletName === void 0 ? void 0 : walletName.startsWith('turnkey')) && id === wallet.id)) === null || _b === void 0 ? void 0 : _b.walletProperties;
|
|
58
58
|
const turnkeyHDWalletId = walletProperties === null || walletProperties === void 0 ? void 0 : walletProperties.turnkeyHDWalletId;
|
|
59
59
|
const privateKeyId = walletProperties === null || walletProperties === void 0 ? void 0 : walletProperties.turnkeyPrivateKeyId;
|
|
60
60
|
const organizationId = walletProperties === null || walletProperties === void 0 ? void 0 : walletProperties.turnkeySubOrganizationId;
|
|
@@ -50,7 +50,7 @@ const handleExportInitCheck = ({ user, wallet, }) => {
|
|
|
50
50
|
}
|
|
51
51
|
const connector = wallet.connector;
|
|
52
52
|
connector.setEmail(user.email);
|
|
53
|
-
const walletProperties = (_b = (_a = user.verifiedCredentials) === null || _a === void 0 ? void 0 : _a.find(({ walletName }) => walletName === null || walletName === void 0 ? void 0 : walletName.startsWith('turnkey'))) === null || _b === void 0 ? void 0 : _b.walletProperties;
|
|
53
|
+
const walletProperties = (_b = (_a = user.verifiedCredentials) === null || _a === void 0 ? void 0 : _a.find(({ walletName, id }) => (walletName === null || walletName === void 0 ? void 0 : walletName.startsWith('turnkey')) && id === wallet.id)) === null || _b === void 0 ? void 0 : _b.walletProperties;
|
|
54
54
|
const turnkeyHDWalletId = walletProperties === null || walletProperties === void 0 ? void 0 : walletProperties.turnkeyHDWalletId;
|
|
55
55
|
const privateKeyId = walletProperties === null || walletProperties === void 0 ? void 0 : walletProperties.turnkeyPrivateKeyId;
|
|
56
56
|
const organizationId = walletProperties === null || walletProperties === void 0 ? void 0 : walletProperties.turnkeySubOrganizationId;
|
|
@@ -81,7 +81,7 @@ const passkeyRecoveryBundleValidation = (_c) => _tslib.__awaiter(void 0, [_c], v
|
|
|
81
81
|
if (!user) {
|
|
82
82
|
throw new utils.DynamicError(errors.USER_NOT_LOGGED_IN);
|
|
83
83
|
}
|
|
84
|
-
const organizationId = (_f = (_e = (_d = user.verifiedCredentials) === null || _d === void 0 ? void 0 : _d.find(({ walletName }) => walletName === null || walletName === void 0 ? void 0 : walletName.startsWith('turnkey'))) === null || _e === void 0 ? void 0 : _e.walletProperties) === null || _f === void 0 ? void 0 : _f.turnkeySubOrganizationId;
|
|
84
|
+
const organizationId = (_f = (_e = (_d = user.verifiedCredentials) === null || _d === void 0 ? void 0 : _d.find(({ walletName, id }) => (walletName === null || walletName === void 0 ? void 0 : walletName.startsWith('turnkey')) && id === wallet.id)) === null || _e === void 0 ? void 0 : _e.walletProperties) === null || _f === void 0 ? void 0 : _f.turnkeySubOrganizationId;
|
|
85
85
|
const turnkeyRecoveryHandler = (_g = wallet.connector) === null || _g === void 0 ? void 0 : _g.getAuthenticatorHandler();
|
|
86
86
|
yield turnkeyRecoveryHandler.verifyRecoveryCode(bundleInput, organizationId);
|
|
87
87
|
const sessionSettings = {
|
|
@@ -147,7 +147,7 @@ const recoverTurnkeyWallet = (_m) => _tslib.__awaiter(void 0, [_m], void 0, func
|
|
|
147
147
|
}
|
|
148
148
|
const connector = wallet.connector;
|
|
149
149
|
connector.setEmail(user.email);
|
|
150
|
-
const turnkeySubOrganizationId = (_q = (_p = (_o = user.verifiedCredentials) === null || _o === void 0 ? void 0 : _o.find(({ walletName }) => walletName === null || walletName === void 0 ? void 0 : walletName.startsWith('turnkey'))) === null || _p === void 0 ? void 0 : _p.walletProperties) === null || _q === void 0 ? void 0 : _q.turnkeySubOrganizationId;
|
|
150
|
+
const turnkeySubOrganizationId = (_q = (_p = (_o = user.verifiedCredentials) === null || _o === void 0 ? void 0 : _o.find(({ walletName, id }) => (walletName === null || walletName === void 0 ? void 0 : walletName.startsWith('turnkey')) && id === wallet.id)) === null || _p === void 0 ? void 0 : _p.walletProperties) === null || _q === void 0 ? void 0 : _q.turnkeySubOrganizationId;
|
|
151
151
|
if (!turnkeySubOrganizationId) {
|
|
152
152
|
throw new utils.DynamicError('The authentication token is invalid - turnkeySubOrganizationId is missing');
|
|
153
153
|
}
|
|
@@ -225,7 +225,7 @@ const restoreEmbeddedWalletSession = (_r) => _tslib.__awaiter(void 0, [_r], void
|
|
|
225
225
|
throw new utils.DynamicError('Could not open embedded wallet connection communication');
|
|
226
226
|
}
|
|
227
227
|
turnkeyRecoveryHandler.recoveryUserId = sessionSettings.userId;
|
|
228
|
-
const organizationId = (_v = (_u = (_t = user.verifiedCredentials) === null || _t === void 0 ? void 0 : _t.find(({ walletName }) => walletName === null || walletName === void 0 ? void 0 : walletName.startsWith('turnkey'))) === null || _u === void 0 ? void 0 : _u.walletProperties) === null || _v === void 0 ? void 0 : _v.turnkeySubOrganizationId;
|
|
228
|
+
const organizationId = (_v = (_u = (_t = user.verifiedCredentials) === null || _t === void 0 ? void 0 : _t.find(({ walletName, id }) => (walletName === null || walletName === void 0 ? void 0 : walletName.startsWith('turnkey')) && id === wallet.id)) === null || _u === void 0 ? void 0 : _u.walletProperties) === null || _v === void 0 ? void 0 : _v.turnkeySubOrganizationId;
|
|
229
229
|
yield turnkeyRecoveryHandler.verifyRecoveryCode(sessionSettings.emailCode, organizationId);
|
|
230
230
|
return true;
|
|
231
231
|
});
|
|
@@ -240,7 +240,7 @@ const addEmailRecovery = (_w) => _tslib.__awaiter(void 0, [_w], void 0, function
|
|
|
240
240
|
!walletConnectorCore.isEmailWalletConnector(wallet === null || wallet === void 0 ? void 0 : wallet.connector)) {
|
|
241
241
|
throw new utils.DynamicError('Connector is missing. Please make sure you added EthereumWalletConnectors and/or SolanaWalletConnectors to DynamicProvider settings');
|
|
242
242
|
}
|
|
243
|
-
const { turnkeySubOrganizationId, turnkeyUserId } = (_y = (_x = user$1.verifiedCredentials) === null || _x === void 0 ? void 0 : _x.find(({ walletName }) => walletName === null || walletName === void 0 ? void 0 : walletName.startsWith('turnkey'))) === null || _y === void 0 ? void 0 : _y.walletProperties;
|
|
243
|
+
const { turnkeySubOrganizationId, turnkeyUserId } = (_y = (_x = user$1.verifiedCredentials) === null || _x === void 0 ? void 0 : _x.find(({ walletName, id }) => (walletName === null || walletName === void 0 ? void 0 : walletName.startsWith('turnkey')) && id === wallet.id)) === null || _y === void 0 ? void 0 : _y.walletProperties;
|
|
244
244
|
if (!turnkeySubOrganizationId || !turnkeyUserId) {
|
|
245
245
|
throw new utils.DynamicError('The authentication token is invalid - turnkeySubOrganizationId or turnkeyUserID is missing');
|
|
246
246
|
}
|
|
@@ -77,7 +77,7 @@ const passkeyRecoveryBundleValidation = (_c) => __awaiter(void 0, [_c], void 0,
|
|
|
77
77
|
if (!user) {
|
|
78
78
|
throw new DynamicError(USER_NOT_LOGGED_IN);
|
|
79
79
|
}
|
|
80
|
-
const organizationId = (_f = (_e = (_d = user.verifiedCredentials) === null || _d === void 0 ? void 0 : _d.find(({ walletName }) => walletName === null || walletName === void 0 ? void 0 : walletName.startsWith('turnkey'))) === null || _e === void 0 ? void 0 : _e.walletProperties) === null || _f === void 0 ? void 0 : _f.turnkeySubOrganizationId;
|
|
80
|
+
const organizationId = (_f = (_e = (_d = user.verifiedCredentials) === null || _d === void 0 ? void 0 : _d.find(({ walletName, id }) => (walletName === null || walletName === void 0 ? void 0 : walletName.startsWith('turnkey')) && id === wallet.id)) === null || _e === void 0 ? void 0 : _e.walletProperties) === null || _f === void 0 ? void 0 : _f.turnkeySubOrganizationId;
|
|
81
81
|
const turnkeyRecoveryHandler = (_g = wallet.connector) === null || _g === void 0 ? void 0 : _g.getAuthenticatorHandler();
|
|
82
82
|
yield turnkeyRecoveryHandler.verifyRecoveryCode(bundleInput, organizationId);
|
|
83
83
|
const sessionSettings = {
|
|
@@ -143,7 +143,7 @@ const recoverTurnkeyWallet = (_m) => __awaiter(void 0, [_m], void 0, function* (
|
|
|
143
143
|
}
|
|
144
144
|
const connector = wallet.connector;
|
|
145
145
|
connector.setEmail(user.email);
|
|
146
|
-
const turnkeySubOrganizationId = (_q = (_p = (_o = user.verifiedCredentials) === null || _o === void 0 ? void 0 : _o.find(({ walletName }) => walletName === null || walletName === void 0 ? void 0 : walletName.startsWith('turnkey'))) === null || _p === void 0 ? void 0 : _p.walletProperties) === null || _q === void 0 ? void 0 : _q.turnkeySubOrganizationId;
|
|
146
|
+
const turnkeySubOrganizationId = (_q = (_p = (_o = user.verifiedCredentials) === null || _o === void 0 ? void 0 : _o.find(({ walletName, id }) => (walletName === null || walletName === void 0 ? void 0 : walletName.startsWith('turnkey')) && id === wallet.id)) === null || _p === void 0 ? void 0 : _p.walletProperties) === null || _q === void 0 ? void 0 : _q.turnkeySubOrganizationId;
|
|
147
147
|
if (!turnkeySubOrganizationId) {
|
|
148
148
|
throw new DynamicError('The authentication token is invalid - turnkeySubOrganizationId is missing');
|
|
149
149
|
}
|
|
@@ -221,7 +221,7 @@ const restoreEmbeddedWalletSession = (_r) => __awaiter(void 0, [_r], void 0, fun
|
|
|
221
221
|
throw new DynamicError('Could not open embedded wallet connection communication');
|
|
222
222
|
}
|
|
223
223
|
turnkeyRecoveryHandler.recoveryUserId = sessionSettings.userId;
|
|
224
|
-
const organizationId = (_v = (_u = (_t = user.verifiedCredentials) === null || _t === void 0 ? void 0 : _t.find(({ walletName }) => walletName === null || walletName === void 0 ? void 0 : walletName.startsWith('turnkey'))) === null || _u === void 0 ? void 0 : _u.walletProperties) === null || _v === void 0 ? void 0 : _v.turnkeySubOrganizationId;
|
|
224
|
+
const organizationId = (_v = (_u = (_t = user.verifiedCredentials) === null || _t === void 0 ? void 0 : _t.find(({ walletName, id }) => (walletName === null || walletName === void 0 ? void 0 : walletName.startsWith('turnkey')) && id === wallet.id)) === null || _u === void 0 ? void 0 : _u.walletProperties) === null || _v === void 0 ? void 0 : _v.turnkeySubOrganizationId;
|
|
225
225
|
yield turnkeyRecoveryHandler.verifyRecoveryCode(sessionSettings.emailCode, organizationId);
|
|
226
226
|
return true;
|
|
227
227
|
});
|
|
@@ -236,7 +236,7 @@ const addEmailRecovery = (_w) => __awaiter(void 0, [_w], void 0, function* ({ us
|
|
|
236
236
|
!isEmailWalletConnector(wallet === null || wallet === void 0 ? void 0 : wallet.connector)) {
|
|
237
237
|
throw new DynamicError('Connector is missing. Please make sure you added EthereumWalletConnectors and/or SolanaWalletConnectors to DynamicProvider settings');
|
|
238
238
|
}
|
|
239
|
-
const { turnkeySubOrganizationId, turnkeyUserId } = (_y = (_x = user.verifiedCredentials) === null || _x === void 0 ? void 0 : _x.find(({ walletName }) => walletName === null || walletName === void 0 ? void 0 : walletName.startsWith('turnkey'))) === null || _y === void 0 ? void 0 : _y.walletProperties;
|
|
239
|
+
const { turnkeySubOrganizationId, turnkeyUserId } = (_y = (_x = user.verifiedCredentials) === null || _x === void 0 ? void 0 : _x.find(({ walletName, id }) => (walletName === null || walletName === void 0 ? void 0 : walletName.startsWith('turnkey')) && id === wallet.id)) === null || _y === void 0 ? void 0 : _y.walletProperties;
|
|
240
240
|
if (!turnkeySubOrganizationId || !turnkeyUserId) {
|
|
241
241
|
throw new DynamicError('The authentication token is invalid - turnkeySubOrganizationId or turnkeyUserID is missing');
|
|
242
242
|
}
|
|
@@ -120,6 +120,7 @@ var SimulationStatus;
|
|
|
120
120
|
const TransactionConfirmationView = ({ transaction, onError, onSuccess, mutation, onClickBack, walletConnector, onClickClose, title, displayPoweredByDynamicFooter = false, copykey, hideModal, currentToken, isNativeToken, transactionValue, isModal, sendBalanceTransaction, }) => {
|
|
121
121
|
const { primaryWallet, environmentId } = useInternalDynamicContext.useInternalDynamicContext();
|
|
122
122
|
const [isGasSponsored, setIsGasSponsored] = React.useState(false);
|
|
123
|
+
const [isGasSponsoredLoading, setIsGasSponsoredLoading] = React.useState(false);
|
|
123
124
|
const update = useForceUpdate.useForceUpdate();
|
|
124
125
|
const { t } = reactI18next.useTranslation();
|
|
125
126
|
const { currency } = useFetchCurrency.useFetchCurrency(walletConnector);
|
|
@@ -135,13 +136,20 @@ const TransactionConfirmationView = ({ transaction, onError, onSuccess, mutation
|
|
|
135
136
|
status: SimulationStatus.LOADING,
|
|
136
137
|
});
|
|
137
138
|
const [recipient, setRecipient] = React.useState(undefined);
|
|
139
|
+
const isFetchingSimulationRef = React.useRef(false);
|
|
138
140
|
const fetchSimulationResult = React.useCallback(() => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
139
141
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
140
142
|
if (simulationState.status !== SimulationStatus.LOADING) {
|
|
141
143
|
return;
|
|
142
144
|
}
|
|
145
|
+
if (isFetchingSimulationRef.current) {
|
|
146
|
+
// Already fetching, prevent duplicate call
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
149
|
+
isFetchingSimulationRef.current = true;
|
|
143
150
|
if (sendBalanceTransaction || hideModal) {
|
|
144
151
|
setSimulationState({ status: SimulationStatus.SKIPPED });
|
|
152
|
+
isFetchingSimulationRef.current = false;
|
|
145
153
|
return;
|
|
146
154
|
}
|
|
147
155
|
if (!primaryWallet || (!chainId && (primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.chain) !== 'SOL')) {
|
|
@@ -151,13 +159,16 @@ const TransactionConfirmationView = ({ transaction, onError, onSuccess, mutation
|
|
|
151
159
|
primaryWallet,
|
|
152
160
|
});
|
|
153
161
|
setSimulationState({ status: SimulationStatus.FAILED });
|
|
162
|
+
isFetchingSimulationRef.current = false;
|
|
154
163
|
return;
|
|
155
164
|
}
|
|
156
165
|
try {
|
|
157
166
|
let result;
|
|
158
167
|
if (primaryWallet.connector.key === 'zerodev') {
|
|
159
168
|
const connector = primaryWallet.connector;
|
|
160
|
-
const { userOperation } = yield connector.getCurrentUserOperation(transaction);
|
|
169
|
+
const { userOperation, sponsored } = yield connector.getCurrentUserOperation(transaction);
|
|
170
|
+
setIsGasSponsored(sponsored);
|
|
171
|
+
setIsGasSponsoredLoading(false);
|
|
161
172
|
if (userOperation) {
|
|
162
173
|
const formattedUserOperation = yield connector.formatUserOperation(userOperation);
|
|
163
174
|
// Set the gas fee on the transaction, only for zero dev
|
|
@@ -224,6 +235,9 @@ const TransactionConfirmationView = ({ transaction, onError, onSuccess, mutation
|
|
|
224
235
|
logger.logger.error('[TransactionConfirmationView] Simulation failed:', error);
|
|
225
236
|
setSimulationState({ status: SimulationStatus.FAILED });
|
|
226
237
|
}
|
|
238
|
+
finally {
|
|
239
|
+
isFetchingSimulationRef.current = false;
|
|
240
|
+
}
|
|
227
241
|
}), [
|
|
228
242
|
sendBalanceTransaction,
|
|
229
243
|
hideModal,
|
|
@@ -232,6 +246,8 @@ const TransactionConfirmationView = ({ transaction, onError, onSuccess, mutation
|
|
|
232
246
|
environmentId,
|
|
233
247
|
transaction,
|
|
234
248
|
walletConnector,
|
|
249
|
+
simulationState.status,
|
|
250
|
+
setSimulationState,
|
|
235
251
|
]);
|
|
236
252
|
React.useEffect(() => {
|
|
237
253
|
if (simulationState.status === SimulationStatus.SUCCESS ||
|
|
@@ -253,21 +269,6 @@ const TransactionConfirmationView = ({ transaction, onError, onSuccess, mutation
|
|
|
253
269
|
}
|
|
254
270
|
transaction.fetchFee().finally(update);
|
|
255
271
|
}, [primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.chain, transaction, update]);
|
|
256
|
-
const { isLoading: isGasSponsoredLoading } = usePromise.usePromise(() => {
|
|
257
|
-
if (!walletConnectorCore.isAccountAbstractionConnector(walletConnector)) {
|
|
258
|
-
return false;
|
|
259
|
-
}
|
|
260
|
-
return walletConnector.canSponsorTransactionGas(transaction);
|
|
261
|
-
}, {
|
|
262
|
-
initialData: false,
|
|
263
|
-
onReject: logger.logger.error,
|
|
264
|
-
onResolve: (isGasSponsored) => {
|
|
265
|
-
setIsGasSponsored(isGasSponsored);
|
|
266
|
-
if (!isGasSponsored && walletConnectorCore.isAccountAbstractionConnector(walletConnector)) {
|
|
267
|
-
walletConnector.disableGasSponsorshipOnce();
|
|
268
|
-
}
|
|
269
|
-
},
|
|
270
|
-
});
|
|
271
272
|
React.useEffect(() => {
|
|
272
273
|
var _a;
|
|
273
274
|
// solana gas sponsorship check
|