@wagmi/core 0.4.3 → 0.4.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 (36) hide show
  1. package/README.md +1 -1
  2. package/chains/dist/wagmi-core-chains.cjs.dev.js +1 -1
  3. package/chains/dist/wagmi-core-chains.cjs.prod.js +1 -1
  4. package/chains/dist/wagmi-core-chains.esm.js +1 -1
  5. package/connectors/coinbaseWallet/dist/wagmi-core-connectors-coinbaseWallet.cjs.dev.js +2 -2
  6. package/connectors/coinbaseWallet/dist/wagmi-core-connectors-coinbaseWallet.cjs.prod.js +2 -2
  7. package/connectors/coinbaseWallet/dist/wagmi-core-connectors-coinbaseWallet.esm.js +2 -2
  8. package/connectors/metaMask/dist/wagmi-core-connectors-metaMask.cjs.dev.js +74 -3
  9. package/connectors/metaMask/dist/wagmi-core-connectors-metaMask.cjs.prod.js +74 -3
  10. package/connectors/metaMask/dist/wagmi-core-connectors-metaMask.esm.js +74 -3
  11. package/connectors/mock/dist/wagmi-core-connectors-mock.cjs.dev.js +2 -2
  12. package/connectors/mock/dist/wagmi-core-connectors-mock.cjs.prod.js +2 -2
  13. package/connectors/mock/dist/wagmi-core-connectors-mock.esm.js +2 -2
  14. package/connectors/walletConnect/dist/wagmi-core-connectors-walletConnect.cjs.dev.js +3 -3
  15. package/connectors/walletConnect/dist/wagmi-core-connectors-walletConnect.cjs.prod.js +3 -3
  16. package/connectors/walletConnect/dist/wagmi-core-connectors-walletConnect.esm.js +3 -3
  17. package/dist/{base-e71ae4b2.cjs.dev.js → base-797ad073.cjs.prod.js} +17 -3
  18. package/dist/{base-2d484f6c.cjs.prod.js → base-90b7f3e4.cjs.dev.js} +17 -3
  19. package/dist/{base-e66f9622.esm.js → base-b565d5d4.esm.js} +17 -4
  20. package/dist/{chains-d970ee8d.cjs.dev.js → chains-7e6dc59c.cjs.dev.js} +1 -1
  21. package/dist/{chains-865492ea.cjs.prod.js → chains-f7bb3211.cjs.prod.js} +1 -1
  22. package/dist/{chains-c389721d.esm.js → chains-fd2c546c.esm.js} +1 -1
  23. package/dist/{client-53f2119c.cjs.dev.js → client-71ece661.cjs.dev.js} +24 -23
  24. package/dist/{client-ffba0e25.esm.js → client-a05fd511.esm.js} +20 -20
  25. package/dist/{client-1feb9121.cjs.prod.js → client-a6e61429.cjs.prod.js} +24 -23
  26. package/dist/declarations/src/connectors/injected.d.ts +2 -0
  27. package/dist/declarations/src/connectors/metaMask.d.ts +16 -1
  28. package/dist/declarations/src/errors.d.ts +9 -0
  29. package/dist/declarations/src/index.d.ts +2 -2
  30. package/dist/declarations/src/types/index.d.ts +24 -0
  31. package/dist/declarations/src/utils/deepEqual.d.ts +2 -0
  32. package/dist/declarations/src/utils/index.d.ts +1 -0
  33. package/dist/wagmi-core.cjs.dev.js +76 -14
  34. package/dist/wagmi-core.cjs.prod.js +76 -14
  35. package/dist/wagmi-core.esm.js +71 -11
  36. package/package.json +1 -1
@@ -2,14 +2,14 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var client = require('./client-53f2119c.cjs.dev.js');
6
- var base = require('./base-e71ae4b2.cjs.dev.js');
5
+ var client = require('./client-71ece661.cjs.dev.js');
6
+ var base = require('./base-90b7f3e4.cjs.dev.js');
7
7
  var ethers$1 = require('ethers/lib/ethers');
8
8
  var utils = require('ethers/lib/utils');
9
9
  var ethers = require('ethers');
10
10
  var shallow = require('zustand/shallow');
11
11
  var rpcs = require('./rpcs-f1d24f0e.cjs.dev.js');
12
- var chains = require('./chains-d970ee8d.cjs.dev.js');
12
+ var chains = require('./chains-7e6dc59c.cjs.dev.js');
13
13
  require('zustand/vanilla');
14
14
  require('zustand/middleware');
15
15
  require('eventemitter3');
@@ -132,6 +132,44 @@ function fallbackProvider(targetQuorum, minQuorum, providers_, _ref4) {
132
132
  }
133
133
  }
134
134
 
135
+ /** Forked from https://github.com/epoberezkin/fast-deep-equal */
136
+ function deepEqual(a, b) {
137
+ if (a === b) return true;
138
+
139
+ if (a && b && typeof a === 'object' && typeof b === 'object') {
140
+ if (a.constructor !== b.constructor) return false;
141
+ let length;
142
+ let i;
143
+
144
+ if (Array.isArray(a) && Array.isArray(b)) {
145
+ length = a.length;
146
+ if (length != b.length) return false;
147
+
148
+ for (i = length; i-- !== 0;) if (!deepEqual(a[i], b[i])) return false;
149
+
150
+ return true;
151
+ }
152
+
153
+ if (a.valueOf !== Object.prototype.valueOf) return a.valueOf() === b.valueOf();
154
+ if (a.toString !== Object.prototype.toString) return a.toString() === b.toString();
155
+ const keys = Object.keys(a);
156
+ length = keys.length;
157
+ if (length !== Object.keys(b).length) return false;
158
+
159
+ for (i = length; i-- !== 0;) if (!Object.prototype.hasOwnProperty.call(b, keys[i])) return false;
160
+
161
+ for (i = length; i-- !== 0;) {
162
+ const key = keys[i];
163
+ if (key && !deepEqual(a[key], b[key])) return false;
164
+ }
165
+
166
+ return true;
167
+ } // true if both NaN, false otherwise
168
+
169
+
170
+ return a !== a && b !== b;
171
+ }
172
+
135
173
  // https://ethereum.org/en/developers/docs/standards/tokens/erc-20
136
174
  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
137
175
 
@@ -183,29 +221,30 @@ async function connect(_ref) {
183
221
  chainId,
184
222
  connector
185
223
  } = _ref;
186
- const activeConnector = client.client.connector;
224
+ const client$1 = client.getClient();
225
+ const activeConnector = client$1.connector;
187
226
  if (connector.id === (activeConnector === null || activeConnector === void 0 ? void 0 : activeConnector.id)) throw new base.ConnectorAlreadyConnectedError();
188
227
 
189
228
  try {
190
- client.client.setState(x => ({ ...x,
229
+ client$1.setState(x => ({ ...x,
191
230
  status: 'connecting'
192
231
  }));
193
232
  const data = await connector.connect({
194
233
  chainId
195
234
  });
196
- client.client.setLastUsedConnector(connector.id);
197
- client.client.setState(x => ({ ...x,
235
+ client$1.setLastUsedConnector(connector.id);
236
+ client$1.setState(x => ({ ...x,
198
237
  connector,
199
238
  chains: connector === null || connector === void 0 ? void 0 : connector.chains,
200
239
  data,
201
240
  status: 'connected'
202
241
  }));
203
- client.client.storage.setItem('connected', true);
242
+ client$1.storage.setItem('connected', true);
204
243
  return { ...data,
205
244
  connector
206
245
  };
207
246
  } catch (err) {
208
- client.client.setState(x => ({ ...x,
247
+ client$1.setState(x => ({ ...x,
209
248
  status: 'disconnected'
210
249
  }));
211
250
  throw err;
@@ -346,7 +385,7 @@ async function multicall(_ref) {
346
385
  if (!contract[functionName]) console.warn("\"".concat(functionName, "\" is not in the interface for contract \"").concat(addressOrName, "\""));
347
386
  return {
348
387
  target: addressOrName,
349
- allowFailure: allowFailure,
388
+ allowFailure,
350
389
  callData
351
390
  };
352
391
  });
@@ -357,18 +396,38 @@ async function multicall(_ref) {
357
396
  returnData,
358
397
  success
359
398
  } = _ref3;
360
- if (!success) return undefined;
399
+ if (!success) return null;
361
400
  const {
362
401
  addressOrName,
363
402
  contractInterface,
364
403
  functionName
365
404
  } = contracts[i];
405
+
406
+ if (returnData === '0x') {
407
+ var _chain$blockExplorers;
408
+
409
+ const err = new base.ContractMethodNoResultError({
410
+ addressOrName,
411
+ blockExplorer: (_chain$blockExplorers = chain.blockExplorers) === null || _chain$blockExplorers === void 0 ? void 0 : _chain$blockExplorers.default,
412
+ functionName
413
+ });
414
+ if (!allowFailure) throw err;
415
+ console.warn(err.message);
416
+ return null;
417
+ }
418
+
366
419
  const contract = getContract({
367
420
  addressOrName,
368
421
  contractInterface
369
422
  });
370
- const result = contract.interface.decodeFunctionResult(functionName, returnData);
371
- return Array.isArray(result) && result.length === 1 ? result[0] : result;
423
+
424
+ try {
425
+ const result = contract.interface.decodeFunctionResult(functionName, returnData);
426
+ return Array.isArray(result) && result.length === 1 ? result[0] : result;
427
+ } catch (err) {
428
+ if (!allowFailure) throw err;
429
+ return null;
430
+ }
372
431
  });
373
432
  }
374
433
 
@@ -414,6 +473,7 @@ async function readContracts(_ref) {
414
473
 
415
474
  return (await Promise.all(promises)).flat();
416
475
  } catch (err) {
476
+ if (err instanceof base.ContractMethodNoResultError) throw err;
417
477
  const promises = contracts.map(contract => readContract({ ...contract,
418
478
  overrides
419
479
  }));
@@ -422,7 +482,7 @@ async function readContracts(_ref) {
422
482
  return (await Promise.allSettled(promises)).map(result => result.status === 'fulfilled' ? result.value : null);
423
483
  }
424
484
 
425
- return Promise.all(promises);
485
+ return await Promise.all(promises);
426
486
  }
427
487
  }
428
488
 
@@ -1084,6 +1144,7 @@ exports.ChainNotConfiguredError = base.ChainNotConfiguredError;
1084
1144
  exports.Connector = base.Connector;
1085
1145
  exports.ConnectorAlreadyConnectedError = base.ConnectorAlreadyConnectedError;
1086
1146
  exports.ConnectorNotFoundError = base.ConnectorNotFoundError;
1147
+ exports.ContractMethodNoResultError = base.ContractMethodNoResultError;
1087
1148
  exports.ProviderChainsNotFound = base.ProviderChainsNotFound;
1088
1149
  exports.ProviderRpcError = base.ProviderRpcError;
1089
1150
  exports.ResourceUnavailableError = base.ResourceUnavailableError;
@@ -1103,6 +1164,7 @@ exports.defaultL2Chains = chains.defaultL2Chains;
1103
1164
  exports.etherscanBlockExplorers = chains.etherscanBlockExplorers;
1104
1165
  exports.configureChains = configureChains;
1105
1166
  exports.connect = connect;
1167
+ exports.deepEqual = deepEqual;
1106
1168
  exports.disconnect = disconnect;
1107
1169
  exports.erc20ABI = erc20ABI;
1108
1170
  exports.erc721ABI = erc721ABI;
@@ -2,14 +2,14 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var client = require('./client-1feb9121.cjs.prod.js');
6
- var base = require('./base-2d484f6c.cjs.prod.js');
5
+ var client = require('./client-a6e61429.cjs.prod.js');
6
+ var base = require('./base-797ad073.cjs.prod.js');
7
7
  var ethers$1 = require('ethers/lib/ethers');
8
8
  var utils = require('ethers/lib/utils');
9
9
  var ethers = require('ethers');
10
10
  var shallow = require('zustand/shallow');
11
11
  var rpcs = require('./rpcs-1fd0a12f.cjs.prod.js');
12
- var chains = require('./chains-865492ea.cjs.prod.js');
12
+ var chains = require('./chains-f7bb3211.cjs.prod.js');
13
13
  require('zustand/vanilla');
14
14
  require('zustand/middleware');
15
15
  require('eventemitter3');
@@ -132,6 +132,44 @@ function fallbackProvider(targetQuorum, minQuorum, providers_, _ref4) {
132
132
  }
133
133
  }
134
134
 
135
+ /** Forked from https://github.com/epoberezkin/fast-deep-equal */
136
+ function deepEqual(a, b) {
137
+ if (a === b) return true;
138
+
139
+ if (a && b && typeof a === 'object' && typeof b === 'object') {
140
+ if (a.constructor !== b.constructor) return false;
141
+ let length;
142
+ let i;
143
+
144
+ if (Array.isArray(a) && Array.isArray(b)) {
145
+ length = a.length;
146
+ if (length != b.length) return false;
147
+
148
+ for (i = length; i-- !== 0;) if (!deepEqual(a[i], b[i])) return false;
149
+
150
+ return true;
151
+ }
152
+
153
+ if (a.valueOf !== Object.prototype.valueOf) return a.valueOf() === b.valueOf();
154
+ if (a.toString !== Object.prototype.toString) return a.toString() === b.toString();
155
+ const keys = Object.keys(a);
156
+ length = keys.length;
157
+ if (length !== Object.keys(b).length) return false;
158
+
159
+ for (i = length; i-- !== 0;) if (!Object.prototype.hasOwnProperty.call(b, keys[i])) return false;
160
+
161
+ for (i = length; i-- !== 0;) {
162
+ const key = keys[i];
163
+ if (key && !deepEqual(a[key], b[key])) return false;
164
+ }
165
+
166
+ return true;
167
+ } // true if both NaN, false otherwise
168
+
169
+
170
+ return a !== a && b !== b;
171
+ }
172
+
135
173
  // https://ethereum.org/en/developers/docs/standards/tokens/erc-20
136
174
  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
137
175
 
@@ -183,29 +221,30 @@ async function connect(_ref) {
183
221
  chainId,
184
222
  connector
185
223
  } = _ref;
186
- const activeConnector = client.client.connector;
224
+ const client$1 = client.getClient();
225
+ const activeConnector = client$1.connector;
187
226
  if (connector.id === (activeConnector === null || activeConnector === void 0 ? void 0 : activeConnector.id)) throw new base.ConnectorAlreadyConnectedError();
188
227
 
189
228
  try {
190
- client.client.setState(x => ({ ...x,
229
+ client$1.setState(x => ({ ...x,
191
230
  status: 'connecting'
192
231
  }));
193
232
  const data = await connector.connect({
194
233
  chainId
195
234
  });
196
- client.client.setLastUsedConnector(connector.id);
197
- client.client.setState(x => ({ ...x,
235
+ client$1.setLastUsedConnector(connector.id);
236
+ client$1.setState(x => ({ ...x,
198
237
  connector,
199
238
  chains: connector === null || connector === void 0 ? void 0 : connector.chains,
200
239
  data,
201
240
  status: 'connected'
202
241
  }));
203
- client.client.storage.setItem('connected', true);
242
+ client$1.storage.setItem('connected', true);
204
243
  return { ...data,
205
244
  connector
206
245
  };
207
246
  } catch (err) {
208
- client.client.setState(x => ({ ...x,
247
+ client$1.setState(x => ({ ...x,
209
248
  status: 'disconnected'
210
249
  }));
211
250
  throw err;
@@ -346,7 +385,7 @@ async function multicall(_ref) {
346
385
  if (!contract[functionName]) console.warn("\"".concat(functionName, "\" is not in the interface for contract \"").concat(addressOrName, "\""));
347
386
  return {
348
387
  target: addressOrName,
349
- allowFailure: allowFailure,
388
+ allowFailure,
350
389
  callData
351
390
  };
352
391
  });
@@ -357,18 +396,38 @@ async function multicall(_ref) {
357
396
  returnData,
358
397
  success
359
398
  } = _ref3;
360
- if (!success) return undefined;
399
+ if (!success) return null;
361
400
  const {
362
401
  addressOrName,
363
402
  contractInterface,
364
403
  functionName
365
404
  } = contracts[i];
405
+
406
+ if (returnData === '0x') {
407
+ var _chain$blockExplorers;
408
+
409
+ const err = new base.ContractMethodNoResultError({
410
+ addressOrName,
411
+ blockExplorer: (_chain$blockExplorers = chain.blockExplorers) === null || _chain$blockExplorers === void 0 ? void 0 : _chain$blockExplorers.default,
412
+ functionName
413
+ });
414
+ if (!allowFailure) throw err;
415
+ console.warn(err.message);
416
+ return null;
417
+ }
418
+
366
419
  const contract = getContract({
367
420
  addressOrName,
368
421
  contractInterface
369
422
  });
370
- const result = contract.interface.decodeFunctionResult(functionName, returnData);
371
- return Array.isArray(result) && result.length === 1 ? result[0] : result;
423
+
424
+ try {
425
+ const result = contract.interface.decodeFunctionResult(functionName, returnData);
426
+ return Array.isArray(result) && result.length === 1 ? result[0] : result;
427
+ } catch (err) {
428
+ if (!allowFailure) throw err;
429
+ return null;
430
+ }
372
431
  });
373
432
  }
374
433
 
@@ -414,6 +473,7 @@ async function readContracts(_ref) {
414
473
 
415
474
  return (await Promise.all(promises)).flat();
416
475
  } catch (err) {
476
+ if (err instanceof base.ContractMethodNoResultError) throw err;
417
477
  const promises = contracts.map(contract => readContract({ ...contract,
418
478
  overrides
419
479
  }));
@@ -422,7 +482,7 @@ async function readContracts(_ref) {
422
482
  return (await Promise.allSettled(promises)).map(result => result.status === 'fulfilled' ? result.value : null);
423
483
  }
424
484
 
425
- return Promise.all(promises);
485
+ return await Promise.all(promises);
426
486
  }
427
487
  }
428
488
 
@@ -1084,6 +1144,7 @@ exports.ChainNotConfiguredError = base.ChainNotConfiguredError;
1084
1144
  exports.Connector = base.Connector;
1085
1145
  exports.ConnectorAlreadyConnectedError = base.ConnectorAlreadyConnectedError;
1086
1146
  exports.ConnectorNotFoundError = base.ConnectorNotFoundError;
1147
+ exports.ContractMethodNoResultError = base.ContractMethodNoResultError;
1087
1148
  exports.ProviderChainsNotFound = base.ProviderChainsNotFound;
1088
1149
  exports.ProviderRpcError = base.ProviderRpcError;
1089
1150
  exports.ResourceUnavailableError = base.ResourceUnavailableError;
@@ -1103,6 +1164,7 @@ exports.defaultL2Chains = chains.defaultL2Chains;
1103
1164
  exports.etherscanBlockExplorers = chains.etherscanBlockExplorers;
1104
1165
  exports.configureChains = configureChains;
1105
1166
  exports.connect = connect;
1167
+ exports.deepEqual = deepEqual;
1106
1168
  exports.disconnect = disconnect;
1107
1169
  exports.erc20ABI = erc20ABI;
1108
1170
  exports.erc721ABI = erc721ABI;
@@ -1,13 +1,13 @@
1
- import { c as client, g as getClient } from './client-ffba0e25.esm.js';
2
- export { C as Client, I as InjectedConnector, a as createClient, b as createStorage, n as noopStorage } from './client-ffba0e25.esm.js';
3
- import { C as ConnectorAlreadyConnectedError, P as ProviderChainsNotFound, a as ChainDoesNotSupportMulticallError, b as ConnectorNotFoundError, c as ChainMismatchError, U as UserRejectedRequestError, n as normalizeChainId, S as SwitchChainNotSupportedError } from './base-e66f9622.esm.js';
4
- export { A as AddChainError, a as ChainDoesNotSupportMulticallError, c as ChainMismatchError, e as ChainNotConfiguredError, d as Connector, C as ConnectorAlreadyConnectedError, b as ConnectorNotFoundError, P as ProviderChainsNotFound, f as ProviderRpcError, R as ResourceUnavailableError, g as RpcError, h as SwitchChainError, S as SwitchChainNotSupportedError, U as UserRejectedRequestError, n as normalizeChainId } from './base-e66f9622.esm.js';
1
+ import { g as getClient } from './client-a05fd511.esm.js';
2
+ export { C as Client, I as InjectedConnector, c as createClient, a as createStorage, n as noopStorage } from './client-a05fd511.esm.js';
3
+ import { C as ConnectorAlreadyConnectedError, P as ProviderChainsNotFound, a as ChainDoesNotSupportMulticallError, b as ContractMethodNoResultError, c as ConnectorNotFoundError, d as ChainMismatchError, U as UserRejectedRequestError, n as normalizeChainId, S as SwitchChainNotSupportedError } from './base-b565d5d4.esm.js';
4
+ export { A as AddChainError, a as ChainDoesNotSupportMulticallError, d as ChainMismatchError, f as ChainNotConfiguredError, e as Connector, C as ConnectorAlreadyConnectedError, c as ConnectorNotFoundError, b as ContractMethodNoResultError, P as ProviderChainsNotFound, g as ProviderRpcError, R as ResourceUnavailableError, h as RpcError, i as SwitchChainError, S as SwitchChainNotSupportedError, U as UserRejectedRequestError, n as normalizeChainId } from './base-b565d5d4.esm.js';
5
5
  import { logger, Contract as Contract$1 } from 'ethers/lib/ethers';
6
6
  import { isAddress, Logger, formatUnits, getAddress } from 'ethers/lib/utils';
7
7
  import { providers, Contract } from 'ethers';
8
8
  import shallow from 'zustand/shallow';
9
9
  export { a as alchemyRpcUrls, i as infuraRpcUrls, p as publicRpcUrls } from './rpcs-b73a8f60.esm.js';
10
- export { a as allChains, c as chain, b as chainId, d as defaultChains, e as defaultL2Chains, f as etherscanBlockExplorers } from './chains-c389721d.esm.js';
10
+ export { a as allChains, c as chain, b as chainId, d as defaultChains, e as defaultL2Chains, f as etherscanBlockExplorers } from './chains-fd2c546c.esm.js';
11
11
  import 'zustand/vanilla';
12
12
  import 'zustand/middleware';
13
13
  import 'eventemitter3';
@@ -126,6 +126,44 @@ function fallbackProvider(targetQuorum, minQuorum, providers_, _ref4) {
126
126
  }
127
127
  }
128
128
 
129
+ /** Forked from https://github.com/epoberezkin/fast-deep-equal */
130
+ function deepEqual(a, b) {
131
+ if (a === b) return true;
132
+
133
+ if (a && b && typeof a === 'object' && typeof b === 'object') {
134
+ if (a.constructor !== b.constructor) return false;
135
+ let length;
136
+ let i;
137
+
138
+ if (Array.isArray(a) && Array.isArray(b)) {
139
+ length = a.length;
140
+ if (length != b.length) return false;
141
+
142
+ for (i = length; i-- !== 0;) if (!deepEqual(a[i], b[i])) return false;
143
+
144
+ return true;
145
+ }
146
+
147
+ if (a.valueOf !== Object.prototype.valueOf) return a.valueOf() === b.valueOf();
148
+ if (a.toString !== Object.prototype.toString) return a.toString() === b.toString();
149
+ const keys = Object.keys(a);
150
+ length = keys.length;
151
+ if (length !== Object.keys(b).length) return false;
152
+
153
+ for (i = length; i-- !== 0;) if (!Object.prototype.hasOwnProperty.call(b, keys[i])) return false;
154
+
155
+ for (i = length; i-- !== 0;) {
156
+ const key = keys[i];
157
+ if (key && !deepEqual(a[key], b[key])) return false;
158
+ }
159
+
160
+ return true;
161
+ } // true if both NaN, false otherwise
162
+
163
+
164
+ return a !== a && b !== b;
165
+ }
166
+
129
167
  // https://ethereum.org/en/developers/docs/standards/tokens/erc-20
130
168
  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
131
169
 
@@ -177,6 +215,7 @@ async function connect(_ref) {
177
215
  chainId,
178
216
  connector
179
217
  } = _ref;
218
+ const client = getClient();
180
219
  const activeConnector = client.connector;
181
220
  if (connector.id === (activeConnector === null || activeConnector === void 0 ? void 0 : activeConnector.id)) throw new ConnectorAlreadyConnectedError();
182
221
 
@@ -340,7 +379,7 @@ async function multicall(_ref) {
340
379
  if (!contract[functionName]) console.warn("\"".concat(functionName, "\" is not in the interface for contract \"").concat(addressOrName, "\""));
341
380
  return {
342
381
  target: addressOrName,
343
- allowFailure: allowFailure,
382
+ allowFailure,
344
383
  callData
345
384
  };
346
385
  });
@@ -351,18 +390,38 @@ async function multicall(_ref) {
351
390
  returnData,
352
391
  success
353
392
  } = _ref3;
354
- if (!success) return undefined;
393
+ if (!success) return null;
355
394
  const {
356
395
  addressOrName,
357
396
  contractInterface,
358
397
  functionName
359
398
  } = contracts[i];
399
+
400
+ if (returnData === '0x') {
401
+ var _chain$blockExplorers;
402
+
403
+ const err = new ContractMethodNoResultError({
404
+ addressOrName,
405
+ blockExplorer: (_chain$blockExplorers = chain.blockExplorers) === null || _chain$blockExplorers === void 0 ? void 0 : _chain$blockExplorers.default,
406
+ functionName
407
+ });
408
+ if (!allowFailure) throw err;
409
+ console.warn(err.message);
410
+ return null;
411
+ }
412
+
360
413
  const contract = getContract({
361
414
  addressOrName,
362
415
  contractInterface
363
416
  });
364
- const result = contract.interface.decodeFunctionResult(functionName, returnData);
365
- return Array.isArray(result) && result.length === 1 ? result[0] : result;
417
+
418
+ try {
419
+ const result = contract.interface.decodeFunctionResult(functionName, returnData);
420
+ return Array.isArray(result) && result.length === 1 ? result[0] : result;
421
+ } catch (err) {
422
+ if (!allowFailure) throw err;
423
+ return null;
424
+ }
366
425
  });
367
426
  }
368
427
 
@@ -408,6 +467,7 @@ async function readContracts(_ref) {
408
467
 
409
468
  return (await Promise.all(promises)).flat();
410
469
  } catch (err) {
470
+ if (err instanceof ContractMethodNoResultError) throw err;
411
471
  const promises = contracts.map(contract => readContract({ ...contract,
412
472
  overrides
413
473
  }));
@@ -416,7 +476,7 @@ async function readContracts(_ref) {
416
476
  return (await Promise.allSettled(promises)).map(result => result.status === 'fulfilled' ? result.value : null);
417
477
  }
418
478
 
419
- return Promise.all(promises);
479
+ return await Promise.all(promises);
420
480
  }
421
481
  }
422
482
 
@@ -1066,4 +1126,4 @@ async function waitForTransaction(_ref) {
1066
1126
  return await promise;
1067
1127
  }
1068
1128
 
1069
- export { configureChains, connect, disconnect, erc20ABI, erc721ABI, fetchBalance, fetchBlockNumber, fetchEnsAddress, fetchEnsAvatar, fetchEnsName, fetchEnsResolver, fetchFeeData, fetchSigner, fetchToken, getAccount, getContract, getNetwork, getProvider, getWebSocketProvider, readContract, readContracts, sendTransaction, signMessage, signTypedData, switchNetwork, units, waitForTransaction, watchAccount, watchBlockNumber, watchContractEvent, watchNetwork, watchProvider, watchReadContract, watchReadContracts, watchSigner, watchWebSocketProvider, writeContract };
1129
+ export { configureChains, connect, deepEqual, disconnect, erc20ABI, erc721ABI, fetchBalance, fetchBlockNumber, fetchEnsAddress, fetchEnsAvatar, fetchEnsName, fetchEnsResolver, fetchFeeData, fetchSigner, fetchToken, getAccount, getContract, getNetwork, getProvider, getWebSocketProvider, readContract, readContracts, sendTransaction, signMessage, signTypedData, switchNetwork, units, waitForTransaction, watchAccount, watchBlockNumber, watchContractEvent, watchNetwork, watchProvider, watchReadContract, watchReadContracts, watchSigner, watchWebSocketProvider, writeContract };
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.4.3",
5
+ "version": "0.4.6",
6
6
  "repository": "tmm/wagmi",
7
7
  "author": "awkweb.eth",
8
8
  "ethereum": "awkweb.eth",