wagmi 0.2.21 → 0.3.0-next.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.
Files changed (68) hide show
  1. package/connectors/coinbaseWallet/dist/wagmi-connectors-coinbaseWallet.cjs.d.ts +1 -0
  2. package/connectors/coinbaseWallet/dist/wagmi-connectors-coinbaseWallet.cjs.dev.js +12 -0
  3. package/connectors/coinbaseWallet/dist/wagmi-connectors-coinbaseWallet.cjs.js +7 -0
  4. package/connectors/coinbaseWallet/dist/wagmi-connectors-coinbaseWallet.cjs.prod.js +12 -0
  5. package/connectors/coinbaseWallet/dist/wagmi-connectors-coinbaseWallet.esm.js +1 -0
  6. package/connectors/coinbaseWallet/package.json +4 -0
  7. package/connectors/injected/dist/wagmi-connectors-injected.cjs.dev.js +2 -2
  8. package/connectors/injected/dist/wagmi-connectors-injected.cjs.prod.js +2 -2
  9. package/connectors/injected/dist/wagmi-connectors-injected.esm.js +1 -1
  10. package/connectors/walletConnect/dist/wagmi-connectors-walletConnect.cjs.dev.js +1 -1
  11. package/connectors/walletConnect/dist/wagmi-connectors-walletConnect.cjs.prod.js +1 -1
  12. package/connectors/walletConnect/dist/wagmi-connectors-walletConnect.esm.js +1 -1
  13. package/connectors/walletLink/dist/wagmi-connectors-walletLink.cjs.d.ts +11 -1
  14. package/connectors/walletLink/dist/wagmi-connectors-walletLink.cjs.js +15 -6
  15. package/dist/declarations/src/connectors/coinbaseWallet.d.ts +1 -0
  16. package/dist/declarations/src/connectors/injected.d.ts +1 -1
  17. package/dist/declarations/src/connectors/walletConnect.d.ts +1 -1
  18. package/dist/declarations/src/context.d.ts +12 -59
  19. package/dist/declarations/src/hooks/accounts/index.d.ts +0 -1
  20. package/dist/declarations/src/hooks/accounts/useAccount.d.ts +179 -11
  21. package/dist/declarations/src/hooks/accounts/useBalance.d.ts +15 -26
  22. package/dist/declarations/src/hooks/accounts/useConnect.d.ts +95 -13
  23. package/dist/declarations/src/hooks/accounts/useNetwork.d.ts +87 -29
  24. package/dist/declarations/src/hooks/accounts/useSignMessage.d.ts +63 -15
  25. package/dist/declarations/src/hooks/accounts/useSigner.d.ts +117 -11
  26. package/dist/declarations/src/hooks/contracts/index.d.ts +1 -1
  27. package/dist/declarations/src/hooks/contracts/useContract.d.ts +3 -11
  28. package/dist/declarations/src/hooks/contracts/useContractEvent.d.ts +3 -4
  29. package/dist/declarations/src/hooks/contracts/useContractRead.d.ts +17 -22
  30. package/dist/declarations/src/hooks/contracts/useContractWrite.d.ts +69 -19
  31. package/dist/declarations/src/hooks/contracts/useToken.d.ts +13 -42
  32. package/dist/declarations/src/hooks/ens/index.d.ts +2 -2
  33. package/dist/declarations/src/hooks/ens/useEnsAddress.d.ts +17 -0
  34. package/dist/declarations/src/hooks/ens/useEnsAvatar.d.ts +15 -12
  35. package/dist/declarations/src/hooks/ens/useEnsName.d.ts +17 -0
  36. package/dist/declarations/src/hooks/ens/useEnsResolver.d.ts +15 -19
  37. package/dist/declarations/src/hooks/index.d.ts +4 -4
  38. package/dist/declarations/src/hooks/network-status/useBlockNumber.d.ts +10 -15
  39. package/dist/declarations/src/hooks/network-status/useFeeData.d.ts +12 -27
  40. package/dist/declarations/src/hooks/providers/useProvider.d.ts +1 -1
  41. package/dist/declarations/src/hooks/providers/useWebSocketProvider.d.ts +1 -1
  42. package/dist/declarations/src/hooks/transactions/index.d.ts +1 -1
  43. package/dist/declarations/src/hooks/transactions/useSendTransaction.d.ts +69 -0
  44. package/dist/declarations/src/hooks/transactions/useWaitForTransaction.d.ts +15 -31
  45. package/dist/declarations/src/hooks/utils/index.d.ts +1 -3
  46. package/dist/declarations/src/hooks/utils/useChainId.d.ts +1 -0
  47. package/dist/declarations/src/index.d.ts +3 -5
  48. package/dist/declarations/src/types/index.d.ts +50 -0
  49. package/dist/declarations/src/utils/deserialize.d.ts +2 -0
  50. package/dist/declarations/src/utils/index.d.ts +2 -0
  51. package/dist/declarations/src/utils/serialize.d.ts +7 -0
  52. package/dist/wagmi.cjs.dev.js +1103 -1646
  53. package/dist/wagmi.cjs.prod.js +1103 -1646
  54. package/dist/wagmi.esm.js +1086 -1603
  55. package/package.json +15 -18
  56. package/README.md +0 -81
  57. package/connectors/walletLink/dist/wagmi-connectors-walletLink.cjs.dev.js +0 -12
  58. package/connectors/walletLink/dist/wagmi-connectors-walletLink.cjs.prod.js +0 -12
  59. package/connectors/walletLink/dist/wagmi-connectors-walletLink.esm.js +0 -1
  60. package/connectors/walletLink/package.json +0 -4
  61. package/dist/declarations/src/connectors/walletLink.d.ts +0 -1
  62. package/dist/declarations/src/hooks/accounts/useSignTypedData.d.ts +0 -33
  63. package/dist/declarations/src/hooks/ens/useEnsLookup.d.ts +0 -20
  64. package/dist/declarations/src/hooks/ens/useEnsResolveName.d.ts +0 -20
  65. package/dist/declarations/src/hooks/transactions/useTransaction.d.ts +0 -18
  66. package/dist/declarations/src/hooks/utils/useCacheBuster.d.ts +0 -1
  67. package/dist/declarations/src/hooks/utils/useCancel.d.ts +0 -3
  68. package/dist/declarations/src/hooks/utils/useLocalStorage.d.ts +0 -1
@@ -1,30 +1,88 @@
1
- import { Chain, SwitchChainError } from 'wagmi-core';
2
- export declare const useNetwork: () => readonly [{
3
- readonly data: {
4
- readonly chain: {
5
- id: number;
6
- unsupported: boolean | undefined;
7
- name?: string | undefined;
8
- nativeCurrency?: {
9
- name: string;
10
- symbol: string;
11
- decimals: 18;
12
- } | undefined;
13
- rpcUrls?: string[] | undefined;
14
- blockExplorers?: {
15
- name: string;
16
- url: string;
17
- }[] | undefined;
18
- testnet?: boolean | undefined;
19
- } | undefined;
20
- readonly chains: Chain[];
21
- };
22
- readonly error: Error | undefined;
23
- readonly loading: boolean | undefined;
24
- }, ((chainId: number) => Promise<{
25
- data: undefined;
26
- error: SwitchChainError;
1
+ import { SwitchNetworkResult } from '@wagmi/core';
2
+ import { MutationConfig } from '../../types';
3
+ export declare type UseConnectConfig = MutationConfig<SwitchNetworkResult, Error, number>;
4
+ export declare const mutationKey = "switchNetwork";
5
+ export declare const queryKey: () => readonly [{
6
+ readonly entity: "chain";
7
+ }];
8
+ export declare function useNetwork({ onError, onMutate, onSettled, onSuccess, }?: UseConnectConfig): {
9
+ readonly activeChain: (import("@wagmi/core").Chain & {
10
+ id: number;
11
+ unsupported?: boolean | undefined;
12
+ }) | undefined;
13
+ readonly chainId: number | undefined;
14
+ readonly chains: import("@wagmi/core").Chain[];
15
+ readonly switchNetwork: import("react-query").UseMutateFunction<import("@wagmi/core").Chain, Error, number, unknown> | undefined;
16
+ readonly switchNetworkAsync: import("react-query").UseMutateAsyncFunction<import("@wagmi/core").Chain, Error, number, unknown> | undefined;
17
+ readonly data: undefined;
18
+ readonly error: null;
19
+ readonly isError: false;
20
+ readonly isIdle: true;
21
+ readonly isLoading: false;
22
+ readonly isSuccess: false;
23
+ readonly status: "idle";
24
+ readonly reset: () => void;
25
+ readonly context: unknown;
26
+ readonly failureCount: number;
27
+ readonly isPaused: boolean;
27
28
  } | {
28
- data: Chain | undefined;
29
- error: undefined;
30
- }>) | undefined];
29
+ readonly activeChain: (import("@wagmi/core").Chain & {
30
+ id: number;
31
+ unsupported?: boolean | undefined;
32
+ }) | undefined;
33
+ readonly chainId: number | undefined;
34
+ readonly chains: import("@wagmi/core").Chain[];
35
+ readonly switchNetwork: import("react-query").UseMutateFunction<import("@wagmi/core").Chain, Error, number, unknown> | undefined;
36
+ readonly switchNetworkAsync: import("react-query").UseMutateAsyncFunction<import("@wagmi/core").Chain, Error, number, unknown> | undefined;
37
+ readonly data: undefined;
38
+ readonly error: null;
39
+ readonly isError: false;
40
+ readonly isIdle: false;
41
+ readonly isLoading: true;
42
+ readonly isSuccess: false;
43
+ readonly status: "loading";
44
+ readonly reset: () => void;
45
+ readonly context: unknown;
46
+ readonly failureCount: number;
47
+ readonly isPaused: boolean;
48
+ } | {
49
+ readonly activeChain: (import("@wagmi/core").Chain & {
50
+ id: number;
51
+ unsupported?: boolean | undefined;
52
+ }) | undefined;
53
+ readonly chainId: number | undefined;
54
+ readonly chains: import("@wagmi/core").Chain[];
55
+ readonly switchNetwork: import("react-query").UseMutateFunction<import("@wagmi/core").Chain, Error, number, unknown> | undefined;
56
+ readonly switchNetworkAsync: import("react-query").UseMutateAsyncFunction<import("@wagmi/core").Chain, Error, number, unknown> | undefined;
57
+ readonly data: undefined;
58
+ readonly error: Error;
59
+ readonly isError: true;
60
+ readonly isIdle: false;
61
+ readonly isLoading: false;
62
+ readonly isSuccess: false;
63
+ readonly status: "error";
64
+ readonly reset: () => void;
65
+ readonly context: unknown;
66
+ readonly failureCount: number;
67
+ readonly isPaused: boolean;
68
+ } | {
69
+ readonly activeChain: (import("@wagmi/core").Chain & {
70
+ id: number;
71
+ unsupported?: boolean | undefined;
72
+ }) | undefined;
73
+ readonly chainId: number | undefined;
74
+ readonly chains: import("@wagmi/core").Chain[];
75
+ readonly switchNetwork: import("react-query").UseMutateFunction<import("@wagmi/core").Chain, Error, number, unknown> | undefined;
76
+ readonly switchNetworkAsync: import("react-query").UseMutateAsyncFunction<import("@wagmi/core").Chain, Error, number, unknown> | undefined;
77
+ readonly data: import("@wagmi/core").Chain;
78
+ readonly error: null;
79
+ readonly isError: false;
80
+ readonly isIdle: false;
81
+ readonly isLoading: false;
82
+ readonly isSuccess: true;
83
+ readonly status: "success";
84
+ readonly reset: () => void;
85
+ readonly context: unknown;
86
+ readonly failureCount: number;
87
+ readonly isPaused: boolean;
88
+ };
@@ -1,18 +1,66 @@
1
- import { Bytes } from 'ethers/lib/utils';
2
- export declare type Config = {
3
- /** Message to sign with wallet */
4
- message?: Bytes | string;
5
- };
6
- export declare const useSignMessage: ({ message }?: Config) => readonly [{
7
- readonly data: string | undefined;
8
- readonly error: Error | undefined;
9
- readonly loading: boolean | undefined;
10
- }, (config?: {
11
- message?: Config['message'];
12
- } | undefined) => Promise<{
13
- data: string;
14
- error: undefined;
1
+ import { SignMessageArgs, SignMessageResult } from '@wagmi/core';
2
+ import { MutationConfig } from '../../types';
3
+ export declare type UseSignMessageArgs = Partial<SignMessageArgs>;
4
+ export declare type UseSignMessageConfig = MutationConfig<SignMessageResult, Error, SignMessageArgs>;
5
+ export declare const mutationKey = "signMessage";
6
+ export declare function useSignMessage({ message, onError, onMutate, onSettled, onSuccess, }?: UseSignMessageArgs & UseSignMessageConfig): {
7
+ signMessage: (args?: SignMessageArgs | undefined) => void;
8
+ signMessageAsync: (args?: SignMessageArgs | undefined) => Promise<string>;
9
+ data: undefined;
10
+ error: null;
11
+ isError: false;
12
+ isIdle: true;
13
+ isLoading: false;
14
+ isSuccess: false;
15
+ status: "idle";
16
+ reset: () => void;
17
+ context: unknown;
18
+ failureCount: number;
19
+ isPaused: boolean;
20
+ variables: SignMessageArgs | undefined;
21
+ } | {
22
+ signMessage: (args?: SignMessageArgs | undefined) => void;
23
+ signMessageAsync: (args?: SignMessageArgs | undefined) => Promise<string>;
24
+ data: undefined;
25
+ error: null;
26
+ isError: false;
27
+ isIdle: false;
28
+ isLoading: true;
29
+ isSuccess: false;
30
+ status: "loading";
31
+ reset: () => void;
32
+ context: unknown;
33
+ failureCount: number;
34
+ isPaused: boolean;
35
+ variables: SignMessageArgs | undefined;
15
36
  } | {
37
+ signMessage: (args?: SignMessageArgs | undefined) => void;
38
+ signMessageAsync: (args?: SignMessageArgs | undefined) => Promise<string>;
16
39
  data: undefined;
17
40
  error: Error;
18
- }>];
41
+ isError: true;
42
+ isIdle: false;
43
+ isLoading: false;
44
+ isSuccess: false;
45
+ status: "error";
46
+ reset: () => void;
47
+ context: unknown;
48
+ failureCount: number;
49
+ isPaused: boolean;
50
+ variables: SignMessageArgs | undefined;
51
+ } | {
52
+ signMessage: (args?: SignMessageArgs | undefined) => void;
53
+ signMessageAsync: (args?: SignMessageArgs | undefined) => Promise<string>;
54
+ data: string;
55
+ error: null;
56
+ isError: false;
57
+ isIdle: false;
58
+ isLoading: false;
59
+ isSuccess: true;
60
+ status: "success";
61
+ reset: () => void;
62
+ context: unknown;
63
+ failureCount: number;
64
+ isPaused: boolean;
65
+ variables: SignMessageArgs | undefined;
66
+ };
@@ -1,12 +1,118 @@
1
- import { Signer } from 'ethers';
2
- declare type Config = {
3
- /** Disables fetching */
4
- skip?: boolean;
1
+ import { FetchSignerResult } from '@wagmi/core';
2
+ import { QueryConfig } from '../../types';
3
+ export declare type UseSignerConfig = Omit<QueryConfig<FetchSignerResult, Error>, 'cacheTime' | 'staleTime' | 'enabled'>;
4
+ export declare const queryKey: () => readonly [{
5
+ readonly entity: "signer";
6
+ }];
7
+ export declare const queryFn: () => Promise<FetchSignerResult>;
8
+ export declare function useSigner({ onError, onSettled, onSuccess, }?: UseSignerConfig): {
9
+ isIdle: boolean;
10
+ isFetching: boolean;
11
+ isLoading: boolean;
12
+ status: string;
13
+ data: undefined;
14
+ error: null;
15
+ isError: false;
16
+ isLoadingError: false;
17
+ isRefetchError: false;
18
+ isSuccess: false;
19
+ dataUpdatedAt: number;
20
+ errorUpdatedAt: number;
21
+ failureCount: number;
22
+ isFetched: boolean;
23
+ isFetchedAfterMount: boolean;
24
+ isPlaceholderData: boolean;
25
+ isPreviousData: boolean;
26
+ isRefetching: boolean;
27
+ isStale: boolean;
28
+ refetch: <TPageData>(options?: (import("react-query").RefetchOptions & import("react-query").RefetchQueryFilters<TPageData>) | undefined) => Promise<import("react-query").QueryObserverResult<import("ethers").Signer, Error>>;
29
+ remove: () => void;
30
+ } | {
31
+ isIdle: boolean;
32
+ isFetching: boolean;
33
+ isLoading: boolean;
34
+ status: string;
35
+ data: undefined;
36
+ error: Error;
37
+ isError: true;
38
+ isLoadingError: true;
39
+ isRefetchError: false;
40
+ isSuccess: false;
41
+ dataUpdatedAt: number;
42
+ errorUpdatedAt: number;
43
+ failureCount: number;
44
+ isFetched: boolean;
45
+ isFetchedAfterMount: boolean;
46
+ isPlaceholderData: boolean;
47
+ isPreviousData: boolean;
48
+ isRefetching: boolean;
49
+ isStale: boolean;
50
+ refetch: <TPageData>(options?: (import("react-query").RefetchOptions & import("react-query").RefetchQueryFilters<TPageData>) | undefined) => Promise<import("react-query").QueryObserverResult<import("ethers").Signer, Error>>;
51
+ remove: () => void;
52
+ } | {
53
+ isIdle: boolean;
54
+ isFetching: boolean;
55
+ isLoading: boolean;
56
+ status: string;
57
+ data: undefined;
58
+ error: null;
59
+ isError: false;
60
+ isLoadingError: false;
61
+ isRefetchError: false;
62
+ isSuccess: false;
63
+ dataUpdatedAt: number;
64
+ errorUpdatedAt: number;
65
+ failureCount: number;
66
+ isFetched: boolean;
67
+ isFetchedAfterMount: boolean;
68
+ isPlaceholderData: boolean;
69
+ isPreviousData: boolean;
70
+ isRefetching: boolean;
71
+ isStale: boolean;
72
+ refetch: <TPageData>(options?: (import("react-query").RefetchOptions & import("react-query").RefetchQueryFilters<TPageData>) | undefined) => Promise<import("react-query").QueryObserverResult<import("ethers").Signer, Error>>;
73
+ remove: () => void;
74
+ } | {
75
+ isIdle: boolean;
76
+ isFetching: boolean;
77
+ isLoading: boolean;
78
+ status: string;
79
+ data: import("ethers").Signer;
80
+ error: Error;
81
+ isError: true;
82
+ isLoadingError: false;
83
+ isRefetchError: true;
84
+ isSuccess: false;
85
+ dataUpdatedAt: number;
86
+ errorUpdatedAt: number;
87
+ failureCount: number;
88
+ isFetched: boolean;
89
+ isFetchedAfterMount: boolean;
90
+ isPlaceholderData: boolean;
91
+ isPreviousData: boolean;
92
+ isRefetching: boolean;
93
+ isStale: boolean;
94
+ refetch: <TPageData>(options?: (import("react-query").RefetchOptions & import("react-query").RefetchQueryFilters<TPageData>) | undefined) => Promise<import("react-query").QueryObserverResult<import("ethers").Signer, Error>>;
95
+ remove: () => void;
96
+ } | {
97
+ isIdle: boolean;
98
+ isFetching: boolean;
99
+ isLoading: boolean;
100
+ status: string;
101
+ data: import("ethers").Signer;
102
+ error: null;
103
+ isError: false;
104
+ isLoadingError: false;
105
+ isRefetchError: false;
106
+ isSuccess: true;
107
+ dataUpdatedAt: number;
108
+ errorUpdatedAt: number;
109
+ failureCount: number;
110
+ isFetched: boolean;
111
+ isFetchedAfterMount: boolean;
112
+ isPlaceholderData: boolean;
113
+ isPreviousData: boolean;
114
+ isRefetching: boolean;
115
+ isStale: boolean;
116
+ refetch: <TPageData>(options?: (import("react-query").RefetchOptions & import("react-query").RefetchQueryFilters<TPageData>) | undefined) => Promise<import("react-query").QueryObserverResult<import("ethers").Signer, Error>>;
117
+ remove: () => void;
5
118
  };
6
- declare type State = {
7
- data?: Signer;
8
- error?: Error;
9
- loading?: boolean;
10
- };
11
- export declare const useSigner: ({ skip }?: Config) => readonly [State, () => Promise<Signer | undefined>];
12
- export {};
@@ -1,5 +1,5 @@
1
1
  export { useContract } from './useContract';
2
2
  export { useContractEvent } from './useContractEvent';
3
3
  export { useContractRead } from './useContractRead';
4
- export { useContractWrite as useContractWrite } from './useContractWrite';
4
+ export { useContractWrite } from './useContractWrite';
5
5
  export { useToken } from './useToken';
@@ -1,11 +1,3 @@
1
- import { ContractInterface, Signer } from 'ethers';
2
- import { Provider } from '@ethersproject/providers';
3
- export declare type Config = {
4
- /** Contract address or ENS name */
5
- addressOrName: string;
6
- /** Contract interface or ABI */
7
- contractInterface: ContractInterface;
8
- /** Signer or provider to attach to contract */
9
- signerOrProvider?: Signer | Provider;
10
- };
11
- export declare const useContract: <Contract_1 = any>({ addressOrName, contractInterface, signerOrProvider, }: Config) => Contract_1;
1
+ import { GetContractArgs } from '@wagmi/core';
2
+ export declare type UseContractConfig = GetContractArgs;
3
+ export declare const useContract: <Contract = any>({ addressOrName, contractInterface, signerOrProvider, }: UseContractConfig) => Contract;
@@ -1,8 +1,7 @@
1
1
  import { ethers } from 'ethers';
2
- import { Config as UseContractConfig } from './useContract';
3
- declare type Config = {
2
+ import { UseContractConfig } from './useContract';
3
+ export declare type UseContractEventConfig = {
4
4
  /** Receive only a single event */
5
5
  once?: boolean;
6
6
  };
7
- export declare const useContractEvent: <Contract extends ethers.Contract = ethers.Contract>(contractConfig: UseContractConfig, eventName: Parameters<Contract["on"]>[0], listener: Parameters<Contract["on"]>[1], { once }?: Config) => void;
8
- export {};
7
+ export declare const useContractEvent: <Contract extends ethers.Contract = ethers.Contract>(contractConfig: UseContractConfig, eventName: Parameters<Contract["on"]>[0], listener: Parameters<Contract["on"]>[1], { once }?: UseContractEventConfig) => void;
@@ -1,26 +1,21 @@
1
- import { CallOverrides, ethers } from 'ethers';
2
- import { Config as UseContractConfig } from './useContract';
3
- declare type Config = {
4
- /** Arguments to pass contract method */
5
- args?: any | any[];
6
- overrides?: CallOverrides;
7
- /** Disables fetching */
8
- skip?: boolean;
1
+ import { ReadContractArgs, ReadContractConfig, ReadContractResult } from '@wagmi/core';
2
+ import { QueryConfig } from '../../types';
3
+ declare type UseContractReadArgs = Partial<ReadContractConfig> & {
9
4
  /** Subscribe to changes */
10
5
  watch?: boolean;
11
6
  };
12
- export declare const useContractRead: <Contract extends ethers.Contract = ethers.Contract>(contractConfig: UseContractConfig, functionName: string, { args, overrides, skip, watch }?: Config) => readonly [{
13
- readonly data: ethers.utils.Result | undefined;
14
- readonly error: Error | undefined;
15
- readonly loading: boolean | undefined;
16
- }, (config?: {
17
- args?: Config['args'];
18
- overrides?: Config['overrides'];
19
- } | undefined) => Promise<{
20
- data: ethers.utils.Result;
21
- error: undefined;
22
- } | {
23
- data: undefined;
24
- error: Error;
25
- }>];
7
+ export declare type UseContractReadConfig = QueryConfig<ReadContractResult, Error>;
8
+ export declare const queryKey: ([contractConfig, functionName, { args, overrides }, { blockNumber, chainId },]: [import("@wagmi/core").GetContractArgs, string, Partial<ReadContractConfig>, {
9
+ blockNumber?: number | undefined;
10
+ chainId?: number | undefined;
11
+ }]) => readonly [{
12
+ readonly entity: "readContract";
13
+ readonly args: any;
14
+ readonly blockNumber: number | undefined;
15
+ readonly chainId: number | undefined;
16
+ readonly contractConfig: import("@wagmi/core").GetContractArgs;
17
+ readonly functionName: string;
18
+ readonly overrides: import("ethers").CallOverrides | undefined;
19
+ }];
20
+ export declare function useContractRead(contractConfig: ReadContractArgs, functionName: string, { args, overrides, watch, cacheTime, enabled: enabled_, keepPreviousData, select, staleTime, suspense, onError, onSettled, onSuccess, }?: UseContractReadArgs & UseContractReadConfig): import("react-query").UseQueryResult<import("ethers/lib/utils").Result, Error>;
26
21
  export {};
@@ -1,22 +1,72 @@
1
- import { CallOverrides, ethers } from 'ethers';
2
- import { Config as UseContractConfig } from './useContract';
3
- declare type Config = {
4
- /** Arguments to pass contract method */
5
- args?: any | any[];
6
- overrides?: CallOverrides;
7
- };
8
- export declare const useContractWrite: <Contract extends ethers.Contract = ethers.Contract>(contractConfig: UseContractConfig, functionName: string, { args, overrides }?: Config) => readonly [{
9
- readonly data: ethers.providers.TransactionResponse | undefined;
10
- readonly error: Error | undefined;
11
- readonly loading: boolean | undefined;
12
- }, (config?: {
13
- args?: Config['args'];
14
- overrides?: Config['overrides'];
15
- } | undefined) => Promise<{
16
- data: ethers.providers.TransactionResponse;
17
- error: undefined;
1
+ import { WriteContractArgs, WriteContractConfig, WriteContractResult } from '@wagmi/core';
2
+ import { MutationConfig } from '../../types';
3
+ export declare type UseContractWriteArgs = Partial<WriteContractConfig>;
4
+ export declare type UseContractWriteConfig = MutationConfig<WriteContractResult, Error, UseContractWriteArgs>;
5
+ export declare const mutationKey: ([contractConfig, functionName, { args, overrides },]: [WriteContractArgs, string, Partial<WriteContractConfig>]) => readonly [{
6
+ readonly entity: "writeContract";
7
+ readonly args: any;
8
+ readonly contractConfig: import("@wagmi/core").GetContractArgs;
9
+ readonly functionName: string;
10
+ readonly overrides: import("ethers").CallOverrides | undefined;
11
+ }];
12
+ export declare function useContractWrite(contractConfig: WriteContractArgs, functionName: string, { args, overrides, onError, onMutate, onSettled, onSuccess, }?: UseContractWriteArgs & UseContractWriteConfig): {
13
+ write: (overrideConfig?: WriteContractConfig | undefined) => void;
14
+ writeAsync: (overrideConfig?: WriteContractConfig | undefined) => Promise<import("@ethersproject/abstract-provider").TransactionResponse>;
15
+ data: undefined;
16
+ error: null;
17
+ isError: false;
18
+ isIdle: true;
19
+ isLoading: false;
20
+ isSuccess: false;
21
+ status: "idle";
22
+ reset: () => void;
23
+ context: unknown;
24
+ failureCount: number;
25
+ isPaused: boolean;
26
+ variables: Partial<WriteContractConfig> | undefined;
27
+ } | {
28
+ write: (overrideConfig?: WriteContractConfig | undefined) => void;
29
+ writeAsync: (overrideConfig?: WriteContractConfig | undefined) => Promise<import("@ethersproject/abstract-provider").TransactionResponse>;
30
+ data: undefined;
31
+ error: null;
32
+ isError: false;
33
+ isIdle: false;
34
+ isLoading: true;
35
+ isSuccess: false;
36
+ status: "loading";
37
+ reset: () => void;
38
+ context: unknown;
39
+ failureCount: number;
40
+ isPaused: boolean;
41
+ variables: Partial<WriteContractConfig> | undefined;
18
42
  } | {
43
+ write: (overrideConfig?: WriteContractConfig | undefined) => void;
44
+ writeAsync: (overrideConfig?: WriteContractConfig | undefined) => Promise<import("@ethersproject/abstract-provider").TransactionResponse>;
19
45
  data: undefined;
20
46
  error: Error;
21
- }>];
22
- export {};
47
+ isError: true;
48
+ isIdle: false;
49
+ isLoading: false;
50
+ isSuccess: false;
51
+ status: "error";
52
+ reset: () => void;
53
+ context: unknown;
54
+ failureCount: number;
55
+ isPaused: boolean;
56
+ variables: Partial<WriteContractConfig> | undefined;
57
+ } | {
58
+ write: (overrideConfig?: WriteContractConfig | undefined) => void;
59
+ writeAsync: (overrideConfig?: WriteContractConfig | undefined) => Promise<import("@ethersproject/abstract-provider").TransactionResponse>;
60
+ data: import("@ethersproject/abstract-provider").TransactionResponse;
61
+ error: null;
62
+ isError: false;
63
+ isIdle: false;
64
+ isLoading: false;
65
+ isSuccess: true;
66
+ status: "success";
67
+ reset: () => void;
68
+ context: unknown;
69
+ failureCount: number;
70
+ isPaused: boolean;
71
+ variables: Partial<WriteContractConfig> | undefined;
72
+ };
@@ -1,42 +1,13 @@
1
- import { BigNumber } from 'ethers';
2
- import { Unit } from 'wagmi-core';
3
- export declare type Config = {
4
- address?: string;
5
- formatUnits?: Unit | number;
6
- skip?: boolean;
7
- };
8
- export declare const useToken: ({ address, formatUnits, skip, }?: Config) => readonly [{
9
- readonly data: {
10
- address: string | undefined;
11
- decimals: number;
12
- symbol: string;
13
- totalSupply: {
14
- formatted: string;
15
- value: BigNumber;
16
- };
17
- } | undefined;
18
- readonly error: Error | undefined;
19
- readonly loading: boolean | undefined;
20
- }, (token: {
21
- address: string;
22
- decimals?: number | undefined;
23
- image?: string | undefined;
24
- symbol: string;
25
- }) => Promise<boolean | Error>, (config?: {
26
- address: string;
27
- formatUnits?: Config['formatUnits'];
28
- } | undefined) => Promise<{
29
- data: {
30
- address: string;
31
- decimals: any;
32
- symbol: any;
33
- totalSupply: {
34
- formatted: string;
35
- value: any;
36
- };
37
- };
38
- error: undefined;
39
- } | {
40
- data: undefined;
41
- error: Error;
42
- }>];
1
+ import { FetchTokenArgs, FetchTokenResult } from '@wagmi/core';
2
+ import { QueryConfig } from '../../types';
3
+ export declare type UseTokenArgs = Partial<FetchTokenArgs>;
4
+ export declare type UseTokenConfig = QueryConfig<FetchTokenResult, Error>;
5
+ export declare const queryKey: ({ address, chainId, formatUnits, }: Partial<FetchTokenArgs> & {
6
+ chainId?: number | undefined;
7
+ }) => readonly [{
8
+ readonly entity: "token";
9
+ readonly address: string | undefined;
10
+ readonly chainId: number | undefined;
11
+ readonly formatUnits: number | "wei" | "kwei" | "mwei" | "gwei" | "szabo" | "finney" | "ether" | undefined;
12
+ }];
13
+ export declare function useToken({ address, formatUnits, cacheTime, enabled, keepPreviousData, select, staleTime, suspense, onError, onSettled, onSuccess, }?: UseTokenArgs & UseTokenConfig): import("react-query").UseQueryResult<FetchTokenResult, Error>;
@@ -1,4 +1,4 @@
1
+ export { useEnsAddress } from './useEnsAddress';
1
2
  export { useEnsAvatar } from './useEnsAvatar';
2
- export { useEnsLookup } from './useEnsLookup';
3
- export { useEnsResolveName } from './useEnsResolveName';
3
+ export { useEnsName } from './useEnsName';
4
4
  export { useEnsResolver } from './useEnsResolver';
@@ -0,0 +1,17 @@
1
+ import { FetchEnsAddressResult } from '@wagmi/core';
2
+ import { QueryConfig } from '../../types';
3
+ export declare type UseEnsAddressArgs = {
4
+ /** ENS name */
5
+ name?: string;
6
+ };
7
+ export declare type UseEnsAddressConfig = QueryConfig<FetchEnsAddressResult, Error>;
8
+ export declare const queryKey: ({ chainId, name, }: {
9
+ chainId?: number | undefined;
10
+ name?: string | undefined;
11
+ }) => readonly [{
12
+ readonly entity: "ensAddress";
13
+ readonly chainId: number | undefined;
14
+ readonly name: string | undefined;
15
+ }];
16
+ export declare function useEnsAddress({ name, cacheTime, enabled, keepPreviousData, select, staleTime, // 24 hours
17
+ suspense, onError, onSettled, onSuccess, }?: UseEnsAddressArgs & UseEnsAddressConfig): import("react-query").UseQueryResult<FetchEnsAddressResult, Error>;
@@ -1,14 +1,17 @@
1
- declare type Config = {
1
+ import { FetchEnsAvatarResult } from '@wagmi/core';
2
+ import { QueryConfig } from '../../types';
3
+ export declare type UseEnsAvatarArgs = {
2
4
  /** Address or ENS name */
3
- addressOrName?: string | null;
4
- /** Disables fetching */
5
- skip?: boolean;
5
+ addressOrName?: string;
6
6
  };
7
- export declare const useEnsAvatar: ({ addressOrName, skip }?: Config) => readonly [{
8
- readonly data: string | null | undefined;
9
- readonly loading: boolean;
10
- readonly error: Error | undefined;
11
- }, (config?: {
12
- addressOrName: string;
13
- } | undefined) => Promise<string | Error | null>];
14
- export {};
7
+ export declare type UseEnsLookupConfig = QueryConfig<FetchEnsAvatarResult, Error>;
8
+ export declare const queryKey: ({ addressOrName, chainId, }: {
9
+ addressOrName?: UseEnsAvatarArgs['addressOrName'];
10
+ chainId?: number | undefined;
11
+ }) => readonly [{
12
+ readonly entity: "ensAvatar";
13
+ readonly addressOrName: string | undefined;
14
+ readonly chainId: number | undefined;
15
+ }];
16
+ export declare function useEnsAvatar({ addressOrName, cacheTime, enabled, keepPreviousData, select, staleTime, // 24 hours
17
+ suspense, onError, onSettled, onSuccess, }?: UseEnsAvatarArgs & UseEnsLookupConfig): import("react-query").UseQueryResult<FetchEnsAvatarResult, Error>;
@@ -0,0 +1,17 @@
1
+ import { FetchEnsNameResult } from '@wagmi/core';
2
+ import { QueryConfig } from '../../types';
3
+ export declare type UseEnsNameArgs = {
4
+ /** Address */
5
+ address?: string;
6
+ };
7
+ export declare type UseEnsNameConfig = QueryConfig<FetchEnsNameResult, Error>;
8
+ export declare const queryKey: ({ address, chainId, }: {
9
+ address?: string | undefined;
10
+ chainId?: number | undefined;
11
+ }) => readonly [{
12
+ readonly entity: "ensName";
13
+ readonly address: string | undefined;
14
+ readonly chainId: number | undefined;
15
+ }];
16
+ export declare function useEnsName({ address, cacheTime, enabled, keepPreviousData, select, staleTime, // 24 hours
17
+ suspense, onError, onSettled, onSuccess, }?: UseEnsNameArgs & UseEnsNameConfig): import("react-query").UseQueryResult<FetchEnsNameResult, Error>;