@wagmi/connectors 0.3.2 → 0.3.3-cjs
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/coinbaseWallet/package.json +1 -1
- package/dist/chunk-5NCTPR6C.js +14 -14
- package/dist/{chunk-CYQSS77O.js → chunk-RAYRYMYO.js} +77 -71
- package/dist/coinbaseWallet.js +59 -59
- package/dist/index.d.ts +1 -1
- package/dist/index.js +6 -6
- package/dist/injected.d.ts +1 -1
- package/dist/injected.js +7 -7
- package/dist/ledger.js +45 -45
- package/dist/metaMask.d.ts +1 -1
- package/dist/metaMask.js +34 -34
- package/dist/mock/index.js +62 -62
- package/dist/safe.js +45 -45
- package/dist/{types-47f9e468.d.ts → types-372079e0.d.ts} +2 -0
- package/dist/walletConnect.js +102 -102
- package/dist/walletConnectLegacy.js +54 -54
- package/injected/package.json +1 -1
- package/ledger/package.json +1 -1
- package/metaMask/package.json +1 -1
- package/mock/package.json +1 -1
- package/package.json +2 -42
- package/safe/package.json +1 -1
- package/walletConnect/package.json +1 -1
- package/walletConnectLegacy/package.json +1 -1
package/dist/safe.js
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
var _chunk5NCTPR6Cjs = require('./chunk-5NCTPR6C.js');
|
|
8
8
|
|
|
9
9
|
// src/safe.ts
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
10
|
+
var _safeappsprovider = require('@safe-global/safe-apps-provider');
|
|
11
|
+
var _safeappssdk = require('@safe-global/safe-apps-sdk'); var _safeappssdk2 = _interopRequireDefault(_safeappssdk);
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
var _core = require('@wagmi/core');
|
|
17
|
+
var _ethers = require('ethers');
|
|
18
|
+
var _utilsjs = require('ethers/lib/utils.js');
|
|
19
19
|
var _provider, _sdk;
|
|
20
|
-
var SafeConnector = class extends Connector {
|
|
20
|
+
var SafeConnector = class extends _chunk5NCTPR6Cjs.Connector {
|
|
21
21
|
constructor({
|
|
22
22
|
chains,
|
|
23
23
|
options: options_
|
|
@@ -27,21 +27,21 @@ var SafeConnector = class extends Connector {
|
|
|
27
27
|
...options_
|
|
28
28
|
};
|
|
29
29
|
super({ chains, options });
|
|
30
|
-
__publicField(this, "id", "safe");
|
|
31
|
-
__publicField(this, "name", "Safe");
|
|
32
|
-
__publicField(this, "ready", !(typeof window === "undefined") && window
|
|
33
|
-
__privateAdd(this, _provider, void 0);
|
|
34
|
-
__privateAdd(this, _sdk, void 0);
|
|
35
|
-
__publicField(this, "shimDisconnectKey", `${this.id}.shimDisconnect`);
|
|
36
|
-
let SDK =
|
|
37
|
-
if (typeof
|
|
38
|
-
SDK =
|
|
39
|
-
__privateSet(this, _sdk, new SDK(options));
|
|
30
|
+
_chunk5NCTPR6Cjs.__publicField.call(void 0, this, "id", "safe");
|
|
31
|
+
_chunk5NCTPR6Cjs.__publicField.call(void 0, this, "name", "Safe");
|
|
32
|
+
_chunk5NCTPR6Cjs.__publicField.call(void 0, this, "ready", !(typeof window === "undefined") && _optionalChain([window, 'optionalAccess', _ => _.parent]) !== window);
|
|
33
|
+
_chunk5NCTPR6Cjs.__privateAdd.call(void 0, this, _provider, void 0);
|
|
34
|
+
_chunk5NCTPR6Cjs.__privateAdd.call(void 0, this, _sdk, void 0);
|
|
35
|
+
_chunk5NCTPR6Cjs.__publicField.call(void 0, this, "shimDisconnectKey", `${this.id}.shimDisconnect`);
|
|
36
|
+
let SDK = _safeappssdk2.default;
|
|
37
|
+
if (typeof _safeappssdk2.default !== "function" && typeof _safeappssdk2.default.default === "function")
|
|
38
|
+
SDK = _safeappssdk2.default.default;
|
|
39
|
+
_chunk5NCTPR6Cjs.__privateSet.call(void 0, this, _sdk, new SDK(options));
|
|
40
40
|
}
|
|
41
41
|
async connect() {
|
|
42
42
|
const provider = await this.getProvider();
|
|
43
43
|
if (!provider)
|
|
44
|
-
throw new ConnectorNotFoundError();
|
|
44
|
+
throw new (0, _core.ConnectorNotFoundError)();
|
|
45
45
|
if (provider.on) {
|
|
46
46
|
provider.on("accountsChanged", this.onAccountsChanged);
|
|
47
47
|
provider.on("chainChanged", this.onChainChanged);
|
|
@@ -51,7 +51,7 @@ var SafeConnector = class extends Connector {
|
|
|
51
51
|
const account = await this.getAccount();
|
|
52
52
|
const id = await this.getChainId();
|
|
53
53
|
if (this.options.shimDisconnect)
|
|
54
|
-
getClient().storage
|
|
54
|
+
_optionalChain([_core.getClient.call(void 0, ), 'access', _2 => _2.storage, 'optionalAccess', _3 => _3.setItem, 'call', _4 => _4(this.shimDisconnectKey, true)]);
|
|
55
55
|
return {
|
|
56
56
|
account,
|
|
57
57
|
provider,
|
|
@@ -60,50 +60,50 @@ var SafeConnector = class extends Connector {
|
|
|
60
60
|
}
|
|
61
61
|
async disconnect() {
|
|
62
62
|
const provider = await this.getProvider();
|
|
63
|
-
if (!provider
|
|
63
|
+
if (!_optionalChain([provider, 'optionalAccess', _5 => _5.removeListener]))
|
|
64
64
|
return;
|
|
65
65
|
provider.removeListener("accountsChanged", this.onAccountsChanged);
|
|
66
66
|
provider.removeListener("chainChanged", this.onChainChanged);
|
|
67
67
|
provider.removeListener("disconnect", this.onDisconnect);
|
|
68
68
|
if (this.options.shimDisconnect)
|
|
69
|
-
getClient().storage
|
|
69
|
+
_optionalChain([_core.getClient.call(void 0, ), 'access', _6 => _6.storage, 'optionalAccess', _7 => _7.removeItem, 'call', _8 => _8(this.shimDisconnectKey)]);
|
|
70
70
|
}
|
|
71
71
|
async getAccount() {
|
|
72
72
|
const provider = await this.getProvider();
|
|
73
73
|
if (!provider)
|
|
74
|
-
throw new ConnectorNotFoundError();
|
|
74
|
+
throw new (0, _core.ConnectorNotFoundError)();
|
|
75
75
|
const accounts = await provider.request({
|
|
76
76
|
method: "eth_accounts"
|
|
77
77
|
});
|
|
78
|
-
return getAddress(accounts[0]);
|
|
78
|
+
return _utilsjs.getAddress.call(void 0, accounts[0]);
|
|
79
79
|
}
|
|
80
80
|
async getChainId() {
|
|
81
81
|
const provider = await this.getProvider();
|
|
82
82
|
if (!provider)
|
|
83
|
-
throw new ConnectorNotFoundError();
|
|
84
|
-
return normalizeChainId(provider.chainId);
|
|
83
|
+
throw new (0, _core.ConnectorNotFoundError)();
|
|
84
|
+
return _core.normalizeChainId.call(void 0, provider.chainId);
|
|
85
85
|
}
|
|
86
86
|
async getProvider() {
|
|
87
|
-
if (!__privateGet(this, _provider)) {
|
|
88
|
-
const safe = await __privateGet(this, _sdk).safe.getInfo();
|
|
87
|
+
if (!_chunk5NCTPR6Cjs.__privateGet.call(void 0, this, _provider)) {
|
|
88
|
+
const safe = await _chunk5NCTPR6Cjs.__privateGet.call(void 0, this, _sdk).safe.getInfo();
|
|
89
89
|
if (!safe)
|
|
90
90
|
throw new Error("Could not load Safe information");
|
|
91
|
-
__privateSet(this, _provider, new SafeAppProvider(safe, __privateGet(this, _sdk)));
|
|
91
|
+
_chunk5NCTPR6Cjs.__privateSet.call(void 0, this, _provider, new (0, _safeappsprovider.SafeAppProvider)(safe, _chunk5NCTPR6Cjs.__privateGet.call(void 0, this, _sdk)));
|
|
92
92
|
}
|
|
93
|
-
return __privateGet(this, _provider);
|
|
93
|
+
return _chunk5NCTPR6Cjs.__privateGet.call(void 0, this, _provider);
|
|
94
94
|
}
|
|
95
95
|
async getSigner() {
|
|
96
96
|
const provider = await this.getProvider();
|
|
97
97
|
const account = await this.getAccount();
|
|
98
|
-
return new providers.Web3Provider(provider).getSigner(account);
|
|
98
|
+
return new _ethers.providers.Web3Provider(provider).getSigner(account);
|
|
99
99
|
}
|
|
100
100
|
async isAuthorized() {
|
|
101
101
|
try {
|
|
102
|
-
if (this.options.shimDisconnect && !getClient().storage
|
|
102
|
+
if (this.options.shimDisconnect && !_optionalChain([_core.getClient.call(void 0, ), 'access', _9 => _9.storage, 'optionalAccess', _10 => _10.getItem, 'call', _11 => _11(this.shimDisconnectKey)]))
|
|
103
103
|
return false;
|
|
104
104
|
const account = await this.getAccount();
|
|
105
105
|
return !!account;
|
|
106
|
-
} catch {
|
|
106
|
+
} catch (e) {
|
|
107
107
|
return false;
|
|
108
108
|
}
|
|
109
109
|
}
|
|
@@ -117,6 +117,6 @@ var SafeConnector = class extends Connector {
|
|
|
117
117
|
};
|
|
118
118
|
_provider = new WeakMap();
|
|
119
119
|
_sdk = new WeakMap();
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
exports.SafeConnector = SafeConnector;
|
|
@@ -43,6 +43,7 @@ type WatchAssetParams = {
|
|
|
43
43
|
type InjectedProviderFlags = {
|
|
44
44
|
isApexWallet?: true;
|
|
45
45
|
isAvalanche?: true;
|
|
46
|
+
isBifrost?: true;
|
|
46
47
|
isBitKeep?: true;
|
|
47
48
|
isBitski?: true;
|
|
48
49
|
isBraveWallet?: true;
|
|
@@ -59,6 +60,7 @@ type InjectedProviderFlags = {
|
|
|
59
60
|
isPhantom?: true;
|
|
60
61
|
isPortal?: true;
|
|
61
62
|
isRainbow?: true;
|
|
63
|
+
isStatus?: true;
|
|
62
64
|
isTally?: true;
|
|
63
65
|
isTokenPocket?: true;
|
|
64
66
|
isTokenary?: true;
|
package/dist/walletConnect.js
CHANGED
|
@@ -1,82 +1,82 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
var _chunk5NCTPR6Cjs = require('./chunk-5NCTPR6C.js');
|
|
9
9
|
|
|
10
10
|
// src/walletConnect.ts
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
var _core = require('@wagmi/core');
|
|
16
|
+
var _ethers = require('ethers');
|
|
17
|
+
var _utilsjs = require('ethers/lib/utils.js');
|
|
18
18
|
var NAMESPACE = "eip155";
|
|
19
19
|
var REQUESTED_CHAINS_KEY = "wagmi.requestedChains";
|
|
20
20
|
var ADD_ETH_CHAIN_METHOD = "wallet_addEthereumChain";
|
|
21
21
|
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;
|
|
22
|
-
var WalletConnectConnector = class extends Connector {
|
|
22
|
+
var WalletConnectConnector = class extends _chunk5NCTPR6Cjs.Connector {
|
|
23
23
|
constructor(config) {
|
|
24
24
|
super({
|
|
25
25
|
...config,
|
|
26
26
|
options: { isNewChainsStale: true, ...config.options }
|
|
27
27
|
});
|
|
28
|
-
__privateAdd(this, _createProvider);
|
|
29
|
-
__privateAdd(this, _initProvider);
|
|
30
|
-
__privateAdd(this, _isChainsStale);
|
|
31
|
-
__privateAdd(this, _setupListeners);
|
|
32
|
-
__privateAdd(this, _removeListeners);
|
|
33
|
-
__privateAdd(this, _setRequestedChainsIds);
|
|
34
|
-
__privateAdd(this, _getRequestedChainsIds);
|
|
35
|
-
__privateAdd(this, _getNamespaceChainsIds);
|
|
36
|
-
__privateAdd(this, _getNamespaceMethods);
|
|
37
|
-
__publicField(this, "id", "walletConnect");
|
|
38
|
-
__publicField(this, "name", "WalletConnect");
|
|
39
|
-
__publicField(this, "ready", true);
|
|
40
|
-
__privateAdd(this, _provider, void 0);
|
|
41
|
-
__privateAdd(this, _initProviderPromise, void 0);
|
|
42
|
-
__publicField(this, "onAccountsChanged", (accounts) => {
|
|
28
|
+
_chunk5NCTPR6Cjs.__privateAdd.call(void 0, this, _createProvider);
|
|
29
|
+
_chunk5NCTPR6Cjs.__privateAdd.call(void 0, this, _initProvider);
|
|
30
|
+
_chunk5NCTPR6Cjs.__privateAdd.call(void 0, this, _isChainsStale);
|
|
31
|
+
_chunk5NCTPR6Cjs.__privateAdd.call(void 0, this, _setupListeners);
|
|
32
|
+
_chunk5NCTPR6Cjs.__privateAdd.call(void 0, this, _removeListeners);
|
|
33
|
+
_chunk5NCTPR6Cjs.__privateAdd.call(void 0, this, _setRequestedChainsIds);
|
|
34
|
+
_chunk5NCTPR6Cjs.__privateAdd.call(void 0, this, _getRequestedChainsIds);
|
|
35
|
+
_chunk5NCTPR6Cjs.__privateAdd.call(void 0, this, _getNamespaceChainsIds);
|
|
36
|
+
_chunk5NCTPR6Cjs.__privateAdd.call(void 0, this, _getNamespaceMethods);
|
|
37
|
+
_chunk5NCTPR6Cjs.__publicField.call(void 0, this, "id", "walletConnect");
|
|
38
|
+
_chunk5NCTPR6Cjs.__publicField.call(void 0, this, "name", "WalletConnect");
|
|
39
|
+
_chunk5NCTPR6Cjs.__publicField.call(void 0, this, "ready", true);
|
|
40
|
+
_chunk5NCTPR6Cjs.__privateAdd.call(void 0, this, _provider, void 0);
|
|
41
|
+
_chunk5NCTPR6Cjs.__privateAdd.call(void 0, this, _initProviderPromise, void 0);
|
|
42
|
+
_chunk5NCTPR6Cjs.__publicField.call(void 0, this, "onAccountsChanged", (accounts) => {
|
|
43
43
|
if (accounts.length === 0)
|
|
44
44
|
this.emit("disconnect");
|
|
45
45
|
else
|
|
46
|
-
this.emit("change", { account: getAddress(accounts[0]) });
|
|
46
|
+
this.emit("change", { account: _utilsjs.getAddress.call(void 0, accounts[0]) });
|
|
47
47
|
});
|
|
48
|
-
__publicField(this, "onChainChanged", (chainId) => {
|
|
48
|
+
_chunk5NCTPR6Cjs.__publicField.call(void 0, this, "onChainChanged", (chainId) => {
|
|
49
49
|
const id = Number(chainId);
|
|
50
50
|
const unsupported = this.isChainUnsupported(id);
|
|
51
51
|
this.emit("change", { chain: { id, unsupported } });
|
|
52
52
|
});
|
|
53
|
-
__publicField(this, "onDisconnect", () => {
|
|
54
|
-
__privateMethod(this, _setRequestedChainsIds, setRequestedChainsIds_fn).call(this, []);
|
|
53
|
+
_chunk5NCTPR6Cjs.__publicField.call(void 0, this, "onDisconnect", () => {
|
|
54
|
+
_chunk5NCTPR6Cjs.__privateMethod.call(void 0, this, _setRequestedChainsIds, setRequestedChainsIds_fn).call(this, []);
|
|
55
55
|
this.emit("disconnect");
|
|
56
56
|
});
|
|
57
|
-
__publicField(this, "onDisplayUri", (uri) => {
|
|
57
|
+
_chunk5NCTPR6Cjs.__publicField.call(void 0, this, "onDisplayUri", (uri) => {
|
|
58
58
|
this.emit("message", { type: "display_uri", data: uri });
|
|
59
59
|
});
|
|
60
|
-
__publicField(this, "onConnect", () => {
|
|
61
|
-
this.emit("connect", { provider: __privateGet(this, _provider) });
|
|
60
|
+
_chunk5NCTPR6Cjs.__publicField.call(void 0, this, "onConnect", () => {
|
|
61
|
+
this.emit("connect", { provider: _chunk5NCTPR6Cjs.__privateGet.call(void 0, this, _provider) });
|
|
62
62
|
});
|
|
63
|
-
__privateMethod(this, _createProvider, createProvider_fn).call(this);
|
|
63
|
+
_chunk5NCTPR6Cjs.__privateMethod.call(void 0, this, _createProvider, createProvider_fn).call(this);
|
|
64
64
|
}
|
|
65
65
|
async connect({ chainId, pairingTopic } = {}) {
|
|
66
66
|
try {
|
|
67
67
|
let targetChainId = chainId;
|
|
68
68
|
if (!targetChainId) {
|
|
69
|
-
const lastUsedChainId = getClient().lastUsedChainId;
|
|
69
|
+
const lastUsedChainId = _core.getClient.call(void 0, ).lastUsedChainId;
|
|
70
70
|
if (lastUsedChainId && !this.isChainUnsupported(lastUsedChainId))
|
|
71
71
|
targetChainId = lastUsedChainId;
|
|
72
72
|
else
|
|
73
|
-
targetChainId = this.chains[0]
|
|
73
|
+
targetChainId = _optionalChain([this, 'access', _ => _.chains, 'access', _2 => _2[0], 'optionalAccess', _3 => _3.id]);
|
|
74
74
|
}
|
|
75
75
|
if (!targetChainId)
|
|
76
76
|
throw new Error("No chains found on connector.");
|
|
77
77
|
const provider = await this.getProvider();
|
|
78
|
-
__privateMethod(this, _setupListeners, setupListeners_fn).call(this);
|
|
79
|
-
const isChainsStale = __privateMethod(this, _isChainsStale, isChainsStale_fn).call(this);
|
|
78
|
+
_chunk5NCTPR6Cjs.__privateMethod.call(void 0, this, _setupListeners, setupListeners_fn).call(this);
|
|
79
|
+
const isChainsStale = _chunk5NCTPR6Cjs.__privateMethod.call(void 0, this, _isChainsStale, isChainsStale_fn).call(this);
|
|
80
80
|
if (provider.session && isChainsStale)
|
|
81
81
|
await provider.disconnect();
|
|
82
82
|
if (!provider.session || isChainsStale) {
|
|
@@ -87,20 +87,20 @@ var WalletConnectConnector = class extends Connector {
|
|
|
87
87
|
chains: [targetChainId],
|
|
88
88
|
optionalChains
|
|
89
89
|
});
|
|
90
|
-
__privateMethod(this, _setRequestedChainsIds, setRequestedChainsIds_fn).call(this, this.chains.map(({ id: id2 }) => id2));
|
|
90
|
+
_chunk5NCTPR6Cjs.__privateMethod.call(void 0, this, _setRequestedChainsIds, setRequestedChainsIds_fn).call(this, this.chains.map(({ id: id2 }) => id2));
|
|
91
91
|
}
|
|
92
92
|
const accounts = await provider.enable();
|
|
93
|
-
const account = getAddress(accounts[0]);
|
|
93
|
+
const account = _utilsjs.getAddress.call(void 0, accounts[0]);
|
|
94
94
|
const id = await this.getChainId();
|
|
95
95
|
const unsupported = this.isChainUnsupported(id);
|
|
96
96
|
return {
|
|
97
97
|
account,
|
|
98
98
|
chain: { id, unsupported },
|
|
99
|
-
provider: new providers.Web3Provider(provider)
|
|
99
|
+
provider: new _ethers.providers.Web3Provider(provider)
|
|
100
100
|
};
|
|
101
101
|
} catch (error) {
|
|
102
|
-
if (/user rejected/i.test(error
|
|
103
|
-
throw new UserRejectedRequestError(error);
|
|
102
|
+
if (/user rejected/i.test(_optionalChain([error, 'optionalAccess', _4 => _4.message]))) {
|
|
103
|
+
throw new (0, _core.UserRejectedRequestError)(error);
|
|
104
104
|
}
|
|
105
105
|
throw error;
|
|
106
106
|
}
|
|
@@ -113,31 +113,31 @@ var WalletConnectConnector = class extends Connector {
|
|
|
113
113
|
if (!/No matching key/i.test(error.message))
|
|
114
114
|
throw error;
|
|
115
115
|
} finally {
|
|
116
|
-
__privateMethod(this, _removeListeners, removeListeners_fn).call(this);
|
|
117
|
-
__privateMethod(this, _setRequestedChainsIds, setRequestedChainsIds_fn).call(this, []);
|
|
116
|
+
_chunk5NCTPR6Cjs.__privateMethod.call(void 0, this, _removeListeners, removeListeners_fn).call(this);
|
|
117
|
+
_chunk5NCTPR6Cjs.__privateMethod.call(void 0, this, _setRequestedChainsIds, setRequestedChainsIds_fn).call(this, []);
|
|
118
118
|
}
|
|
119
119
|
}
|
|
120
120
|
async getAccount() {
|
|
121
121
|
const { accounts } = await this.getProvider();
|
|
122
|
-
return getAddress(accounts[0]);
|
|
122
|
+
return _utilsjs.getAddress.call(void 0, accounts[0]);
|
|
123
123
|
}
|
|
124
124
|
async getChainId() {
|
|
125
125
|
const { chainId } = await this.getProvider();
|
|
126
126
|
return chainId;
|
|
127
127
|
}
|
|
128
128
|
async getProvider({ chainId } = {}) {
|
|
129
|
-
if (!__privateGet(this, _provider))
|
|
130
|
-
await __privateMethod(this, _createProvider, createProvider_fn).call(this);
|
|
129
|
+
if (!_chunk5NCTPR6Cjs.__privateGet.call(void 0, this, _provider))
|
|
130
|
+
await _chunk5NCTPR6Cjs.__privateMethod.call(void 0, this, _createProvider, createProvider_fn).call(this);
|
|
131
131
|
if (chainId)
|
|
132
132
|
await this.switchChain(chainId);
|
|
133
|
-
return __privateGet(this, _provider);
|
|
133
|
+
return _chunk5NCTPR6Cjs.__privateGet.call(void 0, this, _provider);
|
|
134
134
|
}
|
|
135
135
|
async getSigner({ chainId } = {}) {
|
|
136
136
|
const [provider, account] = await Promise.all([
|
|
137
137
|
this.getProvider({ chainId }),
|
|
138
138
|
this.getAccount()
|
|
139
139
|
]);
|
|
140
|
-
return new providers.Web3Provider(provider, chainId).getSigner(account);
|
|
140
|
+
return new _ethers.providers.Web3Provider(provider, chainId).getSigner(account);
|
|
141
141
|
}
|
|
142
142
|
async isAuthorized() {
|
|
143
143
|
try {
|
|
@@ -145,58 +145,58 @@ var WalletConnectConnector = class extends Connector {
|
|
|
145
145
|
this.getAccount(),
|
|
146
146
|
this.getProvider()
|
|
147
147
|
]);
|
|
148
|
-
const isChainsStale = __privateMethod(this, _isChainsStale, isChainsStale_fn).call(this);
|
|
148
|
+
const isChainsStale = _chunk5NCTPR6Cjs.__privateMethod.call(void 0, this, _isChainsStale, isChainsStale_fn).call(this);
|
|
149
149
|
if (!account)
|
|
150
150
|
return false;
|
|
151
151
|
if (isChainsStale && provider.session) {
|
|
152
152
|
try {
|
|
153
153
|
await provider.disconnect();
|
|
154
|
-
} catch {
|
|
154
|
+
} catch (e) {
|
|
155
155
|
}
|
|
156
156
|
return false;
|
|
157
157
|
}
|
|
158
158
|
return true;
|
|
159
|
-
} catch {
|
|
159
|
+
} catch (e2) {
|
|
160
160
|
return false;
|
|
161
161
|
}
|
|
162
162
|
}
|
|
163
163
|
async switchChain(chainId) {
|
|
164
164
|
const chain = this.chains.find((chain2) => chain2.id === chainId);
|
|
165
165
|
if (!chain)
|
|
166
|
-
throw new SwitchChainError(new Error("chain not found on connector."));
|
|
166
|
+
throw new (0, _core.SwitchChainError)(new Error("chain not found on connector."));
|
|
167
167
|
try {
|
|
168
168
|
const provider = await this.getProvider();
|
|
169
|
-
const namespaceChains = __privateMethod(this, _getNamespaceChainsIds, getNamespaceChainsIds_fn).call(this);
|
|
170
|
-
const namespaceMethods = __privateMethod(this, _getNamespaceMethods, getNamespaceMethods_fn).call(this);
|
|
169
|
+
const namespaceChains = _chunk5NCTPR6Cjs.__privateMethod.call(void 0, this, _getNamespaceChainsIds, getNamespaceChainsIds_fn).call(this);
|
|
170
|
+
const namespaceMethods = _chunk5NCTPR6Cjs.__privateMethod.call(void 0, this, _getNamespaceMethods, getNamespaceMethods_fn).call(this);
|
|
171
171
|
const isChainApproved = namespaceChains.includes(chainId);
|
|
172
172
|
if (!isChainApproved && namespaceMethods.includes(ADD_ETH_CHAIN_METHOD)) {
|
|
173
173
|
await provider.request({
|
|
174
174
|
method: ADD_ETH_CHAIN_METHOD,
|
|
175
175
|
params: [
|
|
176
176
|
{
|
|
177
|
-
chainId: hexValue(chain.id),
|
|
178
|
-
blockExplorerUrls: [chain.blockExplorers
|
|
177
|
+
chainId: _utilsjs.hexValue.call(void 0, chain.id),
|
|
178
|
+
blockExplorerUrls: [_optionalChain([chain, 'access', _5 => _5.blockExplorers, 'optionalAccess', _6 => _6.default])],
|
|
179
179
|
chainName: chain.name,
|
|
180
180
|
nativeCurrency: chain.nativeCurrency,
|
|
181
181
|
rpcUrls: [...chain.rpcUrls.default.http]
|
|
182
182
|
}
|
|
183
183
|
]
|
|
184
184
|
});
|
|
185
|
-
const requestedChains = __privateMethod(this, _getRequestedChainsIds, getRequestedChainsIds_fn).call(this);
|
|
185
|
+
const requestedChains = _chunk5NCTPR6Cjs.__privateMethod.call(void 0, this, _getRequestedChainsIds, getRequestedChainsIds_fn).call(this);
|
|
186
186
|
requestedChains.push(chainId);
|
|
187
|
-
__privateMethod(this, _setRequestedChainsIds, setRequestedChainsIds_fn).call(this, requestedChains);
|
|
187
|
+
_chunk5NCTPR6Cjs.__privateMethod.call(void 0, this, _setRequestedChainsIds, setRequestedChainsIds_fn).call(this, requestedChains);
|
|
188
188
|
}
|
|
189
189
|
await provider.request({
|
|
190
190
|
method: "wallet_switchEthereumChain",
|
|
191
|
-
params: [{ chainId: hexValue(chainId) }]
|
|
191
|
+
params: [{ chainId: _utilsjs.hexValue.call(void 0, chainId) }]
|
|
192
192
|
});
|
|
193
193
|
return chain;
|
|
194
194
|
} catch (error) {
|
|
195
|
-
const message = typeof error === "string" ? error : error
|
|
195
|
+
const message = typeof error === "string" ? error : _optionalChain([error, 'optionalAccess', _7 => _7.message]);
|
|
196
196
|
if (/user rejected request/i.test(message)) {
|
|
197
|
-
throw new UserRejectedRequestError(error);
|
|
197
|
+
throw new (0, _core.UserRejectedRequestError)(error);
|
|
198
198
|
}
|
|
199
|
-
throw new SwitchChainError(error);
|
|
199
|
+
throw new (0, _core.SwitchChainError)(error);
|
|
200
200
|
}
|
|
201
201
|
}
|
|
202
202
|
};
|
|
@@ -204,10 +204,10 @@ _provider = new WeakMap();
|
|
|
204
204
|
_initProviderPromise = new WeakMap();
|
|
205
205
|
_createProvider = new WeakSet();
|
|
206
206
|
createProvider_fn = async function() {
|
|
207
|
-
if (!__privateGet(this, _initProviderPromise) && typeof window !== "undefined") {
|
|
208
|
-
__privateSet(this, _initProviderPromise, __privateMethod(this, _initProvider, initProvider_fn).call(this));
|
|
207
|
+
if (!_chunk5NCTPR6Cjs.__privateGet.call(void 0, this, _initProviderPromise) && typeof window !== "undefined") {
|
|
208
|
+
_chunk5NCTPR6Cjs.__privateSet.call(void 0, this, _initProviderPromise, _chunk5NCTPR6Cjs.__privateMethod.call(void 0, this, _initProvider, initProvider_fn).call(this));
|
|
209
209
|
}
|
|
210
|
-
return __privateGet(this, _initProviderPromise);
|
|
210
|
+
return _chunk5NCTPR6Cjs.__privateGet.call(void 0, this, _initProviderPromise);
|
|
211
211
|
};
|
|
212
212
|
_initProvider = new WeakSet();
|
|
213
213
|
initProvider_fn = async function() {
|
|
@@ -215,11 +215,11 @@ initProvider_fn = async function() {
|
|
|
215
215
|
default: EthereumProvider,
|
|
216
216
|
OPTIONAL_EVENTS,
|
|
217
217
|
OPTIONAL_METHODS
|
|
218
|
-
} = await
|
|
218
|
+
} = await Promise.resolve().then(() => require("@walletconnect/ethereum-provider"));
|
|
219
219
|
const [defaultChain, ...optionalChains] = this.chains.map(({ id }) => id);
|
|
220
220
|
if (defaultChain) {
|
|
221
221
|
const { projectId, showQrModal } = this.options;
|
|
222
|
-
__privateSet(this, _provider, await EthereumProvider.init({
|
|
222
|
+
_chunk5NCTPR6Cjs.__privateSet.call(void 0, this, _provider, await EthereumProvider.init({
|
|
223
223
|
showQrModal,
|
|
224
224
|
projectId,
|
|
225
225
|
optionalMethods: OPTIONAL_METHODS,
|
|
@@ -237,40 +237,40 @@ initProvider_fn = async function() {
|
|
|
237
237
|
};
|
|
238
238
|
_isChainsStale = new WeakSet();
|
|
239
239
|
isChainsStale_fn = function() {
|
|
240
|
-
const namespaceMethods = __privateMethod(this, _getNamespaceMethods, getNamespaceMethods_fn).call(this);
|
|
240
|
+
const namespaceMethods = _chunk5NCTPR6Cjs.__privateMethod.call(void 0, this, _getNamespaceMethods, getNamespaceMethods_fn).call(this);
|
|
241
241
|
if (namespaceMethods.includes(ADD_ETH_CHAIN_METHOD))
|
|
242
242
|
return false;
|
|
243
243
|
if (!this.options.isNewChainsStale)
|
|
244
244
|
return false;
|
|
245
|
-
const requestedChains = __privateMethod(this, _getRequestedChainsIds, getRequestedChainsIds_fn).call(this);
|
|
245
|
+
const requestedChains = _chunk5NCTPR6Cjs.__privateMethod.call(void 0, this, _getRequestedChainsIds, getRequestedChainsIds_fn).call(this);
|
|
246
246
|
const connectorChains = this.chains.map(({ id }) => id);
|
|
247
|
-
const namespaceChains = __privateMethod(this, _getNamespaceChainsIds, getNamespaceChainsIds_fn).call(this);
|
|
247
|
+
const namespaceChains = _chunk5NCTPR6Cjs.__privateMethod.call(void 0, this, _getNamespaceChainsIds, getNamespaceChainsIds_fn).call(this);
|
|
248
248
|
if (namespaceChains.length && !namespaceChains.some((id) => connectorChains.includes(id)))
|
|
249
249
|
return false;
|
|
250
250
|
return !connectorChains.every((id) => requestedChains.includes(id));
|
|
251
251
|
};
|
|
252
252
|
_setupListeners = new WeakSet();
|
|
253
253
|
setupListeners_fn = function() {
|
|
254
|
-
if (!__privateGet(this, _provider))
|
|
254
|
+
if (!_chunk5NCTPR6Cjs.__privateGet.call(void 0, this, _provider))
|
|
255
255
|
return;
|
|
256
|
-
__privateMethod(this, _removeListeners, removeListeners_fn).call(this);
|
|
257
|
-
__privateGet(this, _provider).on("accountsChanged", this.onAccountsChanged);
|
|
258
|
-
__privateGet(this, _provider).on("chainChanged", this.onChainChanged);
|
|
259
|
-
__privateGet(this, _provider).on("disconnect", this.onDisconnect);
|
|
260
|
-
__privateGet(this, _provider).on("session_delete", this.onDisconnect);
|
|
261
|
-
__privateGet(this, _provider).on("display_uri", this.onDisplayUri);
|
|
262
|
-
__privateGet(this, _provider).on("connect", this.onConnect);
|
|
256
|
+
_chunk5NCTPR6Cjs.__privateMethod.call(void 0, this, _removeListeners, removeListeners_fn).call(this);
|
|
257
|
+
_chunk5NCTPR6Cjs.__privateGet.call(void 0, this, _provider).on("accountsChanged", this.onAccountsChanged);
|
|
258
|
+
_chunk5NCTPR6Cjs.__privateGet.call(void 0, this, _provider).on("chainChanged", this.onChainChanged);
|
|
259
|
+
_chunk5NCTPR6Cjs.__privateGet.call(void 0, this, _provider).on("disconnect", this.onDisconnect);
|
|
260
|
+
_chunk5NCTPR6Cjs.__privateGet.call(void 0, this, _provider).on("session_delete", this.onDisconnect);
|
|
261
|
+
_chunk5NCTPR6Cjs.__privateGet.call(void 0, this, _provider).on("display_uri", this.onDisplayUri);
|
|
262
|
+
_chunk5NCTPR6Cjs.__privateGet.call(void 0, this, _provider).on("connect", this.onConnect);
|
|
263
263
|
};
|
|
264
264
|
_removeListeners = new WeakSet();
|
|
265
265
|
removeListeners_fn = function() {
|
|
266
|
-
if (!__privateGet(this, _provider))
|
|
266
|
+
if (!_chunk5NCTPR6Cjs.__privateGet.call(void 0, this, _provider))
|
|
267
267
|
return;
|
|
268
|
-
__privateGet(this, _provider).removeListener("accountsChanged", this.onAccountsChanged);
|
|
269
|
-
__privateGet(this, _provider).removeListener("chainChanged", this.onChainChanged);
|
|
270
|
-
__privateGet(this, _provider).removeListener("disconnect", this.onDisconnect);
|
|
271
|
-
__privateGet(this, _provider).removeListener("session_delete", this.onDisconnect);
|
|
272
|
-
__privateGet(this, _provider).removeListener("display_uri", this.onDisplayUri);
|
|
273
|
-
__privateGet(this, _provider).removeListener("connect", this.onConnect);
|
|
268
|
+
_chunk5NCTPR6Cjs.__privateGet.call(void 0, this, _provider).removeListener("accountsChanged", this.onAccountsChanged);
|
|
269
|
+
_chunk5NCTPR6Cjs.__privateGet.call(void 0, this, _provider).removeListener("chainChanged", this.onChainChanged);
|
|
270
|
+
_chunk5NCTPR6Cjs.__privateGet.call(void 0, this, _provider).removeListener("disconnect", this.onDisconnect);
|
|
271
|
+
_chunk5NCTPR6Cjs.__privateGet.call(void 0, this, _provider).removeListener("session_delete", this.onDisconnect);
|
|
272
|
+
_chunk5NCTPR6Cjs.__privateGet.call(void 0, this, _provider).removeListener("display_uri", this.onDisplayUri);
|
|
273
|
+
_chunk5NCTPR6Cjs.__privateGet.call(void 0, this, _provider).removeListener("connect", this.onConnect);
|
|
274
274
|
};
|
|
275
275
|
_setRequestedChainsIds = new WeakSet();
|
|
276
276
|
setRequestedChainsIds_fn = function(chains) {
|
|
@@ -283,20 +283,20 @@ getRequestedChainsIds_fn = function() {
|
|
|
283
283
|
};
|
|
284
284
|
_getNamespaceChainsIds = new WeakSet();
|
|
285
285
|
getNamespaceChainsIds_fn = function() {
|
|
286
|
-
if (!__privateGet(this, _provider))
|
|
286
|
+
if (!_chunk5NCTPR6Cjs.__privateGet.call(void 0, this, _provider))
|
|
287
287
|
return [];
|
|
288
|
-
const chainIds = __privateGet(this, _provider).session
|
|
288
|
+
const chainIds = _optionalChain([_chunk5NCTPR6Cjs.__privateGet.call(void 0, this, _provider), 'access', _8 => _8.session, 'optionalAccess', _9 => _9.namespaces, 'access', _10 => _10[NAMESPACE], 'optionalAccess', _11 => _11.chains, 'optionalAccess', _12 => _12.map, 'call', _13 => _13(
|
|
289
289
|
(chain) => parseInt(chain.split(":")[1] || "")
|
|
290
|
-
);
|
|
291
|
-
return chainIds
|
|
290
|
+
)]);
|
|
291
|
+
return _nullishCoalesce(chainIds, () => ( []));
|
|
292
292
|
};
|
|
293
293
|
_getNamespaceMethods = new WeakSet();
|
|
294
294
|
getNamespaceMethods_fn = function() {
|
|
295
|
-
if (!__privateGet(this, _provider))
|
|
295
|
+
if (!_chunk5NCTPR6Cjs.__privateGet.call(void 0, this, _provider))
|
|
296
296
|
return [];
|
|
297
|
-
const methods = __privateGet(this, _provider).session
|
|
298
|
-
return methods
|
|
299
|
-
};
|
|
300
|
-
export {
|
|
301
|
-
WalletConnectConnector
|
|
297
|
+
const methods = _optionalChain([_chunk5NCTPR6Cjs.__privateGet.call(void 0, this, _provider), 'access', _14 => _14.session, 'optionalAccess', _15 => _15.namespaces, 'access', _16 => _16[NAMESPACE], 'optionalAccess', _17 => _17.methods]);
|
|
298
|
+
return _nullishCoalesce(methods, () => ( []));
|
|
302
299
|
};
|
|
300
|
+
|
|
301
|
+
|
|
302
|
+
exports.WalletConnectConnector = WalletConnectConnector;
|