@wagmi/core 0.7.1 → 0.7.3

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.
@@ -19,7 +19,7 @@ import { getAddress, hexValue } from "ethers/lib/utils.js";
19
19
 
20
20
  // src/utils/configureChains.ts
21
21
  import { providers } from "ethers";
22
- function configureChains(defaultChains2, providers4, {
22
+ function configureChains(defaultChains2, providers3, {
23
23
  minQuorum = 1,
24
24
  pollingInterval = 4e3,
25
25
  targetQuorum = 1,
@@ -34,7 +34,7 @@ function configureChains(defaultChains2, providers4, {
34
34
  const webSocketProviders_ = {};
35
35
  for (const chain2 of defaultChains2) {
36
36
  let configExists = false;
37
- for (const provider of providers4) {
37
+ for (const provider of providers3) {
38
38
  const apiConfig = provider(chain2);
39
39
  if (!apiConfig)
40
40
  continue;
@@ -343,7 +343,7 @@ function logWarn(message) {
343
343
  }
344
344
 
345
345
  // src/utils/minimizeContractInterface.ts
346
- import { Contract as Contract2 } from "ethers";
346
+ import { Contract } from "ethers";
347
347
  import { FormatTypes } from "ethers/lib/utils.js";
348
348
  function minimizeContractInterface(config) {
349
349
  try {
@@ -354,7 +354,7 @@ function minimizeContractInterface(config) {
354
354
  throw new Error("Invalid ABI");
355
355
  return minimizedAbi;
356
356
  } catch (error) {
357
- const abi = Contract2.getInterface(config.abi).format(
357
+ const abi = Contract.getInterface(config.abi).format(
358
358
  FormatTypes.full
359
359
  );
360
360
  const minimizedInterface = Array.isArray(abi) ? abi : [abi];
@@ -375,7 +375,7 @@ function normalizeChainId(chainId2) {
375
375
  }
376
376
 
377
377
  // src/utils/parseContractResult.ts
378
- import { Contract as Contract3 } from "ethers";
378
+ import { Contract as Contract2 } from "ethers";
379
379
  function isPlainArray(value) {
380
380
  return Array.isArray(value) && Object.keys(value).length === value.length;
381
381
  }
@@ -385,7 +385,7 @@ function parseContractResult({
385
385
  functionName
386
386
  }) {
387
387
  if (data && isPlainArray(data)) {
388
- const iface = Contract3.getInterface(abi);
388
+ const iface = Contract2.getInterface(abi);
389
389
  const fragment = iface.getFunction(functionName);
390
390
  const isTuple = (fragment.outputs?.length || 0) > 1;
391
391
  const data_ = isTuple ? data : [data];
@@ -2300,9 +2300,7 @@ async function fetchToken({
2300
2300
  }
2301
2301
 
2302
2302
  // src/actions/contracts/getContract.ts
2303
- import {
2304
- Contract as EthersContract
2305
- } from "ethers";
2303
+ import { Contract as EthersContract } from "ethers";
2306
2304
  function getContract({
2307
2305
  address,
2308
2306
  abi,
@@ -2591,9 +2589,9 @@ async function readContracts({
2591
2589
  overrides
2592
2590
  })
2593
2591
  );
2594
- let results;
2592
+ let multicallResults;
2595
2593
  if (allowFailure) {
2596
- results = (await Promise.allSettled(promises())).map((result) => {
2594
+ multicallResults = (await Promise.allSettled(promises())).map((result) => {
2597
2595
  if (result.status === "fulfilled")
2598
2596
  return result.value;
2599
2597
  if (result.reason instanceof ChainDoesNotSupportMulticallError) {
@@ -2603,12 +2601,13 @@ async function readContracts({
2603
2601
  return null;
2604
2602
  }).flat();
2605
2603
  } else {
2606
- results = (await Promise.all(promises())).flat();
2604
+ multicallResults = (await Promise.all(promises())).flat();
2607
2605
  }
2608
2606
  const resultIndexes = Object.values(contractsByChainId).map((contracts2) => contracts2.map(({ index }) => index)).flat();
2609
- return results.reduce((results2, result, index) => {
2610
- results2[resultIndexes[index]] = result;
2611
- return results2;
2607
+ return multicallResults.reduce((results, result, index) => {
2608
+ if (results)
2609
+ results[resultIndexes[index]] = result;
2610
+ return results;
2612
2611
  }, []);
2613
2612
  } catch (err) {
2614
2613
  if (err instanceof ContractResultDecodeError)
@@ -3189,7 +3188,7 @@ async function fetchFeeData({
3189
3188
  }
3190
3189
 
3191
3190
  // src/errors.ts
3192
- var RpcError2 = class extends Error {
3191
+ var RpcError = class extends Error {
3193
3192
  constructor(code, message, internal, data) {
3194
3193
  if (!Number.isInteger(code))
3195
3194
  throw new Error('"code" must be an integer.');
@@ -3201,7 +3200,7 @@ var RpcError2 = class extends Error {
3201
3200
  this.internal = internal;
3202
3201
  }
3203
3202
  };
3204
- var ProviderRpcError4 = class extends RpcError2 {
3203
+ var ProviderRpcError = class extends RpcError {
3205
3204
  constructor(code, message, internal, data) {
3206
3205
  if (!(Number.isInteger(code) && code >= 1e3 && code <= 4999))
3207
3206
  throw new Error(
@@ -3395,13 +3394,13 @@ var ProviderChainsNotFound = class extends Error {
3395
3394
  ].join("\n");
3396
3395
  }
3397
3396
  };
3398
- var ResourceUnavailableError = class extends RpcError2 {
3397
+ var ResourceUnavailableError = class extends RpcError {
3399
3398
  constructor(error) {
3400
3399
  super(-32002, "Resource unavailable", error);
3401
3400
  this.name = "ResourceUnavailable";
3402
3401
  }
3403
3402
  };
3404
- var SwitchChainError = class extends ProviderRpcError4 {
3403
+ var SwitchChainError = class extends ProviderRpcError {
3405
3404
  constructor(error) {
3406
3405
  super(4902, "Error switching chain", error);
3407
3406
  this.name = "SwitchChainError";
@@ -3413,7 +3412,7 @@ var SwitchChainNotSupportedError = class extends Error {
3413
3412
  this.name = "SwitchChainNotSupportedError";
3414
3413
  }
3415
3414
  };
3416
- var UserRejectedRequestError = class extends ProviderRpcError4 {
3415
+ var UserRejectedRequestError = class extends ProviderRpcError {
3417
3416
  constructor(error) {
3418
3417
  super(4001, "User rejected request", error);
3419
3418
  this.name = "UserRejectedRequestError";
@@ -3421,8 +3420,8 @@ var UserRejectedRequestError = class extends ProviderRpcError4 {
3421
3420
  };
3422
3421
 
3423
3422
  export {
3424
- RpcError2 as RpcError,
3425
- ProviderRpcError4 as ProviderRpcError,
3423
+ RpcError,
3424
+ ProviderRpcError,
3426
3425
  AddChainError,
3427
3426
  ChainDoesNotSupportMulticallError,
3428
3427
  ChainMismatchError,
@@ -5,7 +5,7 @@ import {
5
5
  SwitchChainError,
6
6
  UserRejectedRequestError,
7
7
  normalizeChainId
8
- } from "../chunk-WA7I47EF.js";
8
+ } from "../chunk-FJTAQ7YO.js";
9
9
  import "../chunk-4DNFSL2K.js";
10
10
  import {
11
11
  __privateAdd,
@@ -4,7 +4,7 @@ import {
4
4
  ResourceUnavailableError,
5
5
  UserRejectedRequestError,
6
6
  getClient
7
- } from "../chunk-WA7I47EF.js";
7
+ } from "../chunk-FJTAQ7YO.js";
8
8
  import "../chunk-4DNFSL2K.js";
9
9
  import {
10
10
  __privateAdd,
@@ -2,7 +2,7 @@ import {
2
2
  Connector,
3
3
  UserRejectedRequestError,
4
4
  normalizeChainId
5
- } from "../../chunk-WA7I47EF.js";
5
+ } from "../../chunk-FJTAQ7YO.js";
6
6
  import "../../chunk-4DNFSL2K.js";
7
7
  import {
8
8
  __privateAdd,
@@ -4,7 +4,7 @@ import {
4
4
  UserRejectedRequestError,
5
5
  getClient,
6
6
  normalizeChainId
7
- } from "../chunk-WA7I47EF.js";
7
+ } from "../chunk-FJTAQ7YO.js";
8
8
  import "../chunk-4DNFSL2K.js";
9
9
  import {
10
10
  __privateAdd,
@@ -221,7 +221,9 @@ declare type GetResult<TAbi extends Abi | readonly unknown[] = Abi, TFunctionNam
221
221
  * | `[{ name: 'foo', type: 'uint256' }, { name: 'bar', type: 'string' }]` | `readonly [bigint, string] & { foo: bigint; bar: string }` |
222
222
  * | `[{ name: 'foo', type: 'uint256' }, { name: '', type: 'string' }]` | `readonly [bigint, string] & { foo: bigint }` |
223
223
  */ {
224
- [Output in TOutputs[number] as Output['name'] extends '' ? never : Output['name']]: AbiParameterToPrimitiveType<Output>;
224
+ [Output in TOutputs[number] as Output extends {
225
+ name: string;
226
+ } ? Output['name'] extends '' ? never : Output['name'] : never]: AbiParameterToPrimitiveType<Output>;
225
227
  } & AbiParametersToPrimitiveTypes<TOutputs> : unknown : never : never;
226
228
  /**
227
229
  * Gets return type of contract function
package/dist/index.d.ts CHANGED
@@ -7,7 +7,7 @@ import * as abitype from 'abitype';
7
7
  import { Address, ResolvedConfig, TypedDataDomain, Narrow, TypedData, TypedDataToPrimitiveTypes, Abi, ExtractAbiFunction, ExtractAbiEventNames, AbiParametersToPrimitiveTypes, ExtractAbiEvent, AbiFunction, AbiParameterToPrimitiveType, AbiEvent, ExtractAbiFunctionNames } from 'abitype';
8
8
  export { Address } from 'abitype';
9
9
  import { PopulatedTransaction, Signer as Signer$1, providers, Contract as Contract$1, ethers, ContractInterface } from 'ethers';
10
- import { O as Options$2, D as DefaultOptions, G as GetConfig$1, a as GetOverridesForAbiStateMutability, U as UnionToIntersection, C as CountOccurrences, A as AbiItemName, I as IsUnknown, E as Event, b as ContractsConfig, c as ContractsResult, d as GetReturnType, e as Or, f as IsNever, N as NotEqual } from './contracts-fb6a6ff0.js';
10
+ import { O as Options$2, D as DefaultOptions, G as GetConfig$1, a as GetOverridesForAbiStateMutability, U as UnionToIntersection, C as CountOccurrences, A as AbiItemName, I as IsUnknown, E as Event, b as ContractsConfig, c as ContractsResult, d as GetReturnType, e as Or, f as IsNever, N as NotEqual } from './contracts-95eb7c72.js';
11
11
  export { I as InjectedConnector, a as InjectedConnectorOptions } from './injected-6980e5c3.js';
12
12
  import 'eventemitter3';
13
13
 
@@ -1051,7 +1051,7 @@ declare type PrepareWriteContractConfig<TAbi = Abi, TFunctionName = string, TSig
1051
1051
  signer?: TSigner | null;
1052
1052
  }, 'nonpayable' | 'payable', TOptions>;
1053
1053
  declare type PrepareWriteContractResult<TAbi = Abi, TFunctionName extends string = string> = {
1054
- abi: TAbi extends Abi ? [ExtractAbiFunction<TAbi, TFunctionName>] : readonly unknown[];
1054
+ abi: TAbi extends Abi ? [ExtractAbiFunction<TAbi, TFunctionName>] : TAbi;
1055
1055
  address: string;
1056
1056
  chainId?: number;
1057
1057
  functionName: TFunctionName;
@@ -1155,7 +1155,9 @@ declare type AbiFunctionReturnType<TAbiFunction extends AbiFunction & {
1155
1155
  nonpayable: ethers.ContractTransaction;
1156
1156
  } & {
1157
1157
  [_ in 'pure' | 'view']: TAbiFunction['outputs']['length'] extends infer TLength ? TLength extends 0 ? void : TLength extends 1 ? AbiParameterToPrimitiveType<TAbiFunction['outputs'][0]> : {
1158
- [Output in TAbiFunction['outputs'][number] as Output['name'] extends '' ? never : Output['name']]: AbiParameterToPrimitiveType<Output>;
1158
+ [Output in TAbiFunction['outputs'][number] as Output extends {
1159
+ name: string;
1160
+ } ? Output['name'] extends '' ? never : Output['name'] : never]: AbiParameterToPrimitiveType<Output>;
1159
1161
  } & AbiParametersToPrimitiveTypes<TAbiFunction['outputs']> : never;
1160
1162
  })[TAbiFunction['stateMutability']];
1161
1163
  declare type InterfaceFunctions<TAbi extends Abi> = UnionToIntersection<{
package/dist/index.js CHANGED
@@ -69,7 +69,7 @@ import {
69
69
  watchSigner,
70
70
  watchWebSocketProvider,
71
71
  writeContract
72
- } from "./chunk-WA7I47EF.js";
72
+ } from "./chunk-FJTAQ7YO.js";
73
73
  import {
74
74
  alchemyRpcUrls,
75
75
  allChains,
@@ -1,5 +1,5 @@
1
1
  import './index-bacc1c49.js';
2
- export { g as ContractConfig, b as ContractsConfig, c as ContractsResult, E as Event, h as GetArgs, G as GetConfig, d as GetReturnType, f as IsNever, N as NotEqual, i as Optional, e as Or } from './contracts-fb6a6ff0.js';
2
+ export { g as ContractConfig, b as ContractsConfig, c as ContractsResult, E as Event, h as GetArgs, G as GetConfig, d as GetReturnType, f as IsNever, N as NotEqual, i as Optional, e as Or } from './contracts-95eb7c72.js';
3
3
  import 'abitype';
4
4
  import 'ethers';
5
5
 
package/dist/internal.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  debounce
3
- } from "./chunk-WA7I47EF.js";
3
+ } from "./chunk-FJTAQ7YO.js";
4
4
  import "./chunk-4DNFSL2K.js";
5
5
  import "./chunk-MQXBDTVK.js";
6
6
  export {
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@wagmi/core",
3
3
  "description": "Vanilla JS library for Ethereum",
4
4
  "license": "MIT",
5
- "version": "0.7.1",
5
+ "version": "0.7.3",
6
6
  "repository": {
7
7
  "type": "git",
8
8
  "url": "https://github.com/wagmi-dev/wagmi.git",
@@ -92,9 +92,9 @@
92
92
  }
93
93
  },
94
94
  "dependencies": {
95
- "abitype": "^0.1.7",
95
+ "abitype": "^0.1.8",
96
96
  "eventemitter3": "^4.0.7",
97
- "zustand": "^4.1.1"
97
+ "zustand": "^4.1.4"
98
98
  },
99
99
  "devDependencies": {
100
100
  "@coinbase/wallet-sdk": "^3.4.1",