@web3auth/modal 10.0.0-beta.9 → 10.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/README.md +2 -2
- package/dist/lib.cjs/packages/modal/src/config.js +1 -1
- package/dist/lib.cjs/packages/modal/src/connectors/coinbase-connector/index.js +12 -0
- package/dist/lib.cjs/packages/modal/src/modalManager.js +152 -91
- package/dist/lib.cjs/packages/modal/src/providers/ethereum-mpc-provider/index.js +12 -0
- package/dist/lib.cjs/packages/modal/src/providers/xrpl-provider/index.js +12 -0
- package/dist/lib.cjs/packages/modal/src/react/Web3AuthProvider.js +3 -1
- package/dist/lib.cjs/packages/modal/src/react/context/Web3AuthInnerContext.js +23 -19
- package/dist/lib.cjs/packages/modal/src/react/hooks/useIdentityToken.js +3 -3
- package/dist/lib.cjs/packages/modal/src/react/hooks/useWeb3AuthConnect.js +17 -1
- package/dist/lib.cjs/packages/modal/src/react/wagmi/constants.js +16 -0
- package/dist/lib.cjs/packages/modal/src/react/wagmi/provider.js +12 -6
- package/dist/lib.cjs/packages/modal/src/ui/components/ConnectWallet/ConnectWallet.js +17 -1
- package/dist/lib.cjs/packages/modal/src/ui/components/ConnectWallet/ConnectWalletChainFilter/ConnectWalletChainFilter.js +8 -5
- package/dist/lib.cjs/packages/modal/src/ui/components/Footer/Footer.js +1 -1
- package/dist/lib.cjs/packages/modal/src/ui/components/Login/Login.js +23 -4
- package/dist/lib.cjs/packages/modal/src/ui/components/Root/Root.js +1 -1
- package/dist/lib.cjs/packages/modal/src/ui/components/Widget/Widget.js +2 -2
- package/dist/lib.cjs/packages/modal/src/ui/context/AnalyticsContext.js +9 -0
- package/dist/lib.cjs/packages/modal/src/ui/css/index.css.js +1 -1
- package/dist/lib.cjs/packages/modal/src/ui/loginModal.js +42 -15
- package/dist/lib.cjs/packages/modal/src/utils.js +22 -0
- package/dist/lib.cjs/packages/modal/src/vue/Web3AuthProvider.js +11 -2
- package/dist/lib.cjs/packages/modal/src/vue/composables/useIdentityToken.js +3 -3
- package/dist/lib.cjs/packages/modal/src/vue/composables/useManageMFA.js +1 -1
- package/dist/lib.cjs/packages/modal/src/vue/composables/useWeb3AuthConnect.js +17 -1
- package/dist/lib.cjs/packages/modal/src/vue/solana/composables/useSolanaWallet.js +17 -14
- package/dist/lib.cjs/packages/modal/src/vue/wagmi/constants.js +16 -0
- package/dist/lib.cjs/packages/modal/src/vue/wagmi/provider.js +34 -15
- package/dist/lib.cjs/types/connectors/coinbase-connector/index.d.ts +1 -0
- package/dist/lib.cjs/types/interface.d.ts +0 -3
- package/dist/lib.cjs/types/modalManager.d.ts +5 -4
- package/dist/lib.cjs/types/providers/ethereum-mpc-provider/index.d.ts +1 -0
- package/dist/lib.cjs/types/providers/xrpl-provider/index.d.ts +1 -0
- package/dist/lib.cjs/types/react/Web3AuthProvider.d.ts +1 -1
- package/dist/lib.cjs/types/react/hooks/useIdentityToken.d.ts +2 -2
- package/dist/lib.cjs/types/react/hooks/useWeb3AuthConnect.d.ts +2 -1
- package/dist/lib.cjs/types/react/interfaces.d.ts +2 -1
- package/dist/lib.cjs/types/react/wagmi/constants.d.ts +43 -0
- package/dist/lib.cjs/types/ui/context/AnalyticsContext.d.ts +4 -0
- package/dist/lib.cjs/types/ui/interfaces.d.ts +3 -2
- package/dist/lib.cjs/types/ui/loginModal.d.ts +1 -0
- package/dist/lib.cjs/types/utils.d.ts +17 -0
- package/dist/lib.cjs/types/vue/composables/useIdentityToken.d.ts +1 -1
- package/dist/lib.cjs/types/vue/composables/useWeb3AuthConnect.d.ts +2 -1
- package/dist/lib.cjs/types/vue/wagmi/constants.d.ts +43 -0
- package/dist/lib.cjs/types/vue/wagmi/provider.d.ts +1 -0
- package/dist/lib.esm/packages/modal/src/config.js +1 -1
- package/dist/lib.esm/packages/modal/src/connectors/coinbase-connector/index.js +1 -0
- package/dist/lib.esm/packages/modal/src/modalManager.js +160 -97
- package/dist/lib.esm/packages/modal/src/providers/ethereum-mpc-provider/index.js +1 -0
- package/dist/lib.esm/packages/modal/src/providers/xrpl-provider/index.js +1 -0
- package/dist/lib.esm/packages/modal/src/react/Web3AuthProvider.js +3 -1
- package/dist/lib.esm/packages/modal/src/react/context/Web3AuthInnerContext.js +25 -21
- package/dist/lib.esm/packages/modal/src/react/hooks/useIdentityToken.js +3 -3
- package/dist/lib.esm/packages/modal/src/react/hooks/useWeb3AuthConnect.js +17 -1
- package/dist/lib.esm/packages/modal/src/react/wagmi/constants.js +14 -0
- package/dist/lib.esm/packages/modal/src/react/wagmi/provider.js +14 -9
- package/dist/lib.esm/packages/modal/src/ui/components/ConnectWallet/ConnectWallet.js +19 -2
- package/dist/lib.esm/packages/modal/src/ui/components/ConnectWallet/ConnectWalletChainFilter/ConnectWalletChainFilter.js +8 -5
- package/dist/lib.esm/packages/modal/src/ui/components/Footer/Footer.js +1 -1
- package/dist/lib.esm/packages/modal/src/ui/components/Login/Login.js +24 -5
- package/dist/lib.esm/packages/modal/src/ui/components/Root/Root.js +1 -1
- package/dist/lib.esm/packages/modal/src/ui/components/Widget/Widget.js +2 -2
- package/dist/lib.esm/packages/modal/src/ui/context/AnalyticsContext.js +7 -0
- package/dist/lib.esm/packages/modal/src/ui/css/index.css.js +1 -1
- package/dist/lib.esm/packages/modal/src/ui/loginModal.js +41 -14
- package/dist/lib.esm/packages/modal/src/utils.js +20 -0
- package/dist/lib.esm/packages/modal/src/vue/Web3AuthProvider.js +12 -3
- package/dist/lib.esm/packages/modal/src/vue/composables/useIdentityToken.js +3 -3
- package/dist/lib.esm/packages/modal/src/vue/composables/useManageMFA.js +1 -1
- package/dist/lib.esm/packages/modal/src/vue/composables/useWeb3AuthConnect.js +17 -1
- package/dist/lib.esm/packages/modal/src/vue/solana/composables/useSolanaWallet.js +17 -14
- package/dist/lib.esm/packages/modal/src/vue/wagmi/constants.js +14 -0
- package/dist/lib.esm/packages/modal/src/vue/wagmi/provider.js +37 -18
- package/dist/modal.umd.min.js +1 -1
- package/dist/modal.umd.min.js.LICENSE.txt +4 -6
- package/package.json +41 -16
|
@@ -36,12 +36,28 @@ const useWeb3AuthConnect = () => {
|
|
|
36
36
|
loading.value = false;
|
|
37
37
|
}
|
|
38
38
|
};
|
|
39
|
+
const connectTo = async (connectorType, loginParams) => {
|
|
40
|
+
try {
|
|
41
|
+
if (!web3Auth.value) throw WalletInitializationError.notReady();
|
|
42
|
+
error.value = null;
|
|
43
|
+
loading.value = true;
|
|
44
|
+
const localProvider = await web3Auth.value.connectTo(connectorType, loginParams);
|
|
45
|
+
connectorName.value = web3Auth.value.connectedConnectorName;
|
|
46
|
+
return localProvider;
|
|
47
|
+
} catch (err) {
|
|
48
|
+
error.value = err;
|
|
49
|
+
return null;
|
|
50
|
+
} finally {
|
|
51
|
+
loading.value = false;
|
|
52
|
+
}
|
|
53
|
+
};
|
|
39
54
|
return {
|
|
40
55
|
isConnected,
|
|
41
56
|
loading,
|
|
42
57
|
error,
|
|
43
58
|
connectorName,
|
|
44
|
-
connect
|
|
59
|
+
connect,
|
|
60
|
+
connectTo
|
|
45
61
|
};
|
|
46
62
|
};
|
|
47
63
|
|
|
@@ -12,30 +12,33 @@ const useSolanaWallet = () => {
|
|
|
12
12
|
const accounts = ref([]);
|
|
13
13
|
const solanaWallet = shallowRef(null);
|
|
14
14
|
const connection = shallowRef(null);
|
|
15
|
-
|
|
16
|
-
var _web3Auth$value,
|
|
15
|
+
const setupWallet = async () => {
|
|
16
|
+
var _web3Auth$value, _web3Auth$value2;
|
|
17
17
|
if (!((_web3Auth$value = web3Auth.value) !== null && _web3Auth$value !== void 0 && (_web3Auth$value = _web3Auth$value.currentChain) !== null && _web3Auth$value !== void 0 && _web3Auth$value.chainNamespace) || web3Auth.value.currentChain.chainNamespace !== CHAIN_NAMESPACES.SOLANA) {
|
|
18
18
|
return;
|
|
19
19
|
}
|
|
20
|
+
solanaWallet.value = new SolanaWallet(provider.value);
|
|
21
|
+
const result = await solanaWallet.value.requestAccounts();
|
|
22
|
+
if ((result === null || result === void 0 ? void 0 : result.length) > 0) {
|
|
23
|
+
accounts.value = result;
|
|
24
|
+
}
|
|
25
|
+
connection.value = new Connection((_web3Auth$value2 = web3Auth.value) === null || _web3Auth$value2 === void 0 || (_web3Auth$value2 = _web3Auth$value2.currentChain) === null || _web3Auth$value2 === void 0 ? void 0 : _web3Auth$value2.rpcTarget);
|
|
26
|
+
};
|
|
27
|
+
if (provider.value && !solanaWallet.value) {
|
|
28
|
+
setupWallet();
|
|
29
|
+
}
|
|
30
|
+
watch(provider, async newVal => {
|
|
20
31
|
if (!newVal && solanaWallet.value) {
|
|
21
32
|
solanaWallet.value = null;
|
|
22
33
|
accounts.value = null;
|
|
23
34
|
connection.value = null;
|
|
24
35
|
return;
|
|
25
36
|
}
|
|
26
|
-
if (!solanaWallet.value) {
|
|
27
|
-
|
|
28
|
-
}
|
|
29
|
-
if (solanaWallet.value && ((_accounts$value = accounts.value) === null || _accounts$value === void 0 ? void 0 : _accounts$value.length) === 0) {
|
|
30
|
-
const result = await solanaWallet.value.requestAccounts();
|
|
31
|
-
if ((result === null || result === void 0 ? void 0 : result.length) > 0) {
|
|
32
|
-
accounts.value = result;
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
if (solanaWallet.value && !connection.value) {
|
|
36
|
-
var _web3Auth$value2;
|
|
37
|
-
connection.value = new Connection((_web3Auth$value2 = web3Auth.value) === null || _web3Auth$value2 === void 0 || (_web3Auth$value2 = _web3Auth$value2.currentChain) === null || _web3Auth$value2 === void 0 ? void 0 : _web3Auth$value2.rpcTarget);
|
|
37
|
+
if (newVal && !solanaWallet.value) {
|
|
38
|
+
setupWallet();
|
|
38
39
|
}
|
|
40
|
+
}, {
|
|
41
|
+
immediate: true
|
|
39
42
|
});
|
|
40
43
|
return {
|
|
41
44
|
solanaWallet,
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { createConfig, http } from '@wagmi/vue';
|
|
2
|
+
import { mainnet } from '@wagmi/vue/chains';
|
|
3
|
+
|
|
4
|
+
const defaultWagmiConfig = createConfig({
|
|
5
|
+
chains: [mainnet],
|
|
6
|
+
connectors: [],
|
|
7
|
+
// or your basic wallets
|
|
8
|
+
ssr: true,
|
|
9
|
+
transports: {
|
|
10
|
+
[mainnet.id]: http(mainnet.rpcUrls.default.http[0])
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
export { defaultWagmiConfig };
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import _objectSpread from '@babel/runtime/helpers/objectSpread2';
|
|
2
2
|
import { hydrate } from '@wagmi/core';
|
|
3
|
-
import { useConfig, useAccountEffect, configKey, createConfig } from '@wagmi/vue';
|
|
3
|
+
import { useConfig, useReconnect, useAccountEffect, configKey, createConfig } from '@wagmi/vue';
|
|
4
4
|
import { injected } from '@wagmi/vue/connectors';
|
|
5
|
-
import {
|
|
5
|
+
import { randomId } from '@web3auth/auth';
|
|
6
|
+
import { log, CHAIN_NAMESPACES, WalletInitializationError } from '@web3auth/no-modal';
|
|
6
7
|
import { defineChain, webSocket, http } from 'viem';
|
|
7
|
-
import { defineComponent, h, watch, provide, shallowRef } from 'vue';
|
|
8
|
+
import { defineComponent, h, watch, provide, shallowRef, ref } from 'vue';
|
|
8
9
|
import '@web3auth/no-modal/vue';
|
|
9
10
|
import { useWeb3Auth } from '../composables/useWeb3Auth.js';
|
|
10
11
|
import { useWeb3AuthDisconnect } from '../composables/useWeb3AuthDisconnect.js';
|
|
12
|
+
import { defaultWagmiConfig } from './constants.js';
|
|
11
13
|
|
|
12
14
|
const WEB3AUTH_CONNECTOR_ID = "web3auth";
|
|
13
15
|
|
|
@@ -71,6 +73,9 @@ const Web3AuthWagmiProvider = defineComponent({
|
|
|
71
73
|
disconnect
|
|
72
74
|
} = useWeb3AuthDisconnect();
|
|
73
75
|
const wagmiConfig = useConfig();
|
|
76
|
+
const {
|
|
77
|
+
reconnect
|
|
78
|
+
} = useReconnect();
|
|
74
79
|
useAccountEffect({
|
|
75
80
|
onDisconnect: async () => {
|
|
76
81
|
log.info("Disconnected from wagmi");
|
|
@@ -85,6 +90,7 @@ const Web3AuthWagmiProvider = defineComponent({
|
|
|
85
90
|
throw new Error("Failed to setup connector");
|
|
86
91
|
}
|
|
87
92
|
await connectWeb3AuthWithWagmi(connector, wagmiConfig);
|
|
93
|
+
reconnect();
|
|
88
94
|
} else if (!newIsConnected) {
|
|
89
95
|
if (wagmiConfig.state.status === "connected") {
|
|
90
96
|
await disconnectWeb3AuthFromWagmi(wagmiConfig);
|
|
@@ -127,6 +133,7 @@ const WagmiProvider = defineComponent({
|
|
|
127
133
|
}
|
|
128
134
|
},
|
|
129
135
|
setup(props) {
|
|
136
|
+
var _web3Auth$value;
|
|
130
137
|
const {
|
|
131
138
|
config
|
|
132
139
|
} = props;
|
|
@@ -134,9 +141,13 @@ const WagmiProvider = defineComponent({
|
|
|
134
141
|
web3Auth,
|
|
135
142
|
isInitialized
|
|
136
143
|
} = useWeb3Auth();
|
|
137
|
-
const finalConfig = shallowRef(
|
|
144
|
+
const finalConfig = shallowRef(defaultWagmiConfig);
|
|
145
|
+
const configKey = ref(randomId());
|
|
146
|
+
(_web3Auth$value = web3Auth.value) === null || _web3Auth$value === void 0 || _web3Auth$value.setAnalyticsProperties({
|
|
147
|
+
wagmi_enabled: true
|
|
148
|
+
});
|
|
138
149
|
const defineWagmiConfig = () => {
|
|
139
|
-
var _web3Auth$
|
|
150
|
+
var _web3Auth$value2;
|
|
140
151
|
const configParams = _objectSpread(_objectSpread({
|
|
141
152
|
ssr: true
|
|
142
153
|
}, config), {}, {
|
|
@@ -147,10 +158,11 @@ const WagmiProvider = defineComponent({
|
|
|
147
158
|
client: undefined
|
|
148
159
|
});
|
|
149
160
|
const wagmiChains = [];
|
|
150
|
-
if (isInitialized.value && web3Auth !== null && web3Auth !== void 0 && (_web3Auth$
|
|
161
|
+
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) {
|
|
151
162
|
var _web3Auth$value$curre;
|
|
152
163
|
const defaultChainId = (_web3Auth$value$curre = web3Auth.value.currentChain) === null || _web3Auth$value$curre === void 0 ? void 0 : _web3Auth$value$curre.chainId;
|
|
153
|
-
const chains = web3Auth.value.coreOptions.chains;
|
|
164
|
+
const chains = web3Auth.value.coreOptions.chains.filter(chain => chain.chainNamespace === CHAIN_NAMESPACES.EIP155);
|
|
165
|
+
if (chains.length === 0) throw WalletInitializationError.invalidParams("No valid chains found in web3auth config for wagmi.");
|
|
154
166
|
chains.forEach(chain => {
|
|
155
167
|
const wagmiChain = defineChain({
|
|
156
168
|
id: Number.parseInt(chain.chainId, 16),
|
|
@@ -184,29 +196,36 @@ const WagmiProvider = defineComponent({
|
|
|
184
196
|
});
|
|
185
197
|
configParams.chains = [wagmiChains[0], ...wagmiChains.slice(1)];
|
|
186
198
|
}
|
|
187
|
-
if (!configParams.chains) return;
|
|
188
199
|
return createConfig(configParams);
|
|
189
200
|
};
|
|
190
|
-
|
|
191
|
-
if (
|
|
201
|
+
const hydrateWagmiConfig = () => {
|
|
202
|
+
if (finalConfig.value) {
|
|
203
|
+
hydrate(finalConfig.value, _objectSpread({
|
|
204
|
+
reconnectOnMount: false
|
|
205
|
+
}, props.config));
|
|
206
|
+
}
|
|
207
|
+
};
|
|
208
|
+
watch(isInitialized, (newIsInitialized, prevIsInitialized) => {
|
|
209
|
+
if (newIsInitialized && !prevIsInitialized) {
|
|
192
210
|
finalConfig.value = defineWagmiConfig();
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
reconnectOnMount: false
|
|
196
|
-
}, props.config));
|
|
197
|
-
}
|
|
211
|
+
hydrateWagmiConfig();
|
|
212
|
+
configKey.value = randomId();
|
|
198
213
|
}
|
|
199
214
|
}, {
|
|
200
215
|
immediate: true
|
|
201
216
|
});
|
|
217
|
+
if (!isInitialized.value) {
|
|
218
|
+
hydrateWagmiConfig();
|
|
219
|
+
}
|
|
202
220
|
return {
|
|
203
|
-
finalConfig
|
|
221
|
+
finalConfig,
|
|
222
|
+
configKey
|
|
204
223
|
};
|
|
205
224
|
},
|
|
206
225
|
render() {
|
|
207
|
-
if (!this.finalConfig) return null;
|
|
208
226
|
return h(Web3AuthWagmiInnerProvider, {
|
|
209
|
-
config: this.finalConfig
|
|
227
|
+
config: this.finalConfig,
|
|
228
|
+
key: this.configKey
|
|
210
229
|
}, {
|
|
211
230
|
default: () => {
|
|
212
231
|
var _this$$slots$default3, _this$$slots;
|