@dynamic-labs/sdk-react-core 4.19.6 → 4.20.0
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 +26 -0
- package/package.cjs +2 -1
- package/package.js +2 -1
- package/package.json +12 -11
- package/src/functions.d.ts +1 -0
- package/src/lib/client/client.cjs +19 -0
- package/src/lib/client/client.d.ts +8 -0
- package/src/lib/client/client.js +11 -0
- package/src/lib/client/extension/constants.cjs +12 -0
- package/src/lib/client/extension/constants.d.ts +5 -0
- package/src/lib/client/extension/constants.js +8 -0
- package/src/lib/client/extension/index.d.ts +1 -0
- package/src/lib/client/extension/useInitializeSdkClient/fetchOverride/MockedFetchError.cjs +14 -0
- package/src/lib/client/extension/useInitializeSdkClient/fetchOverride/MockedFetchError.d.ts +4 -0
- package/src/lib/client/extension/useInitializeSdkClient/fetchOverride/MockedFetchError.js +10 -0
- package/src/lib/client/extension/useInitializeSdkClient/fetchOverride/fetchOverride.cjs +29 -0
- package/src/lib/client/extension/useInitializeSdkClient/fetchOverride/fetchOverride.d.ts +7 -0
- package/src/lib/client/extension/useInitializeSdkClient/fetchOverride/fetchOverride.js +25 -0
- package/src/lib/client/extension/useInitializeSdkClient/fetchOverride/index.d.ts +1 -0
- package/src/lib/client/extension/useInitializeSdkClient/index.d.ts +1 -0
- package/src/lib/client/extension/useInitializeSdkClient/useInitializeSdkClient.cjs +30 -0
- package/src/lib/client/extension/useInitializeSdkClient/useInitializeSdkClient.d.ts +2 -0
- package/src/lib/client/extension/useInitializeSdkClient/useInitializeSdkClient.js +26 -0
- package/src/lib/client/extension/utils/useClientState/index.d.ts +1 -0
- package/src/lib/client/extension/utils/useClientState/useClientState.d.ts +2 -0
- package/src/lib/context/DynamicContext/DynamicContext.cjs +3 -0
- package/src/lib/context/DynamicContext/DynamicContext.js +3 -0
- package/src/lib/styles/index.shadow.cjs +1 -1
- package/src/lib/styles/index.shadow.js +1 -1
- package/src/lib/utils/functions/getSessionInformation/getSessionInformation.cjs +13 -2
- package/src/lib/utils/functions/getSessionInformation/getSessionInformation.d.ts +2 -0
- package/src/lib/utils/functions/getSessionInformation/getSessionInformation.js +13 -2
- package/src/lib/utils/hooks/authenticationHooks/useConnectAndSign/unsetInitialWalletVerificationFlag/unsetInitialWalletVerificationFlag.cjs +9 -6
- package/src/lib/utils/hooks/authenticationHooks/useConnectAndSign/unsetInitialWalletVerificationFlag/unsetInitialWalletVerificationFlag.d.ts +8 -0
- package/src/lib/utils/hooks/authenticationHooks/useConnectAndSign/unsetInitialWalletVerificationFlag/unsetInitialWalletVerificationFlag.js +8 -7
- package/src/lib/utils/hooks/authenticationHooks/useConnectAndSign/useConnectAndSign.cjs +3 -2
- package/src/lib/utils/hooks/authenticationHooks/useConnectAndSign/useConnectAndSign.js +4 -3
- package/src/lib/utils/hooks/useDynamicWaas/constants.cjs +2 -0
- package/src/lib/utils/hooks/useDynamicWaas/constants.d.ts +1 -0
- package/src/lib/utils/hooks/useDynamicWaas/constants.js +2 -1
- package/src/lib/utils/hooks/useDynamicWaas/useDynamicWaas.cjs +11 -3
- package/src/lib/utils/hooks/useDynamicWaas/useDynamicWaas.d.ts +4 -2
- package/src/lib/utils/hooks/useDynamicWaas/useDynamicWaas.js +12 -4
- package/src/lib/utils/types/SessionInformation.d.ts +6 -1
- package/src/lib/views/EmbeddedReveal/EmbeddedRevealView/EmbeddedRevealView.cjs +15 -88
- package/src/lib/views/EmbeddedReveal/EmbeddedRevealView/EmbeddedRevealView.js +15 -88
|
@@ -116,16 +116,11 @@ import '../../../shared/utils/functions/getInitialUrl/getInitialUrl.js';
|
|
|
116
116
|
import { useInternalDynamicContext } from '../../../context/DynamicContext/useDynamicContext/useInternalDynamicContext/useInternalDynamicContext.js';
|
|
117
117
|
|
|
118
118
|
const EmbeddedRevealView = ({ exportPrivateKey, isPromptForExport = false, }) => {
|
|
119
|
-
var _a, _b, _c
|
|
119
|
+
var _a, _b, _c;
|
|
120
120
|
const { primaryWallet, user, setShowAuthFlow, environmentId } = useInternalDynamicContext();
|
|
121
121
|
const { handleAcknowledgeExportPrompt } = useSyncEmbeddedWalletFlow();
|
|
122
122
|
const { isTurnkeyWallet } = useIsTurnkeyWallet();
|
|
123
|
-
//should use useIsWaasWallet hook
|
|
124
123
|
const isWaasWallet = user === null || user === void 0 ? void 0 : user.verifiedCredentials.find((vc) => { var _a; return (_a = vc.walletName) === null || _a === void 0 ? void 0 : _a.startsWith('dynamicwaas'); });
|
|
125
|
-
// Check if it's a Sui wallet
|
|
126
|
-
const isSuiWallet = ((_a = primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.connector) === null || _a === void 0 ? void 0 : _a.connectedChain) === 'SUI';
|
|
127
|
-
// Check if it's a SOL wallet
|
|
128
|
-
const isSolWallet = ((_b = primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.connector) === null || _b === void 0 ? void 0 : _b.connectedChain) === 'SOL';
|
|
129
124
|
const { setDynamicWidgetView } = useWidgetContext();
|
|
130
125
|
const { pushView } = useViewContext();
|
|
131
126
|
const { getEOAWallet, isSmartWallet } = useSmartWallets();
|
|
@@ -141,9 +136,9 @@ const EmbeddedRevealView = ({ exportPrivateKey, isPromptForExport = false, }) =>
|
|
|
141
136
|
catch (error) {
|
|
142
137
|
// waas wallet
|
|
143
138
|
}
|
|
144
|
-
const walletProperties = (
|
|
139
|
+
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;
|
|
145
140
|
const isTurnkeyHDWallet = walletProperties === null || walletProperties === void 0 ? void 0 : walletProperties.turnkeyHDWalletId;
|
|
146
|
-
const wallet = (
|
|
141
|
+
const wallet = (_c = (primaryWallet && getEOAWallet(primaryWallet))) !== null && _c !== void 0 ? _c : primaryWallet;
|
|
147
142
|
const [showSkeleton, setShowSkeleton] = useState(false);
|
|
148
143
|
// eslint-disable-next-line arrow-body-style
|
|
149
144
|
useEffect(() => {
|
|
@@ -163,14 +158,14 @@ const EmbeddedRevealView = ({ exportPrivateKey, isPromptForExport = false, }) =>
|
|
|
163
158
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
164
159
|
}, []);
|
|
165
160
|
const { isLoading: exportLoading } = usePromise(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
166
|
-
var
|
|
161
|
+
var _d, _e;
|
|
167
162
|
const iframeContainerElement = iframeContainerRef.current;
|
|
168
163
|
if (!iframeContainerElement ||
|
|
169
|
-
((
|
|
164
|
+
((_d = iframeContainerElement === null || iframeContainerElement === void 0 ? void 0 : iframeContainerElement.children) === null || _d === void 0 ? void 0 : _d.length) > 0) {
|
|
170
165
|
return;
|
|
171
166
|
}
|
|
172
167
|
if (isSessionKeyCompatibleWalletConnector(wallet === null || wallet === void 0 ? void 0 : wallet.connector)) {
|
|
173
|
-
yield ((
|
|
168
|
+
yield ((_e = wallet === null || wallet === void 0 ? void 0 : wallet.connector) === null || _e === void 0 ? void 0 : _e.createOrRestoreSession());
|
|
174
169
|
}
|
|
175
170
|
if (isTurnkeyWallet) {
|
|
176
171
|
return initExport({
|
|
@@ -182,7 +177,7 @@ const EmbeddedRevealView = ({ exportPrivateKey, isPromptForExport = false, }) =>
|
|
|
182
177
|
return;
|
|
183
178
|
}));
|
|
184
179
|
const { mutate: handleExportWallet, isLoading, error, data, } = useMutation(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
185
|
-
var
|
|
180
|
+
var _f, _g, _h;
|
|
186
181
|
handleAcknowledgeExportPrompt();
|
|
187
182
|
if (isTurnkeyWallet) {
|
|
188
183
|
try {
|
|
@@ -193,11 +188,11 @@ const EmbeddedRevealView = ({ exportPrivateKey, isPromptForExport = false, }) =>
|
|
|
193
188
|
wallet: wallet,
|
|
194
189
|
});
|
|
195
190
|
}
|
|
196
|
-
catch (
|
|
191
|
+
catch (_j) {
|
|
197
192
|
if (isSessionKeyCompatibleWalletConnector(wallet === null || wallet === void 0 ? void 0 : wallet.connector) &&
|
|
198
|
-
((
|
|
199
|
-
yield ((
|
|
200
|
-
yield ((
|
|
193
|
+
((_f = wallet === null || wallet === void 0 ? void 0 : wallet.connector) === null || _f === void 0 ? void 0 : _f.removeSessionKeys)) {
|
|
194
|
+
yield ((_g = wallet === null || wallet === void 0 ? void 0 : wallet.connector) === null || _g === void 0 ? void 0 : _g.removeSessionKeys());
|
|
195
|
+
yield ((_h = wallet === null || wallet === void 0 ? void 0 : wallet.connector) === null || _h === void 0 ? void 0 : _h.createOrRestoreSession({
|
|
201
196
|
ignoreRestore: true,
|
|
202
197
|
}));
|
|
203
198
|
}
|
|
@@ -218,7 +213,7 @@ const EmbeddedRevealView = ({ exportPrivateKey, isPromptForExport = false, }) =>
|
|
|
218
213
|
wallet: wallet,
|
|
219
214
|
});
|
|
220
215
|
}
|
|
221
|
-
catch (
|
|
216
|
+
catch (_k) {
|
|
222
217
|
return undefined;
|
|
223
218
|
}
|
|
224
219
|
}
|
|
@@ -255,44 +250,6 @@ const EmbeddedRevealView = ({ exportPrivateKey, isPromptForExport = false, }) =>
|
|
|
255
250
|
setShowAuthFlow(false);
|
|
256
251
|
setDynamicWidgetView('send-balance');
|
|
257
252
|
}, className: 'embedded-reveal-view__zerodev-warning__link-button', children: jsx(Typography, { variant: 'body_normal', weight: 'regular', color: 'primary', className: 'underline', copykey: 'dyn_embedded_reveal.aa_warning.button', children: t('dyn_embedded_reveal.aa_warning.button') }) })] })] })), jsx("div", { className: 'embedded-reveal-view__body__description', children: !(!isLoading && data && !error) && (jsx("div", { className: 'embedded-reveal-view__header', children: jsx("div", { className: 'embedded-reveal-view__header__hero', children: jsx(SvgExportEmbeddedHero, {}) }) })) })] }));
|
|
258
|
-
useEffect(() => {
|
|
259
|
-
var _a;
|
|
260
|
-
if (((_a = iframeContainerRef === null || iframeContainerRef === void 0 ? void 0 : iframeContainerRef.current) === null || _a === void 0 ? void 0 : _a.children) && data) {
|
|
261
|
-
// eslint-disable-next-line prefer-destructuring
|
|
262
|
-
const iframeElement = iframeContainerRef.current.children[0];
|
|
263
|
-
let height = '88px';
|
|
264
|
-
let minHeight = '88px';
|
|
265
|
-
// Determine height based on wallet type and other conditions
|
|
266
|
-
if (!isTurnkeyHDWallet || exportPrivateKey) {
|
|
267
|
-
if (isSolWallet) {
|
|
268
|
-
height = '140px';
|
|
269
|
-
minHeight = '140px';
|
|
270
|
-
}
|
|
271
|
-
else if (isSuiWallet) {
|
|
272
|
-
height = '100px';
|
|
273
|
-
minHeight = '100px';
|
|
274
|
-
}
|
|
275
|
-
else {
|
|
276
|
-
height = '88px';
|
|
277
|
-
minHeight = '88px';
|
|
278
|
-
}
|
|
279
|
-
}
|
|
280
|
-
else {
|
|
281
|
-
// Turnkey HD wallet case
|
|
282
|
-
height = '120px';
|
|
283
|
-
minHeight = '120px';
|
|
284
|
-
}
|
|
285
|
-
iframeElement === null || iframeElement === void 0 ? void 0 : iframeElement.setAttribute('style', `height: ${height}; min-height: ${minHeight}; width: 100%; border: none; background: transparent; overflow: hidden;`);
|
|
286
|
-
}
|
|
287
|
-
}, [
|
|
288
|
-
iframeContainerRef,
|
|
289
|
-
data,
|
|
290
|
-
isTurnkeyHDWallet,
|
|
291
|
-
isWaasWallet,
|
|
292
|
-
exportPrivateKey,
|
|
293
|
-
isSuiWallet,
|
|
294
|
-
isSolWallet,
|
|
295
|
-
]);
|
|
296
253
|
useEffect(() => {
|
|
297
254
|
if (data) {
|
|
298
255
|
// Show skeleton first
|
|
@@ -339,14 +296,7 @@ const EmbeddedRevealView = ({ exportPrivateKey, isPromptForExport = false, }) =>
|
|
|
339
296
|
return `${baseClass} ${baseClass}--hidden`;
|
|
340
297
|
}
|
|
341
298
|
if (isWaasWallet) {
|
|
342
|
-
|
|
343
|
-
if (isSuiWallet) {
|
|
344
|
-
return `${waasClass} ${baseClass}--sui`;
|
|
345
|
-
}
|
|
346
|
-
if (isSolWallet) {
|
|
347
|
-
return `${waasClass} ${baseClass}--sol`;
|
|
348
|
-
}
|
|
349
|
-
return waasClass;
|
|
299
|
+
return `${baseClass} ${baseClass}--waas`;
|
|
350
300
|
}
|
|
351
301
|
return baseClass;
|
|
352
302
|
};
|
|
@@ -358,29 +308,10 @@ const EmbeddedRevealView = ({ exportPrivateKey, isPromptForExport = false, }) =>
|
|
|
358
308
|
if (showSkeleton) {
|
|
359
309
|
return `${baseClass} ${baseClass}--invisible`;
|
|
360
310
|
}
|
|
361
|
-
if (isWaasWallet) {
|
|
362
|
-
if (isSuiWallet) {
|
|
363
|
-
return `${baseClass} ${baseClass}--sui`;
|
|
364
|
-
}
|
|
365
|
-
if (isSolWallet) {
|
|
366
|
-
return `${baseClass} ${baseClass}--sol`;
|
|
367
|
-
}
|
|
368
|
-
}
|
|
369
311
|
return baseClass;
|
|
370
312
|
};
|
|
371
313
|
const getSkeletonLines = () => {
|
|
372
|
-
|
|
373
|
-
if (isWaasWallet) {
|
|
374
|
-
if (isSolWallet) {
|
|
375
|
-
lineCount = 7; // For 140px height
|
|
376
|
-
}
|
|
377
|
-
else if (isSuiWallet) {
|
|
378
|
-
lineCount = 5; // For 100px height
|
|
379
|
-
}
|
|
380
|
-
}
|
|
381
|
-
else if (isTurnkeyHDWallet && !exportPrivateKey) {
|
|
382
|
-
lineCount = 6; // For 120px height
|
|
383
|
-
}
|
|
314
|
+
const lineCount = 5; // Updated for 110px height
|
|
384
315
|
const lines = [];
|
|
385
316
|
for (let i = 0; i < lineCount; i++) {
|
|
386
317
|
const isLastLine = i === lineCount - 1;
|
|
@@ -394,11 +325,7 @@ const EmbeddedRevealView = ({ exportPrivateKey, isPromptForExport = false, }) =>
|
|
|
394
325
|
return (jsxs(Fragment, { children: [jsx(ModalHeader, { trailing: isPromptForExport ? null : closeButton, children: jsx(Typography, { as: 'h1', variant: 'title', color: 'primary', "data-testid": 'dynamic-auth-modal-heading', className: 'header__typography', children: title }) }), jsx("div", { className: 'embedded-reveal-view', children: jsxs("div", { className: getBodyClassName(), children: [(!isWaasWallet ||
|
|
395
326
|
!hasInjectedCredential ||
|
|
396
327
|
title !== credentialTitle) &&
|
|
397
|
-
contentHeader, isTurnkeyWallet || isWaasWallet ? (jsxs("div", { className: getCredentialContainerClassName(), children: [jsx("div", { id: iframeContainerId, className: getIframeContainerClassName(), ref: iframeContainerRef }), showSkeleton && data && (jsx("div", { className:
|
|
398
|
-
? ' embedded-reveal-view__body__skeleton-container--sui'
|
|
399
|
-
: isWaasWallet && isSolWallet
|
|
400
|
-
? ' embedded-reveal-view__body__skeleton-container--sol'
|
|
401
|
-
: ''}`, children: getSkeletonLines() }))] })) : null, hasInjectedCredential ? (jsxs(Fragment, { children: [jsx(TypographyButton, { buttonPadding: 'medium', buttonVariant: 'brand-primary', onClick: () => {
|
|
328
|
+
contentHeader, isTurnkeyWallet || isWaasWallet ? (jsxs("div", { className: getCredentialContainerClassName(), children: [jsx("div", { id: iframeContainerId, className: getIframeContainerClassName(), ref: iframeContainerRef }), showSkeleton && data && (jsx("div", { className: 'embedded-reveal-view__body__skeleton-container', children: getSkeletonLines() }))] })) : null, hasInjectedCredential ? (jsxs(Fragment, { children: [jsx(TypographyButton, { buttonPadding: 'medium', buttonVariant: 'brand-primary', onClick: () => {
|
|
402
329
|
setShowAuthFlow(false);
|
|
403
330
|
}, loading: isLoading, copykey: 'dyn_embedded_reveal.done_button_label', typographyProps: {
|
|
404
331
|
color: 'inherit',
|