@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.
Files changed (2) hide show
  1. package/README.md +29 -19
  2. 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 `wagmi` for EVM interactions.
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
- ```tsx
47
- // src/store/pulsar.ts
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
- // 1. Create the vanilla store instance
53
- const pulsarStore = createPulsarStore({
54
- name: 'my-app-pulsar-storage',
55
- adapters: [evmAdapter(wagmiConfig, chains)],
56
- // ... other configurations
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
- // 2. Create and export the bounded hook for React components
60
- export const usePulsar = createBoundedUseStore(pulsarStore);
66
+ export type TransactionUnion = ExampleTx;
61
67
 
62
- // 3. Export the vanilla store for non-React usage if needed
63
- export default pulsarStore;
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 { usePulsar } from '../store/pulsar';
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
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tuwaio/pulsar-react",
3
- "version": "0.0.5",
3
+ "version": "0.0.7",
4
4
  "private": false,
5
5
  "author": "Oleksandr Tkach",
6
6
  "license": "Apache-2.0",