wagmi-extended 2.2.7 → 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 +34 -36
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -92,7 +92,7 @@ const { writeContractAsync, isPending, errorMessage } = useContractWriteX({
92
92
  queriesToInvalidate: [["userBalance"], ["userActivity"]],
93
93
  onSuccess: (txHash) => console.log("✅", txHash),
94
94
  onError: (err) => console.error("❌", err),
95
- });
95
+ })
96
96
 
97
97
  // will wait for the receipt, then invalidate `userBalance` & `userActivity`
98
98
  await writeContractAsync({
@@ -102,7 +102,7 @@ await writeContractAsync({
102
102
  args: [
103
103
  /* ... */
104
104
  ],
105
- });
105
+ })
106
106
  ```
107
107
 
108
108
  #### New `writeContractX` method
@@ -113,7 +113,7 @@ Use `writeContractX` if you need control over the simulation step:
113
113
  const { writeContractX, isPending, errorMessage } = useContractWriteX({
114
114
  onSuccess: (tx) => console.log("✔ Receipt confirmed:", tx),
115
115
  onError: (e) => console.error("✖ Failed:", e),
116
- });
116
+ })
117
117
 
118
118
  // simulate + send:
119
119
  await writeContractX(
@@ -129,14 +129,15 @@ await writeContractX(
129
129
  value: 0n,
130
130
  },
131
131
  /* disableSimulation? */ false
132
- );
132
+ )
133
133
 
134
134
  // send immediately without simulation:
135
- await writeContractX(params, /* disableSimulation= */ true);
135
+ await writeContractX(params, /* disableSimulation= */ true)
136
136
  ```
137
137
 
138
138
  - **`writeContractAsync`** = always runs the built-in dry-run, then write.
139
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)
140
141
 
141
142
  ---
142
143
 
@@ -157,17 +158,17 @@ const {
157
158
  queriesToInvalidate: [["ethBalance"]],
158
159
  onSuccess: (tx) => console.log("🎉 Tx sent & confirmed:", tx),
159
160
  onError: (e) => console.error("🚫 Simulation or send failed:", e),
160
- });
161
+ })
161
162
 
162
163
  // simulate & send an ETH transfer:
163
164
  await sendTransactionX(
164
165
  { to: recipient, value: 1n * 10n ** 18n, account: myAddress, chain: myChain },
165
166
  // for contract calls, pass simulation params:
166
167
  { abi: MyAbi, functionName: "deposit", args: [1000n], chain: myChain }
167
- );
168
+ )
168
169
 
169
170
  // or just raw send (no simulationParams):
170
- await sendTransactionX({ to, value, account });
171
+ await sendTransactionX({ to, value, account })
171
172
  ```
172
173
 
173
174
  ---
@@ -178,24 +179,24 @@ In all “X” hooks you pass a `WriteExtendedAsyncParams` object:
178
179
 
179
180
  ```ts
180
181
  export type WriteExtendedAsyncParams = {
181
- onSuccess?: (txHash: Address) => void;
182
- onError?: (e: any) => void;
183
- onSettled?: () => void;
184
- onSuccessAsync?: (txHash: Address) => Promise<void>;
185
- onErrorAsync?: (e: any) => Promise<void>;
186
- 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>
187
188
 
188
189
  /** simple list of query keys to invalidate after receipt */
189
- queriesToInvalidate?: (QueryKey | undefined)[];
190
+ queriesToInvalidate?: (QueryKey | undefined)[]
190
191
 
191
192
  /** predicate-based invalidation:
192
193
  any active query where `predicate(query)` returns true
193
194
  will be invalidated after the tx settles. */
194
- invalidatePredicate?: (query: Query<unknown, unknown>) => boolean;
195
+ invalidatePredicate?: (query: Query<unknown, unknown>) => boolean
195
196
 
196
- disableLogging?: boolean;
197
- disableWaitingForReceipt?: boolean;
198
- };
197
+ disableLogging?: boolean
198
+ disableWaitingForReceipt?: boolean
199
+ }
199
200
  ```
200
201
 
201
202
  ---
@@ -205,17 +206,17 @@ export type WriteExtendedAsyncParams = {
205
206
  Fetch summary data from an ERC-4626 vault (total assets, shares, allowances, balances, etc.):
206
207
 
207
208
  ```ts
208
- import { useFetchERC4626DataX } from "wagmi-extended";
209
+ import { useFetchERC4626DataX } from "wagmi-extended"
209
210
 
210
211
  function VaultInfo({ vaultAddress, user, spender }) {
211
212
  const { data, isLoading, error } = useFetchERC4626DataX({
212
213
  vault,
213
214
  user,
214
215
  spender,
215
- });
216
+ })
216
217
 
217
- if (isLoading) return <p>Loading vault data…</p>;
218
- 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>
219
220
 
220
221
  return (
221
222
  <div>
@@ -224,7 +225,7 @@ function VaultInfo({ vaultAddress, user, spender }) {
224
225
  <p>Your balance: {data.userBalance}</p>
225
226
  <p>Your allowance: {data.allowance}</p>
226
227
  </div>
227
- );
228
+ )
228
229
  }
229
230
  ```
230
231
 
@@ -235,17 +236,17 @@ function VaultInfo({ vaultAddress, user, spender }) {
235
236
  Fetch summary data for a generic ERC-20 token (decimals, name, symbol, balances, allowances):
236
237
 
237
238
  ```ts
238
- import { useFetchERC20DataX } from "wagmi-extended";
239
+ import { useFetchERC20DataX } from "wagmi-extended"
239
240
 
240
241
  function TokenInfo({ token, user, spender }) {
241
242
  const { data, isLoading, error } = useFetchERC20DataX({
242
243
  address: token,
243
244
  user,
244
245
  spender,
245
- });
246
+ })
246
247
 
247
- if (isLoading) return <p>Loading token info…</p>;
248
- 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>
249
250
 
250
251
  return (
251
252
  <div>
@@ -255,7 +256,7 @@ function TokenInfo({ token, user, spender }) {
255
256
  <p>Your balance: {data.balance}</p>
256
257
  <p>Your allowance: {data.allowance}</p>
257
258
  </div>
258
- );
259
+ )
259
260
  }
260
261
  ```
261
262
 
@@ -391,18 +392,15 @@ It uses an **exponential descent** followed by a **binary search**, making it op
391
392
  #### Example
392
393
 
393
394
  ```ts
394
- import { fetchDeploymentBlockX } from "wagmi-extended";
395
+ import { fetchDeploymentBlockX } from "wagmi-extended"
395
396
 
396
397
  async function main() {
397
- const deploymentBlock = await fetchDeploymentBlockX(
398
- "0xYourContractAddress",
399
- 0n
400
- );
398
+ const deploymentBlock = await fetchDeploymentBlockX("0xYourContractAddress", 0n)
401
399
 
402
- console.log("Contract was deployed at block:", deploymentBlock.toString());
400
+ console.log("Contract was deployed at block:", deploymentBlock.toString())
403
401
  }
404
402
 
405
- main();
403
+ main()
406
404
  ```
407
405
 
408
406
  Performance
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wagmi-extended",
3
- "version": "2.2.7",
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",