@tuwaio/nova-transactions 1.0.0-alpha.2.cdce32a → 1.0.0-alpha.4.a67b545

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,75 +4,91 @@
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';
53
65
 
54
66
  // Import required CSS
55
67
  import '@tuwaio/nova-core/dist/index.css';
56
68
  import '@tuwaio/nova-transactions/dist/index.css';
57
-
58
- // Your Wagmi Config
59
- import { wagmiConfig, appChains } from './wagmi';
69
+ import 'react-toastify/dist/ReactToastify.css';
60
70
 
61
71
  const queryClient = new QueryClient();
62
72
 
63
- export function Providers({ children }: { children: React.ReactNode }) {
64
- // 1. Get state and actions from your Pulsar store hook
65
- const { transactionsPool, initialTx, handleTransaction, closeTxTrackedModal } = usePulsarStore();
66
-
73
+ export function Providers({children}: { children: React.ReactNode }) {
74
+ // 1. Get live state and actions from your Pulsar store hook
75
+ const {
76
+ transactionsPool,
77
+ initialTx,
78
+ handleTransaction,
79
+ closeTxTrackedModal,
80
+ actions,
81
+ } = usePulsar();
82
+
67
83
  // 2. Get live wallet data from wagmi
68
- const { address, chain } = useAccount();
84
+ const {address, chain} = useAccount();
69
85
 
70
86
  return (
71
87
  <WagmiProvider config={wagmiConfig}>
72
88
  <QueryClientProvider client={queryClient}>
73
- {/* TransactionInitializer handles rehydrating the Pulsar store */}
74
- <TransactionInitializer />
75
-
89
+ {/* PulsarInitializer handles rehydrating the store on page load */}
90
+ <PulsarInitializer/>
91
+
76
92
  {/* Your application's pages */}
77
93
  {children}
78
94
 
@@ -83,15 +99,14 @@ export function Providers({ children }: { children: React.ReactNode }) {
83
99
  initialTx={initialTx}
84
100
  handleTransaction={handleTransaction}
85
101
  closeTxTrackedModal={closeTxTrackedModal}
86
-
87
- // Pass live wallet and chain data
88
- walletAddress={address}
89
- chain={chain}
90
-
102
+ actions={actions}
103
+
104
+ // Pass live wallet and adapter data
105
+ connectedWalletAddress={address}
106
+ connectedAdapterType={chain?.id ? TransactionAdapter.EVM : undefined} // Example for EVM
107
+
91
108
  // Pass static configuration
92
- appChains={appChains}
93
- config={wagmiConfig}
94
- // actions={...} // Pass retry actions if you have them
109
+ adapters={[evmAdapter(wagmiConfig, chains)]}
95
110
  />
96
111
  </QueryClientProvider>
97
112
  </WagmiProvider>
@@ -99,57 +114,39 @@ export function Providers({ children }: { children: React.ReactNode }) {
99
114
  }
100
115
  ```
101
116
 
102
- ## Usage Example
103
-
104
- 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.
105
-
106
- ```tsx
107
- // components/IncrementButton.tsx
108
- 'use client';
109
-
110
- // Import your custom hook, created as shown in the pulsar-react docs
111
- import { usePulsarStore } from '../hooks/usePulsarStore';
112
- // ... other imports
113
-
114
- export function IncrementButton() {
115
- const { handleTransaction } = usePulsarStore();
116
-
117
- const handleIncrement = async () => {
118
- // Calling handleTransaction updates the Pulsar store's state.
119
- // NovaProvider receives this new state via props and renders the appropriate UI.
120
- await handleTransaction({
121
- actionFunction: () => { /* ... your contract write call ... */ },
122
- params: { /* ... your transaction metadata ... */ }
123
- });
124
- };
125
-
126
- return <button onClick={handleIncrement}>Increment</button>;
127
- }
128
- ```
129
-
130
- ## Internationalization (i18n)
117
+ ## Customization
131
118
 
132
- You can easily override the default English text by passing a `labels` prop to the `NovaProvider`. Here is an example with German translations:
119
+ You can easily override the default English text by passing a `labels` prop, or replace entire components using the `customization` prop.
133
120
 
134
121
  ```tsx
135
122
  <NovaProvider
123
+ // 1. Override text labels
136
124
  labels={{
137
- transaction: {
138
- title: 'Transaktion',
139
- pending: 'Ausstehend...',
125
+ statuses: {
126
+ pending: 'In Bearbeitung...',
140
127
  success: 'Erfolgreich!',
141
128
  failed: 'Fehlgeschlagen!',
142
129
  },
143
130
  // ... other keys
144
131
  }}
132
+
133
+ // 2. Override a component (e.g., the status badge)
134
+ customization={{
135
+ components: {
136
+ statusBadge: ({ tx }) => <MyCustomBadge status={tx.status} />,
137
+ }
138
+ }}
139
+
145
140
  // ... other required props
146
141
  />
147
142
  ```
148
143
 
149
- ## Contributing
144
+ -----
145
+
146
+ ## 🤝 Contributing
150
147
 
151
- Contributions are welcome! Please read our main **[Contribution Guidelines](https://github.com/TuwaIO/workflows/blob/main/CONTRIBUTING.md)**.
148
+ Contributions are welcome\! Please read our main **[Contribution Guidelines](https://github.com/TuwaIO/workflows/blob/main/CONTRIBUTING.md)**.
152
149
 
153
- ## License
150
+ ## 📄 License
154
151
 
155
- This project is licensed under the **Apache-2.0 License**.
152
+ This project is licensed under the **Apache-2.0 License** - see the [LICENSE](./LICENSE) file for details.