@tuwaio/nova-transactions 0.0.15 → 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 +82 -84
- package/dist/WalletInfoModal-BcTPDgW_.d.cts +568 -0
- package/dist/WalletInfoModal-BcTPDgW_.d.ts +568 -0
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +5 -21
- package/dist/index.d.cts +32 -138
- package/dist/index.d.ts +32 -138
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/providers/index.cjs +1 -1
- package/dist/providers/index.cjs.map +1 -1
- package/dist/providers/index.d.cts +6 -39
- package/dist/providers/index.d.ts +6 -39
- package/dist/providers/index.js +1 -1
- package/dist/providers/index.js.map +1 -1
- package/package.json +13 -15
- package/dist/types-bqi7UbSO.d.cts +0 -625
- package/dist/types-bqi7UbSO.d.ts +0 -625
package/README.md
CHANGED
@@ -4,75 +4,92 @@
|
|
4
4
|
[](./LICENSE)
|
5
5
|
[](https://github.com/TuwaIO/nova-uikit/actions)
|
6
6
|
|
7
|
-
The official React UI component library for the Pulsar transaction engine.
|
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
|
-
|
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
|
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
|
-
|
26
|
+
---
|
16
27
|
|
17
|
-
|
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
|
-
|
30
|
+
First, install all required packages for the Pulsar & Nova stack.
|
23
31
|
|
24
|
-
|
32
|
+
Next, you need to install a few peer dependencies that `nova-transactions` relies on for UI rendering.
|
25
33
|
|
26
|
-
|
27
|
-
|
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
|
-
|
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
|
-
|
33
|
-
|
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
|
-
|
45
|
+
-----
|
37
46
|
|
38
|
-
|
47
|
+
## 🚀 Getting Started
|
39
48
|
|
40
|
-
|
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
|
-
//
|
54
|
+
// src/providers/index.tsx
|
44
55
|
'use client';
|
45
56
|
|
46
|
-
import {
|
47
|
-
import {
|
48
|
-
import {
|
49
|
-
|
50
|
-
|
51
|
-
import {
|
52
|
-
import {
|
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
|
-
|
58
|
-
// Your Wagmi Config
|
59
|
-
import { wagmiConfig, appChains } from './wagmi';
|
70
|
+
import 'react-toastify/dist/ReactToastify.css';
|
60
71
|
|
61
72
|
const queryClient = new QueryClient();
|
62
73
|
|
63
|
-
export function Providers({
|
64
|
-
// 1. Get state and actions from your Pulsar store hook
|
65
|
-
const {
|
66
|
-
|
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
|
+
|
67
84
|
// 2. Get live wallet data from wagmi
|
68
|
-
const {
|
85
|
+
const {address, chain} = useAccount();
|
69
86
|
|
70
87
|
return (
|
71
88
|
<WagmiProvider config={wagmiConfig}>
|
72
89
|
<QueryClientProvider client={queryClient}>
|
73
|
-
{/*
|
74
|
-
<
|
75
|
-
|
90
|
+
{/* PulsarInitializer handles rehydrating the store on page load */}
|
91
|
+
<PulsarInitializer/>
|
92
|
+
|
76
93
|
{/* Your application's pages */}
|
77
94
|
{children}
|
78
95
|
|
@@ -83,15 +100,14 @@ export function Providers({ children }: { children: React.ReactNode }) {
|
|
83
100
|
initialTx={initialTx}
|
84
101
|
handleTransaction={handleTransaction}
|
85
102
|
closeTxTrackedModal={closeTxTrackedModal}
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
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
|
+
|
91
109
|
// Pass static configuration
|
92
|
-
|
93
|
-
config={wagmiConfig}
|
94
|
-
// actions={...} // Pass retry actions if you have them
|
110
|
+
adapters={[evmAdapter(wagmiConfig, chains)]}
|
95
111
|
/>
|
96
112
|
</QueryClientProvider>
|
97
113
|
</WagmiProvider>
|
@@ -99,57 +115,39 @@ export function Providers({ children }: { children: React.ReactNode }) {
|
|
99
115
|
}
|
100
116
|
```
|
101
117
|
|
102
|
-
##
|
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)
|
118
|
+
## Customization
|
131
119
|
|
132
|
-
You can easily override the default English text by passing a `labels` prop
|
120
|
+
You can easily override the default English text by passing a `labels` prop, or replace entire components using the `customization` prop.
|
133
121
|
|
134
122
|
```tsx
|
135
123
|
<NovaProvider
|
124
|
+
// 1. Override text labels
|
136
125
|
labels={{
|
137
|
-
|
138
|
-
|
139
|
-
pending: 'Ausstehend...',
|
126
|
+
statuses: {
|
127
|
+
pending: 'In Bearbeitung...',
|
140
128
|
success: 'Erfolgreich!',
|
141
129
|
failed: 'Fehlgeschlagen!',
|
142
130
|
},
|
143
131
|
// ... other keys
|
144
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
|
+
|
145
141
|
// ... other required props
|
146
142
|
/>
|
147
143
|
```
|
148
144
|
|
149
|
-
|
145
|
+
-----
|
146
|
+
|
147
|
+
## 🤝 Contributing
|
150
148
|
|
151
|
-
Contributions are welcome
|
149
|
+
Contributions are welcome\! Please read our main **[Contribution Guidelines](https://github.com/TuwaIO/workflows/blob/main/CONTRIBUTING.md)**.
|
152
150
|
|
153
|
-
## License
|
151
|
+
## 📄 License
|
154
152
|
|
155
|
-
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.
|