wagmi 0.3.0-next.9 → 0.3.2

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 (48) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +12 -65
  3. package/connectors/metaMask/dist/wagmi-connectors-metaMask.cjs.d.ts +1 -0
  4. package/connectors/metaMask/dist/wagmi-connectors-metaMask.cjs.dev.js +12 -0
  5. package/connectors/metaMask/dist/wagmi-connectors-metaMask.cjs.js +7 -0
  6. package/connectors/metaMask/dist/wagmi-connectors-metaMask.cjs.prod.js +12 -0
  7. package/connectors/metaMask/dist/wagmi-connectors-metaMask.esm.js +1 -0
  8. package/connectors/metaMask/package.json +4 -0
  9. package/dist/declarations/src/connectors/metaMask.d.ts +1 -0
  10. package/dist/declarations/src/context.d.ts +13 -7
  11. package/dist/declarations/src/hooks/accounts/index.d.ts +1 -0
  12. package/dist/declarations/src/hooks/accounts/useAccount.d.ts +6 -179
  13. package/dist/declarations/src/hooks/accounts/useBalance.d.ts +5 -1
  14. package/dist/declarations/src/hooks/accounts/useConnect.d.ts +20 -76
  15. package/dist/declarations/src/hooks/accounts/useDisconnect.d.ts +27 -0
  16. package/dist/declarations/src/hooks/accounts/useNetwork.d.ts +19 -80
  17. package/dist/declarations/src/hooks/accounts/useSignMessage.d.ts +11 -56
  18. package/dist/declarations/src/hooks/accounts/useSignTypedData.d.ts +13 -56
  19. package/dist/declarations/src/hooks/accounts/useSigner.d.ts +3 -110
  20. package/dist/declarations/src/hooks/contracts/useContractEvent.d.ts +3 -1
  21. package/dist/declarations/src/hooks/contracts/useContractRead.d.ts +9 -4
  22. package/dist/declarations/src/hooks/contracts/useContractWrite.d.ts +7 -55
  23. package/dist/declarations/src/hooks/contracts/useToken.d.ts +6 -1
  24. package/dist/declarations/src/hooks/ens/useEnsAddress.d.ts +8 -7
  25. package/dist/declarations/src/hooks/ens/useEnsAvatar.d.ts +8 -7
  26. package/dist/declarations/src/hooks/ens/useEnsName.d.ts +8 -7
  27. package/dist/declarations/src/hooks/ens/useEnsResolver.d.ts +8 -7
  28. package/dist/declarations/src/hooks/index.d.ts +1 -1
  29. package/dist/declarations/src/hooks/network-status/useBlockNumber.d.ts +9 -3
  30. package/dist/declarations/src/hooks/network-status/useFeeData.d.ts +5 -1
  31. package/dist/declarations/src/hooks/providers/useProvider.d.ts +4 -1
  32. package/dist/declarations/src/hooks/providers/useWebSocketProvider.d.ts +4 -1
  33. package/dist/declarations/src/hooks/transactions/useSendTransaction.d.ts +10 -58
  34. package/dist/declarations/src/hooks/transactions/useWaitForTransaction.d.ts +6 -4
  35. package/dist/declarations/src/hooks/utils/index.d.ts +2 -0
  36. package/dist/declarations/src/hooks/utils/useChainId.d.ts +4 -1
  37. package/dist/declarations/src/hooks/utils/useForceUpdate.d.ts +2 -0
  38. package/dist/declarations/src/hooks/utils/useQuery.d.ts +8 -0
  39. package/dist/declarations/src/index.d.ts +6 -3
  40. package/dist/declarations/src/types/index.d.ts +4 -14
  41. package/dist/declarations/src/utils/deserialize.d.ts +1 -1
  42. package/dist/declarations/src/utils/serialize.d.ts +16 -6
  43. package/dist/wagmi.cjs.dev.js +1051 -859
  44. package/dist/wagmi.cjs.prod.js +1051 -859
  45. package/dist/wagmi.esm.js +1033 -860
  46. package/package.json +32 -10
  47. package/connectors/walletLink/dist/wagmi-connectors-walletLink.cjs.d.ts +0 -11
  48. package/connectors/walletLink/dist/wagmi-connectors-walletLink.cjs.js +0 -16
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2022 Tom Meagher
3
+ Copyright (c) 2022 awkweb.eth
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -1,83 +1,30 @@
1
- # wagmi [![Version](https://img.shields.io/npm/v/wagmi?colorA=292929&colorB=3c82f6)](https://www.npmjs.com/package/wagmi) [![Downloads](https://img.shields.io/npm/dm/wagmi?colorA=292929&colorB=3c82f6)](https://www.npmjs.com/package/wagmi) [![Sponsors](https://img.shields.io/github/sponsors/tmm?colorA=292929&colorB=3c82f6)](https://github.com/sponsors/tmm)
2
-
3
- > React Hooks for Ethereum
4
-
5
- **wagmi** is a collection of React Hooks containing everything you need to start working with Ethereum. wagmi makes it easy to "Connect Wallet," display ENS and balance information, sign messages, interact with contracts, and much more — all with caching, request deduplication, and persistence.
6
-
7
- ## Features
8
-
9
- - 🚀 20+ hooks for working with wallets, ENS, contracts, transactions, signing, etc.
10
- - 💼 Built-in wallet connectors for MetaMask, WalletConnect, and Coinbase Wallet
11
- - 🌀 Auto-refresh data on wallet and network changes
12
- - 🦄 TypeScript ready
13
- - 💨 Zero-dependencies (besides ethers.js peer dependency)
14
- - 🌳 Test suite and documentation
15
- - 📖 MIT License
1
+ # wagmi
16
2
 
17
3
  ## Documentation
18
4
 
19
- Visit https://wagmi.sh to view the full documentation.
5
+ For full documentation and examples, visit [wagmi.sh](https://wagmi.sh).
20
6
 
21
- ## Usage
7
+ ## Installation
22
8
 
23
- 1. Install the dependencies.
9
+ Install wagmi and its ethers peer dependency.
24
10
 
25
11
  ```bash
26
- npm add wagmi ethers
27
- ```
28
-
29
- 2. Wrap your app with the `Provider` component.
30
-
31
- ```tsx
32
- import { Provider } from 'wagmi'
33
-
34
- const App = () => (
35
- <Provider>
36
- <YourRoutes />
37
- </Provider>
38
- )
12
+ npm install wagmi ethers
39
13
  ```
40
14
 
41
- 3. Use hooks.
42
-
43
- ```tsx
44
- import { useAccount } from 'wagmi'
45
-
46
- const Page = () => {
47
- const [{ data, error, loading }, disconnect] = useAccount({
48
- fetchEns: true,
49
- })
50
-
51
- return ...
52
- }
53
- ```
54
-
55
- Every component inside the `Provider` is set up with the default `InjectedConnector` for connecting wallets and ethers.js [Default Provider](https://docs.ethers.io/v5/api/providers/#providers-getDefaultProvider) for fetching data.
56
-
57
- Want to learn more? Check out the [guides](https://wagmi-xyz.vercel.app/guides/connect-wallet) or browse the [API docs](https://wagmi-xyz.vercel.app/docs/provider).
58
-
59
15
  ## Community
60
16
 
17
+ Check out the following places for more wagmi-related content:
18
+
61
19
  - Join the [discussions on GitHub](https://github.com/tmm/wagmi/discussions)
62
20
  - Follow [@awkweb](https://twitter.com/awkweb) on Twitter for project updates
63
21
  - Sign the [guestbook](https://github.com/tmm/wagmi/discussions/2)
64
- - Share [your project/organization](https://github.com/tmm/wagmi/discussions/201) that uses wagmi
22
+ - Share [your project/organization](https://github.com/tmm/wagmi/discussions/201) using wagmi
65
23
 
66
24
  ## Support
67
25
 
68
- - awkweb.eth
69
- - [GitHub Sponsors](https://github.com/sponsors/tmm)
70
- - [Gitcoin Grant](https://gitcoin.co/grants/4493/wagmi-react-hooks-library-for-ethereum)
71
-
72
- ## Thanks
26
+ If you find wagmi useful, please consider supporting development. Thank you 🙏
73
27
 
74
- - [ricmoo.eth](https://twitter.com/ricmoo) for creating and continued work on [ethers.js](https://github.com/ethers-io/ethers.js)
75
- - [Mirror](https://mirror.xyz) for creating space to do good work
76
-
77
- ## License
78
-
79
- MIT.
80
-
81
- <br />
82
-
83
- wagmi frens
28
+ - [awkweb.eth](https://etherscan.io/enslookup-search?search=awkweb.eth)
29
+ - [GitHub Sponsors](https://github.com/sponsors/tmm?metadata_campaign=readme_wagmi)
30
+ - [Gitcoin Grant](https://gitcoin.co/grants/4493/wagmi-react-hooks-library-for-ethereum)
@@ -0,0 +1 @@
1
+ export * from "../../../dist/declarations/src/connectors/metaMask";
@@ -0,0 +1,12 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var metaMask = require('@wagmi/core/connectors/metaMask');
6
+
7
+
8
+
9
+ Object.defineProperty(exports, 'MetaMaskConnector', {
10
+ enumerable: true,
11
+ get: function () { return metaMask.MetaMaskConnector; }
12
+ });
@@ -0,0 +1,7 @@
1
+ 'use strict';
2
+
3
+ if (process.env.NODE_ENV === "production") {
4
+ module.exports = require("./wagmi-connectors-metaMask.cjs.prod.js");
5
+ } else {
6
+ module.exports = require("./wagmi-connectors-metaMask.cjs.dev.js");
7
+ }
@@ -0,0 +1,12 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var metaMask = require('@wagmi/core/connectors/metaMask');
6
+
7
+
8
+
9
+ Object.defineProperty(exports, 'MetaMaskConnector', {
10
+ enumerable: true,
11
+ get: function () { return metaMask.MetaMaskConnector; }
12
+ });
@@ -0,0 +1 @@
1
+ export { MetaMaskConnector } from '@wagmi/core/connectors/metaMask';
@@ -0,0 +1,4 @@
1
+ {
2
+ "main": "dist/wagmi-connectors-metaMask.cjs.js",
3
+ "module": "dist/wagmi-connectors-metaMask.esm.js"
4
+ }
@@ -0,0 +1 @@
1
+ export { MetaMaskConnector } from '@wagmi/core/connectors/metaMask';
@@ -1,16 +1,22 @@
1
1
  import * as React from 'react';
2
+ import type { BaseProvider, WebSocketProvider } from '@ethersproject/providers';
2
3
  import { WagmiClient, ClientConfig as WagmiClientConfig } from '@wagmi/core';
3
4
  import { QueryClient } from 'react-query';
4
- export declare const Context: React.Context<WagmiClient | undefined>;
5
- export declare type ClientConfig = WagmiClientConfig & {
5
+ import { Persister } from 'react-query/persistQueryClient';
6
+ export declare type DecoratedWagmiClient<TProvider extends BaseProvider = BaseProvider, TWebSocketProvider extends WebSocketProvider = WebSocketProvider> = WagmiClient<TProvider, TWebSocketProvider> & {
7
+ queryClient: QueryClient;
8
+ };
9
+ export declare const Context: React.Context<DecoratedWagmiClient<BaseProvider, WebSocketProvider> | undefined>;
10
+ export declare type ClientConfig<TProvider extends BaseProvider = BaseProvider, TWebSocketProvider extends WebSocketProvider = WebSocketProvider> = WagmiClientConfig<TProvider, TWebSocketProvider> & {
6
11
  queryClient?: QueryClient;
12
+ persister?: Persister;
7
13
  };
8
- export declare function createClient({ queryClient, ...config }?: ClientConfig): WagmiClient & {
14
+ export declare function createClient<TProvider extends BaseProvider, TWebSocketProvider extends WebSocketProvider>({ queryClient, persister, ...config }?: ClientConfig<TProvider, TWebSocketProvider>): WagmiClient<TProvider, TWebSocketProvider> & {
9
15
  queryClient: QueryClient;
10
16
  };
11
- export declare type ProviderProps = {
17
+ export declare type ProviderProps<TProvider extends BaseProvider = BaseProvider, TWebSocketProvider extends WebSocketProvider = WebSocketProvider> = {
12
18
  /** React-decorated WagmiClient instance */
13
- client?: ReturnType<typeof createClient>;
19
+ client?: DecoratedWagmiClient<TProvider, TWebSocketProvider>;
14
20
  };
15
- export declare function Provider({ children, client, }: React.PropsWithChildren<ProviderProps>): JSX.Element;
16
- export declare function useClient(): WagmiClient;
21
+ export declare function Provider<TProvider extends BaseProvider, TWebSocketProvider extends WebSocketProvider>({ children, client, }: React.PropsWithChildren<ProviderProps<TProvider, TWebSocketProvider>>): JSX.Element;
22
+ export declare function useClient<TProvider extends BaseProvider, TWebSocketProvider extends WebSocketProvider = WebSocketProvider>(): DecoratedWagmiClient<TProvider, TWebSocketProvider>;
@@ -1,6 +1,7 @@
1
1
  export { useAccount } from './useAccount';
2
2
  export { useBalance } from './useBalance';
3
3
  export { useConnect } from './useConnect';
4
+ export { useDisconnect } from './useDisconnect';
4
5
  export { useNetwork } from './useNetwork';
5
6
  export { useSigner } from './useSigner';
6
7
  export { useSignMessage } from './useSignMessage';
@@ -1,184 +1,11 @@
1
- import { GetAccountResult, disconnect } from '@wagmi/core';
1
+ import { GetAccountResult } from '@wagmi/core';
2
2
  import { QueryConfig } from '../../types';
3
- export declare type UseAccountArgs = {
4
- /** Fetches ENS for connected account */
5
- ens?: boolean | {
6
- avatar?: boolean;
7
- name?: boolean;
8
- };
9
- };
10
- export declare type UseAccountConfig = QueryConfig<GetAccountResult, Error>;
3
+ export declare type UseAccountConfig = Pick<QueryConfig<GetAccountResult, Error>, 'suspense' | 'onError' | 'onSettled' | 'onSuccess'>;
11
4
  export declare const queryKey: () => readonly [{
12
5
  readonly entity: "account";
13
6
  }];
14
- export declare function useAccount({ ens, cacheTime, enabled, keepPreviousData, select, staleTime, suspense, onError, onSettled, onSuccess, }?: UseAccountArgs & UseAccountConfig): {
15
- readonly data: {
16
- ens: {
17
- avatar: import("@wagmi/core").FetchEnsAvatarResult | undefined;
18
- name: import("@wagmi/core").FetchEnsNameResult | undefined;
19
- };
20
- address: string;
21
- connector?: import("@wagmi/core").Connector<any, any> | undefined;
22
- } | {
23
- ens?: undefined;
24
- address: string;
25
- connector?: import("@wagmi/core").Connector<any, any> | undefined;
26
- } | undefined;
27
- readonly disconnect: typeof disconnect;
28
- readonly error: Error | null;
29
- readonly isError: boolean;
30
- readonly isIdle: boolean;
31
- readonly isLoading: boolean;
32
- readonly isSuccess: boolean;
33
- readonly status: "error" | "idle" | "loading" | "success";
34
- readonly isLoadingError: false;
35
- readonly isRefetchError: false;
36
- readonly dataUpdatedAt: number;
37
- readonly errorUpdatedAt: number;
38
- readonly failureCount: number;
39
- readonly isFetched: boolean;
40
- readonly isFetchedAfterMount: boolean;
41
- readonly isFetching: boolean;
42
- readonly isPlaceholderData: boolean;
43
- readonly isPreviousData: boolean;
44
- readonly isRefetching: boolean;
45
- readonly isStale: boolean;
46
- readonly refetch: <TPageData>(options?: (import("react-query").RefetchOptions & import("react-query").RefetchQueryFilters<TPageData>) | undefined) => Promise<import("react-query").QueryObserverResult<GetAccountResult, Error>>;
47
- readonly remove: () => void;
48
- } | {
49
- readonly data: {
50
- ens: {
51
- avatar: import("@wagmi/core").FetchEnsAvatarResult | undefined;
52
- name: import("@wagmi/core").FetchEnsNameResult | undefined;
53
- };
54
- address: string;
55
- connector?: import("@wagmi/core").Connector<any, any> | undefined;
56
- } | {
57
- ens?: undefined;
58
- address: string;
59
- connector?: import("@wagmi/core").Connector<any, any> | undefined;
60
- } | undefined;
61
- readonly disconnect: typeof disconnect;
62
- readonly error: Error | null;
63
- readonly isError: boolean;
64
- readonly isIdle: boolean;
65
- readonly isLoading: boolean;
66
- readonly isSuccess: boolean;
67
- readonly status: "error" | "idle" | "loading" | "success";
68
- readonly isLoadingError: true;
69
- readonly isRefetchError: false;
70
- readonly dataUpdatedAt: number;
71
- readonly errorUpdatedAt: number;
72
- readonly failureCount: number;
73
- readonly isFetched: boolean;
74
- readonly isFetchedAfterMount: boolean;
75
- readonly isFetching: boolean;
76
- readonly isPlaceholderData: boolean;
77
- readonly isPreviousData: boolean;
78
- readonly isRefetching: boolean;
79
- readonly isStale: boolean;
80
- readonly refetch: <TPageData>(options?: (import("react-query").RefetchOptions & import("react-query").RefetchQueryFilters<TPageData>) | undefined) => Promise<import("react-query").QueryObserverResult<GetAccountResult, Error>>;
81
- readonly remove: () => void;
82
- } | {
83
- readonly data: {
84
- ens: {
85
- avatar: import("@wagmi/core").FetchEnsAvatarResult | undefined;
86
- name: import("@wagmi/core").FetchEnsNameResult | undefined;
87
- };
88
- address: string;
89
- connector?: import("@wagmi/core").Connector<any, any> | undefined;
90
- } | {
91
- ens?: undefined;
92
- address: string;
93
- connector?: import("@wagmi/core").Connector<any, any> | undefined;
94
- } | undefined;
95
- readonly disconnect: typeof disconnect;
96
- readonly error: Error | null;
97
- readonly isError: boolean;
98
- readonly isIdle: boolean;
99
- readonly isLoading: boolean;
100
- readonly isSuccess: boolean;
101
- readonly status: "error" | "idle" | "loading" | "success";
102
- readonly isLoadingError: false;
103
- readonly isRefetchError: false;
104
- readonly dataUpdatedAt: number;
105
- readonly errorUpdatedAt: number;
106
- readonly failureCount: number;
107
- readonly isFetched: boolean;
108
- readonly isFetchedAfterMount: boolean;
109
- readonly isFetching: boolean;
110
- readonly isPlaceholderData: boolean;
111
- readonly isPreviousData: boolean;
112
- readonly isRefetching: boolean;
113
- readonly isStale: boolean;
114
- readonly refetch: <TPageData>(options?: (import("react-query").RefetchOptions & import("react-query").RefetchQueryFilters<TPageData>) | undefined) => Promise<import("react-query").QueryObserverResult<GetAccountResult, Error>>;
115
- readonly remove: () => void;
116
- } | {
117
- readonly data: {
118
- ens: {
119
- avatar: import("@wagmi/core").FetchEnsAvatarResult | undefined;
120
- name: import("@wagmi/core").FetchEnsNameResult | undefined;
121
- };
122
- address: string;
123
- connector?: import("@wagmi/core").Connector<any, any> | undefined;
124
- } | {
125
- ens?: undefined;
126
- address: string;
127
- connector?: import("@wagmi/core").Connector<any, any> | undefined;
128
- } | undefined;
129
- readonly disconnect: typeof disconnect;
130
- readonly error: Error | null;
131
- readonly isError: boolean;
132
- readonly isIdle: boolean;
133
- readonly isLoading: boolean;
134
- readonly isSuccess: boolean;
135
- readonly status: "error" | "idle" | "loading" | "success";
136
- readonly isLoadingError: false;
137
- readonly isRefetchError: true;
138
- readonly dataUpdatedAt: number;
139
- readonly errorUpdatedAt: number;
140
- readonly failureCount: number;
141
- readonly isFetched: boolean;
142
- readonly isFetchedAfterMount: boolean;
143
- readonly isFetching: boolean;
144
- readonly isPlaceholderData: boolean;
145
- readonly isPreviousData: boolean;
146
- readonly isRefetching: boolean;
147
- readonly isStale: boolean;
148
- readonly refetch: <TPageData>(options?: (import("react-query").RefetchOptions & import("react-query").RefetchQueryFilters<TPageData>) | undefined) => Promise<import("react-query").QueryObserverResult<GetAccountResult, Error>>;
149
- readonly remove: () => void;
150
- } | {
151
- readonly data: {
152
- ens: {
153
- avatar: import("@wagmi/core").FetchEnsAvatarResult | undefined;
154
- name: import("@wagmi/core").FetchEnsNameResult | undefined;
155
- };
156
- address: string;
157
- connector?: import("@wagmi/core").Connector<any, any> | undefined;
158
- } | {
159
- ens?: undefined;
160
- address: string;
161
- connector?: import("@wagmi/core").Connector<any, any> | undefined;
162
- } | undefined;
163
- readonly disconnect: typeof disconnect;
164
- readonly error: Error | null;
165
- readonly isError: boolean;
166
- readonly isIdle: boolean;
167
- readonly isLoading: boolean;
168
- readonly isSuccess: boolean;
169
- readonly status: "error" | "idle" | "loading" | "success";
170
- readonly isLoadingError: false;
171
- readonly isRefetchError: false;
172
- readonly dataUpdatedAt: number;
173
- readonly errorUpdatedAt: number;
174
- readonly failureCount: number;
175
- readonly isFetched: boolean;
176
- readonly isFetchedAfterMount: boolean;
177
- readonly isFetching: boolean;
178
- readonly isPlaceholderData: boolean;
179
- readonly isPreviousData: boolean;
180
- readonly isRefetching: boolean;
181
- readonly isStale: boolean;
182
- readonly refetch: <TPageData>(options?: (import("react-query").RefetchOptions & import("react-query").RefetchQueryFilters<TPageData>) | undefined) => Promise<import("react-query").QueryObserverResult<GetAccountResult, Error>>;
183
- readonly remove: () => void;
7
+ export declare function useAccount({ suspense, onError, onSettled, onSuccess, }?: UseAccountConfig): Pick<import("react-query").QueryObserverResult<GetAccountResult<import("@ethersproject/providers").BaseProvider>, Error>, "data" | "error" | "isError" | "isLoading" | "isSuccess" | "isFetched" | "isFetching" | "isRefetching" | "refetch" | "fetchStatus"> & {
8
+ isIdle: boolean;
9
+ status: "error" | "loading" | "success" | "idle";
10
+ internal: Pick<import("react-query").QueryObserverResult<unknown, unknown>, "isLoadingError" | "isRefetchError" | "dataUpdatedAt" | "errorUpdatedAt" | "failureCount" | "isFetchedAfterMount" | "isPaused" | "isPlaceholderData" | "isPreviousData" | "isStale" | "remove">;
184
11
  };
@@ -14,4 +14,8 @@ export declare const queryKey: ({ addressOrName, chainId, formatUnits, token, }:
14
14
  readonly formatUnits: number | "wei" | "kwei" | "mwei" | "gwei" | "szabo" | "finney" | "ether" | undefined;
15
15
  readonly token: string | undefined;
16
16
  }];
17
- export declare function useBalance({ addressOrName, formatUnits, token, watch, cacheTime, enabled, keepPreviousData, select, staleTime, suspense, onError, onSettled, onSuccess, }?: UseBalanceArgs & UseBalanceConfig): import("react-query").UseQueryResult<FetchBalanceResult, Error>;
17
+ export declare function useBalance({ addressOrName, cacheTime, chainId: chainId_, enabled, formatUnits, staleTime, suspense, token, watch, onError, onSettled, onSuccess, }?: UseBalanceArgs & UseBalanceConfig): Pick<import("react-query").QueryObserverResult<FetchBalanceResult, Error>, "data" | "error" | "isError" | "isLoading" | "isSuccess" | "isFetched" | "isFetching" | "isRefetching" | "refetch" | "fetchStatus"> & {
18
+ isIdle: boolean;
19
+ status: "error" | "loading" | "success" | "idle";
20
+ internal: Pick<import("react-query").QueryObserverResult<unknown, unknown>, "isLoadingError" | "isRefetchError" | "dataUpdatedAt" | "errorUpdatedAt" | "failureCount" | "isFetchedAfterMount" | "isPaused" | "isPlaceholderData" | "isPreviousData" | "isStale" | "remove">;
21
+ };
@@ -1,95 +1,39 @@
1
- import { ConnectResult, Connector } from '@wagmi/core';
1
+ import { ConnectArgs, ConnectResult } from '@wagmi/core';
2
2
  import { UseMutationOptions } from 'react-query';
3
- declare type MutationOptions = UseMutationOptions<ConnectResult, Error, Connector>;
3
+ export declare type UseConnectArgs = Partial<ConnectArgs>;
4
+ declare type MutationOptions = UseMutationOptions<ConnectResult, Error, ConnectArgs>;
4
5
  export declare type UseConnectConfig = {
5
6
  /**
6
- * Function fires before connect function and is passed same variables connect function would receive.
7
+ * Function to invoke before connect and is passed same variables connect function would receive.
7
8
  * Value returned from this function will be passed to both onError and onSettled functions in event of a mutation failure.
8
9
  */
9
10
  onBeforeConnect?: MutationOptions['onMutate'];
10
- /** Function fires when connect is successful */
11
+ /** Function to invoke when connect is successful. */
11
12
  onConnect?: MutationOptions['onSuccess'];
12
- /** Function fires if connect encounters error */
13
+ /** Function to invoke when an error is thrown while connecting. */
13
14
  onError?: MutationOptions['onError'];
14
- /** Function fires when connect is either successful or encounters error */
15
+ /** Function to invoke when connect is settled (either successfully connected, or an error has thrown). */
15
16
  onSettled?: MutationOptions['onSettled'];
16
17
  };
17
- export declare const mutationKey = "connect";
18
- export declare function useConnect({ onBeforeConnect, onConnect, onError, onSettled, }?: UseConnectConfig): {
19
- readonly activeConnector: Connector<any, any> | undefined;
20
- readonly connect: import("react-query").UseMutateFunction<ConnectResult, Error, Connector<any, any>, unknown>;
21
- readonly connectAsync: import("react-query").UseMutateAsyncFunction<ConnectResult, Error, Connector<any, any>, unknown>;
22
- readonly connector: Connector<any, any> | undefined;
23
- readonly connectors: Connector<any, any>[];
18
+ export declare const mutationKey: (args: UseConnectArgs) => {
19
+ connector?: import("@wagmi/core").Connector<any, any> | undefined;
20
+ entity: string;
21
+ }[];
22
+ export declare function useConnect({ connector, onBeforeConnect, onConnect, onError, onSettled, }?: UseConnectArgs & UseConnectConfig): {
23
+ readonly activeConnector: import("@wagmi/core").Connector<any, any> | undefined;
24
+ readonly connect: (connector_?: import("@wagmi/core").Connector<any, any> | undefined) => void;
25
+ readonly connectAsync: (connector_?: import("@wagmi/core").Connector<any, any> | undefined) => Promise<ConnectResult<import("@ethersproject/providers").BaseProvider>>;
26
+ readonly connectors: import("@wagmi/core").Connector<any, any>[];
27
+ readonly data: ConnectResult<import("@ethersproject/providers").BaseProvider> | undefined;
28
+ readonly error: Error | null;
24
29
  readonly isConnected: boolean;
25
30
  readonly isConnecting: boolean;
26
31
  readonly isDisconnected: boolean;
32
+ readonly isError: boolean;
27
33
  readonly isIdle: boolean;
28
34
  readonly isReconnecting: boolean;
29
- readonly status: "error" | "connecting" | "connected" | "reconnecting" | "disconnected" | "idle";
30
- readonly data: undefined;
31
- readonly error: null;
32
- readonly isError: false;
35
+ readonly pendingConnector: import("@wagmi/core").Connector<any, any> | undefined;
33
36
  readonly reset: () => void;
34
- readonly context: unknown;
35
- readonly failureCount: number;
36
- readonly isPaused: boolean;
37
- } | {
38
- readonly activeConnector: Connector<any, any> | undefined;
39
- readonly connect: import("react-query").UseMutateFunction<ConnectResult, Error, Connector<any, any>, unknown>;
40
- readonly connectAsync: import("react-query").UseMutateAsyncFunction<ConnectResult, Error, Connector<any, any>, unknown>;
41
- readonly connector: Connector<any, any> | undefined;
42
- readonly connectors: Connector<any, any>[];
43
- readonly isConnected: boolean;
44
- readonly isConnecting: boolean;
45
- readonly isDisconnected: boolean;
46
- readonly isIdle: boolean;
47
- readonly isReconnecting: boolean;
48
37
  readonly status: "error" | "connecting" | "connected" | "reconnecting" | "disconnected" | "idle";
49
- readonly data: undefined;
50
- readonly error: null;
51
- readonly isError: false;
52
- readonly reset: () => void;
53
- readonly context: unknown;
54
- readonly failureCount: number;
55
- readonly isPaused: boolean;
56
- } | {
57
- readonly activeConnector: Connector<any, any> | undefined;
58
- readonly connect: import("react-query").UseMutateFunction<ConnectResult, Error, Connector<any, any>, unknown>;
59
- readonly connectAsync: import("react-query").UseMutateAsyncFunction<ConnectResult, Error, Connector<any, any>, unknown>;
60
- readonly connector: Connector<any, any> | undefined;
61
- readonly connectors: Connector<any, any>[];
62
- readonly isConnected: boolean;
63
- readonly isConnecting: boolean;
64
- readonly isDisconnected: boolean;
65
- readonly isIdle: boolean;
66
- readonly isReconnecting: boolean;
67
- readonly status: "error" | "connecting" | "connected" | "reconnecting" | "disconnected" | "idle";
68
- readonly data: undefined;
69
- readonly error: Error;
70
- readonly isError: true;
71
- readonly reset: () => void;
72
- readonly context: unknown;
73
- readonly failureCount: number;
74
- readonly isPaused: boolean;
75
- } | {
76
- readonly activeConnector: Connector<any, any> | undefined;
77
- readonly connect: import("react-query").UseMutateFunction<ConnectResult, Error, Connector<any, any>, unknown>;
78
- readonly connectAsync: import("react-query").UseMutateAsyncFunction<ConnectResult, Error, Connector<any, any>, unknown>;
79
- readonly connector: Connector<any, any> | undefined;
80
- readonly connectors: Connector<any, any>[];
81
- readonly isConnected: boolean;
82
- readonly isConnecting: boolean;
83
- readonly isDisconnected: boolean;
84
- readonly isIdle: boolean;
85
- readonly isReconnecting: boolean;
86
- readonly status: "error" | "connecting" | "connected" | "reconnecting" | "disconnected" | "idle";
87
- readonly data: ConnectResult;
88
- readonly error: null;
89
- readonly isError: false;
90
- readonly reset: () => void;
91
- readonly context: unknown;
92
- readonly failureCount: number;
93
- readonly isPaused: boolean;
94
38
  };
95
39
  export {};
@@ -0,0 +1,27 @@
1
+ export declare type UseDisconnectConfig = {
2
+ /** Function to invoke when an error is thrown while connecting. */
3
+ onError?: (error: Error, context: unknown) => void | Promise<unknown>;
4
+ /**
5
+ * Function fires before mutation function and is passed same variables mutation function would receive.
6
+ * Value returned from this function will be passed to both onError and onSettled functions in event of a mutation failure.
7
+ */
8
+ onMutate?: () => unknown;
9
+ /** Function to invoke when connect is settled (either successfully connected, or an error has thrown). */
10
+ onSettled?: (error: Error | null, context: unknown) => void | Promise<unknown>;
11
+ /** Function fires when mutation is successful and will be passed the mutation's result */
12
+ onSuccess?: (context: unknown) => void | Promise<unknown>;
13
+ };
14
+ export declare const mutationKey: {
15
+ entity: string;
16
+ }[];
17
+ export declare function useDisconnect({ onError, onMutate, onSettled, onSuccess, }?: UseDisconnectConfig): {
18
+ readonly disconnect: import("react-query").UseMutateFunction<void, Error, void, unknown>;
19
+ readonly disconnectAsync: import("react-query").UseMutateAsyncFunction<void, Error, void, unknown>;
20
+ readonly error: Error | null;
21
+ readonly isError: boolean;
22
+ readonly isIdle: boolean;
23
+ readonly isLoading: boolean;
24
+ readonly isSuccess: boolean;
25
+ readonly reset: () => void;
26
+ readonly status: "error" | "loading" | "success" | "idle";
27
+ };