@dynamic-labs/sdk-react-core 4.45.2 → 4.45.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 +16 -0
- package/package.cjs +1 -1
- package/package.js +1 -1
- package/package.json +12 -12
- package/src/functions.d.ts +1 -1
- package/src/lib/utils/hooks/useDynamicWaas/useDynamicWaas.cjs +129 -5
- package/src/lib/utils/hooks/useDynamicWaas/useDynamicWaas.d.ts +2 -0
- package/src/lib/utils/hooks/useDynamicWaas/useDynamicWaas.js +129 -5
- package/src/lib/utils/hooks/useSyncDynamicWaas/useSyncDynamicWaas.cjs +43 -1
- package/src/lib/utils/hooks/useSyncDynamicWaas/useSyncDynamicWaas.js +43 -1
- package/src/lib/utils/hooks/useUserAuth/useUserAuth.cjs +1 -53
- package/src/lib/utils/hooks/useUserAuth/useUserAuth.js +2 -54
- package/src/lib/views/SendBalanceView/SendBalanceView.cjs +1 -0
- package/src/lib/views/SendBalanceView/SendBalanceView.js +1 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,20 @@
|
|
|
1
1
|
|
|
2
|
+
### [4.45.3](https://github.com/dynamic-labs/dynamic-auth/compare/v4.45.2...v4.45.3) (2025-11-18)
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
### Features
|
|
6
|
+
|
|
7
|
+
* add trc20 token transfer to dynamic widget ([#9877](https://github.com/dynamic-labs/dynamic-auth/issues/9877)) ([4365102](https://github.com/dynamic-labs/dynamic-auth/commit/436510253436239d64d4f47b7d0532e65401c19d))
|
|
8
|
+
* add trc20 tokens to sendBalance ([#9873](https://github.com/dynamic-labs/dynamic-auth/issues/9873)) ([fec5e67](https://github.com/dynamic-labs/dynamic-auth/commit/fec5e6715f87fd6a3f7b2ca21c94e4f32ec86031))
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* don't allow mobileExperience override to redirect for wallets that don't support it ([#9865](https://github.com/dynamic-labs/dynamic-auth/issues/9865)) ([b34ada5](https://github.com/dynamic-labs/dynamic-auth/commit/b34ada5ac0450667bf33b3cf2ce13e5c16235cfc))
|
|
14
|
+
* **global-wallet:** validate the redirect url ([#9894](https://github.com/dynamic-labs/dynamic-auth/issues/9894)) ([4cf27b5](https://github.com/dynamic-labs/dynamic-auth/commit/4cf27b538da5a9d1da04160faad009880f15f175))
|
|
15
|
+
* temporarily skip Phantom account creation steps due to extension… ([#9893](https://github.com/dynamic-labs/dynamic-auth/issues/9893)) ([87f8a2e](https://github.com/dynamic-labs/dynamic-auth/commit/87f8a2e1185be09c255e7865980f02b13e916db4))
|
|
16
|
+
* wallet book is required console errors ([#9887](https://github.com/dynamic-labs/dynamic-auth/issues/9887)) ([417605d](https://github.com/dynamic-labs/dynamic-auth/commit/417605d605f70ee558dd550b1fb50c996f219b31))
|
|
17
|
+
|
|
2
18
|
### [4.45.2](https://github.com/dynamic-labs/dynamic-auth/compare/v4.45.1...v4.45.2) (2025-11-17)
|
|
3
19
|
|
|
4
20
|
|
package/package.cjs
CHANGED
package/package.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dynamic-labs/sdk-react-core",
|
|
3
|
-
"version": "4.45.
|
|
3
|
+
"version": "4.45.3",
|
|
4
4
|
"dependencies": {
|
|
5
5
|
"@dynamic-labs/sdk-api-core": "0.0.821",
|
|
6
6
|
"@dynamic-labs-sdk/client": "0.1.0-alpha.28",
|
|
@@ -15,17 +15,17 @@
|
|
|
15
15
|
"yup": "0.32.11",
|
|
16
16
|
"react-international-phone": "4.5.0",
|
|
17
17
|
"bs58": "5.0.0",
|
|
18
|
-
"@dynamic-labs/assert-package-version": "4.45.
|
|
19
|
-
"@dynamic-labs/iconic": "4.45.
|
|
20
|
-
"@dynamic-labs/locale": "4.45.
|
|
21
|
-
"@dynamic-labs/logger": "4.45.
|
|
22
|
-
"@dynamic-labs/multi-wallet": "4.45.
|
|
23
|
-
"@dynamic-labs/rpc-providers": "4.45.
|
|
24
|
-
"@dynamic-labs/store": "4.45.
|
|
25
|
-
"@dynamic-labs/types": "4.45.
|
|
26
|
-
"@dynamic-labs/utils": "4.45.
|
|
27
|
-
"@dynamic-labs/wallet-book": "4.45.
|
|
28
|
-
"@dynamic-labs/wallet-connector-core": "4.45.
|
|
18
|
+
"@dynamic-labs/assert-package-version": "4.45.3",
|
|
19
|
+
"@dynamic-labs/iconic": "4.45.3",
|
|
20
|
+
"@dynamic-labs/locale": "4.45.3",
|
|
21
|
+
"@dynamic-labs/logger": "4.45.3",
|
|
22
|
+
"@dynamic-labs/multi-wallet": "4.45.3",
|
|
23
|
+
"@dynamic-labs/rpc-providers": "4.45.3",
|
|
24
|
+
"@dynamic-labs/store": "4.45.3",
|
|
25
|
+
"@dynamic-labs/types": "4.45.3",
|
|
26
|
+
"@dynamic-labs/utils": "4.45.3",
|
|
27
|
+
"@dynamic-labs/wallet-book": "4.45.3",
|
|
28
|
+
"@dynamic-labs/wallet-connector-core": "4.45.3",
|
|
29
29
|
"eventemitter3": "5.0.1"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
package/src/functions.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { getProjectSettings } from './lib/client/extension';
|
|
1
|
+
export { getProjectSettings, getApiHeaders } from './lib/client/extension';
|
|
2
2
|
export { usingV3Wallets } from './lib/utils/functions/usingV3Wallets/usingV3Wallets';
|
|
@@ -135,7 +135,7 @@ const configWaasWalletConnector = ({ walletConnector, environmentId, apiBaseUrl,
|
|
|
135
135
|
return walletConnector;
|
|
136
136
|
};
|
|
137
137
|
const useDynamicWaas = () => {
|
|
138
|
-
var _a, _b, _c;
|
|
138
|
+
var _a, _b, _c, _d;
|
|
139
139
|
const { setShowAuthFlow, primaryWallet } = useInternalDynamicContext.useInternalDynamicContext();
|
|
140
140
|
const { addedWalletsIds, userWallets } = UserWalletsContext.useInternalUserWallets();
|
|
141
141
|
const user = useUser.useUser();
|
|
@@ -186,8 +186,130 @@ const useDynamicWaas = () => {
|
|
|
186
186
|
walletConnectorOptions,
|
|
187
187
|
environmentId,
|
|
188
188
|
apiBaseUrl,
|
|
189
|
+
getMfaToken,
|
|
190
|
+
getSignedSessionId,
|
|
189
191
|
relayUrl,
|
|
192
|
+
]);
|
|
193
|
+
const shouldInitializeWaas = React.useMemo(() => {
|
|
194
|
+
var _a;
|
|
195
|
+
const isUserAuthenticated = Boolean((user === null || user === void 0 ? void 0 : user.id) && (user === null || user === void 0 ? void 0 : user.sessionId));
|
|
196
|
+
const userHasVerifiedCredentials = Boolean((_a = user === null || user === void 0 ? void 0 : user.verifiedCredentials) === null || _a === void 0 ? void 0 : _a.length);
|
|
197
|
+
const isChainsEnabled = Boolean(enabledChainNames === null || enabledChainNames === void 0 ? void 0 : enabledChainNames.length);
|
|
198
|
+
const isWalletConnectorOptionsEnabled = Boolean(walletConnectorOptions.length);
|
|
199
|
+
return (isUserAuthenticated &&
|
|
200
|
+
userHasVerifiedCredentials &&
|
|
201
|
+
dynamicWaasIsEnabled &&
|
|
202
|
+
isChainsEnabled &&
|
|
203
|
+
isWalletConnectorOptionsEnabled);
|
|
204
|
+
}, [
|
|
205
|
+
user === null || user === void 0 ? void 0 : user.id,
|
|
206
|
+
user === null || user === void 0 ? void 0 : user.sessionId,
|
|
207
|
+
(_d = user === null || user === void 0 ? void 0 : user.verifiedCredentials) === null || _d === void 0 ? void 0 : _d.length,
|
|
208
|
+
dynamicWaasIsEnabled,
|
|
209
|
+
enabledChainNames === null || enabledChainNames === void 0 ? void 0 : enabledChainNames.length,
|
|
210
|
+
walletConnectorOptions.length,
|
|
211
|
+
]);
|
|
212
|
+
const initializeWaas = React.useCallback(() => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
213
|
+
if (!shouldInitializeWaas || !user)
|
|
214
|
+
return;
|
|
215
|
+
try {
|
|
216
|
+
const initializationStart = new Date().getTime();
|
|
217
|
+
const sessionSignature = yield getSignedSessionId();
|
|
218
|
+
yield Promise.all((enabledChainNames || []).map((chain) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
219
|
+
const walletConnector = getWaasWalletConnector(chain);
|
|
220
|
+
if (!walletConnector)
|
|
221
|
+
return;
|
|
222
|
+
// Filter for waas wallets on this chain
|
|
223
|
+
const waasWallets = user.verifiedCredentials.filter((credential) => {
|
|
224
|
+
var _a;
|
|
225
|
+
return credential.walletName === 'dynamicwaas' &&
|
|
226
|
+
credential.address &&
|
|
227
|
+
values.VerifiedCredentialNameToChainEnum[(_a = credential.chain) !== null && _a !== void 0 ? _a : ''] ===
|
|
228
|
+
walletConnector.connectedChain;
|
|
229
|
+
});
|
|
230
|
+
try {
|
|
231
|
+
// Initialize waas iframe
|
|
232
|
+
const client = yield walletConnector.getWaasWalletClient();
|
|
233
|
+
walletConnectorCore.logger.debug('[useDynamicWaas] initialized waas iframe');
|
|
234
|
+
const iframeInitializationEnd = new Date().getTime();
|
|
235
|
+
const iframeLoadingTime = iframeInitializationEnd - initializationStart;
|
|
236
|
+
walletConnectorCore.logger.instrument('Waas iframe initialized', {
|
|
237
|
+
chain,
|
|
238
|
+
end: iframeInitializationEnd,
|
|
239
|
+
environmentId: user.projectEnvironmentId,
|
|
240
|
+
key: 'waasIframeInitialized',
|
|
241
|
+
start: initializationStart,
|
|
242
|
+
time: iframeLoadingTime,
|
|
243
|
+
userId: user === null || user === void 0 ? void 0 : user.id,
|
|
244
|
+
});
|
|
245
|
+
// If user has waas wallets, restore keyshares to the iframe
|
|
246
|
+
if (waasWallets.length > 0) {
|
|
247
|
+
yield Promise.all(waasWallets
|
|
248
|
+
.filter((wallet) => wallet.address)
|
|
249
|
+
.map((wallet) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
250
|
+
try {
|
|
251
|
+
walletConnectorCore.logger.debug('[useDynamicWaas] restoring wallet keyshare', {
|
|
252
|
+
chain: wallet.chain,
|
|
253
|
+
sessionId: user.sessionId,
|
|
254
|
+
userId: user.id,
|
|
255
|
+
walletAddress: wallet.address,
|
|
256
|
+
});
|
|
257
|
+
const keyshareRestorationStart = new Date().getTime();
|
|
258
|
+
yield client.getWallet({
|
|
259
|
+
accountAddress: wallet.address,
|
|
260
|
+
signedSessionId: sessionSignature,
|
|
261
|
+
walletOperation: 'SIGN_MESSAGE',
|
|
262
|
+
});
|
|
263
|
+
const keyshareRestorationEnd = new Date().getTime();
|
|
264
|
+
const keyshareRestorationTime = keyshareRestorationEnd - keyshareRestorationStart;
|
|
265
|
+
const totalElapsedTime = keyshareRestorationEnd - initializationStart;
|
|
266
|
+
walletConnectorCore.logger.instrument('Waas wallet keyshare restored', {
|
|
267
|
+
accountAddress: wallet.address,
|
|
268
|
+
chain,
|
|
269
|
+
end: keyshareRestorationEnd,
|
|
270
|
+
environmentId: user.projectEnvironmentId,
|
|
271
|
+
key: 'waasWalletKeyshareRestored',
|
|
272
|
+
keyshareRestorationTime: keyshareRestorationTime,
|
|
273
|
+
start: initializationStart,
|
|
274
|
+
time: totalElapsedTime,
|
|
275
|
+
userId: user === null || user === void 0 ? void 0 : user.id,
|
|
276
|
+
});
|
|
277
|
+
}
|
|
278
|
+
catch (error) {
|
|
279
|
+
walletConnectorCore.logger.warn('[useDynamicWaas] Error restoring wallet keyshare', {
|
|
280
|
+
chain,
|
|
281
|
+
error,
|
|
282
|
+
sessionId: user.sessionId,
|
|
283
|
+
userId: user.id,
|
|
284
|
+
walletAddress: wallet.address,
|
|
285
|
+
});
|
|
286
|
+
}
|
|
287
|
+
})));
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
catch (error) {
|
|
291
|
+
walletConnectorCore.logger.warn('Error initializing waas wallet client', {
|
|
292
|
+
chain,
|
|
293
|
+
error,
|
|
294
|
+
sessionId: user.sessionId,
|
|
295
|
+
userId: user.id,
|
|
296
|
+
});
|
|
297
|
+
}
|
|
298
|
+
})));
|
|
299
|
+
}
|
|
300
|
+
catch (error) {
|
|
301
|
+
walletConnectorCore.logger.warn('Error initializing waas', {
|
|
302
|
+
error,
|
|
303
|
+
sessionId: user.sessionId,
|
|
304
|
+
userId: user.id,
|
|
305
|
+
});
|
|
306
|
+
}
|
|
307
|
+
}), [
|
|
308
|
+
enabledChainNames,
|
|
190
309
|
getSignedSessionId,
|
|
310
|
+
getWaasWalletConnector,
|
|
311
|
+
shouldInitializeWaas,
|
|
312
|
+
user,
|
|
191
313
|
]);
|
|
192
314
|
// If no chain names are provided, filter out chains that already have a wallet
|
|
193
315
|
// and make a wallet for each enabled chain
|
|
@@ -308,7 +430,7 @@ const useDynamicWaas = () => {
|
|
|
308
430
|
automaticEmbeddedWalletCreationForExternalEnabled,
|
|
309
431
|
enabledChainNames,
|
|
310
432
|
]);
|
|
311
|
-
const importPrivateKey = (
|
|
433
|
+
const importPrivateKey = (_e) => _tslib.__awaiter(void 0, [_e], void 0, function* ({ chainName, privateKey, }) {
|
|
312
434
|
const walletConnector = getWaasWalletConnector(chainName);
|
|
313
435
|
if (!walletConnector)
|
|
314
436
|
return;
|
|
@@ -318,7 +440,7 @@ const useDynamicWaas = () => {
|
|
|
318
440
|
});
|
|
319
441
|
yield refresh();
|
|
320
442
|
});
|
|
321
|
-
const upgradeToDynamicWaas = React.useCallback((
|
|
443
|
+
const upgradeToDynamicWaas = React.useCallback((_f) => _tslib.__awaiter(void 0, [_f], void 0, function* ({ privateKey, wallet, }) {
|
|
322
444
|
isUpgrading.current = true;
|
|
323
445
|
if (!primaryWallet) {
|
|
324
446
|
throw new utils.DynamicError('Primary wallet not found');
|
|
@@ -367,14 +489,14 @@ const useDynamicWaas = () => {
|
|
|
367
489
|
}), [environmentId, getWaasWalletConnector, primaryWallet, refresh]);
|
|
368
490
|
const getWaasWallets = React.useCallback(() => userWallets.filter((w) => w.key === 'dynamicwaas'), [userWallets]);
|
|
369
491
|
const processSignOnWalletSettings = React.useCallback(() => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
370
|
-
var
|
|
492
|
+
var _g;
|
|
371
493
|
if (!(user === null || user === void 0 ? void 0 : user.verifiedCredentials)) {
|
|
372
494
|
return;
|
|
373
495
|
}
|
|
374
496
|
const waasWallets = user.verifiedCredentials.filter((vc) => { var _a; return vc.walletName === 'dynamicwaas' && ((_a = vc.walletProperties) === null || _a === void 0 ? void 0 : _a.settings); });
|
|
375
497
|
for (const wallet of waasWallets) {
|
|
376
498
|
try {
|
|
377
|
-
const settings = (
|
|
499
|
+
const settings = (_g = wallet.walletProperties) === null || _g === void 0 ? void 0 : _g.settings;
|
|
378
500
|
const { address, chain } = wallet;
|
|
379
501
|
if (!settings || !address || !chain) {
|
|
380
502
|
continue;
|
|
@@ -430,9 +552,11 @@ const useDynamicWaas = () => {
|
|
|
430
552
|
getWaasWalletConnector,
|
|
431
553
|
getWaasWallets,
|
|
432
554
|
importPrivateKey,
|
|
555
|
+
initializeWaas,
|
|
433
556
|
needsAutoCreateWalletChains,
|
|
434
557
|
needsSettingsProcessing,
|
|
435
558
|
processSignOnWalletSettings,
|
|
559
|
+
shouldInitializeWaas,
|
|
436
560
|
upgradeToDynamicWaas,
|
|
437
561
|
};
|
|
438
562
|
};
|
|
@@ -25,9 +25,11 @@ export declare const useDynamicWaas: () => {
|
|
|
25
25
|
chainName: ChainEnum;
|
|
26
26
|
privateKey: string;
|
|
27
27
|
}) => Promise<void>;
|
|
28
|
+
initializeWaas: () => Promise<void>;
|
|
28
29
|
needsAutoCreateWalletChains: ChainEnum[];
|
|
29
30
|
needsSettingsProcessing: boolean;
|
|
30
31
|
processSignOnWalletSettings: () => Promise<void>;
|
|
32
|
+
shouldInitializeWaas: boolean;
|
|
31
33
|
upgradeToDynamicWaas: ({ privateKey, wallet, }: {
|
|
32
34
|
privateKey: string;
|
|
33
35
|
wallet: Wallet<WalletConnectorCore.WalletConnector>;
|
|
@@ -131,7 +131,7 @@ const configWaasWalletConnector = ({ walletConnector, environmentId, apiBaseUrl,
|
|
|
131
131
|
return walletConnector;
|
|
132
132
|
};
|
|
133
133
|
const useDynamicWaas = () => {
|
|
134
|
-
var _a, _b, _c;
|
|
134
|
+
var _a, _b, _c, _d;
|
|
135
135
|
const { setShowAuthFlow, primaryWallet } = useInternalDynamicContext();
|
|
136
136
|
const { addedWalletsIds, userWallets } = useInternalUserWallets();
|
|
137
137
|
const user = useUser();
|
|
@@ -182,8 +182,130 @@ const useDynamicWaas = () => {
|
|
|
182
182
|
walletConnectorOptions,
|
|
183
183
|
environmentId,
|
|
184
184
|
apiBaseUrl,
|
|
185
|
+
getMfaToken,
|
|
186
|
+
getSignedSessionId,
|
|
185
187
|
relayUrl,
|
|
188
|
+
]);
|
|
189
|
+
const shouldInitializeWaas = useMemo(() => {
|
|
190
|
+
var _a;
|
|
191
|
+
const isUserAuthenticated = Boolean((user === null || user === void 0 ? void 0 : user.id) && (user === null || user === void 0 ? void 0 : user.sessionId));
|
|
192
|
+
const userHasVerifiedCredentials = Boolean((_a = user === null || user === void 0 ? void 0 : user.verifiedCredentials) === null || _a === void 0 ? void 0 : _a.length);
|
|
193
|
+
const isChainsEnabled = Boolean(enabledChainNames === null || enabledChainNames === void 0 ? void 0 : enabledChainNames.length);
|
|
194
|
+
const isWalletConnectorOptionsEnabled = Boolean(walletConnectorOptions.length);
|
|
195
|
+
return (isUserAuthenticated &&
|
|
196
|
+
userHasVerifiedCredentials &&
|
|
197
|
+
dynamicWaasIsEnabled &&
|
|
198
|
+
isChainsEnabled &&
|
|
199
|
+
isWalletConnectorOptionsEnabled);
|
|
200
|
+
}, [
|
|
201
|
+
user === null || user === void 0 ? void 0 : user.id,
|
|
202
|
+
user === null || user === void 0 ? void 0 : user.sessionId,
|
|
203
|
+
(_d = user === null || user === void 0 ? void 0 : user.verifiedCredentials) === null || _d === void 0 ? void 0 : _d.length,
|
|
204
|
+
dynamicWaasIsEnabled,
|
|
205
|
+
enabledChainNames === null || enabledChainNames === void 0 ? void 0 : enabledChainNames.length,
|
|
206
|
+
walletConnectorOptions.length,
|
|
207
|
+
]);
|
|
208
|
+
const initializeWaas = useCallback(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
209
|
+
if (!shouldInitializeWaas || !user)
|
|
210
|
+
return;
|
|
211
|
+
try {
|
|
212
|
+
const initializationStart = new Date().getTime();
|
|
213
|
+
const sessionSignature = yield getSignedSessionId();
|
|
214
|
+
yield Promise.all((enabledChainNames || []).map((chain) => __awaiter(void 0, void 0, void 0, function* () {
|
|
215
|
+
const walletConnector = getWaasWalletConnector(chain);
|
|
216
|
+
if (!walletConnector)
|
|
217
|
+
return;
|
|
218
|
+
// Filter for waas wallets on this chain
|
|
219
|
+
const waasWallets = user.verifiedCredentials.filter((credential) => {
|
|
220
|
+
var _a;
|
|
221
|
+
return credential.walletName === 'dynamicwaas' &&
|
|
222
|
+
credential.address &&
|
|
223
|
+
VerifiedCredentialNameToChainEnum[(_a = credential.chain) !== null && _a !== void 0 ? _a : ''] ===
|
|
224
|
+
walletConnector.connectedChain;
|
|
225
|
+
});
|
|
226
|
+
try {
|
|
227
|
+
// Initialize waas iframe
|
|
228
|
+
const client = yield walletConnector.getWaasWalletClient();
|
|
229
|
+
logger.debug('[useDynamicWaas] initialized waas iframe');
|
|
230
|
+
const iframeInitializationEnd = new Date().getTime();
|
|
231
|
+
const iframeLoadingTime = iframeInitializationEnd - initializationStart;
|
|
232
|
+
logger.instrument('Waas iframe initialized', {
|
|
233
|
+
chain,
|
|
234
|
+
end: iframeInitializationEnd,
|
|
235
|
+
environmentId: user.projectEnvironmentId,
|
|
236
|
+
key: 'waasIframeInitialized',
|
|
237
|
+
start: initializationStart,
|
|
238
|
+
time: iframeLoadingTime,
|
|
239
|
+
userId: user === null || user === void 0 ? void 0 : user.id,
|
|
240
|
+
});
|
|
241
|
+
// If user has waas wallets, restore keyshares to the iframe
|
|
242
|
+
if (waasWallets.length > 0) {
|
|
243
|
+
yield Promise.all(waasWallets
|
|
244
|
+
.filter((wallet) => wallet.address)
|
|
245
|
+
.map((wallet) => __awaiter(void 0, void 0, void 0, function* () {
|
|
246
|
+
try {
|
|
247
|
+
logger.debug('[useDynamicWaas] restoring wallet keyshare', {
|
|
248
|
+
chain: wallet.chain,
|
|
249
|
+
sessionId: user.sessionId,
|
|
250
|
+
userId: user.id,
|
|
251
|
+
walletAddress: wallet.address,
|
|
252
|
+
});
|
|
253
|
+
const keyshareRestorationStart = new Date().getTime();
|
|
254
|
+
yield client.getWallet({
|
|
255
|
+
accountAddress: wallet.address,
|
|
256
|
+
signedSessionId: sessionSignature,
|
|
257
|
+
walletOperation: 'SIGN_MESSAGE',
|
|
258
|
+
});
|
|
259
|
+
const keyshareRestorationEnd = new Date().getTime();
|
|
260
|
+
const keyshareRestorationTime = keyshareRestorationEnd - keyshareRestorationStart;
|
|
261
|
+
const totalElapsedTime = keyshareRestorationEnd - initializationStart;
|
|
262
|
+
logger.instrument('Waas wallet keyshare restored', {
|
|
263
|
+
accountAddress: wallet.address,
|
|
264
|
+
chain,
|
|
265
|
+
end: keyshareRestorationEnd,
|
|
266
|
+
environmentId: user.projectEnvironmentId,
|
|
267
|
+
key: 'waasWalletKeyshareRestored',
|
|
268
|
+
keyshareRestorationTime: keyshareRestorationTime,
|
|
269
|
+
start: initializationStart,
|
|
270
|
+
time: totalElapsedTime,
|
|
271
|
+
userId: user === null || user === void 0 ? void 0 : user.id,
|
|
272
|
+
});
|
|
273
|
+
}
|
|
274
|
+
catch (error) {
|
|
275
|
+
logger.warn('[useDynamicWaas] Error restoring wallet keyshare', {
|
|
276
|
+
chain,
|
|
277
|
+
error,
|
|
278
|
+
sessionId: user.sessionId,
|
|
279
|
+
userId: user.id,
|
|
280
|
+
walletAddress: wallet.address,
|
|
281
|
+
});
|
|
282
|
+
}
|
|
283
|
+
})));
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
catch (error) {
|
|
287
|
+
logger.warn('Error initializing waas wallet client', {
|
|
288
|
+
chain,
|
|
289
|
+
error,
|
|
290
|
+
sessionId: user.sessionId,
|
|
291
|
+
userId: user.id,
|
|
292
|
+
});
|
|
293
|
+
}
|
|
294
|
+
})));
|
|
295
|
+
}
|
|
296
|
+
catch (error) {
|
|
297
|
+
logger.warn('Error initializing waas', {
|
|
298
|
+
error,
|
|
299
|
+
sessionId: user.sessionId,
|
|
300
|
+
userId: user.id,
|
|
301
|
+
});
|
|
302
|
+
}
|
|
303
|
+
}), [
|
|
304
|
+
enabledChainNames,
|
|
186
305
|
getSignedSessionId,
|
|
306
|
+
getWaasWalletConnector,
|
|
307
|
+
shouldInitializeWaas,
|
|
308
|
+
user,
|
|
187
309
|
]);
|
|
188
310
|
// If no chain names are provided, filter out chains that already have a wallet
|
|
189
311
|
// and make a wallet for each enabled chain
|
|
@@ -304,7 +426,7 @@ const useDynamicWaas = () => {
|
|
|
304
426
|
automaticEmbeddedWalletCreationForExternalEnabled,
|
|
305
427
|
enabledChainNames,
|
|
306
428
|
]);
|
|
307
|
-
const importPrivateKey = (
|
|
429
|
+
const importPrivateKey = (_e) => __awaiter(void 0, [_e], void 0, function* ({ chainName, privateKey, }) {
|
|
308
430
|
const walletConnector = getWaasWalletConnector(chainName);
|
|
309
431
|
if (!walletConnector)
|
|
310
432
|
return;
|
|
@@ -314,7 +436,7 @@ const useDynamicWaas = () => {
|
|
|
314
436
|
});
|
|
315
437
|
yield refresh();
|
|
316
438
|
});
|
|
317
|
-
const upgradeToDynamicWaas = useCallback((
|
|
439
|
+
const upgradeToDynamicWaas = useCallback((_f) => __awaiter(void 0, [_f], void 0, function* ({ privateKey, wallet, }) {
|
|
318
440
|
isUpgrading.current = true;
|
|
319
441
|
if (!primaryWallet) {
|
|
320
442
|
throw new DynamicError('Primary wallet not found');
|
|
@@ -363,14 +485,14 @@ const useDynamicWaas = () => {
|
|
|
363
485
|
}), [environmentId, getWaasWalletConnector, primaryWallet, refresh]);
|
|
364
486
|
const getWaasWallets = useCallback(() => userWallets.filter((w) => w.key === 'dynamicwaas'), [userWallets]);
|
|
365
487
|
const processSignOnWalletSettings = useCallback(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
366
|
-
var
|
|
488
|
+
var _g;
|
|
367
489
|
if (!(user === null || user === void 0 ? void 0 : user.verifiedCredentials)) {
|
|
368
490
|
return;
|
|
369
491
|
}
|
|
370
492
|
const waasWallets = user.verifiedCredentials.filter((vc) => { var _a; return vc.walletName === 'dynamicwaas' && ((_a = vc.walletProperties) === null || _a === void 0 ? void 0 : _a.settings); });
|
|
371
493
|
for (const wallet of waasWallets) {
|
|
372
494
|
try {
|
|
373
|
-
const settings = (
|
|
495
|
+
const settings = (_g = wallet.walletProperties) === null || _g === void 0 ? void 0 : _g.settings;
|
|
374
496
|
const { address, chain } = wallet;
|
|
375
497
|
if (!settings || !address || !chain) {
|
|
376
498
|
continue;
|
|
@@ -426,9 +548,11 @@ const useDynamicWaas = () => {
|
|
|
426
548
|
getWaasWalletConnector,
|
|
427
549
|
getWaasWallets,
|
|
428
550
|
importPrivateKey,
|
|
551
|
+
initializeWaas,
|
|
429
552
|
needsAutoCreateWalletChains,
|
|
430
553
|
needsSettingsProcessing,
|
|
431
554
|
processSignOnWalletSettings,
|
|
555
|
+
shouldInitializeWaas,
|
|
432
556
|
upgradeToDynamicWaas,
|
|
433
557
|
};
|
|
434
558
|
};
|
|
@@ -206,13 +206,17 @@ const useWalletSettingsProcessor = () => {
|
|
|
206
206
|
* The hook ensures wallet creation only happens once per session until logout.
|
|
207
207
|
*/
|
|
208
208
|
const useSyncDynamicWaas = () => {
|
|
209
|
-
const { needsAutoCreateWalletChains, needsSettingsProcessing } = useDynamicWaas.useDynamicWaas();
|
|
209
|
+
const { needsAutoCreateWalletChains, needsSettingsProcessing, initializeWaas, shouldInitializeWaas, } = useDynamicWaas.useDynamicWaas();
|
|
210
210
|
const validateWalletCreation = useWalletCreationValidation();
|
|
211
211
|
const { mutate: createWallets, isLoading: isCreatingWallets } = useWalletCreation();
|
|
212
212
|
const { mutate: processSettings, isLoading: isProcessingSettings } = useWalletSettingsProcessor();
|
|
213
213
|
const { initDelegationProcess, shouldPromptWalletDelegation } = useWalletDelegation.useWalletDelegation();
|
|
214
|
+
const user = useOnboardingCompleteUser.useOnboardingCompleteUser();
|
|
214
215
|
const triggeredCreate = React.useRef(false);
|
|
215
216
|
const triggeredSettingsProcessing = React.useRef(false);
|
|
217
|
+
const hasWaasInitializedRef = React.useRef(false);
|
|
218
|
+
const sessionIdRef = React.useRef(undefined);
|
|
219
|
+
const initializingWaasRef = React.useRef(false);
|
|
216
220
|
useDynamicEvents.useInternalDynamicEvents('logout', () => {
|
|
217
221
|
triggeredCreate.current = false;
|
|
218
222
|
triggeredSettingsProcessing.current = false;
|
|
@@ -262,6 +266,44 @@ const useSyncDynamicWaas = () => {
|
|
|
262
266
|
// Set the flag immediately to prevent duplicate calls
|
|
263
267
|
triggeredCreate.current = true;
|
|
264
268
|
}, [shouldCreateWallets, needsAutoCreateWalletChains, createWallets]);
|
|
269
|
+
// Initialize waas iframe when user is authenticated
|
|
270
|
+
// This handles both page reload (user already authenticated) and fresh authentication
|
|
271
|
+
React.useEffect(() => {
|
|
272
|
+
// handle logout case where user is logged out but session id is still valid
|
|
273
|
+
if (sessionIdRef.current && !(user === null || user === void 0 ? void 0 : user.sessionId)) {
|
|
274
|
+
sessionIdRef.current = undefined;
|
|
275
|
+
hasWaasInitializedRef.current = false;
|
|
276
|
+
initializingWaasRef.current = false;
|
|
277
|
+
}
|
|
278
|
+
if (shouldInitializeWaas && (user === null || user === void 0 ? void 0 : user.sessionId)) {
|
|
279
|
+
const { sessionId, id: userId } = user;
|
|
280
|
+
const shouldInitialize = !initializingWaasRef.current &&
|
|
281
|
+
(!hasWaasInitializedRef.current || sessionIdRef.current !== sessionId);
|
|
282
|
+
if (shouldInitialize) {
|
|
283
|
+
const isSessionIdChanged = sessionIdRef.current !== sessionId;
|
|
284
|
+
logger.logger.debug(isSessionIdChanged
|
|
285
|
+
? '[useSyncDynamicWaas] session id changed, initializing waas'
|
|
286
|
+
: '[useSyncDynamicWaas] waas not initialized, initializing waas');
|
|
287
|
+
initializingWaasRef.current = true;
|
|
288
|
+
initializeWaas()
|
|
289
|
+
.then(() => {
|
|
290
|
+
logger.logger.debug('[useSyncDynamicWaas] waas initialized');
|
|
291
|
+
hasWaasInitializedRef.current = true;
|
|
292
|
+
sessionIdRef.current = sessionId;
|
|
293
|
+
})
|
|
294
|
+
.catch((error) => {
|
|
295
|
+
logger.logger.warn('[useSyncDynamicWaas] Error initializing waas', {
|
|
296
|
+
error,
|
|
297
|
+
sessionId,
|
|
298
|
+
userId,
|
|
299
|
+
});
|
|
300
|
+
})
|
|
301
|
+
.finally(() => {
|
|
302
|
+
initializingWaasRef.current = false;
|
|
303
|
+
});
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
}, [initializeWaas, shouldInitializeWaas, user]);
|
|
265
307
|
React.useEffect(() => {
|
|
266
308
|
if (shouldCreateWallets()) {
|
|
267
309
|
handleWalletCreation();
|
|
@@ -202,13 +202,17 @@ const useWalletSettingsProcessor = () => {
|
|
|
202
202
|
* The hook ensures wallet creation only happens once per session until logout.
|
|
203
203
|
*/
|
|
204
204
|
const useSyncDynamicWaas = () => {
|
|
205
|
-
const { needsAutoCreateWalletChains, needsSettingsProcessing } = useDynamicWaas();
|
|
205
|
+
const { needsAutoCreateWalletChains, needsSettingsProcessing, initializeWaas, shouldInitializeWaas, } = useDynamicWaas();
|
|
206
206
|
const validateWalletCreation = useWalletCreationValidation();
|
|
207
207
|
const { mutate: createWallets, isLoading: isCreatingWallets } = useWalletCreation();
|
|
208
208
|
const { mutate: processSettings, isLoading: isProcessingSettings } = useWalletSettingsProcessor();
|
|
209
209
|
const { initDelegationProcess, shouldPromptWalletDelegation } = useWalletDelegation();
|
|
210
|
+
const user = useOnboardingCompleteUser();
|
|
210
211
|
const triggeredCreate = useRef(false);
|
|
211
212
|
const triggeredSettingsProcessing = useRef(false);
|
|
213
|
+
const hasWaasInitializedRef = useRef(false);
|
|
214
|
+
const sessionIdRef = useRef(undefined);
|
|
215
|
+
const initializingWaasRef = useRef(false);
|
|
212
216
|
useInternalDynamicEvents('logout', () => {
|
|
213
217
|
triggeredCreate.current = false;
|
|
214
218
|
triggeredSettingsProcessing.current = false;
|
|
@@ -258,6 +262,44 @@ const useSyncDynamicWaas = () => {
|
|
|
258
262
|
// Set the flag immediately to prevent duplicate calls
|
|
259
263
|
triggeredCreate.current = true;
|
|
260
264
|
}, [shouldCreateWallets, needsAutoCreateWalletChains, createWallets]);
|
|
265
|
+
// Initialize waas iframe when user is authenticated
|
|
266
|
+
// This handles both page reload (user already authenticated) and fresh authentication
|
|
267
|
+
useEffect(() => {
|
|
268
|
+
// handle logout case where user is logged out but session id is still valid
|
|
269
|
+
if (sessionIdRef.current && !(user === null || user === void 0 ? void 0 : user.sessionId)) {
|
|
270
|
+
sessionIdRef.current = undefined;
|
|
271
|
+
hasWaasInitializedRef.current = false;
|
|
272
|
+
initializingWaasRef.current = false;
|
|
273
|
+
}
|
|
274
|
+
if (shouldInitializeWaas && (user === null || user === void 0 ? void 0 : user.sessionId)) {
|
|
275
|
+
const { sessionId, id: userId } = user;
|
|
276
|
+
const shouldInitialize = !initializingWaasRef.current &&
|
|
277
|
+
(!hasWaasInitializedRef.current || sessionIdRef.current !== sessionId);
|
|
278
|
+
if (shouldInitialize) {
|
|
279
|
+
const isSessionIdChanged = sessionIdRef.current !== sessionId;
|
|
280
|
+
logger.debug(isSessionIdChanged
|
|
281
|
+
? '[useSyncDynamicWaas] session id changed, initializing waas'
|
|
282
|
+
: '[useSyncDynamicWaas] waas not initialized, initializing waas');
|
|
283
|
+
initializingWaasRef.current = true;
|
|
284
|
+
initializeWaas()
|
|
285
|
+
.then(() => {
|
|
286
|
+
logger.debug('[useSyncDynamicWaas] waas initialized');
|
|
287
|
+
hasWaasInitializedRef.current = true;
|
|
288
|
+
sessionIdRef.current = sessionId;
|
|
289
|
+
})
|
|
290
|
+
.catch((error) => {
|
|
291
|
+
logger.warn('[useSyncDynamicWaas] Error initializing waas', {
|
|
292
|
+
error,
|
|
293
|
+
sessionId,
|
|
294
|
+
userId,
|
|
295
|
+
});
|
|
296
|
+
})
|
|
297
|
+
.finally(() => {
|
|
298
|
+
initializingWaasRef.current = false;
|
|
299
|
+
});
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
}, [initializeWaas, shouldInitializeWaas, user]);
|
|
261
303
|
useEffect(() => {
|
|
262
304
|
if (shouldCreateWallets()) {
|
|
263
305
|
handleWalletCreation();
|
|
@@ -11,7 +11,7 @@ var utils = require('@dynamic-labs/utils');
|
|
|
11
11
|
require('@dynamic-labs-sdk/client/core');
|
|
12
12
|
require('../../../client/client.cjs');
|
|
13
13
|
require('../../../config/ApiEndpoint.cjs');
|
|
14
|
-
|
|
14
|
+
require('../../constants/values.cjs');
|
|
15
15
|
require('@dynamic-labs/multi-wallet');
|
|
16
16
|
require('react-international-phone');
|
|
17
17
|
require('../../constants/colors.cjs');
|
|
@@ -28,7 +28,6 @@ require('@dynamic-labs/locale');
|
|
|
28
28
|
require('../../../store/state/dynamicContextProps/dynamicContextProps.cjs');
|
|
29
29
|
require('../../../store/state/primaryWalletId/primaryWalletId.cjs');
|
|
30
30
|
require('../../../store/state/connectedWalletsInfo/connectedWalletsInfo.cjs');
|
|
31
|
-
var getClientSessionKeys = require('../../functions/clientSessionKeys/getClientSessionKeys.cjs');
|
|
32
31
|
require('../../../events/dynamicEvents.cjs');
|
|
33
32
|
var storeTokenAndUser = require('../../../client/extension/storeTokenAndUser/storeTokenAndUser.cjs');
|
|
34
33
|
var AccessDeniedContext = require('../../../context/AccessDeniedContext/AccessDeniedContext.cjs');
|
|
@@ -118,50 +117,6 @@ const useUserAuth = ({ authMethod, }) => {
|
|
|
118
117
|
const handleAuthenticatedUser = useHandleAuthenticatedUser.useHandleAuthenticatedUser();
|
|
119
118
|
const { shouldAutoCreateEmbeddedWallet, shouldPromptForKeyExport, embeddedWalletSettingVersion, } = useEmbeddedWallet.useEmbeddedWallet();
|
|
120
119
|
const isVerifyResponse = (response) => response.user;
|
|
121
|
-
const handleWaasInitialization = React.useCallback((verifiedUser) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
122
|
-
const sessionSignatureResult = yield getClientSessionKeys.getClientSessionSignature({
|
|
123
|
-
sessionId: verifiedUser === null || verifiedUser === void 0 ? void 0 : verifiedUser.sessionId,
|
|
124
|
-
});
|
|
125
|
-
const dynamicWaasConnectors = walletConnectorOptions.filter((walletOption) => walletOption.walletConnector.key === 'dynamicwaas');
|
|
126
|
-
dynamicWaasConnectors.forEach((walletOption) => {
|
|
127
|
-
var _a;
|
|
128
|
-
const walletAddress = (_a = verifiedUser.verifiedCredentials.find((credential) => {
|
|
129
|
-
var _a;
|
|
130
|
-
return values.VerifiedCredentialNameToChainEnum[(_a = credential.chain) !== null && _a !== void 0 ? _a : ''] ===
|
|
131
|
-
walletOption.walletConnector.connectedChain;
|
|
132
|
-
})) === null || _a === void 0 ? void 0 : _a.address;
|
|
133
|
-
if (walletAddress) {
|
|
134
|
-
// Create the waas iframe
|
|
135
|
-
walletOption.walletConnector
|
|
136
|
-
.getWaasWalletClient()
|
|
137
|
-
.then((client) => {
|
|
138
|
-
// Restore the wallet keyshare to the iframe
|
|
139
|
-
client
|
|
140
|
-
.getWallet({
|
|
141
|
-
accountAddress: walletAddress,
|
|
142
|
-
signedSessionId: sessionSignatureResult.sessionSignature,
|
|
143
|
-
walletOperation: 'SIGN_MESSAGE',
|
|
144
|
-
})
|
|
145
|
-
.catch((error) => {
|
|
146
|
-
logger.logger.error('Error restoring wallet keyshare', {
|
|
147
|
-
error,
|
|
148
|
-
sessionId: verifiedUser.sessionId,
|
|
149
|
-
userId: verifiedUser.userId,
|
|
150
|
-
walletAddress,
|
|
151
|
-
});
|
|
152
|
-
});
|
|
153
|
-
})
|
|
154
|
-
.catch((error) => {
|
|
155
|
-
logger.logger.error('Error initializing waas wallet client', {
|
|
156
|
-
error,
|
|
157
|
-
sessionId: verifiedUser.sessionId,
|
|
158
|
-
userId: verifiedUser.userId,
|
|
159
|
-
walletAddress,
|
|
160
|
-
});
|
|
161
|
-
});
|
|
162
|
-
}
|
|
163
|
-
});
|
|
164
|
-
}), [walletConnectorOptions]);
|
|
165
120
|
const cancelAuth = React.useCallback(() => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
166
121
|
logger.logger.debug('cancelAuth', { authMethod });
|
|
167
122
|
yield handleLogOut();
|
|
@@ -266,12 +221,6 @@ const useUserAuth = ({ authMethod, }) => {
|
|
|
266
221
|
}
|
|
267
222
|
if (isSignIn) {
|
|
268
223
|
setCallback('authSuccess');
|
|
269
|
-
const hasWaasWallets = verifiedUser.verifiedCredentials.some((vc) => vc.walletProvider === sdkApiCore.WalletProviderEnum.EmbeddedWallet &&
|
|
270
|
-
vc.walletName === 'dynamicwaas');
|
|
271
|
-
if (hasWaasWallets) {
|
|
272
|
-
// Eagerly initialize waas wallets
|
|
273
|
-
yield handleWaasInitialization(verifiedUser);
|
|
274
|
-
}
|
|
275
224
|
}
|
|
276
225
|
const walletVersion = embeddedWalletSettingVersion();
|
|
277
226
|
if (walletVersion === sdkApiCore.EmbeddedWalletVersionEnum.V1 &&
|
|
@@ -301,7 +250,6 @@ const useUserAuth = ({ authMethod, }) => {
|
|
|
301
250
|
embeddedWalletSettingVersion,
|
|
302
251
|
handleAuthError,
|
|
303
252
|
handleAuthenticatedUser,
|
|
304
|
-
handleWaasInitialization,
|
|
305
253
|
setCallback,
|
|
306
254
|
setLoading,
|
|
307
255
|
setMultiWalletWidgetState,
|
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
import { __awaiter } from '../../../../../_virtual/_tslib.js';
|
|
3
3
|
import { useCallback } from 'react';
|
|
4
4
|
import { MfaInvalidOtpError, MfaRateLimitedError, SandboxMaximumThresholdReachedError as SandboxMaximumThresholdReachedError$1 } from '@dynamic-labs-sdk/client';
|
|
5
|
-
import {
|
|
5
|
+
import { EmbeddedWalletVersionEnum, MfaBackupCodeAcknowledgement } from '@dynamic-labs/sdk-api-core';
|
|
6
6
|
import { EmailAlreadyExistsError, CustomFieldNotUniqueError, UsernameAlreadyExistsError, TooManyEmailVerificationsError, InvalidPhoneNumberError, NoAccessError, AccountExistsError, SandboxMaximumThresholdReachedError, UserHasAccountWithEmailError, DynamicError, sleep } from '@dynamic-labs/utils';
|
|
7
7
|
import '@dynamic-labs-sdk/client/core';
|
|
8
8
|
import '../../../client/client.js';
|
|
9
9
|
import '../../../config/ApiEndpoint.js';
|
|
10
|
-
import
|
|
10
|
+
import '../../constants/values.js';
|
|
11
11
|
import '@dynamic-labs/multi-wallet';
|
|
12
12
|
import 'react-international-phone';
|
|
13
13
|
import '../../constants/colors.js';
|
|
@@ -24,7 +24,6 @@ import '@dynamic-labs/locale';
|
|
|
24
24
|
import '../../../store/state/dynamicContextProps/dynamicContextProps.js';
|
|
25
25
|
import '../../../store/state/primaryWalletId/primaryWalletId.js';
|
|
26
26
|
import '../../../store/state/connectedWalletsInfo/connectedWalletsInfo.js';
|
|
27
|
-
import { getClientSessionSignature } from '../../functions/clientSessionKeys/getClientSessionKeys.js';
|
|
28
27
|
import '../../../events/dynamicEvents.js';
|
|
29
28
|
import { storeTokenAndUser } from '../../../client/extension/storeTokenAndUser/storeTokenAndUser.js';
|
|
30
29
|
import { useAccessDeniedContext } from '../../../context/AccessDeniedContext/AccessDeniedContext.js';
|
|
@@ -114,50 +113,6 @@ const useUserAuth = ({ authMethod, }) => {
|
|
|
114
113
|
const handleAuthenticatedUser = useHandleAuthenticatedUser();
|
|
115
114
|
const { shouldAutoCreateEmbeddedWallet, shouldPromptForKeyExport, embeddedWalletSettingVersion, } = useEmbeddedWallet();
|
|
116
115
|
const isVerifyResponse = (response) => response.user;
|
|
117
|
-
const handleWaasInitialization = useCallback((verifiedUser) => __awaiter(void 0, void 0, void 0, function* () {
|
|
118
|
-
const sessionSignatureResult = yield getClientSessionSignature({
|
|
119
|
-
sessionId: verifiedUser === null || verifiedUser === void 0 ? void 0 : verifiedUser.sessionId,
|
|
120
|
-
});
|
|
121
|
-
const dynamicWaasConnectors = walletConnectorOptions.filter((walletOption) => walletOption.walletConnector.key === 'dynamicwaas');
|
|
122
|
-
dynamicWaasConnectors.forEach((walletOption) => {
|
|
123
|
-
var _a;
|
|
124
|
-
const walletAddress = (_a = verifiedUser.verifiedCredentials.find((credential) => {
|
|
125
|
-
var _a;
|
|
126
|
-
return VerifiedCredentialNameToChainEnum[(_a = credential.chain) !== null && _a !== void 0 ? _a : ''] ===
|
|
127
|
-
walletOption.walletConnector.connectedChain;
|
|
128
|
-
})) === null || _a === void 0 ? void 0 : _a.address;
|
|
129
|
-
if (walletAddress) {
|
|
130
|
-
// Create the waas iframe
|
|
131
|
-
walletOption.walletConnector
|
|
132
|
-
.getWaasWalletClient()
|
|
133
|
-
.then((client) => {
|
|
134
|
-
// Restore the wallet keyshare to the iframe
|
|
135
|
-
client
|
|
136
|
-
.getWallet({
|
|
137
|
-
accountAddress: walletAddress,
|
|
138
|
-
signedSessionId: sessionSignatureResult.sessionSignature,
|
|
139
|
-
walletOperation: 'SIGN_MESSAGE',
|
|
140
|
-
})
|
|
141
|
-
.catch((error) => {
|
|
142
|
-
logger.error('Error restoring wallet keyshare', {
|
|
143
|
-
error,
|
|
144
|
-
sessionId: verifiedUser.sessionId,
|
|
145
|
-
userId: verifiedUser.userId,
|
|
146
|
-
walletAddress,
|
|
147
|
-
});
|
|
148
|
-
});
|
|
149
|
-
})
|
|
150
|
-
.catch((error) => {
|
|
151
|
-
logger.error('Error initializing waas wallet client', {
|
|
152
|
-
error,
|
|
153
|
-
sessionId: verifiedUser.sessionId,
|
|
154
|
-
userId: verifiedUser.userId,
|
|
155
|
-
walletAddress,
|
|
156
|
-
});
|
|
157
|
-
});
|
|
158
|
-
}
|
|
159
|
-
});
|
|
160
|
-
}), [walletConnectorOptions]);
|
|
161
116
|
const cancelAuth = useCallback(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
162
117
|
logger.debug('cancelAuth', { authMethod });
|
|
163
118
|
yield handleLogOut();
|
|
@@ -262,12 +217,6 @@ const useUserAuth = ({ authMethod, }) => {
|
|
|
262
217
|
}
|
|
263
218
|
if (isSignIn) {
|
|
264
219
|
setCallback('authSuccess');
|
|
265
|
-
const hasWaasWallets = verifiedUser.verifiedCredentials.some((vc) => vc.walletProvider === WalletProviderEnum.EmbeddedWallet &&
|
|
266
|
-
vc.walletName === 'dynamicwaas');
|
|
267
|
-
if (hasWaasWallets) {
|
|
268
|
-
// Eagerly initialize waas wallets
|
|
269
|
-
yield handleWaasInitialization(verifiedUser);
|
|
270
|
-
}
|
|
271
220
|
}
|
|
272
221
|
const walletVersion = embeddedWalletSettingVersion();
|
|
273
222
|
if (walletVersion === EmbeddedWalletVersionEnum.V1 &&
|
|
@@ -297,7 +246,6 @@ const useUserAuth = ({ authMethod, }) => {
|
|
|
297
246
|
embeddedWalletSettingVersion,
|
|
298
247
|
handleAuthError,
|
|
299
248
|
handleAuthenticatedUser,
|
|
300
|
-
handleWaasInitialization,
|
|
301
249
|
setCallback,
|
|
302
250
|
setLoading,
|
|
303
251
|
setMultiWalletWidgetState,
|
|
@@ -125,6 +125,7 @@ const getSupportedChainName = (connectedChain) => {
|
|
|
125
125
|
EVM: sdkApiCore.ChainEnum.Evm,
|
|
126
126
|
SOL: sdkApiCore.ChainEnum.Sol,
|
|
127
127
|
SUI: sdkApiCore.ChainEnum.Sui,
|
|
128
|
+
TRON: sdkApiCore.ChainEnum.Tron,
|
|
128
129
|
};
|
|
129
130
|
return connectedChain && connectedChain in supportedChains
|
|
130
131
|
? supportedChains[connectedChain]
|
|
@@ -121,6 +121,7 @@ const getSupportedChainName = (connectedChain) => {
|
|
|
121
121
|
EVM: ChainEnum.Evm,
|
|
122
122
|
SOL: ChainEnum.Sol,
|
|
123
123
|
SUI: ChainEnum.Sui,
|
|
124
|
+
TRON: ChainEnum.Tron,
|
|
124
125
|
};
|
|
125
126
|
return connectedChain && connectedChain in supportedChains
|
|
126
127
|
? supportedChains[connectedChain]
|