@web3auth/no-modal 10.5.1 → 10.5.5
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/utils.js +1 -1
- package/dist/lib.cjs/connectors/wallet-connect-v2-connector/WalletConnectV2Provider.js +4 -3
- package/dist/lib.cjs/connectors/wallet-connect-v2-connector/utils.js +14 -0
- package/dist/lib.cjs/noModal.js +5 -0
- package/dist/lib.cjs/types/connectors/wallet-connect-v2-connector/utils.d.ts +1 -0
- package/dist/lib.cjs/types/noModal.d.ts +1 -0
- package/dist/lib.esm/base/utils.js +1 -1
- package/dist/lib.esm/connectors/wallet-connect-v2-connector/WalletConnectV2Provider.js +4 -4
- package/dist/lib.esm/connectors/wallet-connect-v2-connector/utils.js +12 -0
- package/dist/lib.esm/noModal.js +5 -0
- package/dist/noModal.umd.min.js +1 -1
- package/package.json +9 -9
|
@@ -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.5.
|
|
148
|
+
const sdkVersion = "10.5.5";
|
|
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;
|
|
@@ -32,6 +32,7 @@ require('@toruslabs/bs58');
|
|
|
32
32
|
var JrpcClient = require('../../providers/solana-provider/rpc/JrpcClient.js');
|
|
33
33
|
var solanaRpcMiddlewares = require('../../providers/solana-provider/rpc/solanaRpcMiddlewares.js');
|
|
34
34
|
require('@web3auth/ws-embed');
|
|
35
|
+
var utils$1 = require('./utils.js');
|
|
35
36
|
var walletConnectV2Utils = require('./walletConnectV2Utils.js');
|
|
36
37
|
|
|
37
38
|
var _WalletConnectV2Provider;
|
|
@@ -217,14 +218,14 @@ class WalletConnectV2Provider extends baseProvider.BaseProvider {
|
|
|
217
218
|
if (event.name === "chainChanged") {
|
|
218
219
|
if (!data) return;
|
|
219
220
|
const connectedChainId = data;
|
|
220
|
-
const
|
|
221
|
+
const formattedChainId = utils$1.formatChainId(connectedChainId);
|
|
221
222
|
// Check if chainId changed and trigger event
|
|
222
223
|
const {
|
|
223
224
|
currentChain
|
|
224
225
|
} = this;
|
|
225
|
-
if (
|
|
226
|
+
if (formattedChainId && currentChain.chainId !== formattedChainId) {
|
|
226
227
|
// Handle rpcUrl update
|
|
227
|
-
await this.setupEngine(connector,
|
|
228
|
+
await this.setupEngine(connector, formattedChainId);
|
|
228
229
|
}
|
|
229
230
|
}
|
|
230
231
|
});
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
require('@babel/runtime/helpers/objectSpread2');
|
|
4
|
+
|
|
5
|
+
const formatChainId = chainId => {
|
|
6
|
+
if (typeof chainId === "number") {
|
|
7
|
+
return `0x${chainId.toString(16)}`;
|
|
8
|
+
} else if (typeof chainId === "string") {
|
|
9
|
+
return chainId.startsWith("0x") ? chainId : `0x${parseInt(chainId, 10).toString(16)}`;
|
|
10
|
+
}
|
|
11
|
+
throw new Error(`Invalid chainId: ${chainId}`);
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
exports.formatChainId = formatChainId;
|
package/dist/lib.cjs/noModal.js
CHANGED
|
@@ -136,6 +136,7 @@ class Web3AuthNoModal extends auth.SafeEventEmitter {
|
|
|
136
136
|
this.initCachedConnectorAndChainId();
|
|
137
137
|
this.initUIConfig(projectConfig);
|
|
138
138
|
this.initWalletServicesConfig(projectConfig);
|
|
139
|
+
this.initSessionTimeConfig(projectConfig);
|
|
139
140
|
this.analytics.setGlobalProperties({
|
|
140
141
|
team_id: projectConfig.teamId
|
|
141
142
|
});
|
|
@@ -474,6 +475,10 @@ class Web3AuthNoModal extends auth.SafeEventEmitter {
|
|
|
474
475
|
uxMode: auth.UX_MODE.POPUP
|
|
475
476
|
}, auth.cloneDeep(projectConfig.whitelabel || {}), this.coreOptions.uiConfig || {}]);
|
|
476
477
|
}
|
|
478
|
+
initSessionTimeConfig(projectConfig) {
|
|
479
|
+
if (this.coreOptions.sessionTime) return;
|
|
480
|
+
if (projectConfig.sessionTime) this.coreOptions.sessionTime = projectConfig.sessionTime;
|
|
481
|
+
}
|
|
477
482
|
initCachedConnectorAndChainId() {
|
|
478
483
|
// init chainId using cached chainId if it exists and is valid, otherwise use the defaultChainId or the first chain
|
|
479
484
|
const cachedChainId = this.state.currentChainId;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import type { EngineTypes } from "@walletconnect/types";
|
|
2
2
|
import type { ChainNamespaceType } from "../../base";
|
|
3
3
|
export declare const isChainIdSupported: (chainNamespace: ChainNamespaceType, chainID: number, loginSettings: EngineTypes.ConnectParams | undefined) => boolean;
|
|
4
|
+
export declare const formatChainId: (chainId: number | string) => string;
|
|
@@ -49,6 +49,7 @@ export declare class Web3AuthNoModal extends SafeEventEmitter<Web3AuthNoModalEve
|
|
|
49
49
|
protected initChainsConfig(projectConfig: ProjectConfig): void;
|
|
50
50
|
protected initAccountAbstractionConfig(projectConfig?: ProjectConfig): void;
|
|
51
51
|
protected initUIConfig(projectConfig: ProjectConfig): void;
|
|
52
|
+
protected initSessionTimeConfig(projectConfig: ProjectConfig): void;
|
|
52
53
|
protected initCachedConnectorAndChainId(): void;
|
|
53
54
|
protected initWalletServicesConfig(projectConfig: ProjectConfig): void;
|
|
54
55
|
protected getInitializationTrackData(): {};
|
|
@@ -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.5.
|
|
148
|
+
const sdkVersion = "10.5.5";
|
|
149
149
|
const getErrorAnalyticsProperties = error => {
|
|
150
150
|
try {
|
|
151
151
|
const code = error instanceof Web3AuthError ? error.code : error === null || error === void 0 ? void 0 : error.code;
|
|
@@ -2,6 +2,7 @@ import _objectSpread from '@babel/runtime/helpers/objectSpread2';
|
|
|
2
2
|
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
3
3
|
import { getAccountsFromNamespaces, parseAccountId } from '@walletconnect/utils';
|
|
4
4
|
import { providerErrors, JRPCEngine, providerFromEngine } from '@web3auth/auth';
|
|
5
|
+
import { formatChainId } from './utils.js';
|
|
5
6
|
import { switchChain, getAccounts, getEthProviderHandlers, getSolProviderHandlers } from './walletConnectV2Utils.js';
|
|
6
7
|
import { createEthMiddleware, createEthChainSwitchMiddleware } from '../../providers/ethereum-provider/rpc/ethRpcMiddlewares.js';
|
|
7
8
|
import { createEthJsonRpcClient } from '../../providers/ethereum-provider/rpc/jrpcClient.js';
|
|
@@ -196,15 +197,14 @@ class WalletConnectV2Provider extends BaseProvider {
|
|
|
196
197
|
if (event.name === "chainChanged") {
|
|
197
198
|
if (!data) return;
|
|
198
199
|
const connectedChainId = data;
|
|
199
|
-
const
|
|
200
|
-
|
|
200
|
+
const formattedChainId = formatChainId(connectedChainId);
|
|
201
201
|
// Check if chainId changed and trigger event
|
|
202
202
|
const {
|
|
203
203
|
currentChain
|
|
204
204
|
} = this;
|
|
205
|
-
if (
|
|
205
|
+
if (formattedChainId && currentChain.chainId !== formattedChainId) {
|
|
206
206
|
// Handle rpcUrl update
|
|
207
|
-
await this.setupEngine(connector,
|
|
207
|
+
await this.setupEngine(connector, formattedChainId);
|
|
208
208
|
}
|
|
209
209
|
}
|
|
210
210
|
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import '@babel/runtime/helpers/objectSpread2';
|
|
2
|
+
|
|
3
|
+
const formatChainId = chainId => {
|
|
4
|
+
if (typeof chainId === "number") {
|
|
5
|
+
return `0x${chainId.toString(16)}`;
|
|
6
|
+
} else if (typeof chainId === "string") {
|
|
7
|
+
return chainId.startsWith("0x") ? chainId : `0x${parseInt(chainId, 10).toString(16)}`;
|
|
8
|
+
}
|
|
9
|
+
throw new Error(`Invalid chainId: ${chainId}`);
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export { formatChainId };
|
package/dist/lib.esm/noModal.js
CHANGED
|
@@ -132,6 +132,7 @@ class Web3AuthNoModal extends SafeEventEmitter {
|
|
|
132
132
|
this.initCachedConnectorAndChainId();
|
|
133
133
|
this.initUIConfig(projectConfig);
|
|
134
134
|
this.initWalletServicesConfig(projectConfig);
|
|
135
|
+
this.initSessionTimeConfig(projectConfig);
|
|
135
136
|
this.analytics.setGlobalProperties({
|
|
136
137
|
team_id: projectConfig.teamId
|
|
137
138
|
});
|
|
@@ -483,6 +484,10 @@ class Web3AuthNoModal extends SafeEventEmitter {
|
|
|
483
484
|
uxMode: UX_MODE.POPUP
|
|
484
485
|
}, cloneDeep(projectConfig.whitelabel || {}), this.coreOptions.uiConfig || {}]);
|
|
485
486
|
}
|
|
487
|
+
initSessionTimeConfig(projectConfig) {
|
|
488
|
+
if (this.coreOptions.sessionTime) return;
|
|
489
|
+
if (projectConfig.sessionTime) this.coreOptions.sessionTime = projectConfig.sessionTime;
|
|
490
|
+
}
|
|
486
491
|
initCachedConnectorAndChainId() {
|
|
487
492
|
// init chainId using cached chainId if it exists and is valid, otherwise use the defaultChainId or the first chain
|
|
488
493
|
const cachedChainId = this.state.currentChainId;
|