wagmi-extended 2.2.6 → 2.2.8

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 (2) hide show
  1. package/README.md +41 -36
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -8,6 +8,8 @@ Our library adheres to one core principle: **always wait for a transaction recei
8
8
  <br /><br />
9
9
  Whether you're building a DeFi platform, a governance system, or any blockchain solution, `wagmi-extended` offers a consistent, reliable, and developer-friendly interface, trusted in production with over $500M in volume.
10
10
 
11
+ > **Note:** This project is **actively maintained**. The creator can be reached directly on [Discord](https://discord.gg/XQYzXgq2Ve). We are open to **suggestions and requests**, and love feedback from the community.
12
+
11
13
  ## Table of Contents
12
14
 
13
15
  - [Installation](#installation)
@@ -90,7 +92,7 @@ const { writeContractAsync, isPending, errorMessage } = useContractWriteX({
90
92
  queriesToInvalidate: [["userBalance"], ["userActivity"]],
91
93
  onSuccess: (txHash) => console.log("✅", txHash),
92
94
  onError: (err) => console.error("❌", err),
93
- });
95
+ })
94
96
 
95
97
  // will wait for the receipt, then invalidate `userBalance` & `userActivity`
96
98
  await writeContractAsync({
@@ -100,7 +102,7 @@ await writeContractAsync({
100
102
  args: [
101
103
  /* ... */
102
104
  ],
103
- });
105
+ })
104
106
  ```
105
107
 
106
108
  #### New `writeContractX` method
@@ -111,7 +113,7 @@ Use `writeContractX` if you need control over the simulation step:
111
113
  const { writeContractX, isPending, errorMessage } = useContractWriteX({
112
114
  onSuccess: (tx) => console.log("✔ Receipt confirmed:", tx),
113
115
  onError: (e) => console.error("✖ Failed:", e),
114
- });
116
+ })
115
117
 
116
118
  // simulate + send:
117
119
  await writeContractX(
@@ -127,14 +129,15 @@ await writeContractX(
127
129
  value: 0n,
128
130
  },
129
131
  /* disableSimulation? */ false
130
- );
132
+ )
131
133
 
132
134
  // send immediately without simulation:
133
- await writeContractX(params, /* disableSimulation= */ true);
135
+ await writeContractX(params, /* disableSimulation= */ true)
134
136
  ```
135
137
 
136
138
  - **`writeContractAsync`** = always runs the built-in dry-run, then write.
137
139
  - **`writeContractX`** = you can pass a boolean to skip the simulation step.
140
+ - **`writeContract`** = or use writeContract to skip the simulation step. (still will wait for transaction recepit and invalidate query)
138
141
 
139
142
  ---
140
143
 
@@ -155,17 +158,17 @@ const {
155
158
  queriesToInvalidate: [["ethBalance"]],
156
159
  onSuccess: (tx) => console.log("🎉 Tx sent & confirmed:", tx),
157
160
  onError: (e) => console.error("🚫 Simulation or send failed:", e),
158
- });
161
+ })
159
162
 
160
163
  // simulate & send an ETH transfer:
161
164
  await sendTransactionX(
162
165
  { to: recipient, value: 1n * 10n ** 18n, account: myAddress, chain: myChain },
163
166
  // for contract calls, pass simulation params:
164
167
  { abi: MyAbi, functionName: "deposit", args: [1000n], chain: myChain }
165
- );
168
+ )
166
169
 
167
170
  // or just raw send (no simulationParams):
168
- await sendTransactionX({ to, value, account });
171
+ await sendTransactionX({ to, value, account })
169
172
  ```
170
173
 
171
174
  ---
@@ -176,24 +179,24 @@ In all “X” hooks you pass a `WriteExtendedAsyncParams` object:
176
179
 
177
180
  ```ts
178
181
  export type WriteExtendedAsyncParams = {
179
- onSuccess?: (txHash: Address) => void;
180
- onError?: (e: any) => void;
181
- onSettled?: () => void;
182
- onSuccessAsync?: (txHash: Address) => Promise<void>;
183
- onErrorAsync?: (e: any) => Promise<void>;
184
- onSettledAsync?: () => Promise<void>;
182
+ onSuccess?: (txHash: Address) => void
183
+ onError?: (e: any) => void
184
+ onSettled?: () => void
185
+ onSuccessAsync?: (txHash: Address) => Promise<void>
186
+ onErrorAsync?: (e: any) => Promise<void>
187
+ onSettledAsync?: () => Promise<void>
185
188
 
186
189
  /** simple list of query keys to invalidate after receipt */
187
- queriesToInvalidate?: (QueryKey | undefined)[];
190
+ queriesToInvalidate?: (QueryKey | undefined)[]
188
191
 
189
192
  /** predicate-based invalidation:
190
193
  any active query where `predicate(query)` returns true
191
194
  will be invalidated after the tx settles. */
192
- invalidatePredicate?: (query: Query<unknown, unknown>) => boolean;
195
+ invalidatePredicate?: (query: Query<unknown, unknown>) => boolean
193
196
 
194
- disableLogging?: boolean;
195
- disableWaitingForReceipt?: boolean;
196
- };
197
+ disableLogging?: boolean
198
+ disableWaitingForReceipt?: boolean
199
+ }
197
200
  ```
198
201
 
199
202
  ---
@@ -203,17 +206,17 @@ export type WriteExtendedAsyncParams = {
203
206
  Fetch summary data from an ERC-4626 vault (total assets, shares, allowances, balances, etc.):
204
207
 
205
208
  ```ts
206
- import { useFetchERC4626DataX } from "wagmi-extended";
209
+ import { useFetchERC4626DataX } from "wagmi-extended"
207
210
 
208
211
  function VaultInfo({ vaultAddress, user, spender }) {
209
212
  const { data, isLoading, error } = useFetchERC4626DataX({
210
213
  vault,
211
214
  user,
212
215
  spender,
213
- });
216
+ })
214
217
 
215
- if (isLoading) return <p>Loading vault data…</p>;
216
- if (error) return <p>Error: {error.message}</p>;
218
+ if (isLoading) return <p>Loading vault data…</p>
219
+ if (error) return <p>Error: {error.message}</p>
217
220
 
218
221
  return (
219
222
  <div>
@@ -222,7 +225,7 @@ function VaultInfo({ vaultAddress, user, spender }) {
222
225
  <p>Your balance: {data.userBalance}</p>
223
226
  <p>Your allowance: {data.allowance}</p>
224
227
  </div>
225
- );
228
+ )
226
229
  }
227
230
  ```
228
231
 
@@ -233,17 +236,17 @@ function VaultInfo({ vaultAddress, user, spender }) {
233
236
  Fetch summary data for a generic ERC-20 token (decimals, name, symbol, balances, allowances):
234
237
 
235
238
  ```ts
236
- import { useFetchERC20DataX } from "wagmi-extended";
239
+ import { useFetchERC20DataX } from "wagmi-extended"
237
240
 
238
241
  function TokenInfo({ token, user, spender }) {
239
242
  const { data, isLoading, error } = useFetchERC20DataX({
240
243
  address: token,
241
244
  user,
242
245
  spender,
243
- });
246
+ })
244
247
 
245
- if (isLoading) return <p>Loading token info…</p>;
246
- if (error) return <p>Error: {error.message}</p>;
248
+ if (isLoading) return <p>Loading token info…</p>
249
+ if (error) return <p>Error: {error.message}</p>
247
250
 
248
251
  return (
249
252
  <div>
@@ -253,7 +256,7 @@ function TokenInfo({ token, user, spender }) {
253
256
  <p>Your balance: {data.balance}</p>
254
257
  <p>Your allowance: {data.allowance}</p>
255
258
  </div>
256
- );
259
+ )
257
260
  }
258
261
  ```
259
262
 
@@ -389,18 +392,15 @@ It uses an **exponential descent** followed by a **binary search**, making it op
389
392
  #### Example
390
393
 
391
394
  ```ts
392
- import { fetchDeploymentBlockX } from "wagmi-extended";
395
+ import { fetchDeploymentBlockX } from "wagmi-extended"
393
396
 
394
397
  async function main() {
395
- const deploymentBlock = await fetchDeploymentBlockX(
396
- "0xYourContractAddress",
397
- 0n
398
- );
398
+ const deploymentBlock = await fetchDeploymentBlockX("0xYourContractAddress", 0n)
399
399
 
400
- console.log("Contract was deployed at block:", deploymentBlock.toString());
400
+ console.log("Contract was deployed at block:", deploymentBlock.toString())
401
401
  }
402
402
 
403
- main();
403
+ main()
404
404
  ```
405
405
 
406
406
  Performance
@@ -434,6 +434,11 @@ If you enjoy this project and would like to support its ongoing development, ple
434
434
 
435
435
  Any donation, no matter how small, is greatly appreciated!
436
436
 
437
+ ## Community
438
+
439
+ - **X (Twitter):** Follow and share updates with the hashtag [#wagmiExtended](https://x.com/hashtag/wagmiExtended). Use it to discover tips, release notes, and community projects.
440
+ - **Discord:** Join the community and reach the creator directly at [discord.gg/XQYzXgq2Ve](https://discord.gg/XQYzXgq2Ve).
441
+
437
442
  ## License
438
443
 
439
444
  This is free and unencumbered software released into the public domain.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wagmi-extended",
3
- "version": "2.2.6",
3
+ "version": "2.2.8",
4
4
  "type": "module",
5
5
  "description": "A library providing extended hooks on top of Wagmi with additional hooks and features.",
6
6
  "main": "dist/index.cjs.js",