@tuwaio/nova-transactions 0.0.3 → 0.0.5

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.
Files changed (3) hide show
  1. package/README.md +51 -57
  2. package/dist/index.css +3 -0
  3. package/package.json +16 -3
package/README.md CHANGED
@@ -8,17 +8,14 @@ The official React UI component library for the Pulsar transaction engine. Provi
8
8
 
9
9
  ## Architecture
10
10
 
11
- This package provides the **View Layer** for TUWA's transaction tracking ecosystem. It works in tandem with our headless state management libraries:
11
+ 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
12
 
13
- - **`@tuwaio/pulsar-core`**: The core state management engine.
14
- - **`@tuwaio/nova-transactions` (this package)**: The React components that consume state from `pulsar-core` and render the UI.
15
-
16
- You must set up both the Pulsar engine and this UI package to achieve the full functionality.
13
+ You must connect your Pulsar store's state and actions to the `<NovaProvider />` component via props.
17
14
 
18
15
  ## Core Features
19
16
 
20
- - **🧩 UI Components:** A suite of pre-built, accessible components including `TransactionModal`, `TransactionToasts`, and `TransactionHistory`.
21
- - **🔌 Simple Integration:** The UI automatically reacts to transactions tracked by `pulsar-core`.
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.
22
19
  - **🌐 Internationalization (i18n):** Built-in support for multiple languages and easy overrides for all text content.
23
20
  - **🎨 Highly Customizable:** Styled with `@tuwaio/nova-core` to be easily themed using Tailwind CSS.
24
21
 
@@ -38,7 +35,7 @@ You must set up both the Pulsar engine and this UI package to achieve the full f
38
35
 
39
36
  ## Getting Started
40
37
 
41
- To use this library, you need to set up the `NovaProvider` from this package alongside the Pulsar initialization logic.
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.
42
39
 
43
40
  Here is a complete example of a `providers.tsx` file that configures both systems:
44
41
 
@@ -46,37 +43,57 @@ Here is a complete example of a `providers.tsx` file that configures both system
46
43
  // app/providers.tsx or similar
47
44
  'use client';
48
45
 
49
- import { WagmiProvider } from 'wagmi';
46
+ import { WagmiProvider, useAccount } from 'wagmi';
50
47
  import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
51
- import { NovaProvider, TransactionToasts } from '@tuwaio/nova-transactions';
52
- import { ToastContainer } from 'react-toastify';
48
+ import { NovaProvider } from '@tuwaio/nova-transactions';
53
49
 
54
- // Import the TransactionInitializer component you created (see pulsar-react docs)
50
+ // Import your custom Pulsar hook and the TransactionInitializer component
51
+ import { usePulsarStore } from '../hooks/usePulsarStore';
55
52
  import { TransactionInitializer } from '../components/TransactionInitializer';
53
+
56
54
  // Import required CSS
57
55
  import '@tuwaio/nova-core/dist/index.css';
58
56
  import '@tuwaio/nova-transactions/dist/index.css';
57
+ import 'react-toastify/dist/ReactToastify.css';
59
58
 
60
59
  // Your Wagmi Config
61
- import { wagmiConfig } from './wagmi';
60
+ import { wagmiConfig, appChains } from './wagmi';
62
61
 
63
62
  const queryClient = new QueryClient();
64
63
 
65
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
+
68
+ // 2. Get live wallet data from wagmi
69
+ const { address, chain } = useAccount();
70
+
66
71
  return (
67
72
  <WagmiProvider config={wagmiConfig}>
68
73
  <QueryClientProvider client={queryClient}>
69
- {/* NovaProvider is the parent for all UI-related context and components */}
70
- <NovaProvider>
71
- {/* TransactionInitializer handles the logic of rehydrating the Pulsar store */}
72
- <TransactionInitializer />
74
+ {/* TransactionInitializer handles rehydrating the Pulsar store */}
75
+ <TransactionInitializer />
73
76
 
74
- {children}
75
-
76
- {/* Global UI components from this package */}
77
- <TransactionToasts />
78
- <ToastContainer />
79
- </NovaProvider>
77
+ {/* Your application's pages */}
78
+ {children}
79
+
80
+ {/* 3. Render NovaProvider as a self-contained UI manager */}
81
+ <NovaProvider
82
+ // Pass all required state and actions from Pulsar as props
83
+ transactionsPool={transactionsPool}
84
+ initialTx={initialTx}
85
+ handleTransaction={handleTransaction}
86
+ closeTxTrackedModal={closeTxTrackedModal}
87
+
88
+ // Pass live wallet and chain data
89
+ walletAddress={address}
90
+ chain={chain}
91
+
92
+ // Pass static configuration
93
+ appChains={appChains}
94
+ config={wagmiConfig}
95
+ // actions={...} // Pass retry actions if you have them
96
+ />
80
97
  </QueryClientProvider>
81
98
  </WagmiProvider>
82
99
  );
@@ -85,49 +102,27 @@ export function Providers({ children }: { children: React.ReactNode }) {
85
102
 
86
103
  ## Usage Example
87
104
 
88
- Once the providers are set up, you use your custom `usePulsarStore` hook to track transactions. The components from this library will automatically appear and update.
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.
89
106
 
90
107
  ```tsx
91
108
  // components/IncrementButton.tsx
92
109
  'use client';
93
110
 
94
- import { getAccount } from '@wagmi/core';
95
-
96
111
  // Import your custom hook, created as shown in the pulsar-react docs
97
112
  import { usePulsarStore } from '../hooks/usePulsarStore';
98
- import { config } from '../configs/wagmiConfig';
99
- import { abi } from './my-nft-abi';
100
-
101
- const CONTRACT_ADDRESS = '0x...';
113
+ // ... other imports
102
114
 
103
115
  export function IncrementButton() {
104
- const activeWallet = getAccount(config);
105
116
  const { handleTransaction } = usePulsarStore();
106
117
 
107
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.
108
121
  await handleTransaction({
109
- actionFunction: txActions.increment,
110
- params: {
111
- type: TxType.increment,
112
- adapter: TransactionAdapter.EVM,
113
- from: activeWallet.address ?? zeroAddress,
114
- walletType: activeWallet.connector?.type ?? '',
115
- desiredChainID: sepolia.id,
116
- actionKey: TxAction.increment,
117
- title: ['Incrementing', 'Incremented', 'Error when increment', 'Increment tx replaced'],
118
- description: [
119
- `Value after incrementing ${currentCount + 1}`,
120
- `Success. Current value is ${currentCount + 1}`,
121
- 'Something went wrong when increment.',
122
- 'Transaction replaced. Please take a look details in your wallet.',
123
- ],
124
- payload: {
125
- value: currentCount,
126
- },
127
- withTrackedModal: true,
128
- },
122
+ actionFunction: () => { /* ... your contract write call ... */ },
123
+ params: { /* ... your transaction metadata ... */ }
129
124
  });
130
- }
125
+ };
131
126
 
132
127
  return <button onClick={handleIncrement}>Increment</button>;
133
128
  }
@@ -135,11 +130,11 @@ export function IncrementButton() {
135
130
 
136
131
  ## Internationalization (i18n)
137
132
 
138
- You can easily override the default English text by passing a `locale` object to the `NovaProvider`. Here is an example with German translations:
133
+ You can easily override the default English text by passing a `labels` prop to the `NovaProvider`. Here is an example with German translations:
139
134
 
140
135
  ```tsx
141
136
  <NovaProvider
142
- locale={{
137
+ labels={{
143
138
  transaction: {
144
139
  title: 'Transaktion',
145
140
  pending: 'Ausstehend...',
@@ -148,9 +143,8 @@ You can easily override the default English text by passing a `locale` object to
148
143
  },
149
144
  // ... other keys
150
145
  }}
151
- >
152
- {/* ... */}
153
- </NovaProvider>
146
+ // ... other required props
147
+ />
154
148
  ```
155
149
 
156
150
  ## Contributing
package/dist/index.css CHANGED
@@ -209,6 +209,9 @@
209
209
  .relative {
210
210
  position: relative;
211
211
  }
212
+ .static {
213
+ position: static;
214
+ }
212
215
  .sticky {
213
216
  position: sticky;
214
217
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tuwaio/nova-transactions",
3
- "version": "0.0.3",
3
+ "version": "0.0.5",
4
4
  "private": false,
5
5
  "author": "Oleksandr Tkach",
6
6
  "license": "Apache-2.0",
@@ -8,13 +8,26 @@
8
8
  "main": "./dist/index.js",
9
9
  "module": "./dist/index.mjs",
10
10
  "types": "./dist/index.d.ts",
11
+ "type": "module",
12
+ "exports": {
13
+ ".": {
14
+ "import": "./dist/index.mjs",
15
+ "require": "./dist/index.js",
16
+ "types": "./dist/index.d.ts"
17
+ },
18
+ "./providers": {
19
+ "import": "./dist/providers/index.mjs",
20
+ "require": "./dist/providers/index.js",
21
+ "types": "./dist/providers/index.d.ts"
22
+ },
23
+ "./dist/index.css": "./dist/index.css"
24
+ },
11
25
  "publishConfig": {
12
26
  "access": "public"
13
27
  },
14
28
  "files": [
15
29
  "dist"
16
30
  ],
17
- "type": "module",
18
31
  "keywords": [
19
32
  "react",
20
33
  "web3",
@@ -53,7 +66,7 @@
53
66
  "@tuwaio/pulsar-evm": "latest",
54
67
  "dayjs": "^1.11.13",
55
68
  "ethereum-blockies-base64": "^1.0.2",
56
- "@tuwaio/nova-core": "^0.0.1"
69
+ "@tuwaio/nova-core": "^0.0.2"
57
70
  },
58
71
  "peerDependencies": {
59
72
  "@bgd-labs/react-web3-icons": ">=1",