wagmi-extended 2.0.1 → 2.1.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 +153 -68
- package/dist/hooks/mutations/useContractWriteX.d.ts +21 -57
- package/dist/hooks/mutations/useHandleTransactionMutationX.d.ts +0 -1
- package/dist/hooks/mutations/useSendTransactionX.d.ts +26 -45
- package/dist/index.cjs.js +58 -106
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +58 -106
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/hooks/mutations/useContractWriteX.ts +27 -61
- package/src/hooks/mutations/useHandleTransactionMutationX.ts +0 -2
- package/src/hooks/mutations/useSendTransactionX.ts +32 -47
- package/src/hooks/queries/useERC20Data.ts +0 -1
package/README.md
CHANGED
|
@@ -74,102 +74,187 @@ Each hook is documented with detailed JSDoc comments (including usage examples)
|
|
|
74
74
|
|
|
75
75
|
## Hooks explanations and examples
|
|
76
76
|
|
|
77
|
-
###
|
|
77
|
+
### useContractWriteX Hook
|
|
78
78
|
|
|
79
|
-
The `
|
|
79
|
+
The `useContractWriteX` hook wraps Wagmi’s `useWriteContract` with extra features:
|
|
80
80
|
|
|
81
|
-
|
|
81
|
+
- **Receipt waiting**: always waits for the transaction receipt before resolving.
|
|
82
|
+
- **Logging control**: disable console logging if you wish.
|
|
83
|
+
- **Query invalidation**: automatically invalidates queries after receipt, either by explicit keys or by predicate.
|
|
82
84
|
|
|
83
|
-
|
|
84
|
-
import { useERC20ApproveX } from "wagmi-extended";
|
|
85
|
+
#### Original `writeContractAsync`
|
|
85
86
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
87
|
+
```ts
|
|
88
|
+
const { writeContractAsync, isPending, errorMessage } = useContractWriteX({
|
|
89
|
+
queriesToInvalidate: [["userBalance"], ["userActivity"]],
|
|
90
|
+
onSuccess: (txHash) => console.log("✅", txHash),
|
|
91
|
+
onError: (err) => console.error("❌", err),
|
|
92
|
+
});
|
|
89
93
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
94
|
+
// will wait for the receipt, then invalidate `userBalance` & `userActivity`
|
|
95
|
+
await writeContractAsync({
|
|
96
|
+
address: "0xContractAddress",
|
|
97
|
+
abi: MyContractAbi,
|
|
98
|
+
functionName: "executeFunction",
|
|
99
|
+
args: [
|
|
100
|
+
/* ... */
|
|
101
|
+
],
|
|
102
|
+
});
|
|
103
|
+
```
|
|
95
104
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
}
|
|
105
|
+
#### New `writeContractX` method
|
|
106
|
+
|
|
107
|
+
Use `writeContractX` if you need control over the simulation step:
|
|
108
|
+
|
|
109
|
+
```ts
|
|
110
|
+
const { writeContractX, isPending, errorMessage } = useContractWriteX({
|
|
111
|
+
onSuccess: (tx) => console.log("✔ Receipt confirmed:", tx),
|
|
112
|
+
onError: (e) => console.error("✖ Failed:", e),
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
// simulate + send:
|
|
116
|
+
await writeContractX(
|
|
117
|
+
{
|
|
118
|
+
address: "0xContractAddress",
|
|
119
|
+
abi: MyContractAbi,
|
|
120
|
+
functionName: "executeFunction",
|
|
121
|
+
args: [
|
|
122
|
+
/* ... */
|
|
123
|
+
],
|
|
124
|
+
account: myAddress,
|
|
125
|
+
chain: myChain,
|
|
126
|
+
value: 0n,
|
|
127
|
+
},
|
|
128
|
+
/* disableSimulation? */ false
|
|
129
|
+
);
|
|
130
|
+
|
|
131
|
+
// send immediately without simulation:
|
|
132
|
+
await writeContractX(params, /* disableSimulation= */ true);
|
|
102
133
|
```
|
|
103
134
|
|
|
104
|
-
|
|
135
|
+
- **`writeContractAsync`** = always runs the built-in dry-run, then write.
|
|
136
|
+
- **`writeContractX`** = you can pass a boolean to skip the simulation step.
|
|
105
137
|
|
|
106
|
-
|
|
138
|
+
---
|
|
107
139
|
|
|
108
|
-
|
|
140
|
+
### useSendTransactionX Hook
|
|
109
141
|
|
|
110
|
-
|
|
111
|
-
function MyTransactionComponent() {
|
|
112
|
-
const { writeContractAsync, isPending, errorMessage } = useContractWriteX({
|
|
113
|
-
queriesToInvalidate: [["userBalance"], ["userActivity"]],
|
|
114
|
-
{
|
|
115
|
-
// use calbacks here in writeContractAsync or in useContractWriteX
|
|
116
|
-
onSuccess: (txHash) => console.log("Transaction successful:", txHash),
|
|
117
|
-
onError: (error) => console.error("Transaction error:", error),
|
|
118
|
-
}
|
|
119
|
-
});
|
|
142
|
+
The `useSendTransactionX` hook wraps Wagmi’s `useSendTransaction` with the same lifecycle features:
|
|
120
143
|
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
const txHash = await writeContractAsync({
|
|
124
|
-
address: "0xContractAddress",
|
|
125
|
-
abi: [], // Provide your contract ABI
|
|
126
|
-
functionName: "executeFunction",
|
|
127
|
-
args: [/* function arguments */],
|
|
128
|
-
});
|
|
129
|
-
console.log("Received txHash:", txHash);
|
|
130
|
-
} catch (err) {
|
|
131
|
-
console.error("Failed writing transaction:", err);`
|
|
132
|
-
}
|
|
133
|
-
};
|
|
144
|
+
- **`sendTransaction`** = Wagmi’s raw send
|
|
145
|
+
- **`sendTransactionX`** = optionally simulate (contract call) or just `eth_call`, then `sendTransaction` + receipt waiting + invalidations.
|
|
134
146
|
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
147
|
+
```ts
|
|
148
|
+
const {
|
|
149
|
+
sendTransaction, // raw
|
|
150
|
+
sendTransactionX, // wrapped
|
|
151
|
+
isPending,
|
|
152
|
+
errorMessage,
|
|
153
|
+
} = useSendTransactionX({
|
|
154
|
+
queriesToInvalidate: [["ethBalance"]],
|
|
155
|
+
onSuccess: (tx) => console.log("🎉 Tx sent & confirmed:", tx),
|
|
156
|
+
onError: (e) => console.error("🚫 Simulation or send failed:", e),
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
// simulate & send an ETH transfer:
|
|
160
|
+
await sendTransactionX(
|
|
161
|
+
{ to: recipient, value: 1n * 10n ** 18n, account: myAddress, chain: myChain },
|
|
162
|
+
// for contract calls, pass simulation params:
|
|
163
|
+
{ abi: MyAbi, functionName: "deposit", args: [1000n], chain: myChain }
|
|
142
164
|
);
|
|
143
|
-
|
|
165
|
+
|
|
166
|
+
// or just raw send (no simulationParams):
|
|
167
|
+
await sendTransactionX({ to, value, account });
|
|
144
168
|
```
|
|
145
169
|
|
|
146
|
-
|
|
170
|
+
---
|
|
171
|
+
|
|
172
|
+
## Transaction mutation settings
|
|
147
173
|
|
|
148
|
-
|
|
174
|
+
In all “X” hooks you pass a `WriteExtendedAsyncParams` object:
|
|
149
175
|
|
|
150
176
|
```ts
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
177
|
+
export type WriteExtendedAsyncParams = {
|
|
178
|
+
onSuccess?: (txHash: Address) => void;
|
|
179
|
+
onError?: (e: any) => void;
|
|
180
|
+
onSettled?: () => void;
|
|
181
|
+
onSuccessAsync?: (txHash: Address) => Promise<void>;
|
|
182
|
+
onErrorAsync?: (e: any) => Promise<void>;
|
|
183
|
+
onSettledAsync?: () => Promise<void>;
|
|
184
|
+
|
|
185
|
+
/** simple list of query keys to invalidate after receipt */
|
|
186
|
+
queriesToInvalidate?: (QueryKey | undefined)[];
|
|
187
|
+
|
|
188
|
+
/** predicate-based invalidation:
|
|
189
|
+
any active query where `predicate(query)` returns true
|
|
190
|
+
will be invalidated after the tx settles. */
|
|
191
|
+
invalidatePredicate?: (query: Query<unknown, unknown>) => boolean;
|
|
192
|
+
|
|
193
|
+
disableLogging?: boolean;
|
|
194
|
+
disableWaitingForReceipt?: boolean;
|
|
195
|
+
};
|
|
156
196
|
```
|
|
157
197
|
|
|
158
|
-
|
|
198
|
+
---
|
|
199
|
+
|
|
200
|
+
### useFetchERC4626DataX Hook
|
|
201
|
+
|
|
202
|
+
Fetch summary data from an ERC-4626 vault (total assets, shares, allowances, balances, etc.):
|
|
159
203
|
|
|
160
204
|
```ts
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
})
|
|
205
|
+
import { useFetchERC4626DataX } from "wagmi-extended";
|
|
206
|
+
|
|
207
|
+
function VaultInfo({ vaultAddress, user, spender }) {
|
|
208
|
+
const { data, isLoading, error } = useFetchERC4626DataX({
|
|
209
|
+
vault,
|
|
210
|
+
user,
|
|
211
|
+
spender,
|
|
212
|
+
});
|
|
213
|
+
|
|
214
|
+
if (isLoading) return <p>Loading vault data…</p>;
|
|
215
|
+
if (error) return <p>Error: {error.message}</p>;
|
|
216
|
+
|
|
217
|
+
return (
|
|
218
|
+
<div>
|
|
219
|
+
<p>Total assets: {data.totalAssets}</p>
|
|
220
|
+
<p>Current shares: {data.shares}</p>
|
|
221
|
+
<p>Your balance: {data.userBalance}</p>
|
|
222
|
+
<p>Your allowance: {data.allowance}</p>
|
|
223
|
+
</div>
|
|
224
|
+
);
|
|
225
|
+
}
|
|
164
226
|
```
|
|
165
227
|
|
|
166
|
-
|
|
228
|
+
---
|
|
167
229
|
|
|
168
|
-
###
|
|
230
|
+
### useFetchERC20DataX Hook
|
|
231
|
+
|
|
232
|
+
Fetch summary data for a generic ERC-20 token (decimals, name, symbol, balances, allowances):
|
|
233
|
+
|
|
234
|
+
```ts
|
|
235
|
+
import { useFetchERC20DataX } from "wagmi-extended";
|
|
169
236
|
|
|
170
|
-
|
|
237
|
+
function TokenInfo({ token, user, spender }) {
|
|
238
|
+
const { data, isLoading, error } = useFetchERC20DataX({
|
|
239
|
+
address: token,
|
|
240
|
+
user,
|
|
241
|
+
spender,
|
|
242
|
+
});
|
|
171
243
|
|
|
172
|
-
|
|
244
|
+
if (isLoading) return <p>Loading token info…</p>;
|
|
245
|
+
if (error) return <p>Error: {error.message}</p>;
|
|
246
|
+
|
|
247
|
+
return (
|
|
248
|
+
<div>
|
|
249
|
+
<p>Name: {data.name}</p>
|
|
250
|
+
<p>Symbol: {data.symbol}</p>
|
|
251
|
+
<p>Decimals: {data.decimals}</p>
|
|
252
|
+
<p>Your balance: {data.balance}</p>
|
|
253
|
+
<p>Your allowance: {data.allowance}</p>
|
|
254
|
+
</div>
|
|
255
|
+
);
|
|
256
|
+
}
|
|
257
|
+
```
|
|
173
258
|
|
|
174
259
|
### useTokenX Hook
|
|
175
260
|
|
|
@@ -1,66 +1,30 @@
|
|
|
1
1
|
import { WriteExtendedAsyncParams } from "./useHandleTransactionMutationX.js";
|
|
2
2
|
import { Address } from "viem";
|
|
3
3
|
/**
|
|
4
|
-
* Custom hook for writing to a smart contract using Wagmi.
|
|
4
|
+
* Custom hook for writing to a smart contract using Wagmi with optional simulation.
|
|
5
5
|
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* @param {
|
|
9
|
-
* @param {
|
|
10
|
-
* @param {
|
|
11
|
-
* @param {Function} [settings.
|
|
12
|
-
* @param {
|
|
13
|
-
* @param {Function} [settings.onSettled] - Callback function to be called after the transaction settles (whether success or failure).
|
|
14
|
-
* @param {QueryKey[]} [settings.queriesToInvalidate] - Array of query keys to invalidate after the transaction receives a receipt.
|
|
15
|
-
* @returns {Object} Object containing the following properties:
|
|
16
|
-
* - {boolean} isPending - Indicates whether the transaction is pending.
|
|
17
|
-
* - {string|undefined} errorMessage - The error message, if an error occurred during the transaction.
|
|
18
|
-
* - {Function} writeContractAsync - Function to trigger the write operation.
|
|
19
|
-
*
|
|
20
|
-
/**
|
|
21
|
-
* Custom hook for writing a contract using Wagmi with extended functionality.
|
|
22
|
-
*
|
|
23
|
-
* This hook wraps Wagmi’s `useContractWriteX` with additional handling for
|
|
24
|
-
* waiting for a transaction receipt, logging control, and invalidation of specified queries.
|
|
25
|
-
*
|
|
26
|
-
* @param {WriteExtendedAsyncParams} [settings] - Optional settings for handling the transaction.
|
|
6
|
+
* @param {WriteExtendedAsyncParams} settings - Settings for handling transaction lifecycle:
|
|
7
|
+
* @param {boolean} [settings.disableWaitingForReceipt] - Disable waiting for receipt.
|
|
8
|
+
* @param {boolean} [settings.disableLogging] - Disable logging.
|
|
9
|
+
* @param {Function} [settings.onSuccess] - Callback invoked on successful transaction receipt.
|
|
10
|
+
* @param {Function} [settings.onError] - Callback invoked on simulation or transaction error.
|
|
11
|
+
* @param {Function} [settings.onSettled] - Callback invoked after transaction settles.
|
|
12
|
+
* @param {Array<import('@tanstack/query-core').QueryKey>} [settings.queriesToInvalidate] - Query keys to invalidate after receipt.
|
|
27
13
|
* @returns {Object} An object containing:
|
|
28
|
-
* -
|
|
29
|
-
* -
|
|
30
|
-
* -
|
|
14
|
+
* - writeContract: Wagmi's writeContract function.
|
|
15
|
+
* - writeContractX: Wrapped writeContract with optional simulation.
|
|
16
|
+
* - isPending: Boolean indicating if transaction is in progress.
|
|
17
|
+
* - errorMessage: Error message if one occurred.
|
|
31
18
|
*
|
|
32
19
|
* @example
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
* const handleWrite = async () => {
|
|
40
|
-
* try {
|
|
41
|
-
* const txHash = await writeContractAsync({ transaction params here.. }, {
|
|
42
|
-
* // use calbacks here in writeContractAsync or in useContractWriteX
|
|
43
|
-
* onSuccess: (txHash) => console.log("Transaction successful:", txHash),
|
|
44
|
-
* onError: (error) => console.error("Transaction error:", error),
|
|
45
|
-
* });
|
|
46
|
-
* console.log("Received txHash:", txHash);
|
|
47
|
-
* } catch (err) {
|
|
48
|
-
* console.error("Failed writing transaction:", err);`
|
|
49
|
-
* }
|
|
50
|
-
* };
|
|
51
|
-
*
|
|
52
|
-
* return (
|
|
53
|
-
* <div>
|
|
54
|
-
* <button onClick={handleWrite} disabled={isPending}>
|
|
55
|
-
* {isPending ? "Processing..." : "Write Transaction"}
|
|
56
|
-
* </button>
|
|
57
|
-
* {errorMessage && <p>Error: {errorMessage}</p>}
|
|
58
|
-
* </div>
|
|
59
|
-
* );
|
|
60
|
-
* }
|
|
20
|
+
* const { writeContractX, isPending, errorMessage } = useContractWriteX({ onSuccess: ..., onError: ... });
|
|
21
|
+
* await writeContractX(
|
|
22
|
+
* { abi, address, functionName, args, account, chain, value },
|
|
23
|
+
* disable simulation? = false
|
|
24
|
+
* );
|
|
61
25
|
*/
|
|
62
26
|
export declare function useContractWriteX(settings: WriteExtendedAsyncParams): {
|
|
63
|
-
|
|
27
|
+
writeContractX: (params: Parameters<import("wagmi/query").WriteContractMutate<import("wagmi").Config, void>>[0], disableSimulation?: boolean) => Promise<void>;
|
|
64
28
|
isPending: boolean;
|
|
65
29
|
errorMessage: string | undefined;
|
|
66
30
|
error: null;
|
|
@@ -79,7 +43,7 @@ export declare function useContractWriteX(settings: WriteExtendedAsyncParams): {
|
|
|
79
43
|
writeContract: import("wagmi/query").WriteContractMutate<import("wagmi").Config, void>;
|
|
80
44
|
writeContractAsync: import("wagmi/query").WriteContractMutateAsync<import("wagmi").Config, void>;
|
|
81
45
|
} | {
|
|
82
|
-
|
|
46
|
+
writeContractX: (params: Parameters<import("wagmi/query").WriteContractMutate<import("wagmi").Config, void>>[0], disableSimulation?: boolean) => Promise<void>;
|
|
83
47
|
isPending: boolean;
|
|
84
48
|
errorMessage: string | undefined;
|
|
85
49
|
error: null;
|
|
@@ -223,7 +187,7 @@ export declare function useContractWriteX(settings: WriteExtendedAsyncParams): {
|
|
|
223
187
|
writeContract: import("wagmi/query").WriteContractMutate<import("wagmi").Config, void>;
|
|
224
188
|
writeContractAsync: import("wagmi/query").WriteContractMutateAsync<import("wagmi").Config, void>;
|
|
225
189
|
} | {
|
|
226
|
-
|
|
190
|
+
writeContractX: (params: Parameters<import("wagmi/query").WriteContractMutate<import("wagmi").Config, void>>[0], disableSimulation?: boolean) => Promise<void>;
|
|
227
191
|
isPending: boolean;
|
|
228
192
|
errorMessage: string | undefined;
|
|
229
193
|
error: import("@wagmi/core").WriteContractErrorType;
|
|
@@ -367,7 +331,7 @@ export declare function useContractWriteX(settings: WriteExtendedAsyncParams): {
|
|
|
367
331
|
writeContract: import("wagmi/query").WriteContractMutate<import("wagmi").Config, void>;
|
|
368
332
|
writeContractAsync: import("wagmi/query").WriteContractMutateAsync<import("wagmi").Config, void>;
|
|
369
333
|
} | {
|
|
370
|
-
|
|
334
|
+
writeContractX: (params: Parameters<import("wagmi/query").WriteContractMutate<import("wagmi").Config, void>>[0], disableSimulation?: boolean) => Promise<void>;
|
|
371
335
|
isPending: boolean;
|
|
372
336
|
errorMessage: string | undefined;
|
|
373
337
|
error: null;
|
|
@@ -11,7 +11,6 @@ export type WriteExtendedAsyncParams = {
|
|
|
11
11
|
queriesToInvalidate?: (QueryKey | undefined)[];
|
|
12
12
|
/** a predicate to decide which queries to invalidate */
|
|
13
13
|
invalidatePredicate?: (query: Query<unknown, unknown>) => boolean;
|
|
14
|
-
simulationOverrideAbis?: any;
|
|
15
14
|
disableLogging?: boolean;
|
|
16
15
|
disableWaitingForReceipt?: boolean;
|
|
17
16
|
};
|
|
@@ -1,55 +1,33 @@
|
|
|
1
1
|
import { WriteExtendedAsyncParams } from "./useHandleTransactionMutationX.js";
|
|
2
2
|
import { writeContract } from "wagmi/actions";
|
|
3
3
|
/**
|
|
4
|
-
* Custom hook for sending a transaction using Wagmi.
|
|
4
|
+
* Custom hook for sending a transaction using Wagmi with optional simulation.
|
|
5
5
|
*
|
|
6
|
-
*
|
|
6
|
+
* @param {WriteExtendedAsyncParams} [settings] - Settings for handling transaction lifecycle:
|
|
7
|
+
* @param {boolean} [settings.disableWaitingForReceipt] - Disable waiting for receipt.
|
|
8
|
+
* @param {boolean} [settings.disableLogging] - Disable logging.
|
|
9
|
+
* @param {Function} [settings.onSuccess] - Callback on success.
|
|
10
|
+
* @param {Function} [settings.onError] - Callback on error.
|
|
11
|
+
* @param {Function} [settings.onSettled] - Callback after settlement.
|
|
12
|
+
* @param {Array<import('@tanstack/query-core').QueryKey>} [settings.queriesToInvalidate] - Query keys to invalidate after receipt.
|
|
13
|
+
* @returns {Object} An object containing:
|
|
14
|
+
* - sendTransaction: Wagmi's sendTransaction function.
|
|
15
|
+
* - sendTransactionX: Wrapped sendTransaction with optional simulation.
|
|
16
|
+
* - isPending: Boolean indicating if transaction is in progress.
|
|
17
|
+
* - errorMessage: Error message if one occurred.
|
|
7
18
|
*
|
|
8
|
-
* @param {WriteExtendedAsyncParams} [settings] - Optional settings for the write operation.
|
|
9
|
-
* @param {boolean} [settings.disableWaitingForReceipt] - Disables waiting for the transaction receipt.
|
|
10
|
-
* @param {boolean} [settings.disableLogging] - Disables logging the result of the transaction.
|
|
11
|
-
* @param {Function} [settings.onSuccess] - Callback function to be called on successful transaction.
|
|
12
|
-
* @param {Function} [settings.onError] - Callback function to be called on transaction error.
|
|
13
|
-
* @param {Function} [settings.onSettled] - Callback function to be called after the transaction settles (whether success or failure).
|
|
14
|
-
* @param {QueryKey[]} [settings.queriesToInvalidate] - Array of query keys to invalidate after the transaction receives a receipt.
|
|
15
|
-
* @returns {Object} Object containing the following properties:
|
|
16
|
-
* - {boolean} isPending - Indicates whether the transaction is pending.
|
|
17
|
-
* - {string|undefined} errorMessage - The error message, if an error occurred during the transaction.
|
|
18
|
-
* - {Function} sendTransactionAsync - Function to trigger the send transaction mutation.
|
|
19
|
-
|
|
20
19
|
* @example
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
* onError: (error) => console.error("Transaction error:", error),
|
|
27
|
-
* queriesToInvalidate: [["userBalance"], ["userActivity"]],
|
|
28
|
-
* });
|
|
29
|
-
*
|
|
30
|
-
* const handleSend = async () => {
|
|
31
|
-
* try {
|
|
32
|
-
* const txHash = await sendTransactionAsync({ transaction params here.. });
|
|
33
|
-
* console.log("Received txHash:", txHash);
|
|
34
|
-
* } catch (err) {
|
|
35
|
-
* console.error("Failed sending transaction:", err);`
|
|
36
|
-
* }
|
|
37
|
-
* };
|
|
38
|
-
*
|
|
39
|
-
* return (
|
|
40
|
-
* <div>
|
|
41
|
-
* <button onClick={handleSend} disabled={isPending}>
|
|
42
|
-
* {isPending ? "Processing..." : "Send Transaction"}
|
|
43
|
-
* </button>
|
|
44
|
-
* {errorMessage && <p>Error: {errorMessage}</p>}
|
|
45
|
-
* </div>
|
|
46
|
-
* );
|
|
47
|
-
* }
|
|
20
|
+
* const { sendTransactionX, isPending, errorMessage } = useSendTransactionX({ onSuccess: ..., onError: ... });
|
|
21
|
+
* await sendTransactionX(
|
|
22
|
+
* { to, value, data, account, chain },
|
|
23
|
+
* { abi, functionName, args, chain }
|
|
24
|
+
* );
|
|
48
25
|
*/
|
|
49
26
|
export declare function useSendTransactionX(settings?: WriteExtendedAsyncParams): {
|
|
50
27
|
isPending: boolean;
|
|
51
28
|
errorMessage: string | undefined;
|
|
52
|
-
|
|
29
|
+
sendTransaction: import("wagmi/query").SendTransactionMutate<import("wagmi").Config, void>;
|
|
30
|
+
sendTransactionX: (params: Parameters<import("wagmi/query").SendTransactionMutate<import("wagmi").Config, void>>[0], simulationParams?: Parameters<typeof writeContract>[1]) => Promise<void>;
|
|
53
31
|
error: null;
|
|
54
32
|
status: "idle";
|
|
55
33
|
data: undefined;
|
|
@@ -67,7 +45,8 @@ export declare function useSendTransactionX(settings?: WriteExtendedAsyncParams)
|
|
|
67
45
|
} | {
|
|
68
46
|
isPending: boolean;
|
|
69
47
|
errorMessage: string | undefined;
|
|
70
|
-
|
|
48
|
+
sendTransaction: import("wagmi/query").SendTransactionMutate<import("wagmi").Config, void>;
|
|
49
|
+
sendTransactionX: (params: Parameters<import("wagmi/query").SendTransactionMutate<import("wagmi").Config, void>>[0], simulationParams?: Parameters<typeof writeContract>[1]) => Promise<void>;
|
|
71
50
|
error: null;
|
|
72
51
|
status: "pending";
|
|
73
52
|
data: undefined;
|
|
@@ -85,7 +64,8 @@ export declare function useSendTransactionX(settings?: WriteExtendedAsyncParams)
|
|
|
85
64
|
} | {
|
|
86
65
|
isPending: boolean;
|
|
87
66
|
errorMessage: string | undefined;
|
|
88
|
-
|
|
67
|
+
sendTransaction: import("wagmi/query").SendTransactionMutate<import("wagmi").Config, void>;
|
|
68
|
+
sendTransactionX: (params: Parameters<import("wagmi/query").SendTransactionMutate<import("wagmi").Config, void>>[0], simulationParams?: Parameters<typeof writeContract>[1]) => Promise<void>;
|
|
89
69
|
error: import("wagmi/actions").SendTransactionErrorType;
|
|
90
70
|
status: "error";
|
|
91
71
|
data: undefined;
|
|
@@ -103,7 +83,8 @@ export declare function useSendTransactionX(settings?: WriteExtendedAsyncParams)
|
|
|
103
83
|
} | {
|
|
104
84
|
isPending: boolean;
|
|
105
85
|
errorMessage: string | undefined;
|
|
106
|
-
|
|
86
|
+
sendTransaction: import("wagmi/query").SendTransactionMutate<import("wagmi").Config, void>;
|
|
87
|
+
sendTransactionX: (params: Parameters<import("wagmi/query").SendTransactionMutate<import("wagmi").Config, void>>[0], simulationParams?: Parameters<typeof writeContract>[1]) => Promise<void>;
|
|
107
88
|
error: null;
|
|
108
89
|
status: "success";
|
|
109
90
|
data: `0x${string}`;
|