wagmi-extended 0.5.0 → 1.0.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/README.md +220 -1
- package/dist/config/defaults.d.ts +40 -0
- package/dist/fetch-functions/fetchAllowanceX.d.ts +2 -0
- package/dist/fetch-functions/fetchTokenX.d.ts +24 -0
- package/dist/hooks/{useContractWriteExtended.d.ts → useContractWriteX.d.ts} +43 -3
- package/dist/hooks/useERC20ApproveX.d.ts +40 -0
- package/dist/hooks/useFetchAssetAllowanceX.d.ts +192 -0
- package/dist/hooks/{useHandleTransactionMutation.d.ts → useHandleTransactionMutationX.d.ts} +1 -1
- package/dist/hooks/{useSendTransactionExtended.d.ts → useSendTransactionX.d.ts} +31 -10
- package/dist/hooks/useTokenX.d.ts +204 -0
- package/dist/index.cjs.js +456 -27
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +8 -3
- package/dist/index.esm.js +446 -28
- package/dist/index.esm.js.map +1 -1
- package/dist/query-config/index.d.ts +8 -0
- package/dist/utils/{errorParser.d.ts → errorParserX.d.ts} +1 -1
- package/package.json +2 -2
- package/src/config/defaults.ts +60 -0
- package/src/fetch-functions/fetchAllowanceX.ts +22 -0
- package/src/fetch-functions/fetchTokenX.ts +134 -0
- package/src/hooks/useContractWriteX.ts +84 -0
- package/src/hooks/useERC20ApproveX.ts +108 -0
- package/src/hooks/useFetchAssetAllowanceX.ts +60 -0
- package/src/hooks/{useHandleTransactionMutation.ts → useHandleTransactionMutationX.ts} +4 -4
- package/src/hooks/{useSendTransactionExtended.ts → useSendTransactionX.ts} +35 -13
- package/src/hooks/useTokenX.ts +65 -0
- package/src/index.ts +27 -3
- package/src/query-config/index.ts +8 -0
- package/src/utils/{errorParser.ts → errorParserX.ts} +1 -1
- package/tsconfig.json +9 -1
- package/src/hooks/useContractWriteExtended.ts +0 -44
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
import { Address } from "viem";
|
|
2
|
+
/**
|
|
3
|
+
* Returns a query key for fetching token data.
|
|
4
|
+
*
|
|
5
|
+
* @param {Address | undefined} asset - The token address.
|
|
6
|
+
* @returns {Array} A unique query key for the token fetch.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* const queryKey = HookFetchTokenQK("0x123...");
|
|
10
|
+
*/
|
|
11
|
+
export declare const HookFetchTokenQK: (asset?: Address) => any[];
|
|
12
|
+
/**
|
|
13
|
+
* Custom hook for fetching token metadata using extended Wagmi functionality.
|
|
14
|
+
*
|
|
15
|
+
* This hook leverages React Query for data fetching and caching.
|
|
16
|
+
* It retrieves token metadata (such as symbol, decimals, name, etc.) for a given token address.
|
|
17
|
+
*
|
|
18
|
+
* @param {Address} [asset] - The token address.
|
|
19
|
+
* @returns {Object} An object with the following properties:
|
|
20
|
+
* - `data`: The token data (or undefined if not loaded).
|
|
21
|
+
* - `isLoading`: Boolean indicating if the data is loading.
|
|
22
|
+
* - `error`: Any error encountered during the fetch.
|
|
23
|
+
* - `queryKey`: The unique key used for the query.
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* // In your component:
|
|
27
|
+
* function MyTokenComponent() {
|
|
28
|
+
* const { data, isLoading, error, queryKey } = useTokenX("0x123456...");
|
|
29
|
+
*
|
|
30
|
+
* if (isLoading) return <div>Loading token data...</div>;
|
|
31
|
+
* if (error) return <div>Error: {error.message}</div>;
|
|
32
|
+
*
|
|
33
|
+
* return (
|
|
34
|
+
* <div>
|
|
35
|
+
* <p>Token Symbol: {data.symbol}</p>
|
|
36
|
+
* <p>Decimals: {data.decimals}</p>
|
|
37
|
+
* <p>Name: {data.name}</p>
|
|
38
|
+
* </div>
|
|
39
|
+
* );
|
|
40
|
+
* }
|
|
41
|
+
*/
|
|
42
|
+
export declare const useTokenX: (asset?: Address) => {
|
|
43
|
+
data: import("../fetch-functions/fetchTokenX.js").Token | undefined;
|
|
44
|
+
queryKey: any[];
|
|
45
|
+
error: Error;
|
|
46
|
+
isError: true;
|
|
47
|
+
isPending: false;
|
|
48
|
+
isLoading: false;
|
|
49
|
+
isLoadingError: false;
|
|
50
|
+
isRefetchError: true;
|
|
51
|
+
isSuccess: false;
|
|
52
|
+
isPlaceholderData: false;
|
|
53
|
+
status: "error";
|
|
54
|
+
dataUpdatedAt: number;
|
|
55
|
+
errorUpdatedAt: number;
|
|
56
|
+
failureCount: number;
|
|
57
|
+
failureReason: Error | null;
|
|
58
|
+
errorUpdateCount: number;
|
|
59
|
+
isFetched: boolean;
|
|
60
|
+
isFetchedAfterMount: boolean;
|
|
61
|
+
isFetching: boolean;
|
|
62
|
+
isInitialLoading: boolean;
|
|
63
|
+
isPaused: boolean;
|
|
64
|
+
isRefetching: boolean;
|
|
65
|
+
isStale: boolean;
|
|
66
|
+
refetch: (options?: import("@tanstack/react-query").RefetchOptions) => Promise<import("@tanstack/react-query").QueryObserverResult<import("../fetch-functions/fetchTokenX.js").Token, Error>>;
|
|
67
|
+
fetchStatus: import("@tanstack/react-query").FetchStatus;
|
|
68
|
+
promise: Promise<import("../fetch-functions/fetchTokenX.js").Token>;
|
|
69
|
+
} | {
|
|
70
|
+
data: import("../fetch-functions/fetchTokenX.js").Token | undefined;
|
|
71
|
+
queryKey: any[];
|
|
72
|
+
error: null;
|
|
73
|
+
isError: false;
|
|
74
|
+
isPending: false;
|
|
75
|
+
isLoading: false;
|
|
76
|
+
isLoadingError: false;
|
|
77
|
+
isRefetchError: false;
|
|
78
|
+
isSuccess: true;
|
|
79
|
+
isPlaceholderData: false;
|
|
80
|
+
status: "success";
|
|
81
|
+
dataUpdatedAt: number;
|
|
82
|
+
errorUpdatedAt: number;
|
|
83
|
+
failureCount: number;
|
|
84
|
+
failureReason: Error | null;
|
|
85
|
+
errorUpdateCount: number;
|
|
86
|
+
isFetched: boolean;
|
|
87
|
+
isFetchedAfterMount: boolean;
|
|
88
|
+
isFetching: boolean;
|
|
89
|
+
isInitialLoading: boolean;
|
|
90
|
+
isPaused: boolean;
|
|
91
|
+
isRefetching: boolean;
|
|
92
|
+
isStale: boolean;
|
|
93
|
+
refetch: (options?: import("@tanstack/react-query").RefetchOptions) => Promise<import("@tanstack/react-query").QueryObserverResult<import("../fetch-functions/fetchTokenX.js").Token, Error>>;
|
|
94
|
+
fetchStatus: import("@tanstack/react-query").FetchStatus;
|
|
95
|
+
promise: Promise<import("../fetch-functions/fetchTokenX.js").Token>;
|
|
96
|
+
} | {
|
|
97
|
+
data: import("../fetch-functions/fetchTokenX.js").Token | undefined;
|
|
98
|
+
queryKey: any[];
|
|
99
|
+
error: Error;
|
|
100
|
+
isError: true;
|
|
101
|
+
isPending: false;
|
|
102
|
+
isLoading: false;
|
|
103
|
+
isLoadingError: true;
|
|
104
|
+
isRefetchError: false;
|
|
105
|
+
isSuccess: false;
|
|
106
|
+
isPlaceholderData: false;
|
|
107
|
+
status: "error";
|
|
108
|
+
dataUpdatedAt: number;
|
|
109
|
+
errorUpdatedAt: number;
|
|
110
|
+
failureCount: number;
|
|
111
|
+
failureReason: Error | null;
|
|
112
|
+
errorUpdateCount: number;
|
|
113
|
+
isFetched: boolean;
|
|
114
|
+
isFetchedAfterMount: boolean;
|
|
115
|
+
isFetching: boolean;
|
|
116
|
+
isInitialLoading: boolean;
|
|
117
|
+
isPaused: boolean;
|
|
118
|
+
isRefetching: boolean;
|
|
119
|
+
isStale: boolean;
|
|
120
|
+
refetch: (options?: import("@tanstack/react-query").RefetchOptions) => Promise<import("@tanstack/react-query").QueryObserverResult<import("../fetch-functions/fetchTokenX.js").Token, Error>>;
|
|
121
|
+
fetchStatus: import("@tanstack/react-query").FetchStatus;
|
|
122
|
+
promise: Promise<import("../fetch-functions/fetchTokenX.js").Token>;
|
|
123
|
+
} | {
|
|
124
|
+
data: import("../fetch-functions/fetchTokenX.js").Token | undefined;
|
|
125
|
+
queryKey: any[];
|
|
126
|
+
error: null;
|
|
127
|
+
isError: false;
|
|
128
|
+
isPending: true;
|
|
129
|
+
isLoading: true;
|
|
130
|
+
isLoadingError: false;
|
|
131
|
+
isRefetchError: false;
|
|
132
|
+
isSuccess: false;
|
|
133
|
+
isPlaceholderData: false;
|
|
134
|
+
status: "pending";
|
|
135
|
+
dataUpdatedAt: number;
|
|
136
|
+
errorUpdatedAt: number;
|
|
137
|
+
failureCount: number;
|
|
138
|
+
failureReason: Error | null;
|
|
139
|
+
errorUpdateCount: number;
|
|
140
|
+
isFetched: boolean;
|
|
141
|
+
isFetchedAfterMount: boolean;
|
|
142
|
+
isFetching: boolean;
|
|
143
|
+
isInitialLoading: boolean;
|
|
144
|
+
isPaused: boolean;
|
|
145
|
+
isRefetching: boolean;
|
|
146
|
+
isStale: boolean;
|
|
147
|
+
refetch: (options?: import("@tanstack/react-query").RefetchOptions) => Promise<import("@tanstack/react-query").QueryObserverResult<import("../fetch-functions/fetchTokenX.js").Token, Error>>;
|
|
148
|
+
fetchStatus: import("@tanstack/react-query").FetchStatus;
|
|
149
|
+
promise: Promise<import("../fetch-functions/fetchTokenX.js").Token>;
|
|
150
|
+
} | {
|
|
151
|
+
data: import("../fetch-functions/fetchTokenX.js").Token | undefined;
|
|
152
|
+
queryKey: any[];
|
|
153
|
+
error: null;
|
|
154
|
+
isError: false;
|
|
155
|
+
isPending: true;
|
|
156
|
+
isLoadingError: false;
|
|
157
|
+
isRefetchError: false;
|
|
158
|
+
isSuccess: false;
|
|
159
|
+
isPlaceholderData: false;
|
|
160
|
+
status: "pending";
|
|
161
|
+
dataUpdatedAt: number;
|
|
162
|
+
errorUpdatedAt: number;
|
|
163
|
+
failureCount: number;
|
|
164
|
+
failureReason: Error | null;
|
|
165
|
+
errorUpdateCount: number;
|
|
166
|
+
isFetched: boolean;
|
|
167
|
+
isFetchedAfterMount: boolean;
|
|
168
|
+
isFetching: boolean;
|
|
169
|
+
isLoading: boolean;
|
|
170
|
+
isInitialLoading: boolean;
|
|
171
|
+
isPaused: boolean;
|
|
172
|
+
isRefetching: boolean;
|
|
173
|
+
isStale: boolean;
|
|
174
|
+
refetch: (options?: import("@tanstack/react-query").RefetchOptions) => Promise<import("@tanstack/react-query").QueryObserverResult<import("../fetch-functions/fetchTokenX.js").Token, Error>>;
|
|
175
|
+
fetchStatus: import("@tanstack/react-query").FetchStatus;
|
|
176
|
+
promise: Promise<import("../fetch-functions/fetchTokenX.js").Token>;
|
|
177
|
+
} | {
|
|
178
|
+
data: import("../fetch-functions/fetchTokenX.js").Token | undefined;
|
|
179
|
+
queryKey: any[];
|
|
180
|
+
isError: false;
|
|
181
|
+
error: null;
|
|
182
|
+
isPending: false;
|
|
183
|
+
isLoading: false;
|
|
184
|
+
isLoadingError: false;
|
|
185
|
+
isRefetchError: false;
|
|
186
|
+
isSuccess: true;
|
|
187
|
+
isPlaceholderData: true;
|
|
188
|
+
status: "success";
|
|
189
|
+
dataUpdatedAt: number;
|
|
190
|
+
errorUpdatedAt: number;
|
|
191
|
+
failureCount: number;
|
|
192
|
+
failureReason: Error | null;
|
|
193
|
+
errorUpdateCount: number;
|
|
194
|
+
isFetched: boolean;
|
|
195
|
+
isFetchedAfterMount: boolean;
|
|
196
|
+
isFetching: boolean;
|
|
197
|
+
isInitialLoading: boolean;
|
|
198
|
+
isPaused: boolean;
|
|
199
|
+
isRefetching: boolean;
|
|
200
|
+
isStale: boolean;
|
|
201
|
+
refetch: (options?: import("@tanstack/react-query").RefetchOptions) => Promise<import("@tanstack/react-query").QueryObserverResult<import("../fetch-functions/fetchTokenX.js").Token, Error>>;
|
|
202
|
+
fetchStatus: import("@tanstack/react-query").FetchStatus;
|
|
203
|
+
promise: Promise<import("../fetch-functions/fetchTokenX.js").Token>;
|
|
204
|
+
};
|