@wagmi/core 0.8.19 → 0.9.0

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.
package/README.md CHANGED
@@ -6,7 +6,7 @@ For full documentation and examples, visit [wagmi.sh](https://wagmi.sh).
6
6
 
7
7
  ## Installation
8
8
 
9
- Install wagmi and its ethers peer dependency.
9
+ Install `@wagmi/core` and its ethers peer dependency.
10
10
 
11
11
  ```bash
12
12
  npm install @wagmi/core ethers
@@ -26,5 +26,5 @@ Check out the following places for more wagmi-related content:
26
26
  If you find wagmi useful, please consider supporting development. Thank you 🙏
27
27
 
28
28
  - [GitHub Sponsors](https://github.com/sponsors/wagmi-dev?metadata_campaign=readme_core)
29
- - [Gitcoin Grant](https://gitcoin.co/grants/4493/wagmi-react-hooks-library-for-ethereum)
29
+ - [Gitcoin Grant](https://wagmi.sh/gitcoin)
30
30
  - [wagmi-dev.eth](https://etherscan.io/enslookup-search?search=wagmi-dev.eth)
@@ -50,7 +50,7 @@ function configureChains(defaultChains, providers2, {
50
50
  `Could not find valid provider configuration for chain "${chain.name}".
51
51
  `,
52
52
  "You may need to add `jsonRpcProvider` to `configureChains` with the chain's RPC URLs.",
53
- "Read more: https://wagmi.sh/react/providers/jsonRpc"
53
+ "Read more: https://wagmi.sh/core/providers/jsonRpc"
54
54
  ].join("\n")
55
55
  );
56
56
  }
@@ -2771,33 +2771,25 @@ function watchPendingTransactions(args, callback) {
2771
2771
  }
2772
2772
 
2773
2773
  // src/actions/contracts/writeContract.ts
2774
- async function writeContract({
2775
- address,
2776
- args,
2777
- chainId,
2778
- abi,
2779
- functionName,
2780
- mode,
2781
- overrides,
2782
- request: request_
2783
- }) {
2774
+ async function writeContract(config) {
2784
2775
  const signer = await fetchSigner();
2785
2776
  if (!signer)
2786
2777
  throw new ConnectorNotFoundError();
2787
- if (chainId)
2788
- assertActiveChain({ chainId, signer });
2789
- if (mode === "prepared") {
2790
- if (!request_)
2791
- throw new Error("`request` is required");
2778
+ if (config.chainId)
2779
+ assertActiveChain({ chainId: config.chainId, signer });
2780
+ let request;
2781
+ if (config.mode === "prepared") {
2782
+ request = config.request;
2783
+ } else {
2784
+ request = (await prepareWriteContract({
2785
+ address: config.address,
2786
+ args: config.args,
2787
+ chainId: config.chainId,
2788
+ abi: config.abi,
2789
+ functionName: config.functionName,
2790
+ overrides: config.overrides
2791
+ })).request;
2792
2792
  }
2793
- const request = mode === "recklesslyUnprepared" ? (await prepareWriteContract({
2794
- address,
2795
- args,
2796
- chainId,
2797
- abi,
2798
- functionName,
2799
- overrides
2800
- })).request : request_;
2801
2793
  const transaction = await sendTransaction({
2802
2794
  request,
2803
2795
  mode: "prepared"
@@ -196,4 +196,4 @@ type Event<TAbiEvent extends AbiEvent> = Omit<ethers.Event, 'args' | 'event' | '
196
196
  eventSignature: AbiItemName<TAbiEvent, true>;
197
197
  };
198
198
 
199
- export { AbiItemName as A, CountOccurrences as C, Event as E, GetConfig as G, IsUnknown as I, UnionToIntersection as U, GetOverridesForAbiStateMutability as a, Contract as b, ContractsConfig as c, ContractsResult as d, GetReturnType as e };
199
+ export { AbiItemName as A, CountOccurrences as C, Event as E, GetConfig as G, IsUnknown as I, UnionToIntersection as U, GetOverridesForAbiStateMutability as a, Contract as b, ContractsConfig as c, ContractsResult as d, GetReturnType as e, GetFunctionName as f, GetArgs as g };
@@ -0,0 +1,49 @@
1
+ import { Ethereum } from '@wagmi/connectors';
2
+ import { Address, TypedData, TypedDataToPrimitiveTypes, TypedDataDomain, ResolvedConfig } from 'abitype';
3
+ import { BigNumber, providers, Signer as Signer$1 } from 'ethers';
4
+ import { Chain } from '@wagmi/chains';
5
+
6
+ declare const units: readonly ["wei", "kwei", "mwei", "gwei", "szabo", "finney", "ether"];
7
+
8
+ declare module 'abitype' {
9
+ interface Config {
10
+ BigIntType: BigNumber;
11
+ IntType: number;
12
+ }
13
+ }
14
+ declare module 'ethers/lib/utils.js' {
15
+ function getAddress(address: string): Address;
16
+ function isAddress(address: string): address is Address;
17
+ function verifyTypedData<TTypedData extends TypedData, TSchema extends TypedDataToPrimitiveTypes<TTypedData>>(domain: TypedDataDomain, types: TTypedData, value: TSchema[keyof TSchema] extends infer TValue ? {
18
+ [x: string]: any;
19
+ } extends TValue ? Record<string, any> : TValue : never, signature: {
20
+ r: string;
21
+ s?: string;
22
+ _vs?: string;
23
+ recoveryParam?: number;
24
+ v?: number;
25
+ } | ResolvedConfig['BytesType'] | string): string;
26
+ }
27
+ type Hash = `0x${string}`;
28
+ type ChainProviderFn<TChain extends Chain = Chain, TProvider extends Provider = providers.BaseProvider, TWebSocketProvider extends WebSocketProvider = providers.WebSocketProvider> = (chain: TChain) => {
29
+ chain: TChain;
30
+ provider: () => ProviderWithFallbackConfig<TProvider>;
31
+ webSocketProvider?: () => TWebSocketProvider;
32
+ } | null;
33
+ type FallbackProviderConfig = Omit<providers.FallbackProviderConfig, 'provider'>;
34
+ type ProviderWithFallbackConfig<TProvider extends Provider = Provider> = TProvider & FallbackProviderConfig;
35
+ type Provider = providers.BaseProvider & {
36
+ chains?: Chain[];
37
+ };
38
+ type WebSocketProvider = providers.WebSocketProvider & {
39
+ chains?: Chain[];
40
+ };
41
+ type Signer = Signer$1;
42
+ type Unit = (typeof units)[number];
43
+ declare global {
44
+ interface Window {
45
+ ethereum?: Ethereum;
46
+ }
47
+ }
48
+
49
+ export { ChainProviderFn as C, FallbackProviderConfig as F, Hash as H, Provider as P, Signer as S, Unit as U, WebSocketProvider as W, ProviderWithFallbackConfig as a, units as u };
package/dist/index.d.ts CHANGED
@@ -3,16 +3,16 @@ import { Chain } from '@wagmi/chains';
3
3
  export { Chain, goerli, mainnet } from '@wagmi/chains';
4
4
  import { Mutate, StoreApi } from 'zustand/vanilla';
5
5
  import { Connector, ConnectorData } from '@wagmi/connectors';
6
- export { Connector, ConnectorData, ConnectorEvents } from '@wagmi/connectors';
7
- import { P as Provider, W as WebSocketProvider, U as Unit, S as Signer, H as Hash, C as ChainProviderFn, a as ProviderWithFallbackConfig } from './index-1260a84c.js';
8
- export { C as ChainProviderFn, E as Ethereum, F as FallbackProviderConfig, H as Hash, P as Provider, a as ProviderWithFallbackConfig, S as Signer, U as Unit, W as WebSocketProvider, u as units } from './index-1260a84c.js';
6
+ export { Connector, ConnectorData, ConnectorEvents, Ethereum } from '@wagmi/connectors';
7
+ import { P as Provider, W as WebSocketProvider, U as Unit, S as Signer, H as Hash, C as ChainProviderFn, a as ProviderWithFallbackConfig } from './index-35b6525c.js';
8
+ export { C as ChainProviderFn, F as FallbackProviderConfig, H as Hash, P as Provider, a as ProviderWithFallbackConfig, S as Signer, U as Unit, W as WebSocketProvider, u as units } from './index-35b6525c.js';
9
9
  import { Address, ResolvedConfig, TypedData, TypedDataToPrimitiveTypes, TypedDataDomain, Narrow, Abi, ExtractAbiFunction, ExtractAbiEventNames, AbiParametersToPrimitiveTypes, ExtractAbiEvent, AbiFunction, AbiParameter, AbiParameterToPrimitiveType, AbiEvent, ExtractAbiFunctionNames } from 'abitype';
10
10
  export { Address } from 'abitype';
11
11
  import { PopulatedTransaction, Signer as Signer$1, providers, Contract as Contract$1, ethers, Transaction, ContractInterface } from 'ethers';
12
- import { G as GetConfig, a as GetOverridesForAbiStateMutability, U as UnionToIntersection, C as CountOccurrences, A as AbiItemName, I as IsUnknown, E as Event, b as Contract$2, c as ContractsConfig, d as ContractsResult, e as GetReturnType } from './contracts-9eb7706c.js';
12
+ import { G as GetConfig, a as GetOverridesForAbiStateMutability, U as UnionToIntersection, C as CountOccurrences, A as AbiItemName, I as IsUnknown, E as Event, b as Contract$2, c as ContractsConfig, d as ContractsResult, e as GetReturnType, f as GetFunctionName, g as GetArgs } from './contracts-b112c24e.js';
13
13
  import { TransactionResponse } from '@ethersproject/providers';
14
14
  export { InjectedConnector, InjectedConnectorOptions } from '@wagmi/connectors/injected';
15
- import * as abitype_dist_abi_b1bae27f from 'abitype/dist/abi-b1bae27f';
15
+ import * as abitype_dist_abi_78346466 from 'abitype/dist/abi-78346466';
16
16
 
17
17
  type BaseStorage = Pick<Storage, 'getItem' | 'setItem' | 'removeItem'>;
18
18
  type ClientStorage = {
@@ -1049,9 +1049,9 @@ type FetchTokenResult = {
1049
1049
  declare function fetchToken({ address, chainId, formatUnits: units, }: FetchTokenArgs): Promise<FetchTokenResult>;
1050
1050
 
1051
1051
  type StateMutability$1 = 'nonpayable' | 'payable';
1052
- type PrepareWriteContractConfig<TAbi extends Abi | readonly unknown[] = Abi, TFunctionName extends string = string, TSigner extends Signer = Signer> = GetConfig<TAbi, TFunctionName, StateMutability$1> & {
1052
+ type PrepareWriteContractConfig<TAbi extends Abi | readonly unknown[] = Abi, TFunctionName extends string = string, TChainId extends number = number, TSigner extends Signer = Signer> = GetConfig<TAbi, TFunctionName, StateMutability$1> & {
1053
1053
  /** Chain id to use for provider */
1054
- chainId?: number;
1054
+ chainId?: TChainId | number;
1055
1055
  /** Overrides */
1056
1056
  overrides?: GetOverridesForAbiStateMutability<[
1057
1057
  TAbi,
@@ -1067,10 +1067,10 @@ type Request$1 = PopulatedTransaction & {
1067
1067
  to: Address;
1068
1068
  gasLimit: NonNullable<PopulatedTransaction['gasLimit']>;
1069
1069
  };
1070
- type PrepareWriteContractResult<TAbi extends Abi | readonly unknown[] = Abi, TFunctionName extends string = string> = {
1070
+ type PrepareWriteContractResult<TAbi extends Abi | readonly unknown[] = Abi, TFunctionName extends string = string, TChainId extends number = number> = {
1071
1071
  abi: TAbi extends Abi ? [ExtractAbiFunction<TAbi, TFunctionName>] : TAbi;
1072
1072
  address: Address;
1073
- chainId?: number;
1073
+ chainId?: TChainId;
1074
1074
  functionName: TFunctionName;
1075
1075
  mode: 'prepared';
1076
1076
  request: Request$1;
@@ -1090,7 +1090,7 @@ type PrepareWriteContractResult<TAbi extends Abi | readonly unknown[] = Abi, TFu
1090
1090
  * })
1091
1091
  * const result = await writeContract(config)
1092
1092
  */
1093
- declare function prepareWriteContract<TAbi extends Abi | readonly unknown[], TFunctionName extends string, TSigner extends Signer = Signer>({ abi, address, chainId, functionName, overrides, signer: signer_, ...config }: PrepareWriteContractConfig<TAbi, TFunctionName, TSigner>): Promise<PrepareWriteContractResult<TAbi, TFunctionName>>;
1093
+ declare function prepareWriteContract<TAbi extends Abi | readonly unknown[], TFunctionName extends string, TChainId extends number, TSigner extends Signer = Signer>({ abi, address, chainId, functionName, overrides, signer: signer_, ...config }: PrepareWriteContractConfig<TAbi, TFunctionName, TChainId, TSigner>): Promise<PrepareWriteContractResult<TAbi, TFunctionName, TChainId>>;
1094
1094
 
1095
1095
  type GetContractArgs<TAbi extends Abi | readonly unknown[] = Abi> = {
1096
1096
  /** Contract address */
@@ -1434,9 +1434,13 @@ type WriteContractPreparedArgs<TAbi extends Abi | readonly unknown[], TFunctionN
1434
1434
  chainId?: number;
1435
1435
  /** Request to submit transaction for */
1436
1436
  request: Request;
1437
- args?: never;
1438
- overrides?: never;
1439
- } & Omit<GetConfig<TAbi, TFunctionName, 'nonpayable' | 'payable'>, 'args'>;
1437
+ /** Contract ABI */
1438
+ abi: Narrow<TAbi>;
1439
+ /** Contract address */
1440
+ address: Address;
1441
+ /** Function to invoke on the contract */
1442
+ functionName: GetFunctionName<TAbi, TFunctionName, 'nonpayable' | 'payable'>;
1443
+ };
1440
1444
  type WriteContractUnpreparedArgs<TAbi extends Abi | readonly unknown[], TFunctionName extends string> = {
1441
1445
  /**
1442
1446
  * `recklesslyUnprepared`: Allow to pass through unprepared config. Note: This has
@@ -1458,9 +1462,14 @@ type WriteContractUnpreparedArgs<TAbi extends Abi | readonly unknown[], TFunctio
1458
1462
  infer TAbi_ extends Abi,
1459
1463
  infer TFunctionName_ extends string
1460
1464
  ] ? ExtractAbiFunction<TAbi_, TFunctionName_>['stateMutability'] : 'nonpayable' | 'payable'>;
1461
- request?: never;
1462
- } & GetConfig<TAbi, TFunctionName, 'nonpayable' | 'payable'>;
1463
- type WriteContractArgs<TAbi extends Abi | readonly unknown[], TFunctionName extends string> = WriteContractUnpreparedArgs<TAbi, TFunctionName> | WriteContractPreparedArgs<TAbi, TFunctionName>;
1465
+ /** Contract ABI */
1466
+ abi: Narrow<TAbi>;
1467
+ /** Contract address */
1468
+ address: Address;
1469
+ /** Function to invoke on the contract */
1470
+ functionName: GetFunctionName<TAbi, TFunctionName, 'nonpayable' | 'payable'>;
1471
+ } & GetArgs<TAbi, TFunctionName>;
1472
+ type WriteContractArgs<TAbi extends Abi | readonly unknown[], TFunctionName extends string> = WriteContractPreparedArgs<TAbi, TFunctionName> | WriteContractUnpreparedArgs<TAbi, TFunctionName>;
1464
1473
  type WriteContractResult = SendTransactionResult;
1465
1474
  /**
1466
1475
  * @description Function to call a contract write method.
@@ -1478,7 +1487,7 @@ type WriteContractResult = SendTransactionResult;
1478
1487
  * })
1479
1488
  * const result = await writeContract(config)
1480
1489
  */
1481
- declare function writeContract<TAbi extends Abi | readonly unknown[], TFunctionName extends string, TSigner extends Signer = Signer>({ address, args, chainId, abi, functionName, mode, overrides, request: request_, }: WriteContractArgs<TAbi, TFunctionName>): Promise<WriteContractResult>;
1490
+ declare function writeContract<TAbi extends Abi | readonly unknown[], TFunctionName extends string, TSigner extends Signer = Signer>(config: WriteContractUnpreparedArgs<TAbi, TFunctionName> | WriteContractPreparedArgs<TAbi, TFunctionName>): Promise<WriteContractResult>;
1482
1491
 
1483
1492
  type FetchEnsAddressArgs = {
1484
1493
  /** Chain id to use for provider */
@@ -1707,7 +1716,7 @@ type ConfigureChainsConfig = {
1707
1716
  targetQuorum: number;
1708
1717
  minQuorum?: number;
1709
1718
  });
1710
- declare function configureChains<TProvider extends Provider = Provider, TWebSocketProvider extends WebSocketProvider = WebSocketProvider, TChain extends Chain = Chain>(defaultChains: TChain[], providers: ChainProviderFn<TProvider, TWebSocketProvider, TChain>[], { minQuorum, pollingInterval, targetQuorum, stallTimeout, }?: ConfigureChainsConfig): {
1719
+ declare function configureChains<TChain extends Chain = Chain, TProvider extends Provider = Provider, TWebSocketProvider extends WebSocketProvider = WebSocketProvider>(defaultChains: TChain[], providers: ChainProviderFn<TChain, TProvider, TWebSocketProvider>[], { minQuorum, pollingInterval, targetQuorum, stallTimeout, }?: ConfigureChainsConfig): {
1711
1720
  readonly chains: TChain[];
1712
1721
  readonly provider: ({ chainId }: {
1713
1722
  chainId?: number | undefined;
@@ -1730,7 +1739,7 @@ declare function deserialize(cachedString: string): any;
1730
1739
  declare function minimizeContractInterface<TAbi extends Abi | readonly unknown[]>(config: {
1731
1740
  abi: TAbi;
1732
1741
  functionName: TAbi extends Abi ? ExtractAbiFunctionNames<TAbi> : string;
1733
- }): string[] | (abitype_dist_abi_b1bae27f.q | abitype_dist_abi_b1bae27f.p | abitype_dist_abi_b1bae27f.o)[];
1742
+ }): string[] | (abitype_dist_abi_78346466.q | abitype_dist_abi_78346466.p | abitype_dist_abi_78346466.o)[];
1734
1743
 
1735
1744
  declare function normalizeChainId(chainId: string | number | bigint): number;
1736
1745
 
package/dist/index.js CHANGED
@@ -72,7 +72,7 @@ import {
72
72
  watchSigner,
73
73
  watchWebSocketProvider,
74
74
  writeContract
75
- } from "./chunk-TQJMA6J5.js";
75
+ } from "./chunk-55IO54NW.js";
76
76
  import {
77
77
  goerli,
78
78
  mainnet
@@ -1,7 +1,8 @@
1
- export { b as Contract, c as ContractsConfig } from '../contracts-9eb7706c.js';
2
- import '../index-1260a84c.js';
1
+ export { b as Contract, c as ContractsConfig } from '../contracts-b112c24e.js';
2
+ import '../index-35b6525c.js';
3
3
  import 'abitype';
4
4
  import 'ethers';
5
+ import '@wagmi/connectors';
5
6
  import '@wagmi/chains';
6
7
 
7
8
  declare function debounce(fn: (...args: any) => void, waitTime?: number): (...args: any) => void;
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  debounce
3
- } from "../chunk-TQJMA6J5.js";
3
+ } from "../chunk-55IO54NW.js";
4
4
  import "../chunk-BVC4KGLQ.js";
5
5
  import "../chunk-MQXBDTVK.js";
6
6
  export {
@@ -1,9 +1,181 @@
1
- import '../index-1260a84c.js';
1
+ import '../index-35b6525c.js';
2
2
  import { Wallet, providers } from 'ethers';
3
3
  import { Chain } from '@wagmi/chains';
4
+ import '@wagmi/connectors';
4
5
  import 'abitype';
5
6
 
6
- declare const testChains: Chain[];
7
+ declare const testChains: (Chain | {
8
+ readonly id: 5;
9
+ readonly network: "goerli";
10
+ readonly name: "Goerli";
11
+ readonly nativeCurrency: {
12
+ readonly name: "Goerli Ether";
13
+ readonly symbol: "ETH";
14
+ readonly decimals: 18;
15
+ };
16
+ readonly rpcUrls: {
17
+ readonly alchemy: {
18
+ readonly http: readonly ["https://eth-goerli.g.alchemy.com/v2"];
19
+ readonly webSocket: readonly ["wss://eth-goerli.g.alchemy.com/v2"];
20
+ };
21
+ readonly infura: {
22
+ readonly http: readonly ["https://goerli.infura.io/v3"];
23
+ readonly webSocket: readonly ["wss://goerli.infura.io/ws/v3"];
24
+ };
25
+ readonly default: {
26
+ readonly http: readonly ["https://rpc.ankr.com/eth_goerli"];
27
+ };
28
+ readonly public: {
29
+ readonly http: readonly ["https://rpc.ankr.com/eth_goerli"];
30
+ };
31
+ };
32
+ readonly blockExplorers: {
33
+ readonly etherscan: {
34
+ readonly name: "Etherscan";
35
+ readonly url: "https://goerli.etherscan.io";
36
+ };
37
+ readonly default: {
38
+ readonly name: "Etherscan";
39
+ readonly url: "https://goerli.etherscan.io";
40
+ };
41
+ };
42
+ readonly contracts: {
43
+ readonly ensRegistry: {
44
+ readonly address: "0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e";
45
+ };
46
+ readonly multicall3: {
47
+ readonly address: "0xca11bde05977b3631167028862be2a173976ca11";
48
+ readonly blockCreated: 6507670;
49
+ };
50
+ };
51
+ readonly testnet: true;
52
+ } | {
53
+ readonly id: 1;
54
+ readonly network: "homestead";
55
+ readonly name: "Ethereum";
56
+ readonly nativeCurrency: {
57
+ readonly name: "Ether";
58
+ readonly symbol: "ETH";
59
+ readonly decimals: 18;
60
+ };
61
+ readonly rpcUrls: {
62
+ readonly alchemy: {
63
+ readonly http: readonly ["https://eth-mainnet.g.alchemy.com/v2"];
64
+ readonly webSocket: readonly ["wss://eth-mainnet.g.alchemy.com/v2"];
65
+ };
66
+ readonly infura: {
67
+ readonly http: readonly ["https://mainnet.infura.io/v3"];
68
+ readonly webSocket: readonly ["wss://mainnet.infura.io/ws/v3"];
69
+ };
70
+ readonly default: {
71
+ readonly http: readonly ["https://cloudflare-eth.com"];
72
+ };
73
+ readonly public: {
74
+ readonly http: readonly ["https://cloudflare-eth.com"];
75
+ };
76
+ };
77
+ readonly blockExplorers: {
78
+ readonly etherscan: {
79
+ readonly name: "Etherscan";
80
+ readonly url: "https://etherscan.io";
81
+ };
82
+ readonly default: {
83
+ readonly name: "Etherscan";
84
+ readonly url: "https://etherscan.io";
85
+ };
86
+ };
87
+ readonly contracts: {
88
+ readonly ensRegistry: {
89
+ readonly address: "0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e";
90
+ };
91
+ readonly multicall3: {
92
+ readonly address: "0xca11bde05977b3631167028862be2a173976ca11";
93
+ readonly blockCreated: 14353601;
94
+ };
95
+ };
96
+ } | {
97
+ readonly id: 10;
98
+ readonly name: "Optimism";
99
+ readonly network: "optimism";
100
+ readonly nativeCurrency: {
101
+ readonly name: "Ether";
102
+ readonly symbol: "ETH";
103
+ readonly decimals: 18;
104
+ };
105
+ readonly rpcUrls: {
106
+ readonly alchemy: {
107
+ readonly http: readonly ["https://opt-mainnet.g.alchemy.com/v2"];
108
+ readonly webSocket: readonly ["wss://opt-mainnet.g.alchemy.com/v2"];
109
+ };
110
+ readonly infura: {
111
+ readonly http: readonly ["https://optimism-mainnet.infura.io/v3"];
112
+ readonly webSocket: readonly ["wss://optimism-mainnet.infura.io/ws/v3"];
113
+ };
114
+ readonly default: {
115
+ readonly http: readonly ["https://mainnet.optimism.io"];
116
+ };
117
+ readonly public: {
118
+ readonly http: readonly ["https://mainnet.optimism.io"];
119
+ };
120
+ };
121
+ readonly blockExplorers: {
122
+ readonly etherscan: {
123
+ readonly name: "Etherscan";
124
+ readonly url: "https://optimistic.etherscan.io";
125
+ };
126
+ readonly default: {
127
+ readonly name: "Optimism Explorer";
128
+ readonly url: "https://explorer.optimism.io";
129
+ };
130
+ };
131
+ readonly contracts: {
132
+ readonly multicall3: {
133
+ readonly address: "0xca11bde05977b3631167028862be2a173976ca11";
134
+ readonly blockCreated: 4286263;
135
+ };
136
+ };
137
+ } | {
138
+ readonly id: 137;
139
+ readonly name: "Polygon";
140
+ readonly network: "matic";
141
+ readonly nativeCurrency: {
142
+ readonly name: "MATIC";
143
+ readonly symbol: "MATIC";
144
+ readonly decimals: 18;
145
+ };
146
+ readonly rpcUrls: {
147
+ readonly alchemy: {
148
+ readonly http: readonly ["https://polygon-mainnet.g.alchemy.com/v2"];
149
+ readonly webSocket: readonly ["wss://polygon-mainnet.g.alchemy.com/v2"];
150
+ };
151
+ readonly infura: {
152
+ readonly http: readonly ["https://polygon-mainnet.infura.io/v3"];
153
+ readonly webSocket: readonly ["wss://polygon-mainnet.infura.io/ws/v3"];
154
+ };
155
+ readonly default: {
156
+ readonly http: readonly ["https://polygon-rpc.com"];
157
+ };
158
+ readonly public: {
159
+ readonly http: readonly ["https://polygon-rpc.com"];
160
+ };
161
+ };
162
+ readonly blockExplorers: {
163
+ readonly etherscan: {
164
+ readonly name: "PolygonScan";
165
+ readonly url: "https://polygonscan.com";
166
+ };
167
+ readonly default: {
168
+ readonly name: "PolygonScan";
169
+ readonly url: "https://polygonscan.com";
170
+ };
171
+ };
172
+ readonly contracts: {
173
+ readonly multicall3: {
174
+ readonly address: "0xca11bde05977b3631167028862be2a173976ca11";
175
+ readonly blockCreated: 25770160;
176
+ };
177
+ };
178
+ })[];
7
179
  declare class WalletSigner extends Wallet {
8
180
  connectUnchecked(): providers.JsonRpcSigner;
9
181
  }
@@ -1,5 +1,5 @@
1
1
  import "../chunk-KX4UEHS5.js";
2
- import "../chunk-TQJMA6J5.js";
2
+ import "../chunk-55IO54NW.js";
3
3
  import {
4
4
  foundry,
5
5
  goerli,
@@ -1,12 +1,13 @@
1
1
  import { providers } from 'ethers';
2
- import { F as FallbackProviderConfig, C as ChainProviderFn } from '../index-1260a84c.js';
2
+ import { Chain } from '@wagmi/chains';
3
+ import { F as FallbackProviderConfig, C as ChainProviderFn } from '../index-35b6525c.js';
4
+ import '@wagmi/connectors';
3
5
  import 'abitype';
4
- import '@wagmi/chains';
5
6
 
6
7
  type AlchemyProviderConfig = FallbackProviderConfig & {
7
8
  /** Your Alchemy API key from the [Alchemy Dashboard](https://dashboard.alchemyapi.io/). */
8
9
  apiKey: string;
9
10
  };
10
- declare function alchemyProvider({ apiKey, priority, stallTimeout, weight, }: AlchemyProviderConfig): ChainProviderFn<providers.AlchemyProvider, providers.AlchemyWebSocketProvider>;
11
+ declare function alchemyProvider<TChain extends Chain = Chain>({ apiKey, priority, stallTimeout, weight, }: AlchemyProviderConfig): ChainProviderFn<TChain, providers.AlchemyProvider, providers.AlchemyWebSocketProvider>;
11
12
 
12
13
  export { AlchemyProviderConfig, alchemyProvider };
@@ -1,12 +1,13 @@
1
1
  import { providers } from 'ethers';
2
- import { F as FallbackProviderConfig, C as ChainProviderFn } from '../index-1260a84c.js';
2
+ import { Chain } from '@wagmi/chains';
3
+ import { F as FallbackProviderConfig, C as ChainProviderFn } from '../index-35b6525c.js';
4
+ import '@wagmi/connectors';
3
5
  import 'abitype';
4
- import '@wagmi/chains';
5
6
 
6
7
  type InfuraProviderConfig = FallbackProviderConfig & {
7
8
  /** Your Infura API key from the [Infura Dashboard](https://infura.io/login). */
8
9
  apiKey: string;
9
10
  };
10
- declare function infuraProvider({ apiKey, priority, stallTimeout, weight, }: InfuraProviderConfig): ChainProviderFn<providers.InfuraProvider, providers.InfuraWebSocketProvider>;
11
+ declare function infuraProvider<TChain extends Chain = Chain>({ apiKey, priority, stallTimeout, weight, }: InfuraProviderConfig): ChainProviderFn<TChain, providers.InfuraProvider, providers.InfuraWebSocketProvider>;
11
12
 
12
13
  export { InfuraProviderConfig, infuraProvider };
@@ -1,6 +1,7 @@
1
1
  import { providers } from 'ethers';
2
2
  import { Chain } from '@wagmi/chains';
3
- import { F as FallbackProviderConfig, C as ChainProviderFn } from '../index-1260a84c.js';
3
+ import { F as FallbackProviderConfig, C as ChainProviderFn } from '../index-35b6525c.js';
4
+ import '@wagmi/connectors';
4
5
  import 'abitype';
5
6
 
6
7
  type JsonRpcProviderConfig = FallbackProviderConfig & {
@@ -10,6 +11,6 @@ type JsonRpcProviderConfig = FallbackProviderConfig & {
10
11
  } | null;
11
12
  static?: boolean;
12
13
  };
13
- declare function jsonRpcProvider({ priority, rpc, stallTimeout, static: static_, weight, }: JsonRpcProviderConfig): ChainProviderFn<providers.JsonRpcProvider, providers.WebSocketProvider>;
14
+ declare function jsonRpcProvider<TChain extends Chain = Chain>({ priority, rpc, stallTimeout, static: static_, weight, }: JsonRpcProviderConfig): ChainProviderFn<TChain, providers.JsonRpcProvider, providers.WebSocketProvider>;
14
15
 
15
16
  export { JsonRpcProviderConfig, jsonRpcProvider };
@@ -1,9 +1,10 @@
1
1
  import { providers } from 'ethers';
2
- import { F as FallbackProviderConfig, C as ChainProviderFn } from '../index-1260a84c.js';
2
+ import { Chain } from '@wagmi/chains';
3
+ import { F as FallbackProviderConfig, C as ChainProviderFn } from '../index-35b6525c.js';
4
+ import '@wagmi/connectors';
3
5
  import 'abitype';
4
- import '@wagmi/chains';
5
6
 
6
7
  type PublicProviderConfig = FallbackProviderConfig;
7
- declare function publicProvider({ priority, stallTimeout, weight, }?: PublicProviderConfig): ChainProviderFn<providers.StaticJsonRpcProvider>;
8
+ declare function publicProvider<TChain extends Chain = Chain>({ priority, stallTimeout, weight, }?: PublicProviderConfig): ChainProviderFn<TChain, providers.StaticJsonRpcProvider>;
8
9
 
9
10
  export { PublicProviderConfig, publicProvider };
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.8.19",
5
+ "version": "0.9.0",
6
6
  "repository": {
7
7
  "type": "git",
8
8
  "url": "https://github.com/wagmi-dev/wagmi.git",
@@ -16,7 +16,7 @@
16
16
  "funding": [
17
17
  {
18
18
  "type": "gitcoin",
19
- "url": "https://gitcoin.co/grants/4493/wagmi-react-hooks-library-for-ethereum"
19
+ "url": "https://wagmi.sh/gitcoin"
20
20
  },
21
21
  {
22
22
  "type": "github",
@@ -98,29 +98,23 @@
98
98
  "/dist"
99
99
  ],
100
100
  "peerDependencies": {
101
- "@coinbase/wallet-sdk": ">=3.6.0",
102
- "@walletconnect/ethereum-provider": ">=1.7.5",
103
- "ethers": ">=5.5.1"
101
+ "ethers": ">=5.5.1",
102
+ "typescript": ">=4.9.4"
104
103
  },
105
104
  "peerDependenciesMeta": {
106
- "@coinbase/wallet-sdk": {
107
- "optional": true
108
- },
109
- "@walletconnect/ethereum-provider": {
105
+ "typescript": {
110
106
  "optional": true
111
107
  }
112
108
  },
113
109
  "dependencies": {
114
- "abitype": "^0.2.5",
110
+ "abitype": "^0.3.0",
115
111
  "eventemitter3": "^4.0.7",
116
112
  "zustand": "^4.3.1",
117
- "@wagmi/chains": "0.1.14",
118
- "@wagmi/connectors": "0.1.10"
113
+ "@wagmi/chains": "0.2.0",
114
+ "@wagmi/connectors": "0.2.0"
119
115
  },
120
116
  "devDependencies": {
121
- "@coinbase/wallet-sdk": "^3.6.0",
122
- "@walletconnect/ethereum-provider": "^1.7.8",
123
- "typescript": "^4.9.3"
117
+ "ethers": "^5.7.1"
124
118
  },
125
119
  "keywords": [
126
120
  "eth",
@@ -1,189 +0,0 @@
1
- import { Address, TypedData, TypedDataToPrimitiveTypes, TypedDataDomain, ResolvedConfig } from 'abitype';
2
- import { BigNumber, providers, Signer as Signer$1 } from 'ethers';
3
- import { Chain } from '@wagmi/chains';
4
-
5
- declare const units: readonly ["wei", "kwei", "mwei", "gwei", "szabo", "finney", "ether"];
6
-
7
- declare module 'abitype' {
8
- interface Config {
9
- BigIntType: BigNumber;
10
- IntType: number;
11
- }
12
- }
13
- declare module 'ethers/lib/utils.js' {
14
- function getAddress(address: string): Address;
15
- function isAddress(address: string): address is Address;
16
- function verifyTypedData<TTypedData extends TypedData, TSchema extends TypedDataToPrimitiveTypes<TTypedData>>(domain: TypedDataDomain, types: TTypedData, value: TSchema[keyof TSchema] extends infer TValue ? {
17
- [x: string]: any;
18
- } extends TValue ? Record<string, any> : TValue : never, signature: {
19
- r: string;
20
- s?: string;
21
- _vs?: string;
22
- recoveryParam?: number;
23
- v?: number;
24
- } | ResolvedConfig['BytesType'] | string): string;
25
- }
26
- type Hash = `0x${string}`;
27
- type ChainProviderFn<TProvider extends Provider = providers.BaseProvider, TWebSocketProvider extends WebSocketProvider = providers.WebSocketProvider, TChain extends Chain = Chain> = (chain: TChain) => {
28
- chain: TChain;
29
- provider: () => ProviderWithFallbackConfig<TProvider>;
30
- webSocketProvider?: () => TWebSocketProvider;
31
- } | null;
32
- type FallbackProviderConfig = Omit<providers.FallbackProviderConfig, 'provider'>;
33
- type ProviderWithFallbackConfig<TProvider extends Provider = Provider> = TProvider & FallbackProviderConfig;
34
- type Provider = providers.BaseProvider & {
35
- chains?: Chain[];
36
- };
37
- type WebSocketProvider = providers.WebSocketProvider & {
38
- chains?: Chain[];
39
- };
40
- type Signer = Signer$1;
41
- type Unit = typeof units[number];
42
- type AddEthereumChainParameter = {
43
- /** A 0x-prefixed hexadecimal string */
44
- chainId: string;
45
- chainName: string;
46
- nativeCurrency?: {
47
- name: string;
48
- /** 2-6 characters long */
49
- symbol: string;
50
- decimals: number;
51
- };
52
- rpcUrls: string[];
53
- blockExplorerUrls?: string[];
54
- /** Currently ignored. */
55
- iconUrls?: string[];
56
- };
57
- type WalletPermissionCaveat = {
58
- type: string;
59
- value: any;
60
- };
61
- type WalletPermission = {
62
- caveats: WalletPermissionCaveat[];
63
- date: number;
64
- id: string;
65
- invoker: `http://${string}` | `https://${string}`;
66
- parentCapability: 'eth_accounts' | string;
67
- };
68
- type WatchAssetParams = {
69
- /** In the future, other standards will be supported */
70
- type: 'ERC20';
71
- options: {
72
- /** Address of token contract */
73
- address: Address;
74
- /** Number of token decimals */
75
- decimals: ResolvedConfig['IntType'];
76
- /** String url of token logo */
77
- image?: string;
78
- /** A ticker symbol or shorthand, up to 5 characters */
79
- symbol: string;
80
- };
81
- };
82
- type InjectedProviderFlags = {
83
- isAvalanche?: true;
84
- isBitKeep?: true;
85
- isBraveWallet?: true;
86
- isCoinbaseWallet?: true;
87
- isExodus?: true;
88
- isFrame?: true;
89
- isKuCoinWallet?: true;
90
- isMathWallet?: true;
91
- isMetaMask?: true;
92
- isOneInchAndroidWallet?: true;
93
- isOneInchIOSWallet?: true;
94
- isOpera?: true;
95
- isPhantom?: true;
96
- isPortal?: true;
97
- isRainbow?: true;
98
- isTally?: true;
99
- isTokenPocket?: true;
100
- isTokenary?: true;
101
- isTrust?: true;
102
- isTrustWallet?: true;
103
- };
104
- type InjectedProviders = InjectedProviderFlags & {
105
- isMetaMask: true;
106
- /** Only exists in MetaMask as of 2022/04/03 */
107
- _events: {
108
- connect?: () => void;
109
- };
110
- /** Only exists in MetaMask as of 2022/04/03 */
111
- _state?: {
112
- accounts?: string[];
113
- initialized?: boolean;
114
- isConnected?: boolean;
115
- isPermanentlyDisconnected?: boolean;
116
- isUnlocked?: boolean;
117
- };
118
- };
119
- interface Ethereum extends InjectedProviders {
120
- on?: (...args: any[]) => void;
121
- removeListener?: (...args: any[]) => void;
122
- providers?: Ethereum[];
123
- /**
124
- * EIP-747: Add wallet_watchAsset to Provider
125
- * https://eips.ethereum.org/EIPS/eip-747
126
- */
127
- request(args: {
128
- method: 'wallet_watchAsset';
129
- params: WatchAssetParams;
130
- }): Promise<boolean>;
131
- /**
132
- * EIP-1193: Ethereum Provider JavaScript API
133
- * https://eips.ethereum.org/EIPS/eip-1193
134
- */
135
- request(args: {
136
- method: 'eth_accounts';
137
- }): Promise<Address[]>;
138
- request(args: {
139
- method: 'eth_chainId';
140
- }): Promise<string>;
141
- request(args: {
142
- method: 'eth_requestAccounts';
143
- }): Promise<Address[]>;
144
- /**
145
- * EIP-1474: Remote procedure call specification
146
- * https://eips.ethereum.org/EIPS/eip-1474
147
- */
148
- request(args: {
149
- method: 'web3_clientVersion';
150
- }): Promise<string>;
151
- /**
152
- * EIP-2255: Wallet Permissions System
153
- * https://eips.ethereum.org/EIPS/eip-2255
154
- */
155
- request(args: {
156
- method: 'wallet_requestPermissions';
157
- params: [{
158
- eth_accounts: Record<string, any>;
159
- }];
160
- }): Promise<WalletPermission[]>;
161
- request(args: {
162
- method: 'wallet_getPermissions';
163
- }): Promise<WalletPermission[]>;
164
- /**
165
- * EIP-3085: Wallet Add Ethereum Chain RPC Method
166
- * https://eips.ethereum.org/EIPS/eip-3085
167
- */
168
- request(args: {
169
- method: 'wallet_addEthereumChain';
170
- params: AddEthereumChainParameter[];
171
- }): Promise<null>;
172
- /**
173
- * EIP-3326: Wallet Switch Ethereum Chain RPC Method
174
- * https://eips.ethereum.org/EIPS/eip-3326
175
- */
176
- request(args: {
177
- method: 'wallet_switchEthereumChain';
178
- params: [{
179
- chainId: string;
180
- }];
181
- }): Promise<null>;
182
- }
183
- declare global {
184
- interface Window {
185
- ethereum?: Ethereum;
186
- }
187
- }
188
-
189
- export { ChainProviderFn as C, Ethereum as E, FallbackProviderConfig as F, Hash as H, Provider as P, Signer as S, Unit as U, WebSocketProvider as W, ProviderWithFallbackConfig as a, units as u };