-
Notifications
You must be signed in to change notification settings - Fork 276
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
…#2224) Signed-off-by: Ekaterina Mekhnetsova <mekkatya@gmail.com>
- Loading branch information
1 parent
61bbd74
commit 64fb445
Showing
1 changed file
with
54 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,72 +1,86 @@ | ||
# Parity Scale Decoder Tool | ||
|
||
## Description | ||
This tool helps you decode **Iroha 2** data types from binaries using [Parity Scale Codec](https://github.com/paritytech/parity-scale-codec). | ||
|
||
This tool will help you to decode **Iroha 2** types from binaries using [Parity Scale Codec](https://github.com/paritytech/parity-scale-codec) | ||
## Build | ||
|
||
## Usage | ||
|
||
Building: | ||
To build the tool, run: | ||
|
||
```bash | ||
cargo build --bin parity_scale_decoder | ||
``` | ||
|
||
If your terminal does not support colors: | ||
If your terminal does not support colours, run: | ||
|
||
```bash | ||
cargo build --features no-color --bin parity_scale_decoder | ||
``` | ||
|
||
From the main project directory: | ||
## Usage | ||
|
||
* List all supported types: | ||
Run Parity Scale Decoder Tool: | ||
|
||
```bash | ||
./target/debug/parity_scale_decoder list-type | ||
``` | ||
```bash | ||
parity_scale_decoder <SUBCOMMAND> | ||
``` | ||
|
||
* Decode type from binary: | ||
### Subcommands | ||
|
||
```bash | ||
./target/debug/parity_scale_decoder decode <path_to_binary> --type <type> | ||
``` | ||
| Command | Description | | ||
| ------------------------- | --------------------------------------------------- | | ||
| [`list-type`](#list-type) | List all available data types | | ||
| [`decode`](#decode) | Decode the data type from binary | | ||
| `help` | Print the help message for the tool or a subcommand | | ||
|
||
As an example you can use provided samples: | ||
## `list-type` | ||
|
||
```bash | ||
./target/debug/parity_scale_decoder decode tools/parity_scale_decoder/samples/account.bin --type Account | ||
``` | ||
To list all supported data types, run from the project main directory: | ||
|
||
* Decode any type from binary: | ||
```bash | ||
./target/debug/parity_scale_decoder list-type | ||
``` | ||
|
||
If you are not sure about type you can simply omit `--type` option: | ||
|
||
```bash | ||
./target/debug/parity_scale_decoder decode <path_to_binary> | ||
``` | ||
<details> <summary> Expand to see possible outputs</summary> | ||
|
||
``` | ||
No type is supported | ||
1 type is supported | ||
3 types are supported | ||
``` | ||
|
||
</details> | ||
|
||
## `decode` | ||
|
||
Decode the data type from a given binary. | ||
|
||
| Option | Description | Type | | ||
| ---------- | ----------------------------------------------------------------------------------------------------------------------------- | ---------------------- | | ||
| `--binary` | The path to the binary file with an encoded Iroha structure for the tool to decode. | An owned, mutable path | | ||
| `--type` | The data type that is expected to be encoded in the provided binary.<br />If not specified, the tool tries to guess the type. | String | | ||
|
||
* To see all available options run: | ||
* Decode the specified data type from a binary: | ||
|
||
```bash | ||
./target/debug/parity_scale_decoder --help | ||
./target/debug/parity_scale_decoder decode <path_to_binary> --type <type> | ||
``` | ||
|
||
## Contributing | ||
* If you are not sure which data type is encoded in the binary, run the tool without the `--type` option: | ||
|
||
```bash | ||
./target/debug/parity_scale_decoder decode <path_to_binary> | ||
``` | ||
|
||
Check out [this document](https://github.com/hyperledger/iroha/blob/iroha2-dev/CONTRIBUTING.md) | ||
### `decode` usage examples | ||
|
||
## [Need help?](https://github.com/hyperledger/iroha/blob/iroha2-dev/CONTRIBUTING.md#contact) | ||
* Decode the `Account` data type from the `samples/account.bin` binary: | ||
|
||
## License | ||
```bash | ||
./target/debug/parity_scale_decoder decode tools/parity_scale_decoder/samples/account.bin --type Account | ||
``` | ||
|
||
Iroha codebase is licensed under the Apache License, | ||
Version 2.0 (the "License"); you may not use this file except | ||
in compliance with the License. You may obtain a copy of the | ||
License at http://www.apache.org/licenses/LICENSE-2.0 | ||
* Decode the `Domain` data type from the `samples/domain.bin` binary: | ||
|
||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
```bash | ||
./target/debug/parity_scale_decoder decode tools/parity_scale_decoder/samples/domain.bin --type Domain | ||
``` |