@tuwaio/nova-transactions 1.0.0-fix-ui-alpha.1.bc1cb87 → 1.0.0-fix-docs-alpha.1.dfcdaa7c

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
@@ -1,203 +1,165 @@
1
- # TUWA Nova Transactions
1
+ # @tuwaio/nova-transactions
2
2
 
3
3
  [![NPM Version](https://img.shields.io/npm/v/@tuwaio/nova-transactions.svg)](https://www.npmjs.com/package/@tuwaio/nova-transactions)
4
4
  [![License](https://img.shields.io/npm/l/@tuwaio/nova-transactions.svg)](./LICENSE)
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
5
 
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.
6
+ `@tuwaio/nova-transactions` is the **UI Components (L7)** package of the TUWA Ecosystem transaction lifecycle tracking system. It provides the visual layer to monitor, display, and manage active on-chain transactions, consuming state directly from the headless **[Pulsar Engine](https://github.com/TuwaIO/pulsar-core)** state machine.
8
7
 
9
- ---
10
-
11
- ## 🏛️ Architecture
12
-
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. You must connect your Pulsar store's state and actions to the `<NovaTransactionsProvider />` component, which acts as a self-contained UI manager that renders modals and toasts.
8
+ By coupling the UI manager to Pulsar stores, it automatically handles pending loaders, speed-up options, failure overlays, and success notifications, keeping the user in the loop even during congested block space periods.
14
9
 
15
10
  ---
16
11
 
17
- ## Core Features
12
+ ## 🏛️ Core Capabilities
18
13
 
19
- - **🧩 Pre-built UI Suite:** A set of accessible components including `TrackingTxModal`, `TransactionsInfoModal`, and `ToastTransaction`, all managed internally by the `NovaTransactionsProvider`.
20
- - **🔌 Plug-and-Play Integration:** Once connected to your Pulsar store, the UI automatically reacts to all transaction state changes.
21
- - **🌐 Internationalization (custom version of i18n):** Built-in support for multiple languages with easy overrides for all text content via the `labels` prop.
22
- - **🎨 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
+ - **🧩 Interactive Visual Nodes:** Built-in dialogs and widget cards (`TrackingTxModal` for individual status, `TransactionsInfoModal` for full transaction lists, and `ToastTransaction` feeds).
15
+ - **🔌 Isolated Provider Hooks:** The `<NovaTransactionsProvider />` bridges your React tree with Pulsar's transaction history pools and signature polling events.
16
+ - **🎨 Custom Styling overrides:** Style sub-components via CSS variables from `@tuwaio/nova-core` or replace components using the `customization` property.
17
+ - **🌍 Dynamic Internationalization:** Supports overriding labels configuration to localize status messages (`pending`, `success`, `failed`, `replaced`) and actions.
23
18
 
24
19
  ---
25
20
 
26
21
  ## 💾 Installation
27
22
 
28
- ### Basic Installation
29
-
30
- Install the main package:
31
-
32
23
  ```bash
33
- pnpm add @tuwaio/nova-transactions
24
+ pnpm add @tuwaio/nova-transactions @tuwaio/nova-core @tuwaio/pulsar-core @tuwaio/pulsar-react
34
25
  ```
35
26
 
36
- ### Peer Dependencies
27
+ ### Peer Dependencies Check
37
28
 
38
- This package requires several peer dependencies for UI rendering:
29
+ Make sure your project contains the required layout and utility engines:
39
30
 
40
31
  ```bash
41
- # Core dependencies
42
- pnpm add @tuwaio/nova-core @tuwaio/pulsar-core @tuwaio/orbit-core
43
-
44
- # React ecosystem
45
- pnpm add react react-dom zustand immer
46
-
47
- # UI libraries
48
- pnpm add framer-motion @radix-ui/react-dialog @heroicons/react
49
- pnpm add react-toastify @web3icons/common @web3icons/react
50
-
51
- # Utilities
52
- pnpm add dayjs clsx tailwind-merge
53
- ```
32
+ # State & Utilities
33
+ pnpm add zustand immer dayjs clsx tailwind-merge framer-motion
54
34
 
55
- ### Complete Installation (All Packages)
56
-
57
- For a complete setup with all TUWA packages:
58
-
59
- ```bash
60
- # Using pnpm (recommended), but you can use npm, yarn or bun as well
61
- pnpm add @tuwaio/nova-transactions @tuwaio/nova-core @tuwaio/pulsar-core @tuwaio/orbit-core react-toastify framer-motion @radix-ui/react-dialog @heroicons/react @web3icons/common @web3icons/react dayjs react immer zustand clsx tailwind-merge
35
+ # Dialog Primitives & Notifications
36
+ pnpm add @radix-ui/react-dialog @heroicons/react @web3icons/common @web3icons/react react-toastify
62
37
  ```
63
38
 
64
39
  ---
65
40
 
66
- ## 🚀 Getting Started
41
+ ## 🚀 Quick Start Setup
67
42
 
68
- To use this library, you must render the `<NovaTransactionsProvider />` component at a high level in your application and pass the state and actions from your Pulsar store to it as props.
43
+ ### 1. Create the Transaction Store (Pulsar)
69
44
 
70
- Here is a complete example of a `src/providers/index.tsx` file that configures the entire system.
71
-
72
- ### 1. Create Transaction Store
45
+ Initialize the local-first persistent transaction store with chain-specific state adapters:
73
46
 
74
47
  ```tsx
75
- // src/hooks/txTrackingHooks.tsx
76
- import { createBoundedUseStore, createPulsarStore } from '@tuwaio/pulsar-core';
77
- import { evmAdapter } from '@tuwaio/pulsar-evm';
48
+ // src/hooks/usePulsarStore.ts
49
+ 'use client';
78
50
 
79
- import { appChains, config } from '@/configs/wagmiConfig';
51
+ import { createBoundedUseStore, createPulsarStore, Transaction } from '@tuwaio/pulsar-core';
52
+ import { pulsarEvmAdapter } from '@tuwaio/pulsar-evm';
53
+ import { pulsarSolanaAdapter } from '@tuwaio/pulsar-solana';
54
+ import { wagmiConfig, appEVMChains, solanaRPCUrls } from '@/config/appConfig';
80
55
 
81
56
  const storageName = 'transactions-tracking-storage';
82
57
 
83
58
  export enum TxType {
84
- example = 'example',
59
+ swap = 'swap',
85
60
  }
86
61
 
87
- type ExampleTx = Transaction & {
88
- type: TxType.example;
89
- payload: {
90
- value: number;
91
- };
62
+ type SwapTx = Transaction & {
63
+ type: TxType.swap;
64
+ payload: { from: string; to: string; amount: string };
92
65
  };
93
66
 
94
- export type TransactionUnion = ExampleTx;
67
+ export type TransactionUnion = SwapTx;
95
68
 
96
69
  export const usePulsarStore = createBoundedUseStore(
97
70
  createPulsarStore<TransactionUnion>({
98
71
  name: storageName,
99
- adapter: evmAdapter(config, appChains),
72
+ adapter: [pulsarEvmAdapter(wagmiConfig, appEVMChains), pulsarSolanaAdapter({ rpcUrls: solanaRPCUrls })],
73
+ maxTransactions: 50, // prevent localStorage bloat
100
74
  }),
101
75
  );
102
76
  ```
103
77
 
104
- ### 2. Setup Provider Component
78
+ ### 2. Setup the Transactions UI Provider
79
+
80
+ Create a bridge component connecting your Pulsar store parameters and Satellite wallet state with the Nova Transactions UI:
105
81
 
106
82
  ```tsx
107
- // src/providers/NovaTransactionsProvider.tsx
108
- import { NovaTransactionsProvider as NP } from '@tuwaio/nova-transactions/providers';
109
- import { TransactionAdapter } from '@tuwaio/pulsar-core';
83
+ // src/providers/NovaTransactionsWrapper.tsx
84
+ 'use client';
85
+
86
+ import { useSatelliteConnectStore } from '@tuwaio/nova-connect/satellite';
87
+ import { NovaTransactionsProvider as NTP } from '@tuwaio/nova-transactions/providers';
88
+ import { getAdapterFromConnectorType } from '@tuwaio/orbit-core';
110
89
  import { useInitializeTransactionsPool } from '@tuwaio/pulsar-react';
111
- import { useAccount } from 'wagmi';
112
90
 
113
- import { usePulsarStore } from '@/hooks/txTrackingHooks';
91
+ import { usePulsarStore } from '@/hooks/usePulsarStore';
114
92
 
115
- export function NovaTransactionsProvider() {
116
- const transactionsPool = usePulsarStore((state) => state.transactionsPool);
93
+ export function NovaTransactionsWrapper() {
94
+ const getAdapter = usePulsarStore((state) => state.getAdapter);
117
95
  const initialTx = usePulsarStore((state) => state.initialTx);
118
96
  const closeTxTrackedModal = usePulsarStore((state) => state.closeTxTrackedModal);
119
- const handleTransaction = usePulsarStore((state) => state.handleTransaction);
97
+ const transactionsPool = usePulsarStore((state) => state.transactionsPool);
98
+ const executeTxAction = usePulsarStore((state) => state.executeTxAction);
120
99
  const initializeTransactionsPool = usePulsarStore((state) => state.initializeTransactionsPool);
121
- const getAdapter = usePulsarStore((state) => state.getAdapter);
122
100
 
123
- useInitializeTransactionsPool({ initializeTransactionsPool });
101
+ const activeConnection = useSatelliteConnectStore((state) => state.activeConnection);
124
102
 
125
- const { address } = useAccount();
103
+ // Resume tracking for active pending signatures on mount
104
+ useInitializeTransactionsPool({ initializeTransactionsPool });
126
105
 
127
106
  return (
128
- <NP
107
+ <NTP
129
108
  transactionsPool={transactionsPool}
130
109
  initialTx={initialTx}
131
110
  closeTxTrackedModal={closeTxTrackedModal}
132
- handleTransaction={handleTransaction}
133
- connectedWalletAddress={address}
134
- connectedAdapterType={TransactionAdapter.EVM}
111
+ executeTxAction={executeTxAction}
112
+ connectedWalletAddress={activeConnection?.isConnected ? activeConnection.address : undefined}
113
+ connectedAdapterType={getAdapterFromConnectorType(activeConnection?.connectorType ?? 'evm:')}
135
114
  adapter={getAdapter()}
136
115
  />
137
116
  );
138
117
  }
139
118
  ```
140
119
 
141
- ### 3. Integrate into App
120
+ ### 3. Usage in Action Buttons
142
121
 
143
- ```tsx
144
- // src/providers/index.tsx
145
- import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
146
- import { ReactNode } from 'react';
147
- import { WagmiProvider } from 'wagmi';
122
+ Call the action wrapper to trigger on-chain operations and auto-render status modals:
148
123
 
149
- import { config } from '@/configs/wagmiConfig';
150
-
151
- import { NovaTransactionsProvider } from './NovaTransactionsProvider';
152
-
153
- const queryClient = new QueryClient();
124
+ ```tsx
125
+ import { usePulsarStore, TxType } from '@/hooks/usePulsarStore';
126
+ import { OrbitAdapter } from '@tuwaio/orbit-core';
127
+ import { mainnet } from 'viem/chains';
128
+
129
+ export function SwapButton() {
130
+ const executeTxAction = usePulsarStore((state) => state.executeTxAction);
131
+
132
+ const triggerSwap = async () => {
133
+ const swapFunction = async () => {
134
+ // Execute smart contract write method and return the hash
135
+ return '0x...';
136
+ };
137
+
138
+ await executeTxAction({
139
+ actionFunction: swapFunction,
140
+ onSuccess: (tx) => console.log('Transaction succeeded!', tx.hash),
141
+ params: {
142
+ type: TxType.swap,
143
+ adapter: OrbitAdapter.EVM,
144
+ desiredChainID: mainnet.id,
145
+ title: 'Swap ETH',
146
+ description: 'Swapping 1 ETH for USDC',
147
+ payload: { from: 'ETH', to: 'USDC', amount: '1' },
148
+ withTrackedModal: true, // opens tracking overlay automatically
149
+ },
150
+ });
151
+ };
154
152
 
155
- export function Providers({ children }: { children: ReactNode }) {
156
153
  return (
157
- <WagmiProvider config={config}>
158
- <QueryClientProvider client={queryClient}>
159
- <NovaTransactionsProvider />
160
- {children}
161
- </QueryClientProvider>
162
- </WagmiProvider>
154
+ <button onClick={triggerSwap} className="btn-primary">
155
+ Execute Swap
156
+ </button>
163
157
  );
164
158
  }
165
159
  ```
166
160
 
167
- ## 🎨 Customization
168
-
169
- You can easily override the default English text by passing a `labels` prop, or replace entire components using the `customization` prop.
170
-
171
- ```tsx
172
- <NovaTransactionsProvider
173
- // 1. Override text labels
174
- labels={{
175
- statuses: {
176
- pending: 'В обработке...',
177
- success: 'Успешно!',
178
- failed: 'Ошибка!',
179
- },
180
- // ... other keys
181
- }}
182
- customization={{
183
- components: {
184
- statusBadge: ({ tx }) => <MyCustomBadge status={tx.status} />,
185
- },
186
- }}
187
- // ... other required props
188
- />
189
- ```
190
-
191
161
  ---
192
162
 
193
- ## 🤝 Contributing & Support
194
-
195
- Contributions are welcome! Please read our main **[Contribution Guidelines](https://github.com/TuwaIO/workflows/blob/main/CONTRIBUTING.md)**.
196
-
197
- If you find this library useful, please consider supporting its development. Every contribution helps!
198
-
199
- [**➡️ View Support Options**](https://github.com/TuwaIO/workflows/blob/main/Donation.md)
200
-
201
163
  ## 📄 License
202
164
 
203
- This project is licensed under the **Apache-2.0 License** - see the [LICENSE](./LICENSE) file for details.
165
+ Licensed under the **Apache-2.0 License**. See the [LICENSE](./LICENSE) file for details.