@web3auth/modal 10.0.0-beta.12 → 10.0.0-beta.13
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/packages/modal/src/config.js +1 -1
- package/dist/lib.cjs/packages/modal/src/modalManager.js +147 -86
- package/dist/lib.cjs/packages/modal/src/react/context/Web3AuthInnerContext.js +3 -0
- package/dist/lib.cjs/packages/modal/src/react/wagmi/provider.js +3 -0
- package/dist/lib.cjs/packages/modal/src/ui/components/ConnectWallet/ConnectWallet.js +17 -1
- package/dist/lib.cjs/packages/modal/src/ui/components/Footer/Footer.js +8 -5
- package/dist/lib.cjs/packages/modal/src/ui/components/Login/Login.js +19 -0
- 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 +38 -13
- package/dist/lib.cjs/packages/modal/src/utils.js +22 -0
- package/dist/lib.cjs/packages/modal/src/vue/Web3AuthProvider.js +3 -0
- package/dist/lib.cjs/packages/modal/src/vue/composables/useManageMFA.js +1 -1
- package/dist/lib.cjs/packages/modal/src/vue/wagmi/provider.js +6 -2
- package/dist/lib.cjs/types/modalManager.d.ts +3 -2
- package/dist/lib.cjs/types/ui/context/AnalyticsContext.d.ts +4 -0
- package/dist/lib.cjs/types/ui/interfaces.d.ts +2 -1
- package/dist/lib.cjs/types/ui/loginModal.d.ts +1 -0
- package/dist/lib.cjs/types/utils.d.ts +17 -0
- package/dist/lib.esm/packages/modal/src/config.js +1 -1
- package/dist/lib.esm/packages/modal/src/modalManager.js +155 -92
- package/dist/lib.esm/packages/modal/src/react/context/Web3AuthInnerContext.js +4 -1
- package/dist/lib.esm/packages/modal/src/react/wagmi/provider.js +3 -0
- package/dist/lib.esm/packages/modal/src/ui/components/ConnectWallet/ConnectWallet.js +19 -2
- package/dist/lib.esm/packages/modal/src/ui/components/Footer/Footer.js +8 -5
- package/dist/lib.esm/packages/modal/src/ui/components/Login/Login.js +20 -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 +37 -12
- package/dist/lib.esm/packages/modal/src/utils.js +20 -0
- package/dist/lib.esm/packages/modal/src/vue/Web3AuthProvider.js +4 -1
- package/dist/lib.esm/packages/modal/src/vue/composables/useManageMFA.js +1 -1
- package/dist/lib.esm/packages/modal/src/vue/wagmi/provider.js +6 -2
- package/dist/modal.umd.min.js +1 -1
- package/dist/modal.umd.min.js.LICENSE.txt +4 -0
- package/package.json +6 -6
|
@@ -97,64 +97,101 @@ class Web3Auth extends noModal.Web3AuthNoModal {
|
|
|
97
97
|
noModal.log.info("modalConfig", this.modalConfig);
|
|
98
98
|
}
|
|
99
99
|
async init(options) {
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
projectConfig,
|
|
107
|
-
walletRegistry
|
|
108
|
-
} = await this.getProjectAndWalletConfig();
|
|
109
|
-
// init config
|
|
110
|
-
this.initUIConfig(projectConfig);
|
|
111
|
-
super.initAccountAbstractionConfig(projectConfig);
|
|
112
|
-
super.initChainsConfig(projectConfig);
|
|
113
|
-
super.initCachedConnectorAndChainId();
|
|
114
|
-
// init login modal
|
|
115
|
-
const {
|
|
116
|
-
filteredWalletRegistry,
|
|
117
|
-
disabledExternalWallets
|
|
118
|
-
} = this.filterWalletRegistry(walletRegistry, projectConfig);
|
|
119
|
-
this.loginModal = new loginModal.LoginModal(_objectSpread(_objectSpread({}, this.options.uiConfig), {}, {
|
|
120
|
-
connectorListener: this,
|
|
121
|
-
web3authClientId: this.options.clientId,
|
|
122
|
-
web3authNetwork: this.options.web3AuthNetwork,
|
|
123
|
-
authBuildEnv: this.options.authBuildEnv,
|
|
124
|
-
chainNamespaces: this.getChainNamespaces(),
|
|
125
|
-
walletRegistry: filteredWalletRegistry
|
|
126
|
-
}), {
|
|
127
|
-
onInitExternalWallets: this.onInitExternalWallets,
|
|
128
|
-
onSocialLogin: this.onSocialLogin,
|
|
129
|
-
onExternalWalletLogin: this.onExternalWalletLogin,
|
|
130
|
-
onModalVisibility: this.onModalVisibility
|
|
100
|
+
// init analytics
|
|
101
|
+
const startTime = Date.now();
|
|
102
|
+
this.analytics.init();
|
|
103
|
+
this.analytics.identify(this.options.clientId, {
|
|
104
|
+
web3auth_client_id: this.options.clientId,
|
|
105
|
+
web3auth_network: this.options.web3AuthNetwork
|
|
131
106
|
});
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
noModal.withAbort(() => this.initConnectors({
|
|
147
|
-
connectors: newConnectors,
|
|
107
|
+
this.analytics.setGlobalProperties({
|
|
108
|
+
dapp_url: window.location.origin,
|
|
109
|
+
sdk_name: noModal.ANALYTICS_SDK_TYPE.WEB_MODAL,
|
|
110
|
+
sdk_version: noModal.sdkVersion
|
|
111
|
+
});
|
|
112
|
+
let trackData = {};
|
|
113
|
+
try {
|
|
114
|
+
var _authConnector$authIn, _this$coreOptions$uiC;
|
|
115
|
+
const {
|
|
116
|
+
signal
|
|
117
|
+
} = options || {};
|
|
118
|
+
super.checkInitRequirements();
|
|
119
|
+
// get project config and wallet registry
|
|
120
|
+
const {
|
|
148
121
|
projectConfig,
|
|
122
|
+
walletRegistry
|
|
123
|
+
} = await this.getProjectAndWalletConfig();
|
|
124
|
+
// init config
|
|
125
|
+
this.initUIConfig(projectConfig);
|
|
126
|
+
super.initAccountAbstractionConfig(projectConfig);
|
|
127
|
+
super.initChainsConfig(projectConfig);
|
|
128
|
+
super.initCachedConnectorAndChainId();
|
|
129
|
+
super.initWalletServicesConfig(projectConfig);
|
|
130
|
+
trackData = this.getInitializationTrackData();
|
|
131
|
+
// init login modal
|
|
132
|
+
const {
|
|
133
|
+
filteredWalletRegistry,
|
|
149
134
|
disabledExternalWallets
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
135
|
+
} = this.filterWalletRegistry(walletRegistry, projectConfig);
|
|
136
|
+
this.loginModal = new loginModal.LoginModal(_objectSpread(_objectSpread({}, this.options.uiConfig), {}, {
|
|
137
|
+
connectorListener: this,
|
|
138
|
+
web3authClientId: this.options.clientId,
|
|
139
|
+
web3authNetwork: this.options.web3AuthNetwork,
|
|
140
|
+
authBuildEnv: this.options.authBuildEnv,
|
|
141
|
+
chainNamespaces: this.getChainNamespaces(),
|
|
142
|
+
walletRegistry: filteredWalletRegistry,
|
|
143
|
+
analytics: this.analytics
|
|
144
|
+
}), {
|
|
145
|
+
onInitExternalWallets: this.onInitExternalWallets,
|
|
146
|
+
onSocialLogin: this.onSocialLogin,
|
|
147
|
+
onExternalWalletLogin: this.onExternalWalletLogin,
|
|
148
|
+
onModalVisibility: this.onModalVisibility
|
|
149
|
+
});
|
|
150
|
+
await noModal.withAbort(() => this.loginModal.initModal(), signal);
|
|
151
|
+
// setup common JRPC provider
|
|
152
|
+
await noModal.withAbort(() => this.setupCommonJRPCProvider(), signal);
|
|
153
|
+
// initialize connectors
|
|
154
|
+
this.on(noModal.CONNECTOR_EVENTS.CONNECTORS_UPDATED, ({
|
|
155
|
+
connectors: newConnectors
|
|
156
|
+
}) => {
|
|
157
|
+
const onAbortHandler = () => {
|
|
158
|
+
var _this$connectors;
|
|
159
|
+
noModal.log.debug("init aborted");
|
|
160
|
+
if (((_this$connectors = this.connectors) === null || _this$connectors === void 0 ? void 0 : _this$connectors.length) > 0) {
|
|
161
|
+
super.cleanup();
|
|
162
|
+
}
|
|
163
|
+
};
|
|
164
|
+
noModal.withAbort(() => this.initConnectors({
|
|
165
|
+
connectors: newConnectors,
|
|
166
|
+
projectConfig,
|
|
167
|
+
disabledExternalWallets
|
|
168
|
+
}), signal, onAbortHandler);
|
|
169
|
+
});
|
|
170
|
+
await noModal.withAbort(() => super.loadConnectors({
|
|
171
|
+
projectConfig,
|
|
172
|
+
modalMode: true
|
|
173
|
+
}), signal);
|
|
174
|
+
// initialize plugins
|
|
175
|
+
await noModal.withAbort(() => super.initPlugins(), signal);
|
|
176
|
+
// track completion event
|
|
177
|
+
const authConnector = this.getConnector(noModal.WALLET_CONNECTORS.AUTH);
|
|
178
|
+
trackData = _objectSpread(_objectSpread({}, trackData), {}, {
|
|
179
|
+
connectors: this.connectors.map(connector => connector.name),
|
|
180
|
+
plugins: Object.keys(this.plugins),
|
|
181
|
+
auth_ux_mode: (authConnector === null || authConnector === void 0 || (_authConnector$authIn = authConnector.authInstance) === null || _authConnector$authIn === void 0 || (_authConnector$authIn = _authConnector$authIn.options) === null || _authConnector$authIn === void 0 ? void 0 : _authConnector$authIn.uxMode) || ((_this$coreOptions$uiC = this.coreOptions.uiConfig) === null || _this$coreOptions$uiC === void 0 ? void 0 : _this$coreOptions$uiC.uxMode)
|
|
182
|
+
});
|
|
183
|
+
this.analytics.track(noModal.ANALYTICS_EVENTS.SDK_INITIALIZATION_COMPLETED, _objectSpread(_objectSpread({}, trackData), {}, {
|
|
184
|
+
duration: Date.now() - startTime
|
|
185
|
+
}));
|
|
186
|
+
} catch (error) {
|
|
187
|
+
if (error instanceof DOMException && error.name === "AbortError") return;
|
|
188
|
+
// track failure event
|
|
189
|
+
this.analytics.track(noModal.ANALYTICS_EVENTS.SDK_INITIALIZATION_FAILED, _objectSpread(_objectSpread(_objectSpread({}, trackData), noModal.getErrorAnalyticsProperties(error)), {}, {
|
|
190
|
+
duration: Date.now() - startTime
|
|
191
|
+
}));
|
|
192
|
+
noModal.log.error("Failed to initialize modal", error);
|
|
193
|
+
throw error;
|
|
194
|
+
}
|
|
158
195
|
}
|
|
159
196
|
async connect() {
|
|
160
197
|
if (!this.loginModal) throw noModal.WalletInitializationError.notReady("Login modal is not initialized");
|
|
@@ -187,6 +224,49 @@ class Web3Auth extends noModal.Web3AuthNoModal {
|
|
|
187
224
|
this.once(interfaces.LOGIN_MODAL_EVENTS.MODAL_VISIBILITY, handleVisibility);
|
|
188
225
|
});
|
|
189
226
|
}
|
|
227
|
+
initUIConfig(projectConfig) {
|
|
228
|
+
super.initUIConfig(projectConfig);
|
|
229
|
+
this.options.uiConfig = deepmerge(noModal.cloneDeep(projectConfig.whitelabel || {}), this.options.uiConfig || {});
|
|
230
|
+
if (!this.options.uiConfig.defaultLanguage) this.options.uiConfig.defaultLanguage = utils.getUserLanguage(this.options.uiConfig.defaultLanguage);
|
|
231
|
+
if (!this.options.uiConfig.mode) this.options.uiConfig.mode = "light";
|
|
232
|
+
this.options.uiConfig = deepmerge(projectConfig.loginModal || {}, this.options.uiConfig, {
|
|
233
|
+
arrayMerge: (_, sourceArray) => sourceArray
|
|
234
|
+
});
|
|
235
|
+
// merge login methods order from project config and user config, with user config taking precedence
|
|
236
|
+
const defaultAuthConnections = projectConfig.embeddedWalletAuth.filter(x => x.isDefault).map(x => x.authConnection);
|
|
237
|
+
const mergedAuthConnections = [...(this.options.uiConfig.loginMethodsOrder || []), ...defaultAuthConnections];
|
|
238
|
+
const loginMethodsOrder = [];
|
|
239
|
+
const authConnectionSet = new Set();
|
|
240
|
+
for (const authConnection of mergedAuthConnections) {
|
|
241
|
+
if (authConnectionSet.has(authConnection)) continue;
|
|
242
|
+
authConnectionSet.add(authConnection);
|
|
243
|
+
loginMethodsOrder.push(authConnection);
|
|
244
|
+
}
|
|
245
|
+
this.options.uiConfig.loginMethodsOrder = loginMethodsOrder;
|
|
246
|
+
}
|
|
247
|
+
getInitializationTrackData() {
|
|
248
|
+
var _this$modalConfig, _this$modalConfig2, _this$modalConfig3, _this$options$uiConfi, _this$options$uiConfi2, _this$options$uiConfi3, _this$options$uiConfi4, _this$options$uiConfi5, _this$options$uiConfi6, _this$options$uiConfi7, _this$options$uiConfi8, _this$options$uiConfi9, _this$options$uiConfi0, _this$options$uiConfi1, _this$options$uiConfi10, _this$options$uiConfi11, _this$options$uiConfi12;
|
|
249
|
+
return _objectSpread(_objectSpread({}, super.getInitializationTrackData()), {}, {
|
|
250
|
+
modal_hide_wallet_discovery: (_this$modalConfig = this.modalConfig) === null || _this$modalConfig === void 0 ? void 0 : _this$modalConfig.hideWalletDiscovery,
|
|
251
|
+
modal_connectors: Object.keys(((_this$modalConfig2 = this.modalConfig) === null || _this$modalConfig2 === void 0 ? void 0 : _this$modalConfig2.connectors) || {}),
|
|
252
|
+
modal_auth_connector_login_methods: Object.keys(((_this$modalConfig3 = this.modalConfig) === null || _this$modalConfig3 === void 0 || (_this$modalConfig3 = _this$modalConfig3.connectors) === null || _this$modalConfig3 === void 0 || (_this$modalConfig3 = _this$modalConfig3[noModal.WALLET_CONNECTORS.AUTH]) === null || _this$modalConfig3 === void 0 ? void 0 : _this$modalConfig3.loginMethods) || {}),
|
|
253
|
+
// UI config
|
|
254
|
+
ui_login_methods_order: (_this$options$uiConfi = this.options.uiConfig) === null || _this$options$uiConfi === void 0 ? void 0 : _this$options$uiConfi.loginMethodsOrder,
|
|
255
|
+
ui_modal_z_index: (_this$options$uiConfi2 = this.options.uiConfig) === null || _this$options$uiConfi2 === void 0 ? void 0 : _this$options$uiConfi2.modalZIndex,
|
|
256
|
+
ui_display_errors_on_modal: (_this$options$uiConfi3 = this.options.uiConfig) === null || _this$options$uiConfi3 === void 0 ? void 0 : _this$options$uiConfi3.displayErrorsOnModal,
|
|
257
|
+
ui_login_grid_col: (_this$options$uiConfi4 = this.options.uiConfig) === null || _this$options$uiConfi4 === void 0 ? void 0 : _this$options$uiConfi4.loginGridCol,
|
|
258
|
+
ui_primary_button: (_this$options$uiConfi5 = this.options.uiConfig) === null || _this$options$uiConfi5 === void 0 ? void 0 : _this$options$uiConfi5.primaryButton,
|
|
259
|
+
ui_modal_widget_type: (_this$options$uiConfi6 = this.options.uiConfig) === null || _this$options$uiConfi6 === void 0 ? void 0 : _this$options$uiConfi6.widgetType,
|
|
260
|
+
ui_modal_target_id_used: Boolean((_this$options$uiConfi7 = this.options.uiConfig) === null || _this$options$uiConfi7 === void 0 ? void 0 : _this$options$uiConfi7.targetId),
|
|
261
|
+
ui_modal_logo_alignment: (_this$options$uiConfi8 = this.options.uiConfig) === null || _this$options$uiConfi8 === void 0 ? void 0 : _this$options$uiConfi8.logoAlignment,
|
|
262
|
+
ui_modal_border_radius_type: (_this$options$uiConfi9 = this.options.uiConfig) === null || _this$options$uiConfi9 === void 0 ? void 0 : _this$options$uiConfi9.borderRadiusType,
|
|
263
|
+
ui_modal_button_radius_type: (_this$options$uiConfi0 = this.options.uiConfig) === null || _this$options$uiConfi0 === void 0 ? void 0 : _this$options$uiConfi0.buttonRadiusType,
|
|
264
|
+
ui_modal_sign_in_methods: (_this$options$uiConfi1 = this.options.uiConfig) === null || _this$options$uiConfi1 === void 0 ? void 0 : _this$options$uiConfi1.signInMethods,
|
|
265
|
+
ui_modal_add_previous_login_hint: (_this$options$uiConfi10 = this.options.uiConfig) === null || _this$options$uiConfi10 === void 0 ? void 0 : _this$options$uiConfi10.addPreviousLoginHint,
|
|
266
|
+
ui_modal_display_installed_external_wallets: (_this$options$uiConfi11 = this.options.uiConfig) === null || _this$options$uiConfi11 === void 0 ? void 0 : _this$options$uiConfi11.displayInstalledExternalWallets,
|
|
267
|
+
ui_modal_display_external_wallets_count: (_this$options$uiConfi12 = this.options.uiConfig) === null || _this$options$uiConfi12 === void 0 ? void 0 : _this$options$uiConfi12.displayExternalWalletsCount
|
|
268
|
+
});
|
|
269
|
+
}
|
|
190
270
|
filterWalletRegistry(walletRegistry, projectConfig) {
|
|
191
271
|
const {
|
|
192
272
|
disableAllRecommendedWallets,
|
|
@@ -215,7 +295,7 @@ class Web3Auth extends noModal.Web3AuthNoModal {
|
|
|
215
295
|
};
|
|
216
296
|
}
|
|
217
297
|
async getProjectAndWalletConfig() {
|
|
218
|
-
var _this$options$account, _this$
|
|
298
|
+
var _this$options$account, _this$modalConfig4;
|
|
219
299
|
const [projectConfigResult, walletRegistryResult] = await Promise.allSettled([noModal.fetchProjectConfig({
|
|
220
300
|
clientId: this.options.clientId,
|
|
221
301
|
web3AuthNetwork: this.options.web3AuthNetwork,
|
|
@@ -235,7 +315,7 @@ class Web3Auth extends noModal.Web3AuthNoModal {
|
|
|
235
315
|
default: {}
|
|
236
316
|
};
|
|
237
317
|
const isExternalWalletEnabled = Boolean(projectConfig.externalWalletAuth);
|
|
238
|
-
if (isExternalWalletEnabled && !((_this$
|
|
318
|
+
if (isExternalWalletEnabled && !((_this$modalConfig4 = this.modalConfig) !== null && _this$modalConfig4 !== void 0 && _this$modalConfig4.hideWalletDiscovery)) {
|
|
239
319
|
if (walletRegistryResult.status === "fulfilled") {
|
|
240
320
|
walletRegistry = walletRegistryResult.value;
|
|
241
321
|
} else {
|
|
@@ -247,25 +327,6 @@ class Web3Auth extends noModal.Web3AuthNoModal {
|
|
|
247
327
|
walletRegistry
|
|
248
328
|
};
|
|
249
329
|
}
|
|
250
|
-
initUIConfig(projectConfig) {
|
|
251
|
-
this.options.uiConfig = deepmerge(noModal.cloneDeep(projectConfig.whitelabel || {}), this.options.uiConfig || {});
|
|
252
|
-
if (!this.options.uiConfig.defaultLanguage) this.options.uiConfig.defaultLanguage = utils.getUserLanguage(this.options.uiConfig.defaultLanguage);
|
|
253
|
-
if (!this.options.uiConfig.mode) this.options.uiConfig.mode = "light";
|
|
254
|
-
this.options.uiConfig = deepmerge(projectConfig.loginModal || {}, this.options.uiConfig, {
|
|
255
|
-
arrayMerge: (_, sourceArray) => sourceArray
|
|
256
|
-
});
|
|
257
|
-
// merge login methods order from project config and user config, with user config taking precedence
|
|
258
|
-
const defaultAuthConnections = projectConfig.embeddedWalletAuth.filter(x => x.isDefault).map(x => x.authConnection);
|
|
259
|
-
const mergedAuthConnections = [...(this.options.uiConfig.loginMethodsOrder || []), ...defaultAuthConnections];
|
|
260
|
-
const loginMethodsOrder = [];
|
|
261
|
-
const authConnectionSet = new Set();
|
|
262
|
-
for (const authConnection of mergedAuthConnections) {
|
|
263
|
-
if (authConnectionSet.has(authConnection)) continue;
|
|
264
|
-
authConnectionSet.add(authConnection);
|
|
265
|
-
loginMethodsOrder.push(authConnection);
|
|
266
|
-
}
|
|
267
|
-
this.options.uiConfig.loginMethodsOrder = loginMethodsOrder;
|
|
268
|
-
}
|
|
269
330
|
async initConnectors({
|
|
270
331
|
connectors,
|
|
271
332
|
projectConfig,
|
|
@@ -314,7 +375,7 @@ class Web3Auth extends noModal.Web3AuthNoModal {
|
|
|
314
375
|
projectConfig,
|
|
315
376
|
disabledExternalWallets
|
|
316
377
|
}) {
|
|
317
|
-
var _this$
|
|
378
|
+
var _this$modalConfig5;
|
|
318
379
|
// Auth connector config: populate this with the default config for auth connectors.
|
|
319
380
|
const loginMethods = {};
|
|
320
381
|
const embedWalletConfigMap = new Map();
|
|
@@ -345,7 +406,7 @@ class Web3Auth extends noModal.Web3AuthNoModal {
|
|
|
345
406
|
}
|
|
346
407
|
};
|
|
347
408
|
// populate the user config data with the dashboard config.
|
|
348
|
-
if ((_this$
|
|
409
|
+
if ((_this$modalConfig5 = this.modalConfig) !== null && _this$modalConfig5 !== void 0 && (_this$modalConfig5 = _this$modalConfig5.connectors) !== null && _this$modalConfig5 !== void 0 && _this$modalConfig5[noModal.WALLET_CONNECTORS.AUTH]) {
|
|
349
410
|
if (!this.modalConfig.connectors[noModal.WALLET_CONNECTORS.AUTH].loginMethods) this.modalConfig.connectors[noModal.WALLET_CONNECTORS.AUTH].loginMethods = {};
|
|
350
411
|
}
|
|
351
412
|
const authProviders = new Set(config$1.AUTH_PROVIDERS);
|
|
@@ -375,13 +436,13 @@ class Web3Auth extends noModal.Web3AuthNoModal {
|
|
|
375
436
|
// merge default connectors with the custom configured connectors.
|
|
376
437
|
const allConnectorNames = [...new Set([...Object.keys(this.modalConfig.connectors || {}), ...this.connectors.map(connector => connector.name)])];
|
|
377
438
|
const connectorNames = allConnectorNames.map(connectorName => {
|
|
378
|
-
var _this$
|
|
439
|
+
var _this$modalConfig6, _this$modalConfig$con, _this$modalConfig$con2;
|
|
379
440
|
// start with the default config of connector.
|
|
380
441
|
const defaultConnectorConfig = {
|
|
381
442
|
label: noModal.CONNECTOR_NAMES[connectorName] || connectorName.split("-").map(config$1.capitalizeFirstLetter).join(" "),
|
|
382
443
|
showOnModal: true
|
|
383
444
|
};
|
|
384
|
-
this.modalConfig.connectors[connectorName] = _objectSpread(_objectSpread({}, defaultConnectorConfig), ((_this$
|
|
445
|
+
this.modalConfig.connectors[connectorName] = _objectSpread(_objectSpread({}, defaultConnectorConfig), ((_this$modalConfig6 = this.modalConfig) === null || _this$modalConfig6 === void 0 || (_this$modalConfig6 = _this$modalConfig6.connectors) === null || _this$modalConfig6 === void 0 ? void 0 : _this$modalConfig6[connectorName]) || {});
|
|
385
446
|
// check if connector is configured/added by user and exist in connectors map.
|
|
386
447
|
const connector = this.getConnector(connectorName);
|
|
387
448
|
noModal.log.debug("connector config", connectorName, (_this$modalConfig$con = this.modalConfig.connectors) === null || _this$modalConfig$con === void 0 || (_this$modalConfig$con = _this$modalConfig$con[connectorName]) === null || _this$modalConfig$con === void 0 ? void 0 : _this$modalConfig$con.showOnModal, connector);
|
|
@@ -401,9 +462,9 @@ class Web3Auth extends noModal.Web3AuthNoModal {
|
|
|
401
462
|
}
|
|
402
463
|
// skip WC connector if external wallets are disabled or hideWalletDiscovery is true
|
|
403
464
|
if (connectorName === noModal.WALLET_CONNECTORS.WALLET_CONNECT_V2) {
|
|
404
|
-
var _this$
|
|
465
|
+
var _this$modalConfig7;
|
|
405
466
|
if (!isExternalWalletEnabled) return;
|
|
406
|
-
if ((_this$
|
|
467
|
+
if ((_this$modalConfig7 = this.modalConfig) !== null && _this$modalConfig7 !== void 0 && _this$modalConfig7.hideWalletDiscovery) return;
|
|
407
468
|
}
|
|
408
469
|
this.modalConfig.connectors[connectorName] = connectorConfig;
|
|
409
470
|
return connectorName;
|
|
@@ -454,12 +515,12 @@ class Web3Auth extends noModal.Web3AuthNoModal {
|
|
|
454
515
|
// note: not adding cachedWallet to modal if it is external wallet.
|
|
455
516
|
// adding it later if no in-app wallets are available.
|
|
456
517
|
if (connector.type === noModal.CONNECTOR_CATEGORY.IN_APP) {
|
|
457
|
-
var _this$modalConfig$con6, _this$options$
|
|
518
|
+
var _this$modalConfig$con6, _this$options$uiConfi13, _this$options$uiConfi14, _this$options$uiConfi15;
|
|
458
519
|
noModal.log.info("connectorInitResults", connectorName);
|
|
459
520
|
const loginMethods = ((_this$modalConfig$con6 = this.modalConfig.connectors[connectorName]) === null || _this$modalConfig$con6 === void 0 ? void 0 : _this$modalConfig$con6.loginMethods) || {};
|
|
460
|
-
this.loginModal.addSocialLogins(connectorName, loginMethods, ((_this$options$
|
|
461
|
-
loginGridCol: ((_this$options$
|
|
462
|
-
primaryButton: ((_this$options$
|
|
521
|
+
this.loginModal.addSocialLogins(connectorName, loginMethods, ((_this$options$uiConfi13 = this.options.uiConfig) === null || _this$options$uiConfi13 === void 0 ? void 0 : _this$options$uiConfi13.loginMethodsOrder) || config$1.AUTH_PROVIDERS, _objectSpread(_objectSpread({}, this.options.uiConfig), {}, {
|
|
522
|
+
loginGridCol: ((_this$options$uiConfi14 = this.options.uiConfig) === null || _this$options$uiConfi14 === void 0 ? void 0 : _this$options$uiConfi14.loginGridCol) || 3,
|
|
523
|
+
primaryButton: ((_this$options$uiConfi15 = this.options.uiConfig) === null || _this$options$uiConfi15 === void 0 ? void 0 : _this$options$uiConfi15.primaryButton) || "socialLogin"
|
|
463
524
|
}));
|
|
464
525
|
}
|
|
465
526
|
} catch (error) {
|
|
@@ -35,6 +35,9 @@ function Web3AuthInnerProvider(params) {
|
|
|
35
35
|
try {
|
|
36
36
|
setInitError(null);
|
|
37
37
|
setIsInitializing(true);
|
|
38
|
+
web3Auth.setAnalyticsProperties({
|
|
39
|
+
integration_type: noModal.ANALYTICS_INTEGRATION_TYPE.REACT_HOOKS
|
|
40
|
+
});
|
|
38
41
|
await web3Auth.init({
|
|
39
42
|
signal: controller.signal
|
|
40
43
|
});
|
|
@@ -130,6 +130,9 @@ function WagmiProvider(_ref) {
|
|
|
130
130
|
web3Auth,
|
|
131
131
|
isInitialized
|
|
132
132
|
} = useWeb3Auth.useWeb3Auth();
|
|
133
|
+
web3Auth === null || web3Auth === void 0 || web3Auth.setAnalyticsProperties({
|
|
134
|
+
wagmi_enabled: true
|
|
135
|
+
});
|
|
133
136
|
const finalConfig = react.useMemo(() => {
|
|
134
137
|
var _web3Auth$coreOptions;
|
|
135
138
|
if (!isInitialized) return constants.defaultWagmiConfig;
|
|
@@ -5,6 +5,7 @@ var jsxRuntime = require('react/jsx-runtime');
|
|
|
5
5
|
var noModal = require('@web3auth/no-modal');
|
|
6
6
|
var react = require('react');
|
|
7
7
|
var constants = require('../../constants.js');
|
|
8
|
+
var AnalyticsContext = require('../../context/AnalyticsContext.js');
|
|
8
9
|
var RootContext = require('../../context/RootContext.js');
|
|
9
10
|
var ConnectWalletChainFilter = require('./ConnectWalletChainFilter/ConnectWalletChainFilter.js');
|
|
10
11
|
var ConnectWalletHeader = require('./ConnectWalletHeader/ConnectWalletHeader.js');
|
|
@@ -34,6 +35,9 @@ function ConnectWallet(props) {
|
|
|
34
35
|
bodyState,
|
|
35
36
|
setBodyState
|
|
36
37
|
} = react.useContext(RootContext.RootContext);
|
|
38
|
+
const {
|
|
39
|
+
analytics
|
|
40
|
+
} = react.useContext(AnalyticsContext.AnalyticsContext);
|
|
37
41
|
const [currentPage, setCurrentPage] = react.useState(constants.CONNECT_WALLET_PAGES.CONNECT_WALLET);
|
|
38
42
|
const [selectedWallet, setSelectedWallet] = react.useState(false);
|
|
39
43
|
const [isLoading] = react.useState(false);
|
|
@@ -120,6 +124,18 @@ function ConnectWallet(props) {
|
|
|
120
124
|
}, [walletDiscoverySupported, defaultButtons, installedWalletButtons, isShowAllWallets, totalExternalWalletsCount]);
|
|
121
125
|
const handleWalletClick = button => {
|
|
122
126
|
var _button$chainNamespac2, _button$chainNamespac3;
|
|
127
|
+
const isInstalled = button.hasInjectedWallet || !button.hasWalletConnect && !button.hasInstallLinks;
|
|
128
|
+
analytics === null || analytics === void 0 || analytics.track(noModal.ANALYTICS_EVENTS.EXTERNAL_WALLET_SELECTED, {
|
|
129
|
+
connector: isInstalled ? button.name : button.hasWalletConnect ? noModal.WALLET_CONNECTORS.WALLET_CONNECT_V2 : "",
|
|
130
|
+
wallet_name: button.displayName,
|
|
131
|
+
is_installed: isInstalled,
|
|
132
|
+
is_injected: button.hasInjectedWallet,
|
|
133
|
+
chain_namespaces: button.chainNamespaces,
|
|
134
|
+
has_wallet_connect: button.hasWalletConnect,
|
|
135
|
+
has_install_links: button.hasInstallLinks,
|
|
136
|
+
has_wallet_registry_item: !!button.walletRegistryItem,
|
|
137
|
+
total_external_wallets: allUniqueButtons.length
|
|
138
|
+
});
|
|
123
139
|
// show chain namespace selector if the button is an injected connector with multiple chain namespaces
|
|
124
140
|
const isChainNamespaceSelectorRequired = button.hasInjectedWallet && ((_button$chainNamespac2 = button.chainNamespaces) === null || _button$chainNamespac2 === void 0 ? void 0 : _button$chainNamespac2.length) > 1;
|
|
125
141
|
if (isChainNamespaceSelectorRequired) {
|
|
@@ -139,7 +155,7 @@ function ConnectWallet(props) {
|
|
|
139
155
|
connector: button.name
|
|
140
156
|
});
|
|
141
157
|
}
|
|
142
|
-
if (button.hasWalletConnect
|
|
158
|
+
if (button.hasWalletConnect) {
|
|
143
159
|
setSelectedButton(button);
|
|
144
160
|
setSelectedWallet(true);
|
|
145
161
|
setCurrentPage(constants.CONNECT_WALLET_PAGES.SELECTED_WALLET);
|
|
@@ -32,16 +32,19 @@ function Footer({
|
|
|
32
32
|
})]
|
|
33
33
|
}), jsxRuntime.jsxs("div", {
|
|
34
34
|
className: "w3a--flex w3a--items-center w3a--justify-center w3a--gap-2",
|
|
35
|
-
children: [jsxRuntime.jsx("
|
|
36
|
-
|
|
35
|
+
children: [jsxRuntime.jsx("div", {
|
|
36
|
+
className: "w3a--text-xs w3a--text-app-gray-300 dark:w3a--text-app-gray-500",
|
|
37
|
+
children: t("modal.footer.message-new")
|
|
38
|
+
}), jsxRuntime.jsx("img", {
|
|
39
|
+
height: "16",
|
|
37
40
|
src: "https://images.web3auth.io/web3auth-footer-logo-light.svg",
|
|
38
41
|
alt: "Web3Auth Logo Light",
|
|
39
|
-
className: "w3a--block w3a--h-
|
|
42
|
+
className: "w3a--block w3a--h-4 dark:w3a--hidden"
|
|
40
43
|
}), jsxRuntime.jsx("img", {
|
|
41
|
-
height: "
|
|
44
|
+
height: "16",
|
|
42
45
|
src: "https://images.web3auth.io/web3auth-footer-logo-dark.svg",
|
|
43
46
|
alt: "Web3Auth Logo Dark",
|
|
44
|
-
className: "w3a--hidden w3a--h-
|
|
47
|
+
className: "w3a--hidden w3a--h-4 dark:w3a--block"
|
|
45
48
|
})]
|
|
46
49
|
})]
|
|
47
50
|
});
|
|
@@ -9,6 +9,7 @@ var react = require('react');
|
|
|
9
9
|
var reactI18next = require('react-i18next');
|
|
10
10
|
var config = require('../../config.js');
|
|
11
11
|
var constants = require('../../constants.js');
|
|
12
|
+
var AnalyticsContext = require('../../context/AnalyticsContext.js');
|
|
12
13
|
var RootContext = require('../../context/RootContext.js');
|
|
13
14
|
var factory = require('../../handlers/factory.js');
|
|
14
15
|
var localeImport = require('../../localeImport.js');
|
|
@@ -52,6 +53,9 @@ function Login(props) {
|
|
|
52
53
|
bodyState,
|
|
53
54
|
setBodyState
|
|
54
55
|
} = react.useContext(RootContext.RootContext);
|
|
56
|
+
const {
|
|
57
|
+
analytics
|
|
58
|
+
} = react.useContext(AnalyticsContext.AnalyticsContext);
|
|
55
59
|
const [countryCode, setCountryCode] = react.useState("");
|
|
56
60
|
const [countryFlag, setCountryFlag] = react.useState("");
|
|
57
61
|
const [passwordlessErrorMessage, setPasswordlessErrorMessage] = react.useState("");
|
|
@@ -265,6 +269,10 @@ function Login(props) {
|
|
|
265
269
|
if (isSmsPasswordLessLoginVisible) getLocation();
|
|
266
270
|
}, [isSmsPasswordLessLoginVisible]);
|
|
267
271
|
const handleConnectWallet = e => {
|
|
272
|
+
analytics === null || analytics === void 0 || analytics.track(noModal.ANALYTICS_EVENTS.EXTERNAL_WALLET_LIST_EXPANDED, {
|
|
273
|
+
total_external_wallets: totalExternalWallets,
|
|
274
|
+
installed_external_wallets: installedExternalWallets.length
|
|
275
|
+
});
|
|
268
276
|
setIsPasswordLessCtaClicked(false);
|
|
269
277
|
e.preventDefault();
|
|
270
278
|
if (handleExternalWalletBtnClick) handleExternalWalletBtnClick(true);
|
|
@@ -304,6 +312,17 @@ function Login(props) {
|
|
|
304
312
|
};
|
|
305
313
|
const handleInstalledWalletClick = wallet => {
|
|
306
314
|
var _wallet$chainNamespac;
|
|
315
|
+
analytics === null || analytics === void 0 || analytics.track(noModal.ANALYTICS_EVENTS.EXTERNAL_WALLET_SELECTED, {
|
|
316
|
+
connector: wallet.name,
|
|
317
|
+
wallet_name: wallet.displayName,
|
|
318
|
+
is_installed: true,
|
|
319
|
+
is_injected: wallet.hasInjectedWallet,
|
|
320
|
+
chain_namespaces: wallet.chainNamespaces,
|
|
321
|
+
has_wallet_connect: wallet.hasWalletConnect,
|
|
322
|
+
has_install_links: wallet.hasInstallLinks,
|
|
323
|
+
has_wallet_registry_item: !!wallet.walletRegistryItem,
|
|
324
|
+
total_external_wallets: totalExternalWallets
|
|
325
|
+
});
|
|
307
326
|
// for non-injected Metamask, show QR code to connect
|
|
308
327
|
if (wallet.name === noModal.WALLET_CONNECTORS.METAMASK && !wallet.hasInjectedWallet) {
|
|
309
328
|
setBodyState(_objectSpread(_objectSpread({}, bodyState), {}, {
|
|
@@ -129,7 +129,7 @@ function Widget(props) {
|
|
|
129
129
|
externalWalletsVisibility: flag
|
|
130
130
|
});
|
|
131
131
|
});
|
|
132
|
-
if (handleShowExternalWallets) handleShowExternalWallets(modalState.externalWalletsInitialized);
|
|
132
|
+
if (flag && handleShowExternalWallets) handleShowExternalWallets(modalState.externalWalletsInitialized);
|
|
133
133
|
};
|
|
134
134
|
const onCloseModal = () => {
|
|
135
135
|
setModalState(prevState => _objectSpread(_objectSpread({}, prevState), {}, {
|
|
@@ -169,7 +169,7 @@ function Widget(props) {
|
|
|
169
169
|
});
|
|
170
170
|
}
|
|
171
171
|
// auto connect to MetaMask if not injected to generate QR code URI for mobile connection
|
|
172
|
-
const mmAvailable = !((_modalState$externalW2 = modalState.externalWalletsConfig[noModal.WALLET_CONNECTORS.METAMASK]) !== null && _modalState$externalW2 !== void 0 && _modalState$externalW2.isInjected);
|
|
172
|
+
const mmAvailable = modalState.externalWalletsConfig[noModal.WALLET_CONNECTORS.METAMASK] && !((_modalState$externalW2 = modalState.externalWalletsConfig[noModal.WALLET_CONNECTORS.METAMASK]) !== null && _modalState$externalW2 !== void 0 && _modalState$externalW2.isInjected);
|
|
173
173
|
if (mmAvailable && !modalState.metamaskConnectUri && typeof handleExternalWalletClick === "function") {
|
|
174
174
|
handleExternalWalletClick({
|
|
175
175
|
connector: noModal.WALLET_CONNECTORS.METAMASK
|