mist-chainz-client 1.0.0 → 1.0.1
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 +108 -0
- package/package.json +1 -1
package/README.md
ADDED
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
# mist-chainz-client
|
|
2
|
+
|
|
3
|
+
TypeScript client library for the **GGL-DS-MIST** blockchain system. Provides wallet creation, transaction management, and signature verification over a simple HTTP API.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install mist-chainz-client
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
```typescript
|
|
14
|
+
import { MistClient } from 'mist-chainz-client';
|
|
15
|
+
|
|
16
|
+
const client = new MistClient('https://your-mist-node-url');
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
### Create a wallet
|
|
20
|
+
|
|
21
|
+
```typescript
|
|
22
|
+
const wallet = await client.createWallet();
|
|
23
|
+
// { address: '0x...', privateKey: '...' }
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
### Create a transaction
|
|
27
|
+
|
|
28
|
+
```typescript
|
|
29
|
+
const tx = await client.createTransaction({
|
|
30
|
+
senderAddress: wallet.address,
|
|
31
|
+
recipient: '0xRecipientAddress',
|
|
32
|
+
data: {
|
|
33
|
+
id: 'my-object-id',
|
|
34
|
+
// ...any additional fields
|
|
35
|
+
},
|
|
36
|
+
});
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
The transaction ID is automatically persisted to a local store file (default: `mist-store.json`) keyed by `data.id`, so you can look it up later.
|
|
40
|
+
|
|
41
|
+
### Get a transaction
|
|
42
|
+
|
|
43
|
+
```typescript
|
|
44
|
+
const tx = await client.getTransaction(transactionId);
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
### Validate a transaction
|
|
48
|
+
|
|
49
|
+
```typescript
|
|
50
|
+
const result = await client.validateTransaction(transactionId, rawData);
|
|
51
|
+
// { transactionId: '...', isValid: true }
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
### Look up a stored transaction UUID
|
|
55
|
+
|
|
56
|
+
```typescript
|
|
57
|
+
const transactionId = client.getTransactionUuid('my-object-id');
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## API Reference
|
|
61
|
+
|
|
62
|
+
### `new MistClient(baseUrl, storeFilename?)`
|
|
63
|
+
|
|
64
|
+
| Parameter | Type | Default | Description |
|
|
65
|
+
|---|---|---|---|
|
|
66
|
+
| `baseUrl` | `string` | — | Base URL of the MIST node |
|
|
67
|
+
| `storeFilename` | `string` | `mist-store.json` | Path for the local transaction ID store |
|
|
68
|
+
|
|
69
|
+
### Methods
|
|
70
|
+
|
|
71
|
+
| Method | Returns | Description |
|
|
72
|
+
|---|---|---|
|
|
73
|
+
| `createWallet()` | `Promise<Wallet>` | Creates a new wallet on the node |
|
|
74
|
+
| `createTransaction(body)` | `Promise<Transaction>` | Submits a transaction and caches its ID locally |
|
|
75
|
+
| `getTransaction(id)` | `Promise<Transaction>` | Fetches a transaction by its blockchain ID |
|
|
76
|
+
| `validateTransaction(id, rawData)` | `Promise<VerifyResult>` | Verifies a transaction's signature externally |
|
|
77
|
+
| `getTransactionUuid(objectId)` | `string \| null` | Looks up a cached transaction ID by object ID |
|
|
78
|
+
|
|
79
|
+
### Types
|
|
80
|
+
|
|
81
|
+
```typescript
|
|
82
|
+
interface Wallet {
|
|
83
|
+
address: string;
|
|
84
|
+
privateKey: string;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
interface Transaction {
|
|
88
|
+
id: string;
|
|
89
|
+
status: string;
|
|
90
|
+
input: { timestamp: number; address: string; signature: string };
|
|
91
|
+
outputMap: { destination: string; data: any };
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
interface CreateTransactionBody {
|
|
95
|
+
senderAddress: string;
|
|
96
|
+
recipient: string;
|
|
97
|
+
data: Record<string, any> & { id: string };
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
interface VerifyResult {
|
|
101
|
+
transactionId: string;
|
|
102
|
+
isValid: boolean;
|
|
103
|
+
}
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
## License
|
|
107
|
+
|
|
108
|
+
ISC
|