@dynamic-labs/sdk-react-core 4.10.1 → 4.10.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +23 -0
- package/package.cjs +1 -1
- package/package.js +1 -1
- package/package.json +11 -11
- package/src/api.d.ts +1 -0
- package/src/lib/components/AuthProviderIcon/AuthProviderIcon.cjs +1 -1
- package/src/lib/components/AuthProviderIcon/AuthProviderIcon.js +1 -1
- package/src/lib/components/DynamicSpinner/DynamicSpinner.d.ts +3 -0
- package/src/lib/components/DynamicSpinner/index.d.ts +1 -0
- package/src/lib/components/IconWithSpinner/IconWithSpinner.cjs +2 -5
- package/src/lib/components/IconWithSpinner/IconWithSpinner.d.ts +3 -3
- package/src/lib/components/IconWithSpinner/IconWithSpinner.js +2 -5
- package/src/lib/components/Popper/PopperContext/PopperContext.cjs +2 -2
- package/src/lib/components/Popper/PopperContext/PopperContext.d.ts +2 -1
- package/src/lib/components/Popper/PopperContext/PopperContext.js +2 -2
- package/src/lib/components/QrCodeWrapper/QrCodeWrapper.cjs +7 -7
- package/src/lib/components/QrCodeWrapper/QrCodeWrapper.js +7 -7
- package/src/lib/components/SocialSignIn/SocialSignIn.cjs +1 -1
- package/src/lib/components/SocialSignIn/SocialSignIn.js +1 -1
- package/src/lib/components/TransactionStatusLayout/TransactionStatusLayout.cjs +8 -8
- package/src/lib/components/TransactionStatusLayout/TransactionStatusLayout.js +8 -8
- package/src/lib/components/Typography/Typography.cjs +1 -0
- package/src/lib/components/Typography/Typography.js +1 -0
- package/src/lib/components/Typography/Typography.types.d.ts +1 -1
- package/src/lib/components/index.d.ts +8 -7
- package/src/lib/context/DynamicContext/hooks/useTieCallbacksToEvents/useTieCallbacksToEvents.cjs +4 -0
- package/src/lib/context/DynamicContext/hooks/useTieCallbacksToEvents/useTieCallbacksToEvents.js +4 -0
- package/src/lib/context/DynamicContext/types/SettingsOverrides.d.ts +3 -4
- package/src/lib/context/OnrampContext/OnrampContext.cjs +21 -8
- package/src/lib/context/OnrampContext/OnrampContext.d.ts +6 -2
- package/src/lib/context/OnrampContext/OnrampContext.js +21 -8
- package/src/lib/context/SocialRedirectContext/hooks/useRedirectSocialHandler/useRedirectSocialHandler.cjs +1 -1
- package/src/lib/context/SocialRedirectContext/hooks/useRedirectSocialHandler/useRedirectSocialHandler.js +1 -1
- package/src/lib/data/api/embeddedWallets/embeddedWallets.cjs +62 -23
- package/src/lib/data/api/embeddedWallets/embeddedWallets.js +57 -18
- package/src/lib/data/api/index.d.ts +1 -0
- package/src/lib/data/api/transactions/index.d.ts +1 -0
- package/src/lib/events/dynamicEvents.cjs +1 -0
- package/src/lib/events/dynamicEvents.d.ts +2 -2
- package/src/lib/events/dynamicEvents.js +1 -0
- package/src/lib/events/ui.d.ts +8 -0
- package/src/lib/main.global.cjs +1 -1
- package/src/lib/main.global.js +1 -1
- package/src/lib/modals/SignMessageConfirmationModal/SignMessageConfirmationModal.cjs +8 -8
- package/src/lib/modals/SignMessageConfirmationModal/SignMessageConfirmationModal.js +8 -8
- package/src/lib/shared/assets/index.d.ts +2 -1
- package/src/lib/shared/types/dynamicEventsCallbacks.d.ts +6 -1
- package/src/lib/shared/types/wallets.d.ts +10 -0
- package/src/lib/styles/index.shadow.cjs +1 -1
- package/src/lib/styles/index.shadow.js +1 -1
- package/src/lib/utils/functions/onrampConfigurationToOnrampOption/onrampConfigurationToOnrampOption.cjs +2 -21
- package/src/lib/utils/functions/onrampConfigurationToOnrampOption/onrampConfigurationToOnrampOption.d.ts +2 -4
- package/src/lib/utils/functions/onrampConfigurationToOnrampOption/onrampConfigurationToOnrampOption.js +2 -21
- package/src/lib/utils/hooks/events/useDynamicEvents/useDynamicEvents.d.ts +1 -1
- package/src/lib/utils/hooks/useMfa/useMfa.cjs +1 -1
- package/src/lib/utils/hooks/useMfa/useMfa.js +1 -1
- package/src/lib/utils/hooks/useRefreshUser/useRefreshUser.cjs +23 -82
- package/src/lib/utils/hooks/useRefreshUser/useRefreshUser.js +23 -82
- package/src/lib/utils/hooks/useSocialAccounts/useSocialAccounts.cjs +1 -1
- package/src/lib/utils/hooks/useSocialAccounts/useSocialAccounts.js +1 -1
- package/src/lib/utils/hooks/useSocialAuth/useSocialAuth.cjs +1 -1
- package/src/lib/utils/hooks/useSocialAuth/useSocialAuth.js +1 -1
- package/src/lib/utils/hooks/useSyncEmbeddedWalletFlow/useSyncEmbeddedWalletFlow.cjs +1 -1
- package/src/lib/utils/hooks/useSyncEmbeddedWalletFlow/useSyncEmbeddedWalletFlow.js +1 -1
- package/src/lib/utils/hooks/useSyncOnboardingFlow/useSyncOnboardingFlow.cjs +1 -1
- package/src/lib/utils/hooks/useSyncOnboardingFlow/useSyncOnboardingFlow.js +1 -1
- package/src/lib/utils/hooks/useTelegramLogin/useTelegramLogin.cjs +1 -1
- package/src/lib/utils/hooks/useTelegramLogin/useTelegramLogin.js +1 -1
- package/src/lib/utils/hooks/useVerifyWallet/useVerifyWallet.cjs +1 -1
- package/src/lib/utils/hooks/useVerifyWallet/useVerifyWallet.js +1 -1
- package/src/lib/views/LoginView/sections/EmailSignInSection/LoginEmailForm.cjs +1 -1
- package/src/lib/views/LoginView/sections/EmailSignInSection/LoginEmailForm.js +1 -1
- package/src/lib/views/MfaRecoveryView/MfaRecoveryView.cjs +1 -1
- package/src/lib/views/MfaRecoveryView/MfaRecoveryView.js +1 -1
- package/src/lib/views/Passkey/PasskeyRecovery/AddRecoveryEmail/AddRecoveryEmail.cjs +1 -1
- package/src/lib/views/Passkey/PasskeyRecovery/AddRecoveryEmail/AddRecoveryEmail.js +1 -1
- package/src/lib/views/SmsVerification/useSmsVerification/useSmsVerification.cjs +1 -1
- package/src/lib/views/SmsVerification/useSmsVerification/useSmsVerification.js +1 -1
- package/src/lib/views/TransactionConfirmationView/TransactionConfirmationView.cjs +1 -1
- package/src/lib/views/TransactionConfirmationView/TransactionConfirmationView.js +1 -1
- package/src/lib/views/WalletList/hooks/useTabState.cjs +29 -4
- package/src/lib/views/WalletList/hooks/useTabState.d.ts +2 -2
- package/src/lib/views/WalletList/hooks/useTabState.js +30 -5
- package/src/lib/views/WalletSignSpinnerView/WalletSignSpinnerView.cjs +1 -1
- package/src/lib/views/WalletSignSpinnerView/WalletSignSpinnerView.js +1 -1
- package/src/lib/widgets/DynamicBridgeWidget/components/DynamicBridgeUserProfile/DynamicBridgeUserProfile.cjs +1 -1
- package/src/lib/widgets/DynamicBridgeWidget/components/DynamicBridgeUserProfile/DynamicBridgeUserProfile.js +1 -1
- package/src/lib/widgets/DynamicWidget/components/Wallet/Wallet.cjs +1 -1
- package/src/lib/widgets/DynamicWidget/components/Wallet/Wallet.js +1 -1
- package/src/lib/widgets/DynamicWidget/views/AccountAndSecuritySettingsView/AccountAndSecuritySettingsView.cjs +1 -1
- package/src/lib/widgets/DynamicWidget/views/AccountAndSecuritySettingsView/AccountAndSecuritySettingsView.js +1 -1
- package/src/lib/widgets/DynamicWidget/views/ChooseOnrampProviderView/ChooseOnrampProviderView.cjs +5 -2
- package/src/lib/widgets/DynamicWidget/views/ChooseOnrampProviderView/ChooseOnrampProviderView.js +5 -2
- package/src/lib/widgets/DynamicWidget/views/ChooseWalletFundingMethod/useFundingMethods/useFundingMethods.cjs +18 -5
- package/src/lib/widgets/DynamicWidget/views/ChooseWalletFundingMethod/useFundingMethods/useFundingMethods.js +18 -5
- package/src/lib/widgets/DynamicWidget/views/GlobalWalletView/GlobalWalletView.cjs +1 -1
- package/src/lib/widgets/DynamicWidget/views/GlobalWalletView/GlobalWalletView.js +1 -1
- package/src/lib/widgets/DynamicWidget/views/SettingsView/SettingsView.cjs +2 -2
- package/src/lib/widgets/DynamicWidget/views/SettingsView/SettingsView.js +2 -2
|
@@ -95,6 +95,7 @@ require('../../store/state/tokenBalances.cjs');
|
|
|
95
95
|
require('../../shared/utils/functions/getInitialUrl/getInitialUrl.cjs');
|
|
96
96
|
var useInternalDynamicContext = require('../DynamicContext/useDynamicContext/useInternalDynamicContext.cjs');
|
|
97
97
|
var onrampConfigurationToOnrampOption = require('../../utils/functions/onrampConfigurationToOnrampOption/onrampConfigurationToOnrampOption.cjs');
|
|
98
|
+
var openOnrampPopup = require('../../utils/functions/openOnrampPopup.cjs');
|
|
98
99
|
var useEnabledOnrampProviders = require('./useEnabledOnrampProviders/useEnabledOnrampProviders.cjs');
|
|
99
100
|
|
|
100
101
|
const OnrampContext = React.createContext(undefined);
|
|
@@ -118,13 +119,7 @@ const OnrampContextProvider = ({ children, }) => {
|
|
|
118
119
|
projectSettingsOnramps: (_b = (_a = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk) === null || _a === void 0 ? void 0 : _a.funding) === null || _b === void 0 ? void 0 : _b.onramps,
|
|
119
120
|
target: enabledOnrampProvidersTarget,
|
|
120
121
|
});
|
|
121
|
-
const enabledOnrampProvidersInDashboardOptions = React.useMemo(() => enabledOnrampProvidersInDashboard.map((provider) => onrampConfigurationToOnrampOption.onrampConfigurationToOnrampOption(provider,
|
|
122
|
-
if (primaryWallet) {
|
|
123
|
-
setSelectedOnrampProvider(onrampProvider);
|
|
124
|
-
}
|
|
125
|
-
setShowOnramp(true);
|
|
126
|
-
return Promise.resolve();
|
|
127
|
-
}, setShowOnramp)),
|
|
122
|
+
const enabledOnrampProvidersInDashboardOptions = React.useMemo(() => enabledOnrampProvidersInDashboard.map((provider) => onrampConfigurationToOnrampOption.onrampConfigurationToOnrampOption(provider)),
|
|
128
123
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
129
124
|
[enabledOnrampProvidersInDashboard, primaryWallet, setShowOnramp]);
|
|
130
125
|
const onrampOverrides = React.useMemo(() => {
|
|
@@ -183,12 +178,29 @@ const OnrampContextProvider = ({ children, }) => {
|
|
|
183
178
|
const selectedOnramp = React.useMemo(() => enabledOnrampProviders.length
|
|
184
179
|
? enabledOnrampProviders.find((p) => p.id === selectedOnrampProvider)
|
|
185
180
|
: undefined, [enabledOnrampProviders, selectedOnrampProvider]);
|
|
181
|
+
const hasPrimaryWallet = React.useMemo(() => Boolean(primaryWallet), [primaryWallet]);
|
|
182
|
+
const selectOnrampProvider = React.useCallback(({ provider, wallet }) => {
|
|
183
|
+
var _a;
|
|
184
|
+
if (provider.onClick) {
|
|
185
|
+
provider.onClick({ wallet });
|
|
186
|
+
return;
|
|
187
|
+
}
|
|
188
|
+
if (hasPrimaryWallet) {
|
|
189
|
+
setSelectedOnrampProvider(provider.id);
|
|
190
|
+
}
|
|
191
|
+
setShowOnramp(true);
|
|
192
|
+
const shouldOpenPopup = provider.openMode === 'popup' && provider.url && setShowOnramp;
|
|
193
|
+
if (!shouldOpenPopup) {
|
|
194
|
+
return;
|
|
195
|
+
}
|
|
196
|
+
return openOnrampPopup.openOnrampPopup((_a = provider.url) !== null && _a !== void 0 ? _a : '', wallet, setShowOnramp, provider.id);
|
|
197
|
+
}, [hasPrimaryWallet, setShowOnramp]);
|
|
186
198
|
const value = React.useMemo(() => ({
|
|
187
199
|
enabledOnrampProviders,
|
|
188
200
|
onrampEnabled,
|
|
189
201
|
openOnramp,
|
|
202
|
+
selectOnrampProvider,
|
|
190
203
|
selectedOnramp,
|
|
191
|
-
setSelectedOnrampProvider,
|
|
192
204
|
setShowOnramp,
|
|
193
205
|
showOnramp,
|
|
194
206
|
}), [
|
|
@@ -198,6 +210,7 @@ const OnrampContextProvider = ({ children, }) => {
|
|
|
198
210
|
selectedOnramp,
|
|
199
211
|
showOnramp,
|
|
200
212
|
setShowOnramp,
|
|
213
|
+
selectOnrampProvider,
|
|
201
214
|
]);
|
|
202
215
|
return (jsxRuntime.jsx(OnrampContext.Provider, { value: value, children: children }));
|
|
203
216
|
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type ReactNode } from 'react';
|
|
2
|
-
import type { OnrampProviders
|
|
2
|
+
import type { OnrampProviders } from '@dynamic-labs/sdk-api-core';
|
|
3
|
+
import { Wallet } from '@dynamic-labs/wallet-connector-core';
|
|
3
4
|
import type { OnrampOption } from '../DynamicContext';
|
|
4
5
|
type OpenOnrampProps = {
|
|
5
6
|
address?: string;
|
|
@@ -10,10 +11,13 @@ export type OnrampContextReturn = {
|
|
|
10
11
|
onrampEnabled: boolean;
|
|
11
12
|
setShowOnramp: (value: boolean) => void;
|
|
12
13
|
showOnramp: boolean;
|
|
13
|
-
setSelectedOnrampProvider: (provider: ProviderEnum) => void;
|
|
14
14
|
selectedOnramp: OnrampOption | undefined;
|
|
15
15
|
enabledOnrampProviders: OnrampOption[];
|
|
16
16
|
openOnramp: (props: OpenOnrampProps) => Promise<void>;
|
|
17
|
+
selectOnrampProvider: ({ provider, wallet, }: {
|
|
18
|
+
provider: OnrampOption;
|
|
19
|
+
wallet: Wallet;
|
|
20
|
+
}) => void;
|
|
17
21
|
};
|
|
18
22
|
export declare const OnrampContext: import("react").Context<OnrampContextReturn | undefined>;
|
|
19
23
|
export declare const OnrampContextProvider: ({ children, }: {
|
|
@@ -91,6 +91,7 @@ import '../../store/state/tokenBalances.js';
|
|
|
91
91
|
import '../../shared/utils/functions/getInitialUrl/getInitialUrl.js';
|
|
92
92
|
import { useInternalDynamicContext } from '../DynamicContext/useDynamicContext/useInternalDynamicContext.js';
|
|
93
93
|
import { onrampConfigurationToOnrampOption } from '../../utils/functions/onrampConfigurationToOnrampOption/onrampConfigurationToOnrampOption.js';
|
|
94
|
+
import { openOnrampPopup } from '../../utils/functions/openOnrampPopup.js';
|
|
94
95
|
import { useEnabledOnrampProviders } from './useEnabledOnrampProviders/useEnabledOnrampProviders.js';
|
|
95
96
|
|
|
96
97
|
const OnrampContext = createContext(undefined);
|
|
@@ -114,13 +115,7 @@ const OnrampContextProvider = ({ children, }) => {
|
|
|
114
115
|
projectSettingsOnramps: (_b = (_a = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk) === null || _a === void 0 ? void 0 : _a.funding) === null || _b === void 0 ? void 0 : _b.onramps,
|
|
115
116
|
target: enabledOnrampProvidersTarget,
|
|
116
117
|
});
|
|
117
|
-
const enabledOnrampProvidersInDashboardOptions = useMemo(() => enabledOnrampProvidersInDashboard.map((provider) => onrampConfigurationToOnrampOption(provider,
|
|
118
|
-
if (primaryWallet) {
|
|
119
|
-
setSelectedOnrampProvider(onrampProvider);
|
|
120
|
-
}
|
|
121
|
-
setShowOnramp(true);
|
|
122
|
-
return Promise.resolve();
|
|
123
|
-
}, setShowOnramp)),
|
|
118
|
+
const enabledOnrampProvidersInDashboardOptions = useMemo(() => enabledOnrampProvidersInDashboard.map((provider) => onrampConfigurationToOnrampOption(provider)),
|
|
124
119
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
125
120
|
[enabledOnrampProvidersInDashboard, primaryWallet, setShowOnramp]);
|
|
126
121
|
const onrampOverrides = useMemo(() => {
|
|
@@ -179,12 +174,29 @@ const OnrampContextProvider = ({ children, }) => {
|
|
|
179
174
|
const selectedOnramp = useMemo(() => enabledOnrampProviders.length
|
|
180
175
|
? enabledOnrampProviders.find((p) => p.id === selectedOnrampProvider)
|
|
181
176
|
: undefined, [enabledOnrampProviders, selectedOnrampProvider]);
|
|
177
|
+
const hasPrimaryWallet = useMemo(() => Boolean(primaryWallet), [primaryWallet]);
|
|
178
|
+
const selectOnrampProvider = useCallback(({ provider, wallet }) => {
|
|
179
|
+
var _a;
|
|
180
|
+
if (provider.onClick) {
|
|
181
|
+
provider.onClick({ wallet });
|
|
182
|
+
return;
|
|
183
|
+
}
|
|
184
|
+
if (hasPrimaryWallet) {
|
|
185
|
+
setSelectedOnrampProvider(provider.id);
|
|
186
|
+
}
|
|
187
|
+
setShowOnramp(true);
|
|
188
|
+
const shouldOpenPopup = provider.openMode === 'popup' && provider.url && setShowOnramp;
|
|
189
|
+
if (!shouldOpenPopup) {
|
|
190
|
+
return;
|
|
191
|
+
}
|
|
192
|
+
return openOnrampPopup((_a = provider.url) !== null && _a !== void 0 ? _a : '', wallet, setShowOnramp, provider.id);
|
|
193
|
+
}, [hasPrimaryWallet, setShowOnramp]);
|
|
182
194
|
const value = useMemo(() => ({
|
|
183
195
|
enabledOnrampProviders,
|
|
184
196
|
onrampEnabled,
|
|
185
197
|
openOnramp,
|
|
198
|
+
selectOnrampProvider,
|
|
186
199
|
selectedOnramp,
|
|
187
|
-
setSelectedOnrampProvider,
|
|
188
200
|
setShowOnramp,
|
|
189
201
|
showOnramp,
|
|
190
202
|
}), [
|
|
@@ -194,6 +206,7 @@ const OnrampContextProvider = ({ children, }) => {
|
|
|
194
206
|
selectedOnramp,
|
|
195
207
|
showOnramp,
|
|
196
208
|
setShowOnramp,
|
|
209
|
+
selectOnrampProvider,
|
|
197
210
|
]);
|
|
198
211
|
return (jsx(OnrampContext.Provider, { value: value, children: children }));
|
|
199
212
|
};
|
|
@@ -57,6 +57,7 @@ require('../../../../store/state/walletOptions/walletOptions.cjs');
|
|
|
57
57
|
require('react-i18next');
|
|
58
58
|
require('../../../../components/Accordion/components/AccordionItem/AccordionItem.cjs');
|
|
59
59
|
require('../../../../components/Alert/Alert.cjs');
|
|
60
|
+
require('../../../WalletContext/WalletContext.cjs');
|
|
60
61
|
require('../../../../components/ShadowDOM/ShadowDOM.cjs');
|
|
61
62
|
require('../../../../components/IconButton/IconButton.cjs');
|
|
62
63
|
require('../../../../components/InlineWidget/InlineWidget.cjs');
|
|
@@ -72,7 +73,6 @@ require('../../../../components/Popper/Popper/Popper.cjs');
|
|
|
72
73
|
require('../../../../components/Popper/PopperContext/PopperContext.cjs');
|
|
73
74
|
require('react-focus-lock');
|
|
74
75
|
require('qrcode');
|
|
75
|
-
require('../../../WalletContext/WalletContext.cjs');
|
|
76
76
|
require('formik');
|
|
77
77
|
require('../../../../utils/hooks/useSubdomainCheck/useSubdomainCheck.cjs');
|
|
78
78
|
var useEffectOnce = require('../../../../utils/hooks/useEffectOnce/useEffectOnce.cjs');
|
|
@@ -53,6 +53,7 @@ import '../../../../store/state/walletOptions/walletOptions.js';
|
|
|
53
53
|
import 'react-i18next';
|
|
54
54
|
import '../../../../components/Accordion/components/AccordionItem/AccordionItem.js';
|
|
55
55
|
import '../../../../components/Alert/Alert.js';
|
|
56
|
+
import '../../../WalletContext/WalletContext.js';
|
|
56
57
|
import '../../../../components/ShadowDOM/ShadowDOM.js';
|
|
57
58
|
import '../../../../components/IconButton/IconButton.js';
|
|
58
59
|
import '../../../../components/InlineWidget/InlineWidget.js';
|
|
@@ -68,7 +69,6 @@ import '../../../../components/Popper/Popper/Popper.js';
|
|
|
68
69
|
import '../../../../components/Popper/PopperContext/PopperContext.js';
|
|
69
70
|
import 'react-focus-lock';
|
|
70
71
|
import 'qrcode';
|
|
71
|
-
import '../../../WalletContext/WalletContext.js';
|
|
72
72
|
import 'formik';
|
|
73
73
|
import '../../../../utils/hooks/useSubdomainCheck/useSubdomainCheck.js';
|
|
74
74
|
import { useEffectOnce } from '../../../../utils/hooks/useEffectOnce/useEffectOnce.js';
|
|
@@ -5,11 +5,20 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
|
|
6
6
|
var _tslib = require('../../../../../_virtual/_tslib.cjs');
|
|
7
7
|
var sdkApiCore = require('@dynamic-labs/sdk-api-core');
|
|
8
|
-
var utils
|
|
8
|
+
var utils = require('@dynamic-labs/utils');
|
|
9
9
|
var storeAuthTokenAndUser = require('../../../store/state/user/storeAuthTokenAndUser/storeAuthTokenAndUser.cjs');
|
|
10
10
|
require('../../../store/state/user/user.cjs');
|
|
11
11
|
var api = require('../api.cjs');
|
|
12
|
-
var
|
|
12
|
+
var logger = require('../../../shared/logger.cjs');
|
|
13
|
+
require('@dynamic-labs/iconic');
|
|
14
|
+
require('@dynamic-labs/wallet-connector-core');
|
|
15
|
+
require('react');
|
|
16
|
+
require('react/jsx-runtime');
|
|
17
|
+
require('../../../context/ViewContext/ViewContext.cjs');
|
|
18
|
+
require('@dynamic-labs/wallet-book');
|
|
19
|
+
require('../../../utils/constants/colors.cjs');
|
|
20
|
+
require('../../../utils/constants/values.cjs');
|
|
21
|
+
require('../../../shared/consts/index.cjs');
|
|
13
22
|
|
|
14
23
|
const createTurnkeyEmbeddedWallet = (_a) => _tslib.__awaiter(void 0, [_a], void 0, function* ({ attestation, challenge, environmentId, chains = [sdkApiCore.EmbeddedWalletChainEnum.Evm], passkeyAlias, sessionPublicKey, }) {
|
|
15
24
|
const embeddedWallets = [
|
|
@@ -38,7 +47,7 @@ const createTurnkeyEmbeddedWallet = (_a) => _tslib.__awaiter(void 0, [_a], void
|
|
|
38
47
|
return user;
|
|
39
48
|
}
|
|
40
49
|
catch (e) {
|
|
41
|
-
yield
|
|
50
|
+
yield logResponse(e, 'Error creating embedded wallet');
|
|
42
51
|
return undefined;
|
|
43
52
|
}
|
|
44
53
|
});
|
|
@@ -73,7 +82,7 @@ const completePasskeyRecovery = (_c) => _tslib.__awaiter(void 0, [_c], void 0, f
|
|
|
73
82
|
return storeAuthTokenAndUser.storeAuthTokenAndUser(response);
|
|
74
83
|
}
|
|
75
84
|
catch (e) {
|
|
76
|
-
yield
|
|
85
|
+
yield logResponse(e, 'Error completing passkey recovery');
|
|
77
86
|
return undefined;
|
|
78
87
|
}
|
|
79
88
|
});
|
|
@@ -85,8 +94,8 @@ const updatePasskeyRecoveryEmail = (_d) => _tslib.__awaiter(void 0, [_d], void 0
|
|
|
85
94
|
});
|
|
86
95
|
}
|
|
87
96
|
catch (e) {
|
|
88
|
-
yield
|
|
89
|
-
throw new utils
|
|
97
|
+
yield logResponse(e, 'Error while trying to update recovery email');
|
|
98
|
+
throw new utils.DynamicError('Error updating recovery email');
|
|
90
99
|
}
|
|
91
100
|
});
|
|
92
101
|
const getUserPasskeys = (_e) => _tslib.__awaiter(void 0, [_e], void 0, function* ({ environmentId, }) {
|
|
@@ -97,7 +106,7 @@ const getUserPasskeys = (_e) => _tslib.__awaiter(void 0, [_e], void 0, function*
|
|
|
97
106
|
return data;
|
|
98
107
|
}
|
|
99
108
|
catch (e) {
|
|
100
|
-
yield
|
|
109
|
+
yield logResponse(e, 'Error getting user passkeys');
|
|
101
110
|
return {
|
|
102
111
|
count: 0,
|
|
103
112
|
passkeys: [],
|
|
@@ -113,7 +122,7 @@ const updateUserPasskey = (_f) => _tslib.__awaiter(void 0, [_f], void 0, functio
|
|
|
113
122
|
return data;
|
|
114
123
|
}
|
|
115
124
|
catch (e) {
|
|
116
|
-
yield
|
|
125
|
+
yield logResponse(e, 'Error updating user passkeys', { alias, id });
|
|
117
126
|
return undefined;
|
|
118
127
|
}
|
|
119
128
|
});
|
|
@@ -127,7 +136,10 @@ const exportEmbeddedWallet = (_g) => _tslib.__awaiter(void 0, [_g], void 0, func
|
|
|
127
136
|
return data;
|
|
128
137
|
}
|
|
129
138
|
catch (e) {
|
|
130
|
-
yield
|
|
139
|
+
yield logResponse(e, 'Error exporting embedded wallet', {
|
|
140
|
+
activityId,
|
|
141
|
+
walletId,
|
|
142
|
+
});
|
|
131
143
|
return { exportBundle: '' };
|
|
132
144
|
}
|
|
133
145
|
});
|
|
@@ -139,14 +151,25 @@ const registerSessionKey = (_h) => _tslib.__awaiter(void 0, [_h], void 0, functi
|
|
|
139
151
|
registerSessionKeyRequest: { prevSessionKeySignature, publicKey },
|
|
140
152
|
});
|
|
141
153
|
}
|
|
142
|
-
catch (
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
154
|
+
catch (error) {
|
|
155
|
+
if (error instanceof Response) {
|
|
156
|
+
const responseError = yield utils.ResponseError.fromResponse({
|
|
157
|
+
cause: error,
|
|
158
|
+
message: 'Error register session key',
|
|
159
|
+
});
|
|
160
|
+
logger.logger.error(responseError, { prevSessionKeySignature, publicKey });
|
|
161
|
+
if (responseError.response.status === 422) {
|
|
162
|
+
if (responseError.json.code ===
|
|
163
|
+
sdkApiCore.UnprocessableEntityErrorCode.InvalidSessionPublicKey) {
|
|
164
|
+
throw new utils.InvalidEmbeddedWalletSessionKeyError(responseError.json.error);
|
|
165
|
+
}
|
|
147
166
|
}
|
|
167
|
+
throw responseError;
|
|
168
|
+
}
|
|
169
|
+
else {
|
|
170
|
+
logger.logger.error(error);
|
|
148
171
|
}
|
|
149
|
-
throw
|
|
172
|
+
throw error;
|
|
150
173
|
}
|
|
151
174
|
return response;
|
|
152
175
|
});
|
|
@@ -159,8 +182,8 @@ const getCreateEmbeddedWalletAccountRequest = (_j) => _tslib.__awaiter(void 0, [
|
|
|
159
182
|
return response;
|
|
160
183
|
}
|
|
161
184
|
catch (e) {
|
|
162
|
-
yield
|
|
163
|
-
throw new utils
|
|
185
|
+
yield logResponse(e, 'Error fetching create embedded wallet account request', { chain });
|
|
186
|
+
throw new utils.DynamicError('Error fetching create embedded wallet account request');
|
|
164
187
|
}
|
|
165
188
|
});
|
|
166
189
|
const createEmbeddedWalletAccount = (_k) => _tslib.__awaiter(void 0, [_k], void 0, function* ({ environmentId, createEmbeddedWalletAccountRequest, }) {
|
|
@@ -174,8 +197,10 @@ const createEmbeddedWalletAccount = (_k) => _tslib.__awaiter(void 0, [_k], void
|
|
|
174
197
|
return response;
|
|
175
198
|
}
|
|
176
199
|
catch (e) {
|
|
177
|
-
yield
|
|
178
|
-
|
|
200
|
+
yield logResponse(e, 'Error creating embedded wallet account', {
|
|
201
|
+
createEmbeddedWalletAccountRequest,
|
|
202
|
+
});
|
|
203
|
+
throw new utils.DynamicError('Error creating embedded wallet account');
|
|
179
204
|
}
|
|
180
205
|
});
|
|
181
206
|
const getDeleteEmbeddedWalletsRequest = (_l) => _tslib.__awaiter(void 0, [_l], void 0, function* ({ environmentId, }) {
|
|
@@ -186,8 +211,8 @@ const getDeleteEmbeddedWalletsRequest = (_l) => _tslib.__awaiter(void 0, [_l], v
|
|
|
186
211
|
return response;
|
|
187
212
|
}
|
|
188
213
|
catch (e) {
|
|
189
|
-
yield
|
|
190
|
-
throw new utils
|
|
214
|
+
yield logResponse(e, 'Error fetching delete embedded wallet request');
|
|
215
|
+
throw new utils.DynamicError('Error fetching delete embedded wallets request');
|
|
191
216
|
}
|
|
192
217
|
});
|
|
193
218
|
const deleteEmbeddedWallets = (_m) => _tslib.__awaiter(void 0, [_m], void 0, function* ({ environmentId, deleteEmbeddedWalletsRequest, }) {
|
|
@@ -201,8 +226,22 @@ const deleteEmbeddedWallets = (_m) => _tslib.__awaiter(void 0, [_m], void 0, fun
|
|
|
201
226
|
return response;
|
|
202
227
|
}
|
|
203
228
|
catch (e) {
|
|
204
|
-
yield
|
|
205
|
-
|
|
229
|
+
yield logResponse(e, 'Error deleting embedded wallets', {
|
|
230
|
+
deleteEmbeddedWalletsRequest,
|
|
231
|
+
});
|
|
232
|
+
throw new utils.DynamicError('Error deleting embedded wallets');
|
|
233
|
+
}
|
|
234
|
+
});
|
|
235
|
+
const logResponse = (error, message, data) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
236
|
+
if (error instanceof Response) {
|
|
237
|
+
const responseError = yield utils.ResponseError.fromResponse({
|
|
238
|
+
cause: error,
|
|
239
|
+
message,
|
|
240
|
+
});
|
|
241
|
+
logger.logger.error(responseError, data);
|
|
242
|
+
}
|
|
243
|
+
else {
|
|
244
|
+
logger.logger.error(error, data);
|
|
206
245
|
}
|
|
207
246
|
});
|
|
208
247
|
|
|
@@ -1,11 +1,20 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
import { __awaiter } from '../../../../../_virtual/_tslib.js';
|
|
3
3
|
import { UnprocessableEntityErrorCode, EmbeddedWalletProviderEnum, EmbeddedWalletChainEnum } from '@dynamic-labs/sdk-api-core';
|
|
4
|
-
import { DynamicError, InvalidEmbeddedWalletSessionKeyError } from '@dynamic-labs/utils';
|
|
4
|
+
import { DynamicError, ResponseError, InvalidEmbeddedWalletSessionKeyError } from '@dynamic-labs/utils';
|
|
5
5
|
import { storeAuthTokenAndUser } from '../../../store/state/user/storeAuthTokenAndUser/storeAuthTokenAndUser.js';
|
|
6
6
|
import '../../../store/state/user/user.js';
|
|
7
7
|
import { sdkApi } from '../api.js';
|
|
8
|
-
import {
|
|
8
|
+
import { logger } from '../../../shared/logger.js';
|
|
9
|
+
import '@dynamic-labs/iconic';
|
|
10
|
+
import '@dynamic-labs/wallet-connector-core';
|
|
11
|
+
import 'react';
|
|
12
|
+
import 'react/jsx-runtime';
|
|
13
|
+
import '../../../context/ViewContext/ViewContext.js';
|
|
14
|
+
import '@dynamic-labs/wallet-book';
|
|
15
|
+
import '../../../utils/constants/colors.js';
|
|
16
|
+
import '../../../utils/constants/values.js';
|
|
17
|
+
import '../../../shared/consts/index.js';
|
|
9
18
|
|
|
10
19
|
const createTurnkeyEmbeddedWallet = (_a) => __awaiter(void 0, [_a], void 0, function* ({ attestation, challenge, environmentId, chains = [EmbeddedWalletChainEnum.Evm], passkeyAlias, sessionPublicKey, }) {
|
|
11
20
|
const embeddedWallets = [
|
|
@@ -34,7 +43,7 @@ const createTurnkeyEmbeddedWallet = (_a) => __awaiter(void 0, [_a], void 0, func
|
|
|
34
43
|
return user;
|
|
35
44
|
}
|
|
36
45
|
catch (e) {
|
|
37
|
-
yield
|
|
46
|
+
yield logResponse(e, 'Error creating embedded wallet');
|
|
38
47
|
return undefined;
|
|
39
48
|
}
|
|
40
49
|
});
|
|
@@ -69,7 +78,7 @@ const completePasskeyRecovery = (_c) => __awaiter(void 0, [_c], void 0, function
|
|
|
69
78
|
return storeAuthTokenAndUser(response);
|
|
70
79
|
}
|
|
71
80
|
catch (e) {
|
|
72
|
-
yield
|
|
81
|
+
yield logResponse(e, 'Error completing passkey recovery');
|
|
73
82
|
return undefined;
|
|
74
83
|
}
|
|
75
84
|
});
|
|
@@ -81,7 +90,7 @@ const updatePasskeyRecoveryEmail = (_d) => __awaiter(void 0, [_d], void 0, funct
|
|
|
81
90
|
});
|
|
82
91
|
}
|
|
83
92
|
catch (e) {
|
|
84
|
-
yield
|
|
93
|
+
yield logResponse(e, 'Error while trying to update recovery email');
|
|
85
94
|
throw new DynamicError('Error updating recovery email');
|
|
86
95
|
}
|
|
87
96
|
});
|
|
@@ -93,7 +102,7 @@ const getUserPasskeys = (_e) => __awaiter(void 0, [_e], void 0, function* ({ env
|
|
|
93
102
|
return data;
|
|
94
103
|
}
|
|
95
104
|
catch (e) {
|
|
96
|
-
yield
|
|
105
|
+
yield logResponse(e, 'Error getting user passkeys');
|
|
97
106
|
return {
|
|
98
107
|
count: 0,
|
|
99
108
|
passkeys: [],
|
|
@@ -109,7 +118,7 @@ const updateUserPasskey = (_f) => __awaiter(void 0, [_f], void 0, function* ({ e
|
|
|
109
118
|
return data;
|
|
110
119
|
}
|
|
111
120
|
catch (e) {
|
|
112
|
-
yield
|
|
121
|
+
yield logResponse(e, 'Error updating user passkeys', { alias, id });
|
|
113
122
|
return undefined;
|
|
114
123
|
}
|
|
115
124
|
});
|
|
@@ -123,7 +132,10 @@ const exportEmbeddedWallet = (_g) => __awaiter(void 0, [_g], void 0, function* (
|
|
|
123
132
|
return data;
|
|
124
133
|
}
|
|
125
134
|
catch (e) {
|
|
126
|
-
yield
|
|
135
|
+
yield logResponse(e, 'Error exporting embedded wallet', {
|
|
136
|
+
activityId,
|
|
137
|
+
walletId,
|
|
138
|
+
});
|
|
127
139
|
return { exportBundle: '' };
|
|
128
140
|
}
|
|
129
141
|
});
|
|
@@ -135,14 +147,25 @@ const registerSessionKey = (_h) => __awaiter(void 0, [_h], void 0, function* ({
|
|
|
135
147
|
registerSessionKeyRequest: { prevSessionKeySignature, publicKey },
|
|
136
148
|
});
|
|
137
149
|
}
|
|
138
|
-
catch (
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
150
|
+
catch (error) {
|
|
151
|
+
if (error instanceof Response) {
|
|
152
|
+
const responseError = yield ResponseError.fromResponse({
|
|
153
|
+
cause: error,
|
|
154
|
+
message: 'Error register session key',
|
|
155
|
+
});
|
|
156
|
+
logger.error(responseError, { prevSessionKeySignature, publicKey });
|
|
157
|
+
if (responseError.response.status === 422) {
|
|
158
|
+
if (responseError.json.code ===
|
|
159
|
+
UnprocessableEntityErrorCode.InvalidSessionPublicKey) {
|
|
160
|
+
throw new InvalidEmbeddedWalletSessionKeyError(responseError.json.error);
|
|
161
|
+
}
|
|
143
162
|
}
|
|
163
|
+
throw responseError;
|
|
164
|
+
}
|
|
165
|
+
else {
|
|
166
|
+
logger.error(error);
|
|
144
167
|
}
|
|
145
|
-
throw
|
|
168
|
+
throw error;
|
|
146
169
|
}
|
|
147
170
|
return response;
|
|
148
171
|
});
|
|
@@ -155,7 +178,7 @@ const getCreateEmbeddedWalletAccountRequest = (_j) => __awaiter(void 0, [_j], vo
|
|
|
155
178
|
return response;
|
|
156
179
|
}
|
|
157
180
|
catch (e) {
|
|
158
|
-
yield
|
|
181
|
+
yield logResponse(e, 'Error fetching create embedded wallet account request', { chain });
|
|
159
182
|
throw new DynamicError('Error fetching create embedded wallet account request');
|
|
160
183
|
}
|
|
161
184
|
});
|
|
@@ -170,7 +193,9 @@ const createEmbeddedWalletAccount = (_k) => __awaiter(void 0, [_k], void 0, func
|
|
|
170
193
|
return response;
|
|
171
194
|
}
|
|
172
195
|
catch (e) {
|
|
173
|
-
yield
|
|
196
|
+
yield logResponse(e, 'Error creating embedded wallet account', {
|
|
197
|
+
createEmbeddedWalletAccountRequest,
|
|
198
|
+
});
|
|
174
199
|
throw new DynamicError('Error creating embedded wallet account');
|
|
175
200
|
}
|
|
176
201
|
});
|
|
@@ -182,7 +207,7 @@ const getDeleteEmbeddedWalletsRequest = (_l) => __awaiter(void 0, [_l], void 0,
|
|
|
182
207
|
return response;
|
|
183
208
|
}
|
|
184
209
|
catch (e) {
|
|
185
|
-
yield
|
|
210
|
+
yield logResponse(e, 'Error fetching delete embedded wallet request');
|
|
186
211
|
throw new DynamicError('Error fetching delete embedded wallets request');
|
|
187
212
|
}
|
|
188
213
|
});
|
|
@@ -197,9 +222,23 @@ const deleteEmbeddedWallets = (_m) => __awaiter(void 0, [_m], void 0, function*
|
|
|
197
222
|
return response;
|
|
198
223
|
}
|
|
199
224
|
catch (e) {
|
|
200
|
-
yield
|
|
225
|
+
yield logResponse(e, 'Error deleting embedded wallets', {
|
|
226
|
+
deleteEmbeddedWalletsRequest,
|
|
227
|
+
});
|
|
201
228
|
throw new DynamicError('Error deleting embedded wallets');
|
|
202
229
|
}
|
|
203
230
|
});
|
|
231
|
+
const logResponse = (error, message, data) => __awaiter(void 0, void 0, void 0, function* () {
|
|
232
|
+
if (error instanceof Response) {
|
|
233
|
+
const responseError = yield ResponseError.fromResponse({
|
|
234
|
+
cause: error,
|
|
235
|
+
message,
|
|
236
|
+
});
|
|
237
|
+
logger.error(responseError, data);
|
|
238
|
+
}
|
|
239
|
+
else {
|
|
240
|
+
logger.error(error, data);
|
|
241
|
+
}
|
|
242
|
+
});
|
|
204
243
|
|
|
205
244
|
export { completePasskeyRecovery, createEmbeddedWalletAccount, createTurnkeyEmbeddedWallet, deleteEmbeddedWallets, exportEmbeddedWallet, getCreateEmbeddedWalletAccountRequest, getDeleteEmbeddedWalletsRequest, getUserPasskeys, initEmbeddedWalletSession, registerSessionKey, updatePasskeyRecoveryEmail, updateUserPasskey };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './blockaid';
|
|
@@ -13,7 +13,7 @@ import { WalletEvents } from './wallets';
|
|
|
13
13
|
/** Maps internal event names to their listeners */
|
|
14
14
|
export type DynamicEvents = AuthEvents & UIEvents & OTPEvents & WalletEvents & PasskeyEvents & SocialEvents & EmbeddedWalletEvents & MultiWalletInternalEvents & TokenBalancesEvents & UserEvents & FundingEvents;
|
|
15
15
|
/** Which events are accessible by our clients */
|
|
16
|
-
export declare const externalEvents: ("authFailure" | "authInit" | "logout" | "mfaCompletionSuccess" | "mfaCompletionFailure" | "authFlowOpen" | "authFlowClose" | "authFlowCancelled" | "emailVerificationResult" | "smsVerificationResult" | "walletAdded" | "walletRemoved" | "primaryWalletChanged" | "primaryWalletNetworkChanged" | "userWalletsChanged" | "embeddedWalletCreated" | "walletConnectedForFunding")[];
|
|
16
|
+
export declare const externalEvents: ("authFailure" | "authInit" | "logout" | "mfaCompletionSuccess" | "mfaCompletionFailure" | "authFlowOpen" | "authFlowClose" | "authFlowCancelled" | "walletTabSelected" | "emailVerificationResult" | "smsVerificationResult" | "walletAdded" | "walletRemoved" | "primaryWalletChanged" | "primaryWalletNetworkChanged" | "userWalletsChanged" | "embeddedWalletCreated" | "walletConnectedForFunding")[];
|
|
17
17
|
export declare const dynamicEvents: EventEmitter<DynamicEvents, any>;
|
|
18
|
-
export declare const publicDynamicEvents: EventEmitter<"authFailure" | "authInit" | "logout" | "mfaCompletionSuccess" | "mfaCompletionFailure" | "authFlowOpen" | "authFlowClose" | "authFlowCancelled" | "emailVerificationResult" | "smsVerificationResult" | "walletAdded" | "walletRemoved" | "primaryWalletChanged" | "primaryWalletNetworkChanged" | "userWalletsChanged" | "embeddedWalletCreated" | "walletConnectedForFunding", any>;
|
|
18
|
+
export declare const publicDynamicEvents: EventEmitter<"authFailure" | "authInit" | "logout" | "mfaCompletionSuccess" | "mfaCompletionFailure" | "authFlowOpen" | "authFlowClose" | "authFlowCancelled" | "walletTabSelected" | "emailVerificationResult" | "smsVerificationResult" | "walletAdded" | "walletRemoved" | "primaryWalletChanged" | "primaryWalletNetworkChanged" | "userWalletsChanged" | "embeddedWalletCreated" | "walletConnectedForFunding", any>;
|
|
19
19
|
export type DynamicEventEmitter = typeof dynamicEvents;
|
package/src/lib/events/ui.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { WalletListViewTabItem } from '../shared/types/wallets';
|
|
1
2
|
export type UIEvents = {
|
|
2
3
|
authFlowOpen: () => void;
|
|
3
4
|
/** Triggered when auth is closed before reaching success (due to user cancel or fail) */
|
|
@@ -7,6 +8,13 @@ export type UIEvents = {
|
|
|
7
8
|
* like when user rejects connection or the network call fails
|
|
8
9
|
*/
|
|
9
10
|
authFlowCancelled: () => void;
|
|
11
|
+
/**
|
|
12
|
+
* Triggered when Wallet Tabs are enabled and the user selects a tab
|
|
13
|
+
*/
|
|
14
|
+
walletTabSelected: (props: {
|
|
15
|
+
index: number;
|
|
16
|
+
tab: WalletListViewTabItem;
|
|
17
|
+
}) => void;
|
|
10
18
|
userProfileOpen: () => void;
|
|
11
19
|
userProfileClose: () => void;
|
|
12
20
|
};
|