@web3auth/no-modal 11.0.0-beta.0 → 11.0.0-beta.2
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/index.js +8 -0
- package/dist/lib.cjs/account-linking/react.js +95 -0
- package/dist/lib.cjs/account-linking/rest.js +54 -0
- package/dist/lib.cjs/account-linking/vue.js +98 -0
- package/dist/lib.cjs/base/analytics.js +17 -2
- package/dist/lib.cjs/base/connector/constants.js +2 -0
- package/dist/lib.cjs/base/errors/index.js +48 -0
- package/dist/lib.cjs/base/utils.js +15 -3
- package/dist/lib.cjs/connectors/auth-connector/authConnector.js +501 -70
- package/dist/lib.cjs/connectors/base-evm-connector/baseEvmConnector.js +42 -23
- package/dist/lib.cjs/connectors/base-solana-connector/baseSolanaConnector.js +41 -24
- package/dist/lib.cjs/connectors/metamask-connector/metamaskConnector.js +76 -45
- package/dist/lib.cjs/connectors/wallet-connect-v2-connector/walletConnectV2Connector.js +41 -13
- package/dist/lib.cjs/index.js +20 -13
- package/dist/lib.cjs/noModal.js +834 -117
- package/dist/lib.cjs/plugins/wallet-services-plugin/plugin.js +1 -1
- package/dist/lib.cjs/providers/base-provider/baseProvider.js +65 -33
- package/dist/lib.cjs/react/context/useWeb3AuthInnerContextValue.js +43 -20
- package/dist/lib.cjs/react/hooks/useWallets.js +51 -0
- package/dist/lib.cjs/react/hooks/useWeb3AuthConnect.js +2 -2
- package/dist/lib.cjs/react/index.js +2 -0
- package/dist/lib.cjs/react/solana/hooks/useSolanaWallet.js +2 -2
- package/dist/lib.cjs/react/solana/provider.js +7 -1
- package/dist/lib.cjs/react/wagmi/provider.js +37 -5
- package/dist/lib.cjs/types/account-linking/index.d.ts +2 -0
- package/dist/lib.cjs/types/account-linking/interfaces.d.ts +90 -0
- package/dist/lib.cjs/types/account-linking/react.d.ts +19 -0
- package/dist/lib.cjs/types/account-linking/rest.d.ts +9 -0
- package/dist/lib.cjs/types/account-linking/vue.d.ts +20 -0
- package/dist/lib.cjs/types/base/analytics.d.ts +9 -0
- package/dist/lib.cjs/types/base/connector/baseConnector.d.ts +5 -0
- package/dist/lib.cjs/types/base/connector/constants.d.ts +2 -0
- package/dist/lib.cjs/types/base/connector/interfaces.d.ts +51 -6
- package/dist/lib.cjs/types/base/core/IWeb3Auth.d.ts +39 -2
- package/dist/lib.cjs/types/base/errors/index.d.ts +13 -0
- package/dist/lib.cjs/types/base/interfaces.d.ts +3 -1
- package/dist/lib.cjs/types/base/utils.d.ts +7 -1
- package/dist/lib.cjs/types/connectors/auth-connector/authConnector.d.ts +33 -3
- package/dist/lib.cjs/types/connectors/auth-connector/interface.d.ts +77 -2
- package/dist/lib.cjs/types/connectors/base-evm-connector/baseEvmConnector.d.ts +6 -0
- package/dist/lib.cjs/types/connectors/base-solana-connector/baseSolanaConnector.d.ts +6 -0
- package/dist/lib.cjs/types/index.d.ts +1 -0
- package/dist/lib.cjs/types/noModal.d.ts +104 -5
- package/dist/lib.cjs/types/providers/base-provider/baseProvider.d.ts +7 -0
- package/dist/lib.cjs/types/react/hooks/index.d.ts +1 -0
- package/dist/lib.cjs/types/react/hooks/useWallets.d.ts +8 -0
- package/dist/lib.cjs/types/vue/composables/index.d.ts +1 -0
- package/dist/lib.cjs/types/vue/composables/useWallets.d.ts +9 -0
- package/dist/lib.cjs/vue/composables/useWallets.js +52 -0
- package/dist/lib.cjs/vue/composables/useWeb3AuthConnect.js +2 -2
- package/dist/lib.cjs/vue/index.js +2 -0
- package/dist/lib.cjs/vue/solana/composables/useSolanaWallet.js +2 -2
- package/dist/lib.cjs/vue/solana/provider.js +50 -23
- package/dist/lib.cjs/vue/useWeb3AuthInnerContextValue.js +13 -4
- package/dist/lib.cjs/vue/wagmi/provider.js +35 -7
- package/dist/lib.esm/account-linking/index.js +1 -0
- package/dist/lib.esm/account-linking/react.js +74 -0
- package/dist/lib.esm/account-linking/rest.js +51 -0
- package/dist/lib.esm/account-linking/vue.js +78 -0
- package/dist/lib.esm/base/analytics.js +17 -2
- package/dist/lib.esm/base/connector/constants.js +2 -0
- package/dist/lib.esm/base/errors/index.js +48 -1
- package/dist/lib.esm/base/utils.js +16 -4
- package/dist/lib.esm/connectors/auth-connector/authConnector.js +462 -31
- package/dist/lib.esm/connectors/base-evm-connector/baseEvmConnector.js +43 -24
- package/dist/lib.esm/connectors/base-solana-connector/baseSolanaConnector.js +43 -26
- package/dist/lib.esm/connectors/coinbase-connector/coinbaseConnector.js +2 -2
- package/dist/lib.esm/connectors/injected-evm-connector/injectedEvmConnector.js +2 -2
- package/dist/lib.esm/connectors/injected-solana-connector/walletStandardConnector.js +3 -3
- package/dist/lib.esm/connectors/metamask-connector/metamaskConnector.js +80 -49
- package/dist/lib.esm/connectors/wallet-connect-v2-connector/WalletConnectV2Provider.js +2 -2
- package/dist/lib.esm/connectors/wallet-connect-v2-connector/walletConnectV2Connector.js +43 -15
- package/dist/lib.esm/connectors/wallet-connect-v2-connector/wcSolanaWallet.js +1 -1
- package/dist/lib.esm/index.js +4 -3
- package/dist/lib.esm/noModal.js +851 -126
- package/dist/lib.esm/plugins/wallet-services-plugin/plugin.js +3 -3
- package/dist/lib.esm/providers/base-provider/baseProvider.js +68 -38
- package/dist/lib.esm/react/context/useWeb3AuthInnerContextValue.js +45 -21
- package/dist/lib.esm/react/hooks/useWallets.js +33 -0
- package/dist/lib.esm/react/hooks/useWeb3AuthConnect.js +2 -2
- package/dist/lib.esm/react/index.js +1 -0
- package/dist/lib.esm/react/solana/hooks/useSolanaWallet.js +2 -2
- package/dist/lib.esm/react/solana/provider.js +9 -2
- package/dist/lib.esm/react/wagmi/provider.js +39 -7
- package/dist/lib.esm/vue/composables/useCheckout.js +1 -1
- package/dist/lib.esm/vue/composables/useFunding.js +1 -1
- package/dist/lib.esm/vue/composables/useReceive.js +1 -1
- package/dist/lib.esm/vue/composables/useSwap.js +1 -1
- package/dist/lib.esm/vue/composables/useWalletConnectScanner.js +1 -1
- package/dist/lib.esm/vue/composables/useWalletUI.js +1 -1
- package/dist/lib.esm/vue/composables/useWallets.js +35 -0
- package/dist/lib.esm/vue/composables/useWeb3AuthConnect.js +2 -2
- package/dist/lib.esm/vue/index.js +1 -0
- package/dist/lib.esm/vue/solana/composables/useSignAndSendTransaction.js +1 -1
- package/dist/lib.esm/vue/solana/composables/useSignMessage.js +1 -1
- package/dist/lib.esm/vue/solana/composables/useSignTransaction.js +1 -1
- package/dist/lib.esm/vue/solana/composables/useSolanaWallet.js +2 -2
- package/dist/lib.esm/vue/solana/provider.js +51 -24
- package/dist/lib.esm/vue/useWeb3AuthInnerContextValue.js +12 -3
- package/dist/lib.esm/vue/wagmi/provider.js +36 -8
- package/package.json +44 -20
|
@@ -2,10 +2,10 @@ import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
|
2
2
|
import { SafeEventEmitter } from '@web3auth/auth';
|
|
3
3
|
export { BUTTON_POSITION, CONFIRMATION_STRATEGY } from '@web3auth/ws-embed';
|
|
4
4
|
import { EVM_PLUGINS, PLUGIN_STATUS, PLUGIN_NAMESPACES, PLUGIN_EVENTS } from '../../base/plugin/IPlugin.js';
|
|
5
|
-
import { WalletServicesPluginError } from '../../base/plugin/errors.js';
|
|
6
|
-
import { CAN_AUTHORIZE_STATUSES } from '../../base/connector/connectorStatus.js';
|
|
7
5
|
import { WALLET_CONNECTORS } from '../../base/wallet/index.js';
|
|
6
|
+
import { WalletServicesPluginError } from '../../base/plugin/errors.js';
|
|
8
7
|
import { CHAIN_NAMESPACES } from '@toruslabs/base-controllers';
|
|
8
|
+
import { CAN_AUTHORIZE_STATUSES } from '../../base/connector/connectorStatus.js';
|
|
9
9
|
import { log } from '../../base/loglevel.js';
|
|
10
10
|
import { ANALYTICS_EVENTS } from '../../base/analytics.js';
|
|
11
11
|
|
|
@@ -24,7 +24,7 @@ class WalletServicesPlugin extends SafeEventEmitter {
|
|
|
24
24
|
async initWithWeb3Auth(web3auth, _whiteLabel, analytics) {
|
|
25
25
|
if (this.isInitialized) return;
|
|
26
26
|
if (!web3auth) throw WalletServicesPluginError.web3authRequired();
|
|
27
|
-
if (web3auth.connection && !this.SUPPORTED_CONNECTORS.includes(web3auth.
|
|
27
|
+
if (web3auth.connection && !this.SUPPORTED_CONNECTORS.includes(web3auth.primaryConnectorName)) throw WalletServicesPluginError.notInitialized();
|
|
28
28
|
const currentChainConfig = web3auth.currentChain;
|
|
29
29
|
if (![CHAIN_NAMESPACES.EIP155, CHAIN_NAMESPACES.SOLANA].includes(currentChainConfig === null || currentChainConfig === void 0 ? void 0 : currentChainConfig.chainNamespace)) throw WalletServicesPluginError.unsupportedChainNamespace();
|
|
30
30
|
this.web3auth = web3auth;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _objectSpread from '@babel/runtime/helpers/objectSpread2';
|
|
2
2
|
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
3
|
-
import { BaseController
|
|
3
|
+
import { BaseController } from '@toruslabs/base-controllers';
|
|
4
4
|
import { rpcErrors } from '@web3auth/auth';
|
|
5
5
|
import { EIP1193_EVENTS } from './utils.js';
|
|
6
6
|
import { WalletInitializationError, WalletProviderError } from '../../base/errors/index.js';
|
|
@@ -19,6 +19,8 @@ class BaseProvider extends BaseController {
|
|
|
19
19
|
// set to true when the keyExportEnabled flag is set by code.
|
|
20
20
|
// This is to prevent the flag from being overridden by the dashboard config.
|
|
21
21
|
_defineProperty(this, "keyExportFlagSetByCode", false);
|
|
22
|
+
_defineProperty(this, "providerEventBridges", new Map());
|
|
23
|
+
_defineProperty(this, "providerListenerBridgeRegistered", false);
|
|
22
24
|
const {
|
|
23
25
|
chain
|
|
24
26
|
} = config;
|
|
@@ -90,45 +92,19 @@ class BaseProvider extends BaseController {
|
|
|
90
92
|
})).catch(err => callback(err, null));
|
|
91
93
|
}
|
|
92
94
|
updateProviderEngineProxy(provider) {
|
|
95
|
+
if (this._providerEngineProxy === provider) return;
|
|
93
96
|
if (this._providerEngineProxy) {
|
|
94
|
-
//
|
|
95
|
-
this._providerEngineProxy
|
|
96
|
-
|
|
97
|
-
// we want events to propagate from Ethereum provider -> wrapper provider (e.g. CommonJRPC provider) -> SDK -> dapp
|
|
98
|
-
// ensure that only one handler is added for each event
|
|
99
|
-
const reEmitHandler = event => {
|
|
100
|
-
// skip newListener event
|
|
101
|
-
if (event === "newListener") return;
|
|
102
|
-
|
|
103
|
-
// listen to the event from the Ethereum provider
|
|
104
|
-
provider.on(event, (...args) => {
|
|
105
|
-
// handle chainChanged event: update chainId state
|
|
106
|
-
if (event === EIP1193_EVENTS.CHAIN_CHANGED) {
|
|
107
|
-
const chainId = args[0];
|
|
108
|
-
this.update({
|
|
109
|
-
chainId
|
|
110
|
-
});
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
// re-emit the event
|
|
114
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
115
|
-
this.emit(event, ...args);
|
|
116
|
-
});
|
|
117
|
-
};
|
|
118
|
-
|
|
119
|
-
// handle existing events
|
|
120
|
-
this.eventNames().forEach(event => {
|
|
121
|
-
reEmitHandler(event);
|
|
122
|
-
});
|
|
123
|
-
// handle when a new listener is added
|
|
124
|
-
this.on("newListener", event => {
|
|
125
|
-
// skip if the event already exists
|
|
126
|
-
if (this.listenerCount(event) > 0) return;
|
|
127
|
-
reEmitHandler(event);
|
|
128
|
-
});
|
|
129
|
-
} else {
|
|
130
|
-
this._providerEngineProxy = createEventEmitterProxy(provider);
|
|
97
|
+
// remove all event bridges from the previous provider
|
|
98
|
+
this.detachProviderEventBridges(this._providerEngineProxy);
|
|
131
99
|
}
|
|
100
|
+
|
|
101
|
+
// attach all event bridges to the new provider
|
|
102
|
+
this._providerEngineProxy = provider;
|
|
103
|
+
this.ensureProviderListenerBridge();
|
|
104
|
+
this.eventNames().forEach(event => {
|
|
105
|
+
this.ensureProviderEventBridge(event);
|
|
106
|
+
});
|
|
107
|
+
this.attachProviderEventBridges(provider);
|
|
132
108
|
}
|
|
133
109
|
setKeyExportFlag(flag) {
|
|
134
110
|
if (!this.keyExportFlagSetByCode) {
|
|
@@ -143,6 +119,60 @@ class BaseProvider extends BaseController {
|
|
|
143
119
|
getChain(chainId) {
|
|
144
120
|
return this.config.chains.find(chain => chain.chainId === chainId);
|
|
145
121
|
}
|
|
122
|
+
ensureProviderListenerBridge() {
|
|
123
|
+
if (this.providerListenerBridgeRegistered) return;
|
|
124
|
+
this.providerListenerBridgeRegistered = true;
|
|
125
|
+
this.on("newListener", event => {
|
|
126
|
+
this.ensureProviderEventBridge(event);
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
ensureProviderEventBridge(event) {
|
|
130
|
+
if (event === "newListener" || event === "removeListener" || this.providerEventBridges.has(event)) return;
|
|
131
|
+
const bridge = {
|
|
132
|
+
handler: (...args) => {
|
|
133
|
+
if (event === EIP1193_EVENTS.CHAIN_CHANGED) {
|
|
134
|
+
const chainId = args[0];
|
|
135
|
+
this.update({
|
|
136
|
+
chainId
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
141
|
+
this.emit(event, ...args);
|
|
142
|
+
}
|
|
143
|
+
};
|
|
144
|
+
this.providerEventBridges.set(event, bridge);
|
|
145
|
+
if (!this._providerEngineProxy) return;
|
|
146
|
+
bridge.detach = this.attachProviderEventBridge(this._providerEngineProxy, event, bridge.handler);
|
|
147
|
+
}
|
|
148
|
+
attachProviderEventBridges(provider) {
|
|
149
|
+
this.providerEventBridges.forEach((bridge, event) => {
|
|
150
|
+
if (bridge.detach) return;
|
|
151
|
+
bridge.detach = this.attachProviderEventBridge(provider, event, bridge.handler);
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
attachProviderEventBridge(provider, event, handler) {
|
|
155
|
+
const removableProvider = provider;
|
|
156
|
+
const maybeDetach = removableProvider.on(event, handler);
|
|
157
|
+
return typeof maybeDetach === "function" ? () => {
|
|
158
|
+
maybeDetach();
|
|
159
|
+
} : undefined;
|
|
160
|
+
}
|
|
161
|
+
detachProviderEventBridges(provider) {
|
|
162
|
+
this.providerEventBridges.forEach((bridge, event) => {
|
|
163
|
+
if (bridge.detach) {
|
|
164
|
+
bridge.detach();
|
|
165
|
+
} else {
|
|
166
|
+
const removableProvider = provider;
|
|
167
|
+
if (typeof removableProvider.removeListener === "function") {
|
|
168
|
+
removableProvider.removeListener(event, bridge.handler);
|
|
169
|
+
} else if (typeof removableProvider.off === "function") {
|
|
170
|
+
removableProvider.off(event, bridge.handler);
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
bridge.detach = undefined;
|
|
174
|
+
});
|
|
175
|
+
}
|
|
146
176
|
}
|
|
147
177
|
|
|
148
178
|
export { BaseProvider };
|
|
@@ -1,9 +1,24 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useMemo, useState, useCallback, useEffect } from 'react';
|
|
2
2
|
import { WalletInitializationError } from '../../base/errors/index.js';
|
|
3
|
-
import { CONNECTOR_EVENTS, CONNECTOR_STATUS } from '../../base/connector/constants.js';
|
|
4
3
|
import { LOGIN_MODE } from '../../base/constants.js';
|
|
5
4
|
import { ANALYTICS_INTEGRATION_TYPE } from '../../base/analytics.js';
|
|
5
|
+
import { CONNECTOR_EVENTS, CONNECTOR_STATUS } from '../../base/connector/constants.js';
|
|
6
|
+
import { CONNECTED_STATUSES } from '../../base/connector/connectorStatus.js';
|
|
6
7
|
|
|
8
|
+
function getInitialState(web3Auth) {
|
|
9
|
+
var _web3Auth$currentChai, _web3Auth$currentChai2;
|
|
10
|
+
const isConnected = CONNECTED_STATUSES.includes(web3Auth.status);
|
|
11
|
+
const isAuthorized = web3Auth.status === CONNECTOR_STATUS.AUTHORIZED;
|
|
12
|
+
return {
|
|
13
|
+
chainId: isConnected ? web3Auth.currentChainId : null,
|
|
14
|
+
chainNamespace: isConnected ? (_web3Auth$currentChai = (_web3Auth$currentChai2 = web3Auth.currentChain) === null || _web3Auth$currentChai2 === void 0 ? void 0 : _web3Auth$currentChai2.chainNamespace) !== null && _web3Auth$currentChai !== void 0 ? _web3Auth$currentChai : null : null,
|
|
15
|
+
connection: isConnected ? web3Auth.connection : null,
|
|
16
|
+
isAuthorized,
|
|
17
|
+
isConnected,
|
|
18
|
+
isInitialized: isConnected,
|
|
19
|
+
status: web3Auth.status
|
|
20
|
+
};
|
|
21
|
+
}
|
|
7
22
|
function useWeb3AuthInnerContextValue({
|
|
8
23
|
Web3AuthConstructor,
|
|
9
24
|
web3AuthOptions,
|
|
@@ -12,20 +27,20 @@ function useWeb3AuthInnerContextValue({
|
|
|
12
27
|
cleanupOnUnmount = false,
|
|
13
28
|
initEffectDependency
|
|
14
29
|
}) {
|
|
15
|
-
const [chainId, setChainId] = useState(null);
|
|
16
|
-
const [chainNamespace, setChainNamespace] = useState(null);
|
|
17
|
-
const [isInitializing, setIsInitializing] = useState(false);
|
|
18
|
-
const [initError, setInitError] = useState(null);
|
|
19
|
-
const [connection, setConnection] = useState(null);
|
|
20
|
-
const [isInitialized, setIsInitialized] = useState(false);
|
|
21
|
-
const [isMFAEnabled, setIsMFAEnabled] = useState(false);
|
|
22
30
|
const web3Auth = useMemo(() => {
|
|
23
|
-
setConnection(null);
|
|
24
31
|
return new Web3AuthConstructor(web3AuthOptions, initialState);
|
|
25
32
|
}, [Web3AuthConstructor, web3AuthOptions, initialState]);
|
|
26
|
-
const
|
|
27
|
-
const [
|
|
28
|
-
const [
|
|
33
|
+
const initialWeb3AuthState = getInitialState(web3Auth);
|
|
34
|
+
const [chainId, setChainId] = useState(() => initialWeb3AuthState.chainId);
|
|
35
|
+
const [chainNamespace, setChainNamespace] = useState(() => initialWeb3AuthState.chainNamespace);
|
|
36
|
+
const [isInitializing, setIsInitializing] = useState(false);
|
|
37
|
+
const [initError, setInitError] = useState(null);
|
|
38
|
+
const [connection, setConnection] = useState(() => initialWeb3AuthState.connection);
|
|
39
|
+
const [isInitialized, setIsInitialized] = useState(initialWeb3AuthState.isInitialized);
|
|
40
|
+
const [isMFAEnabled, setIsMFAEnabled] = useState(false);
|
|
41
|
+
const [isConnected, setIsConnected] = useState(initialWeb3AuthState.isConnected);
|
|
42
|
+
const [status, setStatus] = useState(initialWeb3AuthState.status);
|
|
43
|
+
const [isAuthorized, setIsAuthorized] = useState(initialWeb3AuthState.isAuthorized);
|
|
29
44
|
const getPlugin = useCallback(name => {
|
|
30
45
|
if (!web3Auth) throw WalletInitializationError.notReady();
|
|
31
46
|
return web3Auth.getPlugin(name);
|
|
@@ -34,7 +49,7 @@ function useWeb3AuthInnerContextValue({
|
|
|
34
49
|
const controller = new AbortController();
|
|
35
50
|
async function init() {
|
|
36
51
|
try {
|
|
37
|
-
var _web3Auth$
|
|
52
|
+
var _web3Auth$currentChai3;
|
|
38
53
|
setInitError(null);
|
|
39
54
|
setIsInitializing(true);
|
|
40
55
|
web3Auth.setAnalyticsProperties({
|
|
@@ -44,7 +59,7 @@ function useWeb3AuthInnerContextValue({
|
|
|
44
59
|
signal: controller.signal
|
|
45
60
|
});
|
|
46
61
|
setChainId(web3Auth.currentChainId);
|
|
47
|
-
setChainNamespace((_web3Auth$
|
|
62
|
+
setChainNamespace((_web3Auth$currentChai3 = web3Auth.currentChain) === null || _web3Auth$currentChai3 === void 0 ? void 0 : _web3Auth$currentChai3.chainNamespace);
|
|
48
63
|
} catch (error) {
|
|
49
64
|
setInitError(error);
|
|
50
65
|
} finally {
|
|
@@ -59,9 +74,9 @@ function useWeb3AuthInnerContextValue({
|
|
|
59
74
|
useEffect(() => {
|
|
60
75
|
var _connection$ethereumP;
|
|
61
76
|
const handleChainChange = async nextChainId => {
|
|
62
|
-
var _web3Auth$
|
|
77
|
+
var _web3Auth$currentChai4;
|
|
63
78
|
setChainId(nextChainId);
|
|
64
|
-
setChainNamespace((_web3Auth$
|
|
79
|
+
setChainNamespace((_web3Auth$currentChai4 = web3Auth.currentChain) === null || _web3Auth$currentChai4 === void 0 ? void 0 : _web3Auth$currentChai4.chainNamespace);
|
|
65
80
|
};
|
|
66
81
|
const provider = (_connection$ethereumP = connection === null || connection === void 0 ? void 0 : connection.ethereumProvider) !== null && _connection$ethereumP !== void 0 ? _connection$ethereumP : null;
|
|
67
82
|
if (!provider) return undefined;
|
|
@@ -83,12 +98,12 @@ function useWeb3AuthInnerContextValue({
|
|
|
83
98
|
setStatus(web3Auth.status);
|
|
84
99
|
// we do this because of rehydration issues. status connected is fired first but web3auth sdk is not ready yet.
|
|
85
100
|
if (web3Auth.status === CONNECTOR_STATUS.CONNECTED) {
|
|
86
|
-
var _web3Auth$
|
|
101
|
+
var _web3Auth$currentChai5, _web3Auth$currentChai6;
|
|
87
102
|
setIsInitialized(true);
|
|
88
103
|
setIsConnected(true);
|
|
89
104
|
setConnection(web3Auth.connection);
|
|
90
105
|
setChainId(web3Auth.currentChainId);
|
|
91
|
-
setChainNamespace((_web3Auth$
|
|
106
|
+
setChainNamespace((_web3Auth$currentChai5 = (_web3Auth$currentChai6 = web3Auth.currentChain) === null || _web3Auth$currentChai6 === void 0 ? void 0 : _web3Auth$currentChai6.chainNamespace) !== null && _web3Auth$currentChai5 !== void 0 ? _web3Auth$currentChai5 : null);
|
|
92
107
|
}
|
|
93
108
|
};
|
|
94
109
|
const disconnectedListener = () => {
|
|
@@ -119,12 +134,12 @@ function useWeb3AuthInnerContextValue({
|
|
|
119
134
|
const consentAcceptedListener = () => {
|
|
120
135
|
setStatus(web3Auth.status);
|
|
121
136
|
if (web3Auth.status === CONNECTOR_STATUS.CONNECTED || web3Auth.status === CONNECTOR_STATUS.AUTHORIZED) {
|
|
122
|
-
var _web3Auth$
|
|
137
|
+
var _web3Auth$currentChai7, _web3Auth$currentChai8;
|
|
123
138
|
setIsInitialized(true);
|
|
124
139
|
setIsConnected(true);
|
|
125
140
|
setConnection(web3Auth.connection);
|
|
126
141
|
setChainId(web3Auth.currentChainId);
|
|
127
|
-
setChainNamespace((_web3Auth$
|
|
142
|
+
setChainNamespace((_web3Auth$currentChai7 = (_web3Auth$currentChai8 = web3Auth.currentChain) === null || _web3Auth$currentChai8 === void 0 ? void 0 : _web3Auth$currentChai8.chainNamespace) !== null && _web3Auth$currentChai7 !== void 0 ? _web3Auth$currentChai7 : null);
|
|
128
143
|
if (web3Auth.status === CONNECTOR_STATUS.AUTHORIZED) {
|
|
129
144
|
setIsAuthorized(true);
|
|
130
145
|
}
|
|
@@ -133,6 +148,13 @@ function useWeb3AuthInnerContextValue({
|
|
|
133
148
|
const mfaEnabledListener = nextIsMFAEnabled => {
|
|
134
149
|
if (typeof nextIsMFAEnabled === "boolean") setIsMFAEnabled(nextIsMFAEnabled);
|
|
135
150
|
};
|
|
151
|
+
const connectionUpdatedListener = () => {
|
|
152
|
+
var _web3Auth$currentChai9, _web3Auth$currentChai0;
|
|
153
|
+
setStatus(web3Auth.status);
|
|
154
|
+
setConnection(web3Auth.connection);
|
|
155
|
+
setChainId(web3Auth.currentChainId);
|
|
156
|
+
setChainNamespace((_web3Auth$currentChai9 = (_web3Auth$currentChai0 = web3Auth.currentChain) === null || _web3Auth$currentChai0 === void 0 ? void 0 : _web3Auth$currentChai0.chainNamespace) !== null && _web3Auth$currentChai9 !== void 0 ? _web3Auth$currentChai9 : null);
|
|
157
|
+
};
|
|
136
158
|
if (web3Auth) {
|
|
137
159
|
web3Auth.on(CONNECTOR_EVENTS.NOT_READY, notReadyListener);
|
|
138
160
|
web3Auth.on(CONNECTOR_EVENTS.READY, readyListener);
|
|
@@ -143,6 +165,7 @@ function useWeb3AuthInnerContextValue({
|
|
|
143
165
|
web3Auth.on(CONNECTOR_EVENTS.ERRORED, errorListener);
|
|
144
166
|
web3Auth.on(CONNECTOR_EVENTS.REHYDRATION_ERROR, rehydrationErrorListener);
|
|
145
167
|
web3Auth.on(CONNECTOR_EVENTS.MFA_ENABLED, mfaEnabledListener);
|
|
168
|
+
web3Auth.on(CONNECTOR_EVENTS.CONNECTION_UPDATED, connectionUpdatedListener);
|
|
146
169
|
if (web3Auth.loginMode === LOGIN_MODE.MODAL) {
|
|
147
170
|
web3Auth.on(CONNECTOR_EVENTS.CONSENT_ACCEPTED, consentAcceptedListener);
|
|
148
171
|
}
|
|
@@ -158,6 +181,7 @@ function useWeb3AuthInnerContextValue({
|
|
|
158
181
|
web3Auth.removeListener(CONNECTOR_EVENTS.REHYDRATION_ERROR, rehydrationErrorListener);
|
|
159
182
|
web3Auth.removeListener(CONNECTOR_EVENTS.MFA_ENABLED, mfaEnabledListener);
|
|
160
183
|
web3Auth.removeListener(CONNECTOR_EVENTS.AUTHORIZED, authorizedListener);
|
|
184
|
+
web3Auth.removeListener(CONNECTOR_EVENTS.CONNECTION_UPDATED, connectionUpdatedListener);
|
|
161
185
|
if (web3Auth.loginMode === LOGIN_MODE.MODAL) {
|
|
162
186
|
web3Auth.removeListener(CONNECTOR_EVENTS.CONSENT_ACCEPTED, consentAcceptedListener);
|
|
163
187
|
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { useState, useCallback } from 'react';
|
|
2
|
+
import { useWeb3AuthInner } from './useWeb3AuthInner.js';
|
|
3
|
+
import { WalletInitializationError } from '../../base/errors/index.js';
|
|
4
|
+
|
|
5
|
+
const useWallets = () => {
|
|
6
|
+
const {
|
|
7
|
+
web3Auth
|
|
8
|
+
} = useWeb3AuthInner();
|
|
9
|
+
const [loading, setLoading] = useState(false);
|
|
10
|
+
const [error, setError] = useState(null);
|
|
11
|
+
const [wallets, setWallets] = useState([]);
|
|
12
|
+
const syncWallets = useCallback(async () => {
|
|
13
|
+
if (!web3Auth) throw WalletInitializationError.notReady();
|
|
14
|
+
setLoading(true);
|
|
15
|
+
setError(null);
|
|
16
|
+
try {
|
|
17
|
+
const result = await web3Auth.getConnectedAccountsWithProviders();
|
|
18
|
+
setWallets(result);
|
|
19
|
+
} catch (err) {
|
|
20
|
+
setError(err);
|
|
21
|
+
} finally {
|
|
22
|
+
setLoading(false);
|
|
23
|
+
}
|
|
24
|
+
}, [web3Auth]);
|
|
25
|
+
return {
|
|
26
|
+
loading,
|
|
27
|
+
error,
|
|
28
|
+
wallets,
|
|
29
|
+
syncWallets
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export { useWallets };
|
|
@@ -16,7 +16,7 @@ const useWeb3AuthConnect = () => {
|
|
|
16
16
|
setConnectorName(null);
|
|
17
17
|
}
|
|
18
18
|
if (isConnected && !connectorName) {
|
|
19
|
-
setConnectorName(web3Auth.
|
|
19
|
+
setConnectorName(web3Auth.primaryConnectorName);
|
|
20
20
|
}
|
|
21
21
|
}, [isConnected, connectorName, web3Auth]);
|
|
22
22
|
const connect = useCallback(async (connector, params) => {
|
|
@@ -25,7 +25,7 @@ const useWeb3AuthConnect = () => {
|
|
|
25
25
|
try {
|
|
26
26
|
const provider = await web3Auth.connectTo(connector, params);
|
|
27
27
|
if (provider) {
|
|
28
|
-
setConnectorName(web3Auth.
|
|
28
|
+
setConnectorName(web3Auth.primaryConnectorName);
|
|
29
29
|
}
|
|
30
30
|
return provider;
|
|
31
31
|
} catch (error) {
|
|
@@ -14,6 +14,7 @@ export { useWalletConnectScanner } from './hooks/useWalletConnectScanner.js';
|
|
|
14
14
|
export { useWalletServicesContextValue } from './context/useWalletServicesContextValue.js';
|
|
15
15
|
export { useWalletServicesPlugin } from './hooks/useWalletServicesPlugin.js';
|
|
16
16
|
export { useWalletUI } from './hooks/useWalletUI.js';
|
|
17
|
+
export { useWallets } from './hooks/useWallets.js';
|
|
17
18
|
export { useWeb3Auth } from './hooks/useWeb3Auth.js';
|
|
18
19
|
export { useWeb3AuthConnect } from './hooks/useWeb3AuthConnect.js';
|
|
19
20
|
export { useWeb3AuthDisconnect } from './hooks/useWeb3AuthDisconnect.js';
|
|
@@ -28,12 +28,12 @@ const useSolanaWallet = () => {
|
|
|
28
28
|
return createSolanaRpc(web3Auth.currentChain.rpcTarget);
|
|
29
29
|
}, [web3Auth, solanaWallet, chainNamespace]);
|
|
30
30
|
const getPrivateKey = useCallback(async () => {
|
|
31
|
-
var _web3Auth$
|
|
31
|
+
var _web3Auth$primaryConn;
|
|
32
32
|
if (!web3Auth) throw new Error("Web3Auth not initialized");
|
|
33
33
|
if ((connection === null || connection === void 0 ? void 0 : connection.connectorName) !== WALLET_CONNECTORS.AUTH) {
|
|
34
34
|
throw new Error("getPrivateKey is only supported with the Auth connector");
|
|
35
35
|
}
|
|
36
|
-
const provider = (_web3Auth$
|
|
36
|
+
const provider = (_web3Auth$primaryConn = web3Auth.primaryConnector) === null || _web3Auth$primaryConn === void 0 ? void 0 : _web3Auth$primaryConn.provider;
|
|
37
37
|
if (!provider) throw new Error("Provider not available");
|
|
38
38
|
const privateKey = await provider.request({
|
|
39
39
|
method: SOLANA_METHOD_TYPES.SOLANA_PRIVATE_KEY
|
|
@@ -3,8 +3,8 @@ import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProper
|
|
|
3
3
|
import { createWalletStandardConnector, createClient } from '@solana/client';
|
|
4
4
|
import { SolanaProvider as SolanaProvider$1 } from '@solana/react-hooks';
|
|
5
5
|
import { createElement, useRef, useState, useEffect } from 'react';
|
|
6
|
-
import { useChain } from '../hooks/useChain.js';
|
|
7
6
|
import { useWeb3Auth } from '../hooks/useWeb3Auth.js';
|
|
7
|
+
import { useChain } from '../hooks/useChain.js';
|
|
8
8
|
import { CHAIN_NAMESPACES } from '@toruslabs/base-controllers';
|
|
9
9
|
import { log } from '../../base/loglevel.js';
|
|
10
10
|
|
|
@@ -52,6 +52,7 @@ function useFrameworkKitSolanaClient() {
|
|
|
52
52
|
isInitialized
|
|
53
53
|
} = useWeb3Auth();
|
|
54
54
|
const {
|
|
55
|
+
chainId,
|
|
55
56
|
chainNamespace
|
|
56
57
|
} = useChain();
|
|
57
58
|
const ref = useRef(null);
|
|
@@ -100,6 +101,12 @@ function useFrameworkKitSolanaClient() {
|
|
|
100
101
|
adopt(makePlaceholder(rpc));
|
|
101
102
|
return;
|
|
102
103
|
}
|
|
104
|
+
|
|
105
|
+
// only reconnect for the primary connector
|
|
106
|
+
if (conn.connectorName !== (web3Auth === null || web3Auth === void 0 ? void 0 : web3Auth.primaryConnectorName)) {
|
|
107
|
+
adopt(makePlaceholder(rpc));
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
103
110
|
try {
|
|
104
111
|
const solanaWalletId = "wallet-standard:" + conn.connectorName;
|
|
105
112
|
const connector = createWalletStandardConnector(solanaWallet, {
|
|
@@ -131,7 +138,7 @@ function useFrameworkKitSolanaClient() {
|
|
|
131
138
|
return () => {
|
|
132
139
|
stale = true;
|
|
133
140
|
};
|
|
134
|
-
}, [isConnected, connection === null || connection === void 0 ? void 0 : connection.solanaWallet, chainNamespace, web3Auth, isInitialized, connection === null || connection === void 0 ? void 0 : connection.connectorName]);
|
|
141
|
+
}, [isConnected, connection === null || connection === void 0 ? void 0 : connection.solanaWallet, chainId, chainNamespace, web3Auth, isInitialized, connection === null || connection === void 0 ? void 0 : connection.connectorName]);
|
|
135
142
|
return client;
|
|
136
143
|
}
|
|
137
144
|
function SolanaProvider(_ref) {
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
|
|
2
2
|
import _objectSpread from '@babel/runtime/helpers/objectSpread2';
|
|
3
|
-
import { useMemo, createElement, useEffect, Fragment } from 'react';
|
|
3
|
+
import { useMemo, createElement, useRef, useEffect, Fragment } from 'react';
|
|
4
4
|
import { defineChain } from 'viem';
|
|
5
5
|
import { createConfig, WagmiProvider as WagmiProvider$1, webSocket, http, fallback, useConfig, useReconnect, useConnectionEffect } from 'wagmi';
|
|
6
6
|
import { injected } from 'wagmi/connectors';
|
|
7
7
|
import { defaultWagmiConfig } from './constants.js';
|
|
8
8
|
import { useWeb3Auth } from '../hooks/useWeb3Auth.js';
|
|
9
|
-
import { useWeb3AuthDisconnect } from '../hooks/useWeb3AuthDisconnect.js';
|
|
10
9
|
import { CHAIN_NAMESPACES } from '@toruslabs/base-controllers';
|
|
11
10
|
import { WalletInitializationError } from '../../base/errors/index.js';
|
|
11
|
+
import { useWeb3AuthDisconnect } from '../hooks/useWeb3AuthDisconnect.js';
|
|
12
12
|
import { log } from '../../base/loglevel.js';
|
|
13
13
|
|
|
14
14
|
const _excluded = ["children"];
|
|
@@ -78,7 +78,8 @@ function Web3AuthWagmiProvider({
|
|
|
78
78
|
}) {
|
|
79
79
|
const {
|
|
80
80
|
isConnected,
|
|
81
|
-
connection
|
|
81
|
+
connection,
|
|
82
|
+
chainNamespace
|
|
82
83
|
} = useWeb3Auth();
|
|
83
84
|
const {
|
|
84
85
|
disconnect
|
|
@@ -87,10 +88,17 @@ function Web3AuthWagmiProvider({
|
|
|
87
88
|
const {
|
|
88
89
|
mutate: reconnect
|
|
89
90
|
} = useReconnect();
|
|
91
|
+
const suppressWagmiDisconnect = useRef(false);
|
|
92
|
+
const lastSyncedBinding = useRef({
|
|
93
|
+
provider: null,
|
|
94
|
+
connectorName: null
|
|
95
|
+
});
|
|
90
96
|
useConnectionEffect({
|
|
91
97
|
onDisconnect: async () => {
|
|
92
98
|
log.info("Disconnected from wagmi");
|
|
93
|
-
|
|
99
|
+
const isSuppressed = suppressWagmiDisconnect.current;
|
|
100
|
+
suppressWagmiDisconnect.current = false;
|
|
101
|
+
if (!isSuppressed && isConnected) await disconnect();
|
|
94
102
|
const connector = getWeb3authConnector(wagmiConfig);
|
|
95
103
|
// reset wagmi connector state if the provider handles disconnection because of the accountsChanged event
|
|
96
104
|
// from the connected provider
|
|
@@ -101,20 +109,44 @@ function Web3AuthWagmiProvider({
|
|
|
101
109
|
});
|
|
102
110
|
useEffect(() => {
|
|
103
111
|
(async () => {
|
|
104
|
-
|
|
112
|
+
const shouldBindToWagmi = isConnected && chainNamespace === CHAIN_NAMESPACES.EIP155 && Boolean(connection === null || connection === void 0 ? void 0 : connection.ethereumProvider);
|
|
113
|
+
if (shouldBindToWagmi) {
|
|
114
|
+
const hasSameBinding = lastSyncedBinding.current.provider === connection.ethereumProvider && lastSyncedBinding.current.connectorName === connection.connectorName;
|
|
115
|
+
if (hasSameBinding && wagmiConfig.state.status === "connected") {
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
if (!hasSameBinding && getWeb3authConnector(wagmiConfig)) {
|
|
119
|
+
if (wagmiConfig.state.status === "connected") {
|
|
120
|
+
suppressWagmiDisconnect.current = true;
|
|
121
|
+
await disconnectWeb3AuthFromWagmi(wagmiConfig);
|
|
122
|
+
} else {
|
|
123
|
+
resetConnectorState(wagmiConfig);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
105
126
|
const connector = await setupConnector(connection.ethereumProvider, wagmiConfig);
|
|
106
127
|
if (!connector) {
|
|
107
128
|
throw new Error("Failed to setup connector");
|
|
108
129
|
}
|
|
109
130
|
await connectWeb3AuthWithWagmi(connector, wagmiConfig);
|
|
131
|
+
lastSyncedBinding.current = {
|
|
132
|
+
provider: connection.ethereumProvider,
|
|
133
|
+
connectorName: connection.connectorName
|
|
134
|
+
};
|
|
110
135
|
reconnect();
|
|
111
|
-
} else
|
|
136
|
+
} else {
|
|
137
|
+
lastSyncedBinding.current = {
|
|
138
|
+
provider: null,
|
|
139
|
+
connectorName: null
|
|
140
|
+
};
|
|
112
141
|
if (wagmiConfig.state.status === "connected") {
|
|
142
|
+
suppressWagmiDisconnect.current = true;
|
|
113
143
|
await disconnectWeb3AuthFromWagmi(wagmiConfig);
|
|
144
|
+
} else if (getWeb3authConnector(wagmiConfig)) {
|
|
145
|
+
resetConnectorState(wagmiConfig);
|
|
114
146
|
}
|
|
115
147
|
}
|
|
116
148
|
})();
|
|
117
|
-
}, [
|
|
149
|
+
}, [chainNamespace, connection, isConnected, reconnect, wagmiConfig]);
|
|
118
150
|
return createElement(Fragment, null, children);
|
|
119
151
|
}
|
|
120
152
|
function WagmiProvider(_ref) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ref } from 'vue';
|
|
2
2
|
import { useWalletServicesPlugin } from './useWalletServicesPlugin.js';
|
|
3
|
-
import { WalletServicesPluginError } from '../../base/plugin/errors.js';
|
|
4
3
|
import { log } from '../../base/loglevel.js';
|
|
4
|
+
import { WalletServicesPluginError } from '../../base/plugin/errors.js';
|
|
5
5
|
|
|
6
6
|
const useCheckout = () => {
|
|
7
7
|
const {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ref } from 'vue';
|
|
2
2
|
import { useWalletServicesPlugin } from './useWalletServicesPlugin.js';
|
|
3
|
-
import { WalletServicesPluginError } from '../../base/plugin/errors.js';
|
|
4
3
|
import { log } from '../../base/loglevel.js';
|
|
4
|
+
import { WalletServicesPluginError } from '../../base/plugin/errors.js';
|
|
5
5
|
|
|
6
6
|
const useFunding = () => {
|
|
7
7
|
const {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ref } from 'vue';
|
|
2
2
|
import { useWalletServicesPlugin } from './useWalletServicesPlugin.js';
|
|
3
|
-
import { WalletServicesPluginError } from '../../base/plugin/errors.js';
|
|
4
3
|
import { log } from '../../base/loglevel.js';
|
|
4
|
+
import { WalletServicesPluginError } from '../../base/plugin/errors.js';
|
|
5
5
|
|
|
6
6
|
const useReceive = () => {
|
|
7
7
|
const {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ref } from 'vue';
|
|
2
2
|
import { useWalletServicesPlugin } from './useWalletServicesPlugin.js';
|
|
3
|
-
import { WalletServicesPluginError } from '../../base/plugin/errors.js';
|
|
4
3
|
import { log } from '../../base/loglevel.js';
|
|
4
|
+
import { WalletServicesPluginError } from '../../base/plugin/errors.js';
|
|
5
5
|
|
|
6
6
|
const useSwap = () => {
|
|
7
7
|
const {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ref } from 'vue';
|
|
2
2
|
import { useWalletServicesPlugin } from './useWalletServicesPlugin.js';
|
|
3
|
-
import { WalletServicesPluginError } from '../../base/plugin/errors.js';
|
|
4
3
|
import { log } from '../../base/loglevel.js';
|
|
4
|
+
import { WalletServicesPluginError } from '../../base/plugin/errors.js';
|
|
5
5
|
|
|
6
6
|
const useWalletConnectScanner = () => {
|
|
7
7
|
const {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ref } from 'vue';
|
|
2
2
|
import { useWalletServicesPlugin } from './useWalletServicesPlugin.js';
|
|
3
|
-
import { WalletServicesPluginError } from '../../base/plugin/errors.js';
|
|
4
3
|
import { log } from '../../base/loglevel.js';
|
|
4
|
+
import { WalletServicesPluginError } from '../../base/plugin/errors.js';
|
|
5
5
|
|
|
6
6
|
const useWalletUI = () => {
|
|
7
7
|
const {
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { ref } from 'vue';
|
|
2
|
+
import { useWeb3AuthInner } from './useWeb3AuthInner.js';
|
|
3
|
+
import { WalletInitializationError } from '../../base/errors/index.js';
|
|
4
|
+
import { log } from '../../base/loglevel.js';
|
|
5
|
+
|
|
6
|
+
const useWallets = () => {
|
|
7
|
+
const {
|
|
8
|
+
web3Auth
|
|
9
|
+
} = useWeb3AuthInner();
|
|
10
|
+
const loading = ref(false);
|
|
11
|
+
const error = ref(null);
|
|
12
|
+
const wallets = ref([]);
|
|
13
|
+
const syncWallets = async () => {
|
|
14
|
+
if (!web3Auth.value) throw WalletInitializationError.notReady();
|
|
15
|
+
error.value = null;
|
|
16
|
+
loading.value = true;
|
|
17
|
+
try {
|
|
18
|
+
const result = await web3Auth.value.getConnectedAccountsWithProviders();
|
|
19
|
+
wallets.value = result;
|
|
20
|
+
} catch (err) {
|
|
21
|
+
log.error("Error getting wallets", err);
|
|
22
|
+
error.value = err;
|
|
23
|
+
} finally {
|
|
24
|
+
loading.value = false;
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
return {
|
|
28
|
+
loading,
|
|
29
|
+
error,
|
|
30
|
+
wallets,
|
|
31
|
+
syncWallets
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export { useWallets };
|
|
@@ -17,7 +17,7 @@ const useWeb3AuthConnect = () => {
|
|
|
17
17
|
}
|
|
18
18
|
if (newVal && !connectorName.value) {
|
|
19
19
|
var _web3Auth$value;
|
|
20
|
-
connectorName.value = (_web3Auth$value = web3Auth.value) === null || _web3Auth$value === void 0 ? void 0 : _web3Auth$value.
|
|
20
|
+
connectorName.value = (_web3Auth$value = web3Auth.value) === null || _web3Auth$value === void 0 ? void 0 : _web3Auth$value.primaryConnectorName;
|
|
21
21
|
}
|
|
22
22
|
}, {
|
|
23
23
|
immediate: true
|
|
@@ -28,7 +28,7 @@ const useWeb3AuthConnect = () => {
|
|
|
28
28
|
error.value = null;
|
|
29
29
|
loading.value = true;
|
|
30
30
|
const localProvider = await web3Auth.value.connectTo(connectorType, loginParams);
|
|
31
|
-
connectorName.value = web3Auth.value.
|
|
31
|
+
connectorName.value = web3Auth.value.primaryConnectorName;
|
|
32
32
|
return localProvider;
|
|
33
33
|
} catch (err) {
|
|
34
34
|
log.error("Error connecting", err);
|
|
@@ -15,6 +15,7 @@ export { useSwitchChain } from './composables/useSwitchChain.js';
|
|
|
15
15
|
export { useWalletConnectScanner } from './composables/useWalletConnectScanner.js';
|
|
16
16
|
export { useWalletServicesPlugin } from './composables/useWalletServicesPlugin.js';
|
|
17
17
|
export { useWalletUI } from './composables/useWalletUI.js';
|
|
18
|
+
export { useWallets } from './composables/useWallets.js';
|
|
18
19
|
export { useWeb3Auth } from './composables/useWeb3Auth.js';
|
|
19
20
|
export { useWeb3AuthConnect } from './composables/useWeb3AuthConnect.js';
|
|
20
21
|
export { useWeb3AuthDisconnect } from './composables/useWeb3AuthDisconnect.js';
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { ref } from 'vue';
|
|
2
2
|
import { WalletInitializationError } from '../../../base/errors/index.js';
|
|
3
3
|
import { useSolanaWallet } from './useSolanaWallet.js';
|
|
4
|
-
import { walletSignAndSendTransaction } from '../../../base/wallet/solana.js';
|
|
5
4
|
import { log } from '../../../base/loglevel.js';
|
|
5
|
+
import { walletSignAndSendTransaction } from '../../../base/wallet/solana.js';
|
|
6
6
|
|
|
7
7
|
const useSignAndSendTransaction = () => {
|
|
8
8
|
const {
|