@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.
@@ -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";
19
- var switchChainAllowedRegex = /(imtoken|metamask|rainbow|trust wallet)/i;
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
+ var switchChainAllowedRegex = /(imtoken|metamask|rainbow|trust wallet|uniswap wallet)/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,40 +88,40 @@ 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
116
  }
117
- return __privateGet(this, _provider);
117
+ return _chunk5NCTPR6Cjs.__privateGet.call(void 0, this, _provider);
118
118
  }
119
119
  async getSigner({ chainId } = {}) {
120
120
  const [provider, account] = await Promise.all([
121
121
  this.getProvider({ chainId }),
122
122
  this.getAccount()
123
123
  ]);
124
- return new providers.Web3Provider(
124
+ return new _ethers.providers.Web3Provider(
125
125
  provider,
126
126
  chainId
127
127
  ).getSigner(account);
@@ -130,7 +130,7 @@ var WalletConnectLegacyConnector = class extends Connector {
130
130
  try {
131
131
  const account = await this.getAccount();
132
132
  return !!account;
133
- } catch {
133
+ } catch (e) {
134
134
  return false;
135
135
  }
136
136
  }
@@ -139,7 +139,7 @@ _provider = new WeakMap();
139
139
  _switchChain = new WeakSet();
140
140
  switchChain_fn = async function(chainId) {
141
141
  const provider = await this.getProvider();
142
- const id = hexValue(chainId);
142
+ const id = _utilsjs.hexValue.call(void 0, chainId);
143
143
  try {
144
144
  await Promise.race([
145
145
  provider.request({
@@ -148,25 +148,25 @@ switchChain_fn = async function(chainId) {
148
148
  }),
149
149
  new Promise(
150
150
  (res) => this.on("change", ({ chain }) => {
151
- if (chain?.id === chainId)
151
+ if (_optionalChain([chain, 'optionalAccess', _8 => _8.id]) === chainId)
152
152
  res(chainId);
153
153
  })
154
154
  )
155
155
  ]);
156
- return this.chains.find((x) => x.id === chainId) ?? {
156
+ return _nullishCoalesce(this.chains.find((x) => x.id === chainId), () => ( {
157
157
  id: chainId,
158
158
  name: `Chain ${id}`,
159
159
  network: `${id}`,
160
160
  nativeCurrency: { name: "Ether", decimals: 18, symbol: "ETH" },
161
161
  rpcUrls: { default: { http: [""] }, public: { http: [""] } }
162
- };
162
+ }));
163
163
  } catch (error) {
164
- const message = typeof error === "string" ? error : error?.message;
164
+ const message = typeof error === "string" ? error : _optionalChain([error, 'optionalAccess', _9 => _9.message]);
165
165
  if (/user rejected request/i.test(message))
166
- throw new UserRejectedRequestError(error);
167
- throw new SwitchChainError(error);
166
+ throw new (0, _core.UserRejectedRequestError)(error);
167
+ throw new (0, _core.SwitchChainError)(error);
168
168
  }
169
169
  };
170
- export {
171
- WalletConnectLegacyConnector
172
- };
170
+
171
+
172
+ 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.2",
5
+ "version": "0.3.3-cjs",
6
6
  "peerDependencies": {
7
7
  "@wagmi/core": ">=0.9.x",
8
8
  "ethers": ">=5.5.1 <6",
@@ -19,7 +19,7 @@
19
19
  "dependencies": {
20
20
  "@coinbase/wallet-sdk": "^3.5.4",
21
21
  "@ledgerhq/connect-kit-loader": "^1.0.1",
22
- "@walletconnect/ethereum-provider": "^2.4.7",
22
+ "@walletconnect/ethereum-provider": "^2.4.8",
23
23
  "@walletconnect/legacy-provider": "^2.0.0",
24
24
  "@safe-global/safe-apps-provider": "^0.15.2",
25
25
  "@safe-global/safe-apps-sdk": "^7.9.0",
@@ -30,48 +30,8 @@
30
30
  "@wagmi/core": "^0.8.19",
31
31
  "ethers": "^5.7.2"
32
32
  },
33
- "type": "module",
34
33
  "main": "dist/index.js",
35
34
  "types": "dist/index.d.ts",
36
- "exports": {
37
- ".": {
38
- "types": "./dist/index.d.ts",
39
- "default": "./dist/index.js"
40
- },
41
- "./coinbaseWallet": {
42
- "types": "./dist/coinbaseWallet.d.ts",
43
- "default": "./dist/coinbaseWallet.js"
44
- },
45
- "./injected": {
46
- "types": "./dist/injected.d.ts",
47
- "default": "./dist/injected.js"
48
- },
49
- "./ledger": {
50
- "types": "./dist/ledger.d.ts",
51
- "default": "./dist/ledger.js"
52
- },
53
- "./metaMask": {
54
- "types": "./dist/metaMask.d.ts",
55
- "default": "./dist/metaMask.js"
56
- },
57
- "./mock": {
58
- "types": "./dist/mock/index.d.ts",
59
- "default": "./dist/mock/index.js"
60
- },
61
- "./safe": {
62
- "types": "./dist/safe.d.ts",
63
- "default": "./dist/safe.js"
64
- },
65
- "./walletConnect": {
66
- "types": "./dist/walletConnect.d.ts",
67
- "default": "./dist/walletConnect.js"
68
- },
69
- "./walletConnectLegacy": {
70
- "types": "./dist/walletConnectLegacy.d.ts",
71
- "default": "./dist/walletConnectLegacy.js"
72
- },
73
- "./package.json": "./package.json"
74
- },
75
35
  "files": [
76
36
  "/coinbaseWallet",
77
37
  "/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
  }