@web3auth/no-modal 10.0.0 → 10.0.1-beta.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/base/analytics.js +13 -2
- package/dist/lib.cjs/base/utils.js +1 -1
- package/dist/lib.cjs/connectors/auth-connector/authConnector.js +24 -19
- package/dist/lib.cjs/connectors/metamask-connector/metamaskConnector.js +39 -7
- package/dist/lib.cjs/connectors/wallet-connect-v2-connector/walletConnectV2Connector.js +83 -26
- package/dist/lib.cjs/noModal.js +50 -16
- package/dist/lib.cjs/plugins/wallet-services-plugin/plugin.js +33 -8
- package/dist/lib.cjs/providers/solana-provider/solanaWallet.js +6 -0
- package/dist/lib.cjs/react/solana/hooks/useSolanaWallet.js +1 -1
- package/dist/lib.cjs/react/wagmi/provider.js +3 -0
- package/dist/lib.cjs/types/base/analytics.d.ts +5 -0
- package/dist/lib.cjs/types/base/connector/interfaces.d.ts +3 -0
- package/dist/lib.cjs/types/base/plugin/IPlugin.d.ts +2 -1
- package/dist/lib.cjs/types/connectors/auth-connector/authConnector.d.ts +4 -2
- package/dist/lib.cjs/types/noModal.d.ts +1 -0
- package/dist/lib.cjs/types/plugins/wallet-services-plugin/plugin.d.ts +3 -2
- package/dist/lib.cjs/types/providers/solana-provider/solanaWallet.d.ts +1 -0
- package/dist/lib.cjs/vue/solana/composables/useSolanaWallet.js +1 -1
- package/dist/lib.cjs/vue/wagmi/provider.js +4 -0
- package/dist/lib.esm/base/analytics.js +13 -2
- package/dist/lib.esm/base/utils.js +1 -1
- package/dist/lib.esm/connectors/auth-connector/authConnector.js +25 -19
- package/dist/lib.esm/connectors/metamask-connector/metamaskConnector.js +41 -3
- package/dist/lib.esm/connectors/wallet-connect-v2-connector/walletConnectV2Connector.js +78 -14
- package/dist/lib.esm/noModal.js +52 -17
- package/dist/lib.esm/plugins/wallet-services-plugin/plugin.js +36 -5
- package/dist/lib.esm/providers/solana-provider/solanaWallet.js +6 -0
- package/dist/lib.esm/react/context/Web3AuthInnerContext.js +1 -1
- package/dist/lib.esm/react/solana/hooks/useSolanaWallet.js +1 -1
- package/dist/lib.esm/react/wagmi/provider.js +3 -0
- package/dist/lib.esm/vue/solana/composables/useSolanaWallet.js +1 -1
- package/dist/lib.esm/vue/wagmi/provider.js +4 -0
- package/dist/noModal.umd.min.js +1 -1
- package/package.json +2 -2
|
@@ -87,28 +87,39 @@ class Analytics {
|
|
|
87
87
|
}
|
|
88
88
|
}
|
|
89
89
|
const ANALYTICS_EVENTS = {
|
|
90
|
+
// SDK Initialization
|
|
90
91
|
SDK_INITIALIZATION_COMPLETED: "SDK Initialization Completed",
|
|
91
92
|
SDK_INITIALIZATION_FAILED: "SDK Initialization Failed",
|
|
93
|
+
// Connection
|
|
92
94
|
CONNECTION_STARTED: "Connection Started",
|
|
93
95
|
CONNECTION_COMPLETED: "Connection Completed",
|
|
94
96
|
CONNECTION_FAILED: "Connection Failed",
|
|
97
|
+
// Identity Token
|
|
95
98
|
IDENTITY_TOKEN_STARTED: "Identity Token Started",
|
|
96
99
|
IDENTITY_TOKEN_COMPLETED: "Identity Token Completed",
|
|
97
100
|
IDENTITY_TOKEN_FAILED: "Identity Token Failed",
|
|
101
|
+
// MFA
|
|
98
102
|
MFA_ENABLEMENT_STARTED: "MFA Enablement Started",
|
|
99
103
|
MFA_ENABLEMENT_COMPLETED: "MFA Enablement Completed",
|
|
100
104
|
MFA_ENABLEMENT_FAILED: "MFA Enablement Failed",
|
|
101
105
|
MFA_MANAGEMENT_SELECTED: "MFA Management Selected",
|
|
102
106
|
MFA_MANAGEMENT_FAILED: "MFA Management Failed",
|
|
107
|
+
// Login Modal
|
|
103
108
|
LOGIN_MODAL_OPENED: "Login Modal Opened",
|
|
104
109
|
LOGIN_MODAL_CLOSED: "Login Modal Closed",
|
|
105
110
|
SOCIAL_LOGIN_SELECTED: "Social Login Selected",
|
|
106
111
|
EXTERNAL_WALLET_SELECTED: "External Wallet Selected",
|
|
107
|
-
EXTERNAL_WALLET_LIST_EXPANDED: "External Wallet List Expanded"
|
|
112
|
+
EXTERNAL_WALLET_LIST_EXPANDED: "External Wallet List Expanded",
|
|
113
|
+
// Wallet Plugin
|
|
114
|
+
WALLET_UI_CLICKED: "Wallet UI Clicked",
|
|
115
|
+
WALLET_CONNECT_SCANNER_CLICKED: "Wallet Connect Scanner Clicked",
|
|
116
|
+
WALLET_CHECKOUT_CLICKED: "Wallet Checkout Clicked",
|
|
117
|
+
WALLET_SWAP_CLICKED: "Wallet Swap Clicked"
|
|
108
118
|
};
|
|
109
119
|
const ANALYTICS_INTEGRATION_TYPE = {
|
|
110
120
|
REACT_HOOKS: "React Hooks",
|
|
111
|
-
VUE_COMPOSABLES: "Vue Composables"
|
|
121
|
+
VUE_COMPOSABLES: "Vue Composables",
|
|
122
|
+
NATIVE_SDK: "Native SDK"
|
|
112
123
|
};
|
|
113
124
|
const ANALYTICS_SDK_TYPE = {
|
|
114
125
|
WEB_NO_MODAL: "Web NoModal",
|
|
@@ -145,7 +145,7 @@ const getWalletServicesAnalyticsProperties = walletServicesConfig => {
|
|
|
145
145
|
ws_default_portfolio: walletServicesConfig === null || walletServicesConfig === void 0 || (_walletServicesConfig1 = walletServicesConfig.whiteLabel) === null || _walletServicesConfig1 === void 0 ? void 0 : _walletServicesConfig1.defaultPortfolio
|
|
146
146
|
};
|
|
147
147
|
};
|
|
148
|
-
const sdkVersion = "10.0.0";
|
|
148
|
+
const sdkVersion = "10.0.1-beta.0";
|
|
149
149
|
const getErrorAnalyticsProperties = error => {
|
|
150
150
|
try {
|
|
151
151
|
const code = error instanceof index.Web3AuthError ? error.code : error === null || error === void 0 ? void 0 : error.code;
|
|
@@ -288,6 +288,24 @@ class AuthConnector extends baseConnector.BaseConnector {
|
|
|
288
288
|
this.wsEmbedInstance.clearInit();
|
|
289
289
|
}
|
|
290
290
|
}
|
|
291
|
+
getOAuthProviderConfig(params) {
|
|
292
|
+
const {
|
|
293
|
+
authConnection,
|
|
294
|
+
authConnectionId,
|
|
295
|
+
groupedAuthConnectionId
|
|
296
|
+
} = params;
|
|
297
|
+
const providerConfig = this.authConnectionConfig.find(x => {
|
|
298
|
+
if (groupedAuthConnectionId) {
|
|
299
|
+
return x.authConnection === authConnection && x.groupedAuthConnectionId === groupedAuthConnectionId;
|
|
300
|
+
}
|
|
301
|
+
if (authConnectionId) {
|
|
302
|
+
return x.authConnection === authConnection && x.authConnectionId === authConnectionId;
|
|
303
|
+
}
|
|
304
|
+
// return the default auth connection, if not found, return undefined
|
|
305
|
+
return x.authConnection === authConnection && x.isDefault;
|
|
306
|
+
});
|
|
307
|
+
return providerConfig;
|
|
308
|
+
}
|
|
291
309
|
getChain(chainId) {
|
|
292
310
|
return this.coreOptions.chains.find(x => x.chainId === chainId);
|
|
293
311
|
}
|
|
@@ -500,24 +518,6 @@ class AuthConnector extends baseConnector.BaseConnector {
|
|
|
500
518
|
delete loginParams.chainId;
|
|
501
519
|
return this.authInstance.postLoginInitiatedMessage(loginParams);
|
|
502
520
|
}
|
|
503
|
-
getOAuthProviderConfig(params) {
|
|
504
|
-
const {
|
|
505
|
-
authConnection,
|
|
506
|
-
authConnectionId,
|
|
507
|
-
groupedAuthConnectionId
|
|
508
|
-
} = params;
|
|
509
|
-
const providerConfig = this.authConnectionConfig.find(x => {
|
|
510
|
-
if (groupedAuthConnectionId) {
|
|
511
|
-
return x.authConnection === authConnection && x.groupedAuthConnectionId === groupedAuthConnectionId;
|
|
512
|
-
}
|
|
513
|
-
if (authConnectionId) {
|
|
514
|
-
return x.authConnection === authConnection && x.authConnectionId === authConnectionId;
|
|
515
|
-
}
|
|
516
|
-
// return the default auth connection, if not found, return undefined
|
|
517
|
-
return x.authConnection === authConnection && x.isDefault;
|
|
518
|
-
});
|
|
519
|
-
return providerConfig;
|
|
520
|
-
}
|
|
521
521
|
}
|
|
522
522
|
const authConnector = params => {
|
|
523
523
|
return ({
|
|
@@ -532,7 +532,12 @@ const authConnector = params => {
|
|
|
532
532
|
sessionTime
|
|
533
533
|
} = projectConfig;
|
|
534
534
|
if (whitelist) connectorSettings.originData = whitelist.signed_urls;
|
|
535
|
-
|
|
535
|
+
// If sessionTime is provided in the coreOptions, it takes precedence over the sessionTime in the projectConfig.
|
|
536
|
+
if (coreOptions.sessionTime) {
|
|
537
|
+
connectorSettings.sessionTime = coreOptions.sessionTime;
|
|
538
|
+
} else if (sessionTime) {
|
|
539
|
+
connectorSettings.sessionTime = sessionTime;
|
|
540
|
+
}
|
|
536
541
|
if ((_coreOptions$uiConfig = coreOptions.uiConfig) !== null && _coreOptions$uiConfig !== void 0 && _coreOptions$uiConfig.uxMode) connectorSettings.uxMode = coreOptions.uiConfig.uxMode;
|
|
537
542
|
const uiConfig = coreOptions.uiConfig || {};
|
|
538
543
|
connectorSettings.whiteLabel = uiConfig;
|
|
@@ -3,20 +3,19 @@
|
|
|
3
3
|
var _objectSpread = require('@babel/runtime/helpers/objectSpread2');
|
|
4
4
|
var _defineProperty = require('@babel/runtime/helpers/defineProperty');
|
|
5
5
|
var sdk = require('@metamask/sdk');
|
|
6
|
+
var baseControllers = require('@toruslabs/base-controllers');
|
|
6
7
|
var deepmerge = require('deepmerge');
|
|
7
|
-
require('
|
|
8
|
-
require('../../base/loglevel.js');
|
|
8
|
+
var analytics = require('../../base/analytics.js');
|
|
9
9
|
var IChainInterface = require('../../base/chain/IChainInterface.js');
|
|
10
10
|
require('@web3auth/auth');
|
|
11
11
|
var index$1 = require('../../base/errors/index.js');
|
|
12
12
|
var index = require('../../base/wallet/index.js');
|
|
13
13
|
var constants = require('../../base/connector/constants.js');
|
|
14
14
|
require('jwt-decode');
|
|
15
|
+
require('../../base/loglevel.js');
|
|
15
16
|
require('../../base/plugin/errors.js');
|
|
16
17
|
require('../../base/plugin/IPlugin.js');
|
|
17
|
-
var
|
|
18
|
-
require('@toruslabs/constants');
|
|
19
|
-
require('@toruslabs/http-helpers');
|
|
18
|
+
var utils$1 = require('../../base/utils.js');
|
|
20
19
|
var baseEvmConnector = require('../base-evm-connector/baseEvmConnector.js');
|
|
21
20
|
var utils = require('../utils.js');
|
|
22
21
|
|
|
@@ -31,7 +30,9 @@ class MetaMaskConnector extends baseEvmConnector.BaseEvmConnector {
|
|
|
31
30
|
_defineProperty(this, "metamaskProvider", null);
|
|
32
31
|
_defineProperty(this, "metamaskSDK", null);
|
|
33
32
|
_defineProperty(this, "metamaskOptions", void 0);
|
|
33
|
+
_defineProperty(this, "analytics", void 0);
|
|
34
34
|
this.metamaskOptions = connectorOptions.connectorSettings;
|
|
35
|
+
this.analytics = connectorOptions.analytics;
|
|
35
36
|
}
|
|
36
37
|
get provider() {
|
|
37
38
|
if (this.status !== constants.CONNECTOR_STATUS.NOT_READY && this.metamaskProvider) {
|
|
@@ -96,6 +97,19 @@ class MetaMaskConnector extends baseEvmConnector.BaseEvmConnector {
|
|
|
96
97
|
if (!this.metamaskSDK) throw index$1.WalletLoginError.notConnectedError("Connector is not initialized");
|
|
97
98
|
const chainConfig = this.coreOptions.chains.find(x => x.chainId === chainId);
|
|
98
99
|
if (!chainConfig) throw index$1.WalletLoginError.connectionError("Chain config is not available");
|
|
100
|
+
// Skip tracking for injected MetaMask since it's handled in connectTo
|
|
101
|
+
// Skip tracking for rehydration since only new connections are tracked
|
|
102
|
+
// Only track non-injected MetaMask when connection completes since it auto-initializes to generate QR code
|
|
103
|
+
const shouldTrack = !this.isInjected && !this.rehydrated;
|
|
104
|
+
const startTime = Date.now();
|
|
105
|
+
const eventData = {
|
|
106
|
+
connector: this.name,
|
|
107
|
+
connector_type: this.type,
|
|
108
|
+
is_injected: this.isInjected,
|
|
109
|
+
chain_id: utils$1.getCaipChainId(chainConfig),
|
|
110
|
+
chain_name: chainConfig === null || chainConfig === void 0 ? void 0 : chainConfig.displayName,
|
|
111
|
+
chain_namespace: chainConfig === null || chainConfig === void 0 ? void 0 : chainConfig.chainNamespace
|
|
112
|
+
};
|
|
99
113
|
try {
|
|
100
114
|
if (this.status !== constants.CONNECTOR_STATUS.CONNECTING) {
|
|
101
115
|
var _this$metamaskOptions;
|
|
@@ -131,6 +145,14 @@ class MetaMaskConnector extends baseEvmConnector.BaseEvmConnector {
|
|
|
131
145
|
this.disconnect();
|
|
132
146
|
});
|
|
133
147
|
this.status = constants.CONNECTOR_STATUS.CONNECTED;
|
|
148
|
+
// track connection events
|
|
149
|
+
if (shouldTrack) {
|
|
150
|
+
var _this$analytics, _this$analytics2;
|
|
151
|
+
(_this$analytics = this.analytics) === null || _this$analytics === void 0 || _this$analytics.track(analytics.ANALYTICS_EVENTS.CONNECTION_STARTED, eventData);
|
|
152
|
+
(_this$analytics2 = this.analytics) === null || _this$analytics2 === void 0 || _this$analytics2.track(analytics.ANALYTICS_EVENTS.CONNECTION_COMPLETED, _objectSpread(_objectSpread({}, eventData), {}, {
|
|
153
|
+
duration: Date.now() - startTime
|
|
154
|
+
}));
|
|
155
|
+
}
|
|
134
156
|
this.emit(constants.CONNECTOR_EVENTS.CONNECTED, {
|
|
135
157
|
connector: index.WALLET_CONNECTORS.METAMASK,
|
|
136
158
|
reconnected: this.rehydrated,
|
|
@@ -142,6 +164,14 @@ class MetaMaskConnector extends baseEvmConnector.BaseEvmConnector {
|
|
|
142
164
|
this.status = constants.CONNECTOR_STATUS.READY;
|
|
143
165
|
if (!this.rehydrated) this.emit(constants.CONNECTOR_EVENTS.ERRORED, error);
|
|
144
166
|
this.rehydrated = false;
|
|
167
|
+
// track connection events
|
|
168
|
+
if (shouldTrack) {
|
|
169
|
+
var _this$analytics3, _this$analytics4;
|
|
170
|
+
(_this$analytics3 = this.analytics) === null || _this$analytics3 === void 0 || _this$analytics3.track(analytics.ANALYTICS_EVENTS.CONNECTION_STARTED, eventData);
|
|
171
|
+
(_this$analytics4 = this.analytics) === null || _this$analytics4 === void 0 || _this$analytics4.track(analytics.ANALYTICS_EVENTS.CONNECTION_FAILED, _objectSpread(_objectSpread(_objectSpread({}, eventData), baseControllers.getErrorAnalyticsProperties(error)), {}, {
|
|
172
|
+
duration: Date.now() - startTime
|
|
173
|
+
}));
|
|
174
|
+
}
|
|
145
175
|
if (error instanceof index$1.Web3AuthError) throw error;
|
|
146
176
|
throw index$1.WalletLoginError.connectionError("Failed to login with MetaMask wallet", error);
|
|
147
177
|
}
|
|
@@ -214,11 +244,13 @@ class MetaMaskConnector extends baseEvmConnector.BaseEvmConnector {
|
|
|
214
244
|
}
|
|
215
245
|
const metaMaskConnector = params => {
|
|
216
246
|
return ({
|
|
217
|
-
coreOptions
|
|
247
|
+
coreOptions,
|
|
248
|
+
analytics
|
|
218
249
|
}) => {
|
|
219
250
|
return new MetaMaskConnector({
|
|
220
251
|
connectorSettings: params,
|
|
221
|
-
coreOptions
|
|
252
|
+
coreOptions,
|
|
253
|
+
analytics
|
|
222
254
|
});
|
|
223
255
|
};
|
|
224
256
|
};
|
|
@@ -4,21 +4,20 @@ var _objectSpread = require('@babel/runtime/helpers/objectSpread2');
|
|
|
4
4
|
var _defineProperty = require('@babel/runtime/helpers/defineProperty');
|
|
5
5
|
var baseControllers = require('@toruslabs/base-controllers');
|
|
6
6
|
var Client = require('@walletconnect/sign-client');
|
|
7
|
-
var utils$
|
|
7
|
+
var utils$2 = require('@walletconnect/utils');
|
|
8
8
|
var wsEmbed = require('@web3auth/ws-embed');
|
|
9
9
|
var deepmerge = require('deepmerge');
|
|
10
|
-
require('
|
|
11
|
-
var loglevel = require('../../base/loglevel.js');
|
|
10
|
+
var analytics = require('../../base/analytics.js');
|
|
12
11
|
var IChainInterface = require('../../base/chain/IChainInterface.js');
|
|
13
12
|
var baseConnector = require('../../base/connector/baseConnector.js');
|
|
14
13
|
var constants = require('../../base/connector/constants.js');
|
|
15
14
|
require('@web3auth/auth');
|
|
16
|
-
var utils = require('../../base/connector/utils.js');
|
|
15
|
+
var utils$1 = require('../../base/connector/utils.js');
|
|
17
16
|
var index$1 = require('../../base/errors/index.js');
|
|
17
|
+
var loglevel = require('../../base/loglevel.js');
|
|
18
18
|
require('../../base/plugin/errors.js');
|
|
19
19
|
require('../../base/plugin/IPlugin.js');
|
|
20
|
-
require('
|
|
21
|
-
require('@toruslabs/http-helpers');
|
|
20
|
+
var utils = require('../../base/utils.js');
|
|
22
21
|
var index = require('../../base/wallet/index.js');
|
|
23
22
|
var config = require('./config.js');
|
|
24
23
|
var WalletConnectV2Provider = require('./WalletConnectV2Provider.js');
|
|
@@ -39,6 +38,7 @@ class WalletConnectV2Connector extends baseConnector.BaseConnector {
|
|
|
39
38
|
_defineProperty(this, "connector", null);
|
|
40
39
|
_defineProperty(this, "activeSession", null);
|
|
41
40
|
_defineProperty(this, "wcProvider", null);
|
|
41
|
+
_defineProperty(this, "analytics", void 0);
|
|
42
42
|
this.connectorOptions = _objectSpread({}, options);
|
|
43
43
|
const {
|
|
44
44
|
qrcodeModal,
|
|
@@ -48,6 +48,7 @@ class WalletConnectV2Connector extends baseConnector.BaseConnector {
|
|
|
48
48
|
connectorSettings: (_this$connectorOption = (_this$connectorOption2 = this.connectorOptions) === null || _this$connectorOption2 === void 0 ? void 0 : _this$connectorOption2.connectorSettings) !== null && _this$connectorOption !== void 0 ? _this$connectorOption : {},
|
|
49
49
|
loginSettings: (_this$connectorOption3 = (_this$connectorOption4 = this.connectorOptions) === null || _this$connectorOption4 === void 0 ? void 0 : _this$connectorOption4.loginSettings) !== null && _this$connectorOption3 !== void 0 ? _this$connectorOption3 : {}
|
|
50
50
|
});
|
|
51
|
+
this.analytics = options.analytics;
|
|
51
52
|
if (qrcodeModal) this.connectorOptions.connectorSettings.qrcodeModal = qrcodeModal;
|
|
52
53
|
if (walletConnectInitOptions) this.connectorOptions.connectorSettings.walletConnectInitOptions = _objectSpread(_objectSpread({}, (_this$connectorOption5 = this.connectorOptions.connectorSettings.walletConnectInitOptions) !== null && _this$connectorOption5 !== void 0 ? _this$connectorOption5 : {}), walletConnectInitOptions);
|
|
53
54
|
const {
|
|
@@ -122,7 +123,47 @@ class WalletConnectV2Connector extends baseConnector.BaseConnector {
|
|
|
122
123
|
const chainConfig = this.coreOptions.chains.find(x => x.chainId === chainId);
|
|
123
124
|
if (!chainConfig) throw index$1.WalletLoginError.connectionError("Chain config is not available");
|
|
124
125
|
if (!this.connector) throw index$1.WalletInitializationError.notReady("Wallet connector is not ready yet");
|
|
126
|
+
// Skip tracking for rehydration since only new connections are tracked
|
|
127
|
+
// Track when connection completes since it auto-initializes to generate QR code
|
|
128
|
+
const shouldTrack = !this.connected && !this.rehydrated;
|
|
129
|
+
const startTime = Date.now();
|
|
130
|
+
let eventData = {
|
|
131
|
+
connector: this.name,
|
|
132
|
+
connector_type: this.type,
|
|
133
|
+
is_injected: this.isInjected,
|
|
134
|
+
is_wallet_connect: true,
|
|
135
|
+
chain_id: utils.getCaipChainId(chainConfig),
|
|
136
|
+
chain_name: chainConfig === null || chainConfig === void 0 ? void 0 : chainConfig.displayName,
|
|
137
|
+
chain_namespace: chainConfig === null || chainConfig === void 0 ? void 0 : chainConfig.chainNamespace
|
|
138
|
+
};
|
|
125
139
|
try {
|
|
140
|
+
const trackCompletionEvents = () => {
|
|
141
|
+
// track connection events
|
|
142
|
+
if (shouldTrack) {
|
|
143
|
+
var _this$activeSession, _this$analytics, _this$analytics2;
|
|
144
|
+
const {
|
|
145
|
+
name,
|
|
146
|
+
url,
|
|
147
|
+
redirect
|
|
148
|
+
} = ((_this$activeSession = this.activeSession) === null || _this$activeSession === void 0 || (_this$activeSession = _this$activeSession.peer) === null || _this$activeSession === void 0 ? void 0 : _this$activeSession.metadata) || {};
|
|
149
|
+
const {
|
|
150
|
+
native,
|
|
151
|
+
universal,
|
|
152
|
+
linkMode
|
|
153
|
+
} = redirect || {};
|
|
154
|
+
eventData = _objectSpread(_objectSpread({}, eventData), {}, {
|
|
155
|
+
connector: name || this.name,
|
|
156
|
+
wallet_url: url,
|
|
157
|
+
redirect_native: native,
|
|
158
|
+
redirect_universal: universal,
|
|
159
|
+
redirect_link_mode_enabled: linkMode
|
|
160
|
+
});
|
|
161
|
+
(_this$analytics = this.analytics) === null || _this$analytics === void 0 || _this$analytics.track(analytics.ANALYTICS_EVENTS.CONNECTION_STARTED, eventData);
|
|
162
|
+
(_this$analytics2 = this.analytics) === null || _this$analytics2 === void 0 || _this$analytics2.track(analytics.ANALYTICS_EVENTS.CONNECTION_COMPLETED, _objectSpread(_objectSpread({}, eventData), {}, {
|
|
163
|
+
duration: Date.now() - startTime
|
|
164
|
+
}));
|
|
165
|
+
}
|
|
166
|
+
};
|
|
126
167
|
// if already connected
|
|
127
168
|
if (this.connected) {
|
|
128
169
|
await this.onConnectHandler({
|
|
@@ -132,7 +173,8 @@ class WalletConnectV2Connector extends baseConnector.BaseConnector {
|
|
|
132
173
|
}
|
|
133
174
|
if (this.status !== constants.CONNECTOR_STATUS.CONNECTING) {
|
|
134
175
|
await this.createNewSession({
|
|
135
|
-
chainConfig
|
|
176
|
+
chainConfig,
|
|
177
|
+
trackCompletionEvents
|
|
136
178
|
});
|
|
137
179
|
}
|
|
138
180
|
return this.provider;
|
|
@@ -142,6 +184,14 @@ class WalletConnectV2Connector extends baseConnector.BaseConnector {
|
|
|
142
184
|
this.status = constants.CONNECTOR_STATUS.READY;
|
|
143
185
|
this.rehydrated = true;
|
|
144
186
|
this.emit(constants.CONNECTOR_EVENTS.ERRORED, error);
|
|
187
|
+
// track connection events
|
|
188
|
+
if (shouldTrack) {
|
|
189
|
+
var _this$analytics3, _this$analytics4;
|
|
190
|
+
(_this$analytics3 = this.analytics) === null || _this$analytics3 === void 0 || _this$analytics3.track(analytics.ANALYTICS_EVENTS.CONNECTION_STARTED, eventData);
|
|
191
|
+
(_this$analytics4 = this.analytics) === null || _this$analytics4 === void 0 || _this$analytics4.track(analytics.ANALYTICS_EVENTS.CONNECTION_FAILED, _objectSpread(_objectSpread(_objectSpread({}, eventData), baseControllers.getErrorAnalyticsProperties(error)), {}, {
|
|
192
|
+
duration: Date.now() - startTime
|
|
193
|
+
}));
|
|
194
|
+
}
|
|
145
195
|
const finalError = error instanceof index$1.Web3AuthError ? error : index$1.WalletLoginError.connectionError(`Failed to login with wallet connect: ${(error === null || error === void 0 ? void 0 : error.message) || ""}`, error);
|
|
146
196
|
throw finalError;
|
|
147
197
|
}
|
|
@@ -166,14 +216,14 @@ class WalletConnectV2Connector extends baseConnector.BaseConnector {
|
|
|
166
216
|
cleanup: false,
|
|
167
217
|
sessionRemovedByWallet: false
|
|
168
218
|
}) {
|
|
169
|
-
var _this$
|
|
219
|
+
var _this$activeSession2, _this$activeSession3;
|
|
170
220
|
const {
|
|
171
221
|
cleanup
|
|
172
222
|
} = options;
|
|
173
|
-
if (!this.connector || !this.connected || !((_this$
|
|
223
|
+
if (!this.connector || !this.connected || !((_this$activeSession2 = this.activeSession) !== null && _this$activeSession2 !== void 0 && _this$activeSession2.topic)) throw index$1.WalletLoginError.notConnectedError("Not connected with wallet");
|
|
174
224
|
if (!options.sessionRemovedByWallet) await this.connector.disconnect({
|
|
175
|
-
topic: (_this$
|
|
176
|
-
reason: utils$
|
|
225
|
+
topic: (_this$activeSession3 = this.activeSession) === null || _this$activeSession3 === void 0 ? void 0 : _this$activeSession3.topic,
|
|
226
|
+
reason: utils$2.getSdkError("USER_DISCONNECTED")
|
|
177
227
|
});
|
|
178
228
|
this.rehydrated = false;
|
|
179
229
|
if (cleanup) {
|
|
@@ -201,9 +251,9 @@ class WalletConnectV2Connector extends baseConnector.BaseConnector {
|
|
|
201
251
|
method: chainNamespace === baseControllers.CHAIN_NAMESPACES.EIP155 ? wsEmbed.EVM_METHOD_TYPES.GET_ACCOUNTS : wsEmbed.SOLANA_METHOD_TYPES.GET_ACCOUNTS
|
|
202
252
|
});
|
|
203
253
|
if (accounts && accounts.length > 0) {
|
|
204
|
-
const existingToken = utils.getSavedToken(accounts[0], this.name);
|
|
254
|
+
const existingToken = utils$1.getSavedToken(accounts[0], this.name);
|
|
205
255
|
if (existingToken) {
|
|
206
|
-
const isExpired = utils.checkIfTokenIsExpired(existingToken);
|
|
256
|
+
const isExpired = utils$1.checkIfTokenIsExpired(existingToken);
|
|
207
257
|
if (!isExpired) {
|
|
208
258
|
return {
|
|
209
259
|
idToken: existingToken
|
|
@@ -222,7 +272,7 @@ class WalletConnectV2Connector extends baseConnector.BaseConnector {
|
|
|
222
272
|
const challenge = await baseControllers.signChallenge(payload, chainNamespace);
|
|
223
273
|
const signedMessage = await this._getSignedMessage(challenge, accounts, chainNamespace);
|
|
224
274
|
const idToken = await baseControllers.verifySignedChallenge(chainNamespace, signedMessage, challenge, this.name, this.coreOptions.sessionTime, this.coreOptions.clientId, this.coreOptions.web3AuthNetwork);
|
|
225
|
-
utils.saveToken(accounts[0], this.name, idToken);
|
|
275
|
+
utils$1.saveToken(accounts[0], this.name, idToken);
|
|
226
276
|
return {
|
|
227
277
|
idToken
|
|
228
278
|
};
|
|
@@ -240,10 +290,10 @@ class WalletConnectV2Connector extends baseConnector.BaseConnector {
|
|
|
240
290
|
const inactivePairings = this.connector.pairing.getAll({
|
|
241
291
|
active: false
|
|
242
292
|
});
|
|
243
|
-
if (!utils$
|
|
293
|
+
if (!utils$2.isValidArray(inactivePairings)) return;
|
|
244
294
|
inactivePairings.forEach(pairing => {
|
|
245
295
|
if (this.connector) {
|
|
246
|
-
this.connector.pairing.delete(pairing.topic, utils$
|
|
296
|
+
this.connector.pairing.delete(pairing.topic, utils$2.getSdkError("USER_DISCONNECTED"));
|
|
247
297
|
}
|
|
248
298
|
});
|
|
249
299
|
}
|
|
@@ -257,21 +307,22 @@ class WalletConnectV2Connector extends baseConnector.BaseConnector {
|
|
|
257
307
|
}
|
|
258
308
|
async createNewSession({
|
|
259
309
|
forceNewSession = false,
|
|
260
|
-
chainConfig
|
|
310
|
+
chainConfig,
|
|
311
|
+
trackCompletionEvents
|
|
261
312
|
}) {
|
|
262
313
|
try {
|
|
263
|
-
var _this$
|
|
314
|
+
var _this$activeSession4, _this$connectorOption7;
|
|
264
315
|
if (!this.connector) throw index$1.WalletInitializationError.notReady("Wallet connector is not ready yet");
|
|
265
316
|
if (!this.connectorOptions.loginSettings || Object.keys(this.connectorOptions.loginSettings).length === 0) throw index$1.WalletInitializationError.notReady("login settings are not set yet");
|
|
266
317
|
this.status = constants.CONNECTOR_STATUS.CONNECTING;
|
|
267
318
|
this.emit(constants.CONNECTOR_EVENTS.CONNECTING, {
|
|
268
319
|
connector: index.WALLET_CONNECTORS.WALLET_CONNECT_V2
|
|
269
320
|
});
|
|
270
|
-
if (forceNewSession && (_this$
|
|
271
|
-
var _this$
|
|
321
|
+
if (forceNewSession && (_this$activeSession4 = this.activeSession) !== null && _this$activeSession4 !== void 0 && _this$activeSession4.topic) {
|
|
322
|
+
var _this$activeSession5;
|
|
272
323
|
await this.connector.disconnect({
|
|
273
|
-
topic: (_this$
|
|
274
|
-
reason: utils$
|
|
324
|
+
topic: (_this$activeSession5 = this.activeSession) === null || _this$activeSession5 === void 0 ? void 0 : _this$activeSession5.topic,
|
|
325
|
+
reason: utils$2.getSdkError("USER_DISCONNECTED")
|
|
275
326
|
});
|
|
276
327
|
}
|
|
277
328
|
const {
|
|
@@ -304,7 +355,8 @@ class WalletConnectV2Connector extends baseConnector.BaseConnector {
|
|
|
304
355
|
this.activeSession = session;
|
|
305
356
|
// Handle the returned session (e.g. update UI to "connected" state).
|
|
306
357
|
await this.onConnectHandler({
|
|
307
|
-
chain: chainConfig
|
|
358
|
+
chain: chainConfig,
|
|
359
|
+
trackCompletionEvents
|
|
308
360
|
});
|
|
309
361
|
if (qrcodeModal) {
|
|
310
362
|
qrcodeModal.closeModal();
|
|
@@ -332,7 +384,8 @@ class WalletConnectV2Connector extends baseConnector.BaseConnector {
|
|
|
332
384
|
}
|
|
333
385
|
}
|
|
334
386
|
async onConnectHandler({
|
|
335
|
-
chain
|
|
387
|
+
chain,
|
|
388
|
+
trackCompletionEvents
|
|
336
389
|
}) {
|
|
337
390
|
var _this$connectorOption8;
|
|
338
391
|
if (!this.connector || !this.wcProvider) throw index$1.WalletInitializationError.notReady("Wallet connect connector is not ready yet");
|
|
@@ -350,6 +403,8 @@ class WalletConnectV2Connector extends baseConnector.BaseConnector {
|
|
|
350
403
|
await this.wcProvider.setupProvider(this.connector);
|
|
351
404
|
this.cleanupPendingPairings();
|
|
352
405
|
this.status = constants.CONNECTOR_STATUS.CONNECTED;
|
|
406
|
+
// track connection events
|
|
407
|
+
if (trackCompletionEvents) trackCompletionEvents();
|
|
353
408
|
this.emit(constants.CONNECTOR_EVENTS.CONNECTED, {
|
|
354
409
|
connector: index.WALLET_CONNECTORS.WALLET_CONNECT_V2,
|
|
355
410
|
reconnected: this.rehydrated,
|
|
@@ -394,7 +449,8 @@ class WalletConnectV2Connector extends baseConnector.BaseConnector {
|
|
|
394
449
|
const walletConnectV2Connector = params => {
|
|
395
450
|
return ({
|
|
396
451
|
coreOptions,
|
|
397
|
-
projectConfig
|
|
452
|
+
projectConfig,
|
|
453
|
+
analytics
|
|
398
454
|
}) => {
|
|
399
455
|
var _params$walletConnect;
|
|
400
456
|
const projectId = (params === null || params === void 0 || (_params$walletConnect = params.walletConnectInitOptions) === null || _params$walletConnect === void 0 ? void 0 : _params$walletConnect.projectId) || (projectConfig === null || projectConfig === void 0 ? void 0 : projectConfig.walletConnectProjectId);
|
|
@@ -405,7 +461,8 @@ const walletConnectV2Connector = params => {
|
|
|
405
461
|
});
|
|
406
462
|
return new WalletConnectV2Connector({
|
|
407
463
|
connectorSettings,
|
|
408
|
-
coreOptions
|
|
464
|
+
coreOptions,
|
|
465
|
+
analytics
|
|
409
466
|
});
|
|
410
467
|
};
|
|
411
468
|
};
|
package/dist/lib.cjs/noModal.js
CHANGED
|
@@ -51,6 +51,9 @@ class Web3AuthNoModal extends auth.SafeEventEmitter {
|
|
|
51
51
|
this.coreOptions = options;
|
|
52
52
|
this.storage = this.getStorageMethod();
|
|
53
53
|
this.analytics = new analytics.Analytics();
|
|
54
|
+
this.analytics.setGlobalProperties({
|
|
55
|
+
integration_type: analytics.ANALYTICS_INTEGRATION_TYPE.NATIVE_SDK
|
|
56
|
+
});
|
|
54
57
|
this.loadState(initialState);
|
|
55
58
|
if (this.state.idToken && this.coreOptions.ssr) {
|
|
56
59
|
this.status = constants.CONNECTOR_STATUS.CONNECTED;
|
|
@@ -58,6 +61,7 @@ class Web3AuthNoModal extends auth.SafeEventEmitter {
|
|
|
58
61
|
}
|
|
59
62
|
get currentChain() {
|
|
60
63
|
var _this$coreOptions$cha;
|
|
64
|
+
if (!this.currentChainId) return undefined;
|
|
61
65
|
return (_this$coreOptions$cha = this.coreOptions.chains) === null || _this$coreOptions$cha === void 0 ? void 0 : _this$coreOptions$cha.find(chain => chain.chainId === this.currentChainId);
|
|
62
66
|
}
|
|
63
67
|
get connected() {
|
|
@@ -76,7 +80,8 @@ class Web3AuthNoModal extends auth.SafeEventEmitter {
|
|
|
76
80
|
return this.state.cachedConnector;
|
|
77
81
|
}
|
|
78
82
|
get currentChainId() {
|
|
79
|
-
|
|
83
|
+
var _this$coreOptions$cha2;
|
|
84
|
+
return this.state.currentChainId || this.coreOptions.defaultChainId || ((_this$coreOptions$cha2 = this.coreOptions.chains) === null || _this$coreOptions$cha2 === void 0 || (_this$coreOptions$cha2 = _this$coreOptions$cha2[0]) === null || _this$coreOptions$cha2 === void 0 ? void 0 : _this$coreOptions$cha2.chainId) || null;
|
|
80
85
|
}
|
|
81
86
|
get connectedConnector() {
|
|
82
87
|
var _this$currentChain;
|
|
@@ -203,12 +208,10 @@ class Web3AuthNoModal extends auth.SafeEventEmitter {
|
|
|
203
208
|
if (!newChainConfig) throw index.WalletInitializationError.invalidParams("Invalid chainId");
|
|
204
209
|
if (this.status === constants.CONNECTOR_STATUS.CONNECTED && this.connectedConnector) {
|
|
205
210
|
await this.connectedConnector.switchChain(params);
|
|
206
|
-
this.setCurrentChain(params.chainId);
|
|
207
211
|
return;
|
|
208
212
|
}
|
|
209
213
|
if (this.commonJRPCProvider) {
|
|
210
214
|
await this.commonJRPCProvider.switchChain(params);
|
|
211
|
-
this.setCurrentChain(params.chainId);
|
|
212
215
|
return;
|
|
213
216
|
}
|
|
214
217
|
throw index.WalletInitializationError.notReady(`No wallet is ready`);
|
|
@@ -231,10 +234,16 @@ class Web3AuthNoModal extends auth.SafeEventEmitter {
|
|
|
231
234
|
if (connectorName === index$1.WALLET_CONNECTORS.AUTH) {
|
|
232
235
|
var _connector$authInstan;
|
|
233
236
|
const authLoginParams = loginParams;
|
|
237
|
+
const authConnectionConfig = connector.getOAuthProviderConfig({
|
|
238
|
+
authConnection: authLoginParams.authConnection,
|
|
239
|
+
authConnectionId: authLoginParams.authConnectionId,
|
|
240
|
+
groupedAuthConnectionId: authLoginParams.groupedAuthConnectionId
|
|
241
|
+
});
|
|
234
242
|
eventData = {
|
|
235
243
|
connector: connectorName,
|
|
236
244
|
connector_type: connector.type,
|
|
237
245
|
chain_id: utils.getCaipChainId(initialChain),
|
|
246
|
+
chain_name: initialChain.displayName,
|
|
238
247
|
chain_namespace: initialChain.chainNamespace,
|
|
239
248
|
auth_connection: authLoginParams.authConnection,
|
|
240
249
|
auth_connection_id: authLoginParams.authConnectionId,
|
|
@@ -246,6 +255,7 @@ class Web3AuthNoModal extends auth.SafeEventEmitter {
|
|
|
246
255
|
curve: authLoginParams.curve,
|
|
247
256
|
auth_dapp_url: authLoginParams.dappUrl,
|
|
248
257
|
is_sfa: Boolean(authLoginParams.idToken),
|
|
258
|
+
is_default_auth_connection: authConnectionConfig === null || authConnectionConfig === void 0 ? void 0 : authConnectionConfig.isDefault,
|
|
249
259
|
auth_ux_mode: (_connector$authInstan = connector.authInstance) === null || _connector$authInstan === void 0 || (_connector$authInstan = _connector$authInstan.options) === null || _connector$authInstan === void 0 ? void 0 : _connector$authInstan.uxMode
|
|
250
260
|
};
|
|
251
261
|
} else {
|
|
@@ -254,25 +264,37 @@ class Web3AuthNoModal extends auth.SafeEventEmitter {
|
|
|
254
264
|
connector_type: connector.type,
|
|
255
265
|
is_injected: connector.isInjected,
|
|
256
266
|
chain_id: utils.getCaipChainId(initialChain),
|
|
267
|
+
chain_name: initialChain.displayName,
|
|
257
268
|
chain_namespace: initialChain.chainNamespace
|
|
258
269
|
};
|
|
259
270
|
}
|
|
271
|
+
// track connection started event
|
|
260
272
|
this.analytics.track(analytics.ANALYTICS_EVENTS.CONNECTION_STARTED, eventData);
|
|
261
273
|
return new Promise((resolve, reject) => {
|
|
262
|
-
|
|
274
|
+
const cleanup = () => {
|
|
275
|
+
this.off(constants.CONNECTOR_EVENTS.CONNECTED, onConnected);
|
|
276
|
+
this.off(constants.CONNECTOR_EVENTS.ERRORED, onErrored);
|
|
277
|
+
};
|
|
278
|
+
const onConnected = async () => {
|
|
263
279
|
// track connection completed event
|
|
280
|
+
const userInfo = await connector.getUserInfo();
|
|
264
281
|
this.analytics.track(analytics.ANALYTICS_EVENTS.CONNECTION_COMPLETED, _objectSpread(_objectSpread({}, eventData), {}, {
|
|
282
|
+
is_mfa_enabled: userInfo === null || userInfo === void 0 ? void 0 : userInfo.isMfaEnabled,
|
|
265
283
|
duration: Date.now() - startTime
|
|
266
284
|
}));
|
|
285
|
+
cleanup();
|
|
267
286
|
resolve(this.provider);
|
|
268
|
-
}
|
|
269
|
-
|
|
287
|
+
};
|
|
288
|
+
const onErrored = async err => {
|
|
270
289
|
// track connection failed event
|
|
271
290
|
this.analytics.track(analytics.ANALYTICS_EVENTS.CONNECTION_FAILED, _objectSpread(_objectSpread(_objectSpread({}, eventData), utils.getErrorAnalyticsProperties(err)), {}, {
|
|
272
291
|
duration: Date.now() - startTime
|
|
273
292
|
}));
|
|
293
|
+
cleanup();
|
|
274
294
|
reject(err);
|
|
275
|
-
}
|
|
295
|
+
};
|
|
296
|
+
this.once(constants.CONNECTOR_EVENTS.CONNECTED, onConnected);
|
|
297
|
+
this.once(constants.CONNECTOR_EVENTS.ERRORED, onErrored);
|
|
276
298
|
connector.connect(finalLoginParams);
|
|
277
299
|
this.setCurrentChain(initialChain.chainId);
|
|
278
300
|
});
|
|
@@ -500,13 +522,15 @@ class Web3AuthNoModal extends auth.SafeEventEmitter {
|
|
|
500
522
|
}
|
|
501
523
|
getInitializationTrackData() {
|
|
502
524
|
try {
|
|
503
|
-
var _this$coreOptions$
|
|
504
|
-
const defaultChain = (_this$coreOptions$
|
|
505
|
-
const rpcHostnames = Array.from(new Set((_this$coreOptions$
|
|
525
|
+
var _this$coreOptions$cha3, _this$coreOptions$cha4, _this$coreOptions$cha5, _this$coreOptions$cha6, _this$coreOptions$uiC2;
|
|
526
|
+
const defaultChain = (_this$coreOptions$cha3 = this.coreOptions.chains) === null || _this$coreOptions$cha3 === void 0 ? void 0 : _this$coreOptions$cha3.find(chain => chain.chainId === this.coreOptions.defaultChainId);
|
|
527
|
+
const rpcHostnames = Array.from(new Set((_this$coreOptions$cha4 = this.coreOptions.chains) === null || _this$coreOptions$cha4 === void 0 ? void 0 : _this$coreOptions$cha4.map(chain => utils.getHostname(chain.rpcTarget)))).filter(Boolean);
|
|
506
528
|
return _objectSpread(_objectSpread(_objectSpread({
|
|
507
|
-
chain_ids: (_this$coreOptions$
|
|
529
|
+
chain_ids: (_this$coreOptions$cha5 = this.coreOptions.chains) === null || _this$coreOptions$cha5 === void 0 ? void 0 : _this$coreOptions$cha5.map(chain => utils.getCaipChainId(chain)),
|
|
530
|
+
chain_names: (_this$coreOptions$cha6 = this.coreOptions.chains) === null || _this$coreOptions$cha6 === void 0 ? void 0 : _this$coreOptions$cha6.map(chain => chain.displayName),
|
|
508
531
|
chain_rpc_targets: rpcHostnames,
|
|
509
532
|
default_chain_id: defaultChain ? utils.getCaipChainId(defaultChain) : undefined,
|
|
533
|
+
default_chain_name: defaultChain === null || defaultChain === void 0 ? void 0 : defaultChain.displayName,
|
|
510
534
|
logging_enabled: this.coreOptions.enableLogging,
|
|
511
535
|
storage_type: this.coreOptions.storageType,
|
|
512
536
|
session_time: this.coreOptions.sessionTime,
|
|
@@ -537,8 +561,9 @@ class Web3AuthNoModal extends auth.SafeEventEmitter {
|
|
|
537
561
|
this.subscribeToConnectorEvents(connector);
|
|
538
562
|
try {
|
|
539
563
|
const initialChain = this.getInitialChainIdForConnector(connector);
|
|
564
|
+
const autoConnect = this.checkIfAutoConnect(connector);
|
|
540
565
|
await connector.init({
|
|
541
|
-
autoConnect
|
|
566
|
+
autoConnect,
|
|
542
567
|
chainId: initialChain.chainId
|
|
543
568
|
});
|
|
544
569
|
} catch (e) {
|
|
@@ -554,7 +579,8 @@ class Web3AuthNoModal extends auth.SafeEventEmitter {
|
|
|
554
579
|
const connectorFns = [...(this.coreOptions.connectors || []), authConnector.authConnector()];
|
|
555
580
|
const config = {
|
|
556
581
|
projectConfig,
|
|
557
|
-
coreOptions: this.coreOptions
|
|
582
|
+
coreOptions: this.coreOptions,
|
|
583
|
+
analytics: this.analytics
|
|
558
584
|
};
|
|
559
585
|
// add injected connectors
|
|
560
586
|
const isExternalWalletEnabled = Boolean(projectConfig.externalWalletAuth);
|
|
@@ -775,6 +801,14 @@ class Web3AuthNoModal extends auth.SafeEventEmitter {
|
|
|
775
801
|
checkInitRequirements() {
|
|
776
802
|
if (this.status === constants.CONNECTOR_STATUS.READY) throw index.WalletInitializationError.notReady("Connector is already initialized");
|
|
777
803
|
}
|
|
804
|
+
checkIfAutoConnect(connector) {
|
|
805
|
+
var _this$currentChain5;
|
|
806
|
+
let autoConnect = this.cachedConnector === connector.name;
|
|
807
|
+
if (autoConnect && (_this$currentChain5 = this.currentChain) !== null && _this$currentChain5 !== void 0 && _this$currentChain5.chainNamespace) {
|
|
808
|
+
if (connector.connectorNamespace === IChainInterface.CONNECTOR_NAMESPACES.MULTICHAIN) autoConnect = true;else autoConnect = connector.connectorNamespace === this.currentChain.chainNamespace;
|
|
809
|
+
}
|
|
810
|
+
return autoConnect;
|
|
811
|
+
}
|
|
778
812
|
/**
|
|
779
813
|
* Gets the initial chain configuration for a connector
|
|
780
814
|
* @throws WalletInitializationError If no chain is found for the connector's namespace
|
|
@@ -804,14 +838,14 @@ class Web3AuthNoModal extends auth.SafeEventEmitter {
|
|
|
804
838
|
connectToPlugins(data) {
|
|
805
839
|
Object.values(this.plugins).map(async plugin => {
|
|
806
840
|
try {
|
|
807
|
-
var _this$
|
|
841
|
+
var _this$currentChain6;
|
|
808
842
|
// skip if it's not compatible with the connector
|
|
809
843
|
if (!plugin.SUPPORTED_CONNECTORS.includes(data.connector)) return;
|
|
810
844
|
// skip if it's not compatible with the current chain
|
|
811
|
-
if (plugin.pluginNamespace !== IPlugin.PLUGIN_NAMESPACES.MULTICHAIN && plugin.pluginNamespace !== ((_this$
|
|
845
|
+
if (plugin.pluginNamespace !== IPlugin.PLUGIN_NAMESPACES.MULTICHAIN && plugin.pluginNamespace !== ((_this$currentChain6 = this.currentChain) === null || _this$currentChain6 === void 0 ? void 0 : _this$currentChain6.chainNamespace)) return;
|
|
812
846
|
// skip if it's already connected
|
|
813
847
|
if (plugin.status === IPlugin.PLUGIN_STATUS.CONNECTED) return;
|
|
814
|
-
await plugin.initWithWeb3Auth(this, this.coreOptions.uiConfig);
|
|
848
|
+
await plugin.initWithWeb3Auth(this, this.coreOptions.uiConfig, this.analytics);
|
|
815
849
|
await plugin.connect();
|
|
816
850
|
} catch (error) {
|
|
817
851
|
// swallow error if connector connector doesn't supports this plugin.
|