@web3auth/no-modal 10.4.0 → 10.5.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 +2 -0
- package/dist/lib.cjs/base/utils.js +1 -1
- package/dist/lib.cjs/connectors/auth-connector/authConnector.js +10 -2
- package/dist/lib.cjs/connectors/coinbase-connector/coinbaseConnector.js +10 -3
- package/dist/lib.cjs/connectors/injected-evm-connector/injectedEvmConnector.js +10 -3
- package/dist/lib.cjs/connectors/injected-solana-connector/walletStandardConnector.js +10 -3
- package/dist/lib.cjs/connectors/metamask-connector/metamaskConnector.js +11 -5
- package/dist/lib.cjs/connectors/wallet-connect-v2-connector/walletConnectV2Connector.js +22 -9
- package/dist/lib.cjs/noModal.js +8 -1
- package/dist/lib.cjs/plugins/wallet-services-plugin/plugin.js +37 -13
- package/dist/lib.cjs/react/hooks/useFunding.js +47 -0
- package/dist/lib.cjs/react/hooks/useReceive.js +47 -0
- package/dist/lib.cjs/react/index.js +4 -0
- package/dist/lib.cjs/types/base/analytics.d.ts +2 -0
- package/dist/lib.cjs/types/base/connector/interfaces.d.ts +2 -0
- package/dist/lib.cjs/types/connectors/auth-connector/authConnector.d.ts +2 -4
- package/dist/lib.cjs/types/connectors/injected-evm-connector/injectedEvmConnector.d.ts +2 -4
- package/dist/lib.cjs/types/connectors/injected-solana-connector/walletStandardConnector.d.ts +2 -4
- package/dist/lib.cjs/types/plugins/wallet-services-plugin/plugin.d.ts +2 -0
- package/dist/lib.cjs/types/react/hooks/index.d.ts +2 -0
- package/dist/lib.cjs/types/react/hooks/useFunding.d.ts +8 -0
- package/dist/lib.cjs/types/react/hooks/useReceive.d.ts +8 -0
- package/dist/lib.cjs/types/vue/composables/index.d.ts +2 -0
- package/dist/lib.cjs/types/vue/composables/useFunding.d.ts +9 -0
- package/dist/lib.cjs/types/vue/composables/useReceive.d.ts +9 -0
- package/dist/lib.cjs/vue/composables/useFunding.js +47 -0
- package/dist/lib.cjs/vue/composables/useReceive.js +47 -0
- package/dist/lib.cjs/vue/index.js +4 -0
- package/dist/lib.esm/base/analytics.js +2 -0
- package/dist/lib.esm/base/utils.js +1 -1
- package/dist/lib.esm/connectors/auth-connector/authConnector.js +10 -2
- package/dist/lib.esm/connectors/coinbase-connector/coinbaseConnector.js +10 -3
- package/dist/lib.esm/connectors/injected-evm-connector/injectedEvmConnector.js +10 -3
- package/dist/lib.esm/connectors/injected-solana-connector/walletStandardConnector.js +10 -3
- package/dist/lib.esm/connectors/metamask-connector/metamaskConnector.js +11 -5
- package/dist/lib.esm/connectors/wallet-connect-v2-connector/walletConnectV2Connector.js +22 -9
- package/dist/lib.esm/noModal.js +9 -1
- package/dist/lib.esm/plugins/wallet-services-plugin/plugin.js +39 -13
- package/dist/lib.esm/react/hooks/useFunding.js +32 -0
- package/dist/lib.esm/react/hooks/useReceive.js +32 -0
- package/dist/lib.esm/react/index.js +2 -0
- package/dist/lib.esm/vue/composables/useFunding.js +32 -0
- package/dist/lib.esm/vue/composables/useReceive.js +32 -0
- package/dist/lib.esm/vue/index.js +2 -0
- package/dist/noModal.umd.min.js +1 -1
- package/package.json +2 -2
|
@@ -113,7 +113,9 @@ const ANALYTICS_EVENTS = {
|
|
|
113
113
|
// Wallet Plugin
|
|
114
114
|
WALLET_UI_CLICKED: "Wallet UI Clicked",
|
|
115
115
|
WALLET_CONNECT_SCANNER_CLICKED: "Wallet Connect Scanner Clicked",
|
|
116
|
+
WALLET_FUNDING_CLICKED: "Wallet Funding Clicked",
|
|
116
117
|
WALLET_CHECKOUT_CLICKED: "Wallet Checkout Clicked",
|
|
118
|
+
WALLET_RECEIVE_CLICKED: "Wallet Receive Clicked",
|
|
117
119
|
WALLET_SWAP_CLICKED: "Wallet Swap Clicked"
|
|
118
120
|
};
|
|
119
121
|
const ANALYTICS_INTEGRATION_TYPE = {
|
|
@@ -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.
|
|
148
|
+
const sdkVersion = "10.5.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;
|
|
@@ -145,7 +145,8 @@ class AuthConnector extends baseConnector.BaseConnector {
|
|
|
145
145
|
if (sessionId && (options.autoConnect || isRedirectResult)) {
|
|
146
146
|
this.rehydrated = true;
|
|
147
147
|
await this.connect({
|
|
148
|
-
chainId: options.chainId
|
|
148
|
+
chainId: options.chainId,
|
|
149
|
+
getIdentityToken: false
|
|
149
150
|
});
|
|
150
151
|
} else if (!sessionId && options.autoConnect) {
|
|
151
152
|
// if here, this means that the connector is cached but the sessionId is not available.
|
|
@@ -363,11 +364,18 @@ class AuthConnector extends baseConnector.BaseConnector {
|
|
|
363
364
|
});
|
|
364
365
|
if (isLoggedIn) {
|
|
365
366
|
var _this$wsEmbedInstance3;
|
|
367
|
+
// if getIdentityToken is true, then get the identity token
|
|
368
|
+
// No need to get the identity token for auth connector as it is already handled
|
|
369
|
+
let identityTokenInfo;
|
|
370
|
+
if (params.getIdentityToken) {
|
|
371
|
+
identityTokenInfo = await this.getIdentityToken();
|
|
372
|
+
}
|
|
366
373
|
this.status = constants.CONNECTOR_STATUS.CONNECTED;
|
|
367
374
|
this.emit(constants.CONNECTOR_EVENTS.CONNECTED, {
|
|
368
375
|
connector: index.WALLET_CONNECTORS.AUTH,
|
|
369
376
|
reconnected: this.rehydrated,
|
|
370
|
-
provider: this.provider
|
|
377
|
+
provider: this.provider,
|
|
378
|
+
identityTokenInfo
|
|
371
379
|
});
|
|
372
380
|
// handle disconnect from ws embed
|
|
373
381
|
(_this$wsEmbedInstance3 = this.wsEmbedInstance) === null || _this$wsEmbedInstance3 === void 0 || _this$wsEmbedInstance3.provider.on("accountsChanged", (accounts = []) => {
|
|
@@ -64,7 +64,8 @@ class CoinbaseConnector extends baseEvmConnector.BaseEvmConnector {
|
|
|
64
64
|
if (options.autoConnect) {
|
|
65
65
|
this.rehydrated = true;
|
|
66
66
|
const provider = await this.connect({
|
|
67
|
-
chainId: options.chainId
|
|
67
|
+
chainId: options.chainId,
|
|
68
|
+
getIdentityToken: false
|
|
68
69
|
});
|
|
69
70
|
// the connect function could fail silently as well.
|
|
70
71
|
if (!provider) {
|
|
@@ -77,7 +78,8 @@ class CoinbaseConnector extends baseEvmConnector.BaseEvmConnector {
|
|
|
77
78
|
}
|
|
78
79
|
}
|
|
79
80
|
async connect({
|
|
80
|
-
chainId
|
|
81
|
+
chainId,
|
|
82
|
+
getIdentityToken
|
|
81
83
|
}) {
|
|
82
84
|
super.checkConnectionRequirements();
|
|
83
85
|
if (!this.coinbaseProvider) throw index$1.WalletLoginError.notConnectedError("Connector is not initialized");
|
|
@@ -103,10 +105,15 @@ class CoinbaseConnector extends baseEvmConnector.BaseEvmConnector {
|
|
|
103
105
|
// ready to be connected again
|
|
104
106
|
this.disconnect();
|
|
105
107
|
});
|
|
108
|
+
let identityTokenInfo;
|
|
109
|
+
if (getIdentityToken) {
|
|
110
|
+
identityTokenInfo = await this.getIdentityToken();
|
|
111
|
+
}
|
|
106
112
|
this.emit(constants.CONNECTOR_EVENTS.CONNECTED, {
|
|
107
113
|
connector: index.WALLET_CONNECTORS.COINBASE,
|
|
108
114
|
reconnected: this.rehydrated,
|
|
109
|
-
provider: this.provider
|
|
115
|
+
provider: this.provider,
|
|
116
|
+
identityTokenInfo
|
|
110
117
|
});
|
|
111
118
|
return this.provider;
|
|
112
119
|
} catch (error) {
|
|
@@ -52,7 +52,8 @@ class InjectedEvmConnector extends baseEvmConnector.BaseEvmConnector {
|
|
|
52
52
|
if (options.autoConnect) {
|
|
53
53
|
this.rehydrated = true;
|
|
54
54
|
const provider = await this.connect({
|
|
55
|
-
chainId: options.chainId
|
|
55
|
+
chainId: options.chainId,
|
|
56
|
+
getIdentityToken: false
|
|
56
57
|
});
|
|
57
58
|
if (!provider) {
|
|
58
59
|
this.rehydrated = false;
|
|
@@ -64,7 +65,8 @@ class InjectedEvmConnector extends baseEvmConnector.BaseEvmConnector {
|
|
|
64
65
|
}
|
|
65
66
|
}
|
|
66
67
|
async connect({
|
|
67
|
-
chainId
|
|
68
|
+
chainId,
|
|
69
|
+
getIdentityToken
|
|
68
70
|
}) {
|
|
69
71
|
super.checkConnectionRequirements();
|
|
70
72
|
if (!this.injectedProvider) throw index.WalletLoginError.connectionError("Injected provider is not available");
|
|
@@ -96,10 +98,15 @@ class InjectedEvmConnector extends baseEvmConnector.BaseEvmConnector {
|
|
|
96
98
|
}
|
|
97
99
|
};
|
|
98
100
|
this.injectedProvider.on("accountsChanged", accountDisconnectHandler);
|
|
101
|
+
let identityTokenInfo;
|
|
102
|
+
if (getIdentityToken) {
|
|
103
|
+
identityTokenInfo = await this.getIdentityToken();
|
|
104
|
+
}
|
|
99
105
|
this.emit(constants.CONNECTOR_EVENTS.CONNECTED, {
|
|
100
106
|
connector: this.name,
|
|
101
107
|
reconnected: this.rehydrated,
|
|
102
|
-
provider: this.injectedProvider
|
|
108
|
+
provider: this.injectedProvider,
|
|
109
|
+
identityTokenInfo
|
|
103
110
|
});
|
|
104
111
|
return this.injectedProvider;
|
|
105
112
|
} catch (error) {
|
|
@@ -68,7 +68,8 @@ class WalletStandardConnector extends baseSolanaConnector.BaseSolanaConnector {
|
|
|
68
68
|
if (options.autoConnect) {
|
|
69
69
|
this.rehydrated = true;
|
|
70
70
|
const provider = await this.connect({
|
|
71
|
-
chainId: options.chainId
|
|
71
|
+
chainId: options.chainId,
|
|
72
|
+
getIdentityToken: false
|
|
72
73
|
});
|
|
73
74
|
if (!provider) {
|
|
74
75
|
this.rehydrated = false;
|
|
@@ -80,7 +81,8 @@ class WalletStandardConnector extends baseSolanaConnector.BaseSolanaConnector {
|
|
|
80
81
|
}
|
|
81
82
|
}
|
|
82
83
|
async connect({
|
|
83
|
-
chainId
|
|
84
|
+
chainId,
|
|
85
|
+
getIdentityToken
|
|
84
86
|
}) {
|
|
85
87
|
try {
|
|
86
88
|
super.checkConnectionRequirements();
|
|
@@ -97,10 +99,15 @@ class WalletStandardConnector extends baseSolanaConnector.BaseSolanaConnector {
|
|
|
97
99
|
}
|
|
98
100
|
if (this.wallet.accounts.length === 0) throw index.WalletLoginError.connectionError();
|
|
99
101
|
this.status = constants.CONNECTOR_STATUS.CONNECTED;
|
|
102
|
+
let identityTokenInfo;
|
|
103
|
+
if (getIdentityToken) {
|
|
104
|
+
identityTokenInfo = await this.getIdentityToken();
|
|
105
|
+
}
|
|
100
106
|
this.emit(constants.CONNECTOR_EVENTS.CONNECTED, {
|
|
101
107
|
connector: this.name,
|
|
102
108
|
reconnected: this.rehydrated,
|
|
103
|
-
provider: this.provider
|
|
109
|
+
provider: this.provider,
|
|
110
|
+
identityTokenInfo
|
|
104
111
|
});
|
|
105
112
|
return this.provider;
|
|
106
113
|
} catch (error) {
|
|
@@ -44,7 +44,6 @@ class MetaMaskConnector extends baseEvmConnector.BaseEvmConnector {
|
|
|
44
44
|
throw new Error("Not implemented");
|
|
45
45
|
}
|
|
46
46
|
async init(options) {
|
|
47
|
-
var _metamaskOptions$useD;
|
|
48
47
|
await super.init(options);
|
|
49
48
|
const chainConfig = this.coreOptions.chains.find(x => x.chainId === options.chainId);
|
|
50
49
|
super.checkInitializationRequirements({
|
|
@@ -64,7 +63,7 @@ class MetaMaskConnector extends baseEvmConnector.BaseEvmConnector {
|
|
|
64
63
|
});
|
|
65
64
|
this.metamaskSDK = new sdk.MetaMaskSDK(_objectSpread(_objectSpread({}, metamaskOptions), {}, {
|
|
66
65
|
_source: "web3auth",
|
|
67
|
-
|
|
66
|
+
preferDesktop: true
|
|
68
67
|
}));
|
|
69
68
|
// Work around: in case there is an existing SDK instance in memory (window.mmsdk exists), it won't initialize the new SDK instance again
|
|
70
69
|
// and return the existing instance instead of undefined (this is an assumption, not sure if it's a bug or feature of the MetaMask SDK)
|
|
@@ -79,7 +78,8 @@ class MetaMaskConnector extends baseEvmConnector.BaseEvmConnector {
|
|
|
79
78
|
if (options.autoConnect) {
|
|
80
79
|
this.rehydrated = true;
|
|
81
80
|
const provider = await this.connect({
|
|
82
|
-
chainId: options.chainId
|
|
81
|
+
chainId: options.chainId,
|
|
82
|
+
getIdentityToken: false
|
|
83
83
|
});
|
|
84
84
|
if (!provider) {
|
|
85
85
|
this.rehydrated = false;
|
|
@@ -91,7 +91,8 @@ class MetaMaskConnector extends baseEvmConnector.BaseEvmConnector {
|
|
|
91
91
|
}
|
|
92
92
|
}
|
|
93
93
|
async connect({
|
|
94
|
-
chainId
|
|
94
|
+
chainId,
|
|
95
|
+
getIdentityToken
|
|
95
96
|
}) {
|
|
96
97
|
super.checkConnectionRequirements();
|
|
97
98
|
if (!this.metamaskSDK) throw index$1.WalletLoginError.notConnectedError("Connector is not initialized");
|
|
@@ -153,10 +154,15 @@ class MetaMaskConnector extends baseEvmConnector.BaseEvmConnector {
|
|
|
153
154
|
duration: Date.now() - startTime
|
|
154
155
|
}));
|
|
155
156
|
}
|
|
157
|
+
let identityTokenInfo;
|
|
158
|
+
if (getIdentityToken) {
|
|
159
|
+
identityTokenInfo = await this.getIdentityToken();
|
|
160
|
+
}
|
|
156
161
|
this.emit(constants.CONNECTOR_EVENTS.CONNECTED, {
|
|
157
162
|
connector: index.WALLET_CONNECTORS.METAMASK,
|
|
158
163
|
reconnected: this.rehydrated,
|
|
159
|
-
provider: this.metamaskProvider
|
|
164
|
+
provider: this.metamaskProvider,
|
|
165
|
+
identityTokenInfo
|
|
160
166
|
});
|
|
161
167
|
return this.metamaskProvider;
|
|
162
168
|
} catch (error) {
|
|
@@ -104,7 +104,8 @@ class WalletConnectV2Connector extends baseConnector.BaseConnector {
|
|
|
104
104
|
this.rehydrated = true;
|
|
105
105
|
try {
|
|
106
106
|
await this.onConnectHandler({
|
|
107
|
-
chain: chainConfig
|
|
107
|
+
chain: chainConfig,
|
|
108
|
+
getIdentityToken: false
|
|
108
109
|
});
|
|
109
110
|
} catch (error) {
|
|
110
111
|
loglevel.log.error("wallet auto connect", error);
|
|
@@ -117,7 +118,8 @@ class WalletConnectV2Connector extends baseConnector.BaseConnector {
|
|
|
117
118
|
}
|
|
118
119
|
}
|
|
119
120
|
async connect({
|
|
120
|
-
chainId
|
|
121
|
+
chainId,
|
|
122
|
+
getIdentityToken
|
|
121
123
|
}) {
|
|
122
124
|
super.checkConnectionRequirements();
|
|
123
125
|
const chainConfig = this.coreOptions.chains.find(x => x.chainId === chainId);
|
|
@@ -167,14 +169,16 @@ class WalletConnectV2Connector extends baseConnector.BaseConnector {
|
|
|
167
169
|
// if already connected
|
|
168
170
|
if (this.connected) {
|
|
169
171
|
await this.onConnectHandler({
|
|
170
|
-
chain: chainConfig
|
|
172
|
+
chain: chainConfig,
|
|
173
|
+
getIdentityToken: false
|
|
171
174
|
});
|
|
172
175
|
return this.provider;
|
|
173
176
|
}
|
|
174
177
|
if (this.status !== constants.CONNECTOR_STATUS.CONNECTING) {
|
|
175
178
|
await this.createNewSession({
|
|
176
179
|
chainConfig,
|
|
177
|
-
trackCompletionEvents
|
|
180
|
+
trackCompletionEvents,
|
|
181
|
+
getIdentityToken
|
|
178
182
|
});
|
|
179
183
|
}
|
|
180
184
|
return this.provider;
|
|
@@ -308,7 +312,8 @@ class WalletConnectV2Connector extends baseConnector.BaseConnector {
|
|
|
308
312
|
async createNewSession({
|
|
309
313
|
forceNewSession = false,
|
|
310
314
|
chainConfig,
|
|
311
|
-
trackCompletionEvents
|
|
315
|
+
trackCompletionEvents,
|
|
316
|
+
getIdentityToken
|
|
312
317
|
}) {
|
|
313
318
|
try {
|
|
314
319
|
var _this$activeSession4, _this$connectorOption7;
|
|
@@ -356,7 +361,8 @@ class WalletConnectV2Connector extends baseConnector.BaseConnector {
|
|
|
356
361
|
// Handle the returned session (e.g. update UI to "connected" state).
|
|
357
362
|
await this.onConnectHandler({
|
|
358
363
|
chain: chainConfig,
|
|
359
|
-
trackCompletionEvents
|
|
364
|
+
trackCompletionEvents,
|
|
365
|
+
getIdentityToken
|
|
360
366
|
});
|
|
361
367
|
if (qrcodeModal) {
|
|
362
368
|
qrcodeModal.closeModal();
|
|
@@ -370,7 +376,8 @@ class WalletConnectV2Connector extends baseConnector.BaseConnector {
|
|
|
370
376
|
loglevel.log.info("retrying to create new wallet connect session since proposal expired");
|
|
371
377
|
return this.createNewSession({
|
|
372
378
|
forceNewSession: true,
|
|
373
|
-
chainConfig
|
|
379
|
+
chainConfig,
|
|
380
|
+
getIdentityToken
|
|
374
381
|
});
|
|
375
382
|
}
|
|
376
383
|
if (this.status === constants.CONNECTOR_STATUS.READY) {
|
|
@@ -385,7 +392,8 @@ class WalletConnectV2Connector extends baseConnector.BaseConnector {
|
|
|
385
392
|
}
|
|
386
393
|
async onConnectHandler({
|
|
387
394
|
chain,
|
|
388
|
-
trackCompletionEvents
|
|
395
|
+
trackCompletionEvents,
|
|
396
|
+
getIdentityToken
|
|
389
397
|
}) {
|
|
390
398
|
var _this$connectorOption8;
|
|
391
399
|
if (!this.connector || !this.wcProvider) throw index$1.WalletInitializationError.notReady("Wallet connect connector is not ready yet");
|
|
@@ -405,10 +413,15 @@ class WalletConnectV2Connector extends baseConnector.BaseConnector {
|
|
|
405
413
|
this.status = constants.CONNECTOR_STATUS.CONNECTED;
|
|
406
414
|
// track connection events
|
|
407
415
|
if (trackCompletionEvents) trackCompletionEvents();
|
|
416
|
+
let identityTokenInfo;
|
|
417
|
+
if (getIdentityToken) {
|
|
418
|
+
identityTokenInfo = await this.getIdentityToken();
|
|
419
|
+
}
|
|
408
420
|
this.emit(constants.CONNECTOR_EVENTS.CONNECTED, {
|
|
409
421
|
connector: index.WALLET_CONNECTORS.WALLET_CONNECT_V2,
|
|
410
422
|
reconnected: this.rehydrated,
|
|
411
|
-
provider: this.provider
|
|
423
|
+
provider: this.provider,
|
|
424
|
+
identityTokenInfo
|
|
412
425
|
});
|
|
413
426
|
}
|
|
414
427
|
subscribeEvents() {
|
package/dist/lib.cjs/noModal.js
CHANGED
|
@@ -592,6 +592,13 @@ class Web3AuthNoModal extends auth.SafeEventEmitter {
|
|
|
592
592
|
const isExternalWalletEnabled = Boolean(projectConfig.externalWalletAuth);
|
|
593
593
|
const isMipdEnabled = isExternalWalletEnabled && ((_this$coreOptions$mul = this.coreOptions.multiInjectedProviderDiscovery) !== null && _this$coreOptions$mul !== void 0 ? _this$coreOptions$mul : true);
|
|
594
594
|
const chainNamespaces = new Set(this.coreOptions.chains.map(chain => chain.chainNamespace));
|
|
595
|
+
// it's safe to add it here as if there is a MetaMask injected provider, this won't override it
|
|
596
|
+
// only set headless to true if modal SDK is used, otherwise just use the modal from native Metamask SDK
|
|
597
|
+
if (utils.isBrowser() && chainNamespaces.has(baseControllers.CHAIN_NAMESPACES.EIP155) && !chainNamespaces.has(baseControllers.CHAIN_NAMESPACES.SOLANA)) {
|
|
598
|
+
connectorFns.push(metamaskConnector.metaMaskConnector(modalMode ? {
|
|
599
|
+
headless: true
|
|
600
|
+
} : undefined));
|
|
601
|
+
}
|
|
595
602
|
if (isMipdEnabled && utils.isBrowser()) {
|
|
596
603
|
// Solana chains
|
|
597
604
|
if (chainNamespaces.has(baseControllers.CHAIN_NAMESPACES.SOLANA)) {
|
|
@@ -625,7 +632,7 @@ class Web3AuthNoModal extends auth.SafeEventEmitter {
|
|
|
625
632
|
}
|
|
626
633
|
// it's safe to add it here as if there is a MetaMask injected provider, this won't override it
|
|
627
634
|
// only set headless to true if modal SDK is used, otherwise just use the modal from native Metamask SDK
|
|
628
|
-
if (utils.isBrowser() && (chainNamespaces.has(baseControllers.CHAIN_NAMESPACES.
|
|
635
|
+
if (utils.isBrowser() && (chainNamespaces.has(baseControllers.CHAIN_NAMESPACES.SOLANA) || chainNamespaces.has(baseControllers.CHAIN_NAMESPACES.EIP155))) {
|
|
629
636
|
connectorFns.push(metamaskConnector.metaMaskConnector(modalMode ? {
|
|
630
637
|
headless: true
|
|
631
638
|
} : undefined));
|
|
@@ -92,33 +92,57 @@ class WalletServicesPlugin extends auth.SafeEventEmitter {
|
|
|
92
92
|
});
|
|
93
93
|
return this.wsEmbedInstance.showWalletConnectScanner(showWalletConnectParams);
|
|
94
94
|
}
|
|
95
|
-
async
|
|
95
|
+
async showFunding(showFundingParams) {
|
|
96
96
|
var _this$wsEmbedInstance3, _this$analytics2;
|
|
97
97
|
if (!((_this$wsEmbedInstance3 = this.wsEmbedInstance) !== null && _this$wsEmbedInstance3 !== void 0 && _this$wsEmbedInstance3.isLoggedIn)) throw errors.WalletServicesPluginError.walletPluginNotConnected();
|
|
98
98
|
// analytics
|
|
99
|
-
(_this$analytics2 = this.analytics) === null || _this$analytics2 === void 0 || _this$analytics2.track(analytics.ANALYTICS_EVENTS.
|
|
99
|
+
(_this$analytics2 = this.analytics) === null || _this$analytics2 === void 0 || _this$analytics2.track(analytics.ANALYTICS_EVENTS.WALLET_FUNDING_CLICKED, {
|
|
100
|
+
is_visible: showFundingParams === null || showFundingParams === void 0 ? void 0 : showFundingParams.show
|
|
101
|
+
});
|
|
102
|
+
return this.wsEmbedInstance.showFunding(showFundingParams);
|
|
103
|
+
}
|
|
104
|
+
async showCheckout(showCheckoutParams) {
|
|
105
|
+
var _this$wsEmbedInstance4, _this$analytics3;
|
|
106
|
+
if (!((_this$wsEmbedInstance4 = this.wsEmbedInstance) !== null && _this$wsEmbedInstance4 !== void 0 && _this$wsEmbedInstance4.isLoggedIn)) throw errors.WalletServicesPluginError.walletPluginNotConnected();
|
|
107
|
+
// analytics
|
|
108
|
+
(_this$analytics3 = this.analytics) === null || _this$analytics3 === void 0 || _this$analytics3.track(analytics.ANALYTICS_EVENTS.WALLET_CHECKOUT_CLICKED, {
|
|
100
109
|
is_visible: showCheckoutParams === null || showCheckoutParams === void 0 ? void 0 : showCheckoutParams.show,
|
|
101
110
|
receive_wallet_address_enabled: !!(showCheckoutParams !== null && showCheckoutParams !== void 0 && showCheckoutParams.receiveWalletAddress),
|
|
111
|
+
// TODO: where is the below?
|
|
112
|
+
// receive_wallet_address: showCheckoutParams?.receiveWalletAddress,
|
|
102
113
|
token_list: showCheckoutParams === null || showCheckoutParams === void 0 ? void 0 : showCheckoutParams.tokenList,
|
|
103
|
-
fiat_list: showCheckoutParams === null || showCheckoutParams === void 0 ? void 0 : showCheckoutParams.fiatList
|
|
114
|
+
fiat_list: showCheckoutParams === null || showCheckoutParams === void 0 ? void 0 : showCheckoutParams.fiatList,
|
|
115
|
+
crypto: showCheckoutParams === null || showCheckoutParams === void 0 ? void 0 : showCheckoutParams.crypto,
|
|
116
|
+
fiat: showCheckoutParams === null || showCheckoutParams === void 0 ? void 0 : showCheckoutParams.fiat,
|
|
117
|
+
fiat_amount: showCheckoutParams === null || showCheckoutParams === void 0 ? void 0 : showCheckoutParams.fiatAmount,
|
|
118
|
+
crypto_amount: showCheckoutParams === null || showCheckoutParams === void 0 ? void 0 : showCheckoutParams.cryptoAmount
|
|
104
119
|
});
|
|
105
120
|
return this.wsEmbedInstance.showCheckout(showCheckoutParams);
|
|
106
121
|
}
|
|
122
|
+
async showReceive(showReceiveParams) {
|
|
123
|
+
var _this$wsEmbedInstance5, _this$analytics4;
|
|
124
|
+
if (!((_this$wsEmbedInstance5 = this.wsEmbedInstance) !== null && _this$wsEmbedInstance5 !== void 0 && _this$wsEmbedInstance5.isLoggedIn)) throw errors.WalletServicesPluginError.walletPluginNotConnected();
|
|
125
|
+
// analytics
|
|
126
|
+
(_this$analytics4 = this.analytics) === null || _this$analytics4 === void 0 || _this$analytics4.track(analytics.ANALYTICS_EVENTS.WALLET_RECEIVE_CLICKED, {
|
|
127
|
+
is_visible: showReceiveParams === null || showReceiveParams === void 0 ? void 0 : showReceiveParams.show
|
|
128
|
+
});
|
|
129
|
+
return this.wsEmbedInstance.showReceive(showReceiveParams);
|
|
130
|
+
}
|
|
107
131
|
async showWalletUi(showWalletUiParams) {
|
|
108
|
-
var _this$
|
|
109
|
-
if (!((_this$
|
|
132
|
+
var _this$wsEmbedInstance6, _this$analytics5;
|
|
133
|
+
if (!((_this$wsEmbedInstance6 = this.wsEmbedInstance) !== null && _this$wsEmbedInstance6 !== void 0 && _this$wsEmbedInstance6.isLoggedIn)) throw errors.WalletServicesPluginError.walletPluginNotConnected();
|
|
110
134
|
// analytics
|
|
111
|
-
(_this$
|
|
135
|
+
(_this$analytics5 = this.analytics) === null || _this$analytics5 === void 0 || _this$analytics5.track(analytics.ANALYTICS_EVENTS.WALLET_UI_CLICKED, {
|
|
112
136
|
is_visible: showWalletUiParams === null || showWalletUiParams === void 0 ? void 0 : showWalletUiParams.show,
|
|
113
137
|
path: showWalletUiParams === null || showWalletUiParams === void 0 ? void 0 : showWalletUiParams.path
|
|
114
138
|
});
|
|
115
139
|
return this.wsEmbedInstance.showWalletUi(showWalletUiParams);
|
|
116
140
|
}
|
|
117
141
|
async showSwap(showSwapParams) {
|
|
118
|
-
var _this$
|
|
119
|
-
if (!((_this$
|
|
142
|
+
var _this$wsEmbedInstance7, _this$analytics6;
|
|
143
|
+
if (!((_this$wsEmbedInstance7 = this.wsEmbedInstance) !== null && _this$wsEmbedInstance7 !== void 0 && _this$wsEmbedInstance7.isLoggedIn)) throw errors.WalletServicesPluginError.walletPluginNotConnected();
|
|
120
144
|
// analytics
|
|
121
|
-
(_this$
|
|
145
|
+
(_this$analytics6 = this.analytics) === null || _this$analytics6 === void 0 || _this$analytics6.track(analytics.ANALYTICS_EVENTS.WALLET_SWAP_CLICKED, {
|
|
122
146
|
is_visible: showSwapParams === null || showSwapParams === void 0 ? void 0 : showSwapParams.show,
|
|
123
147
|
from_token: showSwapParams === null || showSwapParams === void 0 ? void 0 : showSwapParams.fromToken,
|
|
124
148
|
to_token: showSwapParams === null || showSwapParams === void 0 ? void 0 : showSwapParams.toToken,
|
|
@@ -128,13 +152,13 @@ class WalletServicesPlugin extends auth.SafeEventEmitter {
|
|
|
128
152
|
return this.wsEmbedInstance.showSwap(showSwapParams);
|
|
129
153
|
}
|
|
130
154
|
async cleanup() {
|
|
131
|
-
var _this$
|
|
132
|
-
return (_this$
|
|
155
|
+
var _this$wsEmbedInstance8;
|
|
156
|
+
return (_this$wsEmbedInstance8 = this.wsEmbedInstance) === null || _this$wsEmbedInstance8 === void 0 ? void 0 : _this$wsEmbedInstance8.cleanUp();
|
|
133
157
|
}
|
|
134
158
|
async disconnect() {
|
|
135
|
-
var _this$
|
|
159
|
+
var _this$wsEmbedInstance9;
|
|
136
160
|
if (this.status !== IPlugin.PLUGIN_STATUS.CONNECTED) throw errors.WalletServicesPluginError.invalidSession("Wallet Services plugin is not connected");
|
|
137
|
-
if ((_this$
|
|
161
|
+
if ((_this$wsEmbedInstance9 = this.wsEmbedInstance) !== null && _this$wsEmbedInstance9 !== void 0 && _this$wsEmbedInstance9.isLoggedIn) {
|
|
138
162
|
await this.wsEmbedInstance.logout();
|
|
139
163
|
}
|
|
140
164
|
this.emit(IPlugin.PLUGIN_EVENTS.DISCONNECTED);
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var react = require('react');
|
|
4
|
+
require('@babel/runtime/helpers/objectSpread2');
|
|
5
|
+
require('@babel/runtime/helpers/defineProperty');
|
|
6
|
+
require('@segment/analytics-next');
|
|
7
|
+
require('../../base/loglevel.js');
|
|
8
|
+
require('@toruslabs/base-controllers');
|
|
9
|
+
require('@web3auth/auth');
|
|
10
|
+
require('../../base/errors/index.js');
|
|
11
|
+
require('../../base/wallet/index.js');
|
|
12
|
+
require('../../base/connector/constants.js');
|
|
13
|
+
require('jwt-decode');
|
|
14
|
+
var errors = require('../../base/plugin/errors.js');
|
|
15
|
+
require('../../base/plugin/IPlugin.js');
|
|
16
|
+
require('@toruslabs/constants');
|
|
17
|
+
require('@toruslabs/http-helpers');
|
|
18
|
+
var useWalletServicesPlugin = require('./useWalletServicesPlugin.js');
|
|
19
|
+
|
|
20
|
+
const useFunding = () => {
|
|
21
|
+
const {
|
|
22
|
+
plugin,
|
|
23
|
+
ready
|
|
24
|
+
} = useWalletServicesPlugin.useWalletServicesPlugin();
|
|
25
|
+
const [loading, setLoading] = react.useState(false);
|
|
26
|
+
const [error, setError] = react.useState(null);
|
|
27
|
+
const showFunding = react.useCallback(async showFundingParams => {
|
|
28
|
+
setLoading(true);
|
|
29
|
+
setError(null);
|
|
30
|
+
try {
|
|
31
|
+
if (!plugin) throw errors.WalletServicesPluginError.notInitialized();
|
|
32
|
+
if (!ready) throw errors.WalletServicesPluginError.walletPluginNotConnected();
|
|
33
|
+
await plugin.showFunding(showFundingParams);
|
|
34
|
+
} catch (error) {
|
|
35
|
+
setError(error);
|
|
36
|
+
} finally {
|
|
37
|
+
setLoading(false);
|
|
38
|
+
}
|
|
39
|
+
}, [plugin, ready]);
|
|
40
|
+
return {
|
|
41
|
+
loading,
|
|
42
|
+
error,
|
|
43
|
+
showFunding
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
exports.useFunding = useFunding;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var react = require('react');
|
|
4
|
+
require('@babel/runtime/helpers/objectSpread2');
|
|
5
|
+
require('@babel/runtime/helpers/defineProperty');
|
|
6
|
+
require('@segment/analytics-next');
|
|
7
|
+
require('../../base/loglevel.js');
|
|
8
|
+
require('@toruslabs/base-controllers');
|
|
9
|
+
require('@web3auth/auth');
|
|
10
|
+
require('../../base/errors/index.js');
|
|
11
|
+
require('../../base/wallet/index.js');
|
|
12
|
+
require('../../base/connector/constants.js');
|
|
13
|
+
require('jwt-decode');
|
|
14
|
+
var errors = require('../../base/plugin/errors.js');
|
|
15
|
+
require('../../base/plugin/IPlugin.js');
|
|
16
|
+
require('@toruslabs/constants');
|
|
17
|
+
require('@toruslabs/http-helpers');
|
|
18
|
+
var useWalletServicesPlugin = require('./useWalletServicesPlugin.js');
|
|
19
|
+
|
|
20
|
+
const useReceive = () => {
|
|
21
|
+
const {
|
|
22
|
+
plugin,
|
|
23
|
+
ready
|
|
24
|
+
} = useWalletServicesPlugin.useWalletServicesPlugin();
|
|
25
|
+
const [loading, setLoading] = react.useState(false);
|
|
26
|
+
const [error, setError] = react.useState(null);
|
|
27
|
+
const showReceive = react.useCallback(async showReceiveParams => {
|
|
28
|
+
setLoading(true);
|
|
29
|
+
setError(null);
|
|
30
|
+
try {
|
|
31
|
+
if (!plugin) throw errors.WalletServicesPluginError.notInitialized();
|
|
32
|
+
if (!ready) throw errors.WalletServicesPluginError.walletPluginNotConnected();
|
|
33
|
+
await plugin.showReceive(showReceiveParams);
|
|
34
|
+
} catch (error) {
|
|
35
|
+
setError(error);
|
|
36
|
+
} finally {
|
|
37
|
+
setLoading(false);
|
|
38
|
+
}
|
|
39
|
+
}, [plugin, ready]);
|
|
40
|
+
return {
|
|
41
|
+
loading,
|
|
42
|
+
error,
|
|
43
|
+
showReceive
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
exports.useReceive = useReceive;
|
|
@@ -2,8 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
var useCheckout = require('./hooks/useCheckout.js');
|
|
4
4
|
var useEnableMFA = require('./hooks/useEnableMFA.js');
|
|
5
|
+
var useFunding = require('./hooks/useFunding.js');
|
|
5
6
|
var useIdentityToken = require('./hooks/useIdentityToken.js');
|
|
6
7
|
var useManageMFA = require('./hooks/useManageMFA.js');
|
|
8
|
+
var useReceive = require('./hooks/useReceive.js');
|
|
7
9
|
var useSwap = require('./hooks/useSwap.js');
|
|
8
10
|
var useSwitchChain = require('./hooks/useSwitchChain.js');
|
|
9
11
|
var useWalletConnectScanner = require('./hooks/useWalletConnectScanner.js');
|
|
@@ -19,8 +21,10 @@ var Web3AuthProvider = require('./Web3AuthProvider.js');
|
|
|
19
21
|
|
|
20
22
|
exports.useCheckout = useCheckout.useCheckout;
|
|
21
23
|
exports.useEnableMFA = useEnableMFA.useEnableMFA;
|
|
24
|
+
exports.useFunding = useFunding.useFunding;
|
|
22
25
|
exports.useIdentityToken = useIdentityToken.useIdentityToken;
|
|
23
26
|
exports.useManageMFA = useManageMFA.useManageMFA;
|
|
27
|
+
exports.useReceive = useReceive.useReceive;
|
|
24
28
|
exports.useSwap = useSwap.useSwap;
|
|
25
29
|
exports.useSwitchChain = useSwitchChain.useSwitchChain;
|
|
26
30
|
exports.useWalletConnectScanner = useWalletConnectScanner.useWalletConnectScanner;
|
|
@@ -33,7 +33,9 @@ export declare const ANALYTICS_EVENTS: {
|
|
|
33
33
|
EXTERNAL_WALLET_LIST_EXPANDED: string;
|
|
34
34
|
WALLET_UI_CLICKED: string;
|
|
35
35
|
WALLET_CONNECT_SCANNER_CLICKED: string;
|
|
36
|
+
WALLET_FUNDING_CLICKED: string;
|
|
36
37
|
WALLET_CHECKOUT_CLICKED: string;
|
|
38
|
+
WALLET_RECEIVE_CLICKED: string;
|
|
37
39
|
WALLET_SWAP_CLICKED: string;
|
|
38
40
|
};
|
|
39
41
|
export declare const ANALYTICS_INTEGRATION_TYPE: {
|
|
@@ -78,12 +78,14 @@ export type ConnectorParams = {
|
|
|
78
78
|
};
|
|
79
79
|
export type BaseConnectorLoginParams = {
|
|
80
80
|
chainId: string;
|
|
81
|
+
getIdentityToken: boolean;
|
|
81
82
|
};
|
|
82
83
|
export type ConnectorFn = (params: ConnectorParams) => IConnector<unknown>;
|
|
83
84
|
export type CONNECTED_EVENT_DATA = {
|
|
84
85
|
connector: WALLET_CONNECTOR_TYPE;
|
|
85
86
|
provider: IProvider;
|
|
86
87
|
reconnected: boolean;
|
|
88
|
+
identityTokenInfo: IdentityTokenInfo;
|
|
87
89
|
};
|
|
88
90
|
export interface IConnectorDataEvent {
|
|
89
91
|
connectorName: string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Auth, AuthConnectionConfigItem } from "@web3auth/auth";
|
|
2
2
|
import { type default as WsEmbed } from "@web3auth/ws-embed";
|
|
3
|
-
import { AuthLoginParams, BaseConnector, CONNECTOR_CATEGORY_TYPE, CONNECTOR_STATUS_TYPE, ConnectorFn, ConnectorInitOptions, ConnectorNamespaceType, IProvider, UserInfo, WALLET_CONNECTOR_TYPE } from "../../base";
|
|
3
|
+
import { AuthLoginParams, BaseConnector, BaseConnectorLoginParams, CONNECTOR_CATEGORY_TYPE, CONNECTOR_STATUS_TYPE, ConnectorFn, ConnectorInitOptions, ConnectorNamespaceType, IProvider, UserInfo, WALLET_CONNECTOR_TYPE } from "../../base";
|
|
4
4
|
import type { AuthConnectorOptions, PrivateKeyProvider } from "./interface";
|
|
5
5
|
declare class AuthConnector extends BaseConnector<AuthLoginParams> {
|
|
6
6
|
readonly name: WALLET_CONNECTOR_TYPE;
|
|
@@ -20,9 +20,7 @@ declare class AuthConnector extends BaseConnector<AuthLoginParams> {
|
|
|
20
20
|
get wsEmbed(): WsEmbed;
|
|
21
21
|
set provider(_: IProvider | null);
|
|
22
22
|
init(options: ConnectorInitOptions): Promise<void>;
|
|
23
|
-
connect(params: Partial<AuthLoginParams> &
|
|
24
|
-
chainId: string;
|
|
25
|
-
}): Promise<IProvider | null>;
|
|
23
|
+
connect(params: Partial<AuthLoginParams> & BaseConnectorLoginParams): Promise<IProvider | null>;
|
|
26
24
|
enableMFA(params?: AuthLoginParams): Promise<void>;
|
|
27
25
|
manageMFA(params?: AuthLoginParams): Promise<void>;
|
|
28
26
|
disconnect(options?: {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type EIP6963ProviderDetail } from "mipd";
|
|
2
|
-
import { BaseConnectorSettings, ChainNamespaceType, CONNECTOR_CATEGORY_TYPE, CONNECTOR_STATUS_TYPE, ConnectorFn, ConnectorInitOptions, ConnectorNamespaceType, CustomChainConfig, IProvider, UserInfo } from "../../base";
|
|
2
|
+
import { BaseConnectorLoginParams, BaseConnectorSettings, ChainNamespaceType, CONNECTOR_CATEGORY_TYPE, CONNECTOR_STATUS_TYPE, ConnectorFn, ConnectorInitOptions, ConnectorNamespaceType, CustomChainConfig, IProvider, UserInfo } from "../../base";
|
|
3
3
|
import { BaseEvmConnector } from "../base-evm-connector";
|
|
4
4
|
declare class InjectedEvmConnector extends BaseEvmConnector<void> {
|
|
5
5
|
readonly connectorNamespace: ConnectorNamespaceType;
|
|
@@ -17,9 +17,7 @@ declare class InjectedEvmConnector extends BaseEvmConnector<void> {
|
|
|
17
17
|
get provider(): IProvider | null;
|
|
18
18
|
set provider(_: IProvider | null);
|
|
19
19
|
init(options: ConnectorInitOptions): Promise<void>;
|
|
20
|
-
connect({ chainId }:
|
|
21
|
-
chainId: string;
|
|
22
|
-
}): Promise<IProvider | null>;
|
|
20
|
+
connect({ chainId, getIdentityToken }: BaseConnectorLoginParams): Promise<IProvider | null>;
|
|
23
21
|
disconnect(options?: {
|
|
24
22
|
cleanup: boolean;
|
|
25
23
|
}): Promise<void>;
|
package/dist/lib.cjs/types/connectors/injected-solana-connector/walletStandardConnector.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Wallet } from "@wallet-standard/base";
|
|
2
|
-
import { BaseConnectorSettings, ChainNamespaceType, CONNECTOR_CATEGORY_TYPE, CONNECTOR_STATUS_TYPE, ConnectorFn, ConnectorInitOptions, ConnectorNamespaceType, IProvider, UserInfo } from "../../base";
|
|
2
|
+
import { BaseConnectorLoginParams, BaseConnectorSettings, ChainNamespaceType, CONNECTOR_CATEGORY_TYPE, CONNECTOR_STATUS_TYPE, ConnectorFn, ConnectorInitOptions, ConnectorNamespaceType, IProvider, UserInfo } from "../../base";
|
|
3
3
|
import { BaseSolanaConnector } from "../base-solana-connector";
|
|
4
4
|
export declare class WalletStandardConnector extends BaseSolanaConnector<void> {
|
|
5
5
|
readonly name: string;
|
|
@@ -17,9 +17,7 @@ export declare class WalletStandardConnector extends BaseSolanaConnector<void> {
|
|
|
17
17
|
get provider(): IProvider;
|
|
18
18
|
get isWalletConnected(): boolean;
|
|
19
19
|
init(options: ConnectorInitOptions): Promise<void>;
|
|
20
|
-
connect({ chainId }:
|
|
21
|
-
chainId: string;
|
|
22
|
-
}): Promise<IProvider>;
|
|
20
|
+
connect({ chainId, getIdentityToken }: BaseConnectorLoginParams): Promise<IProvider>;
|
|
23
21
|
disconnect(options?: {
|
|
24
22
|
cleanup: boolean;
|
|
25
23
|
}): Promise<void>;
|
|
@@ -18,7 +18,9 @@ declare class WalletServicesPlugin extends SafeEventEmitter implements IPlugin {
|
|
|
18
18
|
initWithProvider(): Promise<void>;
|
|
19
19
|
connect(): Promise<void>;
|
|
20
20
|
showWalletConnectScanner(showWalletConnectParams?: BaseEmbedControllerState["showWalletConnect"]): Promise<void>;
|
|
21
|
+
showFunding(showFundingParams?: BaseEmbedControllerState["showFunding"]): Promise<void>;
|
|
21
22
|
showCheckout(showCheckoutParams?: BaseEmbedControllerState["showCheckout"]): Promise<void>;
|
|
23
|
+
showReceive(showReceiveParams?: BaseEmbedControllerState["showReceive"]): Promise<void>;
|
|
22
24
|
showWalletUi(showWalletUiParams?: BaseEmbedControllerState["showWalletUi"]): Promise<void>;
|
|
23
25
|
showSwap(showSwapParams?: BaseEmbedControllerState["showSwap"]): Promise<void>;
|
|
24
26
|
cleanup(): Promise<void>;
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
export * from "./useCheckout";
|
|
2
2
|
export * from "./useEnableMFA";
|
|
3
|
+
export * from "./useFunding";
|
|
3
4
|
export * from "./useIdentityToken";
|
|
4
5
|
export * from "./useManageMFA";
|
|
6
|
+
export * from "./useReceive";
|
|
5
7
|
export * from "./useSwap";
|
|
6
8
|
export * from "./useSwitchChain";
|
|
7
9
|
export * from "./useWalletConnectScanner";
|