@wagmi/connectors 3.1.2-cjs → 3.1.2
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/chunk-2UFLHRLT.js +65 -65
- package/dist/chunk-OQILYQDO.js +4 -4
- package/dist/chunk-UGBGYVBH.js +5 -5
- package/dist/chunk-W65LBPLT.js +13 -13
- package/dist/coinbaseWallet.js +51 -51
- package/dist/index.js +16 -16
- package/dist/injected.js +9 -9
- package/dist/ledger.js +75 -75
- package/dist/metaMask.js +34 -34
- package/dist/mock/index.js +55 -55
- package/dist/safe.js +42 -42
- package/dist/walletConnect.js +101 -101
- package/dist/walletConnectLegacy.js +51 -51
- package/package.json +2 -1
package/dist/safe.js
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
1
|
+
import {
|
|
2
|
+
ConnectorNotFoundError
|
|
3
|
+
} from "./chunk-UGBGYVBH.js";
|
|
4
|
+
import {
|
|
5
|
+
normalizeChainId
|
|
6
|
+
} from "./chunk-OQILYQDO.js";
|
|
7
|
+
import {
|
|
8
|
+
Connector,
|
|
9
|
+
__privateAdd,
|
|
10
|
+
__privateGet,
|
|
11
|
+
__privateSet
|
|
12
|
+
} from "./chunk-W65LBPLT.js";
|
|
13
13
|
|
|
14
14
|
// src/safe.ts
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
import { SafeAppProvider } from "@safe-global/safe-apps-provider";
|
|
16
|
+
import { default as SafeAppsSDK } from "@safe-global/safe-apps-sdk";
|
|
17
|
+
import { createWalletClient, custom, getAddress } from "viem";
|
|
18
18
|
var _provider, _sdk;
|
|
19
|
-
var SafeConnector = class extends
|
|
19
|
+
var SafeConnector = class extends Connector {
|
|
20
20
|
constructor({
|
|
21
21
|
chains,
|
|
22
22
|
options: options_
|
|
@@ -28,19 +28,19 @@ var SafeConnector = class extends _chunkW65LBPLTjs.Connector {
|
|
|
28
28
|
super({ chains, options });
|
|
29
29
|
this.id = "safe";
|
|
30
30
|
this.name = "Safe";
|
|
31
|
-
this.ready = !(typeof window === "undefined") &&
|
|
32
|
-
|
|
33
|
-
|
|
31
|
+
this.ready = !(typeof window === "undefined") && window?.parent !== window;
|
|
32
|
+
__privateAdd(this, _provider, void 0);
|
|
33
|
+
__privateAdd(this, _sdk, void 0);
|
|
34
34
|
this.shimDisconnectKey = `${this.id}.shimDisconnect`;
|
|
35
|
-
let SDK =
|
|
36
|
-
if (typeof
|
|
37
|
-
SDK =
|
|
38
|
-
|
|
35
|
+
let SDK = SafeAppsSDK;
|
|
36
|
+
if (typeof SafeAppsSDK !== "function" && typeof SafeAppsSDK.default === "function")
|
|
37
|
+
SDK = SafeAppsSDK.default;
|
|
38
|
+
__privateSet(this, _sdk, new SDK(options));
|
|
39
39
|
}
|
|
40
40
|
async connect() {
|
|
41
41
|
const provider = await this.getProvider();
|
|
42
42
|
if (!provider)
|
|
43
|
-
throw new
|
|
43
|
+
throw new ConnectorNotFoundError();
|
|
44
44
|
if (provider.on) {
|
|
45
45
|
provider.on("accountsChanged", this.onAccountsChanged);
|
|
46
46
|
provider.on("chainChanged", this.onChainChanged);
|
|
@@ -50,7 +50,7 @@ var SafeConnector = class extends _chunkW65LBPLTjs.Connector {
|
|
|
50
50
|
const account = await this.getAccount();
|
|
51
51
|
const id = await this.getChainId();
|
|
52
52
|
if (this.options.shimDisconnect)
|
|
53
|
-
|
|
53
|
+
this.storage?.setItem(this.shimDisconnectKey, true);
|
|
54
54
|
return {
|
|
55
55
|
account,
|
|
56
56
|
chain: { id, unsupported: this.isChainUnsupported(id) }
|
|
@@ -58,37 +58,37 @@ var SafeConnector = class extends _chunkW65LBPLTjs.Connector {
|
|
|
58
58
|
}
|
|
59
59
|
async disconnect() {
|
|
60
60
|
const provider = await this.getProvider();
|
|
61
|
-
if (!
|
|
61
|
+
if (!provider?.removeListener)
|
|
62
62
|
return;
|
|
63
63
|
provider.removeListener("accountsChanged", this.onAccountsChanged);
|
|
64
64
|
provider.removeListener("chainChanged", this.onChainChanged);
|
|
65
65
|
provider.removeListener("disconnect", this.onDisconnect);
|
|
66
66
|
if (this.options.shimDisconnect)
|
|
67
|
-
|
|
67
|
+
this.storage?.removeItem(this.shimDisconnectKey);
|
|
68
68
|
}
|
|
69
69
|
async getAccount() {
|
|
70
70
|
const provider = await this.getProvider();
|
|
71
71
|
if (!provider)
|
|
72
|
-
throw new
|
|
72
|
+
throw new ConnectorNotFoundError();
|
|
73
73
|
const accounts = await provider.request({
|
|
74
74
|
method: "eth_accounts"
|
|
75
75
|
});
|
|
76
|
-
return
|
|
76
|
+
return getAddress(accounts[0]);
|
|
77
77
|
}
|
|
78
78
|
async getChainId() {
|
|
79
79
|
const provider = await this.getProvider();
|
|
80
80
|
if (!provider)
|
|
81
|
-
throw new
|
|
82
|
-
return
|
|
81
|
+
throw new ConnectorNotFoundError();
|
|
82
|
+
return normalizeChainId(provider.chainId);
|
|
83
83
|
}
|
|
84
84
|
async getProvider() {
|
|
85
|
-
if (!
|
|
86
|
-
const safe = await
|
|
85
|
+
if (!__privateGet(this, _provider)) {
|
|
86
|
+
const safe = await __privateGet(this, _sdk).safe.getInfo();
|
|
87
87
|
if (!safe)
|
|
88
88
|
throw new Error("Could not load Safe information");
|
|
89
|
-
|
|
89
|
+
__privateSet(this, _provider, new SafeAppProvider(safe, __privateGet(this, _sdk)));
|
|
90
90
|
}
|
|
91
|
-
return
|
|
91
|
+
return __privateGet(this, _provider);
|
|
92
92
|
}
|
|
93
93
|
async getWalletClient({
|
|
94
94
|
chainId
|
|
@@ -98,19 +98,19 @@ var SafeConnector = class extends _chunkW65LBPLTjs.Connector {
|
|
|
98
98
|
const chain = this.chains.find((x) => x.id === chainId);
|
|
99
99
|
if (!provider)
|
|
100
100
|
throw new Error("provider is required.");
|
|
101
|
-
return
|
|
101
|
+
return createWalletClient({
|
|
102
102
|
account,
|
|
103
103
|
chain,
|
|
104
|
-
transport:
|
|
104
|
+
transport: custom(provider)
|
|
105
105
|
});
|
|
106
106
|
}
|
|
107
107
|
async isAuthorized() {
|
|
108
108
|
try {
|
|
109
|
-
if (this.options.shimDisconnect && !
|
|
109
|
+
if (this.options.shimDisconnect && !this.storage?.getItem(this.shimDisconnectKey))
|
|
110
110
|
return false;
|
|
111
111
|
const account = await this.getAccount();
|
|
112
112
|
return !!account;
|
|
113
|
-
} catch
|
|
113
|
+
} catch {
|
|
114
114
|
return false;
|
|
115
115
|
}
|
|
116
116
|
}
|
|
@@ -124,6 +124,6 @@ var SafeConnector = class extends _chunkW65LBPLTjs.Connector {
|
|
|
124
124
|
};
|
|
125
125
|
_provider = new WeakMap();
|
|
126
126
|
_sdk = new WeakMap();
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
127
|
+
export {
|
|
128
|
+
SafeConnector
|
|
129
|
+
};
|
package/dist/walletConnect.js
CHANGED
|
@@ -1,51 +1,51 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import {
|
|
2
|
+
Connector,
|
|
3
|
+
__privateAdd,
|
|
4
|
+
__privateGet,
|
|
5
|
+
__privateMethod,
|
|
6
|
+
__privateSet
|
|
7
|
+
} from "./chunk-W65LBPLT.js";
|
|
8
8
|
|
|
9
9
|
// src/walletConnect.ts
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
10
|
+
import { normalizeNamespaces } from "@walletconnect/utils";
|
|
11
|
+
import {
|
|
12
|
+
SwitchChainError,
|
|
13
|
+
UserRejectedRequestError,
|
|
14
|
+
createWalletClient,
|
|
15
|
+
custom,
|
|
16
|
+
getAddress,
|
|
17
|
+
numberToHex
|
|
18
|
+
} from "viem";
|
|
19
19
|
var NAMESPACE = "eip155";
|
|
20
20
|
var STORE_KEY = "store";
|
|
21
21
|
var REQUESTED_CHAINS_KEY = "requestedChains";
|
|
22
22
|
var ADD_ETH_CHAIN_METHOD = "wallet_addEthereumChain";
|
|
23
23
|
var _provider, _initProviderPromise, _createProvider, createProvider_fn, _initProvider, initProvider_fn, _isChainsStale, isChainsStale_fn, _setupListeners, setupListeners_fn, _removeListeners, removeListeners_fn, _setRequestedChainsIds, setRequestedChainsIds_fn, _getRequestedChainsIds, getRequestedChainsIds_fn, _getNamespaceChainsIds, getNamespaceChainsIds_fn, _getNamespaceMethods, getNamespaceMethods_fn;
|
|
24
|
-
var WalletConnectConnector = class extends
|
|
24
|
+
var WalletConnectConnector = class extends Connector {
|
|
25
25
|
constructor(config) {
|
|
26
26
|
super({
|
|
27
27
|
...config,
|
|
28
28
|
options: { isNewChainsStale: true, ...config.options }
|
|
29
29
|
});
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
30
|
+
__privateAdd(this, _createProvider);
|
|
31
|
+
__privateAdd(this, _initProvider);
|
|
32
|
+
__privateAdd(this, _isChainsStale);
|
|
33
|
+
__privateAdd(this, _setupListeners);
|
|
34
|
+
__privateAdd(this, _removeListeners);
|
|
35
|
+
__privateAdd(this, _setRequestedChainsIds);
|
|
36
|
+
__privateAdd(this, _getRequestedChainsIds);
|
|
37
|
+
__privateAdd(this, _getNamespaceChainsIds);
|
|
38
|
+
__privateAdd(this, _getNamespaceMethods);
|
|
39
39
|
this.id = "walletConnect";
|
|
40
40
|
this.name = "WalletConnect";
|
|
41
41
|
this.ready = true;
|
|
42
|
-
|
|
43
|
-
|
|
42
|
+
__privateAdd(this, _provider, void 0);
|
|
43
|
+
__privateAdd(this, _initProviderPromise, void 0);
|
|
44
44
|
this.onAccountsChanged = (accounts) => {
|
|
45
45
|
if (accounts.length === 0)
|
|
46
46
|
this.emit("disconnect");
|
|
47
47
|
else
|
|
48
|
-
this.emit("change", { account:
|
|
48
|
+
this.emit("change", { account: getAddress(accounts[0]) });
|
|
49
49
|
};
|
|
50
50
|
this.onChainChanged = (chainId) => {
|
|
51
51
|
const id = Number(chainId);
|
|
@@ -53,7 +53,7 @@ var WalletConnectConnector = class extends _chunkW65LBPLTjs.Connector {
|
|
|
53
53
|
this.emit("change", { chain: { id, unsupported } });
|
|
54
54
|
};
|
|
55
55
|
this.onDisconnect = () => {
|
|
56
|
-
|
|
56
|
+
__privateMethod(this, _setRequestedChainsIds, setRequestedChainsIds_fn).call(this, []);
|
|
57
57
|
this.emit("disconnect");
|
|
58
58
|
};
|
|
59
59
|
this.onDisplayUri = (uri) => {
|
|
@@ -62,24 +62,24 @@ var WalletConnectConnector = class extends _chunkW65LBPLTjs.Connector {
|
|
|
62
62
|
this.onConnect = () => {
|
|
63
63
|
this.emit("connect", {});
|
|
64
64
|
};
|
|
65
|
-
|
|
65
|
+
__privateMethod(this, _createProvider, createProvider_fn).call(this);
|
|
66
66
|
}
|
|
67
67
|
async connect({ chainId, pairingTopic } = {}) {
|
|
68
68
|
try {
|
|
69
69
|
let targetChainId = chainId;
|
|
70
70
|
if (!targetChainId) {
|
|
71
|
-
const store =
|
|
72
|
-
const lastUsedChainId =
|
|
71
|
+
const store = this.storage?.getItem(STORE_KEY);
|
|
72
|
+
const lastUsedChainId = store?.state?.data?.chain?.id;
|
|
73
73
|
if (lastUsedChainId && !this.isChainUnsupported(lastUsedChainId))
|
|
74
74
|
targetChainId = lastUsedChainId;
|
|
75
75
|
else
|
|
76
|
-
targetChainId =
|
|
76
|
+
targetChainId = this.chains[0]?.id;
|
|
77
77
|
}
|
|
78
78
|
if (!targetChainId)
|
|
79
79
|
throw new Error("No chains found on connector.");
|
|
80
80
|
const provider = await this.getProvider();
|
|
81
|
-
|
|
82
|
-
const isChainsStale =
|
|
81
|
+
__privateMethod(this, _setupListeners, setupListeners_fn).call(this);
|
|
82
|
+
const isChainsStale = __privateMethod(this, _isChainsStale, isChainsStale_fn).call(this);
|
|
83
83
|
if (provider.session && isChainsStale)
|
|
84
84
|
await provider.disconnect();
|
|
85
85
|
if (!provider.session || isChainsStale) {
|
|
@@ -90,10 +90,10 @@ var WalletConnectConnector = class extends _chunkW65LBPLTjs.Connector {
|
|
|
90
90
|
chains: [targetChainId],
|
|
91
91
|
optionalChains: optionalChains.length ? optionalChains : void 0
|
|
92
92
|
});
|
|
93
|
-
|
|
93
|
+
__privateMethod(this, _setRequestedChainsIds, setRequestedChainsIds_fn).call(this, this.chains.map(({ id: id2 }) => id2));
|
|
94
94
|
}
|
|
95
95
|
const accounts = await provider.enable();
|
|
96
|
-
const account =
|
|
96
|
+
const account = getAddress(accounts[0]);
|
|
97
97
|
const id = await this.getChainId();
|
|
98
98
|
const unsupported = this.isChainUnsupported(id);
|
|
99
99
|
return {
|
|
@@ -101,8 +101,8 @@ var WalletConnectConnector = class extends _chunkW65LBPLTjs.Connector {
|
|
|
101
101
|
chain: { id, unsupported }
|
|
102
102
|
};
|
|
103
103
|
} catch (error) {
|
|
104
|
-
if (/user rejected/i.test(
|
|
105
|
-
throw new
|
|
104
|
+
if (/user rejected/i.test(error?.message)) {
|
|
105
|
+
throw new UserRejectedRequestError(error);
|
|
106
106
|
}
|
|
107
107
|
throw error;
|
|
108
108
|
}
|
|
@@ -115,24 +115,24 @@ var WalletConnectConnector = class extends _chunkW65LBPLTjs.Connector {
|
|
|
115
115
|
if (!/No matching key/i.test(error.message))
|
|
116
116
|
throw error;
|
|
117
117
|
} finally {
|
|
118
|
-
|
|
119
|
-
|
|
118
|
+
__privateMethod(this, _removeListeners, removeListeners_fn).call(this);
|
|
119
|
+
__privateMethod(this, _setRequestedChainsIds, setRequestedChainsIds_fn).call(this, []);
|
|
120
120
|
}
|
|
121
121
|
}
|
|
122
122
|
async getAccount() {
|
|
123
123
|
const { accounts } = await this.getProvider();
|
|
124
|
-
return
|
|
124
|
+
return getAddress(accounts[0]);
|
|
125
125
|
}
|
|
126
126
|
async getChainId() {
|
|
127
127
|
const { chainId } = await this.getProvider();
|
|
128
128
|
return chainId;
|
|
129
129
|
}
|
|
130
130
|
async getProvider({ chainId } = {}) {
|
|
131
|
-
if (!
|
|
132
|
-
await
|
|
131
|
+
if (!__privateGet(this, _provider))
|
|
132
|
+
await __privateMethod(this, _createProvider, createProvider_fn).call(this);
|
|
133
133
|
if (chainId)
|
|
134
134
|
await this.switchChain(chainId);
|
|
135
|
-
return
|
|
135
|
+
return __privateGet(this, _provider);
|
|
136
136
|
}
|
|
137
137
|
async getWalletClient({
|
|
138
138
|
chainId
|
|
@@ -144,10 +144,10 @@ var WalletConnectConnector = class extends _chunkW65LBPLTjs.Connector {
|
|
|
144
144
|
const chain = this.chains.find((x) => x.id === chainId);
|
|
145
145
|
if (!provider)
|
|
146
146
|
throw new Error("provider is required.");
|
|
147
|
-
return
|
|
147
|
+
return createWalletClient({
|
|
148
148
|
account,
|
|
149
149
|
chain,
|
|
150
|
-
transport:
|
|
150
|
+
transport: custom(provider)
|
|
151
151
|
});
|
|
152
152
|
}
|
|
153
153
|
async isAuthorized() {
|
|
@@ -156,58 +156,58 @@ var WalletConnectConnector = class extends _chunkW65LBPLTjs.Connector {
|
|
|
156
156
|
this.getAccount(),
|
|
157
157
|
this.getProvider()
|
|
158
158
|
]);
|
|
159
|
-
const isChainsStale =
|
|
159
|
+
const isChainsStale = __privateMethod(this, _isChainsStale, isChainsStale_fn).call(this);
|
|
160
160
|
if (!account)
|
|
161
161
|
return false;
|
|
162
162
|
if (isChainsStale && provider.session) {
|
|
163
163
|
try {
|
|
164
164
|
await provider.disconnect();
|
|
165
|
-
} catch
|
|
165
|
+
} catch {
|
|
166
166
|
}
|
|
167
167
|
return false;
|
|
168
168
|
}
|
|
169
169
|
return true;
|
|
170
|
-
} catch
|
|
170
|
+
} catch {
|
|
171
171
|
return false;
|
|
172
172
|
}
|
|
173
173
|
}
|
|
174
174
|
async switchChain(chainId) {
|
|
175
175
|
const chain = this.chains.find((chain2) => chain2.id === chainId);
|
|
176
176
|
if (!chain)
|
|
177
|
-
throw new
|
|
177
|
+
throw new SwitchChainError(new Error("chain not found on connector."));
|
|
178
178
|
try {
|
|
179
179
|
const provider = await this.getProvider();
|
|
180
|
-
const namespaceChains =
|
|
181
|
-
const namespaceMethods =
|
|
180
|
+
const namespaceChains = __privateMethod(this, _getNamespaceChainsIds, getNamespaceChainsIds_fn).call(this);
|
|
181
|
+
const namespaceMethods = __privateMethod(this, _getNamespaceMethods, getNamespaceMethods_fn).call(this);
|
|
182
182
|
const isChainApproved = namespaceChains.includes(chainId);
|
|
183
183
|
if (!isChainApproved && namespaceMethods.includes(ADD_ETH_CHAIN_METHOD)) {
|
|
184
184
|
await provider.request({
|
|
185
185
|
method: ADD_ETH_CHAIN_METHOD,
|
|
186
186
|
params: [
|
|
187
187
|
{
|
|
188
|
-
chainId:
|
|
189
|
-
blockExplorerUrls: [
|
|
188
|
+
chainId: numberToHex(chain.id),
|
|
189
|
+
blockExplorerUrls: [chain.blockExplorers?.default?.url],
|
|
190
190
|
chainName: chain.name,
|
|
191
191
|
nativeCurrency: chain.nativeCurrency,
|
|
192
192
|
rpcUrls: [...chain.rpcUrls.default.http]
|
|
193
193
|
}
|
|
194
194
|
]
|
|
195
195
|
});
|
|
196
|
-
const requestedChains =
|
|
196
|
+
const requestedChains = __privateMethod(this, _getRequestedChainsIds, getRequestedChainsIds_fn).call(this);
|
|
197
197
|
requestedChains.push(chainId);
|
|
198
|
-
|
|
198
|
+
__privateMethod(this, _setRequestedChainsIds, setRequestedChainsIds_fn).call(this, requestedChains);
|
|
199
199
|
}
|
|
200
200
|
await provider.request({
|
|
201
201
|
method: "wallet_switchEthereumChain",
|
|
202
|
-
params: [{ chainId:
|
|
202
|
+
params: [{ chainId: numberToHex(chainId) }]
|
|
203
203
|
});
|
|
204
204
|
return chain;
|
|
205
205
|
} catch (error) {
|
|
206
|
-
const message = typeof error === "string" ? error :
|
|
206
|
+
const message = typeof error === "string" ? error : error?.message;
|
|
207
207
|
if (/user rejected request/i.test(message)) {
|
|
208
|
-
throw new
|
|
208
|
+
throw new UserRejectedRequestError(error);
|
|
209
209
|
}
|
|
210
|
-
throw new
|
|
210
|
+
throw new SwitchChainError(error);
|
|
211
211
|
}
|
|
212
212
|
}
|
|
213
213
|
};
|
|
@@ -215,14 +215,14 @@ _provider = new WeakMap();
|
|
|
215
215
|
_initProviderPromise = new WeakMap();
|
|
216
216
|
_createProvider = new WeakSet();
|
|
217
217
|
createProvider_fn = async function() {
|
|
218
|
-
if (!
|
|
219
|
-
|
|
218
|
+
if (!__privateGet(this, _initProviderPromise) && typeof window !== "undefined") {
|
|
219
|
+
__privateSet(this, _initProviderPromise, __privateMethod(this, _initProvider, initProvider_fn).call(this));
|
|
220
220
|
}
|
|
221
|
-
return
|
|
221
|
+
return __privateGet(this, _initProviderPromise);
|
|
222
222
|
};
|
|
223
223
|
_initProvider = new WeakSet();
|
|
224
224
|
initProvider_fn = async function() {
|
|
225
|
-
const { EthereumProvider, OPTIONAL_EVENTS, OPTIONAL_METHODS } = await
|
|
225
|
+
const { EthereumProvider, OPTIONAL_EVENTS, OPTIONAL_METHODS } = await import("@walletconnect/ethereum-provider");
|
|
226
226
|
const [defaultChain, ...optionalChains] = this.chains.map(({ id }) => id);
|
|
227
227
|
if (defaultChain) {
|
|
228
228
|
const {
|
|
@@ -232,7 +232,7 @@ initProvider_fn = async function() {
|
|
|
232
232
|
metadata,
|
|
233
233
|
relayUrl
|
|
234
234
|
} = this.options;
|
|
235
|
-
|
|
235
|
+
__privateSet(this, _provider, await EthereumProvider.init({
|
|
236
236
|
showQrModal,
|
|
237
237
|
qrModalOptions,
|
|
238
238
|
projectId,
|
|
@@ -253,73 +253,73 @@ initProvider_fn = async function() {
|
|
|
253
253
|
};
|
|
254
254
|
_isChainsStale = new WeakSet();
|
|
255
255
|
isChainsStale_fn = function() {
|
|
256
|
-
const namespaceMethods =
|
|
256
|
+
const namespaceMethods = __privateMethod(this, _getNamespaceMethods, getNamespaceMethods_fn).call(this);
|
|
257
257
|
if (namespaceMethods.includes(ADD_ETH_CHAIN_METHOD))
|
|
258
258
|
return false;
|
|
259
259
|
if (!this.options.isNewChainsStale)
|
|
260
260
|
return false;
|
|
261
|
-
const requestedChains =
|
|
261
|
+
const requestedChains = __privateMethod(this, _getRequestedChainsIds, getRequestedChainsIds_fn).call(this);
|
|
262
262
|
const connectorChains = this.chains.map(({ id }) => id);
|
|
263
|
-
const namespaceChains =
|
|
263
|
+
const namespaceChains = __privateMethod(this, _getNamespaceChainsIds, getNamespaceChainsIds_fn).call(this);
|
|
264
264
|
if (namespaceChains.length && !namespaceChains.some((id) => connectorChains.includes(id)))
|
|
265
265
|
return false;
|
|
266
266
|
return !connectorChains.every((id) => requestedChains.includes(id));
|
|
267
267
|
};
|
|
268
268
|
_setupListeners = new WeakSet();
|
|
269
269
|
setupListeners_fn = function() {
|
|
270
|
-
if (!
|
|
270
|
+
if (!__privateGet(this, _provider))
|
|
271
271
|
return;
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
272
|
+
__privateMethod(this, _removeListeners, removeListeners_fn).call(this);
|
|
273
|
+
__privateGet(this, _provider).on("accountsChanged", this.onAccountsChanged);
|
|
274
|
+
__privateGet(this, _provider).on("chainChanged", this.onChainChanged);
|
|
275
|
+
__privateGet(this, _provider).on("disconnect", this.onDisconnect);
|
|
276
|
+
__privateGet(this, _provider).on("session_delete", this.onDisconnect);
|
|
277
|
+
__privateGet(this, _provider).on("display_uri", this.onDisplayUri);
|
|
278
|
+
__privateGet(this, _provider).on("connect", this.onConnect);
|
|
279
279
|
};
|
|
280
280
|
_removeListeners = new WeakSet();
|
|
281
281
|
removeListeners_fn = function() {
|
|
282
|
-
if (!
|
|
282
|
+
if (!__privateGet(this, _provider))
|
|
283
283
|
return;
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
284
|
+
__privateGet(this, _provider).removeListener("accountsChanged", this.onAccountsChanged);
|
|
285
|
+
__privateGet(this, _provider).removeListener("chainChanged", this.onChainChanged);
|
|
286
|
+
__privateGet(this, _provider).removeListener("disconnect", this.onDisconnect);
|
|
287
|
+
__privateGet(this, _provider).removeListener("session_delete", this.onDisconnect);
|
|
288
|
+
__privateGet(this, _provider).removeListener("display_uri", this.onDisplayUri);
|
|
289
|
+
__privateGet(this, _provider).removeListener("connect", this.onConnect);
|
|
290
290
|
};
|
|
291
291
|
_setRequestedChainsIds = new WeakSet();
|
|
292
292
|
setRequestedChainsIds_fn = function(chains) {
|
|
293
|
-
|
|
293
|
+
this.storage?.setItem(REQUESTED_CHAINS_KEY, chains);
|
|
294
294
|
};
|
|
295
295
|
_getRequestedChainsIds = new WeakSet();
|
|
296
296
|
getRequestedChainsIds_fn = function() {
|
|
297
|
-
return
|
|
297
|
+
return this.storage?.getItem(REQUESTED_CHAINS_KEY) ?? [];
|
|
298
298
|
};
|
|
299
299
|
_getNamespaceChainsIds = new WeakSet();
|
|
300
300
|
getNamespaceChainsIds_fn = function() {
|
|
301
|
-
if (!
|
|
301
|
+
if (!__privateGet(this, _provider))
|
|
302
302
|
return [];
|
|
303
|
-
const namespaces =
|
|
303
|
+
const namespaces = __privateGet(this, _provider).session?.namespaces;
|
|
304
304
|
if (!namespaces)
|
|
305
305
|
return [];
|
|
306
|
-
const normalizedNamespaces =
|
|
307
|
-
const chainIds =
|
|
306
|
+
const normalizedNamespaces = normalizeNamespaces(namespaces);
|
|
307
|
+
const chainIds = normalizedNamespaces[NAMESPACE]?.chains?.map(
|
|
308
308
|
(chain) => parseInt(chain.split(":")[1] || "")
|
|
309
|
-
)
|
|
310
|
-
return
|
|
309
|
+
);
|
|
310
|
+
return chainIds ?? [];
|
|
311
311
|
};
|
|
312
312
|
_getNamespaceMethods = new WeakSet();
|
|
313
313
|
getNamespaceMethods_fn = function() {
|
|
314
|
-
if (!
|
|
314
|
+
if (!__privateGet(this, _provider))
|
|
315
315
|
return [];
|
|
316
|
-
const namespaces =
|
|
316
|
+
const namespaces = __privateGet(this, _provider).session?.namespaces;
|
|
317
317
|
if (!namespaces)
|
|
318
318
|
return [];
|
|
319
|
-
const normalizedNamespaces =
|
|
320
|
-
const methods =
|
|
321
|
-
return
|
|
319
|
+
const normalizedNamespaces = normalizeNamespaces(namespaces);
|
|
320
|
+
const methods = normalizedNamespaces[NAMESPACE]?.methods;
|
|
321
|
+
return methods ?? [];
|
|
322
|
+
};
|
|
323
|
+
export {
|
|
324
|
+
WalletConnectConnector
|
|
322
325
|
};
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
exports.WalletConnectConnector = WalletConnectConnector;
|