wagmi 0.6.7 → 0.7.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/actions/dist/wagmi-actions.cjs.dev.js +8 -0
- package/actions/dist/wagmi-actions.cjs.prod.js +8 -0
- package/actions/dist/wagmi-actions.esm.js +1 -1
- package/dist/declarations/src/actions.d.ts +2 -2
- package/dist/declarations/src/context.d.ts +2 -0
- package/dist/declarations/src/hooks/accounts/useBalance.d.ts +2 -6
- package/dist/declarations/src/hooks/accounts/useConnect.d.ts +2 -2
- package/dist/declarations/src/hooks/accounts/useSignMessage.d.ts +4 -4
- package/dist/declarations/src/hooks/accounts/useSignTypedData.d.ts +8 -21
- package/dist/declarations/src/hooks/accounts/useSigner.d.ts +6 -8
- package/dist/declarations/src/hooks/accounts/useSwitchNetwork.d.ts +2 -2
- package/dist/declarations/src/hooks/contracts/index.d.ts +0 -1
- package/dist/declarations/src/hooks/contracts/useContract.d.ts +7 -3
- package/dist/declarations/src/hooks/contracts/useContractEvent.d.ts +34 -9
- package/dist/declarations/src/hooks/contracts/useContractInfiniteReads.d.ts +531 -17
- package/dist/declarations/src/hooks/contracts/useContractRead.d.ts +11 -19
- package/dist/declarations/src/hooks/contracts/useContractReads.d.ts +122 -22
- package/dist/declarations/src/hooks/contracts/useContractWrite.d.ts +19 -45
- package/dist/declarations/src/hooks/contracts/usePrepareContractWrite.d.ts +13 -19
- package/dist/declarations/src/hooks/contracts/useToken.d.ts +2 -6
- package/dist/declarations/src/hooks/ens/useEnsAddress.d.ts +1 -5
- package/dist/declarations/src/hooks/ens/useEnsAvatar.d.ts +1 -5
- package/dist/declarations/src/hooks/ens/useEnsName.d.ts +3 -10
- package/dist/declarations/src/hooks/ens/useEnsResolver.d.ts +1 -5
- package/dist/declarations/src/hooks/index.d.ts +3 -3
- package/dist/declarations/src/hooks/network-status/useBlockNumber.d.ts +1 -6
- package/dist/declarations/src/hooks/network-status/useFeeData.d.ts +1 -5
- package/dist/declarations/src/hooks/transactions/index.d.ts +0 -1
- package/dist/declarations/src/hooks/transactions/usePrepareSendTransaction.d.ts +4 -18
- package/dist/declarations/src/hooks/transactions/useTransaction.d.ts +1 -5
- package/dist/declarations/src/hooks/transactions/useWaitForTransaction.d.ts +2 -6
- package/dist/declarations/src/hooks/utils/index.d.ts +1 -1
- package/dist/declarations/src/hooks/utils/query/index.d.ts +2 -0
- package/dist/declarations/src/hooks/utils/query/useBaseQuery.d.ts +14 -10
- package/dist/declarations/src/hooks/utils/query/useMutation.d.ts +5 -0
- package/dist/declarations/src/hooks/utils/query/useQuery.d.ts +2 -3
- package/dist/declarations/src/hooks/utils/query/useQueryClient.d.ts +1 -0
- package/dist/declarations/src/index.d.ts +2 -1
- package/dist/declarations/src/types/index.d.ts +20 -0
- package/dist/wagmi.cjs.dev.js +677 -742
- package/dist/wagmi.cjs.prod.js +677 -742
- package/dist/wagmi.esm.js +671 -736
- package/package.json +8 -7
- package/dist/declarations/src/hooks/contracts/useDeprecatedContractWrite.d.ts +0 -27
- package/dist/declarations/src/hooks/transactions/useDeprecatedSendTransaction.d.ts +0 -23
- package/providers/coinbaseNode/dist/wagmi-providers-coinbaseNode.cjs.d.ts +0 -11
- package/providers/coinbaseNode/dist/wagmi-providers-coinbaseNode.cjs.js +0 -16
|
@@ -74,6 +74,10 @@ Object.defineProperty(exports, 'getWebSocketProvider', {
|
|
|
74
74
|
enumerable: true,
|
|
75
75
|
get: function () { return core.getWebSocketProvider; }
|
|
76
76
|
});
|
|
77
|
+
Object.defineProperty(exports, 'multicall', {
|
|
78
|
+
enumerable: true,
|
|
79
|
+
get: function () { return core.multicall; }
|
|
80
|
+
});
|
|
77
81
|
Object.defineProperty(exports, 'prepareSendTransaction', {
|
|
78
82
|
enumerable: true,
|
|
79
83
|
get: function () { return core.prepareSendTransaction; }
|
|
@@ -122,6 +126,10 @@ Object.defineProperty(exports, 'watchContractEvent', {
|
|
|
122
126
|
enumerable: true,
|
|
123
127
|
get: function () { return core.watchContractEvent; }
|
|
124
128
|
});
|
|
129
|
+
Object.defineProperty(exports, 'watchMulticall', {
|
|
130
|
+
enumerable: true,
|
|
131
|
+
get: function () { return core.watchMulticall; }
|
|
132
|
+
});
|
|
125
133
|
Object.defineProperty(exports, 'watchNetwork', {
|
|
126
134
|
enumerable: true,
|
|
127
135
|
get: function () { return core.watchNetwork; }
|
|
@@ -74,6 +74,10 @@ Object.defineProperty(exports, 'getWebSocketProvider', {
|
|
|
74
74
|
enumerable: true,
|
|
75
75
|
get: function () { return core.getWebSocketProvider; }
|
|
76
76
|
});
|
|
77
|
+
Object.defineProperty(exports, 'multicall', {
|
|
78
|
+
enumerable: true,
|
|
79
|
+
get: function () { return core.multicall; }
|
|
80
|
+
});
|
|
77
81
|
Object.defineProperty(exports, 'prepareSendTransaction', {
|
|
78
82
|
enumerable: true,
|
|
79
83
|
get: function () { return core.prepareSendTransaction; }
|
|
@@ -122,6 +126,10 @@ Object.defineProperty(exports, 'watchContractEvent', {
|
|
|
122
126
|
enumerable: true,
|
|
123
127
|
get: function () { return core.watchContractEvent; }
|
|
124
128
|
});
|
|
129
|
+
Object.defineProperty(exports, 'watchMulticall', {
|
|
130
|
+
enumerable: true,
|
|
131
|
+
get: function () { return core.watchMulticall; }
|
|
132
|
+
});
|
|
125
133
|
Object.defineProperty(exports, 'watchNetwork', {
|
|
126
134
|
enumerable: true,
|
|
127
135
|
get: function () { return core.watchNetwork; }
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { connect, disconnect, fetchBalance, fetchBlockNumber, fetchEnsAddress, fetchEnsAvatar, fetchEnsName, fetchEnsResolver, fetchFeeData, fetchSigner, fetchToken, fetchTransaction, getAccount, getContract, getNetwork, getProvider, getWebSocketProvider, prepareSendTransaction, prepareWriteContract, readContract, readContracts, sendTransaction, signMessage, signTypedData, switchNetwork, waitForTransaction, watchAccount, watchBlockNumber, watchContractEvent, watchNetwork, watchProvider, watchReadContract, watchReadContracts, watchSigner, watchWebSocketProvider, writeContract } from '@wagmi/core';
|
|
1
|
+
export { connect, disconnect, fetchBalance, fetchBlockNumber, fetchEnsAddress, fetchEnsAvatar, fetchEnsName, fetchEnsResolver, fetchFeeData, fetchSigner, fetchToken, fetchTransaction, getAccount, getContract, getNetwork, getProvider, getWebSocketProvider, multicall, prepareSendTransaction, prepareWriteContract, readContract, readContracts, sendTransaction, signMessage, signTypedData, switchNetwork, waitForTransaction, watchAccount, watchBlockNumber, watchContractEvent, watchMulticall, watchNetwork, watchProvider, watchReadContract, watchReadContracts, watchSigner, watchWebSocketProvider, writeContract } from '@wagmi/core';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { connect, disconnect, fetchBalance, fetchBlockNumber, fetchEnsAddress, fetchEnsAvatar, fetchEnsName, fetchEnsResolver, fetchFeeData, fetchSigner, fetchToken, fetchTransaction, getAccount, getContract, getNetwork, getProvider, getWebSocketProvider, prepareSendTransaction, prepareWriteContract, readContract, readContracts, sendTransaction, signMessage, signTypedData, switchNetwork, waitForTransaction, watchAccount, watchBlockNumber, watchContractEvent, watchNetwork, watchProvider, watchReadContract, watchReadContracts, watchSigner, watchWebSocketProvider, writeContract, } from '@wagmi/core';
|
|
2
|
-
export type { ConnectArgs, ConnectResult, FetchBalanceArgs, FetchBalanceResult, FetchBlockNumberArgs, FetchBlockNumberResult, FetchEnsAddressArgs, FetchEnsAddressResult, FetchEnsAvatarArgs, FetchEnsAvatarResult, FetchEnsNameArgs, FetchEnsNameResult, FetchEnsResolverArgs, FetchEnsResolverResult, FetchFeeDataArgs, FetchFeeDataResult, FetchSignerResult, FetchTokenArgs, FetchTokenResult, FetchTransactionArgs, FetchTransactionResult, GetAccountResult, GetContractArgs, GetNetworkResult, GetProviderArgs, GetProviderResult, GetWebSocketProviderArgs, GetWebSocketProviderResult, ReadContractConfig, ReadContractResult, ReadContractsConfig, ReadContractsResult, SendTransactionArgs, SendTransactionPreparedRequest, SendTransactionResult, SendTransactionUnpreparedRequest, SignMessageArgs, SignMessageResult, SignTypedDataArgs, SignTypedDataResult, SwitchNetworkArgs, SwitchNetworkResult, WaitForTransactionArgs, WaitForTransactionResult, WatchAccountCallback, WatchBlockNumberArgs, WatchBlockNumberCallback, WatchNetworkCallback, WatchReadContractConfig,
|
|
1
|
+
export { connect, disconnect, fetchBalance, fetchBlockNumber, fetchEnsAddress, fetchEnsAvatar, fetchEnsName, fetchEnsResolver, fetchFeeData, fetchSigner, fetchToken, fetchTransaction, getAccount, getContract, getNetwork, getProvider, getWebSocketProvider, multicall, prepareSendTransaction, prepareWriteContract, readContract, readContracts, sendTransaction, signMessage, signTypedData, switchNetwork, waitForTransaction, watchAccount, watchBlockNumber, watchContractEvent, watchMulticall, watchNetwork, watchProvider, watchReadContract, watchReadContracts, watchSigner, watchWebSocketProvider, writeContract, } from '@wagmi/core';
|
|
2
|
+
export type { ConnectArgs, ConnectResult, FetchBalanceArgs, FetchBalanceResult, FetchBlockNumberArgs, FetchBlockNumberResult, FetchEnsAddressArgs, FetchEnsAddressResult, FetchEnsAvatarArgs, FetchEnsAvatarResult, FetchEnsNameArgs, FetchEnsNameResult, FetchEnsResolverArgs, FetchEnsResolverResult, FetchFeeDataArgs, FetchFeeDataResult, FetchSignerResult, FetchTokenArgs, FetchTokenResult, FetchTransactionArgs, FetchTransactionResult, GetAccountResult, GetContractArgs, GetContractResult, GetNetworkResult, GetProviderArgs, GetProviderResult, GetWebSocketProviderArgs, GetWebSocketProviderResult, MulticallConfig, MulticallResult, ReadContractConfig, ReadContractResult, ReadContractsConfig, ReadContractsResult, SendTransactionArgs, SendTransactionPreparedRequest, SendTransactionResult, SendTransactionUnpreparedRequest, SignMessageArgs, SignMessageResult, SignTypedDataArgs, SignTypedDataResult, SwitchNetworkArgs, SwitchNetworkResult, WaitForTransactionArgs, WaitForTransactionResult, WatchAccountCallback, WatchBlockNumberArgs, WatchBlockNumberCallback, WatchMulticallConfig, WatchMulticallCallback, WatchNetworkCallback, WatchReadContractConfig, WatchReadContractCallback, WatchReadContractsConfig, WatchReadContractsCallback, WatchProviderCallback, WatchSignerCallback, WatchWebSocketProviderCallback, WriteContractArgs, WriteContractPreparedArgs, WriteContractResult, WriteContractUnpreparedArgs, } from '@wagmi/core';
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
import { QueryClient } from '@tanstack/react-query';
|
|
1
2
|
import { Provider, WebSocketProvider } from '@wagmi/core';
|
|
2
3
|
import * as React from 'react';
|
|
3
4
|
import { Client } from './client';
|
|
4
5
|
export declare const Context: React.Context<Client<Provider, WebSocketProvider> | undefined>;
|
|
6
|
+
export declare const queryClientContext: React.Context<QueryClient | undefined>;
|
|
5
7
|
export declare type WagmiConfigProps<TProvider extends Provider = Provider, TWebSocketProvider extends WebSocketProvider = WebSocketProvider> = {
|
|
6
8
|
/** React-decorated Client instance */
|
|
7
9
|
client: Client<TProvider, TWebSocketProvider>;
|
|
@@ -12,10 +12,6 @@ export declare const queryKey: ({ addressOrName, chainId, formatUnits, token, }:
|
|
|
12
12
|
readonly addressOrName: string | undefined;
|
|
13
13
|
readonly chainId: number | undefined;
|
|
14
14
|
readonly formatUnits: number | "wei" | "kwei" | "mwei" | "gwei" | "szabo" | "finney" | "ether" | undefined;
|
|
15
|
-
readonly token: string | undefined;
|
|
15
|
+
readonly token: `0x${string}` | undefined;
|
|
16
16
|
}];
|
|
17
|
-
export declare function useBalance({ addressOrName, cacheTime, chainId: chainId_, enabled, formatUnits, staleTime, suspense, token, watch, onError, onSettled, onSuccess, }?: UseBalanceArgs & UseBalanceConfig):
|
|
18
|
-
isIdle: boolean;
|
|
19
|
-
status: "error" | "success" | "idle" | "loading";
|
|
20
|
-
internal: Pick<import("@tanstack/react-query").QueryObserverResult<unknown, unknown>, "dataUpdatedAt" | "errorUpdatedAt" | "failureCount" | "isFetchedAfterMount" | "isLoadingError" | "isPaused" | "isPlaceholderData" | "isPreviousData" | "isRefetchError" | "isStale" | "remove">;
|
|
21
|
-
};
|
|
17
|
+
export declare function useBalance({ addressOrName, cacheTime, chainId: chainId_, enabled, formatUnits, staleTime, suspense, token, watch, onError, onSettled, onSuccess, }?: UseBalanceArgs & UseBalanceConfig): import("../utils/query/useQuery").UseQueryResult<FetchBalanceResult, Error>;
|
|
@@ -8,8 +8,8 @@ export declare const mutationKey: (args: UseConnectArgs) => readonly [{
|
|
|
8
8
|
readonly entity: "connect";
|
|
9
9
|
}];
|
|
10
10
|
export declare function useConnect({ chainId, connector, onError, onMutate, onSettled, onSuccess, }?: UseConnectArgs & UseConnectConfig): {
|
|
11
|
-
readonly connect: (args?: Partial<ConnectArgs>
|
|
12
|
-
readonly connectAsync: (args?: Partial<ConnectArgs>
|
|
11
|
+
readonly connect: (args?: Partial<ConnectArgs>) => void;
|
|
12
|
+
readonly connectAsync: (args?: Partial<ConnectArgs>) => Promise<ConnectResult<import("@wagmi/core").Provider>>;
|
|
13
13
|
readonly connectors: import("@wagmi/core").Connector<any, any, any>[];
|
|
14
14
|
readonly data: ConnectResult<import("@wagmi/core").Provider> | undefined;
|
|
15
15
|
readonly error: Error | null;
|
|
@@ -3,19 +3,19 @@ import { MutationConfig } from '../../types';
|
|
|
3
3
|
export declare type UseSignMessageArgs = Partial<SignMessageArgs>;
|
|
4
4
|
export declare type UseSignMessageConfig = MutationConfig<SignMessageResult, Error, SignMessageArgs>;
|
|
5
5
|
export declare const mutationKey: (args: UseSignMessageArgs) => readonly [{
|
|
6
|
-
readonly message?: string |
|
|
6
|
+
readonly message?: string | Uint8Array | undefined;
|
|
7
7
|
readonly entity: "signMessage";
|
|
8
8
|
}];
|
|
9
9
|
export declare function useSignMessage({ message, onError, onMutate, onSettled, onSuccess, }?: UseSignMessageArgs & UseSignMessageConfig): {
|
|
10
|
-
data: string | undefined;
|
|
10
|
+
data: `0x${string}` | undefined;
|
|
11
11
|
error: Error | null;
|
|
12
12
|
isError: boolean;
|
|
13
13
|
isIdle: boolean;
|
|
14
14
|
isLoading: boolean;
|
|
15
15
|
isSuccess: boolean;
|
|
16
16
|
reset: () => void;
|
|
17
|
-
signMessage: (args?: SignMessageArgs
|
|
18
|
-
signMessageAsync: (args?: SignMessageArgs
|
|
17
|
+
signMessage: (args?: SignMessageArgs) => void;
|
|
18
|
+
signMessageAsync: (args?: SignMessageArgs) => Promise<`0x${string}`>;
|
|
19
19
|
status: "error" | "success" | "idle" | "loading";
|
|
20
20
|
variables: SignMessageArgs | undefined;
|
|
21
21
|
};
|
|
@@ -1,23 +1,10 @@
|
|
|
1
1
|
import { SignTypedDataArgs, SignTypedDataResult } from '@wagmi/core';
|
|
2
|
+
import { Optional } from '@wagmi/core/internal';
|
|
3
|
+
import { TypedData } from 'abitype';
|
|
2
4
|
import { MutationConfig } from '../../types';
|
|
3
|
-
export declare type UseSignTypedDataArgs =
|
|
4
|
-
export declare type UseSignTypedDataConfig = MutationConfig<SignTypedDataResult, Error, SignTypedDataArgs>;
|
|
5
|
-
export declare
|
|
6
|
-
readonly domain?: {
|
|
7
|
-
name?: string | undefined;
|
|
8
|
-
version?: string | undefined;
|
|
9
|
-
chainId?: string | number | bigint | undefined;
|
|
10
|
-
verifyingContract?: string | undefined;
|
|
11
|
-
salt?: import("ethers").BytesLike | undefined;
|
|
12
|
-
} | undefined;
|
|
13
|
-
readonly types?: Record<string, {
|
|
14
|
-
name: string;
|
|
15
|
-
type: string;
|
|
16
|
-
}[]> | undefined;
|
|
17
|
-
readonly value?: Record<string, any> | undefined;
|
|
18
|
-
readonly entity: "signTypedData";
|
|
19
|
-
}];
|
|
20
|
-
export declare function useSignTypedData({ domain, types, value, onError, onMutate, onSettled, onSuccess, }?: UseSignTypedDataArgs & UseSignTypedDataConfig): {
|
|
5
|
+
export declare type UseSignTypedDataArgs<TTypedData = unknown> = Optional<SignTypedDataArgs<TTypedData>, 'domain' | 'types' | 'value'>;
|
|
6
|
+
export declare type UseSignTypedDataConfig<TTypedData = unknown> = MutationConfig<SignTypedDataResult, Error, SignTypedDataArgs<TTypedData>> & UseSignTypedDataArgs<TTypedData>;
|
|
7
|
+
export declare function useSignTypedData<TTypedData extends TypedData>({ domain, types, value, onError, onMutate, onSettled, onSuccess, }?: UseSignTypedDataConfig<TTypedData>): {
|
|
21
8
|
data: string | undefined;
|
|
22
9
|
error: Error | null;
|
|
23
10
|
isError: boolean;
|
|
@@ -25,8 +12,8 @@ export declare function useSignTypedData({ domain, types, value, onError, onMuta
|
|
|
25
12
|
isLoading: boolean;
|
|
26
13
|
isSuccess: boolean;
|
|
27
14
|
reset: () => void;
|
|
28
|
-
signTypedData: (args?:
|
|
29
|
-
signTypedDataAsync: (args?:
|
|
15
|
+
signTypedData: <TTypedDataMutate extends TypedData = TTypedData>(args?: UseSignTypedDataArgs<TTypedDataMutate> | undefined) => void;
|
|
16
|
+
signTypedDataAsync: <TTypedDataMutate_1 extends TypedData = TTypedData>(args?: UseSignTypedDataArgs<TTypedDataMutate_1> | undefined) => Promise<string>;
|
|
30
17
|
status: "error" | "success" | "idle" | "loading";
|
|
31
|
-
variables: SignTypedDataArgs | undefined;
|
|
18
|
+
variables: SignTypedDataArgs<TTypedData> | undefined;
|
|
32
19
|
};
|
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
import { FetchSignerResult, Signer } from '@wagmi/core';
|
|
1
|
+
import { FetchSignerArgs, FetchSignerResult, Signer } from '@wagmi/core';
|
|
2
2
|
import { QueryConfig } from '../../types';
|
|
3
|
-
export declare type UseSignerConfig = Omit<QueryConfig<FetchSignerResult, Error>, 'cacheTime' | 'staleTime' | 'enabled'
|
|
4
|
-
export declare const queryKey: () => readonly [{
|
|
3
|
+
export declare type UseSignerConfig = Omit<QueryConfig<FetchSignerResult, Error>, 'cacheTime' | 'staleTime' | 'enabled'> & FetchSignerArgs;
|
|
4
|
+
export declare const queryKey: ({ chainId }: FetchSignerArgs) => readonly [{
|
|
5
5
|
readonly entity: "signer";
|
|
6
|
+
readonly chainId: number | undefined;
|
|
7
|
+
readonly persist: false;
|
|
6
8
|
}];
|
|
7
|
-
export declare function useSigner<TSigner extends Signer>({ suspense, onError, onSettled, onSuccess, }?: UseSignerConfig):
|
|
8
|
-
isIdle: boolean;
|
|
9
|
-
status: "error" | "success" | "idle" | "loading";
|
|
10
|
-
internal: Pick<import("@tanstack/react-query").QueryObserverResult<unknown, unknown>, "dataUpdatedAt" | "errorUpdatedAt" | "failureCount" | "isFetchedAfterMount" | "isLoadingError" | "isPaused" | "isPlaceholderData" | "isPreviousData" | "isRefetchError" | "isStale" | "remove">;
|
|
11
|
-
};
|
|
9
|
+
export declare function useSigner<TSigner extends Signer>({ chainId: chainId_, suspense, onError, onSettled, onSuccess, }?: UseSignerConfig): import("../utils/query/useQuery").UseQueryResult<FetchSignerResult<TSigner>, Error>;
|
|
@@ -19,7 +19,7 @@ export declare function useSwitchNetwork({ chainId, throwForSwitchChainNotSuppor
|
|
|
19
19
|
readonly pendingChainId: number | undefined;
|
|
20
20
|
readonly reset: () => void;
|
|
21
21
|
readonly status: "error" | "success" | "idle" | "loading";
|
|
22
|
-
readonly switchNetwork: ((chainId_?:
|
|
23
|
-
readonly switchNetworkAsync: ((chainId_?:
|
|
22
|
+
readonly switchNetwork: ((chainId_?: SwitchNetworkArgs['chainId']) => void) | undefined;
|
|
23
|
+
readonly switchNetworkAsync: ((chainId_?: SwitchNetworkArgs['chainId']) => Promise<import("@wagmi/core").Chain>) | undefined;
|
|
24
24
|
readonly variables: SwitchNetworkArgs | undefined;
|
|
25
25
|
};
|
|
@@ -4,6 +4,5 @@ export { useContractInfiniteReads, paginatedIndexesConfig, } from './useContract
|
|
|
4
4
|
export { useContractRead } from './useContractRead';
|
|
5
5
|
export { useContractReads } from './useContractReads';
|
|
6
6
|
export { useContractWrite } from './useContractWrite';
|
|
7
|
-
export { useDeprecatedContractWrite } from './useDeprecatedContractWrite';
|
|
8
7
|
export { usePrepareContractWrite } from './usePrepareContractWrite';
|
|
9
8
|
export { useToken } from './useToken';
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
-
import { GetContractArgs } from '@wagmi/core';
|
|
2
|
-
|
|
3
|
-
export declare
|
|
1
|
+
import { GetContractArgs, GetContractResult } from '@wagmi/core';
|
|
2
|
+
import { Abi } from 'abitype';
|
|
3
|
+
export declare type UseContractConfig<TAbi extends Abi | readonly unknown[] = Abi> = Partial<Pick<GetContractArgs<TAbi>, 'abi' | 'address'>> & {
|
|
4
|
+
/** Signer or provider to attach to contract */
|
|
5
|
+
signerOrProvider?: GetContractArgs['signerOrProvider'] | null;
|
|
6
|
+
};
|
|
7
|
+
export declare function useContract<TAbi extends Abi | readonly unknown[]>({ address, abi, signerOrProvider, }?: UseContractConfig<TAbi>): GetContractResult<TAbi> | null;
|
|
@@ -1,13 +1,38 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import { AbiEventParametersToPrimitiveTypes, Event, IsNever, NotEqual, Or } from '@wagmi/core/internal';
|
|
2
|
+
import { Abi, AbiEvent, ExtractAbiEvent, ExtractAbiEventNames, Narrow } from 'abitype';
|
|
3
|
+
declare type GetListener<TAbiEvent extends AbiEvent, TAbi = unknown> = AbiEventParametersToPrimitiveTypes<TAbiEvent['inputs']> extends infer TArgs extends readonly unknown[] ? Or<IsNever<TArgs>, NotEqual<TAbi, Abi>> extends true ? {
|
|
4
|
+
/**
|
|
5
|
+
* Callback when event is emitted
|
|
6
|
+
*
|
|
7
|
+
* Use a [const assertion](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-4.html#const-assertions) on {@link abi} for type inference.
|
|
8
|
+
*/
|
|
9
|
+
listener: (...args: any) => void;
|
|
10
|
+
} : {
|
|
11
|
+
/** Callback when event is emitted */
|
|
12
|
+
listener: (...args: [...args: TArgs, event: Event<TAbiEvent>]) => void;
|
|
13
|
+
} : never;
|
|
14
|
+
declare type ContractEventConfig<TAbi extends Abi | readonly unknown[] = Abi, TEventName extends string = string, TEvent extends AbiEvent = TAbi extends Abi ? ExtractAbiEvent<TAbi, TEventName> : never> = {
|
|
15
|
+
/** Contract address */
|
|
16
|
+
address?: string;
|
|
17
|
+
/** Contract ABI */
|
|
18
|
+
abi?: Narrow<TAbi>;
|
|
8
19
|
/** Chain id to use for provider */
|
|
9
20
|
chainId?: number;
|
|
21
|
+
/** Event to listen for */
|
|
22
|
+
eventName?: IsNever<TEventName> extends true ? string : TEventName;
|
|
10
23
|
/** Receive only a single event */
|
|
11
24
|
once?: boolean;
|
|
12
|
-
}
|
|
13
|
-
|
|
25
|
+
} & GetListener<TEvent, TAbi>;
|
|
26
|
+
declare type GetConfig<T> = T extends {
|
|
27
|
+
abi: infer TAbi extends Abi;
|
|
28
|
+
eventName: infer TEventName extends string;
|
|
29
|
+
} ? ContractEventConfig<TAbi, ExtractAbiEventNames<TAbi>, ExtractAbiEvent<TAbi, TEventName>> : T extends {
|
|
30
|
+
abi: infer TAbi extends readonly unknown[];
|
|
31
|
+
eventName: infer TEventName extends string;
|
|
32
|
+
} ? ContractEventConfig<TAbi, TEventName> : ContractEventConfig;
|
|
33
|
+
export declare type UseContractEventConfig<TAbi = Abi, TEventName = string> = GetConfig<{
|
|
34
|
+
abi: TAbi;
|
|
35
|
+
eventName: TEventName;
|
|
36
|
+
}>;
|
|
37
|
+
export declare function useContractEvent<TAbi extends Abi | readonly unknown[], TEventName extends string>({ address, chainId, abi, listener, eventName, once, }?: UseContractEventConfig<TAbi, TEventName>): void;
|
|
38
|
+
export {};
|