@web3auth/modal 10.0.0-beta.8 → 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/solana/hooks/useSolanaWallet.js +4 -0
- package/dist/lib.cjs/packages/modal/src/react/wagmi/constants.js +16 -0
- package/dist/lib.cjs/packages/modal/src/react/wagmi/provider.js +15 -10
- 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/ConnectWallet/ConnectWalletQrCode/ConnectWalletQrCode.js +1 -0
- 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 +6 -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 +19 -13
- package/dist/lib.cjs/packages/modal/src/vue/wagmi/constants.js +16 -0
- package/dist/lib.cjs/packages/modal/src/vue/wagmi/provider.js +35 -16
- 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/react/wagmi/provider.d.ts +1 -2
- 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/solana/hooks/useSolanaWallet.js +5 -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 +18 -14
- 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/ConnectWallet/ConnectWalletQrCode/ConnectWalletQrCode.js +1 -0
- 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 +6 -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 +20 -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 +39 -20
- package/dist/modal.umd.min.js +1 -1
- package/dist/modal.umd.min.js.LICENSE.txt +6 -8
- package/package.json +42 -33
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
const getLoginModalAnalyticsProperties = uiConfig => {
|
|
2
|
+
return {
|
|
3
|
+
ui_modal_login_methods_order: uiConfig === null || uiConfig === void 0 ? void 0 : uiConfig.loginMethodsOrder,
|
|
4
|
+
ui_modal_z_index: uiConfig === null || uiConfig === void 0 ? void 0 : uiConfig.modalZIndex,
|
|
5
|
+
ui_modal_display_errors_on_modal: uiConfig === null || uiConfig === void 0 ? void 0 : uiConfig.displayErrorsOnModal,
|
|
6
|
+
ui_modal_login_grid_col: uiConfig === null || uiConfig === void 0 ? void 0 : uiConfig.loginGridCol,
|
|
7
|
+
ui_modal_primary_button: uiConfig === null || uiConfig === void 0 ? void 0 : uiConfig.primaryButton,
|
|
8
|
+
ui_modal_widget_type: uiConfig === null || uiConfig === void 0 ? void 0 : uiConfig.widgetType,
|
|
9
|
+
ui_modal_target_id_used: Boolean(uiConfig === null || uiConfig === void 0 ? void 0 : uiConfig.targetId),
|
|
10
|
+
ui_modal_logo_alignment: uiConfig === null || uiConfig === void 0 ? void 0 : uiConfig.logoAlignment,
|
|
11
|
+
ui_modal_border_radius_type: uiConfig === null || uiConfig === void 0 ? void 0 : uiConfig.borderRadiusType,
|
|
12
|
+
ui_modal_button_radius_type: uiConfig === null || uiConfig === void 0 ? void 0 : uiConfig.buttonRadiusType,
|
|
13
|
+
ui_modal_sign_in_methods: uiConfig === null || uiConfig === void 0 ? void 0 : uiConfig.signInMethods,
|
|
14
|
+
ui_modal_add_previous_login_hint: uiConfig === null || uiConfig === void 0 ? void 0 : uiConfig.addPreviousLoginHint,
|
|
15
|
+
ui_modal_display_installed_external_wallets: uiConfig === null || uiConfig === void 0 ? void 0 : uiConfig.displayInstalledExternalWallets,
|
|
16
|
+
ui_modal_display_external_wallets_count: uiConfig === null || uiConfig === void 0 ? void 0 : uiConfig.displayExternalWalletsCount
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export { getLoginModalAnalyticsProperties };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CONNECTOR_EVENTS, Web3AuthContextKey, CONNECTOR_STATUS, WalletInitializationError } from '@web3auth/no-modal';
|
|
1
|
+
import { ANALYTICS_INTEGRATION_TYPE, CONNECTOR_EVENTS, Web3AuthContextKey, CONNECTOR_STATUS, WalletInitializationError } from '@web3auth/no-modal';
|
|
2
2
|
import { defineComponent, h, shallowRef, ref, watch, provide } from 'vue';
|
|
3
3
|
import { Web3Auth } from '../modalManager.js';
|
|
4
4
|
import { WalletServicesInnerProvider } from './WalletServicesInnerProvider.js';
|
|
@@ -44,6 +44,9 @@ const Web3AuthProvider = defineComponent({
|
|
|
44
44
|
web3AuthOptions
|
|
45
45
|
} = newConfig;
|
|
46
46
|
const web3AuthInstance = new Web3Auth(web3AuthOptions);
|
|
47
|
+
web3AuthInstance.setAnalyticsProperties({
|
|
48
|
+
integration_type: ANALYTICS_INTEGRATION_TYPE.VUE_COMPOSABLES
|
|
49
|
+
});
|
|
47
50
|
web3Auth.value = web3AuthInstance;
|
|
48
51
|
}, {
|
|
49
52
|
immediate: true
|
|
@@ -59,7 +62,7 @@ const Web3AuthProvider = defineComponent({
|
|
|
59
62
|
try {
|
|
60
63
|
initError.value = null;
|
|
61
64
|
isInitializing.value = true;
|
|
62
|
-
await newWeb3Auth.
|
|
65
|
+
await newWeb3Auth.init({
|
|
63
66
|
signal: controller.signal
|
|
64
67
|
});
|
|
65
68
|
} catch (error) {
|
|
@@ -98,7 +101,11 @@ const Web3AuthProvider = defineComponent({
|
|
|
98
101
|
status.value = web3Auth.value.status;
|
|
99
102
|
};
|
|
100
103
|
const errorListener = () => {
|
|
101
|
-
status.value =
|
|
104
|
+
status.value = web3Auth.value.status;
|
|
105
|
+
if (isConnected.value) {
|
|
106
|
+
isConnected.value = false;
|
|
107
|
+
provider.value = null;
|
|
108
|
+
}
|
|
102
109
|
};
|
|
103
110
|
const mfaEnabledListener = () => {
|
|
104
111
|
isMFAEnabled.value = true;
|
|
@@ -112,6 +119,7 @@ const Web3AuthProvider = defineComponent({
|
|
|
112
119
|
prevWeb3Auth.off(CONNECTOR_EVENTS.DISCONNECTED, disconnectedListener);
|
|
113
120
|
prevWeb3Auth.off(CONNECTOR_EVENTS.CONNECTING, connectingListener);
|
|
114
121
|
prevWeb3Auth.off(CONNECTOR_EVENTS.ERRORED, errorListener);
|
|
122
|
+
prevWeb3Auth.off(CONNECTOR_EVENTS.REHYDRATION_ERROR, errorListener);
|
|
115
123
|
prevWeb3Auth.off(CONNECTOR_EVENTS.MFA_ENABLED, mfaEnabledListener);
|
|
116
124
|
}
|
|
117
125
|
if (newWeb3Auth && newWeb3Auth !== prevWeb3Auth) {
|
|
@@ -123,6 +131,7 @@ const Web3AuthProvider = defineComponent({
|
|
|
123
131
|
newWeb3Auth.on(CONNECTOR_EVENTS.DISCONNECTED, disconnectedListener);
|
|
124
132
|
newWeb3Auth.on(CONNECTOR_EVENTS.CONNECTING, connectingListener);
|
|
125
133
|
newWeb3Auth.on(CONNECTOR_EVENTS.ERRORED, errorListener);
|
|
134
|
+
newWeb3Auth.on(CONNECTOR_EVENTS.REHYDRATION_ERROR, errorListener);
|
|
126
135
|
newWeb3Auth.on(CONNECTOR_EVENTS.MFA_ENABLED, mfaEnabledListener);
|
|
127
136
|
}
|
|
128
137
|
}, {
|
|
@@ -10,12 +10,12 @@ const useIdentityToken = () => {
|
|
|
10
10
|
const loading = ref(false);
|
|
11
11
|
const error = ref(null);
|
|
12
12
|
const token = ref(null);
|
|
13
|
-
const
|
|
13
|
+
const getIdentityToken = async () => {
|
|
14
14
|
try {
|
|
15
15
|
if (!web3Auth.value) throw WalletInitializationError.notReady();
|
|
16
16
|
error.value = null;
|
|
17
17
|
loading.value = true;
|
|
18
|
-
const result = await web3Auth.value.
|
|
18
|
+
const result = await web3Auth.value.getIdentityToken();
|
|
19
19
|
if (result !== null && result !== void 0 && result.idToken) {
|
|
20
20
|
token.value = result.idToken;
|
|
21
21
|
}
|
|
@@ -35,7 +35,7 @@ const useIdentityToken = () => {
|
|
|
35
35
|
loading,
|
|
36
36
|
error,
|
|
37
37
|
token,
|
|
38
|
-
|
|
38
|
+
getIdentityToken
|
|
39
39
|
};
|
|
40
40
|
};
|
|
41
41
|
|
|
@@ -13,7 +13,7 @@ const useManageMFA = () => {
|
|
|
13
13
|
if (!web3Auth.value) throw WalletInitializationError.notReady();
|
|
14
14
|
error.value = null;
|
|
15
15
|
loading.value = true;
|
|
16
|
-
await web3Auth.value.
|
|
16
|
+
await web3Auth.value.manageMFA();
|
|
17
17
|
} catch (err) {
|
|
18
18
|
error.value = err;
|
|
19
19
|
} finally {
|
|
@@ -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
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Connection } from '@solana/web3.js';
|
|
2
|
-
import { SolanaWallet } from '@web3auth/no-modal';
|
|
2
|
+
import { CHAIN_NAMESPACES, SolanaWallet } from '@web3auth/no-modal';
|
|
3
3
|
import { ref, shallowRef, watch } from 'vue';
|
|
4
4
|
import '@web3auth/no-modal/vue';
|
|
5
5
|
import { useWeb3Auth } from '../../composables/useWeb3Auth.js';
|
|
@@ -12,27 +12,33 @@ const useSolanaWallet = () => {
|
|
|
12
12
|
const accounts = ref([]);
|
|
13
13
|
const solanaWallet = shallowRef(null);
|
|
14
14
|
const connection = shallowRef(null);
|
|
15
|
+
const setupWallet = async () => {
|
|
16
|
+
var _web3Auth$value, _web3Auth$value2;
|
|
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
|
+
return;
|
|
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
|
+
}
|
|
15
30
|
watch(provider, async newVal => {
|
|
16
|
-
var _accounts$value;
|
|
17
31
|
if (!newVal && solanaWallet.value) {
|
|
18
32
|
solanaWallet.value = null;
|
|
19
33
|
accounts.value = null;
|
|
20
34
|
connection.value = null;
|
|
21
35
|
return;
|
|
22
36
|
}
|
|
23
|
-
if (!solanaWallet.value) {
|
|
24
|
-
|
|
25
|
-
}
|
|
26
|
-
if (solanaWallet.value && ((_accounts$value = accounts.value) === null || _accounts$value === void 0 ? void 0 : _accounts$value.length) === 0) {
|
|
27
|
-
const result = await solanaWallet.value.requestAccounts();
|
|
28
|
-
if ((result === null || result === void 0 ? void 0 : result.length) > 0) {
|
|
29
|
-
accounts.value = result;
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
if (solanaWallet.value && !connection.value) {
|
|
33
|
-
var _web3Auth$value;
|
|
34
|
-
connection.value = new Connection((_web3Auth$value = web3Auth.value) === null || _web3Auth$value === void 0 || (_web3Auth$value = _web3Auth$value.currentChain) === null || _web3Auth$value === void 0 ? void 0 : _web3Auth$value.rpcTarget);
|
|
37
|
+
if (newVal && !solanaWallet.value) {
|
|
38
|
+
setupWallet();
|
|
35
39
|
}
|
|
40
|
+
}, {
|
|
41
|
+
immediate: true
|
|
36
42
|
});
|
|
37
43
|
return {
|
|
38
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 {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
5
|
+
import { randomId } from '@web3auth/auth';
|
|
6
|
+
import { log, CHAIN_NAMESPACES, WalletInitializationError } from '@web3auth/no-modal';
|
|
7
|
+
import { defineChain, webSocket, http } from 'viem';
|
|
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),
|
|
@@ -180,33 +192,40 @@ const WagmiProvider = defineComponent({
|
|
|
180
192
|
} else {
|
|
181
193
|
wagmiChains.push(wagmiChain);
|
|
182
194
|
}
|
|
183
|
-
configParams.transports[wagmiChain.id] = http(chain.rpcTarget);
|
|
195
|
+
configParams.transports[wagmiChain.id] = chain.wsTarget ? webSocket(chain.wsTarget) : http(chain.rpcTarget);
|
|
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;
|