@wagmi/core 0.5.6 → 0.5.8

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 (54) hide show
  1. package/chains/dist/wagmi-core-chains.cjs.dev.js +2 -2
  2. package/chains/dist/wagmi-core-chains.cjs.prod.js +2 -2
  3. package/chains/dist/wagmi-core-chains.esm.js +2 -2
  4. package/connectors/coinbaseWallet/dist/wagmi-core-connectors-coinbaseWallet.cjs.dev.js +10 -6
  5. package/connectors/coinbaseWallet/dist/wagmi-core-connectors-coinbaseWallet.cjs.prod.js +10 -6
  6. package/connectors/coinbaseWallet/dist/wagmi-core-connectors-coinbaseWallet.esm.js +10 -6
  7. package/connectors/metaMask/dist/wagmi-core-connectors-metaMask.cjs.dev.js +3 -3
  8. package/connectors/metaMask/dist/wagmi-core-connectors-metaMask.cjs.prod.js +3 -3
  9. package/connectors/metaMask/dist/wagmi-core-connectors-metaMask.esm.js +3 -3
  10. package/connectors/mock/dist/wagmi-core-connectors-mock.cjs.dev.js +3 -3
  11. package/connectors/mock/dist/wagmi-core-connectors-mock.cjs.prod.js +3 -3
  12. package/connectors/mock/dist/wagmi-core-connectors-mock.esm.js +3 -3
  13. package/connectors/walletConnect/dist/wagmi-core-connectors-walletConnect.cjs.dev.js +3 -3
  14. package/connectors/walletConnect/dist/wagmi-core-connectors-walletConnect.cjs.prod.js +3 -3
  15. package/connectors/walletConnect/dist/wagmi-core-connectors-walletConnect.esm.js +3 -3
  16. package/dist/{chains-868f0ac6.cjs.prod.js → chains-789e0c2e.cjs.prod.js} +2 -1
  17. package/dist/{chains-a22bcfea.esm.js → chains-8c76af1b.esm.js} +2 -1
  18. package/dist/{chains-4fdb21bc.cjs.dev.js → chains-ec1de502.cjs.dev.js} +2 -1
  19. package/dist/debounce-0862bf88.esm.js +18 -0
  20. package/dist/debounce-2d836dc9.cjs.prod.js +20 -0
  21. package/dist/debounce-46ac0312.cjs.dev.js +20 -0
  22. package/dist/declarations/src/actions/network-status/watchBlockNumber.d.ts +1 -0
  23. package/dist/declarations/src/client.d.ts +11 -1
  24. package/dist/declarations/src/connectors/base.d.ts +1 -0
  25. package/dist/declarations/src/constants/abis.d.ts +148 -0
  26. package/dist/declarations/src/constants/index.d.ts +1 -1
  27. package/dist/declarations/src/constants/rpcs.d.ts +1 -1
  28. package/dist/declarations/src/internal.d.ts +1 -0
  29. package/dist/declarations/src/utils/debounce.d.ts +1 -0
  30. package/dist/declarations/src/utils/index.d.ts +1 -0
  31. package/dist/{getProvider-b220fed1.cjs.prod.js → getProvider-1b3eeda8.cjs.dev.js} +60 -20
  32. package/dist/{getProvider-a3c8cf52.esm.js → getProvider-5b4b62c3.esm.js} +61 -21
  33. package/dist/{getProvider-3a26f086.cjs.dev.js → getProvider-ad4ce6a4.cjs.prod.js} +60 -20
  34. package/dist/{rpcs-6e1b1718.esm.js → rpcs-8d636858.esm.js} +1 -0
  35. package/dist/{rpcs-3326627e.cjs.dev.js → rpcs-d2cd65f1.cjs.dev.js} +1 -0
  36. package/dist/{rpcs-45537550.cjs.prod.js → rpcs-edec227e.cjs.prod.js} +1 -0
  37. package/dist/wagmi-core.cjs.dev.js +294 -63
  38. package/dist/wagmi-core.cjs.prod.js +294 -63
  39. package/dist/wagmi-core.esm.js +297 -66
  40. package/internal/dist/wagmi-core-internal.cjs.d.ts +1 -0
  41. package/internal/dist/wagmi-core-internal.cjs.dev.js +9 -0
  42. package/internal/dist/wagmi-core-internal.cjs.js +7 -0
  43. package/internal/dist/wagmi-core-internal.cjs.prod.js +9 -0
  44. package/internal/dist/wagmi-core-internal.esm.js +1 -0
  45. package/internal/package.json +4 -0
  46. package/package.json +7 -1
  47. package/providers/alchemy/dist/wagmi-core-providers-alchemy.cjs.dev.js +1 -1
  48. package/providers/alchemy/dist/wagmi-core-providers-alchemy.cjs.prod.js +1 -1
  49. package/providers/alchemy/dist/wagmi-core-providers-alchemy.esm.js +1 -1
  50. package/providers/coinbaseNode/dist/wagmi-core-providers-coinbaseNode.cjs.d.ts +11 -0
  51. package/providers/coinbaseNode/dist/wagmi-core-providers-coinbaseNode.cjs.js +16 -0
  52. package/providers/infura/dist/wagmi-core-providers-infura.cjs.dev.js +1 -1
  53. package/providers/infura/dist/wagmi-core-providers-infura.cjs.prod.js +1 -1
  54. package/providers/infura/dist/wagmi-core-providers-infura.esm.js +1 -1
@@ -1,12 +1,13 @@
1
- import { g as getClient, C as ConnectorAlreadyConnectedError, a as ConnectorNotFoundError, b as ChainMismatchError, U as UserRejectedRequestError, c as ContractMethodDoesNotExistError, d as getProvider, P as ProviderChainsNotFound, e as ChainDoesNotSupportMulticallError, f as ContractMethodRevertedError, h as ContractMethodNoResultError, i as ContractResultDecodeError, n as normalizeChainId, S as SwitchChainNotSupportedError } from './getProvider-a3c8cf52.esm.js';
2
- export { A as AddChainError, e as ChainDoesNotSupportMulticallError, b as ChainMismatchError, m as ChainNotConfiguredError, k as Client, l as Connector, C as ConnectorAlreadyConnectedError, a as ConnectorNotFoundError, c as ContractMethodDoesNotExistError, h as ContractMethodNoResultError, f as ContractMethodRevertedError, i as ContractResultDecodeError, I as InjectedConnector, P as ProviderChainsNotFound, o as ProviderRpcError, R as ResourceUnavailableError, p as RpcError, q as SwitchChainError, S as SwitchChainNotSupportedError, U as UserRejectedRequestError, j as createClient, r as createStorage, d as getProvider, s as noopStorage, n as normalizeChainId } from './getProvider-a3c8cf52.esm.js';
1
+ import { g as getClient, C as ConnectorAlreadyConnectedError, a as ConnectorNotFoundError, b as ChainMismatchError, U as UserRejectedRequestError, c as ContractResultDecodeError, d as ContractMethodDoesNotExistError, e as getProvider, P as ProviderChainsNotFound, f as ChainDoesNotSupportMulticallError, h as ContractMethodRevertedError, i as ContractMethodNoResultError, n as normalizeChainId, S as SwitchChainNotSupportedError } from './getProvider-5b4b62c3.esm.js';
2
+ export { A as AddChainError, f as ChainDoesNotSupportMulticallError, b as ChainMismatchError, m as ChainNotConfiguredError, k as Client, l as Connector, C as ConnectorAlreadyConnectedError, a as ConnectorNotFoundError, d as ContractMethodDoesNotExistError, i as ContractMethodNoResultError, h as ContractMethodRevertedError, c as ContractResultDecodeError, I as InjectedConnector, P as ProviderChainsNotFound, o as ProviderRpcError, R as ResourceUnavailableError, p as RpcError, q as SwitchChainError, S as SwitchChainNotSupportedError, U as UserRejectedRequestError, j as createClient, r as createStorage, e as getProvider, s as noopStorage, n as normalizeChainId } from './getProvider-5b4b62c3.esm.js';
3
3
  import { providers, Contract as Contract$1 } from 'ethers';
4
4
  import { Contract, logger } from 'ethers/lib/ethers';
5
- import { FormatTypes, formatUnits, getAddress, isAddress, Logger } from 'ethers/lib/utils';
6
- import { m as mainnet } from './chains-a22bcfea.esm.js';
7
- export { a as allChains, c as chain, b as chainId, d as defaultChains, e as defaultL2Chains, f as etherscanBlockExplorers } from './chains-a22bcfea.esm.js';
5
+ import { FormatTypes, parseBytes32String, formatUnits, getAddress, isAddress, Logger } from 'ethers/lib/utils';
6
+ import { m as mainnet } from './chains-8c76af1b.esm.js';
7
+ export { a as allChains, c as chain, b as chainId, d as defaultChains, e as defaultL2Chains, f as etherscanBlockExplorers } from './chains-8c76af1b.esm.js';
8
8
  import shallow from 'zustand/shallow';
9
- export { a as alchemyRpcUrls, i as infuraRpcUrls, p as publicRpcUrls } from './rpcs-6e1b1718.esm.js';
9
+ import { d as debounce } from './debounce-0862bf88.esm.js';
10
+ export { a as alchemyRpcUrls, i as infuraRpcUrls, p as publicRpcUrls } from './rpcs-8d636858.esm.js';
10
11
  import 'zustand/middleware';
11
12
  import 'zustand/vanilla';
12
13
  import 'eventemitter3';
@@ -213,7 +214,156 @@ function parseContractResult(_ref) {
213
214
  }
214
215
 
215
216
  // https://ethereum.org/en/developers/docs/standards/tokens/erc-20
216
- const erc20ABI = ['event Approval(address indexed _owner, address indexed _spender, uint256 _value)', 'event Transfer(address indexed _from, address indexed _to, uint256 _value)', 'function allowance(address _owner, address _spender) public view returns (uint256 remaining)', 'function approve(address _spender, uint256 _value) public returns (bool success)', 'function balanceOf(address _owner) public view returns (uint256 balance)', 'function decimals() public view returns (uint8)', 'function name() public view returns (string)', 'function symbol() public view returns (string)', 'function totalSupply() public view returns (uint256)', 'function transfer(address _to, uint256 _value) public returns (bool success)', 'function transferFrom(address _from, address _to, uint256 _value) public returns (bool success)']; // https://ethereum.org/en/developers/docs/standards/tokens/erc-721
217
+ const erc20ABI = ['event Approval(address indexed _owner, address indexed _spender, uint256 _value)', 'event Transfer(address indexed _from, address indexed _to, uint256 _value)', 'function allowance(address _owner, address _spender) public view returns (uint256 remaining)', 'function approve(address _spender, uint256 _value) public returns (bool success)', 'function balanceOf(address _owner) public view returns (uint256 balance)', 'function decimals() public view returns (uint8)', 'function name() public view returns (string)', 'function symbol() public view returns (string)', 'function totalSupply() public view returns (uint256)', 'function transfer(address _to, uint256 _value) public returns (bool success)', 'function transferFrom(address _from, address _to, uint256 _value) public returns (bool success)'];
218
+ /**
219
+ * [bytes32-flavored ERC-20](https://docs.makerdao.com/smart-contract-modules/mkr-module#4.-gotchas-potential-source-of-user-error)
220
+ * for tokens (ie. Maker) that use bytes32 instead of string.
221
+ */
222
+
223
+ const erc20ABI_bytes32 = [{
224
+ type: 'event',
225
+ name: 'Approval',
226
+ inputs: [{
227
+ indexed: true,
228
+ name: 'owner',
229
+ type: 'address'
230
+ }, {
231
+ indexed: true,
232
+ name: 'spender',
233
+ type: 'address'
234
+ }, {
235
+ indexed: false,
236
+ name: 'value',
237
+ type: 'uint256'
238
+ }]
239
+ }, {
240
+ type: 'event',
241
+ name: 'Transfer',
242
+ inputs: [{
243
+ indexed: true,
244
+ name: 'from',
245
+ type: 'address'
246
+ }, {
247
+ indexed: true,
248
+ name: 'to',
249
+ type: 'address'
250
+ }, {
251
+ indexed: false,
252
+ name: 'value',
253
+ type: 'uint256'
254
+ }]
255
+ }, {
256
+ type: 'function',
257
+ name: 'allowance',
258
+ stateMutability: 'view',
259
+ inputs: [{
260
+ name: 'owner',
261
+ type: 'address'
262
+ }, {
263
+ name: 'spender',
264
+ type: 'address'
265
+ }],
266
+ outputs: [{
267
+ name: '',
268
+ type: 'uint256'
269
+ }]
270
+ }, {
271
+ type: 'function',
272
+ name: 'approve',
273
+ stateMutability: 'nonpayable',
274
+ inputs: [{
275
+ name: 'spender',
276
+ type: 'address'
277
+ }, {
278
+ name: 'amount',
279
+ type: 'uint256'
280
+ }],
281
+ outputs: [{
282
+ name: '',
283
+ type: 'bool'
284
+ }]
285
+ }, {
286
+ type: 'function',
287
+ name: 'balanceOf',
288
+ stateMutability: 'view',
289
+ inputs: [{
290
+ name: 'account',
291
+ type: 'address'
292
+ }],
293
+ outputs: [{
294
+ name: '',
295
+ type: 'uint256'
296
+ }]
297
+ }, {
298
+ type: 'function',
299
+ name: 'decimals',
300
+ stateMutability: 'view',
301
+ inputs: [],
302
+ outputs: [{
303
+ name: '',
304
+ type: 'uint8'
305
+ }]
306
+ }, {
307
+ type: 'function',
308
+ name: 'name',
309
+ stateMutability: 'view',
310
+ inputs: [],
311
+ outputs: [{
312
+ name: '',
313
+ type: 'bytes32'
314
+ }]
315
+ }, {
316
+ type: 'function',
317
+ name: 'symbol',
318
+ stateMutability: 'view',
319
+ inputs: [],
320
+ outputs: [{
321
+ name: '',
322
+ type: 'bytes32'
323
+ }]
324
+ }, {
325
+ type: 'function',
326
+ name: 'totalSupply',
327
+ stateMutability: 'view',
328
+ inputs: [],
329
+ outputs: [{
330
+ name: '',
331
+ type: 'uint256'
332
+ }]
333
+ }, {
334
+ type: 'function',
335
+ name: 'transfer',
336
+ stateMutability: 'nonpayable',
337
+ inputs: [{
338
+ name: 'recipient',
339
+ type: 'address'
340
+ }, {
341
+ name: 'amount',
342
+ type: 'uint256'
343
+ }],
344
+ outputs: [{
345
+ name: '',
346
+ type: 'bool'
347
+ }]
348
+ }, {
349
+ type: 'function',
350
+ name: 'transferFrom',
351
+ stateMutability: 'nonpayable',
352
+ inputs: [{
353
+ name: 'sender',
354
+ type: 'address'
355
+ }, {
356
+ name: 'recipient',
357
+ type: 'address'
358
+ }, {
359
+ name: 'amount',
360
+ type: 'uint256'
361
+ }],
362
+ outputs: [{
363
+ name: '',
364
+ type: 'bool'
365
+ }]
366
+ }]; // https://ethereum.org/en/developers/docs/standards/tokens/erc-721
217
367
 
218
368
  const erc721ABI = ['event Approval(address indexed _owner, address indexed _approved, uint256 indexed _tokenId)', 'event ApprovalForAll(address indexed _owner, address indexed _operator, bool _approved)', 'event Transfer(address indexed _from, address indexed _to, uint256 indexed _tokenId)', 'function approve(address _approved, uint256 _tokenId) external payable', 'function balanceOf(address _owner) external view returns (uint256)', 'function getApproved(uint256 _tokenId) external view returns (address)', 'function isApprovedForAll(address _owner, address _operator) external view returns (bool)', 'function name() view returns (string memory)', 'function ownerOf(uint256 _tokenId) external view returns (address)', 'function safeTransferFrom(address _from, address _to, uint256 _tokenId) external payable', 'function safeTransferFrom(address _from, address _to, uint256 _tokenId, bytes data) external payable', 'function setApprovalForAll(address _operator, bool _approved) external', 'function symbol() view returns (string memory)', 'function tokenByIndex(uint256 _index) view returns (uint256)', 'function tokenOfOwnerByIndex(address _owner, uint256 _index) view returns (uint256 tokenId)', 'function tokenURI(uint256 _tokenId) view returns (string memory)', 'function totalSupply() view returns (uint256)', 'function transferFrom(address _from, address _to, uint256 _tokenId) external payable'];
219
369
 
@@ -370,33 +520,65 @@ async function fetchToken(_ref) {
370
520
  chainId,
371
521
  formatUnits: units = 'ether'
372
522
  } = _ref;
373
- const erc20Config = {
374
- addressOrName: address,
375
- contractInterface: erc20ABI,
376
- chainId
377
- };
378
- const [decimals, name, symbol, totalSupply] = await readContracts({
379
- allowFailure: false,
380
- contracts: [{ ...erc20Config,
381
- functionName: 'decimals'
382
- }, { ...erc20Config,
383
- functionName: 'name'
384
- }, { ...erc20Config,
385
- functionName: 'symbol'
386
- }, { ...erc20Config,
387
- functionName: 'totalSupply'
388
- }]
389
- });
390
- return {
391
- address,
392
- decimals,
393
- name,
394
- symbol,
395
- totalSupply: {
396
- formatted: formatUnits(totalSupply, units),
397
- value: totalSupply
523
+
524
+ async function fetchToken_(_ref2) {
525
+ let {
526
+ contractInterface
527
+ } = _ref2;
528
+ const erc20Config = {
529
+ addressOrName: address,
530
+ contractInterface,
531
+ chainId
532
+ };
533
+ const [decimals, name, symbol, totalSupply] = await readContracts({
534
+ allowFailure: false,
535
+ contracts: [{ ...erc20Config,
536
+ functionName: 'decimals'
537
+ }, { ...erc20Config,
538
+ functionName: 'name'
539
+ }, { ...erc20Config,
540
+ functionName: 'symbol'
541
+ }, { ...erc20Config,
542
+ functionName: 'totalSupply'
543
+ }]
544
+ });
545
+ return {
546
+ address,
547
+ decimals,
548
+ name,
549
+ symbol,
550
+ totalSupply: {
551
+ formatted: formatUnits(totalSupply, units),
552
+ value: totalSupply
553
+ }
554
+ };
555
+ }
556
+
557
+ try {
558
+ return await fetchToken_({
559
+ contractInterface: erc20ABI
560
+ });
561
+ } catch (err) {
562
+ // In the chance that there is an error upon decoding the contract result,
563
+ // it could be likely that the contract data is represented as bytes32 instead
564
+ // of a string.
565
+ if (err instanceof ContractResultDecodeError) {
566
+ const {
567
+ name,
568
+ symbol,
569
+ ...rest
570
+ } = await fetchToken_({
571
+ contractInterface: erc20ABI_bytes32
572
+ });
573
+ return {
574
+ name: parseBytes32String(name),
575
+ symbol: parseBytes32String(symbol),
576
+ ...rest
577
+ };
398
578
  }
399
- };
579
+
580
+ throw err;
581
+ }
400
582
  }
401
583
 
402
584
  /**
@@ -468,9 +650,9 @@ function getWebSocketProvider() {
468
650
  chainId
469
651
  } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
470
652
  const client = getClient();
471
- if (chainId && typeof client.config.webSocketProvider === 'function') return client.config.webSocketProvider({
653
+ if (chainId) return client.getWebSocketProvider({
472
654
  chainId
473
- });
655
+ }) || client.webSocketProvider;
474
656
  return client.webSocketProvider;
475
657
  }
476
658
 
@@ -791,24 +973,35 @@ async function fetchBlockNumber() {
791
973
  }
792
974
 
793
975
  function watchBlockNumber(args, callback) {
794
- var _client$webSocketProv;
795
-
976
+ var _getWebSocketProvider;
977
+
978
+ // We need to debounce the listener as we want to opt-out
979
+ // of the behavior where ethers emits a "block" event for
980
+ // every block that was missed in between the `pollingInterval`.
981
+ // We are setting a wait time of 1 as emitting an event in
982
+ // ethers takes ~0.1ms.
983
+ const debouncedCallback = debounce(callback, 1);
796
984
  let previousProvider;
797
985
 
798
986
  const createListener = provider => {
799
987
  if (previousProvider) {
800
988
  var _previousProvider;
801
989
 
802
- (_previousProvider = previousProvider) === null || _previousProvider === void 0 ? void 0 : _previousProvider.off('block', callback);
990
+ (_previousProvider = previousProvider) === null || _previousProvider === void 0 ? void 0 : _previousProvider.off('block', debouncedCallback);
803
991
  }
804
992
 
805
- provider.on('block', callback);
993
+ provider.on('block', debouncedCallback);
806
994
  previousProvider = provider;
807
995
  };
808
996
 
809
- const client = getClient();
810
- const provider_ = (_client$webSocketProv = client.webSocketProvider) !== null && _client$webSocketProv !== void 0 ? _client$webSocketProv : client.provider;
997
+ const provider_ = (_getWebSocketProvider = getWebSocketProvider({
998
+ chainId: args.chainId
999
+ })) !== null && _getWebSocketProvider !== void 0 ? _getWebSocketProvider : getProvider({
1000
+ chainId: args.chainId
1001
+ });
811
1002
  if (args.listen) createListener(provider_);
1003
+ let active = true;
1004
+ const client = getClient();
812
1005
  const unsubscribe = client.subscribe(_ref => {
813
1006
  let {
814
1007
  provider,
@@ -825,17 +1018,25 @@ function watchBlockNumber(args, callback) {
825
1018
  } = _ref2;
826
1019
  const provider_ = webSocketProvider !== null && webSocketProvider !== void 0 ? webSocketProvider : provider;
827
1020
 
828
- if (args.listen && provider_) {
1021
+ if (args.listen && !args.chainId && provider_) {
829
1022
  createListener(provider_);
830
1023
  }
831
1024
 
832
- callback(await fetchBlockNumber());
1025
+ const blockNumber = await fetchBlockNumber({
1026
+ chainId: args.chainId
1027
+ });
1028
+ if (!active) return;
1029
+ callback(blockNumber);
833
1030
  }, {
834
1031
  equalityFn: shallow
835
1032
  });
836
1033
  return () => {
1034
+ var _previousProvider2;
1035
+
1036
+ active = false;
837
1037
  unsubscribe();
838
- provider_ === null || provider_ === void 0 ? void 0 : provider_.off('block', callback);
1038
+ provider_ === null || provider_ === void 0 ? void 0 : provider_.off('block', debouncedCallback);
1039
+ (_previousProvider2 = previousProvider) === null || _previousProvider2 === void 0 ? void 0 : _previousProvider2.off('block', debouncedCallback);
839
1040
  };
840
1041
  }
841
1042
 
@@ -1237,12 +1438,7 @@ async function fetchBalance(_ref) {
1237
1438
  });
1238
1439
 
1239
1440
  if (token) {
1240
- const erc20Config = {
1241
- addressOrName: token,
1242
- contractInterface: erc20ABI,
1243
- chainId
1244
- }; // Convert ENS name to address if required
1245
-
1441
+ // Convert ENS name to address if required
1246
1442
  let resolvedAddress;
1247
1443
  if (isAddress(addressOrName)) resolvedAddress = addressOrName;else {
1248
1444
  const address = await provider.resolveName(addressOrName); // Same error `provider.getBalance` throws for invalid ENS name
@@ -1252,23 +1448,58 @@ async function fetchBalance(_ref) {
1252
1448
  });
1253
1449
  resolvedAddress = address;
1254
1450
  }
1255
- const [value, decimals, symbol] = await readContracts({
1256
- allowFailure: false,
1257
- contracts: [{ ...erc20Config,
1258
- functionName: 'balanceOf',
1259
- args: resolvedAddress
1260
- }, { ...erc20Config,
1261
- functionName: 'decimals'
1262
- }, { ...erc20Config,
1263
- functionName: 'symbol'
1264
- }]
1265
- });
1266
- return {
1267
- decimals,
1268
- formatted: formatUnits(value !== null && value !== void 0 ? value : '0', unit !== null && unit !== void 0 ? unit : decimals),
1269
- symbol,
1270
- value
1451
+
1452
+ const fetchContractBalance = async _ref2 => {
1453
+ let {
1454
+ contractInterface
1455
+ } = _ref2;
1456
+ const erc20Config = {
1457
+ addressOrName: token,
1458
+ contractInterface,
1459
+ chainId
1460
+ };
1461
+ const [value, decimals, symbol] = await readContracts({
1462
+ allowFailure: false,
1463
+ contracts: [{ ...erc20Config,
1464
+ functionName: 'balanceOf',
1465
+ args: resolvedAddress
1466
+ }, { ...erc20Config,
1467
+ functionName: 'decimals'
1468
+ }, { ...erc20Config,
1469
+ functionName: 'symbol'
1470
+ }]
1471
+ });
1472
+ return {
1473
+ decimals,
1474
+ formatted: formatUnits(value !== null && value !== void 0 ? value : '0', unit !== null && unit !== void 0 ? unit : decimals),
1475
+ symbol,
1476
+ value
1477
+ };
1271
1478
  };
1479
+
1480
+ try {
1481
+ return await fetchContractBalance({
1482
+ contractInterface: erc20ABI
1483
+ });
1484
+ } catch (err) {
1485
+ // In the chance that there is an error upon decoding the contract result,
1486
+ // it could be likely that the contract data is represented as bytes32 instead
1487
+ // of a string.
1488
+ if (err instanceof ContractResultDecodeError) {
1489
+ const {
1490
+ symbol,
1491
+ ...rest
1492
+ } = await fetchContractBalance({
1493
+ contractInterface: erc20ABI_bytes32
1494
+ });
1495
+ return {
1496
+ symbol: parseBytes32String(symbol),
1497
+ ...rest
1498
+ };
1499
+ }
1500
+
1501
+ throw err;
1502
+ }
1272
1503
  }
1273
1504
 
1274
1505
  const chains = [...(client.provider.chains || []), ...((_client$chains = client.chains) !== null && _client$chains !== void 0 ? _client$chains : [])];
@@ -0,0 +1 @@
1
+ export * from "../../dist/declarations/src/internal";
@@ -0,0 +1,9 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var debounce = require('../../dist/debounce-46ac0312.cjs.dev.js');
6
+
7
+
8
+
9
+ exports.debounce = debounce.debounce;
@@ -0,0 +1,7 @@
1
+ 'use strict';
2
+
3
+ if (process.env.NODE_ENV === "production") {
4
+ module.exports = require("./wagmi-core-internal.cjs.prod.js");
5
+ } else {
6
+ module.exports = require("./wagmi-core-internal.cjs.dev.js");
7
+ }
@@ -0,0 +1,9 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var debounce = require('../../dist/debounce-2d836dc9.cjs.prod.js');
6
+
7
+
8
+
9
+ exports.debounce = debounce.debounce;
@@ -0,0 +1 @@
1
+ export { d as debounce } from '../../dist/debounce-0862bf88.esm.js';
@@ -0,0 +1,4 @@
1
+ {
2
+ "main": "dist/wagmi-core-internal.cjs.js",
3
+ "module": "dist/wagmi-core-internal.esm.js"
4
+ }
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@wagmi/core",
3
3
  "description": "Vanilla JS library for Ethereum",
4
4
  "license": "WAGMIT",
5
- "version": "0.5.6",
5
+ "version": "0.5.8",
6
6
  "repository": {
7
7
  "type": "git",
8
8
  "url": "https://github.com/wagmi-dev/wagmi.git",
@@ -49,6 +49,10 @@
49
49
  "module": "./connectors/walletConnect/dist/wagmi-core-connectors-walletConnect.esm.js",
50
50
  "default": "./connectors/walletConnect/dist/wagmi-core-connectors-walletConnect.cjs.js"
51
51
  },
52
+ "./internal": {
53
+ "module": "./internal/dist/wagmi-core-internal.esm.js",
54
+ "default": "./internal/dist/wagmi-core-internal.cjs.js"
55
+ },
52
56
  "./providers/alchemy": {
53
57
  "module": "./providers/alchemy/dist/wagmi-core-providers-alchemy.esm.js",
54
58
  "default": "./providers/alchemy/dist/wagmi-core-providers-alchemy.cjs.js"
@@ -70,6 +74,7 @@
70
74
  "files": [
71
75
  "/chains",
72
76
  "/connectors",
77
+ "/internal",
73
78
  "/providers",
74
79
  "/dist"
75
80
  ],
@@ -81,6 +86,7 @@
81
86
  "connectors/metaMask.ts",
82
87
  "connectors/walletConnect.ts",
83
88
  "connectors/mock/index.ts",
89
+ "internal.ts",
84
90
  "providers/alchemy.ts",
85
91
  "providers/public.ts",
86
92
  "providers/infura.ts",
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var ethers = require('ethers');
6
- var rpcs = require('../../../dist/rpcs-3326627e.cjs.dev.js');
6
+ var rpcs = require('../../../dist/rpcs-d2cd65f1.cjs.dev.js');
7
7
 
8
8
  function alchemyProvider() {
9
9
  let {
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var ethers = require('ethers');
6
- var rpcs = require('../../../dist/rpcs-45537550.cjs.prod.js');
6
+ var rpcs = require('../../../dist/rpcs-edec227e.cjs.prod.js');
7
7
 
8
8
  function alchemyProvider() {
9
9
  let {
@@ -1,5 +1,5 @@
1
1
  import { providers } from 'ethers';
2
- import { d as defaultAlchemyApiKey } from '../../../dist/rpcs-6e1b1718.esm.js';
2
+ import { d as defaultAlchemyApiKey } from '../../../dist/rpcs-8d636858.esm.js';
3
3
 
4
4
  function alchemyProvider() {
5
5
  let {
@@ -0,0 +1,11 @@
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/providers/coinbaseNode";
@@ -0,0 +1,16 @@
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
9
+
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/providers/coinbaseNode.ts");
15
+
16
+ unregister();
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var ethers = require('ethers');
6
- var rpcs = require('../../../dist/rpcs-3326627e.cjs.dev.js');
6
+ var rpcs = require('../../../dist/rpcs-d2cd65f1.cjs.dev.js');
7
7
 
8
8
  function infuraProvider() {
9
9
  let {
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var ethers = require('ethers');
6
- var rpcs = require('../../../dist/rpcs-45537550.cjs.prod.js');
6
+ var rpcs = require('../../../dist/rpcs-edec227e.cjs.prod.js');
7
7
 
8
8
  function infuraProvider() {
9
9
  let {
@@ -1,5 +1,5 @@
1
1
  import { providers } from 'ethers';
2
- import { b as defaultInfuraApiKey } from '../../../dist/rpcs-6e1b1718.esm.js';
2
+ import { b as defaultInfuraApiKey } from '../../../dist/rpcs-8d636858.esm.js';
3
3
 
4
4
  function infuraProvider() {
5
5
  let {