@tuwaio/pulsar-core 0.1.2 → 0.1.4
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 +1 -1
- package/dist/index.d.mts +96 -91
- package/dist/index.d.ts +96 -91
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -65,7 +65,7 @@ const pulsarStore = createPulsarStore({
|
|
|
65
65
|
|
|
66
66
|
// An array of adapters for different blockchain ecosystems.
|
|
67
67
|
// Each adapter provides chain-specific logic.
|
|
68
|
-
|
|
68
|
+
adapter: [
|
|
69
69
|
evmAdapter(wagmiConfig, chains),
|
|
70
70
|
// ... add other adapters like solanaAdapter here
|
|
71
71
|
],
|
package/dist/index.d.mts
CHANGED
|
@@ -25,6 +25,20 @@ 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
|
*/
|
|
@@ -36,12 +50,29 @@ declare enum TransactionStatus {
|
|
|
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
73
|
* This serves as the base upon which chain-specific transaction types are built.
|
|
42
|
-
* @template T The type of the tracker identifier (e.g., 'ethereum', 'gelato').
|
|
43
74
|
*/
|
|
44
|
-
type BaseTransaction
|
|
75
|
+
type BaseTransaction = {
|
|
45
76
|
/** The chain identifier (e.g., 1 for Ethereum Mainnet, 'SN_MAIN' for Starknet). */
|
|
46
77
|
chainId: number | string;
|
|
47
78
|
/**
|
|
@@ -81,7 +112,7 @@ type BaseTransaction<T> = {
|
|
|
81
112
|
*/
|
|
82
113
|
title?: string | [string, string, string, string];
|
|
83
114
|
/** The specific tracker responsible for monitoring this transaction's status. */
|
|
84
|
-
tracker:
|
|
115
|
+
tracker: TransactionTracker;
|
|
85
116
|
/** The unique identifier for the transaction (e.g., EVM hash, Gelato task ID). */
|
|
86
117
|
txKey: string;
|
|
87
118
|
/** The application-specific type or category of the transaction (e.g., 'SWAP', 'APPROVE'). */
|
|
@@ -91,9 +122,8 @@ type BaseTransaction<T> = {
|
|
|
91
122
|
};
|
|
92
123
|
/**
|
|
93
124
|
* Represents an EVM-specific transaction, extending the base properties with EVM fields.
|
|
94
|
-
* @template T The type of the tracker identifier.
|
|
95
125
|
*/
|
|
96
|
-
type EvmTransaction
|
|
126
|
+
type EvmTransaction = BaseTransaction & {
|
|
97
127
|
adapter: TransactionAdapter.EVM;
|
|
98
128
|
/** The on-chain transaction hash, available after submission. */
|
|
99
129
|
hash?: `0x${string}`;
|
|
@@ -114,9 +144,8 @@ type EvmTransaction<T> = BaseTransaction<T> & {
|
|
|
114
144
|
};
|
|
115
145
|
/**
|
|
116
146
|
* Represents a Solana-specific transaction, extending the base properties.
|
|
117
|
-
* @template T The type of the tracker identifier.
|
|
118
147
|
*/
|
|
119
|
-
type SolanaTransaction
|
|
148
|
+
type SolanaTransaction = BaseTransaction & {
|
|
120
149
|
adapter: TransactionAdapter.SOLANA;
|
|
121
150
|
/** The transaction fee in lamports. */
|
|
122
151
|
fee?: number;
|
|
@@ -133,9 +162,8 @@ type SolanaTransaction<T> = BaseTransaction<T> & {
|
|
|
133
162
|
};
|
|
134
163
|
/**
|
|
135
164
|
* Represents a Starknet-specific transaction, extending the base properties.
|
|
136
|
-
* @template T The type of the tracker identifier.
|
|
137
165
|
*/
|
|
138
|
-
type StarknetTransaction
|
|
166
|
+
type StarknetTransaction = BaseTransaction & {
|
|
139
167
|
adapter: TransactionAdapter.Starknet;
|
|
140
168
|
/** The actual fee paid for the transaction. */
|
|
141
169
|
actualFee?: {
|
|
@@ -144,18 +172,16 @@ type StarknetTransaction<T> = BaseTransaction<T> & {
|
|
|
144
172
|
};
|
|
145
173
|
/** The address of the contract being interacted with. */
|
|
146
174
|
contractAddress?: string;
|
|
147
|
-
/** The reason for transaction failure, if applicable. */
|
|
148
|
-
revertReason?: string;
|
|
149
175
|
};
|
|
150
176
|
/** A union type representing any possible transaction structure that Pulsar can handle. */
|
|
151
|
-
type Transaction
|
|
177
|
+
type Transaction = EvmTransaction | SolanaTransaction | StarknetTransaction;
|
|
152
178
|
/**
|
|
153
179
|
* Represents the parameters required to initiate a new transaction tracking flow.
|
|
154
180
|
*/
|
|
155
|
-
type InitialTransactionParams
|
|
181
|
+
type InitialTransactionParams = {
|
|
156
182
|
adapter: TransactionAdapter;
|
|
157
183
|
/** The function that executes the on-chain action (e.g., sending a transaction) and returns a preliminary identifier like a hash. */
|
|
158
|
-
actionFunction: (...args: any[]) => Promise<
|
|
184
|
+
actionFunction: (...args: any[]) => Promise<ActionTxKey | undefined>;
|
|
159
185
|
/** A user-facing description for the transaction. Supports state-specific descriptions. */
|
|
160
186
|
description?: string | [string, string, string, string];
|
|
161
187
|
/** The target chain ID for the transaction. */
|
|
@@ -175,7 +201,7 @@ type InitialTransactionParams<A> = {
|
|
|
175
201
|
* Represents a transaction in its temporary, pre-submission state.
|
|
176
202
|
* This is used for UI feedback while the transaction is being signed and sent.
|
|
177
203
|
*/
|
|
178
|
-
type InitialTransaction
|
|
204
|
+
type InitialTransaction = InitialTransactionParams & {
|
|
179
205
|
/** An error message if the initialization fails (e.g., user rejects signature). */
|
|
180
206
|
errorMessage?: string;
|
|
181
207
|
/** A flag indicating if the transaction is being processed (e.g., waiting for signature). */
|
|
@@ -187,11 +213,9 @@ type InitialTransaction<A> = InitialTransactionParams<A> & {
|
|
|
187
213
|
};
|
|
188
214
|
/**
|
|
189
215
|
* Defines the interface for a transaction adapter, which provides chain-specific logic and utilities.
|
|
190
|
-
* @template
|
|
191
|
-
* @template T The specific transaction type, extending `Transaction<TR>`.
|
|
192
|
-
* @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`.
|
|
193
217
|
*/
|
|
194
|
-
type TxAdapter<
|
|
218
|
+
type TxAdapter<T extends Transaction> = {
|
|
195
219
|
/** The unique key identifying this adapter. */
|
|
196
220
|
key: TransactionAdapter;
|
|
197
221
|
/** Returns information about the currently connected wallet. */
|
|
@@ -202,14 +226,14 @@ type TxAdapter<TR, T extends Transaction<TR>, A> = {
|
|
|
202
226
|
/** Ensures the connected wallet is on the correct network for the transaction. Throws an error if the chain is mismatched. */
|
|
203
227
|
checkChainForTx: (chainId: string | number) => Promise<void>;
|
|
204
228
|
/** Determines the appropriate tracker and final `txKey` from the result of an action. */
|
|
205
|
-
checkTransactionsTracker: (actionTxKey:
|
|
229
|
+
checkTransactionsTracker: (actionTxKey: ActionTxKey, walletType: string) => {
|
|
206
230
|
txKey: string;
|
|
207
|
-
tracker:
|
|
231
|
+
tracker: TransactionTracker;
|
|
208
232
|
};
|
|
209
233
|
/** Selects and initializes the correct background tracker for a given transaction. */
|
|
210
234
|
checkAndInitializeTrackerInStore: (params: {
|
|
211
235
|
tx: T;
|
|
212
|
-
} & Pick<ITxTrackingStore<
|
|
236
|
+
} & Pick<ITxTrackingStore<T>, 'transactionsPool' | 'updateTxParams' | 'onSucceedCallbacks' | 'removeTxFromPool'>) => Promise<void>;
|
|
213
237
|
/** Returns the base URL for the blockchain explorer for the current network. */
|
|
214
238
|
getExplorerUrl: () => string | undefined;
|
|
215
239
|
/** Optional: Fetches a name from a chain-specific name service (e.g., ENS). */
|
|
@@ -223,22 +247,20 @@ type TxAdapter<TR, T extends Transaction<TR>, A> = {
|
|
|
223
247
|
/** Optional: Logic to retry a failed transaction. */
|
|
224
248
|
retryTxAction?: (params: {
|
|
225
249
|
txKey: string;
|
|
226
|
-
tx: InitialTransactionParams
|
|
250
|
+
tx: InitialTransactionParams;
|
|
227
251
|
onClose: (txKey?: string) => void;
|
|
228
|
-
} & Partial<Pick<ITxTrackingStore<
|
|
252
|
+
} & Partial<Pick<ITxTrackingStore<T>, 'handleTransaction'>>) => Promise<void>;
|
|
229
253
|
/**
|
|
230
254
|
* Optional: Constructs a full explorer URL for a specific transaction.
|
|
231
255
|
* May require the full transaction pool to resolve details for replaced transactions.
|
|
232
256
|
*/
|
|
233
|
-
getExplorerTxUrl?: (transactionsPool: TransactionPool<
|
|
257
|
+
getExplorerTxUrl?: (transactionsPool: TransactionPool<T>, txKey: string, replacedTxHash?: string) => string;
|
|
234
258
|
};
|
|
235
259
|
/**
|
|
236
260
|
* The complete interface for the Pulsar transaction tracking store.
|
|
237
|
-
* @template TR The type of the tracker identifier.
|
|
238
261
|
* @template T The transaction type.
|
|
239
|
-
* @template A The return type of the `actionFunction`.
|
|
240
262
|
*/
|
|
241
|
-
type ITxTrackingStore<
|
|
263
|
+
type ITxTrackingStore<T extends Transaction> = IInitializeTxTrackingStore<T> & {
|
|
242
264
|
/**
|
|
243
265
|
* The primary method for initiating and tracking a new transaction from start to finish.
|
|
244
266
|
* It manages UI state, executes the on-chain action, and initiates background tracking.
|
|
@@ -246,11 +268,11 @@ type ITxTrackingStore<TR, T extends Transaction<TR>, A> = IInitializeTxTrackingS
|
|
|
246
268
|
*/
|
|
247
269
|
handleTransaction: (params: {
|
|
248
270
|
/** The async function to execute (e.g., a smart contract write call). Must return a unique key or undefined. */
|
|
249
|
-
actionFunction: () => Promise<
|
|
271
|
+
actionFunction: () => Promise<ActionTxKey | undefined>;
|
|
250
272
|
/** The metadata for the transaction. */
|
|
251
|
-
params: Omit<InitialTransactionParams
|
|
273
|
+
params: Omit<InitialTransactionParams, 'actionFunction'>;
|
|
252
274
|
/** The default tracker to use if it cannot be determined automatically. */
|
|
253
|
-
defaultTracker?:
|
|
275
|
+
defaultTracker?: TransactionTracker;
|
|
254
276
|
}) => Promise<void>;
|
|
255
277
|
/**
|
|
256
278
|
* Initializes trackers for all pending transactions in the pool.
|
|
@@ -266,37 +288,33 @@ type ITxTrackingStore<TR, T extends Transaction<TR>, A> = IInitializeTxTrackingS
|
|
|
266
288
|
|
|
267
289
|
/**
|
|
268
290
|
* Defines the structure of the transaction pool, a key-value store of transactions indexed by their unique keys.
|
|
269
|
-
* @template
|
|
270
|
-
* @template T The transaction type.
|
|
291
|
+
* @template T The type of the transaction object being tracked.
|
|
271
292
|
*/
|
|
272
|
-
type TransactionPool<
|
|
293
|
+
type TransactionPool<T extends Transaction> = Record<string, T>;
|
|
273
294
|
/**
|
|
274
295
|
* A utility type that creates a union of all fields that can be safely updated
|
|
275
296
|
* on a transaction object via the `updateTxParams` action. This ensures type safety
|
|
276
297
|
* and prevents accidental modification of immutable properties.
|
|
277
|
-
* @template TR The type of the tracker identifier.
|
|
278
298
|
*/
|
|
279
|
-
type UpdatableTransactionFields
|
|
299
|
+
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'>>;
|
|
280
300
|
/**
|
|
281
301
|
* The interface for the base transaction tracking store slice.
|
|
282
302
|
* It includes the state and actions for managing the transaction lifecycle.
|
|
283
|
-
* @template TR The type of the tracker identifier.
|
|
284
303
|
* @template T The specific transaction type.
|
|
285
|
-
* @template A The return type of the initial action function.
|
|
286
304
|
*/
|
|
287
|
-
interface IInitializeTxTrackingStore<
|
|
305
|
+
interface IInitializeTxTrackingStore<T extends Transaction> {
|
|
288
306
|
/** A callback function executed when any transaction successfully completes. */
|
|
289
307
|
onSucceedCallbacks?: (tx: T) => Promise<void> | void;
|
|
290
308
|
/** A pool of all transactions currently being tracked, indexed by `txKey`. */
|
|
291
|
-
transactionsPool: TransactionPool<
|
|
309
|
+
transactionsPool: TransactionPool<T>;
|
|
292
310
|
/** The `txKey` of the most recently added transaction. */
|
|
293
311
|
lastAddedTxKey?: string;
|
|
294
312
|
/** The state for a transaction being initiated, used for UI feedback before it's submitted to the chain. */
|
|
295
|
-
initialTx?: InitialTransaction
|
|
313
|
+
initialTx?: InitialTransaction;
|
|
296
314
|
/** Adds a new transaction to the tracking pool and marks it as pending. */
|
|
297
|
-
addTxToPool: (tx:
|
|
315
|
+
addTxToPool: (tx: T) => void;
|
|
298
316
|
/** Updates one or more properties of an existing transaction in the pool. */
|
|
299
|
-
updateTxParams: (txKey: string, fields: UpdatableTransactionFields
|
|
317
|
+
updateTxParams: (txKey: string, fields: UpdatableTransactionFields) => void;
|
|
300
318
|
/** Removes a transaction from the tracking pool by its key. */
|
|
301
319
|
removeTxFromPool: (txKey: string) => void;
|
|
302
320
|
/** Closes the tracking modal for a transaction and clears any initial transaction state. */
|
|
@@ -308,16 +326,14 @@ interface IInitializeTxTrackingStore<TR, T extends Transaction<TR>, A> {
|
|
|
308
326
|
* Creates a Zustand store slice with the core logic for transaction state management.
|
|
309
327
|
* This function is a slice creator intended for use with Zustand's `create` function.
|
|
310
328
|
*
|
|
311
|
-
* @template TR The type of the tracker identifier.
|
|
312
329
|
* @template T The specific transaction type.
|
|
313
|
-
* @template A The return type of the initial action function.
|
|
314
330
|
* @param options Configuration for the store slice.
|
|
315
331
|
* @param options.onSucceedCallbacks An optional async callback to run when a transaction succeeds.
|
|
316
332
|
* @returns A Zustand store slice implementing `IInitializeTxTrackingStore`.
|
|
317
333
|
*/
|
|
318
|
-
declare function initializeTxTrackingStore<
|
|
334
|
+
declare function initializeTxTrackingStore<T extends Transaction>({ onSucceedCallbacks, }: {
|
|
319
335
|
onSucceedCallbacks?: (tx: T) => Promise<void> | void;
|
|
320
|
-
}): StoreSlice<IInitializeTxTrackingStore<
|
|
336
|
+
}): StoreSlice<IInitializeTxTrackingStore<T>>;
|
|
321
337
|
|
|
322
338
|
/**
|
|
323
339
|
* @file This file contains selector functions for deriving state from the transaction tracking store.
|
|
@@ -326,47 +342,42 @@ declare function initializeTxTrackingStore<TR, T extends Transaction<TR>, A>({ o
|
|
|
326
342
|
|
|
327
343
|
/**
|
|
328
344
|
* Selects all transactions from the pool and sorts them by their creation timestamp in ascending order.
|
|
329
|
-
* @template TR - The type of the tracker identifier.
|
|
330
345
|
* @template T - The transaction type.
|
|
331
|
-
* @param {TransactionPool<
|
|
346
|
+
* @param {TransactionPool<T>} transactionsPool - The entire transaction pool from the store.
|
|
332
347
|
* @returns {T[]} An array of all transactions, sorted chronologically.
|
|
333
348
|
*/
|
|
334
|
-
declare const selectAllTransactions: <
|
|
349
|
+
declare const selectAllTransactions: <T extends Transaction>(transactionsPool: TransactionPool<T>) => T[];
|
|
335
350
|
/**
|
|
336
351
|
* Selects all transactions that are currently in a pending state, sorted chronologically.
|
|
337
|
-
* @template TR - The type of the tracker identifier.
|
|
338
352
|
* @template T - The transaction type.
|
|
339
|
-
* @param {TransactionPool<
|
|
353
|
+
* @param {TransactionPool<T>} transactionsPool - The entire transaction pool from the store.
|
|
340
354
|
* @returns {T[]} An array of pending transactions.
|
|
341
355
|
*/
|
|
342
|
-
declare const selectPendingTransactions: <
|
|
356
|
+
declare const selectPendingTransactions: <T extends Transaction>(transactionsPool: TransactionPool<T>) => T[];
|
|
343
357
|
/**
|
|
344
358
|
* Selects a single transaction from the pool by its unique key (`txKey`).
|
|
345
|
-
* @template TR - The type of the tracker identifier.
|
|
346
359
|
* @template T - The transaction type.
|
|
347
|
-
* @param {TransactionPool<
|
|
360
|
+
* @param {TransactionPool<T>} transactionsPool - The entire transaction pool from the store.
|
|
348
361
|
* @param {string} key - The `txKey` of the transaction to retrieve.
|
|
349
362
|
* @returns {T | undefined} The transaction object if found, otherwise undefined.
|
|
350
363
|
*/
|
|
351
|
-
declare const selectTxByKey: <
|
|
364
|
+
declare const selectTxByKey: <T extends Transaction>(transactionsPool: TransactionPool<T>, key: string) => T | undefined;
|
|
352
365
|
/**
|
|
353
366
|
* Selects all transactions initiated by a specific wallet address, sorted chronologically.
|
|
354
|
-
* @template TR - The type of the tracker identifier.
|
|
355
367
|
* @template T - The transaction type.
|
|
356
|
-
* @param {TransactionPool<
|
|
368
|
+
* @param {TransactionPool<T>} transactionsPool - The entire transaction pool from the store.
|
|
357
369
|
* @param {string} from - The wallet address (`from` address) to filter transactions by.
|
|
358
370
|
* @returns {T[]} An array of transactions associated with the given wallet.
|
|
359
371
|
*/
|
|
360
|
-
declare const selectAllTransactionsByActiveWallet: <
|
|
372
|
+
declare const selectAllTransactionsByActiveWallet: <T extends Transaction>(transactionsPool: TransactionPool<T>, from: string) => T[];
|
|
361
373
|
/**
|
|
362
374
|
* Selects all pending transactions for a specific wallet address, sorted chronologically.
|
|
363
|
-
* @template TR - The type of the tracker identifier.
|
|
364
375
|
* @template T - The transaction type.
|
|
365
|
-
* @param {TransactionPool<
|
|
376
|
+
* @param {TransactionPool<T>} transactionsPool - The entire transaction pool from the store.
|
|
366
377
|
* @param {string} from - The wallet address (`from` address) to filter transactions by.
|
|
367
378
|
* @returns {T[]} An array of pending transactions for the given wallet.
|
|
368
379
|
*/
|
|
369
|
-
declare const selectPendingTransactionsByActiveWallet: <
|
|
380
|
+
declare const selectPendingTransactionsByActiveWallet: <T extends Transaction>(transactionsPool: TransactionPool<T>, from: string) => T[];
|
|
370
381
|
|
|
371
382
|
/**
|
|
372
383
|
* Creates the main Pulsar store for transaction tracking.
|
|
@@ -375,9 +386,7 @@ declare const selectPendingTransactionsByActiveWallet: <TR, T extends Transactio
|
|
|
375
386
|
* slice with a powerful orchestration logic that leverages chain-specific adapters to handle the entire
|
|
376
387
|
* lifecycle of a transaction—from initiation and chain validation to execution and background status tracking.
|
|
377
388
|
*
|
|
378
|
-
* @template TR The type of the tracker identifier (e.g., a string enum).
|
|
379
389
|
* @template T The specific transaction type, extending the base `Transaction`.
|
|
380
|
-
* @template A The type of the key returned by the `actionFunction` (e.g., a transaction hash).
|
|
381
390
|
*
|
|
382
391
|
* @param config Configuration object for creating the store.
|
|
383
392
|
* @param config.onSucceedCallbacks Optional async callback executed on transaction success.
|
|
@@ -385,20 +394,20 @@ declare const selectPendingTransactionsByActiveWallet: <TR, T extends Transactio
|
|
|
385
394
|
* @param options Configuration for the Zustand `persist` middleware.
|
|
386
395
|
* @returns A fully configured Zustand store instance.
|
|
387
396
|
*/
|
|
388
|
-
declare function createPulsarStore<
|
|
397
|
+
declare function createPulsarStore<T extends Transaction>({ onSucceedCallbacks, adapter, ...options }: {
|
|
389
398
|
onSucceedCallbacks?: (tx: T) => Promise<void> | void;
|
|
390
|
-
adapter: TxAdapter<
|
|
391
|
-
} & PersistOptions<ITxTrackingStore<
|
|
392
|
-
setState(partial: ITxTrackingStore<
|
|
393
|
-
setState(state: ITxTrackingStore<
|
|
399
|
+
adapter: TxAdapter<T> | TxAdapter<T>[];
|
|
400
|
+
} & PersistOptions<ITxTrackingStore<T>>): Omit<zustand.StoreApi<ITxTrackingStore<T>>, "setState" | "persist"> & {
|
|
401
|
+
setState(partial: ITxTrackingStore<T> | Partial<ITxTrackingStore<T>> | ((state: ITxTrackingStore<T>) => ITxTrackingStore<T> | Partial<ITxTrackingStore<T>>), replace?: false | undefined): unknown;
|
|
402
|
+
setState(state: ITxTrackingStore<T> | ((state: ITxTrackingStore<T>) => ITxTrackingStore<T>), replace: true): unknown;
|
|
394
403
|
persist: {
|
|
395
|
-
setOptions: (options: Partial<PersistOptions<ITxTrackingStore<
|
|
404
|
+
setOptions: (options: Partial<PersistOptions<ITxTrackingStore<T>, ITxTrackingStore<T>, unknown>>) => void;
|
|
396
405
|
clearStorage: () => void;
|
|
397
406
|
rehydrate: () => Promise<void> | void;
|
|
398
407
|
hasHydrated: () => boolean;
|
|
399
|
-
onHydrate: (fn: (state: ITxTrackingStore<
|
|
400
|
-
onFinishHydration: (fn: (state: ITxTrackingStore<
|
|
401
|
-
getOptions: () => Partial<PersistOptions<ITxTrackingStore<
|
|
408
|
+
onHydrate: (fn: (state: ITxTrackingStore<T>) => void) => () => void;
|
|
409
|
+
onFinishHydration: (fn: (state: ITxTrackingStore<T>) => void) => () => void;
|
|
410
|
+
getOptions: () => Partial<PersistOptions<ITxTrackingStore<T>, ITxTrackingStore<T>, unknown>>;
|
|
402
411
|
};
|
|
403
412
|
};
|
|
404
413
|
|
|
@@ -447,8 +456,8 @@ declare const createBoundedUseStore: <S extends StoreApi<unknown>>(store: S) =>
|
|
|
447
456
|
/**
|
|
448
457
|
* Defines the parameters for the fetcher function used within the polling tracker.
|
|
449
458
|
* The fetcher is the core logic that performs the actual API call.
|
|
450
|
-
* @template R
|
|
451
|
-
* @template T
|
|
459
|
+
* @template R The expected type of the successful API response.
|
|
460
|
+
* @template T The type of the transaction object being tracked.
|
|
452
461
|
*/
|
|
453
462
|
type PollingFetcherParams<R, T> = {
|
|
454
463
|
/** The transaction object being tracked. */
|
|
@@ -468,13 +477,12 @@ type PollingFetcherParams<R, T> = {
|
|
|
468
477
|
};
|
|
469
478
|
/**
|
|
470
479
|
* Defines the configuration object for the `initializePollingTracker` function.
|
|
471
|
-
* @template R
|
|
472
|
-
* @template T
|
|
473
|
-
* @template TR - The type of the tracker identifier.
|
|
480
|
+
* @template R The expected type of the successful API response.
|
|
481
|
+
* @template T The type of the transaction object.
|
|
474
482
|
*/
|
|
475
|
-
type PollingTrackerConfig<R, T
|
|
483
|
+
type PollingTrackerConfig<R, T extends Transaction> = {
|
|
476
484
|
/** The transaction object to be tracked. It must include `txKey` and `pending` status. */
|
|
477
|
-
tx: T & Pick<Transaction
|
|
485
|
+
tx: T & Pick<Transaction, 'txKey' | 'pending'>;
|
|
478
486
|
/** The function that performs the data fetching (e.g., an API call) on each interval. */
|
|
479
487
|
fetcher: (params: PollingFetcherParams<R, T>) => Promise<void>;
|
|
480
488
|
/** Callback to be invoked when the transaction successfully completes. */
|
|
@@ -503,10 +511,9 @@ type PollingTrackerConfig<R, T, TR> = {
|
|
|
503
511
|
*
|
|
504
512
|
* @template R The expected type of the API response.
|
|
505
513
|
* @template T The type of the transaction object.
|
|
506
|
-
* @
|
|
507
|
-
* @param {PollingTrackerConfig<R, T, TR>} config - The configuration for the tracker.
|
|
514
|
+
* @param {PollingTrackerConfig<R, T>} config - The configuration for the tracker.
|
|
508
515
|
*/
|
|
509
|
-
declare function initializePollingTracker<R, T
|
|
516
|
+
declare function initializePollingTracker<R, T extends Transaction>(config: PollingTrackerConfig<R, T>): void;
|
|
510
517
|
|
|
511
518
|
/**
|
|
512
519
|
* @file This file contains a utility function for selecting a specific transaction adapter from a list.
|
|
@@ -520,19 +527,17 @@ declare function initializePollingTracker<R, T, TR>(config: PollingTrackerConfig
|
|
|
520
527
|
* and returns the first adapter in the array as a fallback. This fallback mechanism
|
|
521
528
|
* ensures that the system can still function, but it highlights a potential configuration issue.
|
|
522
529
|
*
|
|
523
|
-
* @template TR - The type of the tracker identifier.
|
|
524
530
|
* @template T - The transaction type, extending the base `Transaction`.
|
|
525
|
-
* @template A - The type for the adapter-specific context or API.
|
|
526
531
|
*
|
|
527
532
|
* @param {object} params - The parameters for the selection.
|
|
528
533
|
* @param {TransactionAdapter} params.adapterKey - The key of the desired adapter.
|
|
529
|
-
* @param {TxAdapter<
|
|
534
|
+
* @param {TxAdapter<T> | TxAdapter<T>[]} params.adapter - Adapter or an array of adapters for different chains or transaction types.
|
|
530
535
|
*
|
|
531
|
-
* @returns {TxAdapter<
|
|
536
|
+
* @returns {TxAdapter<T> | undefined} The found transaction adapter, the fallback adapter, or undefined if the adapters array is empty.
|
|
532
537
|
*/
|
|
533
|
-
declare const selectAdapterByKey: <
|
|
538
|
+
declare const selectAdapterByKey: <T extends Transaction>({ adapterKey, adapter, }: {
|
|
534
539
|
adapterKey: TransactionAdapter;
|
|
535
|
-
adapter: TxAdapter<
|
|
536
|
-
}) => TxAdapter<
|
|
540
|
+
adapter: TxAdapter<T> | TxAdapter<T>[];
|
|
541
|
+
}) => TxAdapter<T> | undefined;
|
|
537
542
|
|
|
538
|
-
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 };
|
|
543
|
+
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 };
|