@tuwaio/pulsar-core 0.0.2 → 0.0.3
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 +11 -15
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -33,22 +33,14 @@ This is the main factory function that creates your transaction store. It takes
|
|
|
33
33
|
```ts
|
|
34
34
|
import { createPulsarStore } from '@tuwaio/pulsar-core';
|
|
35
35
|
import { evmAdapter } from '@tuwaio/pulsar-evm'; // Example adapter
|
|
36
|
-
import { mainnet, sepolia } from 'viem/chains';
|
|
37
36
|
|
|
38
37
|
const pulsarStore = createPulsarStore({
|
|
39
38
|
// Unique name for Zustand's persistence middleware (localStorage key)
|
|
40
39
|
name: 'pulsar-storage',
|
|
41
|
-
|
|
42
|
-
// Array of chains supported by your dApp (from viem/chains)
|
|
43
|
-
appChains: [mainnet, sepolia],
|
|
44
|
-
|
|
45
|
-
// (Optional) An array of adapters for different blockchain ecosystems
|
|
40
|
+
// An array of adapters for different blockchain ecosystems
|
|
46
41
|
adapters: [
|
|
47
|
-
evmAdapter(
|
|
48
|
-
// EVM-specific config
|
|
49
|
-
}),
|
|
42
|
+
evmAdapter(config, chains),
|
|
50
43
|
],
|
|
51
|
-
|
|
52
44
|
// (Optional) Callbacks to execute on successful transaction
|
|
53
45
|
onSucceedCallbacks: {
|
|
54
46
|
onTxSucceed: (tx) => console.log('Transaction succeeded!', tx),
|
|
@@ -62,13 +54,17 @@ const pulsarStore = createPulsarStore({
|
|
|
62
54
|
The `createPulsarStore` function returns a Zustand store with the following state and actions:
|
|
63
55
|
|
|
64
56
|
#### State
|
|
65
|
-
- `
|
|
66
|
-
- `
|
|
67
|
-
- `
|
|
57
|
+
- `transactionsPool: Record<string, T>`: The primary state object. A map of all tracked transactions, where the key is the transaction's unique `txKey`.
|
|
58
|
+
- `initialTx?: InitialTransaction`: Holds the state of a transaction that is currently being initiated (e.g., waiting for a user's signature) but is not yet on-chain.
|
|
59
|
+
- `lastAddedTxKey?: string`: The `txKey` of the most recently added transaction, useful for quick access.
|
|
68
60
|
|
|
69
61
|
#### Actions
|
|
70
|
-
- `
|
|
71
|
-
- `initializeTransactionsPool(
|
|
62
|
+
- `handleTransaction(params)`: The primary, all-in-one function for initiating, sending, and tracking a new transaction.
|
|
63
|
+
- `initializeTransactionsPool()`: An async function to re-initialize trackers for any pending transactions stored from a previous session. Crucial for resuming tracking after a page reload.
|
|
64
|
+
- `addTxToPool({ tx })`: Adds a new transaction directly to the tracking pool.
|
|
65
|
+
- `updateTxParams(fields)`: Updates one or more properties of an existing transaction in the pool.
|
|
66
|
+
- `removeTxFromPool(txKey)`: Removes a transaction from the pool by its key.
|
|
67
|
+
- `closeTxTrackedModal(txKey?)`: Closes the tracking modal for a specific transaction and clears the `initialTx` state.
|
|
72
68
|
|
|
73
69
|
## ✨ How it Connects to the Ecosystem
|
|
74
70
|
|