@tuwaio/pulsar-evm 0.0.18 → 0.0.20
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 +35 -21
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -31,43 +31,58 @@ While its main export is the `evmAdapter`, it also includes a suite of standalon
|
|
|
31
31
|
|
|
32
32
|
## 💾 Installation
|
|
33
33
|
|
|
34
|
-
This package is designed to be used as part of the Pulsar stack and requires
|
|
34
|
+
This package is designed to be used as part of the Pulsar stack and requires `@wagmi/core` and `viem`. Install all necessary packages together:
|
|
35
35
|
|
|
36
36
|
```bash
|
|
37
37
|
# Using pnpm
|
|
38
|
-
pnpm add @tuwaio/pulsar-evm @tuwaio/pulsar-core wagmi viem zustand immer
|
|
38
|
+
pnpm add @tuwaio/pulsar-evm @tuwaio/pulsar-core @wagmi/core viem zustand immer dayjs
|
|
39
39
|
|
|
40
40
|
# Using npm
|
|
41
|
-
npm install @tuwaio/pulsar-evm @tuwaio/pulsar-core wagmi viem zustand immer
|
|
41
|
+
npm install @tuwaio/pulsar-evm @tuwaio/pulsar-core @wagmi/core viem zustand immer dayjs
|
|
42
42
|
|
|
43
43
|
# Using yarn
|
|
44
|
-
yarn add @tuwaio/pulsar-evm @tuwaio/pulsar-core wagmi viem zustand immer
|
|
44
|
+
yarn add @tuwaio/pulsar-evm @tuwaio/pulsar-core @wagmi/core viem zustand immer dayjs
|
|
45
45
|
```
|
|
46
46
|
|
|
47
47
|
---
|
|
48
48
|
|
|
49
49
|
## 🚀 Usage
|
|
50
50
|
|
|
51
|
-
### 1
|
|
51
|
+
### 1. Primary Usage: The `evmAdapter`
|
|
52
52
|
|
|
53
53
|
For most applications, you'll only need to import the `evmAdapter` and pass it to your `createPulsarStore` configuration.
|
|
54
54
|
|
|
55
55
|
```ts
|
|
56
|
-
// src/
|
|
57
|
-
import { createPulsarStore } from '@tuwaio/pulsar-core';
|
|
56
|
+
// src/hooks/txTrackingHooks.ts
|
|
57
|
+
import { createBoundedUseStore, createPulsarStore, Transaction } from '@tuwaio/pulsar-core';
|
|
58
58
|
import { evmAdapter } from '@tuwaio/pulsar-evm';
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
59
|
+
|
|
60
|
+
import { appChains, config } from '@/configs/wagmiConfig';
|
|
61
|
+
|
|
62
|
+
const storageName = 'transactions-tracking-storage';
|
|
63
|
+
|
|
64
|
+
export enum TxType {
|
|
65
|
+
example = 'example',
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
type ExampleTx = Transaction & {
|
|
69
|
+
type: TxType.example;
|
|
70
|
+
payload: {
|
|
71
|
+
value: number;
|
|
72
|
+
};
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
export type TransactionUnion = ExampleTx;
|
|
76
|
+
|
|
77
|
+
export const usePulsarStore = createBoundedUseStore(
|
|
78
|
+
createPulsarStore<TransactionUnion>({
|
|
79
|
+
name: storageName,
|
|
80
|
+
adapter: evmAdapter(config, appChains),
|
|
81
|
+
}),
|
|
82
|
+
);
|
|
68
83
|
```
|
|
69
84
|
|
|
70
|
-
### 2
|
|
85
|
+
### 2. Using Standalone Actions
|
|
71
86
|
|
|
72
87
|
This package also exports utility actions that you can wire up to your UI for features like speeding up or canceling transactions.
|
|
73
88
|
|
|
@@ -76,11 +91,11 @@ This package also exports utility actions that you can wire up to your UI for fe
|
|
|
76
91
|
```tsx
|
|
77
92
|
// src/components/SpeedUpButton.tsx
|
|
78
93
|
import { speedUpTxAction } from '@tuwaio/pulsar-evm';
|
|
79
|
-
import {
|
|
94
|
+
import { usePulsarStore } from '../hooks/txTrackingHooks'; // Or your custom hook
|
|
80
95
|
import { wagmiConfig } from '../configs/wagmi'; // Your wagmi config
|
|
81
96
|
|
|
82
97
|
function SpeedUpButton({ txKey }) {
|
|
83
|
-
const
|
|
98
|
+
const transactionsPool = usePulsarStore((state) => state.transactionsPool);
|
|
84
99
|
const stuckTransaction = transactionsPool[txKey];
|
|
85
100
|
|
|
86
101
|
// Only show the button if the transaction is pending and is a standard EVM tx
|
|
@@ -106,7 +121,7 @@ function SpeedUpButton({ txKey }) {
|
|
|
106
121
|
}
|
|
107
122
|
```
|
|
108
123
|
|
|
109
|
-
### 3
|
|
124
|
+
### 3. Using Standalone Utilities
|
|
110
125
|
|
|
111
126
|
You can use exported utilities, like selectors, to get derived data for your UI.
|
|
112
127
|
|
|
@@ -115,7 +130,6 @@ You can use exported utilities, like selectors, to get derived data for your UI.
|
|
|
115
130
|
```tsx
|
|
116
131
|
// src/components/ExplorerLink.tsx
|
|
117
132
|
import { selectEvmTxExplorerLink } from '@tuwaio/pulsar-evm';
|
|
118
|
-
import { usePulsar } from '@tuwaio/pulsar-react';
|
|
119
133
|
import { chains } from '../configs/wagmi'; // Your wagmi config
|
|
120
134
|
|
|
121
135
|
function ExplorerLink({ tx }) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tuwaio/pulsar-evm",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.20",
|
|
4
4
|
"private": false,
|
|
5
5
|
"author": "Oleksandr Tkach",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
"viem": "^2.37.4",
|
|
58
58
|
"vitest": "^3.2.4",
|
|
59
59
|
"zustand": "^5.0.8",
|
|
60
|
-
"@tuwaio/pulsar-core": "^0.1.
|
|
60
|
+
"@tuwaio/pulsar-core": "^0.1.10"
|
|
61
61
|
},
|
|
62
62
|
"scripts": {
|
|
63
63
|
"start": "tsup src/index.ts --watch",
|