@web3auth/modal 10.0.0-beta.9 → 10.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/lib.cjs/packages/modal/src/config.js +1 -1
- package/dist/lib.cjs/packages/modal/src/connectors/coinbase-connector/index.js +12 -0
- package/dist/lib.cjs/packages/modal/src/modalManager.js +152 -91
- package/dist/lib.cjs/packages/modal/src/providers/ethereum-mpc-provider/index.js +12 -0
- package/dist/lib.cjs/packages/modal/src/providers/xrpl-provider/index.js +12 -0
- package/dist/lib.cjs/packages/modal/src/react/Web3AuthProvider.js +3 -1
- package/dist/lib.cjs/packages/modal/src/react/context/Web3AuthInnerContext.js +23 -19
- package/dist/lib.cjs/packages/modal/src/react/hooks/useIdentityToken.js +3 -3
- package/dist/lib.cjs/packages/modal/src/react/hooks/useWeb3AuthConnect.js +17 -1
- package/dist/lib.cjs/packages/modal/src/react/wagmi/constants.js +16 -0
- package/dist/lib.cjs/packages/modal/src/react/wagmi/provider.js +12 -6
- package/dist/lib.cjs/packages/modal/src/ui/components/ConnectWallet/ConnectWallet.js +17 -1
- package/dist/lib.cjs/packages/modal/src/ui/components/ConnectWallet/ConnectWalletChainFilter/ConnectWalletChainFilter.js +8 -5
- package/dist/lib.cjs/packages/modal/src/ui/components/Footer/Footer.js +1 -1
- package/dist/lib.cjs/packages/modal/src/ui/components/Login/Login.js +23 -4
- package/dist/lib.cjs/packages/modal/src/ui/components/Root/Root.js +1 -1
- package/dist/lib.cjs/packages/modal/src/ui/components/Widget/Widget.js +2 -2
- package/dist/lib.cjs/packages/modal/src/ui/context/AnalyticsContext.js +9 -0
- package/dist/lib.cjs/packages/modal/src/ui/css/index.css.js +1 -1
- package/dist/lib.cjs/packages/modal/src/ui/loginModal.js +42 -15
- package/dist/lib.cjs/packages/modal/src/utils.js +22 -0
- package/dist/lib.cjs/packages/modal/src/vue/Web3AuthProvider.js +11 -2
- package/dist/lib.cjs/packages/modal/src/vue/composables/useIdentityToken.js +3 -3
- package/dist/lib.cjs/packages/modal/src/vue/composables/useManageMFA.js +1 -1
- package/dist/lib.cjs/packages/modal/src/vue/composables/useWeb3AuthConnect.js +17 -1
- package/dist/lib.cjs/packages/modal/src/vue/solana/composables/useSolanaWallet.js +17 -14
- package/dist/lib.cjs/packages/modal/src/vue/wagmi/constants.js +16 -0
- package/dist/lib.cjs/packages/modal/src/vue/wagmi/provider.js +34 -15
- package/dist/lib.cjs/types/connectors/coinbase-connector/index.d.ts +1 -0
- package/dist/lib.cjs/types/interface.d.ts +0 -3
- package/dist/lib.cjs/types/modalManager.d.ts +5 -4
- package/dist/lib.cjs/types/providers/ethereum-mpc-provider/index.d.ts +1 -0
- package/dist/lib.cjs/types/providers/xrpl-provider/index.d.ts +1 -0
- package/dist/lib.cjs/types/react/Web3AuthProvider.d.ts +1 -1
- package/dist/lib.cjs/types/react/hooks/useIdentityToken.d.ts +2 -2
- package/dist/lib.cjs/types/react/hooks/useWeb3AuthConnect.d.ts +2 -1
- package/dist/lib.cjs/types/react/interfaces.d.ts +2 -1
- package/dist/lib.cjs/types/react/wagmi/constants.d.ts +43 -0
- package/dist/lib.cjs/types/ui/context/AnalyticsContext.d.ts +4 -0
- package/dist/lib.cjs/types/ui/interfaces.d.ts +3 -2
- package/dist/lib.cjs/types/ui/loginModal.d.ts +1 -0
- package/dist/lib.cjs/types/utils.d.ts +17 -0
- package/dist/lib.cjs/types/vue/composables/useIdentityToken.d.ts +1 -1
- package/dist/lib.cjs/types/vue/composables/useWeb3AuthConnect.d.ts +2 -1
- package/dist/lib.cjs/types/vue/wagmi/constants.d.ts +43 -0
- package/dist/lib.cjs/types/vue/wagmi/provider.d.ts +1 -0
- package/dist/lib.esm/packages/modal/src/config.js +1 -1
- package/dist/lib.esm/packages/modal/src/connectors/coinbase-connector/index.js +1 -0
- package/dist/lib.esm/packages/modal/src/modalManager.js +160 -97
- package/dist/lib.esm/packages/modal/src/providers/ethereum-mpc-provider/index.js +1 -0
- package/dist/lib.esm/packages/modal/src/providers/xrpl-provider/index.js +1 -0
- package/dist/lib.esm/packages/modal/src/react/Web3AuthProvider.js +3 -1
- package/dist/lib.esm/packages/modal/src/react/context/Web3AuthInnerContext.js +25 -21
- package/dist/lib.esm/packages/modal/src/react/hooks/useIdentityToken.js +3 -3
- package/dist/lib.esm/packages/modal/src/react/hooks/useWeb3AuthConnect.js +17 -1
- package/dist/lib.esm/packages/modal/src/react/wagmi/constants.js +14 -0
- package/dist/lib.esm/packages/modal/src/react/wagmi/provider.js +14 -9
- package/dist/lib.esm/packages/modal/src/ui/components/ConnectWallet/ConnectWallet.js +19 -2
- package/dist/lib.esm/packages/modal/src/ui/components/ConnectWallet/ConnectWalletChainFilter/ConnectWalletChainFilter.js +8 -5
- package/dist/lib.esm/packages/modal/src/ui/components/Footer/Footer.js +1 -1
- package/dist/lib.esm/packages/modal/src/ui/components/Login/Login.js +24 -5
- package/dist/lib.esm/packages/modal/src/ui/components/Root/Root.js +1 -1
- package/dist/lib.esm/packages/modal/src/ui/components/Widget/Widget.js +2 -2
- package/dist/lib.esm/packages/modal/src/ui/context/AnalyticsContext.js +7 -0
- package/dist/lib.esm/packages/modal/src/ui/css/index.css.js +1 -1
- package/dist/lib.esm/packages/modal/src/ui/loginModal.js +41 -14
- package/dist/lib.esm/packages/modal/src/utils.js +20 -0
- package/dist/lib.esm/packages/modal/src/vue/Web3AuthProvider.js +12 -3
- package/dist/lib.esm/packages/modal/src/vue/composables/useIdentityToken.js +3 -3
- package/dist/lib.esm/packages/modal/src/vue/composables/useManageMFA.js +1 -1
- package/dist/lib.esm/packages/modal/src/vue/composables/useWeb3AuthConnect.js +17 -1
- package/dist/lib.esm/packages/modal/src/vue/solana/composables/useSolanaWallet.js +17 -14
- package/dist/lib.esm/packages/modal/src/vue/wagmi/constants.js +14 -0
- package/dist/lib.esm/packages/modal/src/vue/wagmi/provider.js +37 -18
- package/dist/modal.umd.min.js +1 -1
- package/dist/modal.umd.min.js.LICENSE.txt +4 -6
- package/package.json +41 -16
package/README.md
CHANGED
|
@@ -43,7 +43,7 @@ Hop on to the [Web3Auth Dashboard](https://dashboard.web3auth.io/) and create a
|
|
|
43
43
|
Web3Auth needs to initialise as soon as your app loads up to enable the user to log in. Preferably done within a constructor, initialisation is the step where you can pass on all the configurations for Web3Auth you want. A simple integration for Ethereum blockchain will look like this:
|
|
44
44
|
|
|
45
45
|
```js
|
|
46
|
-
import { Web3Auth } from "
|
|
46
|
+
import { Web3Auth } from "web3auth";
|
|
47
47
|
|
|
48
48
|
//Initialize within your constructor
|
|
49
49
|
const web3auth = new Web3Auth({
|
|
@@ -54,7 +54,7 @@ const web3auth = new Web3Auth({
|
|
|
54
54
|
},
|
|
55
55
|
});
|
|
56
56
|
|
|
57
|
-
await web3auth.
|
|
57
|
+
await web3auth.init();
|
|
58
58
|
```
|
|
59
59
|
|
|
60
60
|
### Login your User
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var coinbaseConnector = require('@web3auth/no-modal/connectors/coinbase-connector');
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
Object.keys(coinbaseConnector).forEach(function (k) {
|
|
8
|
+
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
9
|
+
enumerable: true,
|
|
10
|
+
get: function () { return coinbaseConnector[k]; }
|
|
11
|
+
});
|
|
12
|
+
});
|
|
@@ -12,8 +12,8 @@ var loginModal = require('./ui/loginModal.js');
|
|
|
12
12
|
var utils = require('./ui/utils.js');
|
|
13
13
|
|
|
14
14
|
class Web3Auth extends noModal.Web3AuthNoModal {
|
|
15
|
-
constructor(options) {
|
|
16
|
-
super(options);
|
|
15
|
+
constructor(options, initialState) {
|
|
16
|
+
super(options, initialState);
|
|
17
17
|
_defineProperty(this, "loginModal", void 0);
|
|
18
18
|
_defineProperty(this, "options", void 0);
|
|
19
19
|
_defineProperty(this, "modalConfig", noModal.cloneDeep(config.defaultConnectorsModalConfig));
|
|
@@ -27,14 +27,14 @@ class Web3Auth extends noModal.Web3AuthNoModal {
|
|
|
27
27
|
});
|
|
28
28
|
_defineProperty(this, "onSocialLogin", async params => {
|
|
29
29
|
try {
|
|
30
|
-
await this.connectTo(noModal.WALLET_CONNECTORS.AUTH, params.loginParams);
|
|
30
|
+
await this.connectTo(noModal.WALLET_CONNECTORS.AUTH, params.loginParams, noModal.LOGIN_MODE.MODAL);
|
|
31
31
|
} catch (error) {
|
|
32
32
|
noModal.log.error(`Error while connecting to connector: ${params.connector}`, error);
|
|
33
33
|
}
|
|
34
34
|
});
|
|
35
35
|
_defineProperty(this, "onExternalWalletLogin", async params => {
|
|
36
36
|
try {
|
|
37
|
-
await this.connectTo(params.connector, params.loginParams);
|
|
37
|
+
await this.connectTo(params.connector, params.loginParams, noModal.LOGIN_MODE.MODAL);
|
|
38
38
|
} catch (error) {
|
|
39
39
|
noModal.log.error(`Error while connecting to connector: ${params.connector}`, error);
|
|
40
40
|
}
|
|
@@ -96,65 +96,102 @@ class Web3Auth extends noModal.Web3AuthNoModal {
|
|
|
96
96
|
if (this.options.modalConfig) this.modalConfig = this.options.modalConfig;
|
|
97
97
|
noModal.log.info("modalConfig", this.modalConfig);
|
|
98
98
|
}
|
|
99
|
-
async
|
|
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
|
|
99
|
+
async init(options) {
|
|
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) {
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var ethereumMpcProvider = require('@web3auth/no-modal/providers/ethereum-mpc-provider');
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
Object.keys(ethereumMpcProvider).forEach(function (k) {
|
|
8
|
+
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
9
|
+
enumerable: true,
|
|
10
|
+
get: function () { return ethereumMpcProvider[k]; }
|
|
11
|
+
});
|
|
12
|
+
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var xrplProvider = require('@web3auth/no-modal/providers/xrpl-provider');
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
Object.keys(xrplProvider).forEach(function (k) {
|
|
8
|
+
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
9
|
+
enumerable: true,
|
|
10
|
+
get: function () { return xrplProvider[k]; }
|
|
11
|
+
});
|
|
12
|
+
});
|
|
@@ -6,13 +6,15 @@ var Web3AuthInnerContext = require('./context/Web3AuthInnerContext.js');
|
|
|
6
6
|
|
|
7
7
|
function Web3AuthProvider({
|
|
8
8
|
config,
|
|
9
|
+
initialState,
|
|
9
10
|
children
|
|
10
11
|
}) {
|
|
11
12
|
const pluginChild = /*#__PURE__*/react.createElement(WalletServicesInnerContext.WalletServicesContextProvider, {
|
|
12
13
|
context: Web3AuthInnerContext.Web3AuthInnerContext
|
|
13
14
|
}, children);
|
|
14
15
|
return /*#__PURE__*/react.createElement(Web3AuthInnerContext.Web3AuthInnerProvider, {
|
|
15
|
-
config
|
|
16
|
+
config,
|
|
17
|
+
initialState
|
|
16
18
|
}, pluginChild);
|
|
17
19
|
}
|
|
18
20
|
|
|
@@ -8,40 +8,37 @@ const Web3AuthInnerContext = /*#__PURE__*/react.createContext(null);
|
|
|
8
8
|
function Web3AuthInnerProvider(params) {
|
|
9
9
|
const {
|
|
10
10
|
children,
|
|
11
|
-
config
|
|
11
|
+
config,
|
|
12
|
+
initialState
|
|
12
13
|
} = params;
|
|
13
|
-
const
|
|
14
|
+
const {
|
|
15
|
+
web3AuthOptions
|
|
16
|
+
} = config;
|
|
14
17
|
const [isInitializing, setIsInitializing] = react.useState(false);
|
|
15
18
|
const [initError, setInitError] = react.useState(null);
|
|
16
|
-
const [isConnected, setIsConnected] = react.useState(false);
|
|
17
19
|
const [provider, setProvider] = react.useState(null);
|
|
18
20
|
const [isInitialized, setIsInitialized] = react.useState(false);
|
|
19
|
-
const [status, setStatus] = react.useState(null);
|
|
20
21
|
const [isMFAEnabled, setIsMFAEnabled] = react.useState(false);
|
|
22
|
+
const web3Auth = react.useMemo(() => {
|
|
23
|
+
setProvider(null);
|
|
24
|
+
return new modalManager.Web3Auth(web3AuthOptions, initialState);
|
|
25
|
+
}, [web3AuthOptions, initialState]);
|
|
26
|
+
const [isConnected, setIsConnected] = react.useState(web3Auth.status === noModal.CONNECTOR_STATUS.CONNECTED);
|
|
27
|
+
const [status, setStatus] = react.useState(web3Auth.status);
|
|
21
28
|
const getPlugin = react.useCallback(name => {
|
|
22
29
|
if (!web3Auth) throw noModal.WalletInitializationError.notReady();
|
|
23
30
|
return web3Auth.getPlugin(name);
|
|
24
31
|
}, [web3Auth]);
|
|
25
|
-
react.useEffect(() => {
|
|
26
|
-
const resetHookState = () => {
|
|
27
|
-
setProvider(null);
|
|
28
|
-
setIsConnected(false);
|
|
29
|
-
setStatus(null);
|
|
30
|
-
};
|
|
31
|
-
resetHookState();
|
|
32
|
-
const {
|
|
33
|
-
web3AuthOptions
|
|
34
|
-
} = config;
|
|
35
|
-
const web3AuthInstance = new modalManager.Web3Auth(web3AuthOptions);
|
|
36
|
-
setWeb3Auth(web3AuthInstance);
|
|
37
|
-
}, [config]);
|
|
38
32
|
react.useEffect(() => {
|
|
39
33
|
const controller = new AbortController();
|
|
40
34
|
async function init() {
|
|
41
35
|
try {
|
|
42
36
|
setInitError(null);
|
|
43
37
|
setIsInitializing(true);
|
|
44
|
-
|
|
38
|
+
web3Auth.setAnalyticsProperties({
|
|
39
|
+
integration_type: noModal.ANALYTICS_INTEGRATION_TYPE.REACT_HOOKS
|
|
40
|
+
});
|
|
41
|
+
await web3Auth.init({
|
|
45
42
|
signal: controller.signal
|
|
46
43
|
});
|
|
47
44
|
} catch (error) {
|
|
@@ -79,7 +76,12 @@ function Web3AuthInnerProvider(params) {
|
|
|
79
76
|
setStatus(web3Auth.status);
|
|
80
77
|
};
|
|
81
78
|
const errorListener = () => {
|
|
82
|
-
setStatus(
|
|
79
|
+
setStatus(web3Auth.status);
|
|
80
|
+
};
|
|
81
|
+
const rehydrationErrorListener = () => {
|
|
82
|
+
setStatus(web3Auth.status);
|
|
83
|
+
setIsConnected(false);
|
|
84
|
+
setProvider(null);
|
|
83
85
|
};
|
|
84
86
|
const mfaEnabledListener = isMFAEnabled => {
|
|
85
87
|
if (typeof isMFAEnabled === "boolean") setIsMFAEnabled(isMFAEnabled);
|
|
@@ -93,6 +95,7 @@ function Web3AuthInnerProvider(params) {
|
|
|
93
95
|
web3Auth.on(noModal.CONNECTOR_EVENTS.DISCONNECTED, disconnectedListener);
|
|
94
96
|
web3Auth.on(noModal.CONNECTOR_EVENTS.CONNECTING, connectingListener);
|
|
95
97
|
web3Auth.on(noModal.CONNECTOR_EVENTS.ERRORED, errorListener);
|
|
98
|
+
web3Auth.on(noModal.CONNECTOR_EVENTS.REHYDRATION_ERROR, rehydrationErrorListener);
|
|
96
99
|
web3Auth.on(noModal.CONNECTOR_EVENTS.MFA_ENABLED, mfaEnabledListener);
|
|
97
100
|
}
|
|
98
101
|
return () => {
|
|
@@ -103,6 +106,7 @@ function Web3AuthInnerProvider(params) {
|
|
|
103
106
|
web3Auth.off(noModal.CONNECTOR_EVENTS.DISCONNECTED, disconnectedListener);
|
|
104
107
|
web3Auth.off(noModal.CONNECTOR_EVENTS.CONNECTING, connectingListener);
|
|
105
108
|
web3Auth.off(noModal.CONNECTOR_EVENTS.ERRORED, errorListener);
|
|
109
|
+
web3Auth.off(noModal.CONNECTOR_EVENTS.REHYDRATION_ERROR, rehydrationErrorListener);
|
|
106
110
|
web3Auth.off(noModal.CONNECTOR_EVENTS.MFA_ENABLED, mfaEnabledListener);
|
|
107
111
|
web3Auth.cleanup();
|
|
108
112
|
}
|
|
@@ -11,11 +11,11 @@ const useIdentityToken = () => {
|
|
|
11
11
|
const [loading, setLoading] = react.useState(false);
|
|
12
12
|
const [error, setError] = react.useState(null);
|
|
13
13
|
const [token, setToken] = react.useState(null);
|
|
14
|
-
const
|
|
14
|
+
const getIdentityToken = react.useCallback(async () => {
|
|
15
15
|
setLoading(true);
|
|
16
16
|
setError(null);
|
|
17
17
|
try {
|
|
18
|
-
const userAuthInfo = await web3Auth.
|
|
18
|
+
const userAuthInfo = await web3Auth.getIdentityToken();
|
|
19
19
|
if (userAuthInfo !== null && userAuthInfo !== void 0 && userAuthInfo.idToken) {
|
|
20
20
|
setToken(userAuthInfo.idToken);
|
|
21
21
|
}
|
|
@@ -35,7 +35,7 @@ const useIdentityToken = () => {
|
|
|
35
35
|
loading,
|
|
36
36
|
error,
|
|
37
37
|
token,
|
|
38
|
-
|
|
38
|
+
getIdentityToken
|
|
39
39
|
};
|
|
40
40
|
};
|
|
41
41
|
|
|
@@ -35,12 +35,28 @@ const useWeb3AuthConnect = () => {
|
|
|
35
35
|
setLoading(false);
|
|
36
36
|
}
|
|
37
37
|
}, [web3Auth]);
|
|
38
|
+
const connectTo = react.useCallback(async (connector, params) => {
|
|
39
|
+
setLoading(true);
|
|
40
|
+
setError(null);
|
|
41
|
+
try {
|
|
42
|
+
const provider = await web3Auth.connectTo(connector, params);
|
|
43
|
+
if (provider) {
|
|
44
|
+
setConnectorName(web3Auth.connectedConnectorName);
|
|
45
|
+
}
|
|
46
|
+
return provider;
|
|
47
|
+
} catch (error) {
|
|
48
|
+
setError(error);
|
|
49
|
+
} finally {
|
|
50
|
+
setLoading(false);
|
|
51
|
+
}
|
|
52
|
+
}, [web3Auth]);
|
|
38
53
|
return {
|
|
39
54
|
isConnected,
|
|
40
55
|
loading,
|
|
41
56
|
error,
|
|
42
57
|
connectorName,
|
|
43
|
-
connect
|
|
58
|
+
connect,
|
|
59
|
+
connectTo
|
|
44
60
|
};
|
|
45
61
|
};
|
|
46
62
|
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var wagmi = require('wagmi');
|
|
4
|
+
var chains = require('wagmi/chains');
|
|
5
|
+
|
|
6
|
+
const defaultWagmiConfig = wagmi.createConfig({
|
|
7
|
+
chains: [chains.mainnet],
|
|
8
|
+
connectors: [],
|
|
9
|
+
// or your basic wallets
|
|
10
|
+
ssr: true,
|
|
11
|
+
transports: {
|
|
12
|
+
[chains.mainnet.id]: wagmi.http(chains.mainnet.rpcUrls.default.http[0])
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
exports.defaultWagmiConfig = defaultWagmiConfig;
|
|
@@ -28,6 +28,7 @@ require('react-qrcode-logo');
|
|
|
28
28
|
require('../../ui/components/Login/Login.js');
|
|
29
29
|
var useWeb3Auth = require('../hooks/useWeb3Auth.js');
|
|
30
30
|
var useWeb3AuthDisconnect = require('../hooks/useWeb3AuthDisconnect.js');
|
|
31
|
+
var constants = require('./constants.js');
|
|
31
32
|
|
|
32
33
|
const _excluded = ["children"];
|
|
33
34
|
const WEB3AUTH_CONNECTOR_ID = "web3auth";
|
|
@@ -89,6 +90,9 @@ function Web3AuthWagmiProvider({
|
|
|
89
90
|
disconnect
|
|
90
91
|
} = useWeb3AuthDisconnect.useWeb3AuthDisconnect();
|
|
91
92
|
const wagmiConfig = wagmi.useConfig();
|
|
93
|
+
const {
|
|
94
|
+
reconnect
|
|
95
|
+
} = wagmi.useReconnect();
|
|
92
96
|
wagmi.useAccountEffect({
|
|
93
97
|
onDisconnect: async () => {
|
|
94
98
|
noModal.log.info("Disconnected from wagmi");
|
|
@@ -104,13 +108,14 @@ function Web3AuthWagmiProvider({
|
|
|
104
108
|
throw new Error("Failed to setup connector");
|
|
105
109
|
}
|
|
106
110
|
await connectWeb3AuthWithWagmi(connector, wagmiConfig);
|
|
111
|
+
reconnect();
|
|
107
112
|
} else if (!isConnected) {
|
|
108
113
|
if (wagmiConfig.state.status === "connected") {
|
|
109
114
|
await disconnectWeb3AuthFromWagmi(wagmiConfig);
|
|
110
115
|
}
|
|
111
116
|
}
|
|
112
117
|
})();
|
|
113
|
-
}, [isConnected, wagmiConfig, provider]);
|
|
118
|
+
}, [isConnected, wagmiConfig, provider, reconnect]);
|
|
114
119
|
return /*#__PURE__*/react.createElement(react.Fragment, null, children);
|
|
115
120
|
}
|
|
116
121
|
function WagmiProvider(_ref) {
|
|
@@ -125,8 +130,12 @@ function WagmiProvider(_ref) {
|
|
|
125
130
|
web3Auth,
|
|
126
131
|
isInitialized
|
|
127
132
|
} = useWeb3Auth.useWeb3Auth();
|
|
133
|
+
web3Auth === null || web3Auth === void 0 || web3Auth.setAnalyticsProperties({
|
|
134
|
+
wagmi_enabled: true
|
|
135
|
+
});
|
|
128
136
|
const finalConfig = react.useMemo(() => {
|
|
129
137
|
var _web3Auth$coreOptions;
|
|
138
|
+
if (!isInitialized) return constants.defaultWagmiConfig;
|
|
130
139
|
const finalConfig = _objectSpread(_objectSpread({
|
|
131
140
|
ssr: true
|
|
132
141
|
}, config), {}, {
|
|
@@ -140,7 +149,8 @@ function WagmiProvider(_ref) {
|
|
|
140
149
|
if (isInitialized && web3Auth !== null && web3Auth !== void 0 && (_web3Auth$coreOptions = web3Auth.coreOptions) !== null && _web3Auth$coreOptions !== void 0 && _web3Auth$coreOptions.chains) {
|
|
141
150
|
var _web3Auth$currentChai;
|
|
142
151
|
const defaultChainId = (_web3Auth$currentChai = web3Auth.currentChain) === null || _web3Auth$currentChai === void 0 ? void 0 : _web3Auth$currentChai.chainId;
|
|
143
|
-
const chains = web3Auth.coreOptions.chains;
|
|
152
|
+
const chains = web3Auth.coreOptions.chains.filter(chain => chain.chainNamespace === noModal.CHAIN_NAMESPACES.EIP155);
|
|
153
|
+
if (chains.length === 0) throw noModal.WalletInitializationError.invalidParams("No valid chains found in web3auth config for wagmi.");
|
|
144
154
|
chains.forEach(chain => {
|
|
145
155
|
const wagmiChain = viem.defineChain({
|
|
146
156
|
id: Number.parseInt(chain.chainId, 16),
|
|
@@ -174,12 +184,8 @@ function WagmiProvider(_ref) {
|
|
|
174
184
|
});
|
|
175
185
|
finalConfig.chains = [wagmiChains[0], ...wagmiChains.slice(1)];
|
|
176
186
|
}
|
|
177
|
-
if (!finalConfig.chains) return;
|
|
178
187
|
return wagmi.createConfig(finalConfig);
|
|
179
188
|
}, [config, web3Auth, isInitialized]);
|
|
180
|
-
// WagmiProviderBase requires a config to initialize
|
|
181
|
-
// If no config is provided, it will throw an error.
|
|
182
|
-
if (!finalConfig) return null;
|
|
183
189
|
return /*#__PURE__*/react.createElement(wagmi.WagmiProvider, // typecast to WagmiProviderPropsBase to avoid type error
|
|
184
190
|
// as we are omitting the config prop from WagmiProviderProps
|
|
185
191
|
// and creating a new config object with the finalConfig
|