@monygroupcorp/micro-web3 1.2.0 → 1.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/micro-web3.cjs +2 -2
- package/dist/micro-web3.cjs.map +1 -1
- package/dist/micro-web3.esm.js +1 -1
- package/dist/micro-web3.esm.js.map +1 -1
- package/dist/micro-web3.umd.js +1 -1
- package/dist/micro-web3.umd.js.map +1 -1
- package/package.json +1 -1
- package/src/components/FloatingWalletButton/FloatingWalletButton.js +37 -21
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@monygroupcorp/micro-web3",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.1",
|
|
4
4
|
"description": "A lean, reusable Web3 toolkit with components for wallet connection, IPFS, and common Web3 UI patterns.",
|
|
5
5
|
"main": "dist/micro-web3.cjs",
|
|
6
6
|
"module": "dist/micro-web3.esm.js",
|
|
@@ -49,30 +49,31 @@ export class FloatingWalletButton extends Component {
|
|
|
49
49
|
let isConnected = this.walletService.isConnected();
|
|
50
50
|
let address = this.walletService.getAddress();
|
|
51
51
|
|
|
52
|
-
// If not connected,
|
|
52
|
+
// If not connected, check if window.ethereum already has connected accounts
|
|
53
53
|
if (!isConnected && typeof window.ethereum !== 'undefined') {
|
|
54
54
|
try {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
console.log('[FloatingWalletButton] Auto-reconnect not possible');
|
|
55
|
+
// eth_accounts returns already-authorized accounts without prompting
|
|
56
|
+
const accounts = await window.ethereum.request({ method: 'eth_accounts' });
|
|
57
|
+
const hasAccounts = accounts && accounts.length > 0;
|
|
58
|
+
|
|
59
|
+
if (hasAccounts) {
|
|
60
|
+
// Detect which wallet is active
|
|
61
|
+
const walletType = this._detectWalletType();
|
|
62
|
+
console.log('[FloatingWalletButton] Detected existing connection:', walletType, accounts[0]);
|
|
63
|
+
|
|
64
|
+
try {
|
|
65
|
+
await this.walletService.selectWallet(walletType);
|
|
66
|
+
await this.walletService.connect();
|
|
67
|
+
isConnected = this.walletService.isConnected();
|
|
68
|
+
address = this.walletService.getAddress();
|
|
69
|
+
|
|
70
|
+
if (isConnected) {
|
|
71
|
+
console.log('[FloatingWalletButton] Auto-connected to existing session:', walletType);
|
|
72
|
+
// Update lastWallet for future sessions
|
|
73
|
+
localStorage.setItem('ms2fun_lastWallet', walletType);
|
|
75
74
|
}
|
|
75
|
+
} catch (connectError) {
|
|
76
|
+
console.log('[FloatingWalletButton] Could not auto-connect:', connectError.message);
|
|
76
77
|
}
|
|
77
78
|
}
|
|
78
79
|
} catch (error) {
|
|
@@ -91,6 +92,21 @@ export class FloatingWalletButton extends Component {
|
|
|
91
92
|
}
|
|
92
93
|
}
|
|
93
94
|
|
|
95
|
+
/**
|
|
96
|
+
* Detect which wallet type is currently active based on provider flags
|
|
97
|
+
*/
|
|
98
|
+
_detectWalletType() {
|
|
99
|
+
if (typeof window.ethereum === 'undefined') return 'metamask';
|
|
100
|
+
|
|
101
|
+
// Check specific wallet flags (order matters - more specific first)
|
|
102
|
+
if (window.ethereum.isRabby) return 'rabby';
|
|
103
|
+
if (window.ethereum.isRainbow) return 'rainbow';
|
|
104
|
+
if (window.phantom?.ethereum) return 'phantom';
|
|
105
|
+
|
|
106
|
+
// Default to metamask for any EIP-1193 provider
|
|
107
|
+
return 'metamask';
|
|
108
|
+
}
|
|
109
|
+
|
|
94
110
|
/**
|
|
95
111
|
* Load wallet info (balance, EXEC tokens, vault benefactor status)
|
|
96
112
|
*/
|