@tuwaio/pulsar-core 1.0.0-fix-retry-actions-alpha.2.49e2be4 → 1.0.0-fix-callbacks-alpha.1.227594b

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -62,20 +62,12 @@ import { wagmiConfig, chains } from './path/to/your/wagmi/config';
62
62
  const pulsarStore = createPulsarStore({
63
63
  // A unique name for Zustand's persistence middleware. This will be the key in localStorage.
64
64
  name: 'my-app-pulsar-storage',
65
-
66
65
  // An array of adapters for different blockchain ecosystems.
67
66
  // Each adapter provides chain-specific logic.
68
- adapters: [
67
+ adapter: [
69
68
  evmAdapter(wagmiConfig, chains),
70
69
  // ... add other adapters like solanaAdapter here
71
70
  ],
72
-
73
- // (Optional) A callback function to execute on every successful transaction.
74
- // Ideal for global logic like showing a success notification.
75
- onSucceedCallbacks: (tx) => {
76
- console.log('Transaction succeeded!', tx);
77
- // e.g., showToast('Success!', { type: 'success' });
78
- },
79
71
  });
80
72
 
81
73
  export default pulsarStore;
package/dist/index.d.mts CHANGED
@@ -4,14 +4,14 @@ import { PersistOptions } from 'zustand/middleware';
4
4
 
5
5
  /**
6
6
  * @file This file defines the core data structures and TypeScript types for the Pulsar transaction tracking engine.
7
- * It includes types for transactions, their statuses, store interfaces, and utility types for Zustand slices.
8
- * These types are framework-agnostic and form the foundation of the entire tracking system.
7
+ * It specifies the framework-agnostic models for transactions, their lifecycle statuses, and the interfaces for
8
+ * the Zustand-based store and chain-specific adapters.
9
9
  */
10
10
 
11
11
  /**
12
12
  * A utility type for creating modular Zustand store slices, enabling composable state management.
13
- * @template T - The type of the state slice.
14
- * @template S - The type of the full store state, defaulting to T.
13
+ * @template T The state slice being defined.
14
+ * @template S The full store state that includes the slice `T`.
15
15
  */
16
16
  type StoreSlice<T extends object, S extends object = T> = (set: StoreApi<S extends T ? S : S & T>['setState'], get: StoreApi<S extends T ? S : S & T>['getState']) => T;
17
17
  /**
@@ -25,26 +25,64 @@ declare enum TransactionAdapter {
25
25
  /** For the Starknet L2 network. */
26
26
  Starknet = "starknet"
27
27
  }
28
+ /**
29
+ * Enum representing the different tracking strategies available for EVM transactions.
30
+ * Each tracker corresponds to a specific method of monitoring a transaction's lifecycle.
31
+ */
32
+ declare enum TransactionTracker {
33
+ /** For standard on-chain EVM transactions tracked by their hash. */
34
+ Ethereum = "ethereum",
35
+ /** For multi-signature transactions managed and executed via a Safe contract. */
36
+ Safe = "safe",
37
+ /** For meta-transactions relayed and executed by the Gelato Network. */
38
+ Gelato = "gelato",
39
+ /** The tracker for monitoring standard Solana transaction signatures. */
40
+ Solana = "solana"
41
+ }
28
42
  /**
29
43
  * Represents the terminal status of a transaction after it has been processed.
30
44
  */
31
45
  declare enum TransactionStatus {
32
46
  /** The transaction failed to execute due to an on-chain error or rejection. */
33
47
  Failed = "Failed",
34
- /** The transaction was successfully mined and executed. */
48
+ /** The transaction was successfully mined and included in a block. */
35
49
  Success = "Success",
36
50
  /** The transaction was replaced by another with the same nonce (e.g., a speed-up or cancel). */
37
51
  Replaced = "Replaced"
38
52
  }
53
+ /**
54
+ * Defines the shape of the identifier for a Gelato transaction task.
55
+ */
56
+ type GelatoTxKey = {
57
+ taskId: string;
58
+ };
59
+ /**
60
+ * A union type representing the unique identifier returned by an `actionFunction`
61
+ * after a transaction is submitted to the network or a relay service.
62
+ *
63
+ * This key is crucial for the EVM adapter to determine which tracker should
64
+ * monitor the transaction.
65
+ *
66
+ * It can be one of the following:
67
+ * - A standard `0x...` transaction hash (`Hex`).
68
+ * - A structured object from a relay service like Gelato (`GelatoTxKey`).
69
+ */
70
+ type ActionTxKey = `0x${string}` | GelatoTxKey | string;
39
71
  /**
40
72
  * The fundamental structure for any transaction being tracked by Pulsar.
41
- * This forms the base upon which chain-specific transaction types are built.
42
- * @template T - The type of the tracker identifier (e.g., 'ethereum', 'gelato', 'safe').
73
+ * This serves as the base upon which chain-specific transaction types are built.
43
74
  */
44
- type BaseTransaction<T> = {
75
+ type BaseTransaction = {
45
76
  /** The chain identifier (e.g., 1 for Ethereum Mainnet, 'SN_MAIN' for Starknet). */
46
77
  chainId: number | string;
47
- /** A user-facing description. Can be a single string or an array for [pending, success, error, replaced] states. */
78
+ /**
79
+ * User-facing description. Can be a single string for all states, or a tuple for specific states.
80
+ * @example
81
+ * // A single description for all states
82
+ * description: 'Swap 1 ETH for 1,500 USDC'
83
+ * // Specific descriptions for each state in order: [pending, success, error, replaced]
84
+ * description: ['Swapping...', 'Swapped Successfully', 'Swap Failed', 'Swap Replaced']
85
+ */
48
86
  description?: string | [string, string, string, string];
49
87
  /** The error message if the transaction failed. */
50
88
  errorMessage?: string;
@@ -64,10 +102,17 @@ type BaseTransaction<T> = {
64
102
  pending: boolean;
65
103
  /** The final on-chain status of the transaction. */
66
104
  status?: TransactionStatus;
67
- /** A user-facing title. Can be a single string or an array for [pending, success, error, replaced] states. */
105
+ /**
106
+ * User-facing title. Can be a single string for all states, or a tuple for specific states.
107
+ * @example
108
+ * // A single title for all states
109
+ * title: 'ETH/USDC Swap'
110
+ * // Specific titles for each state in order: [pending, success, error, replaced]
111
+ * title: ['Processing Swap', 'Swap Complete', 'Swap Error', 'Swap Replaced']
112
+ */
68
113
  title?: string | [string, string, string, string];
69
114
  /** The specific tracker responsible for monitoring this transaction's status. */
70
- tracker: T;
115
+ tracker: TransactionTracker;
71
116
  /** The unique identifier for the transaction (e.g., EVM hash, Gelato task ID). */
72
117
  txKey: string;
73
118
  /** The application-specific type or category of the transaction (e.g., 'SWAP', 'APPROVE'). */
@@ -77,9 +122,8 @@ type BaseTransaction<T> = {
77
122
  };
78
123
  /**
79
124
  * Represents an EVM-specific transaction, extending the base properties with EVM fields.
80
- * @template T - The type of the tracker identifier.
81
125
  */
82
- type EvmTransaction<T> = BaseTransaction<T> & {
126
+ type EvmTransaction = BaseTransaction & {
83
127
  adapter: TransactionAdapter.EVM;
84
128
  /** The on-chain transaction hash, available after submission. */
85
129
  hash?: `0x${string}`;
@@ -100,9 +144,8 @@ type EvmTransaction<T> = BaseTransaction<T> & {
100
144
  };
101
145
  /**
102
146
  * Represents a Solana-specific transaction, extending the base properties.
103
- * @template T - The type of the tracker identifier.
104
147
  */
105
- type SolanaTransaction<T> = BaseTransaction<T> & {
148
+ type SolanaTransaction = BaseTransaction & {
106
149
  adapter: TransactionAdapter.SOLANA;
107
150
  /** The transaction fee in lamports. */
108
151
  fee?: number;
@@ -112,16 +155,15 @@ type SolanaTransaction<T> = BaseTransaction<T> & {
112
155
  recentBlockhash?: string;
113
156
  /** The slot in which the transaction was processed. */
114
157
  slot?: number;
115
- /** The number of confirmations the transaction has received, or null if the transaction is still pending. */
116
- confirmations?: number | null;
117
- /** The RPC URL used for the transaction. */
158
+ /** The number of confirmations received. `string` when tx successed. `null` if the transaction is pending or unconfirmed. */
159
+ confirmations?: number | string | null;
160
+ /** The RPC URL used to submit and track this transaction. */
118
161
  rpcUrl?: string;
119
162
  };
120
163
  /**
121
164
  * Represents a Starknet-specific transaction, extending the base properties.
122
- * @template T - The type of the tracker identifier.
123
165
  */
124
- type StarknetTransaction<T> = BaseTransaction<T> & {
166
+ type StarknetTransaction = BaseTransaction & {
125
167
  adapter: TransactionAdapter.Starknet;
126
168
  /** The actual fee paid for the transaction. */
127
169
  actualFee?: {
@@ -130,38 +172,36 @@ type StarknetTransaction<T> = BaseTransaction<T> & {
130
172
  };
131
173
  /** The address of the contract being interacted with. */
132
174
  contractAddress?: string;
133
- /** The reason for transaction failure, if applicable. */
134
- revertReason?: string;
135
175
  };
136
176
  /** A union type representing any possible transaction structure that Pulsar can handle. */
137
- type Transaction<T> = EvmTransaction<T> | SolanaTransaction<T> | StarknetTransaction<T>;
177
+ type Transaction = EvmTransaction | SolanaTransaction | StarknetTransaction;
138
178
  /**
139
179
  * Represents the parameters required to initiate a new transaction tracking flow.
140
180
  */
141
- type InitialTransactionParams<A> = {
181
+ type InitialTransactionParams = {
142
182
  adapter: TransactionAdapter;
143
- /** A function that can be re-executed. */
144
- actionFunction: (...args: any[]) => Promise<A | undefined>;
145
- /** A user-facing description for the transaction. */
183
+ /** The function that executes the on-chain action (e.g., sending a transaction) and returns a preliminary identifier like a hash. */
184
+ actionFunction: (...args: any[]) => Promise<ActionTxKey | undefined>;
185
+ /** A user-facing description for the transaction. Supports state-specific descriptions. */
146
186
  description?: string | [string, string, string, string];
147
187
  /** The target chain ID for the transaction. */
148
188
  desiredChainID: number | string;
149
189
  /** Any custom data to associate with the transaction. */
150
190
  payload?: object;
151
- /** A user-facing title for the transaction. */
191
+ /** A user-facing title for the transaction. Supports state-specific titles. */
152
192
  title?: string | [string, string, string, string];
153
193
  /** The application-specific type of the transaction. */
154
194
  type: string;
155
195
  /** If true, the detailed tracking modal will open automatically upon initiation. */
156
196
  withTrackedModal?: boolean;
157
- /** Required for Solana transactions. The RPC URL to use for the transaction. */
197
+ /** The RPC URL to use for the transaction. Required for Solana transactions. */
158
198
  rpcUrl?: string;
159
199
  };
160
200
  /**
161
201
  * Represents a transaction in its temporary, pre-submission state.
162
202
  * This is used for UI feedback while the transaction is being signed and sent.
163
203
  */
164
- type InitialTransaction<A> = InitialTransactionParams<A> & {
204
+ type InitialTransaction = InitialTransactionParams & {
165
205
  /** An error message if the initialization fails (e.g., user rejects signature). */
166
206
  errorMessage?: string;
167
207
  /** A flag indicating if the transaction is being processed (e.g., waiting for signature). */
@@ -173,11 +213,9 @@ type InitialTransaction<A> = InitialTransactionParams<A> & {
173
213
  };
174
214
  /**
175
215
  * Defines the interface for a transaction adapter, which provides chain-specific logic and utilities.
176
- * @template TR - The type of the tracker identifier (e.g., a string enum).
177
- * @template T - The specific transaction type, extending `Transaction<TR>`.
178
- * @template A - The type of the key returned by the `actionFunction` (e.g., a transaction hash).
216
+ * @template T The specific transaction type, extending `Transaction`.
179
217
  */
180
- type TxAdapter<TR, T extends Transaction<TR>, A> = {
218
+ type TxAdapter<T extends Transaction> = {
181
219
  /** The unique key identifying this adapter. */
182
220
  key: TransactionAdapter;
183
221
  /** Returns information about the currently connected wallet. */
@@ -185,19 +223,19 @@ type TxAdapter<TR, T extends Transaction<TR>, A> = {
185
223
  walletAddress: string;
186
224
  walletType: string;
187
225
  };
188
- /** Ensures the connected wallet is on the correct network for the transaction. */
226
+ /** Ensures the connected wallet is on the correct network for the transaction. Throws an error if the chain is mismatched. */
189
227
  checkChainForTx: (chainId: string | number) => Promise<void>;
190
- /** Determines the appropriate tracker and final `txKey` based on the result of an action. */
191
- checkTransactionsTracker: (actionTxKey: A, walletType: string) => {
228
+ /** Determines the appropriate tracker and final `txKey` from the result of an action. */
229
+ checkTransactionsTracker: (actionTxKey: ActionTxKey, walletType: string) => {
192
230
  txKey: string;
193
- tracker: TR;
231
+ tracker: TransactionTracker;
194
232
  };
195
- /** Initializes the correct background tracker for a given transaction. */
233
+ /** Selects and initializes the correct background tracker for a given transaction. */
196
234
  checkAndInitializeTrackerInStore: (params: {
197
235
  tx: T;
198
- } & Pick<ITxTrackingStore<TR, T, A>, 'transactionsPool' | 'updateTxParams' | 'onSucceedCallbacks' | 'removeTxFromPool'>) => Promise<void>;
199
- /** Returns the base URL for the blockchain explorer. */
200
- getExplorerUrl: () => string | undefined;
236
+ } & Pick<ITxTrackingStore<T>, 'updateTxParams' | 'removeTxFromPool'>) => Promise<void>;
237
+ /** Returns the base URL for the blockchain explorer for the current network. */
238
+ getExplorerUrl: (url?: string) => string | undefined;
201
239
  /** Optional: Fetches a name from a chain-specific name service (e.g., ENS). */
202
240
  getName?: (address: string) => Promise<string | null>;
203
241
  /** Optional: Fetches an avatar URL from a chain-specific name service. */
@@ -209,31 +247,34 @@ type TxAdapter<TR, T extends Transaction<TR>, A> = {
209
247
  /** Optional: Logic to retry a failed transaction. */
210
248
  retryTxAction?: (params: {
211
249
  txKey: string;
212
- tx: InitialTransactionParams<A>;
250
+ tx: InitialTransactionParams;
213
251
  onClose: (txKey?: string) => void;
214
- } & Partial<Pick<ITxTrackingStore<TR, T, A>, 'handleTransaction'>>) => Promise<void>;
215
- /** Optional: Constructs a full explorer URL for a specific transaction. */
216
- getExplorerTxUrl?: (transactionsPool: TransactionPool<TR, T>, txKey: string, replacedTxHash?: string) => string;
252
+ } & Partial<Pick<ITxTrackingStore<T>, 'handleTransaction'>>) => Promise<void>;
253
+ /**
254
+ * Optional: Constructs a full explorer URL for a specific transaction.
255
+ * May require the full transaction pool to resolve details for replaced transactions.
256
+ */
257
+ getExplorerTxUrl?: (tx: T) => string;
217
258
  };
218
259
  /**
219
260
  * The complete interface for the Pulsar transaction tracking store.
220
- * @template TR - The type of the tracker identifier.
221
- * @template T - The transaction type.
222
- * @template A - The return type of the `actionFunction`.
261
+ * @template T The transaction type.
223
262
  */
224
- type ITxTrackingStore<TR, T extends Transaction<TR>, A> = IInitializeTxTrackingStore<TR, T, A> & {
263
+ type ITxTrackingStore<T extends Transaction> = IInitializeTxTrackingStore<T> & {
225
264
  /**
226
- * The core function that handles the entire lifecycle of a new transaction.
265
+ * The primary method for initiating and tracking a new transaction from start to finish.
227
266
  * It manages UI state, executes the on-chain action, and initiates background tracking.
228
- * @param params - The parameters for handling the transaction.
267
+ * @param params The parameters for handling the transaction.
229
268
  */
230
269
  handleTransaction: (params: {
231
270
  /** The async function to execute (e.g., a smart contract write call). Must return a unique key or undefined. */
232
- actionFunction: () => Promise<A | undefined>;
271
+ actionFunction: () => Promise<ActionTxKey | undefined>;
233
272
  /** The metadata for the transaction. */
234
- params: Omit<InitialTransactionParams<A>, 'actionFunction'>;
273
+ params: Omit<InitialTransactionParams, 'actionFunction'>;
235
274
  /** The default tracker to use if it cannot be determined automatically. */
236
- defaultTracker?: TR;
275
+ defaultTracker?: TransactionTracker;
276
+ /** Callback to execute when the transaction is successfully submitted. */
277
+ onSucceedCallback?: (tx: T) => Promise<void> | void;
237
278
  }) => Promise<void>;
238
279
  /**
239
280
  * Initializes trackers for all pending transactions in the pool.
@@ -243,58 +284,53 @@ type ITxTrackingStore<TR, T extends Transaction<TR>, A> = IInitializeTxTrackingS
243
284
  };
244
285
 
245
286
  /**
246
- * @file This file provides the core slice for the Zustand store, responsible for managing the state of transactions.
247
- * It includes functions and types for initializing the store and performing basic CRUD operations on the transaction pool.
287
+ * @file This file defines the core Zustand slice for managing the state of transactions. It includes the state,
288
+ * actions, and types necessary for initializing the store and performing CRUD operations on the transaction pool.
248
289
  */
249
290
 
250
291
  /**
251
- * Defines the structure of the transaction pool, which is a record of transactions indexed by their unique keys.
252
- * @template TR - The type of the tracker identifier.
253
- * @template T - The transaction type.
292
+ * Defines the structure of the transaction pool, a key-value store of transactions indexed by their unique keys.
293
+ * @template T The type of the transaction object being tracked.
254
294
  */
255
- type TransactionPool<TR, T extends Transaction<TR>> = Record<string, T>;
295
+ type TransactionPool<T extends Transaction> = Record<string, T>;
256
296
  /**
257
- * A utility type that extracts a subset of fields from the `Transaction` type
258
- * that are updatable via the `updateTxParams` action.
259
- * @template TR - The type of the tracker identifier.
297
+ * A utility type that creates a union of all fields that can be safely updated
298
+ * on a transaction object via the `updateTxParams` action. This ensures type safety
299
+ * and prevents accidental modification of immutable properties.
260
300
  */
261
- type UpdatableTransactionFields<TR> = Partial<Pick<EvmTransaction<TR>, 'to' | 'nonce' | 'txKey' | 'pending' | 'hash' | 'status' | 'replacedTxHash' | 'errorMessage' | 'finishedTimestamp' | 'isTrackedModalOpen' | 'isError' | 'maxPriorityFeePerGas' | 'maxFeePerGas' | 'input' | 'value'>> & Partial<Pick<SolanaTransaction<TR>, 'slot' | 'confirmations' | 'fee' | 'instructions' | 'recentBlockhash' | 'rpcUrl'>>;
301
+ type UpdatableTransactionFields = Partial<Pick<EvmTransaction, 'to' | 'nonce' | 'txKey' | 'pending' | 'hash' | 'status' | 'replacedTxHash' | 'errorMessage' | 'finishedTimestamp' | 'isTrackedModalOpen' | 'isError' | 'maxPriorityFeePerGas' | 'maxFeePerGas' | 'input' | 'value'>> & Partial<Pick<SolanaTransaction, 'slot' | 'confirmations' | 'fee' | 'instructions' | 'recentBlockhash' | 'rpcUrl'>>;
262
302
  /**
263
- * Defines the interface for the base transaction tracking store slice.
264
- * It includes the state and actions for managing transactions.
265
- * @template TR - The type of the tracker identifier.
266
- * @template T - The transaction type.
303
+ * The interface for the base transaction tracking store slice.
304
+ * It includes the state and actions for managing the transaction lifecycle.
305
+ * @template T The specific transaction type.
267
306
  */
268
- interface IInitializeTxTrackingStore<TR, T extends Transaction<TR>, A> {
269
- /** An optional callback function to be executed when a transaction successfully completes. */
270
- onSucceedCallbacks?: (tx: T) => Promise<void> | void;
271
- /** A pool of all transactions currently being tracked, indexed by their `txKey`. */
272
- transactionsPool: TransactionPool<TR, T>;
273
- /** The key of the most recently added transaction. */
307
+ interface IInitializeTxTrackingStore<T extends Transaction> {
308
+ /** A pool of all transactions currently being tracked, indexed by `txKey`. */
309
+ transactionsPool: TransactionPool<T>;
310
+ /** The `txKey` of the most recently added transaction. */
274
311
  lastAddedTxKey?: string;
275
- /** The state of a transaction that is currently being initiated but not yet submitted. */
276
- initialTx?: InitialTransaction<A>;
277
- /** Adds a new transaction to the tracking pool. */
278
- addTxToPool: (tx: Transaction<TR>) => void;
279
- /** Updates one or more parameters of an existing transaction in the pool. */
280
- updateTxParams: (txKey: string, fields: UpdatableTransactionFields<TR>) => void;
281
- /** Removes a transaction from the tracking pool using its key. */
312
+ /** The state for a transaction being initiated, used for UI feedback before it's submitted to the chain. */
313
+ initialTx?: InitialTransaction;
314
+ /** Adds a new transaction to the tracking pool and marks it as pending. */
315
+ addTxToPool: (tx: T) => void;
316
+ /** Updates one or more properties of an existing transaction in the pool. */
317
+ updateTxParams: (txKey: string, fields: UpdatableTransactionFields) => void;
318
+ /** Removes a transaction from the tracking pool by its key. */
282
319
  removeTxFromPool: (txKey: string) => void;
283
- /** Closes the tracking modal for a specific transaction. */
320
+ /** Closes the tracking modal for a transaction and clears any initial transaction state. */
284
321
  closeTxTrackedModal: (txKey?: string) => void;
285
- /** Returns the key of the last transaction that was added to the pool. */
322
+ /** A selector function to retrieve the key of the last transaction added to the pool. */
286
323
  getLastTxKey: () => string | undefined;
287
324
  }
288
325
  /**
289
- * Creates a Zustand store slice containing the core logic for transaction tracking.
290
- * This function is a slice creator and is meant to be used within `createStore` from Zustand.
291
- * @param {object} options - Configuration options for the store slice.
292
- * @param {function} [options.onSucceedCallbacks] - An optional async callback to run when a transaction succeeds.
293
- * @returns {StoreSlice<IInitializeTxTrackingStore<TR, T>>} A Zustand store slice.
326
+ * Creates a Zustand store slice with the core logic for transaction state management.
327
+ * This function is a slice creator intended for use with Zustand's `create` function.
328
+ *
329
+ * @template T The specific transaction type.
330
+ * @param options Configuration for the store slice.
331
+ * @returns A Zustand store slice implementing `IInitializeTxTrackingStore`.
294
332
  */
295
- declare function initializeTxTrackingStore<TR, T extends Transaction<TR>, A>({ onSucceedCallbacks, }: {
296
- onSucceedCallbacks?: (tx: T) => Promise<void> | void;
297
- }): StoreSlice<IInitializeTxTrackingStore<TR, T, A>>;
333
+ declare function initializeTxTrackingStore<T extends Transaction>(): StoreSlice<IInitializeTxTrackingStore<T>>;
298
334
 
299
335
  /**
300
336
  * @file This file contains selector functions for deriving state from the transaction tracking store.
@@ -303,79 +339,70 @@ declare function initializeTxTrackingStore<TR, T extends Transaction<TR>, A>({ o
303
339
 
304
340
  /**
305
341
  * Selects all transactions from the pool and sorts them by their creation timestamp in ascending order.
306
- * @template TR - The type of the tracker identifier.
307
342
  * @template T - The transaction type.
308
- * @param {TransactionPool<TR, T>} transactionsPool - The entire transaction pool from the store.
343
+ * @param {TransactionPool<T>} transactionsPool - The entire transaction pool from the store.
309
344
  * @returns {T[]} An array of all transactions, sorted chronologically.
310
345
  */
311
- declare const selectAllTransactions: <TR, T extends Transaction<TR>>(transactionsPool: TransactionPool<TR, T>) => T[];
346
+ declare const selectAllTransactions: <T extends Transaction>(transactionsPool: TransactionPool<T>) => T[];
312
347
  /**
313
348
  * Selects all transactions that are currently in a pending state, sorted chronologically.
314
- * @template TR - The type of the tracker identifier.
315
349
  * @template T - The transaction type.
316
- * @param {TransactionPool<TR, T>} transactionsPool - The entire transaction pool from the store.
350
+ * @param {TransactionPool<T>} transactionsPool - The entire transaction pool from the store.
317
351
  * @returns {T[]} An array of pending transactions.
318
352
  */
319
- declare const selectPendingTransactions: <TR, T extends Transaction<TR>>(transactionsPool: TransactionPool<TR, T>) => T[];
353
+ declare const selectPendingTransactions: <T extends Transaction>(transactionsPool: TransactionPool<T>) => T[];
320
354
  /**
321
355
  * Selects a single transaction from the pool by its unique key (`txKey`).
322
- * @template TR - The type of the tracker identifier.
323
356
  * @template T - The transaction type.
324
- * @param {TransactionPool<TR, T>} transactionsPool - The entire transaction pool from the store.
357
+ * @param {TransactionPool<T>} transactionsPool - The entire transaction pool from the store.
325
358
  * @param {string} key - The `txKey` of the transaction to retrieve.
326
359
  * @returns {T | undefined} The transaction object if found, otherwise undefined.
327
360
  */
328
- declare const selectTxByKey: <TR, T extends Transaction<TR>>(transactionsPool: TransactionPool<TR, T>, key: string) => T | undefined;
361
+ declare const selectTxByKey: <T extends Transaction>(transactionsPool: TransactionPool<T>, key: string) => T | undefined;
329
362
  /**
330
363
  * Selects all transactions initiated by a specific wallet address, sorted chronologically.
331
- * @template TR - The type of the tracker identifier.
332
364
  * @template T - The transaction type.
333
- * @param {TransactionPool<TR, T>} transactionsPool - The entire transaction pool from the store.
365
+ * @param {TransactionPool<T>} transactionsPool - The entire transaction pool from the store.
334
366
  * @param {string} from - The wallet address (`from` address) to filter transactions by.
335
367
  * @returns {T[]} An array of transactions associated with the given wallet.
336
368
  */
337
- declare const selectAllTransactionsByActiveWallet: <TR, T extends Transaction<TR>>(transactionsPool: TransactionPool<TR, T>, from: string) => T[];
369
+ declare const selectAllTransactionsByActiveWallet: <T extends Transaction>(transactionsPool: TransactionPool<T>, from: string) => T[];
338
370
  /**
339
371
  * Selects all pending transactions for a specific wallet address, sorted chronologically.
340
- * @template TR - The type of the tracker identifier.
341
372
  * @template T - The transaction type.
342
- * @param {TransactionPool<TR, T>} transactionsPool - The entire transaction pool from the store.
373
+ * @param {TransactionPool<T>} transactionsPool - The entire transaction pool from the store.
343
374
  * @param {string} from - The wallet address (`from` address) to filter transactions by.
344
375
  * @returns {T[]} An array of pending transactions for the given wallet.
345
376
  */
346
- declare const selectPendingTransactionsByActiveWallet: <TR, T extends Transaction<TR>>(transactionsPool: TransactionPool<TR, T>, from: string) => T[];
377
+ declare const selectPendingTransactionsByActiveWallet: <T extends Transaction>(transactionsPool: TransactionPool<T>, from: string) => T[];
347
378
 
348
379
  /**
349
380
  * Creates the main Pulsar store for transaction tracking.
350
381
  *
351
- * This function sets up a Zustand store with persistence, combining the core
352
- * transaction slice with adapter-specific logic to handle the entire lifecycle
353
- * of a transaction.
382
+ * This function configures a Zustand store enhanced with persistence. It combines the core transaction management
383
+ * slice with a powerful orchestration logic that leverages chain-specific adapters to handle the entire
384
+ * lifecycle of a transaction—from initiation and chain validation to execution and background status tracking.
354
385
  *
355
- * @template TR - The type of the tracker identifier (e.g., a string enum).
356
- * @template T - The specific transaction type, extending the base `Transaction`.
357
- * @template A - The type for the adapter-specific context or API.
386
+ * @template T The specific transaction type, extending the base `Transaction`.
358
387
  *
359
- * @param {object} config - Configuration object for creating the store.
360
- * @param {function} [config.onSucceedCallbacks] - Optional async callback executed on transaction success.
361
- * @param {TxAdapter<TR, T, A>[]} config.adapters - An array of adapters for different transaction types or chains.
362
- * @param {PersistOptions<ITxTrackingStore<TR, T, A>>} [options] - Configuration for the Zustand persist middleware.
388
+ * @param config Configuration object for creating the store.
389
+ * @param config.adapter Adapter or an array of adapters for different chains or transaction types.
390
+ * @param options Configuration for the Zustand `persist` middleware.
363
391
  * @returns A fully configured Zustand store instance.
364
392
  */
365
- declare function createPulsarStore<TR, T extends Transaction<TR>, A>({ onSucceedCallbacks, adapters, ...options }: {
366
- onSucceedCallbacks?: (tx: T) => Promise<void> | void;
367
- adapters: TxAdapter<TR, T, A>[];
368
- } & PersistOptions<ITxTrackingStore<TR, T, A>>): Omit<zustand.StoreApi<ITxTrackingStore<TR, T, A>>, "setState" | "persist"> & {
369
- setState(partial: ITxTrackingStore<TR, T, A> | Partial<ITxTrackingStore<TR, T, A>> | ((state: ITxTrackingStore<TR, T, A>) => ITxTrackingStore<TR, T, A> | Partial<ITxTrackingStore<TR, T, A>>), replace?: false | undefined): unknown;
370
- setState(state: ITxTrackingStore<TR, T, A> | ((state: ITxTrackingStore<TR, T, A>) => ITxTrackingStore<TR, T, A>), replace: true): unknown;
393
+ declare function createPulsarStore<T extends Transaction>({ adapter, ...options }: {
394
+ adapter: TxAdapter<T> | TxAdapter<T>[];
395
+ } & PersistOptions<ITxTrackingStore<T>>): Omit<zustand.StoreApi<ITxTrackingStore<T>>, "setState" | "persist"> & {
396
+ setState(partial: ITxTrackingStore<T> | Partial<ITxTrackingStore<T>> | ((state: ITxTrackingStore<T>) => ITxTrackingStore<T> | Partial<ITxTrackingStore<T>>), replace?: false | undefined): unknown;
397
+ setState(state: ITxTrackingStore<T> | ((state: ITxTrackingStore<T>) => ITxTrackingStore<T>), replace: true): unknown;
371
398
  persist: {
372
- setOptions: (options: Partial<PersistOptions<ITxTrackingStore<TR, T, A>, ITxTrackingStore<TR, T, A>, unknown>>) => void;
399
+ setOptions: (options: Partial<PersistOptions<ITxTrackingStore<T>, ITxTrackingStore<T>, unknown>>) => void;
373
400
  clearStorage: () => void;
374
401
  rehydrate: () => Promise<void> | void;
375
402
  hasHydrated: () => boolean;
376
- onHydrate: (fn: (state: ITxTrackingStore<TR, T, A>) => void) => () => void;
377
- onFinishHydration: (fn: (state: ITxTrackingStore<TR, T, A>) => void) => () => void;
378
- getOptions: () => Partial<PersistOptions<ITxTrackingStore<TR, T, A>, ITxTrackingStore<TR, T, A>, unknown>>;
403
+ onHydrate: (fn: (state: ITxTrackingStore<T>) => void) => () => void;
404
+ onFinishHydration: (fn: (state: ITxTrackingStore<T>) => void) => () => void;
405
+ getOptions: () => Partial<PersistOptions<ITxTrackingStore<T>, ITxTrackingStore<T>, unknown>>;
379
406
  };
380
407
  };
381
408
 
@@ -424,8 +451,8 @@ declare const createBoundedUseStore: <S extends StoreApi<unknown>>(store: S) =>
424
451
  /**
425
452
  * Defines the parameters for the fetcher function used within the polling tracker.
426
453
  * The fetcher is the core logic that performs the actual API call.
427
- * @template R - The expected type of the successful API response.
428
- * @template T - The type of the transaction object being tracked.
454
+ * @template R The expected type of the successful API response.
455
+ * @template T The type of the transaction object being tracked.
429
456
  */
430
457
  type PollingFetcherParams<R, T> = {
431
458
  /** The transaction object being tracked. */
@@ -445,13 +472,12 @@ type PollingFetcherParams<R, T> = {
445
472
  };
446
473
  /**
447
474
  * Defines the configuration object for the `initializePollingTracker` function.
448
- * @template R - The expected type of the successful API response.
449
- * @template T - The type of the transaction object.
450
- * @template TR - The type of the tracker identifier.
475
+ * @template R The expected type of the successful API response.
476
+ * @template T The type of the transaction object.
451
477
  */
452
- type PollingTrackerConfig<R, T, TR> = {
478
+ type PollingTrackerConfig<R, T extends Transaction> = {
453
479
  /** The transaction object to be tracked. It must include `txKey` and `pending` status. */
454
- tx: T & Pick<Transaction<TR>, 'txKey' | 'pending'>;
480
+ tx: T & Pick<Transaction, 'txKey' | 'pending'>;
455
481
  /** The function that performs the data fetching (e.g., an API call) on each interval. */
456
482
  fetcher: (params: PollingFetcherParams<R, T>) => Promise<void>;
457
483
  /** Callback to be invoked when the transaction successfully completes. */
@@ -480,10 +506,9 @@ type PollingTrackerConfig<R, T, TR> = {
480
506
  *
481
507
  * @template R The expected type of the API response.
482
508
  * @template T The type of the transaction object.
483
- * @template TR The type of the tracker identifier.
484
- * @param {PollingTrackerConfig<R, T, TR>} config - The configuration for the tracker.
509
+ * @param {PollingTrackerConfig<R, T>} config - The configuration for the tracker.
485
510
  */
486
- declare function initializePollingTracker<R, T, TR>(config: PollingTrackerConfig<R, T, TR>): void;
511
+ declare function initializePollingTracker<R, T extends Transaction>(config: PollingTrackerConfig<R, T>): void;
487
512
 
488
513
  /**
489
514
  * @file This file contains a utility function for selecting a specific transaction adapter from a list.
@@ -497,19 +522,17 @@ declare function initializePollingTracker<R, T, TR>(config: PollingTrackerConfig
497
522
  * and returns the first adapter in the array as a fallback. This fallback mechanism
498
523
  * ensures that the system can still function, but it highlights a potential configuration issue.
499
524
  *
500
- * @template TR - The type of the tracker identifier.
501
525
  * @template T - The transaction type, extending the base `Transaction`.
502
- * @template A - The type for the adapter-specific context or API.
503
526
  *
504
527
  * @param {object} params - The parameters for the selection.
505
528
  * @param {TransactionAdapter} params.adapterKey - The key of the desired adapter.
506
- * @param {TxAdapter<TR, T, A>[]} params.adapters - An array of available transaction adapters.
529
+ * @param {TxAdapter<T> | TxAdapter<T>[]} params.adapter - Adapter or an array of adapters for different chains or transaction types.
507
530
  *
508
- * @returns {TxAdapter<TR, T, A> | undefined} The found transaction adapter, the fallback adapter, or undefined if the adapters array is empty.
531
+ * @returns {TxAdapter<T> | undefined} The found transaction adapter, the fallback adapter, or undefined if the adapters array is empty.
509
532
  */
510
- declare const selectAdapterByKey: <TR, T extends Transaction<TR>, A>({ adapterKey, adapters, }: {
533
+ declare const selectAdapterByKey: <T extends Transaction>({ adapterKey, adapter, }: {
511
534
  adapterKey: TransactionAdapter;
512
- adapters: TxAdapter<TR, T, A>[];
513
- }) => TxAdapter<TR, T, A> | undefined;
535
+ adapter: TxAdapter<T> | TxAdapter<T>[];
536
+ }) => TxAdapter<T> | undefined;
514
537
 
515
- export { type BaseTransaction, type EvmTransaction, type IInitializeTxTrackingStore, type ITxTrackingStore, type InitialTransaction, type InitialTransactionParams, type PollingTrackerConfig, type SolanaTransaction, type StarknetTransaction, type StoreSlice, type Transaction, TransactionAdapter, type TransactionPool, TransactionStatus, type TxAdapter, createBoundedUseStore, createPulsarStore, initializePollingTracker, initializeTxTrackingStore, selectAdapterByKey, selectAllTransactions, selectAllTransactionsByActiveWallet, selectPendingTransactions, selectPendingTransactionsByActiveWallet, selectTxByKey };
538
+ export { type ActionTxKey, type BaseTransaction, type EvmTransaction, type GelatoTxKey, type IInitializeTxTrackingStore, type ITxTrackingStore, type InitialTransaction, type InitialTransactionParams, type PollingTrackerConfig, type SolanaTransaction, type StarknetTransaction, type StoreSlice, type Transaction, TransactionAdapter, type TransactionPool, TransactionStatus, TransactionTracker, type TxAdapter, createBoundedUseStore, createPulsarStore, initializePollingTracker, initializeTxTrackingStore, selectAdapterByKey, selectAllTransactions, selectAllTransactionsByActiveWallet, selectPendingTransactions, selectPendingTransactionsByActiveWallet, selectTxByKey };