@wagmi/core 0.2.0-next.6 → 0.2.0-next.9

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.
Files changed (97) hide show
  1. package/connectors/coinbaseWallet/dist/wagmi-core-connectors-coinbaseWallet.cjs.d.ts +11 -1
  2. package/connectors/coinbaseWallet/dist/wagmi-core-connectors-coinbaseWallet.cjs.js +15 -6
  3. package/connectors/mock/dist/wagmi-core-connectors-mock.cjs.d.ts +11 -1
  4. package/connectors/mock/dist/wagmi-core-connectors-mock.cjs.js +15 -6
  5. package/connectors/walletConnect/dist/wagmi-core-connectors-walletConnect.cjs.d.ts +11 -1
  6. package/connectors/walletConnect/dist/wagmi-core-connectors-walletConnect.cjs.js +15 -6
  7. package/dist/wagmi-core.cjs.d.ts +11 -1
  8. package/dist/wagmi-core.cjs.js +15 -6
  9. package/package.json +2 -3
  10. package/connectors/coinbaseWallet/dist/wagmi-core-connectors-coinbaseWallet.cjs.dev.js +0 -253
  11. package/connectors/coinbaseWallet/dist/wagmi-core-connectors-coinbaseWallet.cjs.prod.js +0 -253
  12. package/connectors/coinbaseWallet/dist/wagmi-core-connectors-coinbaseWallet.esm.js +0 -231
  13. package/connectors/mock/dist/wagmi-core-connectors-mock.cjs.dev.js +0 -304
  14. package/connectors/mock/dist/wagmi-core-connectors-mock.cjs.prod.js +0 -304
  15. package/connectors/mock/dist/wagmi-core-connectors-mock.esm.js +0 -295
  16. package/connectors/walletConnect/dist/wagmi-core-connectors-walletConnect.cjs.dev.js +0 -215
  17. package/connectors/walletConnect/dist/wagmi-core-connectors-walletConnect.cjs.prod.js +0 -215
  18. package/connectors/walletConnect/dist/wagmi-core-connectors-walletConnect.esm.js +0 -193
  19. package/dist/base-09a653f3.cjs.dev.js +0 -453
  20. package/dist/base-824c3b6d.esm.js +0 -430
  21. package/dist/base-d8123d5f.cjs.prod.js +0 -453
  22. package/dist/classPrivateMethodGet-0e9a7925.cjs.prod.js +0 -19
  23. package/dist/classPrivateMethodGet-38b54c7a.cjs.dev.js +0 -19
  24. package/dist/classPrivateMethodGet-c9db96d6.esm.js +0 -16
  25. package/dist/declarations/src/actions/accounts/connect.d.ts +0 -7
  26. package/dist/declarations/src/actions/accounts/disconnect.d.ts +0 -1
  27. package/dist/declarations/src/actions/accounts/fetchBalance.d.ts +0 -18
  28. package/dist/declarations/src/actions/accounts/fetchSigner.d.ts +0 -3
  29. package/dist/declarations/src/actions/accounts/getAccount.d.ts +0 -6
  30. package/dist/declarations/src/actions/accounts/getNetwork.d.ts +0 -9
  31. package/dist/declarations/src/actions/accounts/index.d.ts +0 -13
  32. package/dist/declarations/src/actions/accounts/signMessage.d.ts +0 -9
  33. package/dist/declarations/src/actions/accounts/signTypedData.d.ts +0 -13
  34. package/dist/declarations/src/actions/accounts/switchNetwork.d.ts +0 -6
  35. package/dist/declarations/src/actions/accounts/watchAccount.d.ts +0 -3
  36. package/dist/declarations/src/actions/accounts/watchBalance.d.ts +0 -3
  37. package/dist/declarations/src/actions/accounts/watchNetwork.d.ts +0 -3
  38. package/dist/declarations/src/actions/accounts/watchSigner.d.ts +0 -3
  39. package/dist/declarations/src/actions/contracts/getContract.d.ts +0 -11
  40. package/dist/declarations/src/actions/contracts/index.d.ts +0 -5
  41. package/dist/declarations/src/actions/contracts/readContract.d.ts +0 -11
  42. package/dist/declarations/src/actions/contracts/watchContractEvent.d.ts +0 -12
  43. package/dist/declarations/src/actions/contracts/watchReadContract.d.ts +0 -7
  44. package/dist/declarations/src/actions/contracts/writeContract.d.ts +0 -11
  45. package/dist/declarations/src/actions/ens/fetchEnsAddress.d.ts +0 -6
  46. package/dist/declarations/src/actions/ens/fetchEnsAvatar.d.ts +0 -6
  47. package/dist/declarations/src/actions/ens/fetchEnsName.d.ts +0 -6
  48. package/dist/declarations/src/actions/ens/fetchEnsResolver.d.ts +0 -7
  49. package/dist/declarations/src/actions/ens/index.d.ts +0 -8
  50. package/dist/declarations/src/actions/ens/watchEnsAddress.d.ts +0 -3
  51. package/dist/declarations/src/actions/ens/watchEnsAvatar.d.ts +0 -3
  52. package/dist/declarations/src/actions/ens/watchEnsName.d.ts +0 -3
  53. package/dist/declarations/src/actions/ens/watchEnsResolver.d.ts +0 -3
  54. package/dist/declarations/src/actions/index.d.ts +0 -7
  55. package/dist/declarations/src/actions/network-status/fetchBlockNumber.d.ts +0 -2
  56. package/dist/declarations/src/actions/network-status/fetchFeeData.d.ts +0 -14
  57. package/dist/declarations/src/actions/network-status/index.d.ts +0 -4
  58. package/dist/declarations/src/actions/network-status/watchBlockNumber.d.ts +0 -6
  59. package/dist/declarations/src/actions/network-status/watchFeeData.d.ts +0 -7
  60. package/dist/declarations/src/actions/providers/getProvider.d.ts +0 -3
  61. package/dist/declarations/src/actions/providers/getWebSocketProvider.d.ts +0 -3
  62. package/dist/declarations/src/actions/providers/index.d.ts +0 -4
  63. package/dist/declarations/src/actions/providers/watchProvider.d.ts +0 -3
  64. package/dist/declarations/src/actions/providers/watchWebSocketProvider.d.ts +0 -3
  65. package/dist/declarations/src/actions/tokens/fetchToken.d.ts +0 -24
  66. package/dist/declarations/src/actions/tokens/index.d.ts +0 -2
  67. package/dist/declarations/src/actions/tokens/watchToken.d.ts +0 -3
  68. package/dist/declarations/src/actions/transactions/index.d.ts +0 -2
  69. package/dist/declarations/src/actions/transactions/sendTransaction.d.ts +0 -7
  70. package/dist/declarations/src/actions/transactions/waitForTransaction.d.ts +0 -15
  71. package/dist/declarations/src/client.d.ts +0 -80
  72. package/dist/declarations/src/connectors/base.d.ts +0 -51
  73. package/dist/declarations/src/connectors/coinbaseWallet.d.ts +0 -43
  74. package/dist/declarations/src/connectors/index.d.ts +0 -2
  75. package/dist/declarations/src/connectors/injected.d.ts +0 -55
  76. package/dist/declarations/src/connectors/mock/connector.d.ts +0 -37
  77. package/dist/declarations/src/connectors/mock/index.d.ts +0 -2
  78. package/dist/declarations/src/connectors/mock/provider.d.ts +0 -40
  79. package/dist/declarations/src/connectors/walletConnect.d.ts +0 -32
  80. package/dist/declarations/src/constants/abis/erc1155.d.ts +0 -17
  81. package/dist/declarations/src/constants/abis/erc20.d.ts +0 -38
  82. package/dist/declarations/src/constants/abis/erc721.d.ts +0 -15
  83. package/dist/declarations/src/constants/abis/index.d.ts +0 -3
  84. package/dist/declarations/src/constants/chains.d.ts +0 -10
  85. package/dist/declarations/src/constants/index.d.ts +0 -3
  86. package/dist/declarations/src/constants/units.d.ts +0 -1
  87. package/dist/declarations/src/errors.d.ts +0 -28
  88. package/dist/declarations/src/index.d.ts +0 -9
  89. package/dist/declarations/src/storage.d.ts +0 -12
  90. package/dist/declarations/src/types/declarations.d.ts +0 -52
  91. package/dist/declarations/src/types/index.d.ts +0 -14
  92. package/dist/declarations/src/utils/getInjectedName.d.ts +0 -1
  93. package/dist/declarations/src/utils/index.d.ts +0 -2
  94. package/dist/declarations/src/utils/normalizeChainId.d.ts +0 -1
  95. package/dist/wagmi-core.cjs.dev.js +0 -1697
  96. package/dist/wagmi-core.cjs.prod.js +0 -1697
  97. package/dist/wagmi-core.esm.js +0 -1631
@@ -1 +1,11 @@
1
- export * from "../../../dist/declarations/src/connectors/coinbaseWallet";
1
+ // are you seeing an error that a default export doesn't exist but your source file has a default export?
2
+ // you should run `yarn` or `yarn preconstruct dev` if preconstruct dev isn't in your postinstall hook
3
+
4
+ // curious why you need to?
5
+ // this file exists so that you can import from the entrypoint normally
6
+ // except that it points to your source file and you don't need to run build constantly
7
+ // which means we need to re-export all of the modules from your source file
8
+ // and since export * doesn't include default exports, we need to read your source file
9
+ // to check for a default export and re-export it if it exists
10
+ // it's not ideal, but it works pretty well ¯\_(ツ)_/¯
11
+ export * from "../../../src/connectors/coinbaseWallet";
@@ -1,7 +1,16 @@
1
- 'use strict';
1
+ "use strict";
2
+ // this file might look strange and you might be wondering what it's for
3
+ // it's lets you import your source files by importing this entrypoint
4
+ // as you would import it if it was built with preconstruct build
5
+ // this file is slightly different to some others though
6
+ // it has a require hook which compiles your code with Babel
7
+ // this means that you don't have to set up @babel/register or anything like that
8
+ // but you can still require this module and it'll be compiled
2
9
 
3
- if (process.env.NODE_ENV === "production") {
4
- module.exports = require("./wagmi-core-connectors-coinbaseWallet.cjs.prod.js");
5
- } else {
6
- module.exports = require("./wagmi-core-connectors-coinbaseWallet.cjs.dev.js");
7
- }
10
+ // this bit of code imports the require hook and registers it
11
+ let unregister = require("../../../../../node_modules/.pnpm/@preconstruct+hook@0.4.0/node_modules/@preconstruct/hook").___internalHook(typeof __dirname === 'undefined' ? undefined : __dirname, "../../../../..", "../../..");
12
+
13
+ // this re-exports the source file
14
+ module.exports = require("../../../src/connectors/coinbaseWallet.ts");
15
+
16
+ unregister();
@@ -1 +1,11 @@
1
- export * from "../../../dist/declarations/src/connectors/mock/index";
1
+ // are you seeing an error that a default export doesn't exist but your source file has a default export?
2
+ // you should run `yarn` or `yarn preconstruct dev` if preconstruct dev isn't in your postinstall hook
3
+
4
+ // curious why you need to?
5
+ // this file exists so that you can import from the entrypoint normally
6
+ // except that it points to your source file and you don't need to run build constantly
7
+ // which means we need to re-export all of the modules from your source file
8
+ // and since export * doesn't include default exports, we need to read your source file
9
+ // to check for a default export and re-export it if it exists
10
+ // it's not ideal, but it works pretty well ¯\_(ツ)_/¯
11
+ export * from "../../../src/connectors/mock/index";
@@ -1,7 +1,16 @@
1
- 'use strict';
1
+ "use strict";
2
+ // this file might look strange and you might be wondering what it's for
3
+ // it's lets you import your source files by importing this entrypoint
4
+ // as you would import it if it was built with preconstruct build
5
+ // this file is slightly different to some others though
6
+ // it has a require hook which compiles your code with Babel
7
+ // this means that you don't have to set up @babel/register or anything like that
8
+ // but you can still require this module and it'll be compiled
2
9
 
3
- if (process.env.NODE_ENV === "production") {
4
- module.exports = require("./wagmi-core-connectors-mock.cjs.prod.js");
5
- } else {
6
- module.exports = require("./wagmi-core-connectors-mock.cjs.dev.js");
7
- }
10
+ // this bit of code imports the require hook and registers it
11
+ let unregister = require("../../../../../node_modules/.pnpm/@preconstruct+hook@0.4.0/node_modules/@preconstruct/hook").___internalHook(typeof __dirname === 'undefined' ? undefined : __dirname, "../../../../..", "../../..");
12
+
13
+ // this re-exports the source file
14
+ module.exports = require("../../../src/connectors/mock/index.ts");
15
+
16
+ unregister();
@@ -1 +1,11 @@
1
- export * from "../../../dist/declarations/src/connectors/walletConnect";
1
+ // are you seeing an error that a default export doesn't exist but your source file has a default export?
2
+ // you should run `yarn` or `yarn preconstruct dev` if preconstruct dev isn't in your postinstall hook
3
+
4
+ // curious why you need to?
5
+ // this file exists so that you can import from the entrypoint normally
6
+ // except that it points to your source file and you don't need to run build constantly
7
+ // which means we need to re-export all of the modules from your source file
8
+ // and since export * doesn't include default exports, we need to read your source file
9
+ // to check for a default export and re-export it if it exists
10
+ // it's not ideal, but it works pretty well ¯\_(ツ)_/¯
11
+ export * from "../../../src/connectors/walletConnect";
@@ -1,7 +1,16 @@
1
- 'use strict';
1
+ "use strict";
2
+ // this file might look strange and you might be wondering what it's for
3
+ // it's lets you import your source files by importing this entrypoint
4
+ // as you would import it if it was built with preconstruct build
5
+ // this file is slightly different to some others though
6
+ // it has a require hook which compiles your code with Babel
7
+ // this means that you don't have to set up @babel/register or anything like that
8
+ // but you can still require this module and it'll be compiled
2
9
 
3
- if (process.env.NODE_ENV === "production") {
4
- module.exports = require("./wagmi-core-connectors-walletConnect.cjs.prod.js");
5
- } else {
6
- module.exports = require("./wagmi-core-connectors-walletConnect.cjs.dev.js");
7
- }
10
+ // this bit of code imports the require hook and registers it
11
+ let unregister = require("../../../../../node_modules/.pnpm/@preconstruct+hook@0.4.0/node_modules/@preconstruct/hook").___internalHook(typeof __dirname === 'undefined' ? undefined : __dirname, "../../../../..", "../../..");
12
+
13
+ // this re-exports the source file
14
+ module.exports = require("../../../src/connectors/walletConnect.ts");
15
+
16
+ unregister();
@@ -1 +1,11 @@
1
- export * from "./declarations/src/index";
1
+ // are you seeing an error that a default export doesn't exist but your source file has a default export?
2
+ // you should run `yarn` or `yarn preconstruct dev` if preconstruct dev isn't in your postinstall hook
3
+
4
+ // curious why you need to?
5
+ // this file exists so that you can import from the entrypoint normally
6
+ // except that it points to your source file and you don't need to run build constantly
7
+ // which means we need to re-export all of the modules from your source file
8
+ // and since export * doesn't include default exports, we need to read your source file
9
+ // to check for a default export and re-export it if it exists
10
+ // it's not ideal, but it works pretty well ¯\_(ツ)_/¯
11
+ export * from "../src/index";
@@ -1,7 +1,16 @@
1
- 'use strict';
1
+ "use strict";
2
+ // this file might look strange and you might be wondering what it's for
3
+ // it's lets you import your source files by importing this entrypoint
4
+ // as you would import it if it was built with preconstruct build
5
+ // this file is slightly different to some others though
6
+ // it has a require hook which compiles your code with Babel
7
+ // this means that you don't have to set up @babel/register or anything like that
8
+ // but you can still require this module and it'll be compiled
2
9
 
3
- if (process.env.NODE_ENV === "production") {
4
- module.exports = require("./wagmi-core.cjs.prod.js");
5
- } else {
6
- module.exports = require("./wagmi-core.cjs.dev.js");
7
- }
10
+ // this bit of code imports the require hook and registers it
11
+ let unregister = require("../../../node_modules/.pnpm/@preconstruct+hook@0.4.0/node_modules/@preconstruct/hook").___internalHook(typeof __dirname === 'undefined' ? undefined : __dirname, "../../..", "..");
12
+
13
+ // this re-exports the source file
14
+ module.exports = require("../src/index.ts");
15
+
16
+ unregister();
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@wagmi/core",
3
- "description": "JavaScript library for Ethereum",
3
+ "description": "Vanilla JS Client for Ethereum",
4
4
  "license": "MIT",
5
- "version": "0.2.0-next.6",
5
+ "version": "0.2.0-next.9",
6
6
  "ethereum": "awkweb.eth",
7
7
  "repository": "tmm/wagmi",
8
8
  "sideEffects": false,
@@ -60,7 +60,6 @@
60
60
  },
61
61
  "devDependencies": {
62
62
  "@coinbase/wallet-sdk": "^3.0.1",
63
- "@ethersproject/providers": "^5.5.1",
64
63
  "@walletconnect/ethereum-provider": "1.7.5",
65
64
  "ethers": "^5.5.1"
66
65
  }
@@ -1,253 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var base = require('../../../dist/base-09a653f3.cjs.dev.js');
6
- var ethers = require('ethers');
7
- var utils = require('ethers/lib/utils');
8
- require('eventemitter3');
9
-
10
- function _interopNamespace(e) {
11
- if (e && e.__esModule) return e;
12
- var n = Object.create(null);
13
- if (e) {
14
- Object.keys(e).forEach(function (k) {
15
- if (k !== 'default') {
16
- var d = Object.getOwnPropertyDescriptor(e, k);
17
- Object.defineProperty(n, k, d.get ? d : {
18
- enumerable: true,
19
- get: function () { return e[k]; }
20
- });
21
- }
22
- });
23
- }
24
- n["default"] = e;
25
- return Object.freeze(n);
26
- }
27
-
28
- var _client = /*#__PURE__*/new WeakMap();
29
-
30
- var _provider = /*#__PURE__*/new WeakMap();
31
-
32
- class CoinbaseWalletConnector extends base.Connector {
33
- constructor(config) {
34
- var _window$ethereum;
35
-
36
- super(config);
37
-
38
- base._defineProperty(this, "id", 'coinbaseWallet');
39
-
40
- base._defineProperty(this, "name", 'Coinbase Wallet');
41
-
42
- base._defineProperty(this, "ready", typeof window !== 'undefined' && !((_window$ethereum = window.ethereum) !== null && _window$ethereum !== void 0 && _window$ethereum.isCoinbaseWallet));
43
-
44
- base._classPrivateFieldInitSpec(this, _client, {
45
- writable: true,
46
- value: void 0
47
- });
48
-
49
- base._classPrivateFieldInitSpec(this, _provider, {
50
- writable: true,
51
- value: void 0
52
- });
53
-
54
- base._defineProperty(this, "onAccountsChanged", accounts => {
55
- if (accounts.length === 0) this.emit('disconnect');else this.emit('change', {
56
- account: utils.getAddress(accounts[0])
57
- });
58
- });
59
-
60
- base._defineProperty(this, "onChainChanged", chainId => {
61
- var id = base.normalizeChainId(chainId);
62
- var unsupported = this.isChainUnsupported(id);
63
- this.emit('change', {
64
- chain: {
65
- id,
66
- unsupported
67
- }
68
- });
69
- });
70
-
71
- base._defineProperty(this, "onDisconnect", () => {
72
- this.emit('disconnect');
73
- });
74
- }
75
-
76
- connect() {
77
- var _this = this;
78
-
79
- return base._asyncToGenerator(function* () {
80
- try {
81
- var provider = yield _this.getProvider();
82
- provider.on('accountsChanged', _this.onAccountsChanged);
83
- provider.on('chainChanged', _this.onChainChanged);
84
- provider.on('disconnect', _this.onDisconnect);
85
-
86
- _this.emit('connecting');
87
-
88
- var accounts = yield provider.enable();
89
- var account = utils.getAddress(accounts[0]);
90
- var id = yield _this.getChainId();
91
-
92
- var unsupported = _this.isChainUnsupported(id);
93
-
94
- return {
95
- account,
96
- chain: {
97
- id,
98
- unsupported
99
- },
100
- provider: new ethers.providers.Web3Provider(provider)
101
- };
102
- } catch (error) {
103
- if (/user closed modal/i.test(error.message)) throw new base.UserRejectedRequestError();
104
- throw error;
105
- }
106
- })();
107
- }
108
-
109
- disconnect() {
110
- var _this2 = this;
111
-
112
- return base._asyncToGenerator(function* () {
113
- if (!base._classPrivateFieldGet(_this2, _provider)) return;
114
- var provider = yield _this2.getProvider();
115
- provider.removeListener('accountsChanged', _this2.onAccountsChanged);
116
- provider.removeListener('chainChanged', _this2.onChainChanged);
117
- provider.removeListener('disconnect', _this2.onDisconnect);
118
- provider.disconnect();
119
- provider.close();
120
-
121
- if (typeof localStorage !== 'undefined') {
122
- var n = localStorage.length;
123
-
124
- while (n--) {
125
- var key = localStorage.key(n);
126
- if (!key) continue;
127
- if (!/-walletlink/.test(key)) continue;
128
- localStorage.removeItem(key);
129
- }
130
- }
131
- })();
132
- }
133
-
134
- getAccount() {
135
- var _this3 = this;
136
-
137
- return base._asyncToGenerator(function* () {
138
- var provider = yield _this3.getProvider();
139
- var accounts = yield provider.request({
140
- method: 'eth_accounts'
141
- }); // return checksum address
142
-
143
- return utils.getAddress(accounts[0]);
144
- })();
145
- }
146
-
147
- getChainId() {
148
- var _this4 = this;
149
-
150
- return base._asyncToGenerator(function* () {
151
- var provider = yield _this4.getProvider();
152
- var chainId = base.normalizeChainId(provider.chainId);
153
- return chainId;
154
- })();
155
- }
156
-
157
- getProvider() {
158
- var _this5 = this;
159
-
160
- return base._asyncToGenerator(function* () {
161
- if (!base._classPrivateFieldGet(_this5, _provider)) {
162
- var {
163
- CoinbaseWalletSDK
164
- } = yield Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require('@coinbase/wallet-sdk')); });
165
-
166
- base._classPrivateFieldSet(_this5, _client, new CoinbaseWalletSDK(_this5.options));
167
-
168
- base._classPrivateFieldSet(_this5, _provider, base._classPrivateFieldGet(_this5, _client).makeWeb3Provider(_this5.options.jsonRpcUrl));
169
- }
170
-
171
- return base._classPrivateFieldGet(_this5, _provider);
172
- })();
173
- }
174
-
175
- getSigner() {
176
- var _this6 = this;
177
-
178
- return base._asyncToGenerator(function* () {
179
- var [provider, account] = yield Promise.all([_this6.getProvider(), _this6.getAccount()]);
180
- return new ethers.providers.Web3Provider(provider).getSigner(account);
181
- })();
182
- }
183
-
184
- isAuthorized() {
185
- var _this7 = this;
186
-
187
- return base._asyncToGenerator(function* () {
188
- try {
189
- var account = yield _this7.getAccount();
190
- return !!account;
191
- } catch (_unused) {
192
- return false;
193
- }
194
- })();
195
- }
196
-
197
- switchChain(chainId) {
198
- var _this8 = this;
199
-
200
- return base._asyncToGenerator(function* () {
201
- var provider = yield _this8.getProvider();
202
- var id = utils.hexValue(chainId);
203
-
204
- try {
205
- var _chains$find;
206
-
207
- yield provider.request({
208
- method: 'wallet_switchEthereumChain',
209
- params: [{
210
- chainId: id
211
- }]
212
- });
213
- var chains = [..._this8.chains, ...base.allChains];
214
- return (_chains$find = chains.find(x => x.id === chainId)) !== null && _chains$find !== void 0 ? _chains$find : {
215
- id: chainId,
216
- name: "Chain ".concat(id),
217
- rpcUrls: []
218
- };
219
- } catch (error) {
220
- if (/user rejected signature request/i.test(error.message)) throw new base.UserRejectedRequestError();else throw new base.SwitchChainError();
221
- }
222
- })();
223
- }
224
-
225
- watchAsset(_ref) {
226
- var _this9 = this;
227
-
228
- return base._asyncToGenerator(function* () {
229
- var {
230
- address,
231
- decimals = 18,
232
- image,
233
- symbol
234
- } = _ref;
235
- var provider = yield _this9.getProvider();
236
- return yield provider.request({
237
- method: 'wallet_watchAsset',
238
- params: {
239
- type: 'ERC20',
240
- options: {
241
- address,
242
- decimals,
243
- image,
244
- symbol
245
- }
246
- }
247
- });
248
- })();
249
- }
250
-
251
- }
252
-
253
- exports.CoinbaseWalletConnector = CoinbaseWalletConnector;
@@ -1,253 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var base = require('../../../dist/base-d8123d5f.cjs.prod.js');
6
- var ethers = require('ethers');
7
- var utils = require('ethers/lib/utils');
8
- require('eventemitter3');
9
-
10
- function _interopNamespace(e) {
11
- if (e && e.__esModule) return e;
12
- var n = Object.create(null);
13
- if (e) {
14
- Object.keys(e).forEach(function (k) {
15
- if (k !== 'default') {
16
- var d = Object.getOwnPropertyDescriptor(e, k);
17
- Object.defineProperty(n, k, d.get ? d : {
18
- enumerable: true,
19
- get: function () { return e[k]; }
20
- });
21
- }
22
- });
23
- }
24
- n["default"] = e;
25
- return Object.freeze(n);
26
- }
27
-
28
- var _client = /*#__PURE__*/new WeakMap();
29
-
30
- var _provider = /*#__PURE__*/new WeakMap();
31
-
32
- class CoinbaseWalletConnector extends base.Connector {
33
- constructor(config) {
34
- var _window$ethereum;
35
-
36
- super(config);
37
-
38
- base._defineProperty(this, "id", 'coinbaseWallet');
39
-
40
- base._defineProperty(this, "name", 'Coinbase Wallet');
41
-
42
- base._defineProperty(this, "ready", typeof window !== 'undefined' && !((_window$ethereum = window.ethereum) !== null && _window$ethereum !== void 0 && _window$ethereum.isCoinbaseWallet));
43
-
44
- base._classPrivateFieldInitSpec(this, _client, {
45
- writable: true,
46
- value: void 0
47
- });
48
-
49
- base._classPrivateFieldInitSpec(this, _provider, {
50
- writable: true,
51
- value: void 0
52
- });
53
-
54
- base._defineProperty(this, "onAccountsChanged", accounts => {
55
- if (accounts.length === 0) this.emit('disconnect');else this.emit('change', {
56
- account: utils.getAddress(accounts[0])
57
- });
58
- });
59
-
60
- base._defineProperty(this, "onChainChanged", chainId => {
61
- var id = base.normalizeChainId(chainId);
62
- var unsupported = this.isChainUnsupported(id);
63
- this.emit('change', {
64
- chain: {
65
- id,
66
- unsupported
67
- }
68
- });
69
- });
70
-
71
- base._defineProperty(this, "onDisconnect", () => {
72
- this.emit('disconnect');
73
- });
74
- }
75
-
76
- connect() {
77
- var _this = this;
78
-
79
- return base._asyncToGenerator(function* () {
80
- try {
81
- var provider = yield _this.getProvider();
82
- provider.on('accountsChanged', _this.onAccountsChanged);
83
- provider.on('chainChanged', _this.onChainChanged);
84
- provider.on('disconnect', _this.onDisconnect);
85
-
86
- _this.emit('connecting');
87
-
88
- var accounts = yield provider.enable();
89
- var account = utils.getAddress(accounts[0]);
90
- var id = yield _this.getChainId();
91
-
92
- var unsupported = _this.isChainUnsupported(id);
93
-
94
- return {
95
- account,
96
- chain: {
97
- id,
98
- unsupported
99
- },
100
- provider: new ethers.providers.Web3Provider(provider)
101
- };
102
- } catch (error) {
103
- if (/user closed modal/i.test(error.message)) throw new base.UserRejectedRequestError();
104
- throw error;
105
- }
106
- })();
107
- }
108
-
109
- disconnect() {
110
- var _this2 = this;
111
-
112
- return base._asyncToGenerator(function* () {
113
- if (!base._classPrivateFieldGet(_this2, _provider)) return;
114
- var provider = yield _this2.getProvider();
115
- provider.removeListener('accountsChanged', _this2.onAccountsChanged);
116
- provider.removeListener('chainChanged', _this2.onChainChanged);
117
- provider.removeListener('disconnect', _this2.onDisconnect);
118
- provider.disconnect();
119
- provider.close();
120
-
121
- if (typeof localStorage !== 'undefined') {
122
- var n = localStorage.length;
123
-
124
- while (n--) {
125
- var key = localStorage.key(n);
126
- if (!key) continue;
127
- if (!/-walletlink/.test(key)) continue;
128
- localStorage.removeItem(key);
129
- }
130
- }
131
- })();
132
- }
133
-
134
- getAccount() {
135
- var _this3 = this;
136
-
137
- return base._asyncToGenerator(function* () {
138
- var provider = yield _this3.getProvider();
139
- var accounts = yield provider.request({
140
- method: 'eth_accounts'
141
- }); // return checksum address
142
-
143
- return utils.getAddress(accounts[0]);
144
- })();
145
- }
146
-
147
- getChainId() {
148
- var _this4 = this;
149
-
150
- return base._asyncToGenerator(function* () {
151
- var provider = yield _this4.getProvider();
152
- var chainId = base.normalizeChainId(provider.chainId);
153
- return chainId;
154
- })();
155
- }
156
-
157
- getProvider() {
158
- var _this5 = this;
159
-
160
- return base._asyncToGenerator(function* () {
161
- if (!base._classPrivateFieldGet(_this5, _provider)) {
162
- var {
163
- CoinbaseWalletSDK
164
- } = yield Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require('@coinbase/wallet-sdk')); });
165
-
166
- base._classPrivateFieldSet(_this5, _client, new CoinbaseWalletSDK(_this5.options));
167
-
168
- base._classPrivateFieldSet(_this5, _provider, base._classPrivateFieldGet(_this5, _client).makeWeb3Provider(_this5.options.jsonRpcUrl));
169
- }
170
-
171
- return base._classPrivateFieldGet(_this5, _provider);
172
- })();
173
- }
174
-
175
- getSigner() {
176
- var _this6 = this;
177
-
178
- return base._asyncToGenerator(function* () {
179
- var [provider, account] = yield Promise.all([_this6.getProvider(), _this6.getAccount()]);
180
- return new ethers.providers.Web3Provider(provider).getSigner(account);
181
- })();
182
- }
183
-
184
- isAuthorized() {
185
- var _this7 = this;
186
-
187
- return base._asyncToGenerator(function* () {
188
- try {
189
- var account = yield _this7.getAccount();
190
- return !!account;
191
- } catch (_unused) {
192
- return false;
193
- }
194
- })();
195
- }
196
-
197
- switchChain(chainId) {
198
- var _this8 = this;
199
-
200
- return base._asyncToGenerator(function* () {
201
- var provider = yield _this8.getProvider();
202
- var id = utils.hexValue(chainId);
203
-
204
- try {
205
- var _chains$find;
206
-
207
- yield provider.request({
208
- method: 'wallet_switchEthereumChain',
209
- params: [{
210
- chainId: id
211
- }]
212
- });
213
- var chains = [..._this8.chains, ...base.allChains];
214
- return (_chains$find = chains.find(x => x.id === chainId)) !== null && _chains$find !== void 0 ? _chains$find : {
215
- id: chainId,
216
- name: "Chain ".concat(id),
217
- rpcUrls: []
218
- };
219
- } catch (error) {
220
- if (/user rejected signature request/i.test(error.message)) throw new base.UserRejectedRequestError();else throw new base.SwitchChainError();
221
- }
222
- })();
223
- }
224
-
225
- watchAsset(_ref) {
226
- var _this9 = this;
227
-
228
- return base._asyncToGenerator(function* () {
229
- var {
230
- address,
231
- decimals = 18,
232
- image,
233
- symbol
234
- } = _ref;
235
- var provider = yield _this9.getProvider();
236
- return yield provider.request({
237
- method: 'wallet_watchAsset',
238
- params: {
239
- type: 'ERC20',
240
- options: {
241
- address,
242
- decimals,
243
- image,
244
- symbol
245
- }
246
- }
247
- });
248
- })();
249
- }
250
-
251
- }
252
-
253
- exports.CoinbaseWalletConnector = CoinbaseWalletConnector;