signer-test-sdk-react 0.0.15 → 0.0.17
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/dist/src/AbstraxnProvider.js +263 -0
- package/dist/src/AbstraxnProvider.js.map +1 -1
- package/dist/src/components/OnboardingUI/hooks/useAuthMethods.js +40 -0
- package/dist/src/components/OnboardingUI/hooks/useAuthMethods.js.map +1 -1
- package/dist/src/components/OnboardingUI/hooks/useOnboarding.js +16 -0
- package/dist/src/components/OnboardingUI/hooks/useOnboarding.js.map +1 -1
- package/dist/src/connectors.d.ts +27 -0
- package/dist/src/connectors.js +70 -0
- package/dist/src/connectors.js.map +1 -0
- package/dist/src/hooks.d.ts +34 -0
- package/dist/src/hooks.js +93 -3
- package/dist/src/hooks.js.map +1 -1
- package/dist/src/index.d.ts +2 -1
- package/dist/src/index.js +2 -1
- package/dist/src/index.js.map +1 -1
- package/dist/src/types.d.ts +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
|
@@ -97,6 +97,8 @@ function AbstraxnProviderInner({ config, children, base, wagmi }) {
|
|
|
97
97
|
const [isExternalWalletConnected, setIsExternalWalletConnected] = useState(false);
|
|
98
98
|
const [externalWalletAddress, setExternalWalletAddress] = useState(null);
|
|
99
99
|
const [externalWalletChainId, setExternalWalletChainId] = useState(null);
|
|
100
|
+
// Connection type tracking: 'google' | 'email' | 'discord' | 'x' | 'passkey' | 'metamask' | 'walletconnect' | 'coinbase' | 'phantom' | 'injected' | null
|
|
101
|
+
const [connectionType, setConnectionType] = useState(null);
|
|
100
102
|
const explicitConnectionRef = useRef(false);
|
|
101
103
|
const autoDisconnectHandledRef = useRef(false);
|
|
102
104
|
// Track when we last connected to prevent premature reset
|
|
@@ -161,6 +163,37 @@ function AbstraxnProviderInner({ config, children, base, wagmi }) {
|
|
|
161
163
|
setIsConnected(true);
|
|
162
164
|
setExternalWalletChainId(currentChainId);
|
|
163
165
|
setChainId(currentChainId);
|
|
166
|
+
// Restore connection type from connector
|
|
167
|
+
const connector = wagmiAccount.connector;
|
|
168
|
+
if (connector) {
|
|
169
|
+
const connectorId = connector.id.toLowerCase();
|
|
170
|
+
const connectorName = connector.name?.toLowerCase() || '';
|
|
171
|
+
// Map connector to connection type
|
|
172
|
+
if (connectorId.includes('metamask') || connectorId.includes('io.metamask') || connectorName.includes('metamask')) {
|
|
173
|
+
setConnectionType('metamask');
|
|
174
|
+
}
|
|
175
|
+
else if (connectorId.includes('walletconnect') || connectorId.includes('wallet_connect') || connectorName.includes('walletconnect')) {
|
|
176
|
+
setConnectionType('walletconnect');
|
|
177
|
+
}
|
|
178
|
+
else {
|
|
179
|
+
// For other wallets (coinbase, phantom, injected), store as-is
|
|
180
|
+
// The hook will normalize them, but we keep the original for reference
|
|
181
|
+
const fallbackType = connectorName || connectorId;
|
|
182
|
+
setConnectionType(fallbackType);
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
else {
|
|
186
|
+
// Try to restore from localStorage as fallback
|
|
187
|
+
try {
|
|
188
|
+
const storedType = localStorage.getItem('abstraxn_connection_type');
|
|
189
|
+
if (storedType) {
|
|
190
|
+
setConnectionType(storedType);
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
catch (e) {
|
|
194
|
+
// Ignore localStorage errors
|
|
195
|
+
}
|
|
196
|
+
}
|
|
164
197
|
// Update refs to track the restored connection
|
|
165
198
|
lastAddressRef.current = walletAddress;
|
|
166
199
|
lastChainIdRef.current = currentChainId;
|
|
@@ -291,6 +324,18 @@ function AbstraxnProviderInner({ config, children, base, wagmi }) {
|
|
|
291
324
|
}
|
|
292
325
|
const cid = await walletInstance.getChainId();
|
|
293
326
|
setChainId(cid);
|
|
327
|
+
// Always restore connection type from localStorage on connect
|
|
328
|
+
// This ensures connectionType is available after OAuth redirects (Google, X, Discord)
|
|
329
|
+
// and after page refreshes
|
|
330
|
+
try {
|
|
331
|
+
const storedType = localStorage.getItem('abstraxn_connection_type');
|
|
332
|
+
if (storedType && (storedType === 'google' || storedType === 'email' || storedType === 'discord' || storedType === 'x' || storedType === 'passkey')) {
|
|
333
|
+
setConnectionType(storedType);
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
catch (e) {
|
|
337
|
+
// Ignore localStorage errors
|
|
338
|
+
}
|
|
294
339
|
}
|
|
295
340
|
catch (err) {
|
|
296
341
|
console.error('Error getting wallet info on connect:', err);
|
|
@@ -320,6 +365,14 @@ function AbstraxnProviderInner({ config, children, base, wagmi }) {
|
|
|
320
365
|
setUser(null);
|
|
321
366
|
setWhoami(null);
|
|
322
367
|
setChainId(null);
|
|
368
|
+
setConnectionType(null);
|
|
369
|
+
// Clear from localStorage
|
|
370
|
+
try {
|
|
371
|
+
localStorage.removeItem('abstraxn_connection_type');
|
|
372
|
+
}
|
|
373
|
+
catch (e) {
|
|
374
|
+
// Ignore localStorage errors
|
|
375
|
+
}
|
|
323
376
|
});
|
|
324
377
|
walletInstance.on('accountChanged', (newAddress) => {
|
|
325
378
|
setAddress(newAddress);
|
|
@@ -350,6 +403,14 @@ function AbstraxnProviderInner({ config, children, base, wagmi }) {
|
|
|
350
403
|
if (!walletInstance)
|
|
351
404
|
throw new Error('Wallet not initialized');
|
|
352
405
|
const authManager = walletInstance.getAuthManager();
|
|
406
|
+
const connectionTypeValue = 'email';
|
|
407
|
+
setConnectionType(connectionTypeValue);
|
|
408
|
+
try {
|
|
409
|
+
localStorage.setItem('abstraxn_connection_type', connectionTypeValue);
|
|
410
|
+
}
|
|
411
|
+
catch (e) {
|
|
412
|
+
// Ignore localStorage errors
|
|
413
|
+
}
|
|
353
414
|
const result = await authManager.loginWithOTP(email);
|
|
354
415
|
otpIdRef.current = result.otpId;
|
|
355
416
|
}
|
|
@@ -364,6 +425,15 @@ function AbstraxnProviderInner({ config, children, base, wagmi }) {
|
|
|
364
425
|
throw new Error('Wallet not initialized');
|
|
365
426
|
if (!otpIdRef.current)
|
|
366
427
|
throw new Error('OTP ID not found');
|
|
428
|
+
// Set connection type for email OTP before verification
|
|
429
|
+
const connectionTypeValue = 'email';
|
|
430
|
+
setConnectionType(connectionTypeValue);
|
|
431
|
+
try {
|
|
432
|
+
localStorage.setItem('abstraxn_connection_type', connectionTypeValue);
|
|
433
|
+
}
|
|
434
|
+
catch (e) {
|
|
435
|
+
// Ignore localStorage errors
|
|
436
|
+
}
|
|
367
437
|
const authManager = walletInstance.getAuthManager();
|
|
368
438
|
const user = await authManager.verifyOTP(otpIdRef.current, otp);
|
|
369
439
|
otpIdRef.current = null;
|
|
@@ -383,24 +453,57 @@ function AbstraxnProviderInner({ config, children, base, wagmi }) {
|
|
|
383
453
|
onGoogleLogin: async () => {
|
|
384
454
|
if (!walletInstance)
|
|
385
455
|
throw new Error('Wallet not initialized');
|
|
456
|
+
const connectionTypeValue = 'google';
|
|
457
|
+
setConnectionType(connectionTypeValue);
|
|
458
|
+
// Store in localStorage for restoration
|
|
459
|
+
try {
|
|
460
|
+
localStorage.setItem('abstraxn_connection_type', connectionTypeValue);
|
|
461
|
+
}
|
|
462
|
+
catch (e) {
|
|
463
|
+
// Ignore localStorage errors
|
|
464
|
+
}
|
|
386
465
|
const authManager = walletInstance.getAuthManager();
|
|
387
466
|
await authManager.loginWithGoogle();
|
|
388
467
|
},
|
|
389
468
|
onTwitterLogin: async () => {
|
|
390
469
|
if (!walletInstance)
|
|
391
470
|
throw new Error('Wallet not initialized');
|
|
471
|
+
const connectionTypeValue = 'x';
|
|
472
|
+
setConnectionType(connectionTypeValue);
|
|
473
|
+
try {
|
|
474
|
+
localStorage.setItem('abstraxn_connection_type', connectionTypeValue);
|
|
475
|
+
}
|
|
476
|
+
catch (e) {
|
|
477
|
+
// Ignore localStorage errors
|
|
478
|
+
}
|
|
392
479
|
const authManager = walletInstance.getAuthManager();
|
|
393
480
|
await authManager.loginWithTwitter();
|
|
394
481
|
},
|
|
395
482
|
onDiscordLogin: async () => {
|
|
396
483
|
if (!walletInstance)
|
|
397
484
|
throw new Error('Wallet not initialized');
|
|
485
|
+
const connectionTypeValue = 'discord';
|
|
486
|
+
setConnectionType(connectionTypeValue);
|
|
487
|
+
try {
|
|
488
|
+
localStorage.setItem('abstraxn_connection_type', connectionTypeValue);
|
|
489
|
+
}
|
|
490
|
+
catch (e) {
|
|
491
|
+
// Ignore localStorage errors
|
|
492
|
+
}
|
|
398
493
|
const authManager = walletInstance.getAuthManager();
|
|
399
494
|
await authManager.loginWithDiscord();
|
|
400
495
|
},
|
|
401
496
|
onPasskeyLogin: async () => {
|
|
402
497
|
if (!walletInstance)
|
|
403
498
|
throw new Error('Wallet not initialized');
|
|
499
|
+
const connectionTypeValue = 'passkey';
|
|
500
|
+
setConnectionType(connectionTypeValue);
|
|
501
|
+
try {
|
|
502
|
+
localStorage.setItem('abstraxn_connection_type', connectionTypeValue);
|
|
503
|
+
}
|
|
504
|
+
catch (e) {
|
|
505
|
+
// Ignore localStorage errors
|
|
506
|
+
}
|
|
404
507
|
const authManager = walletInstance.getAuthManager();
|
|
405
508
|
const user = await authManager.loginWithPasskey();
|
|
406
509
|
// Set user immediately so onLoginSuccess can access it
|
|
@@ -411,6 +514,14 @@ function AbstraxnProviderInner({ config, children, base, wagmi }) {
|
|
|
411
514
|
onPasskeySignup: async () => {
|
|
412
515
|
if (!walletInstance)
|
|
413
516
|
throw new Error('Wallet not initialized');
|
|
517
|
+
const connectionTypeValue = 'passkey';
|
|
518
|
+
setConnectionType(connectionTypeValue);
|
|
519
|
+
try {
|
|
520
|
+
localStorage.setItem('abstraxn_connection_type', connectionTypeValue);
|
|
521
|
+
}
|
|
522
|
+
catch (e) {
|
|
523
|
+
// Ignore localStorage errors
|
|
524
|
+
}
|
|
414
525
|
const authManager = walletInstance.getAuthManager();
|
|
415
526
|
const user = await authManager.signupWithPasskey();
|
|
416
527
|
// Set user immediately so onLoginSuccess can access it
|
|
@@ -421,6 +532,17 @@ function AbstraxnProviderInner({ config, children, base, wagmi }) {
|
|
|
421
532
|
onLoginSuccess: async (data) => {
|
|
422
533
|
// Clear any previous errors on successful login
|
|
423
534
|
setError(null);
|
|
535
|
+
// Restore connection type from localStorage for OAuth logins (Google, X, Discord)
|
|
536
|
+
// This ensures connectionType is set after OAuth redirects
|
|
537
|
+
try {
|
|
538
|
+
const storedType = localStorage.getItem('abstraxn_connection_type');
|
|
539
|
+
if (storedType && (storedType === 'google' || storedType === 'x' || storedType === 'discord' || storedType === 'email' || storedType === 'passkey')) {
|
|
540
|
+
setConnectionType(storedType);
|
|
541
|
+
}
|
|
542
|
+
}
|
|
543
|
+
catch (e) {
|
|
544
|
+
// Ignore localStorage errors
|
|
545
|
+
}
|
|
424
546
|
// Set user if provided in data
|
|
425
547
|
if (data.user) {
|
|
426
548
|
setUser(data.user);
|
|
@@ -967,6 +1089,16 @@ function AbstraxnProviderInner({ config, children, base, wagmi }) {
|
|
|
967
1089
|
setUser(userInfo);
|
|
968
1090
|
setWhoami(whoamiInfo);
|
|
969
1091
|
setIsConnected(true);
|
|
1092
|
+
// Restore connection type from localStorage
|
|
1093
|
+
try {
|
|
1094
|
+
const storedType = localStorage.getItem('abstraxn_connection_type');
|
|
1095
|
+
if (storedType && (storedType === 'google' || storedType === 'email' || storedType === 'discord' || storedType === 'x' || storedType === 'passkey')) {
|
|
1096
|
+
setConnectionType(storedType);
|
|
1097
|
+
}
|
|
1098
|
+
}
|
|
1099
|
+
catch (e) {
|
|
1100
|
+
// Ignore localStorage errors
|
|
1101
|
+
}
|
|
970
1102
|
}
|
|
971
1103
|
}
|
|
972
1104
|
catch (err) {
|
|
@@ -995,6 +1127,16 @@ function AbstraxnProviderInner({ config, children, base, wagmi }) {
|
|
|
995
1127
|
}
|
|
996
1128
|
const cid = await walletRef.current.getChainId();
|
|
997
1129
|
setChainId(cid);
|
|
1130
|
+
// Restore connection type from localStorage
|
|
1131
|
+
try {
|
|
1132
|
+
const storedType = localStorage.getItem('abstraxn_connection_type');
|
|
1133
|
+
if (storedType && (storedType === 'google' || storedType === 'email' || storedType === 'discord' || storedType === 'x' || storedType === 'passkey')) {
|
|
1134
|
+
setConnectionType(storedType);
|
|
1135
|
+
}
|
|
1136
|
+
}
|
|
1137
|
+
catch (e) {
|
|
1138
|
+
// Ignore localStorage errors
|
|
1139
|
+
}
|
|
998
1140
|
}
|
|
999
1141
|
catch (restoreErr) {
|
|
1000
1142
|
console.error('Error restoring connection state:', restoreErr);
|
|
@@ -1064,6 +1206,14 @@ function AbstraxnProviderInner({ config, children, base, wagmi }) {
|
|
|
1064
1206
|
setIsExternalWalletConnected(false);
|
|
1065
1207
|
setExternalWalletAddress(null);
|
|
1066
1208
|
setExternalWalletChainId(null);
|
|
1209
|
+
setConnectionType(null);
|
|
1210
|
+
// Clear from localStorage
|
|
1211
|
+
try {
|
|
1212
|
+
localStorage.removeItem('abstraxn_connection_type');
|
|
1213
|
+
}
|
|
1214
|
+
catch (e) {
|
|
1215
|
+
// Ignore localStorage errors
|
|
1216
|
+
}
|
|
1067
1217
|
explicitConnectionRef.current = false;
|
|
1068
1218
|
lastConnectionTimeRef.current = 0;
|
|
1069
1219
|
// Always reset main isConnected when disconnecting external wallet
|
|
@@ -1087,6 +1237,14 @@ function AbstraxnProviderInner({ config, children, base, wagmi }) {
|
|
|
1087
1237
|
setIsConnected(false);
|
|
1088
1238
|
setAddress(null);
|
|
1089
1239
|
setChainId(null);
|
|
1240
|
+
setConnectionType(null);
|
|
1241
|
+
// Clear from localStorage
|
|
1242
|
+
try {
|
|
1243
|
+
localStorage.removeItem('abstraxn_connection_type');
|
|
1244
|
+
}
|
|
1245
|
+
catch (e) {
|
|
1246
|
+
// Ignore localStorage errors
|
|
1247
|
+
}
|
|
1090
1248
|
// console.log('✅ Abstraxn wallet disconnected, main state reset');
|
|
1091
1249
|
}
|
|
1092
1250
|
catch (err) {
|
|
@@ -1095,6 +1253,14 @@ function AbstraxnProviderInner({ config, children, base, wagmi }) {
|
|
|
1095
1253
|
setIsConnected(false);
|
|
1096
1254
|
setAddress(null);
|
|
1097
1255
|
setChainId(null);
|
|
1256
|
+
setConnectionType(null);
|
|
1257
|
+
// Clear from localStorage
|
|
1258
|
+
try {
|
|
1259
|
+
localStorage.removeItem('abstraxn_connection_type');
|
|
1260
|
+
}
|
|
1261
|
+
catch (e) {
|
|
1262
|
+
// Ignore localStorage errors
|
|
1263
|
+
}
|
|
1098
1264
|
}
|
|
1099
1265
|
}
|
|
1100
1266
|
// Final check: if neither wallet is connected, ensure main state is reset
|
|
@@ -1105,6 +1271,14 @@ function AbstraxnProviderInner({ config, children, base, wagmi }) {
|
|
|
1105
1271
|
setIsConnected(false);
|
|
1106
1272
|
setAddress(null);
|
|
1107
1273
|
setChainId(null);
|
|
1274
|
+
setConnectionType(null);
|
|
1275
|
+
// Clear from localStorage
|
|
1276
|
+
try {
|
|
1277
|
+
localStorage.removeItem('abstraxn_connection_type');
|
|
1278
|
+
}
|
|
1279
|
+
catch (e) {
|
|
1280
|
+
// Ignore localStorage errors
|
|
1281
|
+
}
|
|
1108
1282
|
// console.log('✅ Final check: All wallets disconnected, main state reset');
|
|
1109
1283
|
}
|
|
1110
1284
|
// Reset OTP screen and show initial login form
|
|
@@ -1344,6 +1518,14 @@ function AbstraxnProviderInner({ config, children, base, wagmi }) {
|
|
|
1344
1518
|
setLoading(true);
|
|
1345
1519
|
setError(null);
|
|
1346
1520
|
try {
|
|
1521
|
+
const connectionTypeValue = 'email';
|
|
1522
|
+
setConnectionType(connectionTypeValue);
|
|
1523
|
+
try {
|
|
1524
|
+
localStorage.setItem('abstraxn_connection_type', connectionTypeValue);
|
|
1525
|
+
}
|
|
1526
|
+
catch (e) {
|
|
1527
|
+
// Ignore localStorage errors
|
|
1528
|
+
}
|
|
1347
1529
|
const result = await walletRef.current.loginWithOTP(email);
|
|
1348
1530
|
return result;
|
|
1349
1531
|
}
|
|
@@ -1363,9 +1545,26 @@ function AbstraxnProviderInner({ config, children, base, wagmi }) {
|
|
|
1363
1545
|
setLoading(true);
|
|
1364
1546
|
setError(null);
|
|
1365
1547
|
try {
|
|
1548
|
+
// Set connection type for email OTP before verification
|
|
1549
|
+
const connectionTypeValue = 'email';
|
|
1550
|
+
setConnectionType(connectionTypeValue);
|
|
1551
|
+
try {
|
|
1552
|
+
localStorage.setItem('abstraxn_connection_type', connectionTypeValue);
|
|
1553
|
+
}
|
|
1554
|
+
catch (e) {
|
|
1555
|
+
// Ignore localStorage errors
|
|
1556
|
+
}
|
|
1366
1557
|
const user = await walletRef.current.verifyOTP(otpId, otpCode);
|
|
1367
1558
|
setIsConnected(true);
|
|
1368
1559
|
setUser(user);
|
|
1560
|
+
// Ensure connection type is set (in case connect event didn't restore it)
|
|
1561
|
+
setConnectionType('email');
|
|
1562
|
+
try {
|
|
1563
|
+
localStorage.setItem('abstraxn_connection_type', 'email');
|
|
1564
|
+
}
|
|
1565
|
+
catch (e) {
|
|
1566
|
+
// Ignore localStorage errors
|
|
1567
|
+
}
|
|
1369
1568
|
// Load whoami and address after verification
|
|
1370
1569
|
try {
|
|
1371
1570
|
const whoamiInfo = await walletRef.current.getWhoami();
|
|
@@ -1395,6 +1594,14 @@ function AbstraxnProviderInner({ config, children, base, wagmi }) {
|
|
|
1395
1594
|
setLoading(true);
|
|
1396
1595
|
setError(null);
|
|
1397
1596
|
try {
|
|
1597
|
+
const connectionTypeValue = 'google';
|
|
1598
|
+
setConnectionType(connectionTypeValue);
|
|
1599
|
+
try {
|
|
1600
|
+
localStorage.setItem('abstraxn_connection_type', connectionTypeValue);
|
|
1601
|
+
}
|
|
1602
|
+
catch (e) {
|
|
1603
|
+
// Ignore localStorage errors
|
|
1604
|
+
}
|
|
1398
1605
|
await walletRef.current.loginWithGoogle();
|
|
1399
1606
|
// Note: This will redirect, so loading state will be reset on callback
|
|
1400
1607
|
}
|
|
@@ -1417,6 +1624,16 @@ function AbstraxnProviderInner({ config, children, base, wagmi }) {
|
|
|
1417
1624
|
const user = await walletRef.current.handleGoogleCallback();
|
|
1418
1625
|
if (user) {
|
|
1419
1626
|
setUser(user);
|
|
1627
|
+
// Restore connection type for Google OAuth
|
|
1628
|
+
try {
|
|
1629
|
+
const storedType = localStorage.getItem('abstraxn_connection_type');
|
|
1630
|
+
if (storedType === 'google') {
|
|
1631
|
+
setConnectionType('google');
|
|
1632
|
+
}
|
|
1633
|
+
}
|
|
1634
|
+
catch (e) {
|
|
1635
|
+
// Ignore localStorage errors
|
|
1636
|
+
}
|
|
1420
1637
|
// handleGoogleCallback() already calls whoami and emits 'connect' event
|
|
1421
1638
|
// The 'connect' event handler will update whoami, address, and chainId
|
|
1422
1639
|
// So we don't need to do it here to avoid duplicate whoami calls
|
|
@@ -1738,6 +1955,41 @@ function AbstraxnProviderInner({ config, children, base, wagmi }) {
|
|
|
1738
1955
|
setIsExternalWalletConnected(true); // This marks it as an external wallet connection
|
|
1739
1956
|
setAddress(formattedAddress);
|
|
1740
1957
|
setIsConnected(true);
|
|
1958
|
+
// Track connection type based on connector
|
|
1959
|
+
const connector = wagmiAccount.connector;
|
|
1960
|
+
if (connector) {
|
|
1961
|
+
const connectorId = connector.id.toLowerCase();
|
|
1962
|
+
const connectorName = connector.name?.toLowerCase() || '';
|
|
1963
|
+
let connectionTypeValue;
|
|
1964
|
+
// Map connector to connection type
|
|
1965
|
+
if (connectorId.includes('metamask') || connectorId.includes('io.metamask') || connectorName.includes('metamask')) {
|
|
1966
|
+
connectionTypeValue = 'metamask';
|
|
1967
|
+
}
|
|
1968
|
+
else if (connectorId.includes('walletconnect') || connectorId.includes('wallet_connect') || connectorName.includes('walletconnect')) {
|
|
1969
|
+
connectionTypeValue = 'walletconnect';
|
|
1970
|
+
}
|
|
1971
|
+
else if (connectorId.includes('coinbase') || connectorId.includes('com.coinbase') || connectorName.includes('coinbase')) {
|
|
1972
|
+
connectionTypeValue = 'coinbase';
|
|
1973
|
+
}
|
|
1974
|
+
else if (connectorId.includes('phantom') || connectorId.includes('app.phantom') || connectorName.includes('phantom')) {
|
|
1975
|
+
connectionTypeValue = 'phantom';
|
|
1976
|
+
}
|
|
1977
|
+
else if (connectorId.includes('injected')) {
|
|
1978
|
+
connectionTypeValue = 'injected';
|
|
1979
|
+
}
|
|
1980
|
+
else {
|
|
1981
|
+
// Use connector name or ID as fallback
|
|
1982
|
+
connectionTypeValue = connectorName || connectorId;
|
|
1983
|
+
}
|
|
1984
|
+
setConnectionType(connectionTypeValue);
|
|
1985
|
+
// Store in localStorage for restoration on refresh
|
|
1986
|
+
try {
|
|
1987
|
+
localStorage.setItem('abstraxn_connection_type', connectionTypeValue);
|
|
1988
|
+
}
|
|
1989
|
+
catch (e) {
|
|
1990
|
+
// Ignore localStorage errors
|
|
1991
|
+
}
|
|
1992
|
+
}
|
|
1741
1993
|
if (currentChainId) {
|
|
1742
1994
|
setChainId(currentChainId);
|
|
1743
1995
|
setExternalWalletChainId(currentChainId);
|
|
@@ -1794,6 +2046,14 @@ function AbstraxnProviderInner({ config, children, base, wagmi }) {
|
|
|
1794
2046
|
setIsExternalWalletConnected(false);
|
|
1795
2047
|
setExternalWalletAddress(null);
|
|
1796
2048
|
setExternalWalletChainId(null);
|
|
2049
|
+
setConnectionType(null);
|
|
2050
|
+
// Clear from localStorage
|
|
2051
|
+
try {
|
|
2052
|
+
localStorage.removeItem('abstraxn_connection_type');
|
|
2053
|
+
}
|
|
2054
|
+
catch (e) {
|
|
2055
|
+
// Ignore localStorage errors
|
|
2056
|
+
}
|
|
1797
2057
|
explicitConnectionRef.current = false;
|
|
1798
2058
|
lastConnectionTimeRef.current = 0;
|
|
1799
2059
|
// CRITICAL: Reset refs so reconnect is detected as a new connection
|
|
@@ -1805,6 +2065,7 @@ function AbstraxnProviderInner({ config, children, base, wagmi }) {
|
|
|
1805
2065
|
setIsConnected(false);
|
|
1806
2066
|
setAddress(null);
|
|
1807
2067
|
setChainId(null);
|
|
2068
|
+
setConnectionType(null);
|
|
1808
2069
|
}
|
|
1809
2070
|
catch (err) {
|
|
1810
2071
|
const error = err instanceof Error ? err : new Error('Failed to disconnect external wallet');
|
|
@@ -2108,6 +2369,8 @@ function AbstraxnProviderInner({ config, children, base, wagmi }) {
|
|
|
2108
2369
|
availableChains,
|
|
2109
2370
|
// Balance (for Abstraxn wallet)
|
|
2110
2371
|
walletBalance: !isExternalWalletConnected ? walletBalance : undefined,
|
|
2372
|
+
// Connection type
|
|
2373
|
+
connectionType,
|
|
2111
2374
|
};
|
|
2112
2375
|
// Ref to store latest value to avoid dependency issues (defined after value)
|
|
2113
2376
|
const valueRef = useRef(value);
|