Skip to content

Commit

Permalink
[feature] hyperledger-iroha#2003: Introduce Parity Scale Decoder tool (
Browse files Browse the repository at this point in the history
…hyperledger-iroha#2080)

Signed-off-by: Daniil Polyakov <[email protected]>
  • Loading branch information
Arjentix authored and mversic committed May 13, 2022
1 parent ad7718f commit 072b811
Show file tree
Hide file tree
Showing 11 changed files with 846 additions and 5 deletions.
31 changes: 29 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ members = [
"core/test_network",
"crypto",
"tools/crypto_cli",
"tools/kura_inspector",
"tools/parity_scale_decoder",
"data_model",
"data_model/primitives",
"futures",
Expand All @@ -27,7 +29,6 @@ members = [
"schema/derive",
"substrate",
"telemetry",
"tools/kura_inspector",
"version",
"version/derive",
]
2 changes: 1 addition & 1 deletion data_model/src/events/data/filters.rs
Original file line number Diff line number Diff line change
Expand Up @@ -689,7 +689,7 @@ pub mod prelude {
peer::{PeerEventFilter, PeerFilter},
trigger::{TriggerEventFilter, TriggerFilter},
EntityFilter as DataEntityFilter, EventFilter as DataEventFilter,
FilterOpt::*,
FilterOpt::{self, *},
IdFilter,
};
}
Expand Down
3 changes: 2 additions & 1 deletion data_model/tests/data_model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ mod register {
}
}

#[allow(unused_must_use)]
#[test]
fn find_rate_and_make_exchange_isi_should_succeed() {
let kp = KeyPair {
Expand Down Expand Up @@ -255,7 +256,7 @@ fn find_rate_and_make_exchange_isi_should_succeed() {
.request(FindAssetQuantityById::new(asset_id_new(
"btc", "crypto", "seller", "company",
)))
.expect_err("Failed to execute Iroha Query");
.expect_err("Query must fail");

let buyer_eth_quantity = iroha_client
.request(FindAssetQuantityById::new(asset_id_new(
Expand Down
24 changes: 24 additions & 0 deletions tools/parity_scale_decoder/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
[package]
name = "parity_scale_decoder"
version = "2.0.0-pre-rc.3"
authors = ["Iroha 2 team <https://github.com/orgs/soramitsu/teams/iroha2>"]
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[features]
no-color = ["colored/no-color"]

[dependencies]
iroha_data_model = { version = "=2.0.0-pre-rc.3", path = "../../data_model", features = ["warp"]}
iroha_schema = { version = "=2.0.0-pre-rc.3", path = "../../schema"}
iroha_core = { version = "=2.0.0-pre-rc.3", path = "../../core", features = ["roles"] }
iroha_crypto = { version = "=2.0.0-pre-rc.3", path = "../../crypto", default-features = false }
iroha_version = { version = "=2.0.0-pre-rc.3", path = "../../version", default-features = false }
clap = { version = "3.1.8", features = ["derive", "cargo"] }
eyre = "0.6.8"
parity-scale-codec = { version = "2.3.1", default-features = false }
colored = "2.0.0"

[dev-dependencies]
iroha_schema_bin = { version = "=2.0.0-pre-rc.3", path = "../../schema/bin"}
72 changes: 72 additions & 0 deletions tools/parity_scale_decoder/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
# Parity Scale Decoder Tool

## Description

This tool will help you to decode **Iroha 2** types from binaries using [Parity Scale Codec](https://github.com/paritytech/parity-scale-codec)

## Usage

Building:

```bash
cargo build --bin parity_scale_decoder
```

If your terminal does not support colors:

```bash
cargo build --features no-color --bin parity_scale_decoder
```

From the main project directory:

* List all supported types:

```bash
./target/debug/parity_scale_decoder list-type
```

* Decode type from binary:

```bash
./target/debug/parity_scale_decoder decode <path_to_binary> --type <type>
```

As an example you can use provided samples:

```bash
./target/debug/parity_scale_decoder decode tools/parity_scale_decoder/samples/account.bin --type Account
```

* Decode any type from binary:

If you are not sure about type you can simply omit `--type` option:

```bash
./target/debug/parity_scale_decoder decode <path_to_binary>
```

* To see all available options run:

```bash
./target/debug/parity_scale_decoder --help
```

## Contributing

Check out [this document](https://github.com/hyperledger/iroha/blob/iroha2-dev/CONTRIBUTING.md)

## [Need help?](https://github.com/hyperledger/iroha/blob/iroha2-dev/CONTRIBUTING.md#contact)

## License

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

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.
Binary file added tools/parity_scale_decoder/samples/account.bin
Binary file not shown.
Binary file added tools/parity_scale_decoder/samples/domain.bin
Binary file not shown.
Binary file added tools/parity_scale_decoder/samples/trigger.bin
Binary file not shown.
Loading

0 comments on commit 072b811

Please sign in to comment.