@dynamic-labs/ethereum 1.0.0-alpha.0 → 1.0.0-alpha.10
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/CHANGELOG.md +176 -0
- package/package.json +8 -8
- package/src/EthWalletConnector.cjs +10 -8
- package/src/EthWalletConnector.d.ts +8 -8
- package/src/EthWalletConnector.js +10 -8
- package/src/coinbase/coinbase.d.ts +12 -12
- package/src/eip6963Provider.cjs +39 -0
- package/src/eip6963Provider.d.ts +25 -0
- package/src/eip6963Provider.js +34 -0
- package/src/ethProviderHelper.cjs +18 -0
- package/src/ethProviderHelper.d.ts +4 -0
- package/src/ethProviderHelper.js +18 -0
- package/src/walletConnect/walletConnect.cjs +6 -1
- package/src/walletConnect/walletConnect.js +6 -1
- package/src/walletConnect/walletConnectV2.cjs +80 -60
- package/src/walletConnect/walletConnectV2.d.ts +15 -10
- package/src/walletConnect/walletConnectV2.js +80 -60
|
@@ -7,12 +7,20 @@ var viem = require('viem');
|
|
|
7
7
|
var walletConnectorCore = require('@dynamic-labs/wallet-connector-core');
|
|
8
8
|
var utils = require('@dynamic-labs/utils');
|
|
9
9
|
var eventListenerHandlers = require('./utils/eventListenerHandlers.cjs');
|
|
10
|
+
var eip6963Provider = require('./eip6963Provider.cjs');
|
|
10
11
|
|
|
11
12
|
class EthProviderHelper {
|
|
12
13
|
constructor(wallet) {
|
|
13
14
|
this.wallet = wallet;
|
|
14
15
|
}
|
|
15
16
|
getInstalledProvider() {
|
|
17
|
+
const eip6963Config = this.getEip6963Config();
|
|
18
|
+
if (eip6963Config) {
|
|
19
|
+
const eip6963Provider = this.eip6963ProviderLookup(eip6963Config.rdns);
|
|
20
|
+
if (eip6963Provider) {
|
|
21
|
+
return eip6963Provider;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
16
24
|
const config = this.getInjectedConfig();
|
|
17
25
|
if (!config ||
|
|
18
26
|
!config.extensionLocators ||
|
|
@@ -20,6 +28,11 @@ class EthProviderHelper {
|
|
|
20
28
|
return undefined;
|
|
21
29
|
return this.installedProviderLookup(config.extensionLocators);
|
|
22
30
|
}
|
|
31
|
+
getEip6963Config() {
|
|
32
|
+
if (!this.wallet || !this.wallet.eip6963Config)
|
|
33
|
+
return;
|
|
34
|
+
return this.wallet.eip6963Config;
|
|
35
|
+
}
|
|
23
36
|
getInjectedConfig() {
|
|
24
37
|
if (!this.wallet || !this.wallet.injectedConfig)
|
|
25
38
|
return;
|
|
@@ -52,6 +65,11 @@ class EthProviderHelper {
|
|
|
52
65
|
const allInstalledProviders = this.installedProviders();
|
|
53
66
|
return walletConnectorCore.ProviderLookup(allInstalledProviders, providerFlags);
|
|
54
67
|
}
|
|
68
|
+
eip6963ProviderLookup(rdns) {
|
|
69
|
+
var _a;
|
|
70
|
+
const { providers } = eip6963Provider.Eip6963ProviderSingleton.get();
|
|
71
|
+
return (_a = providers.find((provider) => provider.info.rdns === rdns)) === null || _a === void 0 ? void 0 : _a.provider;
|
|
72
|
+
}
|
|
55
73
|
isInstalledHelper() {
|
|
56
74
|
return this.findProvider() !== undefined;
|
|
57
75
|
}
|
|
@@ -6,6 +6,9 @@ export declare class EthProviderHelper {
|
|
|
6
6
|
private wallet;
|
|
7
7
|
constructor(wallet: WalletSchema);
|
|
8
8
|
getInstalledProvider(): IEthereum | undefined;
|
|
9
|
+
getEip6963Config(): {
|
|
10
|
+
rdns: string;
|
|
11
|
+
} | undefined;
|
|
9
12
|
getInjectedConfig(): {
|
|
10
13
|
chain: string;
|
|
11
14
|
extensionLocators: {
|
|
@@ -16,6 +19,7 @@ export declare class EthProviderHelper {
|
|
|
16
19
|
} | undefined;
|
|
17
20
|
installedProviders(): IEthereum[];
|
|
18
21
|
installedProviderLookup(providerFlags: Array<ProviderCondition<ProviderFlag>>): IEthereum | undefined;
|
|
22
|
+
eip6963ProviderLookup(rdns: string): IEthereum | undefined;
|
|
19
23
|
isInstalledHelper(): boolean;
|
|
20
24
|
findProvider(): IEthereum | undefined;
|
|
21
25
|
findWalletClient(): WalletClient | undefined;
|
package/src/ethProviderHelper.js
CHANGED
|
@@ -3,12 +3,20 @@ import { createWalletClient, custom, getAddress } from 'viem';
|
|
|
3
3
|
import { ProviderLookup, logger } from '@dynamic-labs/wallet-connector-core';
|
|
4
4
|
import { getProvidersFromWindow } from '@dynamic-labs/utils';
|
|
5
5
|
import { eventListenerHandlers } from './utils/eventListenerHandlers.js';
|
|
6
|
+
import { Eip6963ProviderSingleton } from './eip6963Provider.js';
|
|
6
7
|
|
|
7
8
|
class EthProviderHelper {
|
|
8
9
|
constructor(wallet) {
|
|
9
10
|
this.wallet = wallet;
|
|
10
11
|
}
|
|
11
12
|
getInstalledProvider() {
|
|
13
|
+
const eip6963Config = this.getEip6963Config();
|
|
14
|
+
if (eip6963Config) {
|
|
15
|
+
const eip6963Provider = this.eip6963ProviderLookup(eip6963Config.rdns);
|
|
16
|
+
if (eip6963Provider) {
|
|
17
|
+
return eip6963Provider;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
12
20
|
const config = this.getInjectedConfig();
|
|
13
21
|
if (!config ||
|
|
14
22
|
!config.extensionLocators ||
|
|
@@ -16,6 +24,11 @@ class EthProviderHelper {
|
|
|
16
24
|
return undefined;
|
|
17
25
|
return this.installedProviderLookup(config.extensionLocators);
|
|
18
26
|
}
|
|
27
|
+
getEip6963Config() {
|
|
28
|
+
if (!this.wallet || !this.wallet.eip6963Config)
|
|
29
|
+
return;
|
|
30
|
+
return this.wallet.eip6963Config;
|
|
31
|
+
}
|
|
19
32
|
getInjectedConfig() {
|
|
20
33
|
if (!this.wallet || !this.wallet.injectedConfig)
|
|
21
34
|
return;
|
|
@@ -48,6 +61,11 @@ class EthProviderHelper {
|
|
|
48
61
|
const allInstalledProviders = this.installedProviders();
|
|
49
62
|
return ProviderLookup(allInstalledProviders, providerFlags);
|
|
50
63
|
}
|
|
64
|
+
eip6963ProviderLookup(rdns) {
|
|
65
|
+
var _a;
|
|
66
|
+
const { providers } = Eip6963ProviderSingleton.get();
|
|
67
|
+
return (_a = providers.find((provider) => provider.info.rdns === rdns)) === null || _a === void 0 ? void 0 : _a.provider;
|
|
68
|
+
}
|
|
51
69
|
isInstalledHelper() {
|
|
52
70
|
return this.findProvider() !== undefined;
|
|
53
71
|
}
|
|
@@ -69,9 +69,14 @@ class WalletConnect extends EthWalletConnector.EthWalletConnector {
|
|
|
69
69
|
fetchPublicAddress(opts) {
|
|
70
70
|
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
71
71
|
return client.fetchWalletConnectEVMPublicAddress(walletBook.getWalletBookWallet(this.walletBook, this.key), this.getClient(), this.deepLinkPreference, Object.assign(Object.assign({}, opts), { onConnect: (payload) => {
|
|
72
|
-
var _a;
|
|
72
|
+
var _a, _b;
|
|
73
73
|
(_a = opts === null || opts === void 0 ? void 0 : opts.onConnect) === null || _a === void 0 ? void 0 : _a.call(opts, payload);
|
|
74
74
|
this.connectedChain = payload.params[0].chainId ? 'EVM' : 'SOL';
|
|
75
|
+
if ((_b = payload.params[0].accounts) === null || _b === void 0 ? void 0 : _b.length) {
|
|
76
|
+
this.emit('accountChange', {
|
|
77
|
+
accounts: payload.params[0].accounts,
|
|
78
|
+
});
|
|
79
|
+
}
|
|
75
80
|
} }));
|
|
76
81
|
});
|
|
77
82
|
}
|
|
@@ -61,9 +61,14 @@ class WalletConnect extends EthWalletConnector {
|
|
|
61
61
|
fetchPublicAddress(opts) {
|
|
62
62
|
return __awaiter(this, void 0, void 0, function* () {
|
|
63
63
|
return fetchWalletConnectEVMPublicAddress(getWalletBookWallet(this.walletBook, this.key), this.getClient(), this.deepLinkPreference, Object.assign(Object.assign({}, opts), { onConnect: (payload) => {
|
|
64
|
-
var _a;
|
|
64
|
+
var _a, _b;
|
|
65
65
|
(_a = opts === null || opts === void 0 ? void 0 : opts.onConnect) === null || _a === void 0 ? void 0 : _a.call(opts, payload);
|
|
66
66
|
this.connectedChain = payload.params[0].chainId ? 'EVM' : 'SOL';
|
|
67
|
+
if ((_b = payload.params[0].accounts) === null || _b === void 0 ? void 0 : _b.length) {
|
|
68
|
+
this.emit('accountChange', {
|
|
69
|
+
accounts: payload.params[0].accounts,
|
|
70
|
+
});
|
|
71
|
+
}
|
|
67
72
|
} }));
|
|
68
73
|
});
|
|
69
74
|
}
|
|
@@ -19,9 +19,12 @@ var EventEmitter__default = /*#__PURE__*/_interopDefaultLegacy(EventEmitter);
|
|
|
19
19
|
|
|
20
20
|
const activeAccountKey = (walletName) => `dynamic-wc2-active-account-${walletName}`;
|
|
21
21
|
const sessionTopicKey = (walletName) => `dynamic-wc2-session-topic-${walletName}`;
|
|
22
|
+
const swicthedNetworkKey = (walletName) => `dynamic-wc2-switched-network-${walletName}`;
|
|
23
|
+
const currentChainKey = (walletName) => `dynamic-wc2-current-chain-${walletName}`;
|
|
22
24
|
const ee = new EventEmitter__default["default"]();
|
|
23
25
|
class WalletConnectV2 extends EthWalletConnector.EthWalletConnector {
|
|
24
26
|
constructor(opts) {
|
|
27
|
+
var _a;
|
|
25
28
|
super(opts);
|
|
26
29
|
this.supportedChains = ['EVM', 'ETH'];
|
|
27
30
|
this.connectedChain = 'EVM';
|
|
@@ -29,6 +32,9 @@ class WalletConnectV2 extends EthWalletConnector.EthWalletConnector {
|
|
|
29
32
|
this.canConnectViaQrCode = true;
|
|
30
33
|
this.isWalletConnect = true;
|
|
31
34
|
this.preferredChains = [];
|
|
35
|
+
// When trying to switch network for MetaMask, the switch promise gets stuck
|
|
36
|
+
// if the switch got trigged once already, so we need to keep track of that
|
|
37
|
+
this._hasSwitchedNetwork = false;
|
|
32
38
|
this.name = opts.walletName;
|
|
33
39
|
this.projectId = opts.projectId;
|
|
34
40
|
this.deepLinkPreference = opts.deepLinkPreference || 'native';
|
|
@@ -36,40 +42,17 @@ class WalletConnectV2 extends EthWalletConnector.EthWalletConnector {
|
|
|
36
42
|
if (!this.preferredChains.includes('eip155:1')) {
|
|
37
43
|
this.preferredChains.push('eip155:1');
|
|
38
44
|
}
|
|
45
|
+
this.hasSwitchedNetwork =
|
|
46
|
+
(_a = Boolean(localStorage.getItem(this.swicthedNetworkKey))) !== null && _a !== void 0 ? _a : false;
|
|
47
|
+
const lsCurrentChain = localStorage.getItem(this.currentChainKey);
|
|
48
|
+
this.currentChainId = lsCurrentChain
|
|
49
|
+
? parseIntSafe.parseIntSafe(lsCurrentChain)
|
|
50
|
+
: undefined;
|
|
39
51
|
}
|
|
40
|
-
|
|
41
|
-
const preferredNetwork = this.preferredChains.find((chain) => this.supportedChain(chain));
|
|
42
|
-
if (preferredNetwork) {
|
|
43
|
-
return preferredNetwork;
|
|
44
|
-
}
|
|
45
|
-
else if (this.findSupportedChains().length) {
|
|
46
|
-
return this.findSupportedChains()[0];
|
|
47
|
-
}
|
|
48
|
-
else {
|
|
49
|
-
return 'eip155:1';
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
findSupportedChains() {
|
|
53
|
-
var _a;
|
|
54
|
-
try {
|
|
55
|
-
const wallet = walletBook.getWalletBookWallet(this.walletBook, this.key);
|
|
56
|
-
const supportedChains = (_a = this.evmNetworks) === null || _a === void 0 ? void 0 : _a.filter((network) => { var _a; return (_a = wallet === null || wallet === void 0 ? void 0 : wallet.chains) === null || _a === void 0 ? void 0 : _a.includes(`eip155:${network.chainId}`); }).map((network) => `eip155:${network.chainId}`);
|
|
57
|
-
return supportedChains;
|
|
58
|
-
}
|
|
59
|
-
catch (_b) {
|
|
60
|
-
// pass
|
|
61
|
-
}
|
|
62
|
-
return [];
|
|
63
|
-
}
|
|
64
|
-
supportedChain(chainId) {
|
|
65
|
-
var _a;
|
|
66
|
-
return (_a = this.findSupportedChains().filter((chain) => [`eip155:${chainId}`, chainId].includes(chain))) === null || _a === void 0 ? void 0 : _a[0];
|
|
67
|
-
}
|
|
68
|
-
optionalChains() {
|
|
52
|
+
getMappedChains() {
|
|
69
53
|
return (this.evmNetworks
|
|
70
|
-
// Filters out
|
|
71
|
-
.filter((network) => network.chainId !== 11297108109
|
|
72
|
-
`eip155:${network.chainId}` !== this.defaultChainId())
|
|
54
|
+
// Filters out palm that crashes Trust Wallet
|
|
55
|
+
.filter((network) => network.chainId !== 11297108109)
|
|
73
56
|
.map((network) => `eip155:${network.chainId}`));
|
|
74
57
|
}
|
|
75
58
|
initConnection() {
|
|
@@ -82,34 +65,26 @@ class WalletConnectV2 extends EthWalletConnector.EthWalletConnector {
|
|
|
82
65
|
if (provider === null || provider === void 0 ? void 0 : provider.uri) {
|
|
83
66
|
return;
|
|
84
67
|
}
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
}
|
|
102
|
-
}
|
|
68
|
+
const optionalNamespaces = {
|
|
69
|
+
eip155: {
|
|
70
|
+
chains: this.getMappedChains(),
|
|
71
|
+
events: ['chainChanged', 'accountsChanged'],
|
|
72
|
+
methods: [
|
|
73
|
+
'eth_chainId',
|
|
74
|
+
'eth_signTypedData',
|
|
75
|
+
'eth_signTransaction',
|
|
76
|
+
'eth_sign',
|
|
77
|
+
'personal_sign',
|
|
78
|
+
'eth_sendTransaction',
|
|
79
|
+
'eth_signTypedData_v4',
|
|
80
|
+
'wallet_switchEthereumChain',
|
|
81
|
+
'wallet_addEthereumChain',
|
|
82
|
+
],
|
|
83
|
+
rpcMap: this.evmNetworkRpcMap(),
|
|
84
|
+
},
|
|
85
|
+
};
|
|
103
86
|
provider
|
|
104
87
|
.connect({
|
|
105
|
-
namespaces: {
|
|
106
|
-
eip155: {
|
|
107
|
-
chains: [this.defaultChainId()],
|
|
108
|
-
events: ['chainChanged', 'accountsChanged'],
|
|
109
|
-
methods: ['personal_sign', 'eth_sendTransaction'],
|
|
110
|
-
rpcMap: this.evmNetworkRpcMap(),
|
|
111
|
-
},
|
|
112
|
-
},
|
|
113
88
|
optionalNamespaces,
|
|
114
89
|
})
|
|
115
90
|
.catch((e) => {
|
|
@@ -125,6 +100,8 @@ class WalletConnectV2 extends EthWalletConnector.EthWalletConnector {
|
|
|
125
100
|
projectId: this.projectId,
|
|
126
101
|
});
|
|
127
102
|
WalletConnectV2.provider = provider;
|
|
103
|
+
this.teardownEventListeners();
|
|
104
|
+
this.setupEventListeners();
|
|
128
105
|
});
|
|
129
106
|
}
|
|
130
107
|
initProvider() {
|
|
@@ -161,6 +138,36 @@ class WalletConnectV2 extends EthWalletConnector.EthWalletConnector {
|
|
|
161
138
|
get activeAccountKey() {
|
|
162
139
|
return activeAccountKey(this.key);
|
|
163
140
|
}
|
|
141
|
+
get swicthedNetworkKey() {
|
|
142
|
+
return swicthedNetworkKey(this.key);
|
|
143
|
+
}
|
|
144
|
+
get currentChainKey() {
|
|
145
|
+
return currentChainKey(this.key);
|
|
146
|
+
}
|
|
147
|
+
set currentChainId(value) {
|
|
148
|
+
this._currentChainId = value;
|
|
149
|
+
if (value) {
|
|
150
|
+
localStorage.setItem(this.currentChainKey, value.toString());
|
|
151
|
+
}
|
|
152
|
+
else {
|
|
153
|
+
localStorage.removeItem(this.currentChainKey);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
get currentChainId() {
|
|
157
|
+
return this._currentChainId;
|
|
158
|
+
}
|
|
159
|
+
set hasSwitchedNetwork(value) {
|
|
160
|
+
this._hasSwitchedNetwork = value;
|
|
161
|
+
if (value) {
|
|
162
|
+
localStorage.setItem(this.swicthedNetworkKey, value.toString());
|
|
163
|
+
}
|
|
164
|
+
else {
|
|
165
|
+
localStorage.removeItem(this.swicthedNetworkKey);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
get hasSwitchedNetwork() {
|
|
169
|
+
return this._hasSwitchedNetwork;
|
|
170
|
+
}
|
|
164
171
|
supportsNetworkSwitching() {
|
|
165
172
|
return true;
|
|
166
173
|
}
|
|
@@ -169,6 +176,7 @@ class WalletConnectV2 extends EthWalletConnector.EthWalletConnector {
|
|
|
169
176
|
return;
|
|
170
177
|
}
|
|
171
178
|
WalletConnectV2.provider.client.on('session_event', ({ params }) => {
|
|
179
|
+
walletConnectorCore.logger.debug('session_event was called', { params });
|
|
172
180
|
if (!params || !params.event) {
|
|
173
181
|
walletConnectorCore.logger.debug('session_event was called without params or params.event');
|
|
174
182
|
return;
|
|
@@ -180,6 +188,7 @@ class WalletConnectV2 extends EthWalletConnector.EthWalletConnector {
|
|
|
180
188
|
walletConnectorCore.logger.debug(`received unexpected data for chainChanged: ${data} with type ${typeof data}}`);
|
|
181
189
|
return;
|
|
182
190
|
}
|
|
191
|
+
this.currentChainId = chainId;
|
|
183
192
|
this.emit('chainChange', { chain: String(chainId) });
|
|
184
193
|
// When a user switches network from their wallet, we need the provider to change network
|
|
185
194
|
// such that any future calls to `getNetwork` will return the correct network
|
|
@@ -193,7 +202,6 @@ class WalletConnectV2 extends EthWalletConnector.EthWalletConnector {
|
|
|
193
202
|
// eslint-disable-next-line prefer-destructuring
|
|
194
203
|
const account = data[0].split(':')[2];
|
|
195
204
|
this.setActiveAccount(account);
|
|
196
|
-
this.emit('accountChange', { accounts: [account] });
|
|
197
205
|
}
|
|
198
206
|
});
|
|
199
207
|
WalletConnectV2.provider.client.on('session_delete', () => _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
@@ -348,6 +356,7 @@ class WalletConnectV2 extends EthWalletConnector.EthWalletConnector {
|
|
|
348
356
|
setActiveAccount(account) {
|
|
349
357
|
localStorage.setItem(this.activeAccountKey, account);
|
|
350
358
|
this.activeAccount = account;
|
|
359
|
+
this.emit('accountChange', { accounts: [account] });
|
|
351
360
|
}
|
|
352
361
|
setSession(session) {
|
|
353
362
|
localStorage.setItem(this.sessionTopicKey, session.topic);
|
|
@@ -358,6 +367,8 @@ class WalletConnectV2 extends EthWalletConnector.EthWalletConnector {
|
|
|
358
367
|
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
359
368
|
this.clearActiveAccount();
|
|
360
369
|
this.clearSession();
|
|
370
|
+
this.hasSwitchedNetwork = false;
|
|
371
|
+
this.currentChainId = undefined;
|
|
361
372
|
if (!((_a = WalletConnectV2.provider) === null || _a === void 0 ? void 0 : _a.session)) {
|
|
362
373
|
return;
|
|
363
374
|
}
|
|
@@ -377,6 +388,9 @@ class WalletConnectV2 extends EthWalletConnector.EthWalletConnector {
|
|
|
377
388
|
getNetwork: { get: () => super.getNetwork }
|
|
378
389
|
});
|
|
379
390
|
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
391
|
+
if (this.currentChainId) {
|
|
392
|
+
return this.currentChainId;
|
|
393
|
+
}
|
|
380
394
|
yield this.initProvider();
|
|
381
395
|
return _super.getNetwork.call(this);
|
|
382
396
|
});
|
|
@@ -400,6 +414,8 @@ class WalletConnectV2 extends EthWalletConnector.EthWalletConnector {
|
|
|
400
414
|
throw new utils.DynamicError('Provider not found');
|
|
401
415
|
}
|
|
402
416
|
yield _super.providerSwitchNetwork.call(this, { network, provider });
|
|
417
|
+
this.currentChainId = network.chainId;
|
|
418
|
+
this.hasSwitchedNetwork = true;
|
|
403
419
|
this.emit('chainChange', { chain: String(network.chainId) });
|
|
404
420
|
});
|
|
405
421
|
}
|
|
@@ -417,7 +433,11 @@ class WalletConnectV2 extends EthWalletConnector.EthWalletConnector {
|
|
|
417
433
|
});
|
|
418
434
|
}
|
|
419
435
|
getSupportedNetworks() {
|
|
436
|
+
var _a;
|
|
420
437
|
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
438
|
+
if (!this.hasSwitchedNetwork) {
|
|
439
|
+
return undefined;
|
|
440
|
+
}
|
|
421
441
|
yield this.initProvider();
|
|
422
442
|
this.refreshSession();
|
|
423
443
|
if (!this.session) {
|
|
@@ -431,7 +451,7 @@ class WalletConnectV2 extends EthWalletConnector.EthWalletConnector {
|
|
|
431
451
|
chains.push(key.split(':')[1]);
|
|
432
452
|
}
|
|
433
453
|
});
|
|
434
|
-
this.session.namespaces.eip155.accounts.forEach((account) => chains.push(account.split(':')[1]));
|
|
454
|
+
(_a = this.session.namespaces.eip155) === null || _a === void 0 ? void 0 : _a.accounts.forEach((account) => chains.push(account.split(':')[1]));
|
|
435
455
|
return chains.length ? chains : undefined;
|
|
436
456
|
});
|
|
437
457
|
}
|
|
@@ -23,11 +23,10 @@ export declare class WalletConnectV2 extends EthWalletConnector {
|
|
|
23
23
|
private projectId?;
|
|
24
24
|
private deepLinkPreference;
|
|
25
25
|
private preferredChains;
|
|
26
|
+
private _currentChainId;
|
|
27
|
+
private _hasSwitchedNetwork;
|
|
26
28
|
constructor(opts: WalletConnectorV2Opts);
|
|
27
|
-
private
|
|
28
|
-
private findSupportedChains;
|
|
29
|
-
private supportedChain;
|
|
30
|
-
private optionalChains;
|
|
29
|
+
private getMappedChains;
|
|
31
30
|
private initConnection;
|
|
32
31
|
private createInitProviderPromise;
|
|
33
32
|
private initProvider;
|
|
@@ -35,6 +34,12 @@ export declare class WalletConnectV2 extends EthWalletConnector {
|
|
|
35
34
|
init(): Promise<void>;
|
|
36
35
|
get sessionTopicKey(): string;
|
|
37
36
|
get activeAccountKey(): string;
|
|
37
|
+
get swicthedNetworkKey(): string;
|
|
38
|
+
get currentChainKey(): string;
|
|
39
|
+
private set currentChainId(value);
|
|
40
|
+
private get currentChainId();
|
|
41
|
+
private set hasSwitchedNetwork(value);
|
|
42
|
+
private get hasSwitchedNetwork();
|
|
38
43
|
supportsNetworkSwitching(): boolean;
|
|
39
44
|
setupEventListeners(): void;
|
|
40
45
|
teardownEventListeners(): void;
|
|
@@ -56,20 +61,20 @@ export declare class WalletConnectV2 extends EthWalletConnector {
|
|
|
56
61
|
type: string;
|
|
57
62
|
uid: string;
|
|
58
63
|
addChain: (args: import("viem").AddChainParameters) => Promise<void>;
|
|
59
|
-
deployContract: <const TAbi extends import("viem").Abi | readonly unknown[], TChainOverride extends import("viem").Chain | undefined>(args: import("viem").DeployContractParameters<TAbi, undefined, undefined, TChainOverride>) => Promise<`0x${string}`>;
|
|
64
|
+
deployContract: <const TAbi extends import("viem").Abi | readonly unknown[], TChainOverride extends import("viem").Chain | undefined = undefined>(args: import("viem").DeployContractParameters<TAbi, undefined, undefined, TChainOverride>) => Promise<`0x${string}`>;
|
|
60
65
|
getAddresses: () => Promise<import("viem").GetAddressesReturnType>;
|
|
61
66
|
getChainId: () => Promise<number>;
|
|
62
67
|
getPermissions: () => Promise<import("viem").GetPermissionsReturnType>;
|
|
63
|
-
prepareTransactionRequest: <TChainOverride_1 extends import("viem").Chain | undefined>(args: import("viem").PrepareTransactionRequestParameters<undefined, undefined, TChainOverride_1>) => Promise<import("viem").PrepareTransactionRequestReturnType>;
|
|
68
|
+
prepareTransactionRequest: <TChainOverride_1 extends import("viem").Chain | undefined = undefined>(args: import("viem").PrepareTransactionRequestParameters<undefined, undefined, TChainOverride_1>) => Promise<import("viem").PrepareTransactionRequestReturnType>;
|
|
64
69
|
requestAddresses: () => Promise<import("viem").RequestAddressesReturnType>;
|
|
65
70
|
requestPermissions: (args: {
|
|
66
71
|
[x: string]: Record<string, any>;
|
|
67
72
|
eth_accounts: Record<string, any>;
|
|
68
73
|
}) => Promise<import("viem").RequestPermissionsReturnType>;
|
|
69
74
|
sendRawTransaction: (args: import("viem/_types/actions/wallet/sendRawTransaction").SendRawTransactionParameters) => Promise<`0x${string}`>;
|
|
70
|
-
sendTransaction: <TChainOverride_2 extends import("viem").Chain | undefined>(args: import("viem").SendTransactionParameters<undefined, undefined, TChainOverride_2>) => Promise<`0x${string}`>;
|
|
75
|
+
sendTransaction: <TChainOverride_2 extends import("viem").Chain | undefined = undefined>(args: import("viem").SendTransactionParameters<undefined, undefined, TChainOverride_2>) => Promise<`0x${string}`>;
|
|
71
76
|
signMessage: (args: import("viem").SignMessageParameters<undefined>) => Promise<`0x${string}`>;
|
|
72
|
-
signTransaction: <TChainOverride_3 extends import("viem").Chain | undefined>(args: import("viem/_types/actions/wallet/signTransaction").SignTransactionParameters<undefined, undefined, TChainOverride_3>) => Promise<`0x${string}`>;
|
|
77
|
+
signTransaction: <TChainOverride_3 extends import("viem").Chain | undefined = undefined>(args: import("viem/_types/actions/wallet/signTransaction").SignTransactionParameters<undefined, undefined, TChainOverride_3>) => Promise<`0x${string}`>;
|
|
73
78
|
signTypedData: <const TTypedData extends {
|
|
74
79
|
[x: string]: readonly import("viem").TypedDataParameter[];
|
|
75
80
|
[x: `string[${string}]`]: undefined;
|
|
@@ -280,7 +285,7 @@ export declare class WalletConnectV2 extends EthWalletConnector {
|
|
|
280
285
|
}, TPrimaryType extends string>(args: import("viem").SignTypedDataParameters<TTypedData, TPrimaryType, undefined>) => Promise<`0x${string}`>;
|
|
281
286
|
switchChain: (args: import("viem").SwitchChainParameters) => Promise<void>;
|
|
282
287
|
watchAsset: (args: import("viem").WatchAssetParams) => Promise<boolean>;
|
|
283
|
-
writeContract: <const TAbi_1 extends import("viem").Abi | readonly unknown[], TFunctionName extends string, TChainOverride_4 extends import("viem").Chain | undefined>(args: import("viem").WriteContractParameters<TAbi_1, TFunctionName, undefined, undefined, TChainOverride_4>) => Promise<`0x${string}`>;
|
|
288
|
+
writeContract: <const TAbi_1 extends import("viem").Abi | readonly unknown[], TFunctionName extends string, TChainOverride_4 extends import("viem").Chain | undefined = undefined>(args: import("viem").WriteContractParameters<TAbi_1, TFunctionName, undefined, undefined, TChainOverride_4>) => Promise<`0x${string}`>;
|
|
284
289
|
extend: <const client extends {
|
|
285
290
|
[x: string]: unknown;
|
|
286
291
|
account?: undefined;
|
|
@@ -294,7 +299,7 @@ export declare class WalletConnectV2 extends EthWalletConnector {
|
|
|
294
299
|
transport?: undefined;
|
|
295
300
|
type?: undefined;
|
|
296
301
|
uid?: undefined;
|
|
297
|
-
}>(fn: (client: import("viem").Client<import("viem").CustomTransport, undefined, undefined, import("viem").WalletRpcSchema, import("viem").WalletActions<undefined, undefined>>) => client) => import("viem").Client<import("viem").CustomTransport, undefined, undefined, import("viem").WalletRpcSchema, { [K in keyof client]: client[K]; } & import("viem").WalletActions<undefined, undefined>>;
|
|
302
|
+
} & Partial<Pick<import("viem").PublicActions, "getChainId" | "prepareTransactionRequest" | "sendRawTransaction" | "call" | "createContractEventFilter" | "createEventFilter" | "estimateContractGas" | "estimateGas" | "getBlock" | "getBlockNumber" | "getContractEvents" | "getEnsText" | "getFilterChanges" | "getGasPrice" | "getLogs" | "getTransaction" | "getTransactionCount" | "getTransactionReceipt" | "readContract" | "simulateContract" | "uninstallFilter" | "watchBlockNumber" | "watchContractEvent"> & Pick<import("viem").WalletActions, "sendTransaction" | "writeContract">>>(fn: (client: import("viem").Client<import("viem").CustomTransport, undefined, undefined, import("viem").WalletRpcSchema, import("viem").WalletActions<undefined, undefined>>) => client) => import("viem").Client<import("viem").CustomTransport, undefined, undefined, import("viem").WalletRpcSchema, { [K in keyof client]: client[K]; } & import("viem").WalletActions<undefined, undefined>>;
|
|
298
303
|
} | undefined;
|
|
299
304
|
fetchPublicAddress(opts?: FetchPublicAddressOpts): Promise<string | undefined>;
|
|
300
305
|
/**
|