@web3auth/no-modal 11.0.0-beta.2 → 11.0.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/dist/lib.cjs/account-linking/errors.js +111 -0
- package/dist/lib.cjs/account-linking/index.js +4 -0
- package/dist/lib.cjs/account-linking/rest.js +6 -6
- package/dist/lib.cjs/account-linking/vue.js +0 -1
- package/dist/lib.cjs/base/connector/constants.js +2 -0
- package/dist/lib.cjs/base/errors/index.js +21 -50
- package/dist/lib.cjs/base/utils.js +1 -1
- package/dist/lib.cjs/connectors/auth-connector/authConnector.js +47 -34
- package/dist/lib.cjs/connectors/metamask-connector/metamaskConnector.js +40 -31
- package/dist/lib.cjs/index.js +21 -16
- package/dist/lib.cjs/noModal.js +29 -11
- package/dist/lib.cjs/providers/account-abstraction-provider/providers/AccountAbstractionProvider.js +8 -4
- package/dist/lib.cjs/providers/account-abstraction-provider/providers/utils.js +0 -17
- package/dist/lib.cjs/providers/account-abstraction-provider/rpc/ethRpcMiddlewares.js +15 -0
- package/dist/lib.cjs/react/context/useWeb3AuthInnerContextValue.js +11 -4
- package/dist/lib.cjs/react/wagmi/index.js +6 -0
- package/dist/lib.cjs/react/wagmi/provider.js +60 -41
- package/dist/lib.cjs/types/account-linking/errors.d.ts +17 -0
- package/dist/lib.cjs/types/account-linking/index.d.ts +1 -0
- package/dist/lib.cjs/types/base/connector/constants.d.ts +1 -0
- package/dist/lib.cjs/types/base/connector/interfaces.d.ts +1 -1
- package/dist/lib.cjs/types/base/errors/index.d.ts +2 -13
- package/dist/lib.cjs/types/connectors/auth-connector/authConnector.d.ts +2 -2
- package/dist/lib.cjs/types/providers/account-abstraction-provider/rpc/ethRpcMiddlewares.d.ts +1 -0
- package/dist/lib.cjs/types/react/wagmi/constants.d.ts +2 -0
- package/dist/lib.cjs/types/react/wagmi/provider.d.ts +7 -0
- package/dist/lib.cjs/types/vue/wagmi/constants.d.ts +2 -0
- package/dist/lib.cjs/types/vue/wagmi/provider.d.ts +7 -1
- package/dist/lib.cjs/vue/useWeb3AuthInnerContextValue.js +13 -6
- package/dist/lib.cjs/vue/wagmi/index.js +6 -0
- package/dist/lib.cjs/vue/wagmi/provider.js +53 -26
- package/dist/lib.esm/account-linking/errors.js +92 -0
- package/dist/lib.esm/account-linking/index.js +1 -0
- package/dist/lib.esm/account-linking/rest.js +3 -3
- package/dist/lib.esm/account-linking/vue.js +0 -1
- package/dist/lib.esm/base/connector/constants.js +2 -1
- package/dist/lib.esm/base/errors/index.js +21 -50
- package/dist/lib.esm/base/utils.js +1 -1
- package/dist/lib.esm/connectors/auth-connector/authConnector.js +29 -15
- package/dist/lib.esm/connectors/base-solana-connector/baseSolanaConnector.js +1 -1
- package/dist/lib.esm/connectors/metamask-connector/metamaskConnector.js +42 -33
- package/dist/lib.esm/index.js +3 -2
- package/dist/lib.esm/noModal.js +25 -5
- package/dist/lib.esm/providers/account-abstraction-provider/providers/AccountAbstractionProvider.js +10 -5
- package/dist/lib.esm/providers/account-abstraction-provider/providers/utils.js +0 -3
- package/dist/lib.esm/providers/account-abstraction-provider/rpc/ethRpcMiddlewares.js +17 -3
- package/dist/lib.esm/react/context/useWeb3AuthInnerContextValue.js +11 -4
- package/dist/lib.esm/react/wagmi/index.js +1 -1
- package/dist/lib.esm/react/wagmi/provider.js +59 -42
- package/dist/lib.esm/vue/useWeb3AuthInnerContextValue.js +11 -4
- package/dist/lib.esm/vue/wagmi/index.js +1 -1
- package/dist/lib.esm/vue/wagmi/provider.js +48 -25
- package/package.json +19 -19
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import _objectSpread from '@babel/runtime/helpers/objectSpread2';
|
|
2
|
-
import { hydrate } from '@wagmi/core';
|
|
2
|
+
import { injected, hydrate } from '@wagmi/core';
|
|
3
3
|
import { configKey, createConfig, useConfig, useReconnect, useConnectionEffect } from '@wagmi/vue';
|
|
4
|
-
import { injected } from '@wagmi/vue/connectors';
|
|
5
4
|
import { randomId } from '@web3auth/auth';
|
|
6
|
-
import { defineChain, webSocket, http, fallback } from 'viem';
|
|
5
|
+
import { isAddress, defineChain, webSocket, http, fallback } from 'viem';
|
|
7
6
|
import { defineComponent, h, shallowRef, ref, watch, provide } from 'vue';
|
|
8
7
|
import { log } from '../../base/loglevel.js';
|
|
9
8
|
import { defaultWagmiConfig } from './constants.js';
|
|
@@ -11,26 +10,47 @@ import { useWeb3Auth } from '../composables/useWeb3Auth.js';
|
|
|
11
10
|
import { useWeb3AuthDisconnect } from '../composables/useWeb3AuthDisconnect.js';
|
|
12
11
|
import { CHAIN_NAMESPACES } from '@toruslabs/base-controllers';
|
|
13
12
|
import { WalletInitializationError } from '../../base/errors/index.js';
|
|
13
|
+
import { WEB3AUTH_CONNECTOR_ID } from '../../base/connector/constants.js';
|
|
14
14
|
|
|
15
|
-
const WEB3AUTH_CONNECTOR_ID = "web3auth";
|
|
16
15
|
function getWeb3authConnector(config) {
|
|
17
16
|
return config.connectors.find(c => c.id === WEB3AUTH_CONNECTOR_ID);
|
|
18
17
|
}
|
|
19
18
|
|
|
20
|
-
// Helper to
|
|
19
|
+
// Helper to create a Web3Auth connector to connect with wagmi
|
|
21
20
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
if (connector) return connector;
|
|
25
|
-
|
|
26
|
-
// Create new connector if not already existing
|
|
27
|
-
connector = injected({
|
|
21
|
+
function createWeb3AuthConnectorForWagmi(provider) {
|
|
22
|
+
const baseConnector = injected({
|
|
28
23
|
target: {
|
|
29
24
|
provider: provider,
|
|
30
25
|
id: WEB3AUTH_CONNECTOR_ID,
|
|
31
26
|
name: "Web3Auth"
|
|
32
27
|
}
|
|
33
28
|
});
|
|
29
|
+
return config => {
|
|
30
|
+
const connector = baseConnector(config);
|
|
31
|
+
const baseOnAccountsChanged = connector.onAccountsChanged.bind(connector);
|
|
32
|
+
connector.onAccountsChanged = accounts => {
|
|
33
|
+
// we need to handle the `accountsChanged` event emitted on the cross-namespace chain switch.
|
|
34
|
+
// on evm -> solana, the accountsChanged event is emitted with the solana address, which is not valid for evm.
|
|
35
|
+
// that causes the `invalid account address` error in wagmi. So, here, we're filtering out the solana addresses.
|
|
36
|
+
if (accounts.length > 0 && !accounts.every(account => typeof account === "string" && isAddress(account))) {
|
|
37
|
+
log.warn("onAccountsChanged::accountsChanged event received on non-EVM address");
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
baseOnAccountsChanged(accounts);
|
|
41
|
+
};
|
|
42
|
+
return connector;
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// Helper to initialize connectors for the given wallets
|
|
47
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
48
|
+
function setupConnector(provider, config) {
|
|
49
|
+
let connector = getWeb3authConnector(config);
|
|
50
|
+
if (connector) return connector;
|
|
51
|
+
|
|
52
|
+
// Create new connector if not already existing
|
|
53
|
+
connector = createWeb3AuthConnectorForWagmi(provider);
|
|
34
54
|
const result = config._internal.connectors.setup(connector);
|
|
35
55
|
config._internal.connectors.setState(current => [...current, result]);
|
|
36
56
|
return result;
|
|
@@ -79,6 +99,7 @@ const Web3AuthWagmiProvider = defineComponent({
|
|
|
79
99
|
const {
|
|
80
100
|
isConnected,
|
|
81
101
|
connection,
|
|
102
|
+
web3Auth,
|
|
82
103
|
chainNamespace
|
|
83
104
|
} = useWeb3Auth();
|
|
84
105
|
const {
|
|
@@ -110,13 +131,15 @@ const Web3AuthWagmiProvider = defineComponent({
|
|
|
110
131
|
const newIsConnected = isConnected.value;
|
|
111
132
|
const newConnection = connection.value;
|
|
112
133
|
const newEth = (_newConnection$ethere = newConnection === null || newConnection === void 0 ? void 0 : newConnection.ethereumProvider) !== null && _newConnection$ethere !== void 0 ? _newConnection$ethere : null;
|
|
134
|
+
const w3aWagmiConnector = getWeb3authConnector(wagmiConfig);
|
|
113
135
|
const shouldBindToWagmi = newIsConnected && chainNamespace.value === CHAIN_NAMESPACES.EIP155 && Boolean(newConnection && newEth);
|
|
114
|
-
if (shouldBindToWagmi
|
|
115
|
-
|
|
116
|
-
|
|
136
|
+
if (shouldBindToWagmi) {
|
|
137
|
+
var _web3Auth$value;
|
|
138
|
+
const hasSameBinding = lastSyncedProvider.value === newEth && lastSyncedConnectorName.value === newConnection.connectorName && (newConnection === null || newConnection === void 0 ? void 0 : newConnection.connectorName) === ((_web3Auth$value = web3Auth.value) === null || _web3Auth$value === void 0 ? void 0 : _web3Auth$value.connection.connectorName) && wagmiConfig.state.status === "connected";
|
|
139
|
+
if (hasSameBinding) {
|
|
117
140
|
return;
|
|
118
141
|
}
|
|
119
|
-
if (!hasSameBinding &&
|
|
142
|
+
if (!hasSameBinding && w3aWagmiConnector) {
|
|
120
143
|
if (wagmiConfig.state.status === "connected") {
|
|
121
144
|
suppressWagmiDisconnect.value = true;
|
|
122
145
|
await disconnectWeb3AuthFromWagmi(wagmiConfig);
|
|
@@ -124,21 +147,21 @@ const Web3AuthWagmiProvider = defineComponent({
|
|
|
124
147
|
resetConnectorState(wagmiConfig);
|
|
125
148
|
}
|
|
126
149
|
}
|
|
127
|
-
|
|
150
|
+
lastSyncedProvider.value = newEth;
|
|
151
|
+
lastSyncedConnectorName.value = newConnection.connectorName;
|
|
152
|
+
const connector = setupConnector(newEth, wagmiConfig);
|
|
128
153
|
if (!connector) {
|
|
129
154
|
throw new Error("Failed to setup connector");
|
|
130
155
|
}
|
|
131
156
|
await connectWeb3AuthWithWagmi(connector, wagmiConfig);
|
|
132
|
-
lastSyncedProvider.value = newEth;
|
|
133
|
-
lastSyncedConnectorName.value = newConnection.connectorName;
|
|
134
157
|
reconnect();
|
|
135
|
-
} else {
|
|
158
|
+
} else if (!newIsConnected || chainNamespace.value !== CHAIN_NAMESPACES.EIP155) {
|
|
136
159
|
lastSyncedProvider.value = null;
|
|
137
160
|
lastSyncedConnectorName.value = null;
|
|
138
161
|
if (wagmiConfig.state.status === "connected") {
|
|
139
162
|
suppressWagmiDisconnect.value = true;
|
|
140
163
|
await disconnectWeb3AuthFromWagmi(wagmiConfig);
|
|
141
|
-
} else if (
|
|
164
|
+
} else if (w3aWagmiConnector) {
|
|
142
165
|
resetConnectorState(wagmiConfig);
|
|
143
166
|
}
|
|
144
167
|
}
|
|
@@ -203,7 +226,7 @@ const WagmiProvider = defineComponent({
|
|
|
203
226
|
return fallback(transports);
|
|
204
227
|
};
|
|
205
228
|
const defineWagmiConfig = () => {
|
|
206
|
-
var _web3Auth$
|
|
229
|
+
var _web3Auth$value2;
|
|
207
230
|
const configParams = _objectSpread(_objectSpread({
|
|
208
231
|
ssr: true
|
|
209
232
|
}, config), {}, {
|
|
@@ -214,7 +237,7 @@ const WagmiProvider = defineComponent({
|
|
|
214
237
|
client: undefined
|
|
215
238
|
});
|
|
216
239
|
const wagmiChains = [];
|
|
217
|
-
if (isInitialized.value && web3Auth !== null && web3Auth !== void 0 && (_web3Auth$
|
|
240
|
+
if (isInitialized.value && web3Auth !== null && web3Auth !== void 0 && (_web3Auth$value2 = web3Auth.value) !== null && _web3Auth$value2 !== void 0 && (_web3Auth$value2 = _web3Auth$value2.coreOptions) !== null && _web3Auth$value2 !== void 0 && _web3Auth$value2.chains) {
|
|
218
241
|
var _web3Auth$value$curre;
|
|
219
242
|
const defaultChainId = (_web3Auth$value$curre = web3Auth.value.currentChain) === null || _web3Auth$value$curre === void 0 ? void 0 : _web3Auth$value$curre.chainId;
|
|
220
243
|
const chains = web3Auth.value.coreOptions.chains.filter(chain => chain.chainNamespace === CHAIN_NAMESPACES.EIP155);
|
|
@@ -262,8 +285,8 @@ const WagmiProvider = defineComponent({
|
|
|
262
285
|
}
|
|
263
286
|
};
|
|
264
287
|
watch(isInitialized, (newIsInitialized, prevIsInitialized) => {
|
|
265
|
-
var _web3Auth$
|
|
266
|
-
(_web3Auth$
|
|
288
|
+
var _web3Auth$value3;
|
|
289
|
+
(_web3Auth$value3 = web3Auth.value) === null || _web3Auth$value3 === void 0 || _web3Auth$value3.setAnalyticsProperties({
|
|
267
290
|
wagmi_enabled: true
|
|
268
291
|
});
|
|
269
292
|
if (newIsInitialized && !prevIsInitialized) {
|
|
@@ -295,4 +318,4 @@ const WagmiProvider = defineComponent({
|
|
|
295
318
|
}
|
|
296
319
|
});
|
|
297
320
|
|
|
298
|
-
export { WagmiProvider };
|
|
321
|
+
export { WagmiProvider, connectWeb3AuthWithWagmi, createWeb3AuthConnectorForWagmi, disconnectWeb3AuthFromWagmi, getWeb3authConnector, resetConnectorState, setupConnector };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@web3auth/no-modal",
|
|
3
|
-
"version": "11.0.0
|
|
3
|
+
"version": "11.0.0",
|
|
4
4
|
"description": "Multi chain wallet aggregator for web3Auth",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"web3Auth/no-modal",
|
|
@@ -65,17 +65,17 @@
|
|
|
65
65
|
}
|
|
66
66
|
},
|
|
67
67
|
"dependencies": {
|
|
68
|
-
"@metamask/connect-evm": "^1.
|
|
69
|
-
"@metamask/connect-multichain": "^0.
|
|
70
|
-
"@metamask/connect-solana": "^1.
|
|
71
|
-
"@segment/analytics-next": "^1.
|
|
68
|
+
"@metamask/connect-evm": "^1.4.0",
|
|
69
|
+
"@metamask/connect-multichain": "^0.15.0",
|
|
70
|
+
"@metamask/connect-solana": "^1.2.0",
|
|
71
|
+
"@segment/analytics-next": "^1.84.0",
|
|
72
72
|
"@solana/client": "^1.7.0",
|
|
73
|
-
"@solana/kit": "^6.
|
|
73
|
+
"@solana/kit": "^6.9.0",
|
|
74
74
|
"@solana/wallet-standard-features": "^1.3.0",
|
|
75
|
-
"@toruslabs/base-controllers": "^9.
|
|
75
|
+
"@toruslabs/base-controllers": "^9.10.0",
|
|
76
76
|
"@toruslabs/constants": "^16.1.1",
|
|
77
77
|
"@toruslabs/eccrypto": "^7.0.0",
|
|
78
|
-
"@toruslabs/ethereum-controllers": "^9.
|
|
78
|
+
"@toruslabs/ethereum-controllers": "^9.10.0",
|
|
79
79
|
"@toruslabs/http-helpers": "^9.0.0",
|
|
80
80
|
"@toruslabs/loglevel-sentry": "^9.0.0",
|
|
81
81
|
"@toruslabs/metadata-helpers": "^8.2.0",
|
|
@@ -87,7 +87,7 @@
|
|
|
87
87
|
"@walletconnect/sign-client": "^2.23.9",
|
|
88
88
|
"@walletconnect/types": "^2.23.9",
|
|
89
89
|
"@walletconnect/utils": "^2.23.9",
|
|
90
|
-
"@web3auth/auth": "^11.8.
|
|
90
|
+
"@web3auth/auth": "^11.8.1",
|
|
91
91
|
"@web3auth/ws-embed": "^6.0.4",
|
|
92
92
|
"bignumber.js": "~9.3.1",
|
|
93
93
|
"deepmerge": "^4.3.1",
|
|
@@ -101,16 +101,16 @@
|
|
|
101
101
|
"devDependencies": {
|
|
102
102
|
"@coinbase/wallet-sdk": "^4.3.7",
|
|
103
103
|
"@solana/react-hooks": "^1.4.1",
|
|
104
|
-
"@types/react": "^19.2.
|
|
105
|
-
"@wagmi/core": "^3.
|
|
106
|
-
"@wagmi/vue": "^0.5.
|
|
107
|
-
"@x402/evm": "^2.
|
|
108
|
-
"@x402/fetch": "^2.
|
|
109
|
-
"@x402/svm": "^2.
|
|
110
|
-
"react": "^19.2.
|
|
111
|
-
"viem": "^2.
|
|
104
|
+
"@types/react": "^19.2.16",
|
|
105
|
+
"@wagmi/core": "^3.5.0",
|
|
106
|
+
"@wagmi/vue": "^0.5.17",
|
|
107
|
+
"@x402/evm": "^2.14.0",
|
|
108
|
+
"@x402/fetch": "^2.14.0",
|
|
109
|
+
"@x402/svm": "^2.14.0",
|
|
110
|
+
"react": "^19.2.7",
|
|
111
|
+
"viem": "^2.52.0",
|
|
112
112
|
"vue": "^3.x",
|
|
113
|
-
"wagmi": "^3.6.
|
|
113
|
+
"wagmi": "^3.6.16"
|
|
114
114
|
},
|
|
115
115
|
"exports": {
|
|
116
116
|
".": {
|
|
@@ -252,5 +252,5 @@
|
|
|
252
252
|
"node": ">=22.x",
|
|
253
253
|
"npm": ">=10.x"
|
|
254
254
|
},
|
|
255
|
-
"gitHead": "
|
|
255
|
+
"gitHead": "84b5f0c887209f24f098b7eea634747193bc1f2c"
|
|
256
256
|
}
|