Skip to content

Commit 9cb581a

Browse files
authored
Merge pull request #3 from make-software/fix/docs-title
Fixed readme title
2 parents e0ae64e + 516b47b commit 9cb581a

File tree

1 file changed

+36
-39
lines changed

1 file changed

+36
-39
lines changed

README.md

Lines changed: 36 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,45 @@
1-
# JS CES Parser
1+
# CES JS Parser
22

3-
`@make-software/ces-js-parser` parses contract-level events that follow
4-
the [Casper Event Standard](https://github.com/make-software/casper-event-standard).
3+
`@make-software/ces-js-parser` parses contract-level events that follow the [Casper Event Standard](https://github.com/make-software/casper-event-standard).
54

65
The library is built on top of the [casper-js-sdk](https://github.com/casper-ecosystem/casper-js-sdk) and operates on types defined by the SDK.
76

87
## Install
98

10-
``
11-
npm install --save @make-software/ces-js-parser
12-
``
9+
`npm install --save @make-software/ces-js-parser`
1310

1411
## Usage
1512

16-
Here is an example of parsing CES events using `ces-js-parser` from a real Testnet deploy loaded
17-
with `casper-js-sdk`:
13+
Here is an example of parsing CES events using `ces-js-parser` from a real Testnet deploy loaded with `casper-js-sdk`:
1814

1915
```typescript
2016
import { CasperServiceByJsonRPC } from 'casper-js-sdk';
2117
import { Parser } from '@make-software/ces-js-parser';
2218

23-
const rpcClient = new CasperServiceByJsonRPC(
24-
`http://${process.env.NODE_ADDRESS}:7777/rpc`,
19+
const rpcClient = new CasperServiceByJsonRPC(
20+
`http://${process.env.NODE_ADDRESS}:7777/rpc`
2521
);
2622

2723
const parser = await Parser.create(rpcClient, [
28-
'214a0e730e14501d1e3e03504d3a2f940ef32830b13fa47f9d85a40f73b78161',
24+
'214a0e730e14501d1e3e03504d3a2f940ef32830b13fa47f9d85a40f73b78161'
2925
]);
3026

31-
const deploy = await rpcClient.getDeployInfo('19ee17d9e3b4c1527b433598e647b69aa9a153864eb12433489f99224bfc9442');
27+
const deploy = await rpcClient.getDeployInfo(
28+
'19ee17d9e3b4c1527b433598e647b69aa9a153864eb12433489f99224bfc9442'
29+
);
3230

3331
const events = await parser.parseExecutionResult(
34-
deploy.execution_results[0].result as ExecutionResult,
32+
deploy.execution_results[0].result as ExecutionResult
3533
);
3634

3735
events.forEach(console.log);
3836
```
3937

4038
## API
4139

42-
JS CES Parser provides several public types and functions:
40+
CES JS Parser provides several public types and functions:
4341

44-
- [JS CES Parser](#js-ces-parser)
42+
- [CES JS Parser](#ces-js-parser)
4543
- [Install](#install)
4644
- [Usage](#usage)
4745
- [API](#api)
@@ -59,17 +57,16 @@ JS CES Parser provides several public types and functions:
5957

6058
### `Parser`
6159

62-
Parser that accepts a list of observed contracts and provides possibility to parse CES events out of deploy execution
63-
results
60+
Parser that accepts a list of observed contracts and provides possibility to parse CES events out of deploy execution results
6461

6562
#### `create`
6663

6764
`create` is a async factory function that accepts `CasperServiceByJsonRPC` and `contractHashes` array and created a `Parser` instance:
6865

69-
| Argument | Type | Description |
70-
| ---------------- | ------------------------ | ----------------------------------------------- |
71-
| `rpcClient` | `CasperServiceByJsonRPC` | Instance of the `CasperServiceByJsonRPC` client |
72-
| `contractHashes` | `string[]` | List of the observed contract hashes |
66+
| Argument | Type | Description |
67+
| --- | --- | --- |
68+
| `rpcClient` | `CasperServiceByJsonRPC` | Instance of the `CasperServiceByJsonRPC` client |
69+
| `contractHashes` | `string[]` | List of the observed contract hashes |
7370

7471
**Example**
7572

@@ -78,11 +75,11 @@ import { CasperServiceByJsonRPC } from 'casper-js-sdk';
7875
import { Parser } from '@make-software/ces-js-parser';
7976

8077
const rpcClient = new CasperServiceByJsonRPC(
81-
`http://${process.env.NODE_ADDRESS}:7777/rpc`,
78+
`http://${process.env.NODE_ADDRESS}:7777/rpc`
8279
);
8380

8481
const parser = await Parser.create(rpcClient, [
85-
'214a0e730e14501d1e3e03504d3a2f940ef32830b13fa47f9d85a40f73b78161',
82+
'214a0e730e14501d1e3e03504d3a2f940ef32830b13fa47f9d85a40f73b78161'
8683
]);
8784
```
8885

@@ -98,15 +95,14 @@ const parser = await Parser.create(rpcClient, [
9895

9996
`fetchContractSchemasBytes` method that accepts contract hash and return bytes representation of stored schema:
10097

101-
| Argument | Type | Description |
102-
| --------------- | -------- | ---------------------------------------------------------- |
103-
| `contractHash` | `string` | Contract hash schema want to be fetched |
98+
| Argument | Type | Description |
99+
| --- | --- | --- |
100+
| `contractHash` | `string` | Contract hash schema want to be fetched |
104101
| `stateRootHash` | `string` | State root hash of the data (takes latest if not provided) |
105102

106103
### `parseSchemasFromBytes`
107104

108-
`parseSchemasFromBytes` function that accepts raw CES schema bytes stored under the contract `__events_schema` URef and
109-
returns `Schemas`:
105+
`parseSchemasFromBytes` function that accepts raw CES schema bytes stored under the contract `__events_schema` URef and returns `Schemas`:
110106

111107
| Argument | Type | Description |
112108
| ---------- | ------------ | -------------------------- |
@@ -125,10 +121,13 @@ Function that accepts raw event bytes and contract event schemas and returns `Ev
125121

126122
```typescript
127123
import { decodeBase16 } from 'casper-js-sdk';
128-
import { parseSchemasFromBytes, parseEventNameAndData } from '@make-software/ces-js-parser';
124+
import {
125+
parseSchemasFromBytes,
126+
parseEventNameAndData
127+
} from '@make-software/ces-js-parser';
129128

130129
const schemas = parseSchemasFromBytes(rawBytes);
131-
const rawEvent = decodeBase16("some real example here")
130+
const rawEvent = decodeBase16('some real example here');
132131

133132
const event = parseEventNameAndData(rawEvent, schemas);
134133
```
@@ -137,12 +136,12 @@ const event = parseEventNameAndData(rawEvent, schemas);
137136

138137
Type that represents an event:
139138

140-
| Property | Type | Description |
141-
| --------------------- | ------------------------ | ------------------ |
142-
| `contractHash` | `Uint8Array` | Event ContractHash |
143-
| `contractPackageHash` | `Uint8Array` | Event ContractHash |
144-
| `name` | `string` | Event name |
145-
| `data` | `Record<string,CLValue>` | Event Data |
139+
| Property | Type | Description |
140+
| --- | --- | --- |
141+
| `contractHash` | `Uint8Array` | Event ContractHash |
142+
| `contractPackageHash` | `Uint8Array` | Event ContractHash |
143+
| `name` | `string` | Event name |
144+
| `data` | `Record<string,CLValue>` | Event Data |
146145

147146
### `ParseResult`
148147

@@ -170,6 +169,4 @@ Schemas represent a map of event name and its Schema.
170169

171170
To run unit tests for the library, make sure you are in the root of the library:
172171

173-
``
174-
npm run test
175-
``
172+
`npm run test`

0 commit comments

Comments
 (0)