@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 +86 -124
- package/dist/{TransactionsInfoModal-B5GHg2OG.d.cts → TransactionsInfoModal-s8Cm9SUV.d.cts} +426 -21
- package/dist/{TransactionsInfoModal-B5GHg2OG.d.ts → TransactionsInfoModal-s8Cm9SUV.d.ts} +426 -21
- package/dist/chunk-LUAH6VEC.js +2 -0
- package/dist/chunk-TRO5ODL2.cjs +2 -0
- package/dist/index.cjs +1 -1
- package/dist/index.css +301 -16
- package/dist/index.d.cts +52 -13
- package/dist/index.d.ts +52 -13
- package/dist/index.js +1 -1
- package/dist/providers/index.cjs +1 -1
- package/dist/providers/index.d.cts +70 -5
- package/dist/providers/index.d.ts +70 -5
- package/dist/providers/index.js +1 -1
- package/package.json +19 -19
- package/dist/chunk-ICHQF35O.js +0 -2
- package/dist/chunk-ISN2CHMB.cjs +0 -2
package/README.md
CHANGED
|
@@ -1,203 +1,165 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @tuwaio/nova-transactions
|
|
2
2
|
|
|
3
3
|
[](https://www.npmjs.com/package/@tuwaio/nova-transactions)
|
|
4
4
|
[](./LICENSE)
|
|
5
|
-
[](https://github.com/TuwaIO/nova-uikit/actions)
|
|
6
5
|
|
|
7
|
-
|
|
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
|
-
##
|
|
12
|
+
## 🏛️ Core Capabilities
|
|
18
13
|
|
|
19
|
-
- **🧩
|
|
20
|
-
- **🔌
|
|
21
|
-
-
|
|
22
|
-
-
|
|
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
|
-
|
|
29
|
+
Make sure your project contains the required layout and utility engines:
|
|
39
30
|
|
|
40
31
|
```bash
|
|
41
|
-
#
|
|
42
|
-
pnpm add
|
|
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
|
-
|
|
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
|
-
## 🚀
|
|
41
|
+
## 🚀 Quick Start Setup
|
|
67
42
|
|
|
68
|
-
|
|
43
|
+
### 1. Create the Transaction Store (Pulsar)
|
|
69
44
|
|
|
70
|
-
|
|
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/
|
|
76
|
-
|
|
77
|
-
import { evmAdapter } from '@tuwaio/pulsar-evm';
|
|
48
|
+
// src/hooks/usePulsarStore.ts
|
|
49
|
+
'use client';
|
|
78
50
|
|
|
79
|
-
import {
|
|
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
|
-
|
|
59
|
+
swap = 'swap',
|
|
85
60
|
}
|
|
86
61
|
|
|
87
|
-
type
|
|
88
|
-
type: TxType.
|
|
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 =
|
|
67
|
+
export type TransactionUnion = SwapTx;
|
|
95
68
|
|
|
96
69
|
export const usePulsarStore = createBoundedUseStore(
|
|
97
70
|
createPulsarStore<TransactionUnion>({
|
|
98
71
|
name: storageName,
|
|
99
|
-
adapter:
|
|
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
|
|
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/
|
|
108
|
-
|
|
109
|
-
|
|
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/
|
|
91
|
+
import { usePulsarStore } from '@/hooks/usePulsarStore';
|
|
114
92
|
|
|
115
|
-
export function
|
|
116
|
-
const
|
|
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
|
|
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
|
-
|
|
101
|
+
const activeConnection = useSatelliteConnectStore((state) => state.activeConnection);
|
|
124
102
|
|
|
125
|
-
|
|
103
|
+
// Resume tracking for active pending signatures on mount
|
|
104
|
+
useInitializeTransactionsPool({ initializeTransactionsPool });
|
|
126
105
|
|
|
127
106
|
return (
|
|
128
|
-
<
|
|
107
|
+
<NTP
|
|
129
108
|
transactionsPool={transactionsPool}
|
|
130
109
|
initialTx={initialTx}
|
|
131
110
|
closeTxTrackedModal={closeTxTrackedModal}
|
|
132
|
-
|
|
133
|
-
connectedWalletAddress={address}
|
|
134
|
-
connectedAdapterType={
|
|
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.
|
|
120
|
+
### 3. Usage in Action Buttons
|
|
142
121
|
|
|
143
|
-
|
|
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
|
-
|
|
150
|
-
|
|
151
|
-
import {
|
|
152
|
-
|
|
153
|
-
|
|
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
|
-
<
|
|
158
|
-
|
|
159
|
-
|
|
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
|
-
|
|
165
|
+
Licensed under the **Apache-2.0 License**. See the [LICENSE](./LICENSE) file for details.
|