@wagmi/connectors 0.3.13 → 0.3.14-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.
@@ -1,43 +1,43 @@
1
- import {
2
- Connector,
3
- __privateAdd,
4
- __privateGet,
5
- __privateMethod,
6
- __privateSet,
7
- __publicField
8
- } from "./chunk-5NCTPR6C.js";
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/walletConnectLegacy.ts
11
- import {
12
- SwitchChainError,
13
- UserRejectedRequestError,
14
- getClient,
15
- normalizeChainId
16
- } from "@wagmi/core";
17
- import { providers } from "ethers";
18
- import { getAddress, hexValue } from "ethers/lib/utils.js";
11
+
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 switchChainAllowedRegex = /(imtoken|metamask|rainbow|trust wallet|uniswap wallet|ledger)/i;
20
20
  var _provider, _switchChain, switchChain_fn;
21
- var WalletConnectLegacyConnector = class extends Connector {
21
+ var WalletConnectLegacyConnector = class extends _chunk5NCTPR6Cjs.Connector {
22
22
  constructor(config) {
23
23
  super(config);
24
- __privateAdd(this, _switchChain);
25
- __publicField(this, "id", "walletConnectLegacy");
26
- __publicField(this, "name", "WalletConnectLegacy");
27
- __publicField(this, "ready", true);
28
- __privateAdd(this, _provider, void 0);
29
- __publicField(this, "onAccountsChanged", (accounts) => {
24
+ _chunk5NCTPR6Cjs.__privateAdd.call(void 0, this, _switchChain);
25
+ _chunk5NCTPR6Cjs.__publicField.call(void 0, this, "id", "walletConnectLegacy");
26
+ _chunk5NCTPR6Cjs.__publicField.call(void 0, this, "name", "WalletConnectLegacy");
27
+ _chunk5NCTPR6Cjs.__publicField.call(void 0, this, "ready", true);
28
+ _chunk5NCTPR6Cjs.__privateAdd.call(void 0, this, _provider, void 0);
29
+ _chunk5NCTPR6Cjs.__publicField.call(void 0, this, "onAccountsChanged", (accounts) => {
30
30
  if (accounts.length === 0)
31
31
  this.emit("disconnect");
32
32
  else
33
- this.emit("change", { account: getAddress(accounts[0]) });
33
+ this.emit("change", { account: _utilsjs.getAddress.call(void 0, accounts[0]) });
34
34
  });
35
- __publicField(this, "onChainChanged", (chainId) => {
36
- const id = normalizeChainId(chainId);
35
+ _chunk5NCTPR6Cjs.__publicField.call(void 0, this, "onChainChanged", (chainId) => {
36
+ const id = _core.normalizeChainId.call(void 0, chainId);
37
37
  const unsupported = this.isChainUnsupported(id);
38
38
  this.emit("change", { chain: { id, unsupported } });
39
39
  });
40
- __publicField(this, "onDisconnect", () => {
40
+ _chunk5NCTPR6Cjs.__publicField.call(void 0, this, "onDisconnect", () => {
41
41
  this.emit("disconnect");
42
42
  });
43
43
  }
@@ -45,7 +45,7 @@ var WalletConnectLegacyConnector = class extends Connector {
45
45
  try {
46
46
  let targetChainId = chainId;
47
47
  if (!targetChainId) {
48
- const lastUsedChainId = getClient().lastUsedChainId;
48
+ const lastUsedChainId = _core.getClient.call(void 0, ).lastUsedChainId;
49
49
  if (lastUsedChainId && !this.isChainUnsupported(lastUsedChainId))
50
50
  targetChainId = lastUsedChainId;
51
51
  }
@@ -58,22 +58,22 @@ var WalletConnectLegacyConnector = class extends Connector {
58
58
  provider.on("disconnect", this.onDisconnect);
59
59
  setTimeout(() => this.emit("message", { type: "connecting" }), 0);
60
60
  const accounts = await provider.enable();
61
- const account = getAddress(accounts[0]);
61
+ const account = _utilsjs.getAddress.call(void 0, accounts[0]);
62
62
  const id = await this.getChainId();
63
63
  const unsupported = this.isChainUnsupported(id);
64
- const walletName = provider.connector?.peerMeta?.name ?? "";
64
+ const walletName = _nullishCoalesce(_optionalChain([provider, 'access', _ => _.connector, 'optionalAccess', _2 => _2.peerMeta, 'optionalAccess', _3 => _3.name]), () => ( ""));
65
65
  if (switchChainAllowedRegex.test(walletName))
66
- this.switchChain = __privateMethod(this, _switchChain, switchChain_fn);
66
+ this.switchChain = _chunk5NCTPR6Cjs.__privateMethod.call(void 0, this, _switchChain, switchChain_fn);
67
67
  return {
68
68
  account,
69
69
  chain: { id, unsupported },
70
- provider: new providers.Web3Provider(
70
+ provider: new _ethers.providers.Web3Provider(
71
71
  provider
72
72
  )
73
73
  };
74
74
  } catch (error) {
75
75
  if (/user closed modal/i.test(error.message))
76
- throw new UserRejectedRequestError(error);
76
+ throw new (0, _core.UserRejectedRequestError)(error);
77
77
  throw error;
78
78
  }
79
79
  }
@@ -88,41 +88,41 @@ var WalletConnectLegacyConnector = class extends Connector {
88
88
  async getAccount() {
89
89
  const provider = await this.getProvider();
90
90
  const accounts = provider.accounts;
91
- return getAddress(accounts[0]);
91
+ return _utilsjs.getAddress.call(void 0, accounts[0]);
92
92
  }
93
93
  async getChainId() {
94
94
  const provider = await this.getProvider();
95
- const chainId = normalizeChainId(provider.chainId);
95
+ const chainId = _core.normalizeChainId.call(void 0, provider.chainId);
96
96
  return chainId;
97
97
  }
98
98
  async getProvider({
99
99
  chainId,
100
100
  create
101
101
  } = {}) {
102
- if (!__privateGet(this, _provider) || chainId || create) {
103
- const rpc = !this.options?.infuraId ? this.chains.reduce(
102
+ if (!_chunk5NCTPR6Cjs.__privateGet.call(void 0, this, _provider) || chainId || create) {
103
+ const rpc = !_optionalChain([this, 'access', _4 => _4.options, 'optionalAccess', _5 => _5.infuraId]) ? this.chains.reduce(
104
104
  (rpc2, chain) => ({
105
105
  ...rpc2,
106
106
  [chain.id]: chain.rpcUrls.default.http[0]
107
107
  }),
108
108
  {}
109
109
  ) : {};
110
- const WalletConnectProvider = (await import("@walletconnect/legacy-provider")).default;
111
- __privateSet(this, _provider, new WalletConnectProvider({
110
+ const WalletConnectProvider = (await Promise.resolve().then(() => require("@walletconnect/legacy-provider"))).default;
111
+ _chunk5NCTPR6Cjs.__privateSet.call(void 0, this, _provider, new WalletConnectProvider({
112
112
  ...this.options,
113
113
  chainId,
114
- rpc: { ...rpc, ...this.options?.rpc }
114
+ rpc: { ...rpc, ..._optionalChain([this, 'access', _6 => _6.options, 'optionalAccess', _7 => _7.rpc]) }
115
115
  }));
116
- __privateGet(this, _provider).http = await __privateGet(this, _provider).setHttpProvider(chainId);
116
+ _chunk5NCTPR6Cjs.__privateGet.call(void 0, this, _provider).http = await _chunk5NCTPR6Cjs.__privateGet.call(void 0, this, _provider).setHttpProvider(chainId);
117
117
  }
118
- return __privateGet(this, _provider);
118
+ return _chunk5NCTPR6Cjs.__privateGet.call(void 0, this, _provider);
119
119
  }
120
120
  async getSigner({ chainId } = {}) {
121
121
  const [provider, account] = await Promise.all([
122
122
  this.getProvider({ chainId }),
123
123
  this.getAccount()
124
124
  ]);
125
- return new providers.Web3Provider(
125
+ return new _ethers.providers.Web3Provider(
126
126
  provider,
127
127
  chainId
128
128
  ).getSigner(account);
@@ -131,7 +131,7 @@ var WalletConnectLegacyConnector = class extends Connector {
131
131
  try {
132
132
  const account = await this.getAccount();
133
133
  return !!account;
134
- } catch {
134
+ } catch (e) {
135
135
  return false;
136
136
  }
137
137
  }
@@ -140,7 +140,7 @@ _provider = new WeakMap();
140
140
  _switchChain = new WeakSet();
141
141
  switchChain_fn = async function(chainId) {
142
142
  const provider = await this.getProvider();
143
- const id = hexValue(chainId);
143
+ const id = _utilsjs.hexValue.call(void 0, chainId);
144
144
  try {
145
145
  await Promise.race([
146
146
  provider.request({
@@ -149,25 +149,25 @@ switchChain_fn = async function(chainId) {
149
149
  }),
150
150
  new Promise(
151
151
  (res) => this.on("change", ({ chain }) => {
152
- if (chain?.id === chainId)
152
+ if (_optionalChain([chain, 'optionalAccess', _8 => _8.id]) === chainId)
153
153
  res(chainId);
154
154
  })
155
155
  )
156
156
  ]);
157
- return this.chains.find((x) => x.id === chainId) ?? {
157
+ return _nullishCoalesce(this.chains.find((x) => x.id === chainId), () => ( {
158
158
  id: chainId,
159
159
  name: `Chain ${id}`,
160
160
  network: `${id}`,
161
161
  nativeCurrency: { name: "Ether", decimals: 18, symbol: "ETH" },
162
162
  rpcUrls: { default: { http: [""] }, public: { http: [""] } }
163
- };
163
+ }));
164
164
  } catch (error) {
165
- const message = typeof error === "string" ? error : error?.message;
165
+ const message = typeof error === "string" ? error : _optionalChain([error, 'optionalAccess', _9 => _9.message]);
166
166
  if (/user rejected request/i.test(message))
167
- throw new UserRejectedRequestError(error);
168
- throw new SwitchChainError(error);
167
+ throw new (0, _core.UserRejectedRequestError)(error);
168
+ throw new (0, _core.SwitchChainError)(error);
169
169
  }
170
170
  };
171
- export {
172
- WalletConnectLegacyConnector
173
- };
171
+
172
+
173
+ exports.WalletConnectLegacyConnector = WalletConnectLegacyConnector;
@@ -1,4 +1,4 @@
1
1
  {
2
- "type": "module",
2
+ "module": "../dist/injected.mjs",
3
3
  "main": "../dist/injected.js"
4
4
  }
@@ -1,4 +1,4 @@
1
1
  {
2
- "type": "module",
2
+ "module": "../dist/ledger.mjs",
3
3
  "main": "../dist/ledger.js"
4
4
  }
@@ -1,4 +1,4 @@
1
1
  {
2
- "type": "module",
2
+ "module": "../dist/metaMask.mjs",
3
3
  "main": "../dist/metaMask.js"
4
4
  }
package/mock/package.json CHANGED
@@ -1,4 +1,4 @@
1
1
  {
2
- "type": "module",
2
+ "module": "../dist/mock/index.mjs",
3
3
  "main": "../dist/mock/index.js"
4
4
  }
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@wagmi/connectors",
3
3
  "description": "A collection of connectors for wagmi",
4
4
  "license": "MIT",
5
- "version": "0.3.13",
5
+ "version": "0.3.14-cjs",
6
6
  "peerDependencies": {
7
7
  "@wagmi/core": ">=0.9.x",
8
8
  "ethers": ">=5.5.1 <6",
@@ -19,9 +19,9 @@
19
19
  "dependencies": {
20
20
  "@coinbase/wallet-sdk": "^3.6.4",
21
21
  "@ledgerhq/connect-kit-loader": "^1.0.1",
22
- "@walletconnect/ethereum-provider": "2.6.2",
22
+ "@walletconnect/ethereum-provider": "2.7.0",
23
23
  "@walletconnect/legacy-provider": "^2.0.0",
24
- "@web3modal/standalone": "^2.2.2",
24
+ "@web3modal/standalone": "^2.3.0",
25
25
  "@safe-global/safe-apps-provider": "^0.15.2",
26
26
  "@safe-global/safe-apps-sdk": "^7.9.0",
27
27
  "abitype": "^0.3.0",
@@ -31,48 +31,8 @@
31
31
  "@wagmi/core": "^0.8.19",
32
32
  "ethers": "^5.7.2"
33
33
  },
34
- "type": "module",
35
34
  "main": "dist/index.js",
36
35
  "types": "dist/index.d.ts",
37
- "exports": {
38
- ".": {
39
- "types": "./dist/index.d.ts",
40
- "default": "./dist/index.js"
41
- },
42
- "./coinbaseWallet": {
43
- "types": "./dist/coinbaseWallet.d.ts",
44
- "default": "./dist/coinbaseWallet.js"
45
- },
46
- "./injected": {
47
- "types": "./dist/injected.d.ts",
48
- "default": "./dist/injected.js"
49
- },
50
- "./ledger": {
51
- "types": "./dist/ledger.d.ts",
52
- "default": "./dist/ledger.js"
53
- },
54
- "./metaMask": {
55
- "types": "./dist/metaMask.d.ts",
56
- "default": "./dist/metaMask.js"
57
- },
58
- "./mock": {
59
- "types": "./dist/mock/index.d.ts",
60
- "default": "./dist/mock/index.js"
61
- },
62
- "./safe": {
63
- "types": "./dist/safe.d.ts",
64
- "default": "./dist/safe.js"
65
- },
66
- "./walletConnect": {
67
- "types": "./dist/walletConnect.d.ts",
68
- "default": "./dist/walletConnect.js"
69
- },
70
- "./walletConnectLegacy": {
71
- "types": "./dist/walletConnectLegacy.d.ts",
72
- "default": "./dist/walletConnectLegacy.js"
73
- },
74
- "./package.json": "./package.json"
75
- },
76
36
  "files": [
77
37
  "/coinbaseWallet",
78
38
  "/injected",
package/safe/package.json CHANGED
@@ -1,4 +1,4 @@
1
1
  {
2
- "type": "module",
2
+ "module": "../dist/safe.mjs",
3
3
  "main": "../dist/safe.js"
4
4
  }
@@ -1,4 +1,4 @@
1
1
  {
2
- "type": "module",
2
+ "module": "../dist/walletConnect.mjs",
3
3
  "main": "../dist/walletConnect.js"
4
4
  }
@@ -1,4 +1,4 @@
1
1
  {
2
- "type": "module",
2
+ "module": "../dist/walletConnectLegacy.mjs",
3
3
  "main": "../dist/walletConnectLegacy.js"
4
4
  }