@tuwaio/nova-transactions 0.0.14 → 0.0.16

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
@@ -4,76 +4,92 @@
4
4
  [![License](https://img.shields.io/npm/l/@tuwaio/nova-transactions.svg)](./LICENSE)
5
5
  [![Build Status](https://img.shields.io/github/actions/workflow/status/TuwaIO/nova-uikit/release.yml?branch=main)](https://github.com/TuwaIO/nova-uikit/actions)
6
6
 
7
- The official React UI component library for the Pulsar transaction engine. Provides accessible modals, toasts, and history widgets to visualize transaction states.
7
+ The official React UI component library for the Pulsar transaction engine. It provides a suite of pre-built, accessible, and highly customizable modals, toasts, and history widgets to visualize the entire transaction lifecycle.
8
8
 
9
- ## Architecture
9
+ ---
10
+
11
+ ## 🏛️ Architecture
10
12
 
11
13
  This package provides the **View Layer** for TUWA's transaction tracking ecosystem. It works by consuming the state from your headless Pulsar store and rendering the appropriate UI.
12
14
 
13
- You must connect your Pulsar store's state and actions to the `<NovaProvider />` component via props.
15
+ You must connect your Pulsar store's state and actions to the `<NovaProvider />` component, which acts as a self-contained UI manager that renders modals and toasts via React Portals.
16
+
17
+ ---
18
+
19
+ ## ✨ Core Features
20
+
21
+ - **🧩 Pre-built UI Suite:** A set of accessible components including `TrackingTxModal`, `WalletInfoModal`, and `ToastContainer`, all managed internally by the `NovaProvider`.
22
+ - **🔌 Plug-and-Play Integration:** Once connected to your Pulsar store, the UI automatically reacts to all transaction state changes.
23
+ - **🌐 Internationalization (i18n):** Built-in support for multiple languages with easy overrides for all text content via the `labels` prop.
24
+ - **🎨 Highly Customizable:** Styled with `@tuwaio/nova-core` to be easily themed using CSS variables. Almost every sub-component can be replaced with your own implementation via the `customization` prop.
14
25
 
15
- ## Core Features
26
+ ---
16
27
 
17
- - **🧩 UI Components:** A suite of pre-built, accessible components including `TransactionModal`, `ToastContainer`, and `WalletInfoModal`, all managed internally.
18
- - **🔌 Simple Integration:** Once connected to your Pulsar store, the UI automatically reacts to transaction state changes.
19
- - **🌐 Internationalization (i18n):** Built-in support for multiple languages and easy overrides for all text content.
20
- - **🎨 Highly Customizable:** Styled with `@tuwaio/nova-core` to be easily themed using Tailwind CSS.
28
+ ## 💾 Installation
21
29
 
22
- ## Installation
30
+ First, install all required packages for the Pulsar & Nova stack.
23
31
 
24
- 1. Install all the required TUWA packages:
32
+ Next, you need to install a few peer dependencies that `nova-transactions` relies on for UI rendering.
25
33
 
26
- ```bash
27
- pnpm add @tuwaio/nova-transactions @tuwaio/nova-core @tuwaio/pulsar-core @tuwaio/pulsar-evm @tuwaio/pulsar-react
28
- ```
34
+ ```bash
35
+ # Using pnpm
36
+ pnpm add react-toastify framer-motion @radix-ui/react-dialog @heroicons/react @bgd-labs/react-web3-icons @tuwaio/pulsar-core @tuwaio/nova-core
29
37
 
30
- 2. This package relies on several peer dependencies. Install them if you haven't already:
38
+ # Using npm
39
+ npm install react-toastify framer-motion @radix-ui/react-dialog @heroicons/react @bgd-labs/react-web3-icons @tuwaio/pulsar-core @tuwaio/nova-core
31
40
 
32
- ```bash
33
- pnpm add react react-dom wagmi viem react-toastify framer-motion @radix-ui/react-dialog
34
- ```
41
+ # Using yarn
42
+ yarn add react-toastify framer-motion @radix-ui/react-dialog @heroicons/react @bgd-labs/react-web3-icons @tuwaio/pulsar-core @tuwaio/nova-core
43
+ ````
35
44
 
36
- ## Getting Started
45
+ -----
37
46
 
38
- To use this library, you must render the `<NovaProvider />` component at the top level of your application and pass the state and actions from your Pulsar store to it as props.
47
+ ## 🚀 Getting Started
39
48
 
40
- Here is a complete example of a `providers.tsx` file that configures both systems:
49
+ To use this library, you must render the `<NovaProvider />` component at a high level in your application and pass the state and actions from your Pulsar store to it as props.
50
+
51
+ Here is a complete example of a `Providers.tsx` file that configures the entire system.
41
52
 
42
53
  ```tsx
43
- // app/providers.tsx or similar
54
+ // src/providers/index.tsx
44
55
  'use client';
45
56
 
46
- import { WagmiProvider, useAccount } from 'wagmi';
47
- import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
48
- import { NovaProvider } from '@tuwaio/nova-transactions';
49
-
50
- // Import your custom Pulsar hook and the TransactionInitializer component
51
- import { usePulsarStore } from '../hooks/usePulsarStore';
52
- import { TransactionInitializer } from '../components/TransactionInitializer';
57
+ import {usePulsar} from '@/store/pulsar';
58
+ import {NovaProvider} from '@tuwaio/nova-transactions';
59
+ import {useAccount} from 'wagmi';
60
+ import {QueryClient, QueryClientProvider} from '@tanstack/react-query';
61
+ import {WagmiProvider} from 'wagmi';
62
+ import {PulsarInitializer} from '@/components/PulsarInitializer';
63
+ import {wagmiConfig, chains, pulsarStore} from '@/configs'; // Your app's configs
64
+ import {TransactionAdapter} from '@tuwaio/pulsar-core';
65
+ import {evmAdapter} from '@tuwaio/pulsar-evm';
53
66
 
54
67
  // Import required CSS
55
68
  import '@tuwaio/nova-core/dist/index.css';
56
69
  import '@tuwaio/nova-transactions/dist/index.css';
57
70
  import 'react-toastify/dist/ReactToastify.css';
58
71
 
59
- // Your Wagmi Config
60
- import { wagmiConfig, appChains } from './wagmi';
61
-
62
72
  const queryClient = new QueryClient();
63
73
 
64
- export function Providers({ children }: { children: React.ReactNode }) {
65
- // 1. Get state and actions from your Pulsar store hook
66
- const { transactionsPool, initialTx, handleTransaction, closeTxTrackedModal } = usePulsarStore();
67
-
74
+ export function Providers({children}: { children: React.ReactNode }) {
75
+ // 1. Get live state and actions from your Pulsar store hook
76
+ const {
77
+ transactionsPool,
78
+ initialTx,
79
+ handleTransaction,
80
+ closeTxTrackedModal,
81
+ actions,
82
+ } = usePulsar();
83
+
68
84
  // 2. Get live wallet data from wagmi
69
- const { address, chain } = useAccount();
85
+ const {address, chain} = useAccount();
70
86
 
71
87
  return (
72
88
  <WagmiProvider config={wagmiConfig}>
73
89
  <QueryClientProvider client={queryClient}>
74
- {/* TransactionInitializer handles rehydrating the Pulsar store */}
75
- <TransactionInitializer />
76
-
90
+ {/* PulsarInitializer handles rehydrating the store on page load */}
91
+ <PulsarInitializer/>
92
+
77
93
  {/* Your application's pages */}
78
94
  {children}
79
95
 
@@ -84,15 +100,14 @@ export function Providers({ children }: { children: React.ReactNode }) {
84
100
  initialTx={initialTx}
85
101
  handleTransaction={handleTransaction}
86
102
  closeTxTrackedModal={closeTxTrackedModal}
87
-
88
- // Pass live wallet and chain data
89
- walletAddress={address}
90
- chain={chain}
91
-
103
+ actions={actions}
104
+
105
+ // Pass live wallet and adapter data
106
+ connectedWalletAddress={address}
107
+ connectedAdapterType={chain?.id ? TransactionAdapter.EVM : undefined} // Example for EVM
108
+
92
109
  // Pass static configuration
93
- appChains={appChains}
94
- config={wagmiConfig}
95
- // actions={...} // Pass retry actions if you have them
110
+ adapters={[evmAdapter(wagmiConfig, chains)]}
96
111
  />
97
112
  </QueryClientProvider>
98
113
  </WagmiProvider>
@@ -100,57 +115,39 @@ export function Providers({ children }: { children: React.ReactNode }) {
100
115
  }
101
116
  ```
102
117
 
103
- ## Usage Example
104
-
105
- Once the `NovaProvider` is set up correctly, you can use your custom `usePulsarStore` hook anywhere to track transactions. The UI components rendered by `NovaProvider` will automatically appear and update.
106
-
107
- ```tsx
108
- // components/IncrementButton.tsx
109
- 'use client';
110
-
111
- // Import your custom hook, created as shown in the pulsar-react docs
112
- import { usePulsarStore } from '../hooks/usePulsarStore';
113
- // ... other imports
114
-
115
- export function IncrementButton() {
116
- const { handleTransaction } = usePulsarStore();
117
-
118
- const handleIncrement = async () => {
119
- // Calling handleTransaction updates the Pulsar store's state.
120
- // NovaProvider receives this new state via props and renders the appropriate UI.
121
- await handleTransaction({
122
- actionFunction: () => { /* ... your contract write call ... */ },
123
- params: { /* ... your transaction metadata ... */ }
124
- });
125
- };
126
-
127
- return <button onClick={handleIncrement}>Increment</button>;
128
- }
129
- ```
130
-
131
- ## Internationalization (i18n)
118
+ ## Customization
132
119
 
133
- You can easily override the default English text by passing a `labels` prop to the `NovaProvider`. Here is an example with German translations:
120
+ You can easily override the default English text by passing a `labels` prop, or replace entire components using the `customization` prop.
134
121
 
135
122
  ```tsx
136
123
  <NovaProvider
124
+ // 1. Override text labels
137
125
  labels={{
138
- transaction: {
139
- title: 'Transaktion',
140
- pending: 'Ausstehend...',
126
+ statuses: {
127
+ pending: 'In Bearbeitung...',
141
128
  success: 'Erfolgreich!',
142
129
  failed: 'Fehlgeschlagen!',
143
130
  },
144
131
  // ... other keys
145
132
  }}
133
+
134
+ // 2. Override a component (e.g., the status badge)
135
+ customization={{
136
+ components: {
137
+ statusBadge: ({ tx }) => <MyCustomBadge status={tx.status} />,
138
+ }
139
+ }}
140
+
146
141
  // ... other required props
147
142
  />
148
143
  ```
149
144
 
150
- ## Contributing
145
+ -----
146
+
147
+ ## 🤝 Contributing
151
148
 
152
- Contributions are welcome! Please read our main **[Contribution Guidelines](https://github.com/TuwaIO/workflows/blob/main/CONTRIBUTING.md)**.
149
+ Contributions are welcome\! Please read our main **[Contribution Guidelines](https://github.com/TuwaIO/workflows/blob/main/CONTRIBUTING.md)**.
153
150
 
154
- ## License
151
+ ## 📄 License
155
152
 
156
- This project is licensed under the **Apache-2.0 License**.
153
+ This project is licensed under the **Apache-2.0 License** - see the [LICENSE](./LICENSE) file for details.