wagmi-extended 0.8.0 → 1.0.1

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 (31) hide show
  1. package/README.md +224 -1
  2. package/dist/config/defaults.d.ts +40 -0
  3. package/dist/fetch-functions/fetchAllowanceX.d.ts +2 -0
  4. package/dist/fetch-functions/fetchTokenX.d.ts +24 -0
  5. package/dist/hooks/{useContractWriteExtended.d.ts → useContractWriteX.d.ts} +43 -3
  6. package/dist/hooks/useERC20ApproveX.d.ts +40 -0
  7. package/dist/hooks/{useToken.d.ts → useFetchAssetAllowanceX.d.ts} +50 -37
  8. package/dist/hooks/{useHandleTransactionMutation.d.ts → useHandleTransactionMutationX.d.ts} +1 -1
  9. package/dist/hooks/{useSendTransactionExtended.d.ts → useSendTransactionX.d.ts} +31 -10
  10. package/dist/hooks/{useFetchAssetAllowance.d.ts → useTokenX.d.ts} +62 -108
  11. package/dist/index.cjs.js +353 -141
  12. package/dist/index.cjs.js.map +1 -1
  13. package/dist/index.d.ts +8 -4
  14. package/dist/index.esm.js +341 -138
  15. package/dist/index.esm.js.map +1 -1
  16. package/dist/utils/{errorParser.d.ts → errorParserX.d.ts} +1 -1
  17. package/package.json +2 -2
  18. package/src/config/defaults.ts +60 -0
  19. package/src/fetch-functions/fetchAllowanceX.ts +22 -0
  20. package/src/{hooks/useToken.ts → fetch-functions/fetchTokenX.ts} +42 -30
  21. package/src/hooks/useContractWriteX.ts +84 -0
  22. package/src/hooks/{useERC20Approve.ts → useERC20ApproveX.ts} +42 -38
  23. package/src/hooks/useFetchAssetAllowanceX.ts +60 -0
  24. package/src/hooks/{useHandleTransactionMutation.ts → useHandleTransactionMutationX.ts} +3 -3
  25. package/src/hooks/{useSendTransactionExtended.ts → useSendTransactionX.ts} +35 -13
  26. package/src/hooks/useTokenX.ts +65 -0
  27. package/src/index.ts +27 -4
  28. package/src/utils/{errorParser.ts → errorParserX.ts} +1 -1
  29. package/dist/hooks/useERC20Approve.d.ts +0 -28
  30. package/src/hooks/useContractWriteExtended.ts +0 -44
  31. package/src/hooks/useFetchAssetAllowance.ts +0 -94
@@ -1,25 +1,47 @@
1
1
  import { Address } from "viem";
2
- export declare const fetchAllowance: (asset: Address, spender: Address, userAddress: Address, queryClient: any, config: any) => Promise<{
3
- bigIntValue: bigint;
4
- decimals: number;
5
- symbol: string;
6
- }>;
7
2
  /**
8
- * Custom hook for fetching asset allowance.
3
+ * Returns a query key for fetching token data.
9
4
  *
10
- * @param {Address} asset - The address of the ERC20 token contract.
11
- * @param {Address} spender - The address of the spender to check allowance for.
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
+ * }
12
41
  */
13
- export declare const useFetchAssetAllowance: ({ asset, spender, }: {
14
- asset?: Address;
15
- spender?: Address;
16
- }) => {
17
- data: {
18
- bigIntValue: bigint;
19
- decimals: number;
20
- symbol: string;
21
- } | undefined;
22
- queryKey: readonly ["hookFetchAllowance", `0x${string}`, `0x${string}`, `0x${string}`, any, any];
42
+ export declare const useTokenX: (asset?: Address) => {
43
+ data: import("../fetch-functions/fetchTokenX.js").Token | undefined;
44
+ queryKey: any[];
23
45
  error: Error;
24
46
  isError: true;
25
47
  isPending: false;
@@ -41,24 +63,12 @@ export declare const useFetchAssetAllowance: ({ asset, spender, }: {
41
63
  isPaused: boolean;
42
64
  isRefetching: boolean;
43
65
  isStale: boolean;
44
- refetch: (options?: import("@tanstack/react-query").RefetchOptions) => Promise<import("@tanstack/react-query").QueryObserverResult<{
45
- bigIntValue: bigint;
46
- decimals: number;
47
- symbol: string;
48
- }, Error>>;
66
+ refetch: (options?: import("@tanstack/react-query").RefetchOptions) => Promise<import("@tanstack/react-query").QueryObserverResult<import("../fetch-functions/fetchTokenX.js").Token, Error>>;
49
67
  fetchStatus: import("@tanstack/react-query").FetchStatus;
50
- promise: Promise<{
51
- bigIntValue: bigint;
52
- decimals: number;
53
- symbol: string;
54
- }>;
68
+ promise: Promise<import("../fetch-functions/fetchTokenX.js").Token>;
55
69
  } | {
56
- data: {
57
- bigIntValue: bigint;
58
- decimals: number;
59
- symbol: string;
60
- } | undefined;
61
- queryKey: readonly ["hookFetchAllowance", `0x${string}`, `0x${string}`, `0x${string}`, any, any];
70
+ data: import("../fetch-functions/fetchTokenX.js").Token | undefined;
71
+ queryKey: any[];
62
72
  error: null;
63
73
  isError: false;
64
74
  isPending: false;
@@ -80,24 +90,12 @@ export declare const useFetchAssetAllowance: ({ asset, spender, }: {
80
90
  isPaused: boolean;
81
91
  isRefetching: boolean;
82
92
  isStale: boolean;
83
- refetch: (options?: import("@tanstack/react-query").RefetchOptions) => Promise<import("@tanstack/react-query").QueryObserverResult<{
84
- bigIntValue: bigint;
85
- decimals: number;
86
- symbol: string;
87
- }, Error>>;
93
+ refetch: (options?: import("@tanstack/react-query").RefetchOptions) => Promise<import("@tanstack/react-query").QueryObserverResult<import("../fetch-functions/fetchTokenX.js").Token, Error>>;
88
94
  fetchStatus: import("@tanstack/react-query").FetchStatus;
89
- promise: Promise<{
90
- bigIntValue: bigint;
91
- decimals: number;
92
- symbol: string;
93
- }>;
95
+ promise: Promise<import("../fetch-functions/fetchTokenX.js").Token>;
94
96
  } | {
95
- data: {
96
- bigIntValue: bigint;
97
- decimals: number;
98
- symbol: string;
99
- } | undefined;
100
- queryKey: readonly ["hookFetchAllowance", `0x${string}`, `0x${string}`, `0x${string}`, any, any];
97
+ data: import("../fetch-functions/fetchTokenX.js").Token | undefined;
98
+ queryKey: any[];
101
99
  error: Error;
102
100
  isError: true;
103
101
  isPending: false;
@@ -119,24 +117,12 @@ export declare const useFetchAssetAllowance: ({ asset, spender, }: {
119
117
  isPaused: boolean;
120
118
  isRefetching: boolean;
121
119
  isStale: boolean;
122
- refetch: (options?: import("@tanstack/react-query").RefetchOptions) => Promise<import("@tanstack/react-query").QueryObserverResult<{
123
- bigIntValue: bigint;
124
- decimals: number;
125
- symbol: string;
126
- }, Error>>;
120
+ refetch: (options?: import("@tanstack/react-query").RefetchOptions) => Promise<import("@tanstack/react-query").QueryObserverResult<import("../fetch-functions/fetchTokenX.js").Token, Error>>;
127
121
  fetchStatus: import("@tanstack/react-query").FetchStatus;
128
- promise: Promise<{
129
- bigIntValue: bigint;
130
- decimals: number;
131
- symbol: string;
132
- }>;
122
+ promise: Promise<import("../fetch-functions/fetchTokenX.js").Token>;
133
123
  } | {
134
- data: {
135
- bigIntValue: bigint;
136
- decimals: number;
137
- symbol: string;
138
- } | undefined;
139
- queryKey: readonly ["hookFetchAllowance", `0x${string}`, `0x${string}`, `0x${string}`, any, any];
124
+ data: import("../fetch-functions/fetchTokenX.js").Token | undefined;
125
+ queryKey: any[];
140
126
  error: null;
141
127
  isError: false;
142
128
  isPending: true;
@@ -158,24 +144,12 @@ export declare const useFetchAssetAllowance: ({ asset, spender, }: {
158
144
  isPaused: boolean;
159
145
  isRefetching: boolean;
160
146
  isStale: boolean;
161
- refetch: (options?: import("@tanstack/react-query").RefetchOptions) => Promise<import("@tanstack/react-query").QueryObserverResult<{
162
- bigIntValue: bigint;
163
- decimals: number;
164
- symbol: string;
165
- }, Error>>;
147
+ refetch: (options?: import("@tanstack/react-query").RefetchOptions) => Promise<import("@tanstack/react-query").QueryObserverResult<import("../fetch-functions/fetchTokenX.js").Token, Error>>;
166
148
  fetchStatus: import("@tanstack/react-query").FetchStatus;
167
- promise: Promise<{
168
- bigIntValue: bigint;
169
- decimals: number;
170
- symbol: string;
171
- }>;
149
+ promise: Promise<import("../fetch-functions/fetchTokenX.js").Token>;
172
150
  } | {
173
- data: {
174
- bigIntValue: bigint;
175
- decimals: number;
176
- symbol: string;
177
- } | undefined;
178
- queryKey: readonly ["hookFetchAllowance", `0x${string}`, `0x${string}`, `0x${string}`, any, any];
151
+ data: import("../fetch-functions/fetchTokenX.js").Token | undefined;
152
+ queryKey: any[];
179
153
  error: null;
180
154
  isError: false;
181
155
  isPending: true;
@@ -197,24 +171,12 @@ export declare const useFetchAssetAllowance: ({ asset, spender, }: {
197
171
  isPaused: boolean;
198
172
  isRefetching: boolean;
199
173
  isStale: boolean;
200
- refetch: (options?: import("@tanstack/react-query").RefetchOptions) => Promise<import("@tanstack/react-query").QueryObserverResult<{
201
- bigIntValue: bigint;
202
- decimals: number;
203
- symbol: string;
204
- }, Error>>;
174
+ refetch: (options?: import("@tanstack/react-query").RefetchOptions) => Promise<import("@tanstack/react-query").QueryObserverResult<import("../fetch-functions/fetchTokenX.js").Token, Error>>;
205
175
  fetchStatus: import("@tanstack/react-query").FetchStatus;
206
- promise: Promise<{
207
- bigIntValue: bigint;
208
- decimals: number;
209
- symbol: string;
210
- }>;
176
+ promise: Promise<import("../fetch-functions/fetchTokenX.js").Token>;
211
177
  } | {
212
- data: {
213
- bigIntValue: bigint;
214
- decimals: number;
215
- symbol: string;
216
- } | undefined;
217
- queryKey: readonly ["hookFetchAllowance", `0x${string}`, `0x${string}`, `0x${string}`, any, any];
178
+ data: import("../fetch-functions/fetchTokenX.js").Token | undefined;
179
+ queryKey: any[];
218
180
  isError: false;
219
181
  error: null;
220
182
  isPending: false;
@@ -236,15 +198,7 @@ export declare const useFetchAssetAllowance: ({ asset, spender, }: {
236
198
  isPaused: boolean;
237
199
  isRefetching: boolean;
238
200
  isStale: boolean;
239
- refetch: (options?: import("@tanstack/react-query").RefetchOptions) => Promise<import("@tanstack/react-query").QueryObserverResult<{
240
- bigIntValue: bigint;
241
- decimals: number;
242
- symbol: string;
243
- }, Error>>;
201
+ refetch: (options?: import("@tanstack/react-query").RefetchOptions) => Promise<import("@tanstack/react-query").QueryObserverResult<import("../fetch-functions/fetchTokenX.js").Token, Error>>;
244
202
  fetchStatus: import("@tanstack/react-query").FetchStatus;
245
- promise: Promise<{
246
- bigIntValue: bigint;
247
- decimals: number;
248
- symbol: string;
249
- }>;
203
+ promise: Promise<import("../fetch-functions/fetchTokenX.js").Token>;
250
204
  };