wagmi-extended 2.2.7 → 2.2.9

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