@tuwaio/pulsar-evm 0.5.10 → 0.7.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/dist/index.d.mts CHANGED
@@ -1,103 +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
- import { Chain, GetTransactionReturnType, TransactionReceipt, Client, ReplacementReturnType, WaitForTransactionReceiptParameters, Hex, Transport, HttpTransportConfig } from 'viem';
3
+ import { Chain, Hex, GetTransactionReturnType, TransactionReceipt, Client, ReplacementReturnType, WaitForTransactionReceiptParameters, Transport, HttpTransportConfig } from 'viem';
4
+ import { GetUserOperationReceiptReturnType } from 'viem/account-abstraction';
4
5
 
5
6
  /**
6
- * @file This file contains the factory function for creating the EVM (Ethereum Virtual Machine) transaction adapter.
7
- * 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.
8
8
  */
9
9
 
10
10
  /**
11
- * 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.
12
33
  *
13
- * This function acts as a constructor for the EVM adapter, bundling all the necessary
14
- * chain-specific utilities (like checking chain, ENS resolution, speeding up transactions, etc.)
15
- * into a single object that conforms to the `TxAdapter` interface.
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';
39
+ *
40
+ * const pulsarStore = createPulsarStore({
41
+ * name: 'transactions-tracking-storage',
42
+ * adapter: pulsarEvmAdapter(wagmiConfig, [mainnet, sepolia]),
43
+ * });
44
+ * ```
45
+ */
46
+ declare function pulsarEvmAdapter<T extends Transaction>(config: Config, appChains: readonly [Chain, ...Chain[]]): TxAdapter<T>;
47
+
48
+ /**
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.
51
+ */
52
+
53
+ /**
54
+ * The UserOperation receipt returned by viem's `getUserOperationReceipt`.
55
+ */
56
+ type Erc4337UserOpReceipt = GetUserOperationReceiptReturnType;
57
+ /**
58
+ * The result {@link erc4337Fetcher} reports on each polling tick.
59
+ */
60
+ type Erc4337FetchResult = {
61
+ /** The UserOperation receipt, or `null` while it is not available. */
62
+ receipt: Erc4337UserOpReceipt | null;
63
+ /** `pending` while the UserOperation is not bundled, then `success` or `failed`. */
64
+ status: 'pending' | 'success' | 'failed';
65
+ /** The hash of the bundle transaction that included the UserOperation, once known. */
66
+ hash?: Hex;
67
+ /** The failure reason: the revert reason of the receipt, or a validation message. */
68
+ reason?: string;
69
+ };
70
+ /**
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`.
16
78
  *
17
- * @template T - The application-specific transaction type.
18
- * @param {Config} config - The wagmi configuration object.
19
- * @param {Chain[]} appChains - An array of viem `Chain` objects supported by the application.
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`.
20
81
  *
21
- * @returns {TxAdapter<T>} The configured EVM transaction adapter.
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.
22
87
  *
23
- * @throws {Error} Throws an error if the wagmi `config` is not provided.
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.
24
91
  */
25
- declare function pulsarEvmAdapter<T extends Transaction>(config: Config, appChains: readonly [Chain, ...Chain[]]): TxAdapter<T>;
92
+ declare function erc4337Fetcher<T extends Erc4337FetcherTx>({ tx, stopPolling, onSuccess, onFailure, onIntervalTick, }: PollingFetcherParams<Erc4337FetchResult, T>): Promise<void>;
93
+ /**
94
+ * The configuration of {@link erc4337Tracker}.
95
+ *
96
+ * @template T - The tracked transaction type.
97
+ */
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
+ */
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
+ */
111
+ onFailure: (result?: Erc4337FetchResult) => void;
112
+ /**
113
+ * Called on every tick while the UserOperation is not bundled.
114
+ * @param result - The pending result.
115
+ */
116
+ onIntervalTick?: (result: Erc4337FetchResult) => void;
117
+ /**
118
+ * Called when polling stops after `maxRetries` consecutive failed attempts.
119
+ * @param txKey - The `userOpHash`.
120
+ */
121
+ removeTxFromPool?: (txKey: string) => void;
122
+ /** The delay before each attempt, in milliseconds. Defaults to 2000. */
123
+ pollingInterval?: number;
124
+ /** The number of consecutive failed attempts after which polling stops. Defaults to 60. */
125
+ maxRetries?: number;
126
+ };
127
+ /**
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.
134
+ *
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
+ * ```
143
+ */
144
+ declare function erc4337Tracker<T extends Erc4337FetcherTx & Pick<Transaction, 'pending'>>(config: Erc4337TrackerConfig<T>): void;
145
+ /**
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.
150
+ */
151
+ type Erc4337TrackerForStoreParams<T extends Transaction> = Pick<ITxTrackingStore<T>, 'updateTxParams' | 'removeTxFromPool' | 'transactionsPool'> & {
152
+ /** The transaction to track; `txKey` is the `userOpHash`. */
153
+ tx: T;
154
+ /** The wagmi config, used for the on-chain stage. Without it, the transaction succeeds as soon as it is bundled. */
155
+ config?: Config;
156
+ } & TrackerCallbacks<T>;
157
+ /**
158
+ * Tracks an ERC-4337 UserOperation of the Pulsar store in two stages and writes the results to the store:
159
+ *
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.
166
+ *
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.
169
+ *
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.
173
+ */
174
+ declare function erc4337TrackerForStore<T extends Transaction>({ tx, config, updateTxParams, transactionsPool, onSuccess, onError, onReplaced, }: Erc4337TrackerForStoreParams<T>): Promise<void>;
26
175
 
27
176
  /**
28
- * @file This file contains the tracker implementation for standard EVM transactions.
29
- * It uses viem's public actions (`getTransaction`, `waitForTransactionReceipt`) to monitor
30
- * 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.
31
179
  */
32
180
 
33
181
  /**
34
- * Checks whether an error during receipt polling is transient (RPC network glitch, timeout, or unindexed tx).
35
- * 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.
36
185
  *
37
- * @param error - The caught error object.
38
- * @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.
39
188
  */
40
189
  declare function isRetryableReceiptError(error: unknown): boolean;
41
190
  /**
42
- * Defines the parameters for the low-level EVM transaction tracker.
191
+ * The configuration of {@link evmTracker}.
43
192
  */
44
193
  type EVMTrackerParams = {
45
- /** 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
+ */
46
198
  tx: Pick<Transaction, 'chainId' | 'txKey' | 'requiredConfirmations'>;
47
- /** The `@wagmi/core` configuration instance used to resolve network clients. */
199
+ /** The wagmi config; the tracker uses its client for `tx.chainId`. */
48
200
  config: Config;
49
- /** 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
+ */
50
205
  onTxDetailsFetched: (txDetails: GetTransactionReturnType) => void;
51
- /** 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
+ */
52
213
  onSuccess: (txDetails: GetTransactionReturnType, receipt: TransactionReceipt, client: Client) => Promise<void>;
53
- /** 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
+ */
54
218
  onReplaced: (replacement: ReplacementReturnType) => void;
55
- /** 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
+ */
56
223
  onFailure: (error?: unknown) => void;
57
- /** Optional callback fired when tracker initialization starts. */
224
+ /** Called once, before anything else. */
58
225
  onInitialize?: () => void;
59
- /** Number of retries for the initial `getTransaction` fetch step. Defaults to 10. */
226
+ /** Number of `getTransaction` attempts. Defaults to 10. */
60
227
  retryCount?: number;
61
- /** Timeout in milliseconds between `getTransaction` retry attempts. Defaults to 3000ms. */
228
+ /** Delay between `getTransaction` attempts, in milliseconds. Defaults to 3000. */
62
229
  retryTimeout?: number;
63
- /** 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
+ */
64
234
  onConfirmationsUpdate?: (confirmations: number) => void;
65
- /** 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
+ */
66
239
  waitForTransactionReceiptParams?: WaitForTransactionReceiptParameters;
67
240
  };
68
241
  /**
69
- * A low-level tracker for monitoring a standard EVM transaction by its hash.
70
- * Retries fetching transaction details and gracefully polls for transaction receipt,
71
- * 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.
72
253
  *
73
- * @param params - The configuration parameters and lifecycle callbacks for the EVM tracker.
74
- * @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
+ * ```
75
270
  */
76
271
  declare function evmTracker(params: EVMTrackerParams): Promise<void>;
77
272
  /**
78
- * A higher-level wrapper for `evmTracker` that integrates directly with the Pulsar store.
79
- * 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.
277
+ *
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')`.
80
280
  *
81
- * @template T - The application-specific transaction state structure extending `Transaction`.
82
- * @param params - Configuration connecting `@wagmi/core`, store mutation methods, target transaction, and callbacks.
83
- * @returns A promise that resolves when transaction tracking finishes and store state is committed.
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.
84
284
  */
85
285
  declare function evmTrackerForStore<T extends Transaction>(params: Pick<EVMTrackerParams, 'config'> & Pick<ITxTrackingStore<T>, 'updateTxParams' | 'transactionsPool'> & {
86
286
  tx: T;
87
287
  } & TrackerCallbacks<T>): Promise<void>;
88
288
 
89
289
  /**
90
- * @file This file implements the transaction tracking logic for meta-transactions relayed via the Gelato Network.
91
- * It uses a polling mechanism to check the status of a Gelato task via the authenticated Gelato RPC client.
92
- *
93
- * The fetcher calls `relayer_getStatus` on the Gelato RPC endpoint and interprets the numeric
94
- * 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.
95
292
  */
96
293
 
97
294
  /**
98
295
  * Numeric status codes returned by the Gelato `relayer_getStatus` RPC method.
99
296
  *
100
- * @see https://docs.gelato.cloud/
297
+ * @deprecated Gelato relay is deprecated. Use `TransactionTracker.ERC4337` instead.
298
+ * @see {@link https://docs.gelato.cloud/ Gelato documentation}
101
299
  */
102
300
  declare enum GelatoStatusCode {
103
301
  /** The task has been received and is awaiting execution. */
@@ -112,7 +310,9 @@ declare enum GelatoStatusCode {
112
310
  Reverted = 500
113
311
  }
114
312
  /**
115
- * 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.
116
316
  */
117
317
  type GelatoBaseStatus = {
118
318
  /** The chain ID on which the task was submitted. */
@@ -123,8 +323,9 @@ type GelatoBaseStatus = {
123
323
  id: string;
124
324
  };
125
325
  /**
126
- * Discriminated union representing all possible Gelato task status responses.
127
- * 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.
128
329
  */
129
330
  type GelatoTaskStatus = (GelatoBaseStatus & {
130
331
  status: GelatoStatusCode.Pending;
@@ -149,108 +350,148 @@ type GelatoTaskStatus = (GelatoBaseStatus & {
149
350
  };
150
351
  });
151
352
  /**
152
- * Creates a reusable fetcher function for `initializePollingTracker` that queries the
153
- * 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`.
154
355
  *
155
- * The fetcher interprets the numeric status codes and calls the appropriate polling callbacks:
156
- * - {@link GelatoStatusCode.Success} → `onSuccess`
157
- * - {@link GelatoStatusCode.Rejected} / {@link GelatoStatusCode.Reverted} → `onFailure`
158
- * - {@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.
159
360
  *
160
- * @param {ReturnType<Transport>} client - A viem transport client configured for the Gelato API.
161
- * @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.
162
364
  */
163
- 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>;
164
366
  /**
165
- * A higher-level wrapper that integrates the Gelato polling logic with the Pulsar store.
166
- * It creates an authenticated Gelato RPC client and uses {@link gelatoFetcher} to
167
- * 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`.
168
370
  *
169
- * @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.
170
373
  *
171
- * @param params.tx - The transaction to track.
172
- * @param params.gelatoApiKey - The Gelato API key for authenticating RPC requests.
173
- * @param params.updateTxParams - Store action to update transaction fields.
174
- * @param params.removeTxFromPool - Store action to remove a transaction from the pool.
175
- * @param params.transactionsPool - The current pool of tracked transactions.
176
- * @param params.onSuccess - Optional callback invoked when the transaction succeeds.
177
- * @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.
178
387
  */
179
- 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'> & {
180
389
  tx: T;
181
390
  gelatoApiKey: string;
182
391
  } & TrackerCallbacks<T>): void;
392
+ /**
393
+ * Alias of {@link gelatoTrackerForStore}.
394
+ *
395
+ * @deprecated Gelato relay is deprecated. Use `TransactionTracker.ERC4337` and {@link erc4337TrackerForStore} instead.
396
+ */
397
+ declare const gelatoTracker: typeof gelatoTrackerForStore;
183
398
 
184
399
  /**
185
- * @file This file implements the transaction tracking logic for Safe (formerly Gnosis Safe) multisig transactions.
186
- * 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`.
187
402
  */
188
403
 
189
404
  /**
190
- * 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.
191
406
  */
192
407
  type SafeTxStatusResponse = {
408
+ /** The hash of the executed on-chain transaction, or `null` before execution. */
193
409
  transactionHash: Hex | null;
410
+ /** The Safe transaction hash (the `txKey` of the tracked transaction). */
194
411
  safeTxHash: Hex;
412
+ /** `true` once the multisig transaction has been executed on-chain. */
195
413
  isExecuted: boolean;
414
+ /** Whether the execution succeeded; `null` before execution. */
196
415
  isSuccessful: boolean | null;
416
+ /** ISO date of the execution, or `null` before execution. */
197
417
  executionDate: string | null;
418
+ /** ISO date when the transaction was proposed to the service. */
198
419
  submissionDate: string;
420
+ /** ISO date of the last change. */
199
421
  modified: string;
422
+ /** The Safe nonce of the transaction. */
200
423
  nonce: number;
201
424
  };
202
425
  /**
203
- * A reusable fetcher for `initializePollingTracker` that queries the Safe Transaction Service API.
204
- * 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.
205
443
  */
206
- 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>;
207
445
  /**
208
- * A higher-level wrapper that integrates the Safe polling logic with the Pulsar store.
209
- * 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.
453
+ *
454
+ * Side effects: sends requests to the Safe Transaction Service. The callbacks receive the transaction with every update
455
+ * written by the tracker.
210
456
  *
211
- * @template T - The application-specific transaction type.
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.
212
466
  */
213
- 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'> & {
214
468
  tx: T;
215
469
  } & TrackerCallbacks<T>): void;
216
470
 
217
471
  /**
218
- * @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.
219
473
  */
220
474
 
221
475
  /**
222
- * Cancels a pending EVM transaction by sending a new, zero-value transaction to oneself
223
- * with the same nonce but higher gas fees. This effectively replaces the original transaction.
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.
224
479
  *
225
- * @template T - The transaction type, which must be a valid EVM transaction.
480
+ * Side effects: opens a wallet prompt and broadcasts a transaction.
226
481
  *
227
- * @param {object} params - The parameters required to cancel the transaction.
228
- * @param {Config} params.config - The wagmi configuration object.
229
- * @param {T} params.tx - The original transaction object to be canceled. It must contain the nonce and gas fee fields.
230
- *
231
- * @returns {Promise<Hex>} A promise that resolves with the hash of the new cancellation transaction.
232
- *
233
- * @throws {Error} Throws an error if:
234
- * - The transaction is not an EVM transaction.
235
- * - The transaction is missing required fields (`nonce`, `maxFeePerGas`, etc.).
236
- * - The wagmi config is not provided.
237
- * - No connected account is found.
238
- * - 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.
239
491
  *
240
492
  * @example
241
493
  * ```ts
242
- * const handleCancel = async (stuckTransaction) => {
243
- * try {
244
- * const cancelTxHash = await cancelTxAction({
245
- * config: wagmiConfig,
246
- * tx: stuckTransaction,
247
- * });
248
- * console.log('Cancellation transaction sent with hash:', cancelTxHash);
249
- * // You should now update your state to track this new transaction.
250
- * } catch (error) {
251
- * console.error('Failed to cancel transaction:', error);
252
- * }
253
- * };
494
+ * const hash = await cancelTxAction({ config: wagmiConfig, tx: pendingTx });
254
495
  * ```
255
496
  */
256
497
  declare function cancelTxAction<T extends Transaction>({ config, tx }: {
@@ -259,178 +500,192 @@ declare function cancelTxAction<T extends Transaction>({ config, tx }: {
259
500
  }): Promise<Hex>;
260
501
 
261
502
  /**
262
- * @file This file contains a utility function that acts as a router to initialize the correct transaction tracker.
263
- * 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.
264
504
  */
265
505
 
266
506
  /**
267
- * The parameters required to initialize a tracker.
268
- * @template T - The application-specific transaction type.
507
+ * The parameters of {@link checkAndInitializeTrackerInStore}.
508
+ *
509
+ * @template T - The application transaction type.
269
510
  */
270
511
  type InitializeTrackerParams<T extends Transaction> = Pick<ITxTrackingStore<T>, 'updateTxParams' | 'removeTxFromPool' | 'transactionsPool'> & {
512
+ /** The wagmi config of the app. */
271
513
  config: Config;
514
+ /** The transaction to track. */
272
515
  tx: T;
516
+ /** The tracker to run, usually `tx.tracker`. */
273
517
  tracker: TransactionTracker;
518
+ /** @deprecated Gelato API key; required to run the Gelato tracker. */
274
519
  gelatoApiKey?: string;
275
520
  } & TrackerCallbacks<T>;
276
521
  /**
277
- * Initializes the appropriate tracker for a given transaction based on its `tracker` type.
278
- * This function acts as a central router, delegating to the specific tracker implementation
279
- * (e.g., standard EVM, Gelato, or Safe).
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`.
280
526
  *
281
- * @template T - The application-specific transaction type, extending the base `Transaction`.
282
- * @param {InitializeTrackerParams<T>} params - The parameters for initializing the tracker.
283
- * @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.
284
531
  */
285
532
  declare function checkAndInitializeTrackerInStore<T extends Transaction>({ tracker, tx, config, transactionsPool, onSuccess, onError, onReplaced, gelatoApiKey, ...rest }: InitializeTrackerParams<T>): Promise<void>;
286
533
 
287
534
  /**
288
- * @file This file contains a utility to check if the Gelato Relay service is available for a specific chain.
289
- * 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.
290
536
  */
291
537
  /**
292
- * 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`.
293
539
  *
294
- * @property {string} feeCollector - The address of the fee collector contract on this chain.
295
- * @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.
296
541
  */
297
542
  type GelatoCapabilitiesByChain = {
543
+ /** The address of the fee collector contract on this chain. */
298
544
  feeCollector: string;
545
+ /** The ERC-20 tokens accepted for fee payment on this chain. */
299
546
  tokens: GelatoToken[];
300
547
  };
301
548
  /**
302
- * 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.
303
550
  *
304
- * @property {string} address - The ERC-20 token contract address.
305
- * @property {number} decimals - The number of decimals for the token.
551
+ * @deprecated Gelato relay is deprecated. Use `TransactionTracker.ERC4337` instead.
306
552
  */
307
553
  type GelatoToken = {
554
+ /** The ERC-20 token contract address. */
308
555
  address: string;
556
+ /** The number of decimals of the token. */
309
557
  decimals: number;
310
558
  };
311
559
  /**
312
- * 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.
313
563
  */
314
564
  type GelatoCapabilities = Record<number, GelatoCapabilitiesByChain>;
315
565
  /**
316
- * Checks if the Gelato Relay service supports a given chain ID.
566
+ * Checks whether Gelato Relay supports a chain.
317
567
  *
318
- * This function fetches the relay capabilities via the authenticated Gelato RPC client
319
- * (`relayer_getCapabilities`) and checks whether the specified chain is present in the response.
320
- * 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`.
321
571
  *
322
- * @param {number} chainId - The chain identifier to check.
323
- * @param {string} gelatoApiKey - The Gelato API key used for authentication.
324
- * @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.
325
576
  */
326
577
  declare function checkIsGelatoAvailable(chainId: number, gelatoApiKey: string): Promise<boolean>;
327
578
 
328
579
  /**
329
- * @file This file contains a utility function to determine the correct tracker for a transaction
330
- * 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`.
331
581
  */
332
582
 
333
583
  /**
334
- * 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`.
335
590
  *
336
- * This function is a critical routing step after a transaction is submitted. It inspects
337
- * the key returned by the `actionFunction` and the connector type to decide the tracking strategy.
338
- * The logic follows a specific priority:
339
- * 1. Checks for a Gelato Task ID structure.
340
- * 2. Checks if the connector type indicates a Safe transaction.
341
- * 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`.
342
593
  *
343
- * @param {ActionTxKey} actionTxKey - The key returned from the transaction submission function (e.g., a hash or a Gelato task object).
344
- * @param {string} connectorType - The type of the connector that initiated the action (e.g., 'safe', 'injected').
345
- * @param {TransactionTracker} tracker - The type of transaction tracker to use.
346
- * @param {string} gelatoApiKey - Gelato API key for Gelato relayer integration.
347
- * @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.
348
601
  *
349
- * @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
+ * ```
350
607
  */
351
608
  declare function checkTransactionsTracker({ actionTxKey, connectorType, tracker, gelatoApiKey }: CheckTxTracker): {
609
+ /** The tracker to use. */
352
610
  tracker: TransactionTracker;
611
+ /** The key to store the transaction under: always `actionTxKey`. */
353
612
  txKey: string;
354
613
  };
355
614
 
356
615
  /**
357
- * @file This file contains a utility function for creating a cached viem HTTP transport
358
- * client configured for the Gelato Relay API.
616
+ * @file Creates a cached viem HTTP transport for the Gelato Relay RPC API.
359
617
  */
360
618
 
361
619
  /**
362
- * Configuration options for creating a Gelato API client.
620
+ * The configuration of {@link createGelatoClient}.
363
621
  *
364
- * @property {string} apiKey - The Gelato API key used for authentication.
365
- * @property {number} [timeout] - Optional custom HTTP timeout in milliseconds. Defaults to 15000ms.
366
- * @property {string} [baseUrl] - Optional custom base URL for the Gelato API. Defaults to `https://api.gelato.cloud/rpc`.
367
- * @property {HttpTransportConfig} [httpTransportConfig] - Optional additional viem HTTP transport configuration overrides.
622
+ * @deprecated Gelato relay is deprecated. Use `TransactionTracker.ERC4337` instead.
368
623
  */
369
624
  type GelatoClientConfig = {
625
+ /** The Gelato API key, sent as a `Bearer` token. */
370
626
  apiKey: string;
627
+ /** HTTP timeout in milliseconds. Defaults to 15000. */
371
628
  timeout?: number;
629
+ /** The base URL of the Gelato API; `/rpc` is appended. Defaults to `https://api.gelato.cloud`. */
372
630
  baseUrl?: string;
631
+ /** Additional options for viem's `http` transport. Its `timeout` overrides `timeout`. */
373
632
  httpTransportConfig?: HttpTransportConfig;
374
633
  };
375
634
  /**
376
- * 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.
377
637
  *
378
- * The client is cached by a composite key of `apiKey` and `baseUrl` to avoid
379
- * 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.
380
640
  *
381
- * The default HTTP timeout is set to 15 seconds (instead of viem's default) because
382
- * Gelato's synchronous relay methods may take up to 10 seconds on the server side,
383
- * and the client should not time out before the server does.
384
- *
385
- * @param {GelatoClientConfig} parameters - The configuration for the Gelato client.
386
- * @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.
387
645
  */
388
646
  declare const createGelatoClient: (parameters: GelatoClientConfig) => ReturnType<Transport>;
389
647
 
390
648
  /**
391
- * @file This file contains constants related to Safe (formerly Gnosis Safe) configuration,
392
- * 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.
393
651
  */
394
652
  /**
395
- * Configuration options for the Safe Apps SDK.
396
- * 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.
397
655
  */
398
656
  declare const safeSdkOptions: {
657
+ /** Domains of Safe web apps the SDK accepts messages from. */
399
658
  allowedDomains: RegExp[];
659
+ /** Whether the SDK logs debug messages. */
400
660
  debug: boolean;
401
661
  };
402
662
  /**
403
- * A mapping of chain IDs to their corresponding Safe web application URL prefixes.
404
- * Used by selectors like `selectTxExplorerLink` to build correct links for Safe transactions.
405
- * The prefixes (e.g., 'eth:', 'gor:') are part of the Safe URL scheme.
406
- * @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.
407
665
  */
408
666
  declare const gnosisSafeLinksHelper: Record<number, string>;
409
667
  /**
410
- * A comprehensive mapping of chain IDs to their corresponding Safe Transaction Service API endpoints.
411
- * This is used by the `safeTracker` to fetch the status of multisig transactions from the correct service.
412
- * @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.
413
670
  */
414
671
  declare const SafeTransactionServiceUrls: Record<number, string>;
415
672
 
416
673
  /**
417
- * @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.
418
675
  */
419
676
 
420
677
  /**
421
- * Generates a URL to a block explorer or Safe UI for a given transaction.
422
- * It handles different URL structures for standard EVM transactions and Safe multi-sig transactions.
423
- *
424
- * @template T - The transaction type, extending the base `Transaction`.
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.
425
683
  *
426
- * @param {object} params - The parameters for the selection.
427
- * @param {TransactionPool<T>} params.transactionsPool - The entire pool of transactions from the store.
428
- * @param {Chain[]} params.chains - An array of supported chain objects, typically from `viem/chains`.
429
- * @param {Hex} params.txKey - The unique key (`txKey`) of the transaction for which to generate the link.
430
- * @param {Hex} [params.replacedTxHash] - Optional. If this is a speed-up/cancel transaction, this is the hash of the new transaction.
431
- *
432
- * @returns {string} The full URL to the transaction on the corresponding block explorer or Safe app,
433
- * 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.
434
689
  */
435
690
  declare const selectEvmTxExplorerLink: <T extends Transaction>({ chains, tx, }: {
436
691
  chains: readonly [Chain, ...Chain[]];
@@ -438,42 +693,29 @@ declare const selectEvmTxExplorerLink: <T extends Transaction>({ chains, tx, }:
438
693
  }) => string;
439
694
 
440
695
  /**
441
- * @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.
442
697
  */
443
698
 
444
699
  /**
445
- * Speeds up a pending EVM transaction by resubmitting it with the same nonce but higher gas fees.
446
- * This function is designed to work with wagmi's configuration and actions.
447
- *
448
- * @template T - The transaction type, which must be a valid EVM transaction.
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.
449
703
  *
450
- * @param {object} params - The parameters required to speed up the transaction.
451
- * @param {Config} params.config - The wagmi configuration object.
452
- * @param {T} params.tx - The original transaction object that needs to be sped up. It must contain all necessary EVM fields.
704
+ * Side effects: opens a wallet prompt and broadcasts a transaction.
453
705
  *
454
- * @returns {Promise<Hex>} A promise that resolves with the hash of the new, speed-up transaction.
455
- *
456
- * @throws {Error} Throws an error if:
457
- * - The transaction is not an EVM transaction.
458
- * - The transaction is missing required fields (`nonce`, `from`, `to`, `value`, `maxFeePerGas`, etc.).
459
- * - The wagmi config is not provided.
460
- * - No connected account is found.
461
- * - 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.
462
715
  *
463
716
  * @example
464
717
  * ```ts
465
- * const handleSpeedUp = async (stuckTransaction) => {
466
- * try {
467
- * const newTxHash = await speedUpTxAction({
468
- * config: wagmiConfig,
469
- * tx: stuckTransaction,
470
- * });
471
- * console.log('Transaction sped up with new hash:', newTxHash);
472
- * // You should now update your state to track this new transaction hash.
473
- * } catch (error) {
474
- * console.error('Failed to speed up transaction:', error);
475
- * }
476
- * };
718
+ * const hash = await speedUpTxAction({ config: wagmiConfig, tx: pendingTx });
477
719
  * ```
478
720
  */
479
721
  declare function speedUpTxAction<T extends Transaction>({ config, tx }: {
@@ -481,4 +723,4 @@ declare function speedUpTxAction<T extends Transaction>({ config, tx }: {
481
723
  tx: T;
482
724
  }): Promise<Hex>;
483
725
 
484
- export { type EVMTrackerParams, type GelatoCapabilities, type GelatoCapabilitiesByChain, type GelatoClientConfig, GelatoStatusCode, type GelatoTaskStatus, type GelatoToken, SafeTransactionServiceUrls, type SafeTxStatusResponse, cancelTxAction, checkAndInitializeTrackerInStore, checkIsGelatoAvailable, checkTransactionsTracker, createGelatoClient, evmTracker, evmTrackerForStore, gelatoFetcher, 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 };