wagmi 0.2.24 → 0.3.0-next.10
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 +54 -35
- package/connectors/coinbaseWallet/dist/wagmi-connectors-coinbaseWallet.cjs.d.ts +1 -0
- package/connectors/coinbaseWallet/dist/wagmi-connectors-coinbaseWallet.cjs.dev.js +12 -0
- package/connectors/coinbaseWallet/dist/wagmi-connectors-coinbaseWallet.cjs.js +7 -0
- package/connectors/coinbaseWallet/dist/wagmi-connectors-coinbaseWallet.cjs.prod.js +12 -0
- package/connectors/coinbaseWallet/dist/wagmi-connectors-coinbaseWallet.esm.js +1 -0
- package/connectors/coinbaseWallet/package.json +4 -0
- package/connectors/injected/dist/wagmi-connectors-injected.cjs.dev.js +2 -2
- package/connectors/injected/dist/wagmi-connectors-injected.cjs.prod.js +2 -2
- package/connectors/injected/dist/wagmi-connectors-injected.esm.js +1 -1
- package/connectors/walletConnect/dist/wagmi-connectors-walletConnect.cjs.dev.js +1 -1
- package/connectors/walletConnect/dist/wagmi-connectors-walletConnect.cjs.prod.js +1 -1
- package/connectors/walletConnect/dist/wagmi-connectors-walletConnect.esm.js +1 -1
- package/dist/declarations/src/connectors/coinbaseWallet.d.ts +1 -0
- package/dist/declarations/src/connectors/injected.d.ts +1 -1
- package/dist/declarations/src/connectors/walletConnect.d.ts +1 -1
- package/dist/declarations/src/context.d.ts +12 -59
- package/dist/declarations/src/hooks/accounts/index.d.ts +1 -0
- package/dist/declarations/src/hooks/accounts/useAccount.d.ts +30 -11
- package/dist/declarations/src/hooks/accounts/useBalance.d.ts +15 -26
- package/dist/declarations/src/hooks/accounts/useConnect.d.ts +38 -13
- package/dist/declarations/src/hooks/accounts/useDisconnect.d.ts +26 -0
- package/dist/declarations/src/hooks/accounts/useNetwork.d.ts +91 -29
- package/dist/declarations/src/hooks/accounts/useSignMessage.d.ts +66 -15
- package/dist/declarations/src/hooks/accounts/useSignTypedData.d.ts +68 -30
- package/dist/declarations/src/hooks/accounts/useSigner.d.ts +117 -11
- package/dist/declarations/src/hooks/contracts/index.d.ts +1 -1
- package/dist/declarations/src/hooks/contracts/useContract.d.ts +3 -11
- package/dist/declarations/src/hooks/contracts/useContractEvent.d.ts +3 -4
- package/dist/declarations/src/hooks/contracts/useContractRead.d.ts +17 -22
- package/dist/declarations/src/hooks/contracts/useContractWrite.d.ts +69 -19
- package/dist/declarations/src/hooks/contracts/useToken.d.ts +14 -42
- package/dist/declarations/src/hooks/ens/index.d.ts +2 -2
- package/dist/declarations/src/hooks/ens/useEnsAddress.d.ts +17 -0
- package/dist/declarations/src/hooks/ens/useEnsAvatar.d.ts +15 -12
- package/dist/declarations/src/hooks/ens/useEnsName.d.ts +17 -0
- package/dist/declarations/src/hooks/ens/useEnsResolver.d.ts +15 -19
- package/dist/declarations/src/hooks/index.d.ts +4 -4
- package/dist/declarations/src/hooks/network-status/useBlockNumber.d.ts +10 -15
- package/dist/declarations/src/hooks/network-status/useFeeData.d.ts +12 -27
- package/dist/declarations/src/hooks/providers/useProvider.d.ts +1 -1
- package/dist/declarations/src/hooks/providers/useWebSocketProvider.d.ts +1 -1
- package/dist/declarations/src/hooks/transactions/index.d.ts +1 -1
- package/dist/declarations/src/hooks/transactions/useSendTransaction.d.ts +69 -0
- package/dist/declarations/src/hooks/transactions/useWaitForTransaction.d.ts +15 -31
- package/dist/declarations/src/hooks/utils/index.d.ts +1 -3
- package/dist/declarations/src/hooks/utils/useChainId.d.ts +1 -0
- package/dist/declarations/src/index.d.ts +5 -5
- package/dist/declarations/src/types/index.d.ts +40 -0
- package/dist/declarations/src/utils/deserialize.d.ts +2 -0
- package/dist/declarations/src/utils/index.d.ts +2 -0
- package/dist/declarations/src/utils/serialize.d.ts +7 -0
- package/dist/wagmi.cjs.dev.js +1217 -1478
- package/dist/wagmi.cjs.prod.js +1217 -1478
- package/dist/wagmi.esm.js +1194 -1442
- package/package.json +15 -17
- package/connectors/walletLink/package.json +0 -4
- package/dist/declarations/src/connectors/walletLink.d.ts +0 -1
- package/dist/declarations/src/hooks/ens/useEnsLookup.d.ts +0 -20
- package/dist/declarations/src/hooks/ens/useEnsResolveName.d.ts +0 -20
- package/dist/declarations/src/hooks/transactions/useTransaction.d.ts +0 -18
- package/dist/declarations/src/hooks/utils/useCacheBuster.d.ts +0 -1
- package/dist/declarations/src/hooks/utils/useCancel.d.ts +0 -3
- package/dist/declarations/src/hooks/utils/useLocalStorage.d.ts +0 -1
package/README.md
CHANGED
|
@@ -1,81 +1,100 @@
|
|
|
1
|
-
# wagmi
|
|
1
|
+
# wagmi
|
|
2
2
|
|
|
3
|
-
React Hooks
|
|
3
|
+
React Hooks for Ethereum
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/wagmi) [](/LICENSE) [](https://www.npmjs.com/package/wagmi) [](https://github.com/sponsors/tmm)
|
|
4
6
|
|
|
5
7
|
## Features
|
|
6
8
|
|
|
7
9
|
- 🚀 20+ hooks for working with wallets, ENS, contracts, transactions, signing, etc.
|
|
8
10
|
- 💼 Built-in wallet connectors for MetaMask, WalletConnect, and Coinbase Wallet
|
|
9
|
-
-
|
|
11
|
+
- 👟 Caching, request deduplication, and persistence
|
|
12
|
+
- 🌀 Auto-refresh data on wallet, block, and network changes
|
|
10
13
|
- 🦄 TypeScript ready
|
|
11
|
-
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
+
- 🌳 Test suite running against forked Ethereum network
|
|
15
|
+
|
|
16
|
+
...and a lot more.
|
|
14
17
|
|
|
15
18
|
## Documentation
|
|
16
19
|
|
|
17
|
-
|
|
20
|
+
For full documentation and examples, visit [wagmi.sh](https://wagmi.sh).
|
|
18
21
|
|
|
19
|
-
##
|
|
22
|
+
## Installation
|
|
20
23
|
|
|
21
|
-
|
|
24
|
+
Install wagmi and its ethers peer dependency.
|
|
22
25
|
|
|
23
26
|
```bash
|
|
24
|
-
npm
|
|
27
|
+
npm install wagmi ethers
|
|
25
28
|
```
|
|
26
29
|
|
|
27
|
-
|
|
30
|
+
## Quick Start
|
|
31
|
+
|
|
32
|
+
Connect a wallet in under 60 seconds. LFG.
|
|
28
33
|
|
|
29
34
|
```tsx
|
|
30
|
-
import { Provider } from 'wagmi'
|
|
35
|
+
import { Provider, createClient } from 'wagmi'
|
|
31
36
|
|
|
32
|
-
const
|
|
33
|
-
<Provider>
|
|
34
|
-
<YourRoutes />
|
|
35
|
-
</Provider>
|
|
36
|
-
)
|
|
37
|
-
```
|
|
37
|
+
const client = createClient()
|
|
38
38
|
|
|
39
|
-
|
|
39
|
+
function App() {
|
|
40
|
+
return (
|
|
41
|
+
<Provider client={client}>
|
|
42
|
+
<Profile />
|
|
43
|
+
</Provider>
|
|
44
|
+
)
|
|
45
|
+
}
|
|
40
46
|
|
|
41
|
-
|
|
42
|
-
import {
|
|
47
|
+
import { useAccount, useConnect, useDisconnect } from 'wagmi'
|
|
48
|
+
import { InjectedConnector } from 'wagmi/connectors/injected'
|
|
43
49
|
|
|
44
|
-
|
|
45
|
-
const
|
|
46
|
-
|
|
50
|
+
function Profile() {
|
|
51
|
+
const { data } = useAccount()
|
|
52
|
+
const { connectors, connect } = useConnect({
|
|
53
|
+
connector: new InjectedConnector(),
|
|
47
54
|
})
|
|
48
|
-
|
|
49
|
-
|
|
55
|
+
const { disconnect } = useDisconnect()
|
|
56
|
+
|
|
57
|
+
if (data?.address)
|
|
58
|
+
return (
|
|
59
|
+
<div>
|
|
60
|
+
Connected to {data.address}
|
|
61
|
+
<button onClick={disconnect}>Disconnect</button>
|
|
62
|
+
</div>
|
|
63
|
+
)
|
|
64
|
+
return <button onClick={connect}>Connect Wallet</button>
|
|
50
65
|
}
|
|
51
66
|
```
|
|
52
67
|
|
|
53
|
-
|
|
68
|
+
In this example, we create a wagmi `Client` (using the default configuration) and pass it to the React Context `Provider`. Next, we use the `useConnect` hook to connect an injected wallet (i.e. MetaMask) to the app. Finally, we show the connected account's address with `useAccount` and allow them to disconnect with `useDisconnect`.
|
|
54
69
|
|
|
55
|
-
|
|
70
|
+
We've only scratched the surface for what you can do with wagmi!
|
|
56
71
|
|
|
57
72
|
## Community
|
|
58
73
|
|
|
74
|
+
Check out the following places for more wagmi-related content:
|
|
75
|
+
|
|
59
76
|
- Join the [discussions on GitHub](https://github.com/tmm/wagmi/discussions)
|
|
60
77
|
- Follow [@awkweb](https://twitter.com/awkweb) on Twitter for project updates
|
|
61
78
|
- Sign the [guestbook](https://github.com/tmm/wagmi/discussions/2)
|
|
62
|
-
- Share [your project/organization](https://github.com/tmm/wagmi/discussions/201)
|
|
79
|
+
- Share [your project/organization](https://github.com/tmm/wagmi/discussions/201) using wagmi
|
|
63
80
|
|
|
64
81
|
## Support
|
|
65
82
|
|
|
66
|
-
-
|
|
83
|
+
Help support future development and make wagmi a sustainable open-source project:
|
|
84
|
+
|
|
85
|
+
- [awkweb.eth](https://etherscan.io/enslookup-search?search=awkweb.eth)
|
|
67
86
|
- [GitHub Sponsors](https://github.com/sponsors/tmm)
|
|
68
87
|
- [Gitcoin Grant](https://gitcoin.co/grants/4493/wagmi-react-hooks-library-for-ethereum)
|
|
69
88
|
|
|
70
|
-
##
|
|
89
|
+
## Contributing
|
|
71
90
|
|
|
72
|
-
|
|
73
|
-
- [Mirror](https://mirror.xyz) for creating space to do good work
|
|
91
|
+
If you're interested in contributing to wagmi, please read the [contributing docs](/.github/CONTRIBUTING.md) **before submitting a pull request**.
|
|
74
92
|
|
|
75
93
|
## License
|
|
76
94
|
|
|
77
|
-
MIT.
|
|
95
|
+
The MIT License.
|
|
78
96
|
|
|
97
|
+
<br />
|
|
79
98
|
<br />
|
|
80
99
|
|
|
81
|
-
wagmi
|
|
100
|
+
wagmi frens
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "../../../dist/declarations/src/connectors/coinbaseWallet";
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var coinbaseWallet = require('@wagmi/core/connectors/coinbaseWallet');
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
Object.defineProperty(exports, 'CoinbaseWalletConnector', {
|
|
10
|
+
enumerable: true,
|
|
11
|
+
get: function () { return coinbaseWallet.CoinbaseWalletConnector; }
|
|
12
|
+
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var coinbaseWallet = require('@wagmi/core/connectors/coinbaseWallet');
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
Object.defineProperty(exports, 'CoinbaseWalletConnector', {
|
|
10
|
+
enumerable: true,
|
|
11
|
+
get: function () { return coinbaseWallet.CoinbaseWalletConnector; }
|
|
12
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { CoinbaseWalletConnector } from '@wagmi/core/connectors/coinbaseWallet';
|
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var
|
|
5
|
+
var core = require('@wagmi/core');
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
Object.defineProperty(exports, 'InjectedConnector', {
|
|
10
10
|
enumerable: true,
|
|
11
|
-
get: function () { return
|
|
11
|
+
get: function () { return core.InjectedConnector; }
|
|
12
12
|
});
|
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var
|
|
5
|
+
var core = require('@wagmi/core');
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
Object.defineProperty(exports, 'InjectedConnector', {
|
|
10
10
|
enumerable: true,
|
|
11
|
-
get: function () { return
|
|
11
|
+
get: function () { return core.InjectedConnector; }
|
|
12
12
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { InjectedConnector } from 'wagmi
|
|
1
|
+
export { InjectedConnector } from '@wagmi/core';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { WalletConnectConnector } from 'wagmi
|
|
1
|
+
export { WalletConnectConnector } from '@wagmi/core/connectors/walletConnect';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { CoinbaseWalletConnector } from '@wagmi/core/connectors/coinbaseWallet';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { InjectedConnector } from 'wagmi
|
|
1
|
+
export { InjectedConnector } from '@wagmi/core';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { WalletConnectConnector } from 'wagmi
|
|
1
|
+
export { WalletConnectConnector } from '@wagmi/core/connectors/walletConnect';
|
|
@@ -1,63 +1,16 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
declare
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
connector?: Connector;
|
|
8
|
-
data?: ConnectorData<Web3Provider>;
|
|
9
|
-
error?: Error;
|
|
2
|
+
import { WagmiClient, ClientConfig as WagmiClientConfig } from '@wagmi/core';
|
|
3
|
+
import { QueryClient } from 'react-query';
|
|
4
|
+
export declare const Context: React.Context<WagmiClient | undefined>;
|
|
5
|
+
export declare type ClientConfig = WagmiClientConfig & {
|
|
6
|
+
queryClient?: QueryClient;
|
|
10
7
|
};
|
|
11
|
-
declare
|
|
12
|
-
|
|
13
|
-
/** Flag for triggering refetch */
|
|
14
|
-
cacheBuster: State['cacheBuster'];
|
|
15
|
-
/** Flag for when connection is in progress */
|
|
16
|
-
connecting?: State['connecting'];
|
|
17
|
-
/** Active connector */
|
|
18
|
-
connector?: State['connector'];
|
|
19
|
-
/** Connectors used for linking accounts */
|
|
20
|
-
connectors: Connector[];
|
|
21
|
-
/** Active data */
|
|
22
|
-
data?: State['data'];
|
|
23
|
-
/** Interface for connecting to network */
|
|
24
|
-
provider: BaseProvider;
|
|
25
|
-
/** Interface for connecting to network */
|
|
26
|
-
webSocketProvider?: WebSocketProvider;
|
|
27
|
-
};
|
|
28
|
-
setState: React.Dispatch<React.SetStateAction<State>>;
|
|
29
|
-
setLastUsedConnector: (newValue: string | null) => void;
|
|
8
|
+
export declare function createClient({ queryClient, ...config }?: ClientConfig): WagmiClient & {
|
|
9
|
+
queryClient: QueryClient;
|
|
30
10
|
};
|
|
31
|
-
export declare
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
autoConnect?: boolean;
|
|
35
|
-
/**
|
|
36
|
-
* Key for saving connector preference to browser
|
|
37
|
-
* @default 'wagmi.wallet'
|
|
38
|
-
*/
|
|
39
|
-
connectorStorageKey?: string;
|
|
40
|
-
/**
|
|
41
|
-
* Connectors used for linking accounts
|
|
42
|
-
* @default [new InjectedConnector()]
|
|
43
|
-
*/
|
|
44
|
-
connectors?: Connector[] | ((config: {
|
|
45
|
-
chainId?: number;
|
|
46
|
-
}) => Connector[]);
|
|
47
|
-
/**
|
|
48
|
-
* Interface for connecting to network
|
|
49
|
-
* @default getDefaultProvider()
|
|
50
|
-
*/
|
|
51
|
-
provider?: BaseProvider | ((config: {
|
|
52
|
-
chainId?: number;
|
|
53
|
-
connector?: Connector;
|
|
54
|
-
}) => BaseProvider);
|
|
55
|
-
/** WebSocket interface for connecting to network */
|
|
56
|
-
webSocketProvider?: WebSocketProvider | ((config: {
|
|
57
|
-
chainId?: number;
|
|
58
|
-
connector?: Connector;
|
|
59
|
-
}) => WebSocketProvider | undefined);
|
|
11
|
+
export declare type ProviderProps = {
|
|
12
|
+
/** React-decorated WagmiClient instance */
|
|
13
|
+
client?: ReturnType<typeof createClient>;
|
|
60
14
|
};
|
|
61
|
-
export declare
|
|
62
|
-
export declare
|
|
63
|
-
export {};
|
|
15
|
+
export declare function Provider({ children, client, }: React.PropsWithChildren<ProviderProps>): JSX.Element;
|
|
16
|
+
export declare function useClient(): WagmiClient;
|
|
@@ -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,16 +1,35 @@
|
|
|
1
|
-
|
|
1
|
+
import { GetAccountResult } from '@wagmi/core';
|
|
2
|
+
import { QueryConfig } from '../../types';
|
|
3
|
+
export declare type UseAccountArgs = {
|
|
2
4
|
/** Fetches ENS for connected account */
|
|
3
|
-
|
|
5
|
+
ens?: boolean | {
|
|
6
|
+
avatar?: boolean;
|
|
7
|
+
name?: boolean;
|
|
8
|
+
};
|
|
4
9
|
};
|
|
5
|
-
export declare
|
|
10
|
+
export declare type UseAccountConfig = Pick<QueryConfig<GetAccountResult, Error>, 'suspense' | 'onError' | 'onSettled' | 'onSuccess'>;
|
|
11
|
+
export declare const queryKey: () => readonly [{
|
|
12
|
+
readonly entity: "account";
|
|
13
|
+
}];
|
|
14
|
+
export declare function useAccount({ ens, suspense, onError, onSettled, onSuccess, }?: UseAccountArgs & UseAccountConfig): {
|
|
6
15
|
readonly data: {
|
|
7
|
-
address: string;
|
|
8
|
-
connector: import("wagmi-core").Connector<any, any> | undefined;
|
|
9
16
|
ens: {
|
|
10
|
-
avatar:
|
|
11
|
-
name:
|
|
12
|
-
}
|
|
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;
|
|
13
26
|
} | undefined;
|
|
14
|
-
readonly error: Error |
|
|
15
|
-
readonly
|
|
16
|
-
|
|
27
|
+
readonly error: Error | null;
|
|
28
|
+
readonly isError: boolean;
|
|
29
|
+
readonly isFetching: boolean;
|
|
30
|
+
readonly isFetched: boolean;
|
|
31
|
+
readonly isIdle: boolean;
|
|
32
|
+
readonly isLoading: boolean;
|
|
33
|
+
readonly isSuccess: boolean;
|
|
34
|
+
readonly status: "error" | "idle" | "loading" | "success";
|
|
35
|
+
};
|
|
@@ -1,28 +1,17 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
export declare type
|
|
4
|
-
/** Disables fetching */
|
|
5
|
-
skip?: boolean;
|
|
1
|
+
import { FetchBalanceArgs, FetchBalanceResult } from '@wagmi/core';
|
|
2
|
+
import { QueryConfig } from '../../types';
|
|
3
|
+
export declare type UseBalanceArgs = Partial<FetchBalanceArgs> & {
|
|
6
4
|
/** Subscribe to changes */
|
|
7
5
|
watch?: boolean;
|
|
8
|
-
}
|
|
9
|
-
export declare
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
readonly
|
|
17
|
-
readonly
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
formatUnits?: Config['formatUnits'];
|
|
21
|
-
token?: Config['token'];
|
|
22
|
-
} | undefined) => Promise<{
|
|
23
|
-
data: import("wagmi-core").Balance;
|
|
24
|
-
error: undefined;
|
|
25
|
-
} | {
|
|
26
|
-
data: undefined;
|
|
27
|
-
error: Error;
|
|
28
|
-
}>];
|
|
6
|
+
};
|
|
7
|
+
export declare type UseBalanceConfig = QueryConfig<FetchBalanceResult, Error>;
|
|
8
|
+
export declare const queryKey: ({ addressOrName, chainId, formatUnits, token, }: Partial<FetchBalanceArgs> & {
|
|
9
|
+
chainId?: number | undefined;
|
|
10
|
+
}) => readonly [{
|
|
11
|
+
readonly entity: "balance";
|
|
12
|
+
readonly addressOrName: string | undefined;
|
|
13
|
+
readonly chainId: number | undefined;
|
|
14
|
+
readonly formatUnits: number | "wei" | "kwei" | "mwei" | "gwei" | "szabo" | "finney" | "ether" | undefined;
|
|
15
|
+
readonly token: string | undefined;
|
|
16
|
+
}];
|
|
17
|
+
export declare function useBalance({ addressOrName, cacheTime, enabled, formatUnits, staleTime, suspense, token, watch, onError, onSettled, onSuccess, }?: UseBalanceArgs & UseBalanceConfig): import("react-query").UseQueryResult<FetchBalanceResult, Error>;
|
|
@@ -1,13 +1,38 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
1
|
+
import { ConnectArgs, ConnectResult } from '@wagmi/core';
|
|
2
|
+
import { UseMutationOptions } from 'react-query';
|
|
3
|
+
export declare type UseConnectArgs = Partial<ConnectArgs>;
|
|
4
|
+
declare type MutationOptions = UseMutationOptions<ConnectResult, Error, ConnectArgs>;
|
|
5
|
+
export declare type UseConnectConfig = {
|
|
6
|
+
/**
|
|
7
|
+
* Function to invoke before connect and is passed same variables connect function would receive.
|
|
8
|
+
* Value returned from this function will be passed to both onError and onSettled functions in event of a mutation failure.
|
|
9
|
+
*/
|
|
10
|
+
onBeforeConnect?: MutationOptions['onMutate'];
|
|
11
|
+
/** Function to invoke when connect is successful. */
|
|
12
|
+
onConnect?: MutationOptions['onSuccess'];
|
|
13
|
+
/** Function to invoke when an error is thrown while connecting. */
|
|
14
|
+
onError?: MutationOptions['onError'];
|
|
15
|
+
/** Function to invoke when connect is settled (either successfully connected, or an error has thrown). */
|
|
16
|
+
onSettled?: MutationOptions['onSettled'];
|
|
17
|
+
};
|
|
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>;
|
|
26
|
+
readonly connectors: import("@wagmi/core").Connector<any, any>[];
|
|
27
|
+
readonly data: ConnectResult | undefined;
|
|
28
|
+
readonly error: Error | null;
|
|
29
|
+
readonly isConnected: boolean;
|
|
30
|
+
readonly isConnecting: boolean;
|
|
31
|
+
readonly isDisconnected: boolean;
|
|
32
|
+
readonly isError: boolean;
|
|
33
|
+
readonly isIdle: boolean;
|
|
34
|
+
readonly isReconnecting: boolean;
|
|
35
|
+
readonly pendingConnector: import("@wagmi/core").Connector<any, any> | undefined;
|
|
36
|
+
readonly status: "error" | "connecting" | "connected" | "reconnecting" | "disconnected" | "idle";
|
|
37
|
+
};
|
|
38
|
+
export {};
|
|
@@ -0,0 +1,26 @@
|
|
|
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 status: "error" | "idle" | "loading" | "success";
|
|
26
|
+
};
|
|
@@ -1,30 +1,92 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
readonly error:
|
|
23
|
-
readonly
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
1
|
+
import { SwitchNetworkArgs, SwitchNetworkResult } from '@wagmi/core';
|
|
2
|
+
import { MutationConfig } from '../../types';
|
|
3
|
+
export declare type UseNetworkArgs = Partial<SwitchNetworkArgs>;
|
|
4
|
+
export declare type UseNetworkConfig = MutationConfig<SwitchNetworkResult, Error, SwitchNetworkArgs>;
|
|
5
|
+
export declare const mutationKey: (args: UseNetworkArgs) => {
|
|
6
|
+
chainId?: number | undefined;
|
|
7
|
+
entity: string;
|
|
8
|
+
}[];
|
|
9
|
+
export declare const queryKey: () => readonly [{
|
|
10
|
+
readonly entity: "chain";
|
|
11
|
+
}];
|
|
12
|
+
export declare function useNetwork({ chainId, onError, onMutate, onSettled, onSuccess, }?: UseNetworkArgs & UseNetworkConfig): {
|
|
13
|
+
readonly activeChain: (import("@wagmi/core").Chain & {
|
|
14
|
+
id: number;
|
|
15
|
+
unsupported?: boolean | undefined;
|
|
16
|
+
}) | undefined;
|
|
17
|
+
readonly chains: import("@wagmi/core").Chain[];
|
|
18
|
+
readonly pendingChainId: number | undefined;
|
|
19
|
+
readonly switchNetwork: ((chainId_?: number | undefined) => void) | undefined;
|
|
20
|
+
readonly switchNetworkAsync: ((chainId_?: number | undefined) => Promise<import("@wagmi/core").Chain>) | undefined;
|
|
21
|
+
readonly data: undefined;
|
|
22
|
+
readonly error: null;
|
|
23
|
+
readonly isError: false;
|
|
24
|
+
readonly isIdle: true;
|
|
25
|
+
readonly isLoading: false;
|
|
26
|
+
readonly isSuccess: false;
|
|
27
|
+
readonly status: "idle";
|
|
28
|
+
readonly reset: () => void;
|
|
29
|
+
readonly context: unknown;
|
|
30
|
+
readonly failureCount: number;
|
|
31
|
+
readonly isPaused: boolean;
|
|
27
32
|
} | {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
33
|
+
readonly activeChain: (import("@wagmi/core").Chain & {
|
|
34
|
+
id: number;
|
|
35
|
+
unsupported?: boolean | undefined;
|
|
36
|
+
}) | undefined;
|
|
37
|
+
readonly chains: import("@wagmi/core").Chain[];
|
|
38
|
+
readonly pendingChainId: number | undefined;
|
|
39
|
+
readonly switchNetwork: ((chainId_?: number | undefined) => void) | undefined;
|
|
40
|
+
readonly switchNetworkAsync: ((chainId_?: number | undefined) => Promise<import("@wagmi/core").Chain>) | undefined;
|
|
41
|
+
readonly data: undefined;
|
|
42
|
+
readonly error: null;
|
|
43
|
+
readonly isError: false;
|
|
44
|
+
readonly isIdle: false;
|
|
45
|
+
readonly isLoading: true;
|
|
46
|
+
readonly isSuccess: false;
|
|
47
|
+
readonly status: "loading";
|
|
48
|
+
readonly reset: () => void;
|
|
49
|
+
readonly context: unknown;
|
|
50
|
+
readonly failureCount: number;
|
|
51
|
+
readonly isPaused: boolean;
|
|
52
|
+
} | {
|
|
53
|
+
readonly activeChain: (import("@wagmi/core").Chain & {
|
|
54
|
+
id: number;
|
|
55
|
+
unsupported?: boolean | undefined;
|
|
56
|
+
}) | undefined;
|
|
57
|
+
readonly chains: import("@wagmi/core").Chain[];
|
|
58
|
+
readonly pendingChainId: number | undefined;
|
|
59
|
+
readonly switchNetwork: ((chainId_?: number | undefined) => void) | undefined;
|
|
60
|
+
readonly switchNetworkAsync: ((chainId_?: number | undefined) => Promise<import("@wagmi/core").Chain>) | undefined;
|
|
61
|
+
readonly data: undefined;
|
|
62
|
+
readonly error: Error;
|
|
63
|
+
readonly isError: true;
|
|
64
|
+
readonly isIdle: false;
|
|
65
|
+
readonly isLoading: false;
|
|
66
|
+
readonly isSuccess: false;
|
|
67
|
+
readonly status: "error";
|
|
68
|
+
readonly reset: () => void;
|
|
69
|
+
readonly context: unknown;
|
|
70
|
+
readonly failureCount: number;
|
|
71
|
+
readonly isPaused: boolean;
|
|
72
|
+
} | {
|
|
73
|
+
readonly activeChain: (import("@wagmi/core").Chain & {
|
|
74
|
+
id: number;
|
|
75
|
+
unsupported?: boolean | undefined;
|
|
76
|
+
}) | undefined;
|
|
77
|
+
readonly chains: import("@wagmi/core").Chain[];
|
|
78
|
+
readonly pendingChainId: number | undefined;
|
|
79
|
+
readonly switchNetwork: ((chainId_?: number | undefined) => void) | undefined;
|
|
80
|
+
readonly switchNetworkAsync: ((chainId_?: number | undefined) => Promise<import("@wagmi/core").Chain>) | undefined;
|
|
81
|
+
readonly data: import("@wagmi/core").Chain;
|
|
82
|
+
readonly error: null;
|
|
83
|
+
readonly isError: false;
|
|
84
|
+
readonly isIdle: false;
|
|
85
|
+
readonly isLoading: false;
|
|
86
|
+
readonly isSuccess: true;
|
|
87
|
+
readonly status: "success";
|
|
88
|
+
readonly reset: () => void;
|
|
89
|
+
readonly context: unknown;
|
|
90
|
+
readonly failureCount: number;
|
|
91
|
+
readonly isPaused: boolean;
|
|
92
|
+
};
|