wagmi 0.0.1 → 0.0.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 (43) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +59 -0
  3. package/dist/declarations/src/context.d.ts +51 -0
  4. package/dist/declarations/src/hooks/accounts/index.d.ts +4 -0
  5. package/dist/declarations/src/hooks/accounts/useAccount.d.ts +22 -0
  6. package/dist/declarations/src/hooks/accounts/useBalance.d.ts +27 -0
  7. package/dist/declarations/src/hooks/accounts/useConnect.d.ts +13 -0
  8. package/dist/declarations/src/hooks/accounts/useNetwork.d.ts +24 -0
  9. package/dist/declarations/src/hooks/contracts/index.d.ts +3 -0
  10. package/dist/declarations/src/hooks/contracts/useContract.d.ts +8 -0
  11. package/dist/declarations/src/hooks/contracts/useContractEvent.d.ts +7 -0
  12. package/dist/declarations/src/hooks/contracts/useToken.d.ts +37 -0
  13. package/dist/declarations/src/hooks/ens/index.d.ts +3 -0
  14. package/dist/declarations/src/hooks/ens/useEnsAvatar.d.ts +12 -0
  15. package/dist/declarations/src/hooks/ens/useEnsLookup.d.ts +12 -0
  16. package/dist/declarations/src/hooks/ens/useEnsResolver.d.ts +11 -0
  17. package/dist/declarations/src/hooks/index.d.ts +6 -0
  18. package/dist/declarations/src/hooks/network-status/index.d.ts +2 -0
  19. package/dist/declarations/src/hooks/network-status/useBlockNumber.d.ts +10 -0
  20. package/dist/declarations/src/hooks/network-status/useFeeData.d.ts +22 -0
  21. package/dist/declarations/src/hooks/providers/index.d.ts +2 -0
  22. package/dist/declarations/src/hooks/providers/useProvider.d.ts +1 -0
  23. package/dist/declarations/src/hooks/providers/useWebSocketProvider.d.ts +1 -0
  24. package/dist/declarations/src/hooks/utils/index.d.ts +2 -0
  25. package/dist/declarations/src/hooks/utils/useCacheBuster.d.ts +1 -0
  26. package/dist/declarations/src/hooks/utils/useLocalStorage.d.ts +1 -0
  27. package/dist/declarations/src/index.d.ts +5 -0
  28. package/dist/wagmi.cjs.d.ts +1 -0
  29. package/dist/wagmi.cjs.dev.js +1155 -0
  30. package/dist/wagmi.cjs.js +7 -0
  31. package/dist/wagmi.cjs.prod.js +1155 -0
  32. package/dist/wagmi.esm.js +1069 -0
  33. package/package.json +45 -13
  34. package/index.html +0 -13
  35. package/src/App.css +0 -42
  36. package/src/App.tsx +0 -45
  37. package/src/favicon.svg +0 -15
  38. package/src/index.css +0 -13
  39. package/src/logo.svg +0 -7
  40. package/src/main.tsx +0 -11
  41. package/src/vite-env.d.ts +0 -1
  42. package/tsconfig.json +0 -20
  43. package/vite.config.ts +0 -7
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2021 Tom Meagher
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,59 @@
1
+ <p>
2
+ <a aria-label="NPM version" href="https://www.npmjs.com/package/wagmi">
3
+ <img
4
+ alt=""
5
+ src="https://img.shields.io/npm/v/wagmi.svg?style=for-the-badge&labelColor=161c22"
6
+ />
7
+ </a>
8
+ <a aria-label="License" href="/LICENSE">
9
+ <img
10
+ alt=""
11
+ src="https://img.shields.io/npm/l/degen.svg?style=for-the-badge&labelColor=161c22"
12
+ />
13
+ </a>
14
+ </p>
15
+
16
+ ## Documentation
17
+
18
+ Visit https://wagmi-xyz.vercel.app to view the full documentation.
19
+
20
+ ## Usage
21
+
22
+ ```bash
23
+ pnpm add wagmi ethers
24
+ ```
25
+
26
+ ## Development
27
+
28
+ ```bash
29
+ pnpm i
30
+ pnpm dev
31
+ ```
32
+
33
+ ### Docs
34
+
35
+ ```bash
36
+ pnpm dev:docs
37
+ ```
38
+
39
+ ### Examples
40
+
41
+ ```bash
42
+ pnpm dev:example:vite-react
43
+ pnpm dev:example:next
44
+ ```
45
+
46
+ ### Testing
47
+
48
+ ```bash
49
+ pnpm test
50
+ pnpm test:watch
51
+ ```
52
+
53
+ ### CI
54
+
55
+ [Add secrets](https://github.com/tmm/wagmi/settings/secrets/actions) to GitHub:
56
+
57
+ ```
58
+ NPM_TOKEN
59
+ ```
@@ -0,0 +1,51 @@
1
+ import * as React from 'react';
2
+ import { BaseProvider, WebSocketProvider } from '@ethersproject/providers';
3
+ import { Connector, Data } from 'wagmi-private';
4
+ declare type State = {
5
+ cacheBuster: number;
6
+ connector?: Connector;
7
+ data?: Data;
8
+ error?: Error;
9
+ };
10
+ declare type ContextValue = {
11
+ state: {
12
+ /** Flag for triggering refetch */
13
+ cacheBuster: State['cacheBuster'];
14
+ /** Active connector */
15
+ connector?: State['connector'];
16
+ /** Connectors used for linking accounts */
17
+ connectors: Connector[];
18
+ /** Active data */
19
+ data?: State['data'];
20
+ /** Interface for connecting to network */
21
+ provider: BaseProvider;
22
+ /** Interface for connecting to network */
23
+ webSocketProvider?: WebSocketProvider;
24
+ };
25
+ setState: React.Dispatch<React.SetStateAction<State>>;
26
+ setLastUsedConnector: (newValue: string | null) => void;
27
+ };
28
+ export declare const Context: React.Context<ContextValue | null>;
29
+ export declare type Props = {
30
+ /** Enables reconnecting to last used connector on mount */
31
+ autoConnect?: boolean;
32
+ /** Key for saving connector preference to browser */
33
+ connectorStorageKey?: string;
34
+ /** Connectors used for linking accounts */
35
+ connectors?: Connector[] | ((config: {
36
+ chainId?: number;
37
+ }) => Connector[]);
38
+ /** Interface for connecting to network */
39
+ provider?: BaseProvider | ((config: {
40
+ chainId?: number;
41
+ connector?: Connector;
42
+ }) => BaseProvider);
43
+ /** WebSocket interface for connecting to network */
44
+ webSocketProvider?: WebSocketProvider | ((config: {
45
+ chainId?: number;
46
+ connector?: Connector;
47
+ }) => WebSocketProvider);
48
+ };
49
+ export declare const Provider: ({ autoConnect, children, connectors: _connectors, connectorStorageKey, provider: _provider, webSocketProvider: _webSocketProvider, }: React.PropsWithChildren<Props>) => React.FunctionComponentElement<React.ProviderProps<ContextValue | null>>;
50
+ export declare const useContext: () => ContextValue;
51
+ export {};
@@ -0,0 +1,4 @@
1
+ export { useAccount } from './useAccount';
2
+ export { useBalance } from './useBalance';
3
+ export { useConnect } from './useConnect';
4
+ export { useNetwork } from './useNetwork';
@@ -0,0 +1,22 @@
1
+ declare type Config = {
2
+ fetchBalance?: boolean;
3
+ fetchEns?: boolean;
4
+ };
5
+ export declare const useAccount: ({ fetchBalance, fetchEns }?: Config) => readonly [{
6
+ readonly data: {
7
+ address: string;
8
+ balance: {
9
+ formatted: string;
10
+ symbol: string;
11
+ value: import("ethers").BigNumber;
12
+ } | undefined;
13
+ connector: import("wagmi-private").Connector<any, any> | undefined;
14
+ ens: {
15
+ avatar: string | null | undefined;
16
+ name: string;
17
+ } | undefined;
18
+ } | undefined;
19
+ readonly error: Error | undefined;
20
+ readonly loading: boolean | undefined;
21
+ }, () => void];
22
+ export {};
@@ -0,0 +1,27 @@
1
+ import { BigNumber } from 'ethers';
2
+ import { Unit } from 'wagmi-private';
3
+ declare type Config = {
4
+ address?: string;
5
+ formatUnits?: Unit | number;
6
+ skip?: boolean;
7
+ token?: string;
8
+ watch?: boolean;
9
+ };
10
+ export declare const useBalance: ({ address, formatUnits, skip, token, watch, }: Config) => readonly [{
11
+ readonly data: {
12
+ formatted: string;
13
+ symbol: string;
14
+ value: BigNumber;
15
+ } | undefined;
16
+ readonly error: Error | undefined;
17
+ readonly loading: boolean | undefined;
18
+ }, ({ address, formatUnits, token, }: {
19
+ address: string;
20
+ formatUnits: Config['formatUnits'];
21
+ token: Config['token'];
22
+ }) => Promise<Error | {
23
+ formatted: string;
24
+ symbol: string;
25
+ value: BigNumber;
26
+ }>];
27
+ export {};
@@ -0,0 +1,13 @@
1
+ import { Connector } from 'wagmi-private';
2
+ export declare const useConnect: () => readonly [{
3
+ readonly data: {
4
+ readonly connected: boolean;
5
+ readonly connector: Connector<any, any> | undefined;
6
+ readonly connectors: Connector<any, any>[];
7
+ };
8
+ readonly error: Error | undefined;
9
+ readonly loading: boolean;
10
+ }, (connector: Connector) => Promise<Error | {
11
+ connector: Connector<any, any>;
12
+ data: import("wagmi-private").Data<any>;
13
+ } | undefined>];
@@ -0,0 +1,24 @@
1
+ import { Chain } from 'wagmi-private';
2
+ export declare const useNetwork: () => readonly [{
3
+ readonly data: {
4
+ readonly chain: {
5
+ id: number;
6
+ unsupported: boolean;
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<boolean | Error>) | undefined];
@@ -0,0 +1,3 @@
1
+ export { useContract } from './useContract';
2
+ export { useContractEvent } from './useContractEvent';
3
+ export { useToken } from './useToken';
@@ -0,0 +1,8 @@
1
+ import { ContractInterface, Signer } from 'ethers';
2
+ import { Provider } from '@ethersproject/providers';
3
+ export declare type Config = {
4
+ addressOrName: string;
5
+ contractInterface: ContractInterface;
6
+ signerOrProvider?: Signer | Provider;
7
+ };
8
+ export declare const useContract: <Contract_1 = any>({ addressOrName, contractInterface, signerOrProvider, }: Config) => Contract_1;
@@ -0,0 +1,7 @@
1
+ import { ethers } from 'ethers';
2
+ import { Config as UseContractConfig } from './useContract';
3
+ declare type Config = {
4
+ watch?: boolean;
5
+ };
6
+ export declare const useContractEvent: <Contract extends ethers.Contract = ethers.Contract>(contractConfig: UseContractConfig, eventName: Parameters<Contract["on"]>[0], listener: Parameters<Contract["on"]>[1], { watch }?: Config) => void;
7
+ export {};
@@ -0,0 +1,37 @@
1
+ import { BigNumber } from 'ethers';
2
+ import { Unit } from 'wagmi-private';
3
+ 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>, ({ address, formatUnits, }: {
26
+ address: string;
27
+ formatUnits?: Config['formatUnits'];
28
+ }) => Promise<Error | {
29
+ address: string;
30
+ decimals: any;
31
+ symbol: any;
32
+ totalSupply: {
33
+ formatted: string;
34
+ value: any;
35
+ };
36
+ }>];
37
+ export {};
@@ -0,0 +1,3 @@
1
+ export { useEnsAvatar } from './useEnsAvatar';
2
+ export { useEnsLookup } from './useEnsLookup';
3
+ export { useEnsResolver } from './useEnsResolver';
@@ -0,0 +1,12 @@
1
+ declare type Config = {
2
+ addressOrName?: string | null;
3
+ skip?: boolean;
4
+ };
5
+ export declare const useEnsAvatar: ({ addressOrName, skip }?: Config) => readonly [{
6
+ readonly data: string | null | undefined;
7
+ readonly loading: boolean;
8
+ readonly error: Error | undefined;
9
+ }, (config: {
10
+ addressOrName: string;
11
+ }) => Promise<string | Error | null>];
12
+ export {};
@@ -0,0 +1,12 @@
1
+ declare type Config = {
2
+ address?: string;
3
+ skip?: boolean;
4
+ };
5
+ export declare const useEnsLookup: ({ address, skip }?: Config) => readonly [{
6
+ readonly data: string | null | undefined;
7
+ readonly loading: boolean;
8
+ readonly error: Error | undefined;
9
+ }, (config: {
10
+ address: string;
11
+ }) => Promise<string | Error | null>];
12
+ export {};
@@ -0,0 +1,11 @@
1
+ import { EnsResolver } from '@ethersproject/providers';
2
+ declare type Config = {
3
+ name?: string | null;
4
+ skip?: boolean;
5
+ };
6
+ export declare const useEnsResolver: ({ name, skip }?: Config) => readonly [{
7
+ readonly data: EnsResolver | null | undefined;
8
+ readonly loading: boolean;
9
+ readonly error: Error | undefined;
10
+ }, (config: Pick<Config, 'name'>) => Promise<import("@ethersproject/providers").Resolver | null | undefined>];
11
+ export {};
@@ -0,0 +1,6 @@
1
+ export { useAccount, useBalance, useConnect, useNetwork } from './accounts';
2
+ export { useContract, useContractEvent, useToken } from './contracts';
3
+ export { useEnsAvatar, useEnsLookup, useEnsResolver } from './ens';
4
+ export { useBlockNumber, useFeeData } from './network-status';
5
+ export { useProvider, useWebSocketProvider } from './providers';
6
+ export { useCacheBuster, useLocalStorage } from './utils';
@@ -0,0 +1,2 @@
1
+ export { useBlockNumber } from './useBlockNumber';
2
+ export { useFeeData } from './useFeeData';
@@ -0,0 +1,10 @@
1
+ declare type Config = {
2
+ skip?: boolean;
3
+ watch?: boolean;
4
+ };
5
+ export declare const useBlockNumber: ({ skip, watch }?: Config) => readonly [{
6
+ readonly data: number | undefined;
7
+ readonly error: Error | undefined;
8
+ readonly loading: boolean | undefined;
9
+ }, () => Promise<number | Error>];
10
+ export {};
@@ -0,0 +1,22 @@
1
+ import { FeeData } from '@ethersproject/providers';
2
+ import { Unit } from 'wagmi-private';
3
+ declare type Config = {
4
+ formatUnits?: Unit | number;
5
+ skip?: boolean;
6
+ watch?: boolean;
7
+ };
8
+ export declare const useFeeData: ({ formatUnits, skip, watch, }?: Config) => readonly [{
9
+ readonly data: {
10
+ formatted: {
11
+ gasPrice: string;
12
+ maxFeePerGas: string;
13
+ maxPriorityFeePerGas: string;
14
+ } | undefined;
15
+ maxFeePerGas: import("ethers").BigNumber | null;
16
+ maxPriorityFeePerGas: import("ethers").BigNumber | null;
17
+ gasPrice: import("ethers").BigNumber | null;
18
+ } | undefined;
19
+ readonly loading: boolean | undefined;
20
+ readonly error: Error | undefined;
21
+ }, () => Promise<Error | FeeData>];
22
+ export {};
@@ -0,0 +1,2 @@
1
+ export { useProvider } from './useProvider';
2
+ export { useWebSocketProvider } from './useWebSocketProvider';
@@ -0,0 +1 @@
1
+ export declare const useProvider: () => import("@ethersproject/providers").BaseProvider;
@@ -0,0 +1 @@
1
+ export declare const useWebSocketProvider: () => import("@ethersproject/providers").WebSocketProvider | undefined;
@@ -0,0 +1,2 @@
1
+ export { useCacheBuster } from './useCacheBuster';
2
+ export { useLocalStorage } from './useLocalStorage';
@@ -0,0 +1 @@
1
+ export declare const useCacheBuster: () => number;
@@ -0,0 +1 @@
1
+ export declare const useLocalStorage: <T>(key: string, defaultState?: T | null) => readonly [T | null, (newValue: T | null) => void];
@@ -0,0 +1,5 @@
1
+ export { Provider, useContext } from './context';
2
+ export type { Props as ProviderProps } from './context';
3
+ export { useAccount, useBalance, useBlockNumber, useConnect, useContract, useContractEvent, useEnsAvatar, useEnsLookup, useEnsResolver, useFeeData, useNetwork, useProvider, useToken, useWebSocketProvider, } from './hooks';
4
+ export { Connector, InjectedConnector, WalletConnectConnector, WalletLinkConnector, chain, defaultChains, defaultL2Chains, developmentChains, erc1155ABI, erc20ABI, erc721ABI, isAddress, } from 'wagmi-private';
5
+ export type { Chain, Data } from 'wagmi-private';
@@ -0,0 +1 @@
1
+ export * from "./declarations/src/index";