@tuwaio/pulsar-react 0.0.5 → 0.0.7
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 +29 -19
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -18,17 +18,17 @@ Its primary role is to ensure that transaction tracking can resume reliably afte
|
|
|
18
18
|
|
|
19
19
|
## 💾 Installation
|
|
20
20
|
|
|
21
|
-
To use this package, you need the complete Pulsar stack, including
|
|
21
|
+
To use this package, you need the complete Pulsar stack, including `@wagmi/core` for EVM interactions.
|
|
22
22
|
|
|
23
23
|
```bash
|
|
24
24
|
# Using pnpm
|
|
25
|
-
pnpm add @tuwaio/pulsar-react @tuwaio/pulsar-core @tuwaio/pulsar-evm wagmi viem zustand immer
|
|
25
|
+
pnpm add @tuwaio/pulsar-react @tuwaio/pulsar-core @tuwaio/pulsar-evm @wagmi/core viem zustand immer dayjs
|
|
26
26
|
|
|
27
27
|
# Using npm
|
|
28
|
-
npm install @tuwaio/pulsar-react @tuwaio/pulsar-core @tuwaio/pulsar-evm wagmi viem zustand immer
|
|
28
|
+
npm install @tuwaio/pulsar-react @tuwaio/pulsar-core @tuwaio/pulsar-evm @wagmi/core viem zustand immer dayjs
|
|
29
29
|
|
|
30
30
|
# Using yarn
|
|
31
|
-
yarn add @tuwaio/pulsar-react @tuwaio/pulsar-core @tuwaio/pulsar-evm wagmi viem zustand immer
|
|
31
|
+
yarn add @tuwaio/pulsar-react @tuwaio/pulsar-core @tuwaio/pulsar-evm @wagmi/core viem zustand immer dayjs
|
|
32
32
|
```
|
|
33
33
|
|
|
34
34
|
---
|
|
@@ -43,24 +43,34 @@ Here is a complete step-by-step example:
|
|
|
43
43
|
|
|
44
44
|
First, create your vanilla Pulsar store and a reusable, bounded hook to access it. This pattern is recommended by Zustand for type safety and ease of use.
|
|
45
45
|
|
|
46
|
-
```
|
|
47
|
-
// src/
|
|
48
|
-
import { createBoundedUseStore, createPulsarStore } from '@tuwaio/pulsar-core';
|
|
46
|
+
```ts
|
|
47
|
+
// src/hooks/txTrackingHooks.ts
|
|
48
|
+
import { createBoundedUseStore, createPulsarStore, Transaction } from '@tuwaio/pulsar-core';
|
|
49
49
|
import { evmAdapter } from '@tuwaio/pulsar-evm';
|
|
50
|
-
import { wagmiConfig, chains } from '../configs/wagmi'; // Your wagmi config
|
|
51
50
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
51
|
+
import { appChains, config } from '@/configs/wagmiConfig';
|
|
52
|
+
|
|
53
|
+
const storageName = 'transactions-tracking-storage';
|
|
54
|
+
|
|
55
|
+
export enum TxType {
|
|
56
|
+
example = 'example',
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
type ExampleTx = Transaction & {
|
|
60
|
+
type: TxType.example;
|
|
61
|
+
payload: {
|
|
62
|
+
value: number;
|
|
63
|
+
};
|
|
64
|
+
};
|
|
58
65
|
|
|
59
|
-
|
|
60
|
-
export const usePulsar = createBoundedUseStore(pulsarStore);
|
|
66
|
+
export type TransactionUnion = ExampleTx;
|
|
61
67
|
|
|
62
|
-
|
|
63
|
-
|
|
68
|
+
export const usePulsarStore = createBoundedUseStore(
|
|
69
|
+
createPulsarStore<TransactionUnion>({
|
|
70
|
+
name: storageName,
|
|
71
|
+
adapter: evmAdapter(config, appChains),
|
|
72
|
+
}),
|
|
73
|
+
);
|
|
64
74
|
```
|
|
65
75
|
|
|
66
76
|
### Step 2: Initialize the Store in Your App
|
|
@@ -72,7 +82,7 @@ Create a small, client-side component that uses the `useInitializeTransactionsPo
|
|
|
72
82
|
'use client';
|
|
73
83
|
|
|
74
84
|
import { useInitializeTransactionsPool } from '@tuwaio/pulsar-react';
|
|
75
|
-
import {
|
|
85
|
+
import { usePulsarStore } from '../hooks/txTrackingHooks';
|
|
76
86
|
|
|
77
87
|
export const PulsarInitializer = () => {
|
|
78
88
|
// Get the initialization function from the store via our custom hook
|