@tuwaio/pulsar-evm 0.6.0 → 0.7.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.
package/dist/index.d.ts CHANGED
@@ -1,172 +1,301 @@
1
- import { Transaction, TxAdapter, ITxTrackingStore, TrackerCallbacks, PollingTrackerConfig, TransactionTracker, CheckTxTracker } from '@tuwaio/pulsar-core';
1
+ import { Transaction, TxAdapter, EvmTransaction, ITxTrackingStore, TrackerCallbacks, PollingFetcherParams, TransactionTracker, CheckTxTracker } from '@tuwaio/pulsar-core';
2
2
  import { Config } from '@wagmi/core';
3
3
  import { Chain, Hex, GetTransactionReturnType, TransactionReceipt, Client, ReplacementReturnType, WaitForTransactionReceiptParameters, Transport, HttpTransportConfig } from 'viem';
4
4
  import { GetUserOperationReceiptReturnType } from 'viem/account-abstraction';
5
5
 
6
6
  /**
7
- * @file This file contains the factory function for creating the EVM (Ethereum Virtual Machine) transaction adapter.
8
- * This adapter encapsulates all the logic required to interact with EVM-based chains using wagmi.
7
+ * @file The EVM adapter that plugs `@wagmi/core` and `viem` into the Pulsar store.
9
8
  */
10
9
 
11
10
  /**
12
- * Creates an EVM-specific transaction adapter.
11
+ * Creates the EVM adapter for `createPulsarStore` from `@tuwaio/pulsar-core`. Pass it alone or in the adapter array.
12
+ *
13
+ * The adapter implements `TxAdapter` from `@tuwaio/pulsar-core`:
14
+ * - `getConnectorInfo` returns the address of the active wagmi connection (or, without one, the last connected address
15
+ * saved in `localStorage` by `@tuwaio/orbit-core`, then the zero address) and the connector type, e.g. `evm:metamask`.
16
+ * - `checkChainForTx` runs `checkAndSwitchChain` from `@tuwaio/orbit-evm`: when the wallet is on another chain, it asks
17
+ * the wallet to switch and rejects if the user declines.
18
+ * - `checkTransactionsTracker` and `checkAndInitializeTrackerInStore` are {@link checkTransactionsTracker} and
19
+ * {@link checkAndInitializeTrackerInStore}.
20
+ * - `getExplorerUrl(path, chainId)` appends a path to the default block explorer of `chainId` (looked up in
21
+ * `appChains`), or of the chain the wallet is connected to when `chainId` is omitted. It returns `undefined` when that
22
+ * chain has no block explorer. `getExplorerTxUrl` is {@link selectEvmTxExplorerLink} with `appChains`.
23
+ * - `cancelTxAction` and `speedUpTxAction` are {@link cancelTxAction} and {@link speedUpTxAction}; both open a wallet
24
+ * prompt.
25
+ * - `retryTxAction` closes the modal and runs `executeTxAction` again with
26
+ * `tx.actionFunction({ config, ...tx.payload })`; it logs an error and does nothing without `executeTxAction`.
27
+ *
28
+ * @template T - The application transaction type.
29
+ * @param config - The wagmi config of the app.
30
+ * @param appChains - The viem chains of the app, used to build explorer links.
31
+ * @returns The EVM adapter.
32
+ * @throws `Error` when `config` is not provided.
13
33
  *
14
- * This function acts as a constructor for the EVM adapter, bundling all the necessary
15
- * chain-specific utilities (like checking chain, ENS resolution, speeding up transactions, etc.)
16
- * into a single object that conforms to the `TxAdapter` interface.
17
- *
18
- * @template T - The application-specific transaction type.
19
- * @param {Config} config - The wagmi configuration object.
20
- * @param {Chain[]} appChains - An array of viem `Chain` objects supported by the application.
21
- *
22
- * @returns {TxAdapter<T>} The configured EVM transaction adapter.
34
+ * @example
35
+ * ```ts
36
+ * import { createPulsarStore } from '@tuwaio/pulsar-core';
37
+ * import { pulsarEvmAdapter } from '@tuwaio/pulsar-evm';
38
+ * import { mainnet, sepolia } from 'viem/chains';
23
39
  *
24
- * @throws {Error} Throws an error if the wagmi `config` is not provided.
40
+ * const pulsarStore = createPulsarStore({
41
+ * name: 'transactions-tracking-storage',
42
+ * adapter: pulsarEvmAdapter(wagmiConfig, [mainnet, sepolia]),
43
+ * });
44
+ * ```
25
45
  */
26
46
  declare function pulsarEvmAdapter<T extends Transaction>(config: Config, appChains: readonly [Chain, ...Chain[]]): TxAdapter<T>;
27
47
 
28
48
  /**
29
- * @file This file implements transaction tracking for ERC-4337 UserOperations.
30
- * It uses a polling mechanism against a Bundler RPC endpoint (e.g., Pimlico)
31
- * to check the status of a UserOperation via `eth_getUserOperationReceipt`.
49
+ * @file The tracker for ERC-4337 UserOperations. It polls `eth_getUserOperationReceipt` on a bundler RPC (a custom
50
+ * `bundlerUrl` or Pimlico) and, once the UserOperation is bundled, tracks the bundle transaction on-chain.
32
51
  */
33
52
 
34
53
  /**
35
- * The receipt returned by `getUserOperationReceipt`.
54
+ * The UserOperation receipt returned by viem's `getUserOperationReceipt`.
36
55
  */
37
56
  type Erc4337UserOpReceipt = GetUserOperationReceiptReturnType;
38
57
  /**
39
- * Result structure produced by `erc4337Fetcher` on each polling cycle.
58
+ * The result {@link erc4337Fetcher} reports on each polling tick.
40
59
  */
41
60
  type Erc4337FetchResult = {
61
+ /** The UserOperation receipt, or `null` while it is not available. */
42
62
  receipt: Erc4337UserOpReceipt | null;
63
+ /** `pending` while the UserOperation is not bundled, then `success` or `failed`. */
43
64
  status: 'pending' | 'success' | 'failed';
65
+ /** The hash of the bundle transaction that included the UserOperation, once known. */
44
66
  hash?: Hex;
67
+ /** The failure reason: the revert reason of the receipt, or a validation message. */
45
68
  reason?: string;
46
69
  };
47
- type Erc4337FetcherParams<T extends Transaction> = Parameters<PollingTrackerConfig<Erc4337FetchResult, T>['fetcher']>[0];
48
70
  /**
49
- * Low-level fetcher for ERC-4337 UserOperation status.
50
- * Queries `eth_getUserOperationReceipt` on the configured Bundler client.
71
+ * The transaction fields {@link erc4337Fetcher} reads: the `userOpHash` as `txKey`, the numeric `chainId`, and either a
72
+ * custom `bundlerUrl` or a `pimlicoApiKey` (without both, the public Pimlico endpoint is used).
73
+ */
74
+ type Erc4337FetcherTx = Pick<Transaction, 'txKey' | 'chainId'> & Pick<EvmTransaction, 'pimlicoApiKey' | 'bundlerUrl'>;
75
+ /**
76
+ * A fetcher for `initializePollingTracker` from `@tuwaio/pulsar-core` that checks a UserOperation once through
77
+ * `eth_getUserOperationReceipt`.
78
+ *
79
+ * The bundler client comes from `createBundlerRpcClient` of `@tuwaio/orbit-evm`, which caches it in memory and
80
+ * contacts `tx.bundlerUrl`, else `api.pimlico.io` with `tx.pimlicoApiKey`, else the rate-limited `public.pimlico.io`.
81
+ *
82
+ * - Invalid `chainId`: stops polling (keeping the transaction) and calls `onFailure` with a reason.
83
+ * - Receipt not available yet: calls `onIntervalTick` with `status: 'pending'`.
84
+ * - Receipt with `success: true`: stops polling (keeping the transaction) and calls `onSuccess` with the bundle `hash`.
85
+ * - Receipt with `success: false`: stops polling (keeping the transaction) and calls `onFailure` with the revert reason.
86
+ * - Any other error is rethrown, so the polling tracker counts it as a failed attempt.
51
87
  *
52
- * @param params - The fetcher parameters provided by the polling tracker.
88
+ * @template T - The tracked transaction type.
89
+ * @param params - The fetcher parameters provided by `initializePollingTracker`.
90
+ * @returns A promise that resolves when the check is done.
53
91
  */
54
- declare function erc4337Fetcher<T extends Transaction>({ tx, stopPolling, onSuccess, onFailure, onIntervalTick, }: Erc4337FetcherParams<T>): Promise<void>;
92
+ declare function erc4337Fetcher<T extends Erc4337FetcherTx>({ tx, stopPolling, onSuccess, onFailure, onIntervalTick, }: PollingFetcherParams<Erc4337FetchResult, T>): Promise<void>;
55
93
  /**
56
- * Configuration options for the low-level ERC-4337 tracker.
94
+ * The configuration of {@link erc4337Tracker}.
95
+ *
96
+ * @template T - The tracked transaction type.
57
97
  */
58
- type Erc4337TrackerConfig<T extends Transaction> = {
59
- tx: T & Pick<Transaction, 'txKey' | 'pending'>;
98
+ type Erc4337TrackerConfig<T extends Erc4337FetcherTx & Pick<Transaction, 'pending'>> = {
99
+ /** The UserOperation to track (see {@link Erc4337FetcherTx}); polling starts only if `pending` is `true`. */
100
+ tx: T;
101
+ /**
102
+ * Called when the UserOperation succeeded.
103
+ * @param result - The result; `hash` is the bundle transaction hash.
104
+ */
60
105
  onSuccess: (result: Erc4337FetchResult) => void;
106
+ /**
107
+ * Called when the UserOperation reverted or the chain ID is invalid, and without arguments after `maxRetries`
108
+ * consecutive failed attempts.
109
+ * @param result - The result with the failure `reason`, if any.
110
+ */
61
111
  onFailure: (result?: Erc4337FetchResult) => void;
112
+ /**
113
+ * Called on every tick while the UserOperation is not bundled.
114
+ * @param result - The pending result.
115
+ */
62
116
  onIntervalTick?: (result: Erc4337FetchResult) => void;
117
+ /**
118
+ * Called when polling stops after `maxRetries` consecutive failed attempts.
119
+ * @param txKey - The `userOpHash`.
120
+ */
63
121
  removeTxFromPool?: (txKey: string) => void;
122
+ /** The delay before each attempt, in milliseconds. Defaults to 2000. */
64
123
  pollingInterval?: number;
124
+ /** The number of consecutive failed attempts after which polling stops. Defaults to 60. */
65
125
  maxRetries?: number;
66
126
  };
67
127
  /**
68
- * Initializes a low-level polling tracker for ERC-4337 UserOperations.
128
+ * Starts polling a UserOperation in the background with {@link erc4337Fetcher}, without a store: every 2 s by default,
129
+ * giving up after 60 consecutive failed attempts. It only follows the bundler; it does not wait for block
130
+ * confirmations of the bundle transaction (pass `onSuccess`'s `hash` to {@link evmTracker} for that).
131
+ *
132
+ * @template T - The tracked transaction type.
133
+ * @param config - The UserOperation and the callbacks.
69
134
  *
70
- * @param config - The tracker configuration options.
135
+ * @example
136
+ * ```ts
137
+ * erc4337Tracker({
138
+ * tx: { txKey: userOpHash, chainId: 11155111, pimlicoApiKey, pending: true },
139
+ * onSuccess: ({ hash }) => console.log('Bundled in', hash),
140
+ * onFailure: (result) => console.error('UserOperation failed', result?.reason),
141
+ * });
142
+ * ```
71
143
  */
72
- declare function erc4337Tracker<T extends Transaction>(config: Erc4337TrackerConfig<T>): void;
144
+ declare function erc4337Tracker<T extends Erc4337FetcherTx & Pick<Transaction, 'pending'>>(config: Erc4337TrackerConfig<T>): void;
73
145
  /**
74
- * Parameters for the store-connected ERC-4337 tracker.
146
+ * The parameters of {@link erc4337TrackerForStore}: the transaction, an optional wagmi config, the store members used
147
+ * by trackers and the callbacks.
148
+ *
149
+ * @template T - The application transaction type.
75
150
  */
76
151
  type Erc4337TrackerForStoreParams<T extends Transaction> = Pick<ITxTrackingStore<T>, 'updateTxParams' | 'removeTxFromPool' | 'transactionsPool'> & {
152
+ /** The transaction to track; `txKey` is the `userOpHash`. */
77
153
  tx: T;
154
+ /** The wagmi config, used for the on-chain stage. Without it, the transaction succeeds as soon as it is bundled. */
78
155
  config?: Config;
79
156
  } & TrackerCallbacks<T>;
80
157
  /**
81
- * High-level two-stage tracker for ERC-4337 UserOperations integrated with the Pulsar store.
158
+ * Tracks an ERC-4337 UserOperation of the Pulsar store in two stages and writes the results to the store:
82
159
  *
83
- * - Stage 1 (Bundler Mempool): Polls `eth_getUserOperationReceipt` against the Bundler RPC.
84
- * As soon as the UserOp is bundled on-chain, writes `tx.hash` to the store and stops Bundler polling
85
- * without evicting the transaction from the pool.
86
- * - Stage 2 (EVM On-Chain Finality): Hands off tracking to `evmTracker` for on-chain block confirmations,
87
- * block timestamp resolution, and final terminal status update.
160
+ * 1. Bundler: polls {@link erc4337Fetcher} every 2 s (up to 60 consecutive failed attempts). When the UserOperation
161
+ * is bundled, writes the bundle transaction `hash`. A reverted UserOperation, or 60 failed attempts, marks the
162
+ * transaction `Failed`.
163
+ * 2. On-chain: runs {@link evmTracker} for the bundle transaction and writes the details, confirmations and the final
164
+ * `Success`, `Failed` or `Replaced` status. Without `config`, the transaction is marked `Success` as soon as it is
165
+ * bundled.
88
166
  *
89
- * Supports seamless session restoration across page reloads: if `tx.hash` is already populated,
90
- * Stage 1 is bypassed and tracking resumes directly at Stage 2.
167
+ * If `tx.hash` is already set (tracking resumed after a reload), stage 1 is skipped. The transaction is never removed
168
+ * from the pool. The callbacks receive the transaction with every update written by the tracker.
91
169
  *
92
- * @param params - The store actions, Wagmi config, and transaction object to track.
170
+ * @template T - The application transaction type.
171
+ * @param params - The transaction, the wagmi config, the store members and the callbacks.
172
+ * @returns A promise that resolves once stage 1 has started, or when stage 2 has finished if it started directly.
93
173
  */
94
174
  declare function erc4337TrackerForStore<T extends Transaction>({ tx, config, updateTxParams, transactionsPool, onSuccess, onError, onReplaced, }: Erc4337TrackerForStoreParams<T>): Promise<void>;
95
175
 
96
176
  /**
97
- * @file This file contains the tracker implementation for standard EVM transactions.
98
- * It uses viem's public actions (`getTransaction`, `waitForTransactionReceipt`) to monitor
99
- * a transaction's lifecycle from submission to finality with robust timeout handling.
177
+ * @file The tracker for standard EVM transactions. It uses viem actions (`getTransaction`,
178
+ * `waitForTransactionReceipt`, `getTransactionConfirmations`, `getBlock`) through the wagmi client of the chain.
100
179
  */
101
180
 
102
181
  /**
103
- * Checks whether an error during receipt polling is transient (RPC network glitch, timeout, or unindexed tx).
104
- * Recursively inspects nested error causes to handle wrapped Viem transport errors.
182
+ * Checks whether an error thrown while waiting for a receipt is transient: a receipt timeout or "not found" error, an
183
+ * HTTP or WebSocket transport error, or a message about a timeout, rate limit, connection reset or a 502/503/504
184
+ * status. Nested `cause` errors are checked too.
105
185
  *
106
- * @param error - The caught error object.
107
- * @returns `true` if the error is considered transient and retryable; otherwise `false`.
186
+ * @param error - The caught error.
187
+ * @returns `true` if waiting for the receipt should be retried.
108
188
  */
109
189
  declare function isRetryableReceiptError(error: unknown): boolean;
110
190
  /**
111
- * Defines the parameters for the low-level EVM transaction tracker.
191
+ * The configuration of {@link evmTracker}.
112
192
  */
113
193
  type EVMTrackerParams = {
114
- /** The transaction identity parameters (chainId, txKey, requiredConfirmations). */
194
+ /**
195
+ * The transaction: its hash (`txKey`), its numeric `chainId` (which must be configured in `config`) and, optionally,
196
+ * the number of confirmations to wait for.
197
+ */
115
198
  tx: Pick<Transaction, 'chainId' | 'txKey' | 'requiredConfirmations'>;
116
- /** The `@wagmi/core` configuration instance used to resolve network clients. */
199
+ /** The wagmi config; the tracker uses its client for `tx.chainId`. */
117
200
  config: Config;
118
- /** Callback fired once transaction details (nonce, input, values) are successfully fetched. */
201
+ /**
202
+ * Called once with the result of `getTransaction`.
203
+ * @param txDetails - The transaction: nonce, fees, `to`, `value`, `input`.
204
+ */
119
205
  onTxDetailsFetched: (txDetails: GetTransactionReturnType) => void;
120
- /** Callback fired when the transaction is mined successfully (or reverted on-chain). */
206
+ /**
207
+ * Called and awaited once the receipt is available and the required confirmations are reached. Also called for
208
+ * reverted transactions: check `receipt.status`.
209
+ * @param txDetails - The result of `getTransaction`.
210
+ * @param receipt - The transaction receipt.
211
+ * @param client - The viem client of the chain, for further RPC calls.
212
+ */
121
213
  onSuccess: (txDetails: GetTransactionReturnType, receipt: TransactionReceipt, client: Client) => Promise<void>;
122
- /** Callback fired when the transaction has been replaced (repriced or cancelled). */
214
+ /**
215
+ * Called when viem detects that another transaction with the same nonce replaced this one (speed-up or cancel).
216
+ * @param replacement - viem's replacement data: the `reason` and the replacing `transaction`.
217
+ */
123
218
  onReplaced: (replacement: ReplacementReturnType) => void;
124
- /** Callback fired when tracking fails fatally or exceeds all retry attempts. */
219
+ /**
220
+ * Called once when tracking gives up (see {@link evmTracker}).
221
+ * @param error - The last error.
222
+ */
125
223
  onFailure: (error?: unknown) => void;
126
- /** Optional callback fired when tracker initialization starts. */
224
+ /** Called once, before anything else. */
127
225
  onInitialize?: () => void;
128
- /** Number of retries for the initial `getTransaction` fetch step. Defaults to 10. */
226
+ /** Number of `getTransaction` attempts. Defaults to 10. */
129
227
  retryCount?: number;
130
- /** Timeout in milliseconds between `getTransaction` retry attempts. Defaults to 3000ms. */
228
+ /** Delay between `getTransaction` attempts, in milliseconds. Defaults to 3000. */
131
229
  retryTimeout?: number;
132
- /** Optional callback fired whenever required block confirmation count updates. */
230
+ /**
231
+ * Called while waiting for `requiredConfirmations` (only when it is above 1).
232
+ * @param confirmations - The current number of confirmations.
233
+ */
133
234
  onConfirmationsUpdate?: (confirmations: number) => void;
134
- /** Optional custom parameters passed directly to viem's `waitForTransactionReceipt`. */
235
+ /**
236
+ * Options for viem's `waitForTransactionReceipt`, merged over the defaults (`retryCount: 10`, `retryDelay: 3000`,
237
+ * `timeout: 60000`).
238
+ */
135
239
  waitForTransactionReceiptParams?: WaitForTransactionReceiptParameters;
136
240
  };
137
241
  /**
138
- * A low-level tracker for monitoring a standard EVM transaction by its hash.
139
- * Retries fetching transaction details and gracefully polls for transaction receipt,
140
- * recovering automatically from RPC network glitches and timeout errors.
242
+ * Tracks a standard EVM transaction by its hash, without a store. Use it to track transactions in your own state or on
243
+ * a server.
244
+ *
245
+ * Steps (all RPC calls go through the wagmi client of `tx.chainId`):
246
+ * 1. Calls `onInitialize`. Fails at once for the zero hash or when there is no client for the chain.
247
+ * 2. Calls `getTransaction` up to `retryCount` times, `retryTimeout` ms apart, so a transaction the node has not
248
+ * indexed yet is still found; then calls `onTxDetailsFetched`.
249
+ * 3. Waits for the receipt with `waitForTransactionReceipt`, retrying up to 5 times (5, 10, 15, 20 and 25 s apart) when
250
+ * {@link isRetryableReceiptError} matches. If viem reports a replacement, calls `onReplaced` and stops.
251
+ * 4. If `requiredConfirmations` is above 1, polls `getTransactionConfirmations` every 5 s until it is reached.
252
+ * 5. Awaits `onSuccess`, also for reverted transactions.
141
253
  *
142
- * @param params - The configuration parameters and lifecycle callbacks for the EVM tracker.
143
- * @returns A promise that resolves when tracking completes or fails fatally.
254
+ * Any other error, including one thrown by `onSuccess`, is passed to `onFailure`.
255
+ *
256
+ * @param params - The transaction, the wagmi config and the callbacks.
257
+ * @returns A promise that resolves when tracking has finished.
258
+ *
259
+ * @example
260
+ * ```ts
261
+ * await evmTracker({
262
+ * config: wagmiConfig,
263
+ * tx: { txKey: hash, chainId: 1, requiredConfirmations: 2 },
264
+ * onTxDetailsFetched: (details) => console.log('Nonce', details.nonce),
265
+ * onSuccess: async (_details, receipt) => console.log('Mined with status', receipt.status),
266
+ * onReplaced: (replacement) => console.log('Replaced by', replacement.transaction.hash),
267
+ * onFailure: (error) => console.error('Tracking failed', error),
268
+ * });
269
+ * ```
144
270
  */
145
271
  declare function evmTracker(params: EVMTrackerParams): Promise<void>;
146
272
  /**
147
- * A higher-level wrapper for `evmTracker` that integrates directly with the Pulsar store.
148
- * Updates transaction lifecycle states (pending, success, failed, replaced) in the Zustand store.
273
+ * Runs {@link evmTracker} for a transaction of the Pulsar store and writes the results to it through
274
+ * `updateTxParams`: `hash` at start, the transaction details, `confirmations`, and finally `status` `Success`/`Failed`
275
+ * with `pending: false` and the block timestamp, `Replaced` with `replacedTxHash`, or `Failed` with the normalized
276
+ * error. The transaction is never removed from the pool.
149
277
  *
150
- * @template T - The application-specific transaction state structure extending `Transaction`.
151
- * @param params - Configuration connecting `@wagmi/core`, store mutation methods, target transaction, and callbacks.
152
- * @returns A promise that resolves when transaction tracking finishes and store state is committed.
278
+ * The callbacks receive the transaction with every update written by the tracker (`createTxUpdater` from
279
+ * `@tuwaio/pulsar-core`). A reverted transaction calls `onError` with `Error('Transaction reverted')`.
280
+ *
281
+ * @template T - The application transaction type.
282
+ * @param params - The transaction, the wagmi config, the store members and the callbacks.
283
+ * @returns A promise that resolves when tracking has finished.
153
284
  */
154
285
  declare function evmTrackerForStore<T extends Transaction>(params: Pick<EVMTrackerParams, 'config'> & Pick<ITxTrackingStore<T>, 'updateTxParams' | 'transactionsPool'> & {
155
286
  tx: T;
156
287
  } & TrackerCallbacks<T>): Promise<void>;
157
288
 
158
289
  /**
159
- * @file This file implements the transaction tracking logic for meta-transactions relayed via the Gelato Network.
160
- * It uses a polling mechanism to check the status of a Gelato task via the authenticated Gelato RPC client.
161
- *
162
- * The fetcher calls `relayer_getStatus` on the Gelato RPC endpoint and interprets the numeric
163
- * status codes to determine whether a task is still pending, succeeded, was rejected, or reverted.
290
+ * @file The deprecated tracker for Gelato relay tasks. It polls `relayer_getStatus` on the Gelato RPC endpoint and maps
291
+ * the numeric status codes to Pulsar statuses.
164
292
  */
165
293
 
166
294
  /**
167
295
  * Numeric status codes returned by the Gelato `relayer_getStatus` RPC method.
168
296
  *
169
- * @see https://docs.gelato.cloud/
297
+ * @deprecated Gelato relay is deprecated. Use `TransactionTracker.ERC4337` instead.
298
+ * @see {@link https://docs.gelato.cloud/ Gelato documentation}
170
299
  */
171
300
  declare enum GelatoStatusCode {
172
301
  /** The task has been received and is awaiting execution. */
@@ -181,7 +310,9 @@ declare enum GelatoStatusCode {
181
310
  Reverted = 500
182
311
  }
183
312
  /**
184
- * Common fields shared by all Gelato task status responses.
313
+ * Fields shared by every Gelato task status response.
314
+ *
315
+ * @deprecated Gelato relay is deprecated. Use `TransactionTracker.ERC4337` instead.
185
316
  */
186
317
  type GelatoBaseStatus = {
187
318
  /** The chain ID on which the task was submitted. */
@@ -192,8 +323,9 @@ type GelatoBaseStatus = {
192
323
  id: string;
193
324
  };
194
325
  /**
195
- * Discriminated union representing all possible Gelato task status responses.
196
- * Each variant corresponds to a specific {@link GelatoStatusCode}.
326
+ * A Gelato task status response, discriminated by `status` ({@link GelatoStatusCode}).
327
+ *
328
+ * @deprecated Gelato relay is deprecated. Use `TransactionTracker.ERC4337` instead.
197
329
  */
198
330
  type GelatoTaskStatus = (GelatoBaseStatus & {
199
331
  status: GelatoStatusCode.Pending;
@@ -218,114 +350,148 @@ type GelatoTaskStatus = (GelatoBaseStatus & {
218
350
  };
219
351
  });
220
352
  /**
221
- * Creates a reusable fetcher function for `initializePollingTracker` that queries the
222
- * Gelato RPC endpoint (`relayer_getStatus`) for a task's status using an authenticated client.
353
+ * Creates a fetcher for `initializePollingTracker` from `@tuwaio/pulsar-core` that checks a Gelato task (`tx.txKey`)
354
+ * once through `relayer_getStatus`.
223
355
  *
224
- * The fetcher interprets the numeric status codes and calls the appropriate polling callbacks:
225
- * - {@link GelatoStatusCode.Success} → `onSuccess`
226
- * - {@link GelatoStatusCode.Rejected} / {@link GelatoStatusCode.Reverted} → `onFailure`
227
- * - {@link GelatoStatusCode.Submitted} → `onIntervalTick` (to update the tx hash)
356
+ * On every tick it calls `onIntervalTick` with the status. {@link GelatoStatusCode.Success} calls `onSuccess`;
357
+ * {@link GelatoStatusCode.Rejected} and {@link GelatoStatusCode.Reverted} call `onFailure`; both stop polling and keep
358
+ * the transaction. A task still pending one hour after `createdAt` calls `onFailure` with its status and stops polling,
359
+ * keeping the transaction. Request errors are thrown, so the polling tracker counts them as failed attempts.
228
360
  *
229
- * @deprecated Gelato relay is deprecated. Use TransactionTracker.ERC4337 and erc4337Fetcher instead.
230
- * @param {ReturnType<Transport>} client - A viem transport client configured for the Gelato API.
231
- * @returns {PollingTrackerConfig<GelatoTaskStatus, Transaction>['fetcher']} The fetcher function.
361
+ * @deprecated Gelato relay is deprecated. Use `TransactionTracker.ERC4337` and {@link erc4337Fetcher} instead.
362
+ * @param client - A transport created by {@link createGelatoClient}.
363
+ * @returns The fetcher.
232
364
  */
233
- declare function gelatoFetcher(client: ReturnType<Transport>): PollingTrackerConfig<GelatoTaskStatus, Transaction>['fetcher'];
365
+ declare function gelatoFetcher(client: ReturnType<Transport>): (params: PollingFetcherParams<GelatoTaskStatus, Pick<Transaction, 'txKey'>>) => Promise<void>;
234
366
  /**
235
- * @deprecated Gelato relay is deprecated. Use TransactionTracker.ERC4337 and erc4337TrackerForStore instead.
236
- * A higher-level wrapper that integrates the Gelato polling logic with the Pulsar store.
237
- * It creates an authenticated Gelato RPC client and uses {@link gelatoFetcher} to
238
- * build the fetcher, then delegates to `initializePollingTracker` with store-specific callbacks.
367
+ * Tracks a Gelato task of the Pulsar store with {@link gelatoFetcher} (every 5 s, up to 10 consecutive failed
368
+ * attempts) and writes the results to the store: the transaction `hash` once the task is submitted, then `Success` or
369
+ * `Failed` with the local time as `finishedTimestamp`.
239
370
  *
240
- * @template T - The application-specific transaction type.
371
+ * When tracking gives up (10 consecutive failed attempts, or the task still pending after one hour), the transaction
372
+ * is marked `Failed` and stays in the pool.
241
373
  *
242
- * @param params.tx - The transaction to track.
243
- * @param params.gelatoApiKey - The Gelato API key for authenticating RPC requests.
244
- * @param params.updateTxParams - Store action to update transaction fields.
245
- * @param params.removeTxFromPool - Store action to remove a transaction from the pool.
246
- * @param params.transactionsPool - The current pool of tracked transactions.
247
- * @param params.onSuccess - Optional callback invoked when the transaction succeeds.
248
- * @param params.onError - Optional callback invoked when the transaction fails.
374
+ * Side effects: sends requests to the Gelato API with `gelatoApiKey` (see {@link createGelatoClient}). The callbacks
375
+ * receive the transaction with every update written by the tracker.
376
+ *
377
+ * @deprecated Gelato relay is deprecated. Use `TransactionTracker.ERC4337` and {@link erc4337TrackerForStore} instead.
378
+ * @template T - The application transaction type.
379
+ * @param params - The transaction, the Gelato API key, the store members and the callbacks.
380
+ * @param params.tx - The transaction to track; `txKey` is the Gelato task ID.
381
+ * @param params.gelatoApiKey - The Gelato API key.
382
+ * @param params.updateTxParams - The store's `updateTxParams`.
383
+ * @param params.removeTxFromPool - Not used: failed transactions stay in the pool.
384
+ * @param params.transactionsPool - The store's pool when tracking starts.
385
+ * @param params.onSuccess - Called when the task succeeded.
386
+ * @param params.onError - Called when the task failed or tracking gave up.
249
387
  */
250
- declare function gelatoTrackerForStore<T extends Transaction>({ tx, gelatoApiKey, updateTxParams, removeTxFromPool, transactionsPool, onSuccess, onError, }: Pick<ITxTrackingStore<T>, 'updateTxParams' | 'removeTxFromPool' | 'transactionsPool'> & {
388
+ declare function gelatoTrackerForStore<T extends Transaction>({ tx, gelatoApiKey, updateTxParams, transactionsPool, onSuccess, onError, }: Pick<ITxTrackingStore<T>, 'updateTxParams' | 'removeTxFromPool' | 'transactionsPool'> & {
251
389
  tx: T;
252
390
  gelatoApiKey: string;
253
391
  } & TrackerCallbacks<T>): void;
254
392
  /**
255
- * @deprecated Gelato relay is deprecated. Use TransactionTracker.ERC4337 and erc4337Tracker instead.
393
+ * Alias of {@link gelatoTrackerForStore}.
394
+ *
395
+ * @deprecated Gelato relay is deprecated. Use `TransactionTracker.ERC4337` and {@link erc4337TrackerForStore} instead.
256
396
  */
257
397
  declare const gelatoTracker: typeof gelatoTrackerForStore;
258
398
 
259
399
  /**
260
- * @file This file implements the transaction tracking logic for Safe (formerly Gnosis Safe) multisig transactions.
261
- * It uses a polling mechanism to query the Safe Transaction Service API for the status of a `safeTxHash`.
400
+ * @file The tracker for Safe multisig transactions. It polls the Safe Transaction Service API for the status of a
401
+ * `safeTxHash`.
262
402
  */
263
403
 
264
404
  /**
265
- * Defines the shape of the primary response for a single transaction from the Safe Transaction Service API.
405
+ * The fields of a multisig transaction returned by the Safe Transaction Service API that the Safe tracker reads.
266
406
  */
267
407
  type SafeTxStatusResponse = {
408
+ /** The hash of the executed on-chain transaction, or `null` before execution. */
268
409
  transactionHash: Hex | null;
410
+ /** The Safe transaction hash (the `txKey` of the tracked transaction). */
269
411
  safeTxHash: Hex;
412
+ /** `true` once the multisig transaction has been executed on-chain. */
270
413
  isExecuted: boolean;
414
+ /** Whether the execution succeeded; `null` before execution. */
271
415
  isSuccessful: boolean | null;
416
+ /** ISO date of the execution, or `null` before execution. */
272
417
  executionDate: string | null;
418
+ /** ISO date when the transaction was proposed to the service. */
273
419
  submissionDate: string;
420
+ /** ISO date of the last change. */
274
421
  modified: string;
422
+ /** The Safe nonce of the transaction. */
275
423
  nonce: number;
276
424
  };
277
425
  /**
278
- * A reusable fetcher for `initializePollingTracker` that queries the Safe Transaction Service API.
279
- * It handles the complex logic of detecting executed, failed, and replaced multisig transactions.
426
+ * A fetcher for `initializePollingTracker` from `@tuwaio/pulsar-core` that checks a Safe multisig transaction once
427
+ * through the Safe Transaction Service API of `tx.chainId` ({@link SafeTransactionServiceUrls}). `tx.txKey` is the
428
+ * `safeTxHash` and `tx.from` the Safe address.
429
+ *
430
+ * Requests: `GET <service>/multisig-transactions/<safeTxHash>/`, and while it is not executed,
431
+ * `GET <service>/safes/<from>/multisig-transactions/?nonce=<nonce>`.
432
+ *
433
+ * - Executed: calls `onSuccess` or `onFailure` (by `isSuccessful`) and stops polling, keeping the transaction.
434
+ * - Another transaction with the same nonce was executed: calls `onReplaced` with it and stops polling, keeping the
435
+ * transaction.
436
+ * - Still pending one day after `submissionDate`: calls `onFailure` with the status and stops polling, keeping the
437
+ * transaction.
438
+ * - The service returns 404: calls `onFailure()` without a response and stops polling, keeping the transaction.
439
+ * - An unsupported chain or another failed request throws, so the polling tracker counts it as a failed attempt.
440
+ *
441
+ * @param params - The fetcher parameters provided by `initializePollingTracker`.
442
+ * @returns A promise that resolves when the check is done.
280
443
  */
281
- declare const safeFetcher: PollingTrackerConfig<SafeTxStatusResponse, Transaction>['fetcher'];
444
+ declare const safeFetcher: ({ tx, stopPolling, onSuccess, onFailure, onReplaced, onIntervalTick, }: PollingFetcherParams<SafeTxStatusResponse, Pick<Transaction, "txKey" | "chainId" | "from">>) => Promise<void>;
282
445
  /**
283
- * A higher-level wrapper that integrates the Safe polling logic with the Pulsar store.
284
- * It uses the generic `safeFetcher` and provides store-specific callbacks.
446
+ * Tracks a Safe multisig transaction of the Pulsar store with {@link safeFetcher} (every 5 s, up to 10 consecutive
447
+ * failed attempts) and writes the results to the store: the executed transaction `hash`, then `Success`, `Failed` or
448
+ * `Replaced` (with the `safeTxHash` of the executed transaction as `replacedTxHash`) and the execution date as
449
+ * `finishedTimestamp`.
450
+ *
451
+ * When tracking gives up (10 consecutive failed attempts, a 404 response, or still pending one day after it was
452
+ * proposed), the transaction is marked `Failed` with an error that says why, and it stays in the pool.
285
453
  *
286
- * @template T - The application-specific transaction type.
454
+ * Side effects: sends requests to the Safe Transaction Service. The callbacks receive the transaction with every update
455
+ * written by the tracker.
456
+ *
457
+ * @template T - The application transaction type.
458
+ * @param params - The transaction, the store members and the callbacks.
459
+ * @param params.tx - The transaction to track; `txKey` is the `safeTxHash` and `from` the Safe address.
460
+ * @param params.updateTxParams - The store's `updateTxParams`.
461
+ * @param params.removeTxFromPool - Not used: failed transactions stay in the pool.
462
+ * @param params.transactionsPool - The store's pool when tracking starts.
463
+ * @param params.onSuccess - Called when the transaction was executed successfully.
464
+ * @param params.onError - Called when the execution failed or tracking gave up.
465
+ * @param params.onReplaced - Called when another transaction with the same nonce was executed.
287
466
  */
288
- declare function safeTrackerForStore<T extends Transaction>({ tx, updateTxParams, removeTxFromPool, transactionsPool, onSuccess, onError, onReplaced, }: Pick<ITxTrackingStore<T>, 'updateTxParams' | 'removeTxFromPool' | 'transactionsPool'> & {
467
+ declare function safeTrackerForStore<T extends Transaction>({ tx, updateTxParams, transactionsPool, onSuccess, onError, onReplaced, }: Pick<ITxTrackingStore<T>, 'updateTxParams' | 'removeTxFromPool' | 'transactionsPool'> & {
289
468
  tx: T;
290
469
  } & TrackerCallbacks<T>): void;
291
470
 
292
471
  /**
293
- * @file This file contains a utility function for canceling a pending EVM transaction.
472
+ * @file Cancels a pending EVM transaction by replacing it with a zero-value transaction.
294
473
  */
295
474
 
296
475
  /**
297
- * Cancels a pending EVM transaction by sending a new, zero-value transaction to oneself
298
- * with the same nonce but higher gas fees. This effectively replaces the original transaction.
299
- *
300
- * @template T - The transaction type, which must be a valid EVM transaction.
301
- *
302
- * @param {object} params - The parameters required to cancel the transaction.
303
- * @param {Config} params.config - The wagmi configuration object.
304
- * @param {T} params.tx - The original transaction object to be canceled. It must contain the nonce and gas fee fields.
476
+ * Cancels a pending EVM transaction: asks the connected wallet to send a zero-value transaction to its own address with
477
+ * the same nonce and both EIP-1559 fees raised by 15%. When it is mined, the tracker of the original transaction
478
+ * reports it as `Replaced`; the cancellation transaction itself is not added to the pool.
305
479
  *
306
- * @returns {Promise<Hex>} A promise that resolves with the hash of the new cancellation transaction.
480
+ * Side effects: opens a wallet prompt and broadcasts a transaction.
307
481
  *
308
- * @throws {Error} Throws an error if:
309
- * - The transaction is not an EVM transaction.
310
- * - The transaction is missing required fields (`nonce`, `maxFeePerGas`, etc.).
311
- * - The wagmi config is not provided.
312
- * - No connected account is found.
313
- * - The `sendTransaction` call fails.
482
+ * @template T - The application transaction type.
483
+ * @param params - The wagmi config and the transaction.
484
+ * @param params.config - The wagmi config of the app.
485
+ * @param params.tx - The pending transaction. It must be an EVM transaction with `nonce`, `maxFeePerGas` and
486
+ * `maxPriorityFeePerGas` (set by the EVM tracker once the transaction details are fetched).
487
+ * @returns The hash of the cancellation transaction.
488
+ * @throws `Error` when the transaction is not an EVM transaction or lacks the nonce and fee fields, and
489
+ * `Error('Failed to cancel transaction: …')` (with the original error as `cause`) when no account is connected or the
490
+ * wallet rejects or fails to send the transaction.
314
491
  *
315
492
  * @example
316
493
  * ```ts
317
- * const handleCancel = async (stuckTransaction) => {
318
- * try {
319
- * const cancelTxHash = await cancelTxAction({
320
- * config: wagmiConfig,
321
- * tx: stuckTransaction,
322
- * });
323
- * console.log('Cancellation transaction sent with hash:', cancelTxHash);
324
- * // You should now update your state to track this new transaction.
325
- * } catch (error) {
326
- * console.error('Failed to cancel transaction:', error);
327
- * }
328
- * };
494
+ * const hash = await cancelTxAction({ config: wagmiConfig, tx: pendingTx });
329
495
  * ```
330
496
  */
331
497
  declare function cancelTxAction<T extends Transaction>({ config, tx }: {
@@ -334,179 +500,192 @@ declare function cancelTxAction<T extends Transaction>({ config, tx }: {
334
500
  }): Promise<Hex>;
335
501
 
336
502
  /**
337
- * @file This file contains a utility function that acts as a router to initialize the correct transaction tracker.
338
- * Based on a transaction's `tracker` property, it delegates the tracking task to the appropriate implementation.
503
+ * @file Routes an EVM transaction of the Pulsar store to the tracker named by its `tracker` field.
339
504
  */
340
505
 
341
506
  /**
342
- * The parameters required to initialize a tracker.
343
- * @template T - The application-specific transaction type.
507
+ * The parameters of {@link checkAndInitializeTrackerInStore}.
508
+ *
509
+ * @template T - The application transaction type.
344
510
  */
345
511
  type InitializeTrackerParams<T extends Transaction> = Pick<ITxTrackingStore<T>, 'updateTxParams' | 'removeTxFromPool' | 'transactionsPool'> & {
512
+ /** The wagmi config of the app. */
346
513
  config: Config;
514
+ /** The transaction to track. */
347
515
  tx: T;
516
+ /** The tracker to run, usually `tx.tracker`. */
348
517
  tracker: TransactionTracker;
518
+ /** @deprecated Gelato API key; required to run the Gelato tracker. */
349
519
  gelatoApiKey?: string;
350
520
  } & TrackerCallbacks<T>;
351
521
  /**
352
- * Initializes the appropriate tracker for a given transaction based on its `tracker` type.
353
- * This function acts as a central router, delegating to the specific tracker implementation
354
- * (e.g., standard EVM, Gelato, Safe, or ERC-4337).
522
+ * Starts the tracker named by `tracker` for a transaction of the Pulsar store: {@link evmTrackerForStore},
523
+ * {@link erc4337TrackerForStore}, {@link safeTrackerForStore} or {@link gelatoTrackerForStore}. A Gelato transaction
524
+ * without `gelatoApiKey`, or an unknown tracker, falls back to the standard EVM tracker with a console warning.
525
+ * `pulsarEvmAdapter` uses it as `checkAndInitializeTrackerInStore`.
355
526
  *
356
- * @template T - The application-specific transaction type, extending the base `Transaction`.
357
- * @param {InitializeTrackerParams<T>} params - The parameters for initializing the tracker.
358
- * @returns {Promise<void>} A promise that resolves once the tracking process has been successfully initiated.
527
+ * @template T - The application transaction type.
528
+ * @param params - The tracker, the transaction, the wagmi config, the store members and the callbacks.
529
+ * @returns The promise of the started tracker. For the standard EVM tracker it resolves only when tracking has
530
+ * finished; polling trackers resolve once polling has started.
359
531
  */
360
532
  declare function checkAndInitializeTrackerInStore<T extends Transaction>({ tracker, tx, config, transactionsPool, onSuccess, onError, onReplaced, gelatoApiKey, ...rest }: InitializeTrackerParams<T>): Promise<void>;
361
533
 
362
534
  /**
363
- * @file This file contains a utility to check if the Gelato Relay service is available for a specific chain.
364
- * It uses the authenticated Gelato RPC client to fetch relay capabilities and caches the result.
535
+ * @file Checks whether Gelato Relay supports a chain, using the `relayer_getCapabilities` RPC method.
365
536
  */
366
537
  /**
367
- * Represents the per-chain capabilities returned by the Gelato `relayer_getCapabilities` RPC method.
538
+ * The Gelato Relay capabilities of one chain, as returned by `relayer_getCapabilities`.
368
539
  *
369
- * @property {string} feeCollector - The address of the fee collector contract on this chain.
370
- * @property {GelatoToken[]} tokens - The list of ERC-20 tokens accepted for fee payment on this chain.
540
+ * @deprecated Gelato relay is deprecated. Use `TransactionTracker.ERC4337` instead.
371
541
  */
372
542
  type GelatoCapabilitiesByChain = {
543
+ /** The address of the fee collector contract on this chain. */
373
544
  feeCollector: string;
545
+ /** The ERC-20 tokens accepted for fee payment on this chain. */
374
546
  tokens: GelatoToken[];
375
547
  };
376
548
  /**
377
- * Represents a token accepted for fee payment by the Gelato Relay on a given chain.
549
+ * A token accepted for fee payment by Gelato Relay.
378
550
  *
379
- * @property {string} address - The ERC-20 token contract address.
380
- * @property {number} decimals - The number of decimals for the token.
551
+ * @deprecated Gelato relay is deprecated. Use `TransactionTracker.ERC4337` instead.
381
552
  */
382
553
  type GelatoToken = {
554
+ /** The ERC-20 token contract address. */
383
555
  address: string;
556
+ /** The number of decimals of the token. */
384
557
  decimals: number;
385
558
  };
386
559
  /**
387
- * A record of Gelato relay capabilities keyed by numeric chain ID.
560
+ * Gelato Relay capabilities by numeric chain ID.
561
+ *
562
+ * @deprecated Gelato relay is deprecated. Use `TransactionTracker.ERC4337` instead.
388
563
  */
389
564
  type GelatoCapabilities = Record<number, GelatoCapabilitiesByChain>;
390
565
  /**
391
- * Checks if the Gelato Relay service supports a given chain ID.
566
+ * Checks whether Gelato Relay supports a chain.
392
567
  *
393
- * This function fetches the relay capabilities via the authenticated Gelato RPC client
394
- * (`relayer_getCapabilities`) and checks whether the specified chain is present in the response.
395
- * Results are cached in memory per API key for the lifetime of the application to minimize network requests.
568
+ * Side effects: the first call for an API key sends `relayer_getCapabilities` to the Gelato API (see
569
+ * {@link createGelatoClient}); the result is cached in memory per API key until the page is reloaded. A failed request
570
+ * is logged, is not cached, and returns `false`.
396
571
  *
397
- * @deprecated Gelato relay is deprecated. Use TransactionTracker.ERC4337 instead.
398
- * @param {number} chainId - The chain identifier to check.
399
- * @param {string} gelatoApiKey - The Gelato API key used for authentication.
400
- * @returns {Promise<boolean>} A promise that resolves to `true` if Gelato supports the chain, `false` otherwise.
572
+ * @deprecated Gelato relay is deprecated. Use `TransactionTracker.ERC4337` instead.
573
+ * @param chainId - The chain ID to check.
574
+ * @param gelatoApiKey - The Gelato API key.
575
+ * @returns `true` if the chain is supported; `false` if it is not or the request failed. Never rejects.
401
576
  */
402
577
  declare function checkIsGelatoAvailable(chainId: number, gelatoApiKey: string): Promise<boolean>;
403
578
 
404
579
  /**
405
- * @file This file contains a utility function to determine the correct tracker for a transaction
406
- * based on the key returned by the submission function and the connector type.
580
+ * @file Picks the EVM tracker for the key returned by an `actionFunction`.
407
581
  */
408
582
 
409
583
  /**
410
- * Determines which transaction tracker to use based on the format of the transaction key and the connector type.
584
+ * Picks the tracker for the key returned by an `actionFunction`. The key is always used as `txKey`. Rules, in order:
585
+ * 1. `tracker` is `Gelato` and `gelatoApiKey` is set: `Gelato` (the key is a task ID).
586
+ * 2. The key must be a hex string; otherwise it throws.
587
+ * 3. `tracker` is `ERC4337`: `ERC4337` (the key is a `userOpHash`). ERC-4337 is never detected automatically.
588
+ * 4. The connector type ends with `safe` or `safewallet` (for example `evm:safe`): `Safe` (the key is a `safeTxHash`).
589
+ * 5. Otherwise: `Ethereum`.
411
590
  *
412
- * This function is a critical routing step after a transaction is submitted. It inspects
413
- * the key returned by the `actionFunction` and the connector type to decide the tracking strategy.
414
- * The logic follows a specific priority:
415
- * 1. Checks for a Gelato Task ID structure.
416
- * 2. Checks if the connector type indicates a Safe transaction.
417
- * 3. Defaults to the standard on-chain EVM hash tracker.
591
+ * `bundlerUrl` and `pimlicoApiKey` are not used here. `pulsarEvmAdapter` uses this function as
592
+ * `checkTransactionsTracker`.
418
593
  *
419
- * @param {ActionTxKey} actionTxKey - The key returned from the transaction submission function (e.g., a hash or a Gelato task object).
420
- * @param {string} connectorType - The type of the connector that initiated the action (e.g., 'safe', 'injected').
421
- * @param {TransactionTracker} tracker - The type of transaction tracker to use.
422
- * @param {string} gelatoApiKey - Gelato API key for Gelato relayer integration.
423
- * @returns {{ tracker: TransactionTracker; txKey: string }} An object containing the determined tracker type and the final string-based transaction key.
594
+ * @param params - The returned key and its context (`CheckTxTracker` from `@tuwaio/pulsar-core`).
595
+ * @param params.actionTxKey - The key returned by `actionFunction`.
596
+ * @param params.connectorType - The connector that signed the transaction.
597
+ * @param params.tracker - The tracker requested in the transaction params, if any.
598
+ * @param params.gelatoApiKey - Deprecated Gelato API key.
599
+ * @returns The tracker and the `txKey`.
600
+ * @throws `Error` when the key is not a hex string and the Gelato rule does not apply.
424
601
  *
425
- * @throws {Error} Throws an error if the `actionTxKey` is not a valid Hex string after failing the Gelato check.
602
+ * @example
603
+ * ```ts
604
+ * checkTransactionsTracker({ actionTxKey: '0xabc123', connectorType: 'evm:metamask' });
605
+ * // { tracker: TransactionTracker.Ethereum, txKey: '0xabc123' }
606
+ * ```
426
607
  */
427
608
  declare function checkTransactionsTracker({ actionTxKey, connectorType, tracker, gelatoApiKey }: CheckTxTracker): {
609
+ /** The tracker to use. */
428
610
  tracker: TransactionTracker;
611
+ /** The key to store the transaction under: always `actionTxKey`. */
429
612
  txKey: string;
430
613
  };
431
614
 
432
615
  /**
433
- * @file This file contains a utility function for creating a cached viem HTTP transport
434
- * client configured for the Gelato Relay API.
616
+ * @file Creates a cached viem HTTP transport for the Gelato Relay RPC API.
435
617
  */
436
618
 
437
619
  /**
438
- * Configuration options for creating a Gelato API client.
620
+ * The configuration of {@link createGelatoClient}.
439
621
  *
440
- * @property {string} apiKey - The Gelato API key used for authentication.
441
- * @property {number} [timeout] - Optional custom HTTP timeout in milliseconds. Defaults to 15000ms.
442
- * @property {string} [baseUrl] - Optional custom base URL for the Gelato API. Defaults to `https://api.gelato.cloud/rpc`.
443
- * @property {HttpTransportConfig} [httpTransportConfig] - Optional additional viem HTTP transport configuration overrides.
622
+ * @deprecated Gelato relay is deprecated. Use `TransactionTracker.ERC4337` instead.
444
623
  */
445
624
  type GelatoClientConfig = {
625
+ /** The Gelato API key, sent as a `Bearer` token. */
446
626
  apiKey: string;
627
+ /** HTTP timeout in milliseconds. Defaults to 15000. */
447
628
  timeout?: number;
629
+ /** The base URL of the Gelato API; `/rpc` is appended. Defaults to `https://api.gelato.cloud`. */
448
630
  baseUrl?: string;
631
+ /** Additional options for viem's `http` transport. Its `timeout` overrides `timeout`. */
449
632
  httpTransportConfig?: HttpTransportConfig;
450
633
  };
451
634
  /**
452
- * Creates or retrieves a cached viem HTTP transport client configured for the Gelato Relay API.
635
+ * Creates a viem HTTP transport for `<baseUrl>/rpc` of the Gelato Relay API, authenticated with `apiKey`. The default
636
+ * timeout is 15 s because Gelato's synchronous relay methods can take up to 10 s.
453
637
  *
454
- * The client is cached by a composite key of `apiKey` and `baseUrl` to avoid
455
- * creating redundant transport instances for identical configurations.
638
+ * Side effects: the transport is cached in memory by `apiKey` and `baseUrl` until the page is reloaded; later calls
639
+ * with the same pair return the cached transport and ignore the other options. Creating it sends no request.
456
640
  *
457
- * The default HTTP timeout is set to 15 seconds (instead of viem's default) because
458
- * Gelato's synchronous relay methods may take up to 10 seconds on the server side,
459
- * and the client should not time out before the server does.
460
- *
461
- * @deprecated Gelato relay is deprecated. Use TransactionTracker.ERC4337 and createBundlerRpcClient instead.
462
- * @param {GelatoClientConfig} parameters - The configuration for the Gelato client.
463
- * @returns {ReturnType<Transport>} A viem transport instance configured for the Gelato API.
641
+ * @deprecated Gelato relay is deprecated. Use `TransactionTracker.ERC4337` and `createBundlerRpcClient` from
642
+ * `@tuwaio/orbit-evm` instead.
643
+ * @param parameters - The API key and transport options.
644
+ * @returns The transport; use its `request` method to call the Gelato RPC API.
464
645
  */
465
646
  declare const createGelatoClient: (parameters: GelatoClientConfig) => ReturnType<Transport>;
466
647
 
467
648
  /**
468
- * @file This file contains constants related to Safe (formerly Gnosis Safe) configuration,
469
- * including SDK options, web app URLs, and transaction service API endpoints for various chains.
649
+ * @file Safe (formerly Gnosis Safe) constants: Safe Apps SDK options, Safe web app URLs and Safe Transaction Service
650
+ * endpoints by chain.
470
651
  */
471
652
  /**
472
- * Configuration options for the Safe Apps SDK.
473
- * This is typically used when integrating with the Safe environment.
653
+ * Options for the Safe Apps SDK (`@safe-global/safe-apps-sdk`), for apps that run inside the Safe web app. Pulsar does
654
+ * not use them itself.
474
655
  */
475
656
  declare const safeSdkOptions: {
657
+ /** Domains of Safe web apps the SDK accepts messages from. */
476
658
  allowedDomains: RegExp[];
659
+ /** Whether the SDK logs debug messages. */
477
660
  debug: boolean;
478
661
  };
479
662
  /**
480
- * A mapping of chain IDs to their corresponding Safe web application URL prefixes.
481
- * Used by selectors like `selectTxExplorerLink` to build correct links for Safe transactions.
482
- * The prefixes (e.g., 'eth:', 'gor:') are part of the Safe URL scheme.
483
- * @type {Record<number, string>}
663
+ * Safe web app URL prefixes by chain ID, such as `https://app.safe.global/eth:`. The Safe address follows the prefix.
664
+ * Used by {@link selectEvmTxExplorerLink} to link Safe transactions.
484
665
  */
485
666
  declare const gnosisSafeLinksHelper: Record<number, string>;
486
667
  /**
487
- * A comprehensive mapping of chain IDs to their corresponding Safe Transaction Service API endpoints.
488
- * This is used by the `safeTracker` to fetch the status of multisig transactions from the correct service.
489
- * @type {Record<number, string>}
668
+ * Safe Transaction Service API base URLs by chain ID. {@link safeFetcher} uses them; chains that are not listed cannot be
669
+ * tracked with the Safe tracker.
490
670
  */
491
671
  declare const SafeTransactionServiceUrls: Record<number, string>;
492
672
 
493
673
  /**
494
- * @file This file contains a selector utility for generating a block explorer URL for a given EVM transaction.
674
+ * @file Builds the explorer URL of an EVM transaction.
495
675
  */
496
676
 
497
677
  /**
498
- * Generates a URL to a block explorer or Safe UI for a given transaction.
499
- * It handles different URL structures for standard EVM transactions, Safe multi-sig, and ERC-4337 UserOperations.
500
- * Both standard transactions and ERC-4337 UserOperations link to the native block explorer (e.g., Etherscan).
501
- *
502
- * @template T - The transaction type, extending the base `Transaction`.
503
- *
504
- * @param {object} params - The parameters for the selection.
505
- * @param {Chain[]} params.chains - An array of supported chain objects, typically from `viem/chains`.
506
- * @param {T} params.tx - The transaction object for which to generate the link.
678
+ * Builds the URL of a transaction page:
679
+ * - Safe transactions link to the transaction in the Safe web app ({@link gnosisSafeLinksHelper}).
680
+ * - Other transactions link to `<explorer>/tx/<hash>` on the default block explorer of the chain in `chains`, where
681
+ * `<hash>` is `replacedTxHash`, else `hash`, else `txKey`. Before an ERC-4337 UserOperation is bundled, this is the
682
+ * `userOpHash`, which block explorers do not know.
507
683
  *
508
- * @returns {string} The full URL to the transaction on the corresponding block explorer or Safe app,
509
- * or an empty string if the transaction or required chain configuration is not found.
684
+ * @template T - The application transaction type.
685
+ * @param params - The chains and the transaction.
686
+ * @param params.chains - The viem chains of the app.
687
+ * @param params.tx - The transaction.
688
+ * @returns The URL, or an empty string when the chain or its explorer is not configured.
510
689
  */
511
690
  declare const selectEvmTxExplorerLink: <T extends Transaction>({ chains, tx, }: {
512
691
  chains: readonly [Chain, ...Chain[]];
@@ -514,42 +693,29 @@ declare const selectEvmTxExplorerLink: <T extends Transaction>({ chains, tx, }:
514
693
  }) => string;
515
694
 
516
695
  /**
517
- * @file This file contains a utility function for speeding up a pending EVM transaction.
696
+ * @file Speeds up a pending EVM transaction by resending it with higher fees.
518
697
  */
519
698
 
520
699
  /**
521
- * Speeds up a pending EVM transaction by resubmitting it with the same nonce but higher gas fees.
522
- * This function is designed to work with wagmi's configuration and actions.
700
+ * Speeds up a pending EVM transaction: asks the connected wallet to resend it (same `to`, `value`, `input` and nonce)
701
+ * with both EIP-1559 fees raised by 15%. When it is mined, the tracker of the original transaction reports it as
702
+ * `Replaced`; the new transaction itself is not added to the pool.
523
703
  *
524
- * @template T - The transaction type, which must be a valid EVM transaction.
704
+ * Side effects: opens a wallet prompt and broadcasts a transaction.
525
705
  *
526
- * @param {object} params - The parameters required to speed up the transaction.
527
- * @param {Config} params.config - The wagmi configuration object.
528
- * @param {T} params.tx - The original transaction object that needs to be sped up. It must contain all necessary EVM fields.
529
- *
530
- * @returns {Promise<Hex>} A promise that resolves with the hash of the new, speed-up transaction.
531
- *
532
- * @throws {Error} Throws an error if:
533
- * - The transaction is not an EVM transaction.
534
- * - The transaction is missing required fields (`nonce`, `from`, `to`, `value`, `maxFeePerGas`, etc.).
535
- * - The wagmi config is not provided.
536
- * - No connected account is found.
537
- * - The `sendTransaction` call fails for any reason.
706
+ * @template T - The application transaction type.
707
+ * @param params - The wagmi config and the transaction.
708
+ * @param params.config - The wagmi config of the app.
709
+ * @param params.tx - The pending transaction. It must be an EVM transaction with `nonce`, `from`, `to`, `value`,
710
+ * `maxFeePerGas` and `maxPriorityFeePerGas` (set by the EVM tracker once the transaction details are fetched).
711
+ * @returns The hash of the replacement transaction.
712
+ * @throws `Error` when the transaction is not an EVM transaction or lacks the required fields, and
713
+ * `Error('Failed to speed up transaction: …')` (with the original error as `cause`) when no account is connected or
714
+ * the wallet rejects or fails to send the transaction.
538
715
  *
539
716
  * @example
540
717
  * ```ts
541
- * const handleSpeedUp = async (stuckTransaction) => {
542
- * try {
543
- * const newTxHash = await speedUpTxAction({
544
- * config: wagmiConfig,
545
- * tx: stuckTransaction,
546
- * });
547
- * console.log('Transaction sped up with new hash:', newTxHash);
548
- * // You should now update your state to track this new transaction hash.
549
- * } catch (error) {
550
- * console.error('Failed to speed up transaction:', error);
551
- * }
552
- * };
718
+ * const hash = await speedUpTxAction({ config: wagmiConfig, tx: pendingTx });
553
719
  * ```
554
720
  */
555
721
  declare function speedUpTxAction<T extends Transaction>({ config, tx }: {
@@ -557,4 +723,4 @@ declare function speedUpTxAction<T extends Transaction>({ config, tx }: {
557
723
  tx: T;
558
724
  }): Promise<Hex>;
559
725
 
560
- export { type EVMTrackerParams, type Erc4337FetchResult, type Erc4337TrackerConfig, type Erc4337TrackerForStoreParams, type Erc4337UserOpReceipt, type GelatoCapabilities, type GelatoCapabilitiesByChain, type GelatoClientConfig, GelatoStatusCode, type GelatoTaskStatus, type GelatoToken, SafeTransactionServiceUrls, type SafeTxStatusResponse, cancelTxAction, checkAndInitializeTrackerInStore, checkIsGelatoAvailable, checkTransactionsTracker, createGelatoClient, erc4337Fetcher, erc4337Tracker, erc4337TrackerForStore, evmTracker, evmTrackerForStore, gelatoFetcher, gelatoTracker, gelatoTrackerForStore, gnosisSafeLinksHelper, isRetryableReceiptError, pulsarEvmAdapter, safeFetcher, safeSdkOptions, safeTrackerForStore, selectEvmTxExplorerLink, speedUpTxAction };
726
+ export { type EVMTrackerParams, type Erc4337FetchResult, type Erc4337FetcherTx, type Erc4337TrackerConfig, type Erc4337TrackerForStoreParams, type Erc4337UserOpReceipt, type GelatoBaseStatus, type GelatoCapabilities, type GelatoCapabilitiesByChain, type GelatoClientConfig, GelatoStatusCode, type GelatoTaskStatus, type GelatoToken, type InitializeTrackerParams, SafeTransactionServiceUrls, type SafeTxStatusResponse, cancelTxAction, checkAndInitializeTrackerInStore, checkIsGelatoAvailable, checkTransactionsTracker, createGelatoClient, erc4337Fetcher, erc4337Tracker, erc4337TrackerForStore, evmTracker, evmTrackerForStore, gelatoFetcher, gelatoTracker, gelatoTrackerForStore, gnosisSafeLinksHelper, isRetryableReceiptError, pulsarEvmAdapter, safeFetcher, safeSdkOptions, safeTrackerForStore, selectEvmTxExplorerLink, speedUpTxAction };