@wagmi/core 0.5.5 → 0.5.6

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 (27) hide show
  1. package/chains/dist/wagmi-core-chains.esm.js +1 -1
  2. package/connectors/coinbaseWallet/dist/wagmi-core-connectors-coinbaseWallet.cjs.dev.js +1 -1
  3. package/connectors/coinbaseWallet/dist/wagmi-core-connectors-coinbaseWallet.cjs.prod.js +1 -1
  4. package/connectors/coinbaseWallet/dist/wagmi-core-connectors-coinbaseWallet.esm.js +2 -2
  5. package/connectors/metaMask/dist/wagmi-core-connectors-metaMask.cjs.dev.js +1 -1
  6. package/connectors/metaMask/dist/wagmi-core-connectors-metaMask.cjs.prod.js +1 -1
  7. package/connectors/metaMask/dist/wagmi-core-connectors-metaMask.esm.js +2 -2
  8. package/connectors/mock/dist/wagmi-core-connectors-mock.cjs.dev.js +1 -1
  9. package/connectors/mock/dist/wagmi-core-connectors-mock.cjs.prod.js +1 -1
  10. package/connectors/mock/dist/wagmi-core-connectors-mock.esm.js +2 -2
  11. package/connectors/walletConnect/dist/wagmi-core-connectors-walletConnect.cjs.dev.js +1 -1
  12. package/connectors/walletConnect/dist/wagmi-core-connectors-walletConnect.cjs.prod.js +1 -1
  13. package/connectors/walletConnect/dist/wagmi-core-connectors-walletConnect.esm.js +2 -2
  14. package/dist/{chains-5ceae8b1.esm.js → chains-a22bcfea.esm.js} +1 -1
  15. package/dist/declarations/src/client.d.ts +5 -1
  16. package/dist/declarations/src/errors.d.ts +23 -2
  17. package/dist/declarations/src/index.d.ts +1 -1
  18. package/dist/declarations/src/utils/index.d.ts +1 -1
  19. package/dist/declarations/src/utils/logger.d.ts +1 -0
  20. package/dist/{getProvider-316a5d3f.cjs.dev.js → getProvider-3a26f086.cjs.dev.js} +58 -16
  21. package/dist/{getProvider-a6708613.esm.js → getProvider-a3c8cf52.esm.js} +58 -18
  22. package/dist/{getProvider-51ad330f.cjs.prod.js → getProvider-b220fed1.cjs.prod.js} +58 -16
  23. package/dist/wagmi-core.cjs.dev.js +99 -32
  24. package/dist/wagmi-core.cjs.prod.js +99 -32
  25. package/dist/wagmi-core.esm.js +96 -30
  26. package/package.json +1 -1
  27. package/dist/declarations/src/utils/warn.d.ts +0 -1
@@ -1,2 +1,2 @@
1
- export { g as arbitrum, h as arbitrumGoerli, i as arbitrumRinkeby, j as foundry, k as goerli, l as hardhat, m as kovan, n as localhost, o as mainnet, p as optimism, r as optimismGoerli, q as optimismKovan, t as polygon, u as polygonMumbai, v as rinkeby, w as ropsten, s as sepolia } from '../../dist/chains-5ceae8b1.esm.js';
1
+ export { g as arbitrum, h as arbitrumGoerli, i as arbitrumRinkeby, j as foundry, k as goerli, l as hardhat, n as kovan, o as localhost, m as mainnet, p as optimism, r as optimismGoerli, q as optimismKovan, t as polygon, u as polygonMumbai, v as rinkeby, w as ropsten, s as sepolia } from '../../dist/chains-a22bcfea.esm.js';
2
2
  import '../../dist/rpcs-6e1b1718.esm.js';
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var getProvider = require('../../../dist/getProvider-316a5d3f.cjs.dev.js');
5
+ var getProvider = require('../../../dist/getProvider-3a26f086.cjs.dev.js');
6
6
  var ethers = require('ethers');
7
7
  var utils = require('ethers/lib/utils');
8
8
  require('zustand/middleware');
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var getProvider = require('../../../dist/getProvider-51ad330f.cjs.prod.js');
5
+ var getProvider = require('../../../dist/getProvider-b220fed1.cjs.prod.js');
6
6
  var ethers = require('ethers');
7
7
  var utils = require('ethers/lib/utils');
8
8
  require('zustand/middleware');
@@ -1,10 +1,10 @@
1
- import { j as Connector, _ as _classPrivateMethodInitSpec, r as _defineProperty, s as _classPrivateFieldInitSpec, n as normalizeChainId, U as UserRejectedRequestError, t as _classPrivateFieldGet, u as _classPrivateFieldSet, k as ChainNotConfiguredError, v as _classPrivateMethodGet, A as AddChainError, o as SwitchChainError } from '../../../dist/getProvider-a6708613.esm.js';
1
+ import { l as Connector, _ as _classPrivateMethodInitSpec, t as _defineProperty, u as _classPrivateFieldInitSpec, n as normalizeChainId, U as UserRejectedRequestError, v as _classPrivateFieldGet, w as _classPrivateFieldSet, m as ChainNotConfiguredError, x as _classPrivateMethodGet, A as AddChainError, q as SwitchChainError } from '../../../dist/getProvider-a3c8cf52.esm.js';
2
2
  import { providers } from 'ethers';
3
3
  import { getAddress, hexValue } from 'ethers/lib/utils';
4
4
  import 'zustand/middleware';
5
5
  import 'zustand/vanilla';
6
6
  import 'eventemitter3';
7
- import '../../../dist/chains-5ceae8b1.esm.js';
7
+ import '../../../dist/chains-a22bcfea.esm.js';
8
8
  import '../../../dist/rpcs-6e1b1718.esm.js';
9
9
 
10
10
  var _client = /*#__PURE__*/new WeakMap();
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var getProvider = require('../../../dist/getProvider-316a5d3f.cjs.dev.js');
5
+ var getProvider = require('../../../dist/getProvider-3a26f086.cjs.dev.js');
6
6
  require('zustand/middleware');
7
7
  require('zustand/vanilla');
8
8
  require('ethers');
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var getProvider = require('../../../dist/getProvider-51ad330f.cjs.prod.js');
5
+ var getProvider = require('../../../dist/getProvider-b220fed1.cjs.prod.js');
6
6
  require('zustand/middleware');
7
7
  require('zustand/vanilla');
8
8
  require('ethers');
@@ -1,10 +1,10 @@
1
- import { I as InjectedConnector, _ as _classPrivateMethodInitSpec, r as _defineProperty, v as _classPrivateMethodGet, s as _classPrivateFieldInitSpec, u as _classPrivateFieldSet, a as ConnectorNotFoundError, t as _classPrivateFieldGet, g as getClient, U as UserRejectedRequestError, R as ResourceUnavailableError } from '../../../dist/getProvider-a6708613.esm.js';
1
+ import { I as InjectedConnector, _ as _classPrivateMethodInitSpec, t as _defineProperty, x as _classPrivateMethodGet, u as _classPrivateFieldInitSpec, w as _classPrivateFieldSet, a as ConnectorNotFoundError, v as _classPrivateFieldGet, g as getClient, U as UserRejectedRequestError, R as ResourceUnavailableError } from '../../../dist/getProvider-a3c8cf52.esm.js';
2
2
  import 'zustand/middleware';
3
3
  import 'zustand/vanilla';
4
4
  import 'ethers';
5
5
  import 'ethers/lib/utils';
6
6
  import 'eventemitter3';
7
- import '../../../dist/chains-5ceae8b1.esm.js';
7
+ import '../../../dist/chains-a22bcfea.esm.js';
8
8
  import '../../../dist/rpcs-6e1b1718.esm.js';
9
9
 
10
10
  var _provider = /*#__PURE__*/new WeakMap();
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var getProvider = require('../../../dist/getProvider-316a5d3f.cjs.dev.js');
5
+ var getProvider = require('../../../dist/getProvider-3a26f086.cjs.dev.js');
6
6
  var utils = require('ethers/lib/utils');
7
7
  var ethers = require('ethers');
8
8
  var EventEmitter = require('eventemitter3');
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var getProvider = require('../../../dist/getProvider-51ad330f.cjs.prod.js');
5
+ var getProvider = require('../../../dist/getProvider-b220fed1.cjs.prod.js');
6
6
  var utils = require('ethers/lib/utils');
7
7
  var ethers = require('ethers');
8
8
  var EventEmitter = require('eventemitter3');
@@ -1,10 +1,10 @@
1
- import { r as _defineProperty, s as _classPrivateFieldInitSpec, u as _classPrivateFieldSet, t as _classPrivateFieldGet, U as UserRejectedRequestError, j as Connector, _ as _classPrivateMethodInitSpec, n as normalizeChainId, v as _classPrivateMethodGet } from '../../../dist/getProvider-a6708613.esm.js';
1
+ import { t as _defineProperty, u as _classPrivateFieldInitSpec, w as _classPrivateFieldSet, v as _classPrivateFieldGet, U as UserRejectedRequestError, l as Connector, _ as _classPrivateMethodInitSpec, n as normalizeChainId, x as _classPrivateMethodGet } from '../../../dist/getProvider-a3c8cf52.esm.js';
2
2
  import { getAddress } from 'ethers/lib/utils';
3
3
  import { providers } from 'ethers';
4
4
  import EventEmitter from 'eventemitter3';
5
5
  import 'zustand/middleware';
6
6
  import 'zustand/vanilla';
7
- import '../../../dist/chains-5ceae8b1.esm.js';
7
+ import '../../../dist/chains-a22bcfea.esm.js';
8
8
  import '../../../dist/rpcs-6e1b1718.esm.js';
9
9
 
10
10
  var _options = /*#__PURE__*/new WeakMap();
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var getProvider = require('../../../dist/getProvider-316a5d3f.cjs.dev.js');
5
+ var getProvider = require('../../../dist/getProvider-3a26f086.cjs.dev.js');
6
6
  var ethers = require('ethers');
7
7
  var utils = require('ethers/lib/utils');
8
8
  require('zustand/middleware');
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var getProvider = require('../../../dist/getProvider-51ad330f.cjs.prod.js');
5
+ var getProvider = require('../../../dist/getProvider-b220fed1.cjs.prod.js');
6
6
  var ethers = require('ethers');
7
7
  var utils = require('ethers/lib/utils');
8
8
  require('zustand/middleware');
@@ -1,10 +1,10 @@
1
- import { j as Connector, _ as _classPrivateMethodInitSpec, r as _defineProperty, s as _classPrivateFieldInitSpec, n as normalizeChainId, g as getClient, v as _classPrivateMethodGet, U as UserRejectedRequestError, t as _classPrivateFieldGet, u as _classPrivateFieldSet, o as SwitchChainError } from '../../../dist/getProvider-a6708613.esm.js';
1
+ import { l as Connector, _ as _classPrivateMethodInitSpec, t as _defineProperty, u as _classPrivateFieldInitSpec, n as normalizeChainId, g as getClient, x as _classPrivateMethodGet, U as UserRejectedRequestError, v as _classPrivateFieldGet, w as _classPrivateFieldSet, q as SwitchChainError } from '../../../dist/getProvider-a3c8cf52.esm.js';
2
2
  import { providers } from 'ethers';
3
3
  import { getAddress, hexValue } from 'ethers/lib/utils';
4
4
  import 'zustand/middleware';
5
5
  import 'zustand/vanilla';
6
6
  import 'eventemitter3';
7
- import '../../../dist/chains-5ceae8b1.esm.js';
7
+ import '../../../dist/chains-a22bcfea.esm.js';
8
8
  import '../../../dist/rpcs-6e1b1718.esm.js';
9
9
 
10
10
  /**
@@ -490,4 +490,4 @@ const allChains = [mainnet, ropsten, rinkeby, goerli, kovan, sepolia, optimism,
490
490
  const defaultChains = [mainnet, ropsten, rinkeby, goerli, kovan];
491
491
  const defaultL2Chains = [arbitrum, arbitrumRinkeby, arbitrumGoerli, optimism, optimismKovan, optimismGoerli];
492
492
 
493
- export { allChains as a, chainId as b, chain as c, defaultChains as d, defaultL2Chains as e, etherscanBlockExplorers as f, arbitrum as g, arbitrumGoerli as h, arbitrumRinkeby as i, foundry as j, goerli as k, hardhat as l, kovan as m, localhost as n, mainnet as o, optimism as p, optimismKovan as q, optimismGoerli as r, sepolia as s, polygon as t, polygonMumbai as u, rinkeby as v, ropsten as w };
493
+ export { allChains as a, chainId as b, chain as c, defaultChains as d, defaultL2Chains as e, etherscanBlockExplorers as f, arbitrum as g, arbitrumGoerli as h, arbitrumRinkeby as i, foundry as j, goerli as k, hardhat as l, mainnet as m, kovan as n, localhost as o, optimism as p, optimismKovan as q, optimismGoerli as r, sepolia as s, polygon as t, polygonMumbai as u, rinkeby as v, ropsten as w };
@@ -10,6 +10,10 @@ export declare type ClientConfig<TProvider extends Provider = Provider, TWebSock
10
10
  * @default [new InjectedConnector()]
11
11
  */
12
12
  connectors?: (() => Connector[]) | Connector[];
13
+ /** Custom logger */
14
+ logger?: {
15
+ warn: typeof console.warn | null;
16
+ };
13
17
  /** Interface for connecting to network */
14
18
  provider: ((config: {
15
19
  chainId?: number;
@@ -49,7 +53,7 @@ export declare class Client<TProvider extends Provider = Provider, TWebSocketPro
49
53
  Partial<State<TProvider, TWebSocketProvider>>
50
54
  ]
51
55
  ]>;
52
- constructor({ autoConnect, connectors, provider, storage, webSocketProvider, }: ClientConfig<TProvider, TWebSocketProvider>);
56
+ constructor({ autoConnect, connectors, provider, storage, logger, webSocketProvider, }: ClientConfig<TProvider, TWebSocketProvider>);
53
57
  get chains(): import("./types").Chain[] | undefined;
54
58
  get connectors(): Connector<any, any, any>[];
55
59
  get connector(): Connector<any, any, any> | undefined;
@@ -80,10 +80,31 @@ export declare class ContractMethodDoesNotExistError extends Error {
80
80
  }
81
81
  export declare class ContractMethodNoResultError extends Error {
82
82
  name: string;
83
- constructor({ addressOrName, chainId, functionName, }: {
83
+ constructor({ addressOrName, args, chainId, functionName, }: {
84
84
  addressOrName: string;
85
- chainId?: number;
85
+ args: any;
86
+ chainId: number;
87
+ functionName: string;
88
+ });
89
+ }
90
+ export declare class ContractMethodRevertedError extends Error {
91
+ name: string;
92
+ constructor({ addressOrName, args, chainId, functionName, errorMessage, }: {
93
+ addressOrName: string;
94
+ args: any;
95
+ chainId: number;
96
+ functionName: string;
97
+ errorMessage: string;
98
+ });
99
+ }
100
+ export declare class ContractResultDecodeError extends Error {
101
+ name: string;
102
+ constructor({ addressOrName, args, chainId, functionName, errorMessage, }: {
103
+ addressOrName: string;
104
+ args: any;
105
+ chainId: number;
86
106
  functionName: string;
107
+ errorMessage: string;
87
108
  });
88
109
  }
89
110
  export declare class ProviderChainsNotFound extends Error {
@@ -5,7 +5,7 @@ export type { ClientConfig } from './client';
5
5
  export { Connector, InjectedConnector } from './connectors';
6
6
  export type { ConnectorData, ConnectorEvents, InjectedConnectorOptions, } from './connectors';
7
7
  export { alchemyRpcUrls, allChains, chain, chainId, defaultChains, defaultL2Chains, erc20ABI, erc721ABI, etherscanBlockExplorers, infuraRpcUrls, publicRpcUrls, units, } from './constants';
8
- export { AddChainError, ChainDoesNotSupportMulticallError, ChainMismatchError, ChainNotConfiguredError, ConnectorAlreadyConnectedError, ConnectorNotFoundError, ContractMethodDoesNotExistError, ContractMethodNoResultError, ProviderChainsNotFound, ProviderRpcError, ResourceUnavailableError, RpcError, SwitchChainError, SwitchChainNotSupportedError, UserRejectedRequestError, } from './errors';
8
+ export { AddChainError, ChainDoesNotSupportMulticallError, ChainMismatchError, ChainNotConfiguredError, ConnectorAlreadyConnectedError, ConnectorNotFoundError, ContractMethodDoesNotExistError, ContractMethodNoResultError, ContractMethodRevertedError, ContractResultDecodeError, ProviderChainsNotFound, ProviderRpcError, ResourceUnavailableError, RpcError, SwitchChainError, SwitchChainNotSupportedError, UserRejectedRequestError, } from './errors';
9
9
  export { createStorage, noopStorage } from './storage';
10
10
  export type { ClientStorage as Storage } from './storage';
11
11
  export type { Chain, ChainProviderFn, Ethereum, FallbackProviderConfig, ProviderWithFallbackConfig, Provider, Signer, Unit, WebSocketProvider, } from './types';
@@ -2,7 +2,7 @@ export { configureChains } from './configureChains';
2
2
  export type { ConfigureChainsConfig } from './configureChains';
3
3
  export { deepEqual } from './deepEqual';
4
4
  export { getInjectedName } from './getInjectedName';
5
+ export { logWarn } from './logger';
5
6
  export { minimizeContractInterface } from './minimizeContractInterface';
6
7
  export { normalizeChainId } from './normalizeChainId';
7
8
  export { parseContractResult } from './parseContractResult';
8
- export { warn } from './warn';
@@ -0,0 +1 @@
1
+ export declare function logWarn(message: string): void;
@@ -239,29 +239,65 @@ class ContractMethodDoesNotExistError extends Error {
239
239
  }
240
240
  class ContractMethodNoResultError extends Error {
241
241
  constructor(_ref5) {
242
- var _chain$blockExplorers2;
243
-
244
242
  let {
245
243
  addressOrName,
244
+ args,
246
245
  chainId,
247
246
  functionName
248
247
  } = _ref5;
249
- const {
250
- chains,
251
- network
252
- } = getProvider();
253
- const chain = chains === null || chains === void 0 ? void 0 : chains.find(_ref6 => {
254
- let {
255
- id
256
- } = _ref6;
257
- return id === (chainId || network.chainId);
258
- });
259
- const blockExplorer = chain === null || chain === void 0 ? void 0 : (_chain$blockExplorers2 = chain.blockExplorers) === null || _chain$blockExplorers2 === void 0 ? void 0 : _chain$blockExplorers2.default;
260
- super(["Function \"".concat(functionName, "\" on contract \"").concat(addressOrName, "\" returned an empty response."), '', "Are you sure the function \"".concat(functionName, "\" exists on this contract?"), ...(blockExplorer ? ['', "".concat(blockExplorer === null || blockExplorer === void 0 ? void 0 : blockExplorer.name, ": ").concat(blockExplorer === null || blockExplorer === void 0 ? void 0 : blockExplorer.url, "/address/").concat(addressOrName, "#readContract")] : [])].join('\n'));
248
+ super(['Contract read returned an empty response. This could be due to any of the following:', "- The contract does not have the function \"".concat(functionName, "\","), '- The parameters passed to the contract function may be invalid, or', '- The address is not a contract.', '', "Config:", JSON.stringify({
249
+ addressOrName,
250
+ contractInterface: '...',
251
+ functionName,
252
+ chainId,
253
+ args
254
+ }, null, 2)].join('\n'));
261
255
 
262
256
  _defineProperty(this, "name", 'ContractMethodNoResultError');
263
257
  }
264
258
 
259
+ }
260
+ class ContractMethodRevertedError extends Error {
261
+ constructor(_ref6) {
262
+ let {
263
+ addressOrName,
264
+ args,
265
+ chainId,
266
+ functionName,
267
+ errorMessage
268
+ } = _ref6;
269
+ super(['Contract method reverted with an error.', '', "Config:", JSON.stringify({
270
+ addressOrName,
271
+ contractInterface: '...',
272
+ functionName,
273
+ chainId,
274
+ args
275
+ }, null, 2), '', "Details: ".concat(errorMessage)].join('\n'));
276
+
277
+ _defineProperty(this, "name", 'ContractMethodRevertedError');
278
+ }
279
+
280
+ }
281
+ class ContractResultDecodeError extends Error {
282
+ constructor(_ref7) {
283
+ let {
284
+ addressOrName,
285
+ args,
286
+ chainId,
287
+ functionName,
288
+ errorMessage
289
+ } = _ref7;
290
+ super(['Failed to decode contract function result.', '', "Config:", JSON.stringify({
291
+ addressOrName,
292
+ contractInterface: '...',
293
+ functionName,
294
+ chainId,
295
+ args
296
+ }, null, 2), '', "Details: ".concat(errorMessage)].join('\n'));
297
+
298
+ _defineProperty(this, "name", 'ContractResultDecodeError');
299
+ }
300
+
265
301
  }
266
302
  class ProviderChainsNotFound extends Error {
267
303
  constructor() {
@@ -290,10 +326,10 @@ class SwitchChainError extends ProviderRpcError {
290
326
 
291
327
  }
292
328
  class SwitchChainNotSupportedError extends Error {
293
- constructor(_ref7) {
329
+ constructor(_ref8) {
294
330
  let {
295
331
  connector
296
- } = _ref7;
332
+ } = _ref8;
297
333
  super("\"".concat(connector.name, "\" does not support programmatic chain switching."));
298
334
 
299
335
  _defineProperty(this, "name", 'SwitchChainNotSupportedError');
@@ -739,6 +775,9 @@ class Client {
739
775
  storage = createStorage({
740
776
  storage: typeof window !== 'undefined' ? window.localStorage : noopStorage
741
777
  }),
778
+ logger = {
779
+ warn: console.warn
780
+ },
742
781
  webSocketProvider: _webSocketProvider
743
782
  } = _ref;
744
783
 
@@ -807,6 +846,7 @@ class Client {
807
846
  this.config = {
808
847
  autoConnect,
809
848
  connectors,
849
+ logger,
810
850
  provider: _provider,
811
851
  storage,
812
852
  webSocketProvider: _webSocketProvider
@@ -1033,6 +1073,8 @@ exports.ConnectorAlreadyConnectedError = ConnectorAlreadyConnectedError;
1033
1073
  exports.ConnectorNotFoundError = ConnectorNotFoundError;
1034
1074
  exports.ContractMethodDoesNotExistError = ContractMethodDoesNotExistError;
1035
1075
  exports.ContractMethodNoResultError = ContractMethodNoResultError;
1076
+ exports.ContractMethodRevertedError = ContractMethodRevertedError;
1077
+ exports.ContractResultDecodeError = ContractResultDecodeError;
1036
1078
  exports.InjectedConnector = InjectedConnector;
1037
1079
  exports.ProviderChainsNotFound = ProviderChainsNotFound;
1038
1080
  exports.ProviderRpcError = ProviderRpcError;
@@ -3,7 +3,7 @@ import create from 'zustand/vanilla';
3
3
  import { providers } from 'ethers';
4
4
  import { getAddress, hexValue } from 'ethers/lib/utils';
5
5
  import EventEmitter from 'eventemitter3';
6
- import { d as defaultChains } from './chains-5ceae8b1.esm.js';
6
+ import { d as defaultChains } from './chains-a22bcfea.esm.js';
7
7
 
8
8
  function _checkPrivateRedeclaration(obj, privateCollection) {
9
9
  if (privateCollection.has(obj)) {
@@ -232,29 +232,65 @@ class ContractMethodDoesNotExistError extends Error {
232
232
  }
233
233
  class ContractMethodNoResultError extends Error {
234
234
  constructor(_ref5) {
235
- var _chain$blockExplorers2;
236
-
237
235
  let {
238
236
  addressOrName,
237
+ args,
239
238
  chainId,
240
239
  functionName
241
240
  } = _ref5;
242
- const {
243
- chains,
244
- network
245
- } = getProvider();
246
- const chain = chains === null || chains === void 0 ? void 0 : chains.find(_ref6 => {
247
- let {
248
- id
249
- } = _ref6;
250
- return id === (chainId || network.chainId);
251
- });
252
- const blockExplorer = chain === null || chain === void 0 ? void 0 : (_chain$blockExplorers2 = chain.blockExplorers) === null || _chain$blockExplorers2 === void 0 ? void 0 : _chain$blockExplorers2.default;
253
- super(["Function \"".concat(functionName, "\" on contract \"").concat(addressOrName, "\" returned an empty response."), '', "Are you sure the function \"".concat(functionName, "\" exists on this contract?"), ...(blockExplorer ? ['', "".concat(blockExplorer === null || blockExplorer === void 0 ? void 0 : blockExplorer.name, ": ").concat(blockExplorer === null || blockExplorer === void 0 ? void 0 : blockExplorer.url, "/address/").concat(addressOrName, "#readContract")] : [])].join('\n'));
241
+ super(['Contract read returned an empty response. This could be due to any of the following:', "- The contract does not have the function \"".concat(functionName, "\","), '- The parameters passed to the contract function may be invalid, or', '- The address is not a contract.', '', "Config:", JSON.stringify({
242
+ addressOrName,
243
+ contractInterface: '...',
244
+ functionName,
245
+ chainId,
246
+ args
247
+ }, null, 2)].join('\n'));
254
248
 
255
249
  _defineProperty(this, "name", 'ContractMethodNoResultError');
256
250
  }
257
251
 
252
+ }
253
+ class ContractMethodRevertedError extends Error {
254
+ constructor(_ref6) {
255
+ let {
256
+ addressOrName,
257
+ args,
258
+ chainId,
259
+ functionName,
260
+ errorMessage
261
+ } = _ref6;
262
+ super(['Contract method reverted with an error.', '', "Config:", JSON.stringify({
263
+ addressOrName,
264
+ contractInterface: '...',
265
+ functionName,
266
+ chainId,
267
+ args
268
+ }, null, 2), '', "Details: ".concat(errorMessage)].join('\n'));
269
+
270
+ _defineProperty(this, "name", 'ContractMethodRevertedError');
271
+ }
272
+
273
+ }
274
+ class ContractResultDecodeError extends Error {
275
+ constructor(_ref7) {
276
+ let {
277
+ addressOrName,
278
+ args,
279
+ chainId,
280
+ functionName,
281
+ errorMessage
282
+ } = _ref7;
283
+ super(['Failed to decode contract function result.', '', "Config:", JSON.stringify({
284
+ addressOrName,
285
+ contractInterface: '...',
286
+ functionName,
287
+ chainId,
288
+ args
289
+ }, null, 2), '', "Details: ".concat(errorMessage)].join('\n'));
290
+
291
+ _defineProperty(this, "name", 'ContractResultDecodeError');
292
+ }
293
+
258
294
  }
259
295
  class ProviderChainsNotFound extends Error {
260
296
  constructor() {
@@ -283,10 +319,10 @@ class SwitchChainError extends ProviderRpcError {
283
319
 
284
320
  }
285
321
  class SwitchChainNotSupportedError extends Error {
286
- constructor(_ref7) {
322
+ constructor(_ref8) {
287
323
  let {
288
324
  connector
289
- } = _ref7;
325
+ } = _ref8;
290
326
  super("\"".concat(connector.name, "\" does not support programmatic chain switching."));
291
327
 
292
328
  _defineProperty(this, "name", 'SwitchChainNotSupportedError');
@@ -732,6 +768,9 @@ class Client {
732
768
  storage = createStorage({
733
769
  storage: typeof window !== 'undefined' ? window.localStorage : noopStorage
734
770
  }),
771
+ logger = {
772
+ warn: console.warn
773
+ },
735
774
  webSocketProvider: _webSocketProvider
736
775
  } = _ref;
737
776
 
@@ -800,6 +839,7 @@ class Client {
800
839
  this.config = {
801
840
  autoConnect,
802
841
  connectors,
842
+ logger,
803
843
  provider: _provider,
804
844
  storage,
805
845
  webSocketProvider: _webSocketProvider
@@ -1016,4 +1056,4 @@ function getProvider() {
1016
1056
  return client.provider;
1017
1057
  }
1018
1058
 
1019
- export { AddChainError as A, ConnectorAlreadyConnectedError as C, InjectedConnector as I, ProviderChainsNotFound as P, ResourceUnavailableError as R, SwitchChainNotSupportedError as S, UserRejectedRequestError as U, _classPrivateMethodInitSpec as _, ConnectorNotFoundError as a, ChainMismatchError as b, ContractMethodDoesNotExistError as c, getProvider as d, ChainDoesNotSupportMulticallError as e, ContractMethodNoResultError as f, getClient as g, createClient as h, Client as i, Connector as j, ChainNotConfiguredError as k, ProviderRpcError as l, RpcError as m, normalizeChainId as n, SwitchChainError as o, createStorage as p, noopStorage as q, _defineProperty as r, _classPrivateFieldInitSpec as s, _classPrivateFieldGet as t, _classPrivateFieldSet as u, _classPrivateMethodGet as v };
1059
+ export { AddChainError as A, ConnectorAlreadyConnectedError as C, InjectedConnector as I, ProviderChainsNotFound as P, ResourceUnavailableError as R, SwitchChainNotSupportedError as S, UserRejectedRequestError as U, _classPrivateMethodInitSpec as _, ConnectorNotFoundError as a, ChainMismatchError as b, ContractMethodDoesNotExistError as c, getProvider as d, ChainDoesNotSupportMulticallError as e, ContractMethodRevertedError as f, getClient as g, ContractMethodNoResultError as h, ContractResultDecodeError as i, createClient as j, Client as k, Connector as l, ChainNotConfiguredError as m, normalizeChainId as n, ProviderRpcError as o, RpcError as p, SwitchChainError as q, createStorage as r, noopStorage as s, _defineProperty as t, _classPrivateFieldInitSpec as u, _classPrivateFieldGet as v, _classPrivateFieldSet as w, _classPrivateMethodGet as x };
@@ -239,29 +239,65 @@ class ContractMethodDoesNotExistError extends Error {
239
239
  }
240
240
  class ContractMethodNoResultError extends Error {
241
241
  constructor(_ref5) {
242
- var _chain$blockExplorers2;
243
-
244
242
  let {
245
243
  addressOrName,
244
+ args,
246
245
  chainId,
247
246
  functionName
248
247
  } = _ref5;
249
- const {
250
- chains,
251
- network
252
- } = getProvider();
253
- const chain = chains === null || chains === void 0 ? void 0 : chains.find(_ref6 => {
254
- let {
255
- id
256
- } = _ref6;
257
- return id === (chainId || network.chainId);
258
- });
259
- const blockExplorer = chain === null || chain === void 0 ? void 0 : (_chain$blockExplorers2 = chain.blockExplorers) === null || _chain$blockExplorers2 === void 0 ? void 0 : _chain$blockExplorers2.default;
260
- super(["Function \"".concat(functionName, "\" on contract \"").concat(addressOrName, "\" returned an empty response."), '', "Are you sure the function \"".concat(functionName, "\" exists on this contract?"), ...(blockExplorer ? ['', "".concat(blockExplorer === null || blockExplorer === void 0 ? void 0 : blockExplorer.name, ": ").concat(blockExplorer === null || blockExplorer === void 0 ? void 0 : blockExplorer.url, "/address/").concat(addressOrName, "#readContract")] : [])].join('\n'));
248
+ super(['Contract read returned an empty response. This could be due to any of the following:', "- The contract does not have the function \"".concat(functionName, "\","), '- The parameters passed to the contract function may be invalid, or', '- The address is not a contract.', '', "Config:", JSON.stringify({
249
+ addressOrName,
250
+ contractInterface: '...',
251
+ functionName,
252
+ chainId,
253
+ args
254
+ }, null, 2)].join('\n'));
261
255
 
262
256
  _defineProperty(this, "name", 'ContractMethodNoResultError');
263
257
  }
264
258
 
259
+ }
260
+ class ContractMethodRevertedError extends Error {
261
+ constructor(_ref6) {
262
+ let {
263
+ addressOrName,
264
+ args,
265
+ chainId,
266
+ functionName,
267
+ errorMessage
268
+ } = _ref6;
269
+ super(['Contract method reverted with an error.', '', "Config:", JSON.stringify({
270
+ addressOrName,
271
+ contractInterface: '...',
272
+ functionName,
273
+ chainId,
274
+ args
275
+ }, null, 2), '', "Details: ".concat(errorMessage)].join('\n'));
276
+
277
+ _defineProperty(this, "name", 'ContractMethodRevertedError');
278
+ }
279
+
280
+ }
281
+ class ContractResultDecodeError extends Error {
282
+ constructor(_ref7) {
283
+ let {
284
+ addressOrName,
285
+ args,
286
+ chainId,
287
+ functionName,
288
+ errorMessage
289
+ } = _ref7;
290
+ super(['Failed to decode contract function result.', '', "Config:", JSON.stringify({
291
+ addressOrName,
292
+ contractInterface: '...',
293
+ functionName,
294
+ chainId,
295
+ args
296
+ }, null, 2), '', "Details: ".concat(errorMessage)].join('\n'));
297
+
298
+ _defineProperty(this, "name", 'ContractResultDecodeError');
299
+ }
300
+
265
301
  }
266
302
  class ProviderChainsNotFound extends Error {
267
303
  constructor() {
@@ -290,10 +326,10 @@ class SwitchChainError extends ProviderRpcError {
290
326
 
291
327
  }
292
328
  class SwitchChainNotSupportedError extends Error {
293
- constructor(_ref7) {
329
+ constructor(_ref8) {
294
330
  let {
295
331
  connector
296
- } = _ref7;
332
+ } = _ref8;
297
333
  super("\"".concat(connector.name, "\" does not support programmatic chain switching."));
298
334
 
299
335
  _defineProperty(this, "name", 'SwitchChainNotSupportedError');
@@ -739,6 +775,9 @@ class Client {
739
775
  storage = createStorage({
740
776
  storage: typeof window !== 'undefined' ? window.localStorage : noopStorage
741
777
  }),
778
+ logger = {
779
+ warn: console.warn
780
+ },
742
781
  webSocketProvider: _webSocketProvider
743
782
  } = _ref;
744
783
 
@@ -807,6 +846,7 @@ class Client {
807
846
  this.config = {
808
847
  autoConnect,
809
848
  connectors,
849
+ logger,
810
850
  provider: _provider,
811
851
  storage,
812
852
  webSocketProvider: _webSocketProvider
@@ -1033,6 +1073,8 @@ exports.ConnectorAlreadyConnectedError = ConnectorAlreadyConnectedError;
1033
1073
  exports.ConnectorNotFoundError = ConnectorNotFoundError;
1034
1074
  exports.ContractMethodDoesNotExistError = ContractMethodDoesNotExistError;
1035
1075
  exports.ContractMethodNoResultError = ContractMethodNoResultError;
1076
+ exports.ContractMethodRevertedError = ContractMethodRevertedError;
1077
+ exports.ContractResultDecodeError = ContractResultDecodeError;
1036
1078
  exports.InjectedConnector = InjectedConnector;
1037
1079
  exports.ProviderChainsNotFound = ProviderChainsNotFound;
1038
1080
  exports.ProviderRpcError = ProviderRpcError;