From f4a21f3890a3d028052b8dfbb0cf434809fac1c9 Mon Sep 17 00:00:00 2001 From: Dmitry Balashov Date: Thu, 21 Sep 2023 16:19:23 +0700 Subject: [PATCH] restructure; add `iroha_client_cli` drafts Signed-off-by: Dmitry Balashov --- .gitignore | 1 + Rust/README.md | 23 ------------------- examples/iroha_client_cli/README.md | 5 ++++ .../tutorial-3-register-domain.result.json | 10 ++++++++ .../cli/tutorial-3-register-domain.sh | 7 ++++++ .../tutorial-4-register-account.result.json | 14 +++++++++++ .../cli/tutorial-4-register-account.sh | 6 +++++ .../cli/tutorial-5-asset.output-burn.json | 8 +++++++ .../cli/tutorial-5-asset.output-mint.json | 8 +++++++ .../iroha_client_cli/cli/tutorial-5-asset.sh | 23 +++++++++++++++++++ .../iroha_client_cli}/config.json | 0 .../json/tutorial-3-register-domain.isi.json5 | 11 +++++++++ .../json/tutorial-4-register-accout.isi.json5 | 12 ++++++++++ .../tutorial-5-asset.1-register.isi.json5 | 11 +++++++++ .../json/tutorial-5-asset.2-mint.isi.json5 | 8 +++++++ .../json/tutorial-5-asset.3-burn.isi.json5 | 8 +++++++ {Rust => examples/rust}/.gitignore | 0 {Rust => examples/rust}/Cargo.lock | 0 {Rust => examples/rust}/Cargo.toml | 0 examples/rust/README.md | 3 +++ .../examples/client_account_definition.rs | 0 .../examples/client_account_registration.rs | 0 .../rust}/examples/client_asset_burning.rs | 0 .../rust}/examples/client_asset_minting.rs | 0 .../examples/client_asset_registration.rs | 0 .../examples/client_domain_registration.rs | 0 .../rust}/examples/client_json_config.rs | 0 .../examples/million_accounts_genesis.rs | 0 .../examples/tutorial-3-register-domain.rs | 0 .../examples/tutorial-4-register-account.rs | 0 .../tutorial-5-register-mint-burn-asset.rs | 0 {Rust => examples/rust}/src/lib.rs | 0 32 files changed, 135 insertions(+), 23 deletions(-) create mode 100644 .gitignore delete mode 100644 Rust/README.md create mode 100644 examples/iroha_client_cli/README.md create mode 100644 examples/iroha_client_cli/cli/tutorial-3-register-domain.result.json create mode 100644 examples/iroha_client_cli/cli/tutorial-3-register-domain.sh create mode 100644 examples/iroha_client_cli/cli/tutorial-4-register-account.result.json create mode 100644 examples/iroha_client_cli/cli/tutorial-4-register-account.sh create mode 100644 examples/iroha_client_cli/cli/tutorial-5-asset.output-burn.json create mode 100644 examples/iroha_client_cli/cli/tutorial-5-asset.output-mint.json create mode 100644 examples/iroha_client_cli/cli/tutorial-5-asset.sh rename {Rust => examples/iroha_client_cli}/config.json (100%) create mode 100644 examples/iroha_client_cli/json/tutorial-3-register-domain.isi.json5 create mode 100644 examples/iroha_client_cli/json/tutorial-4-register-accout.isi.json5 create mode 100644 examples/iroha_client_cli/json/tutorial-5-asset.1-register.isi.json5 create mode 100644 examples/iroha_client_cli/json/tutorial-5-asset.2-mint.isi.json5 create mode 100644 examples/iroha_client_cli/json/tutorial-5-asset.3-burn.isi.json5 rename {Rust => examples/rust}/.gitignore (100%) rename {Rust => examples/rust}/Cargo.lock (100%) rename {Rust => examples/rust}/Cargo.toml (100%) create mode 100644 examples/rust/README.md rename {Rust => examples/rust}/examples/client_account_definition.rs (100%) rename {Rust => examples/rust}/examples/client_account_registration.rs (100%) rename {Rust => examples/rust}/examples/client_asset_burning.rs (100%) rename {Rust => examples/rust}/examples/client_asset_minting.rs (100%) rename {Rust => examples/rust}/examples/client_asset_registration.rs (100%) rename {Rust => examples/rust}/examples/client_domain_registration.rs (100%) rename {Rust => examples/rust}/examples/client_json_config.rs (100%) rename {Rust => examples/rust}/examples/million_accounts_genesis.rs (100%) rename {Rust => examples/rust}/examples/tutorial-3-register-domain.rs (100%) rename {Rust => examples/rust}/examples/tutorial-4-register-account.rs (100%) rename {Rust => examples/rust}/examples/tutorial-5-register-mint-burn-asset.rs (100%) rename {Rust => examples/rust}/src/lib.rs (100%) diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..723ef36 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.idea \ No newline at end of file diff --git a/Rust/README.md b/Rust/README.md deleted file mode 100644 index afcae99..0000000 --- a/Rust/README.md +++ /dev/null @@ -1,23 +0,0 @@ -# Rust examples for Iroha 2 - -This directory contains the examples from the [Rust tutorial](https://hyperledger.github.io/iroha-2-docs/guide/rust.html#_2-configuring-iroha-2). - -## Running the examples - -To run the examples, you need to install [`cargo-nextest`](https://nexte.st/) first. - -```bash -cargo install cargo-nextest -``` - -After it is installed, type: - -```bash -cargo nextest run -``` - -You'll Cargo install the packages that are needed for the tests and the test code will run. - -## Extending the example set - -Simply add a file with Rust code to the [`examples`](./examples/) directory. It will be launched by `cargo-nextest` on its next run. diff --git a/examples/iroha_client_cli/README.md b/examples/iroha_client_cli/README.md new file mode 100644 index 0000000..644579d --- /dev/null +++ b/examples/iroha_client_cli/README.md @@ -0,0 +1,5 @@ +# Examples for `iroha_client_cli` + +`cli` directory contains examples of using the binary through its CLI. + +`json` directory contains examples of using the binary through its JSON API. \ No newline at end of file diff --git a/examples/iroha_client_cli/cli/tutorial-3-register-domain.result.json b/examples/iroha_client_cli/cli/tutorial-3-register-domain.result.json new file mode 100644 index 0000000..7df8320 --- /dev/null +++ b/examples/iroha_client_cli/cli/tutorial-3-register-domain.result.json @@ -0,0 +1,10 @@ +[ + { + "id": "looking_glass", + "accounts": {}, + "asset_definitions": {}, + "asset_total_quantities": {}, + "logo": null, + "metadata": {} + } +] diff --git a/examples/iroha_client_cli/cli/tutorial-3-register-domain.sh b/examples/iroha_client_cli/cli/tutorial-3-register-domain.sh new file mode 100644 index 0000000..1be0fb3 --- /dev/null +++ b/examples/iroha_client_cli/cli/tutorial-3-register-domain.sh @@ -0,0 +1,7 @@ +iroha_client_cli domain register --id "looking_glass" +# returns "..." tx hash + +# FIXME: would be good to have at least JSON5 here or some other CLI-friendly format +iroha_client_cli domain list filter '{ Identifiable: { Is: "looking_glass" } }' + +# should return: ./tutorial-3-register-domain.output.json diff --git a/examples/iroha_client_cli/cli/tutorial-4-register-account.result.json b/examples/iroha_client_cli/cli/tutorial-4-register-account.result.json new file mode 100644 index 0000000..da36ac6 --- /dev/null +++ b/examples/iroha_client_cli/cli/tutorial-4-register-account.result.json @@ -0,0 +1,14 @@ +[ + { + "id": "white_rabbit@looking_glass", + "assets": {}, + "signatories": [ + "ed0120E7BF9FD343AF8C112AE4AF12FEE1D21EDD3403D97562758C9AA12074A793E95B" + ], + "signature_check_condition": { + "AnyAccountSignatureOr": [] + }, + "metadata": {}, + "roles": [] + } +] diff --git a/examples/iroha_client_cli/cli/tutorial-4-register-account.sh b/examples/iroha_client_cli/cli/tutorial-4-register-account.sh new file mode 100644 index 0000000..8a96dfd --- /dev/null +++ b/examples/iroha_client_cli/cli/tutorial-4-register-account.sh @@ -0,0 +1,6 @@ +iroha_client_cli account register \ + --id 'white_rabbit@looking_glass' \ + --key 'ed0120E7BF9FD343AF8C112AE4AF12FEE1D21EDD3403D97562758C9AA12074A793E95B' +# tx hash + +iroha_client_cli account list filter '{ Identifiable: { Is: "white_rabbit@looking_glass" } }' \ No newline at end of file diff --git a/examples/iroha_client_cli/cli/tutorial-5-asset.output-burn.json b/examples/iroha_client_cli/cli/tutorial-5-asset.output-burn.json new file mode 100644 index 0000000..d429541 --- /dev/null +++ b/examples/iroha_client_cli/cli/tutorial-5-asset.output-burn.json @@ -0,0 +1,8 @@ +[ + { + "id": "time##white_rabbit@looking_glass", + "value": { + "Quantity": 35 + } + } +] diff --git a/examples/iroha_client_cli/cli/tutorial-5-asset.output-mint.json b/examples/iroha_client_cli/cli/tutorial-5-asset.output-mint.json new file mode 100644 index 0000000..bd43907 --- /dev/null +++ b/examples/iroha_client_cli/cli/tutorial-5-asset.output-mint.json @@ -0,0 +1,8 @@ +[ + { + "id": "time##white_rabbit@looking_glass", + "value": { + "Quantity": 42 + } + } +] diff --git a/examples/iroha_client_cli/cli/tutorial-5-asset.sh b/examples/iroha_client_cli/cli/tutorial-5-asset.sh new file mode 100644 index 0000000..7818794 --- /dev/null +++ b/examples/iroha_client_cli/cli/tutorial-5-asset.sh @@ -0,0 +1,23 @@ +iroha_client_cli asset register \ + --id 'time#looking_glass' \ + --value-type Quantity \ + --unmintable # mintable once + +# iroha_client_cli asset list filter '{ "Identifiable": { "Is": "time#looking_glass" } }' +# FIXME: lol `asset register` creates an asset DEFINITION, but `asset list` doesn't return a definition + +iroha_client_cli asset mint \ + --account 'white_rabbit@looking_glass' \ + --asset 'time#looking_glass' \ + --quantity 42 + # FIXME: Fixed-type quantity is not supported + # --quantity=12.34 + +iroha_client_cli asset list filter '{ Identifiable: { StartsWith: "time" } }' + +iroha_client_cli asset burn \ + --account 'white_rabbit@looking_glass' \ + --asset 'time#looking_glass' \ + --quantity 7 + +iroha_client_cli asset list filter '{ Identifiable: { StartsWith: "time" } }' diff --git a/Rust/config.json b/examples/iroha_client_cli/config.json similarity index 100% rename from Rust/config.json rename to examples/iroha_client_cli/config.json diff --git a/examples/iroha_client_cli/json/tutorial-3-register-domain.isi.json5 b/examples/iroha_client_cli/json/tutorial-3-register-domain.isi.json5 new file mode 100644 index 0000000..d570226 --- /dev/null +++ b/examples/iroha_client_cli/json/tutorial-3-register-domain.isi.json5 @@ -0,0 +1,11 @@ +[ + { + Register: { + NewDomain: { + id: "looking_glass", + // FIXME: remove empty metadata requirement + metadata: {} + } + } + } +] diff --git a/examples/iroha_client_cli/json/tutorial-4-register-accout.isi.json5 b/examples/iroha_client_cli/json/tutorial-4-register-accout.isi.json5 new file mode 100644 index 0000000..375c99c --- /dev/null +++ b/examples/iroha_client_cli/json/tutorial-4-register-accout.isi.json5 @@ -0,0 +1,12 @@ +{ + Register: { + NewAccount: { + id: "white_rabbit@looking_glass", + signatories: [ + "ed0120E7BF9FD343AF8C112AE4AF12FEE1D21EDD3403D97562758C9AA12074A793E95B" + ], + // FIXME: remove empty metadata requirement + metadata: {} + } + } +} \ No newline at end of file diff --git a/examples/iroha_client_cli/json/tutorial-5-asset.1-register.isi.json5 b/examples/iroha_client_cli/json/tutorial-5-asset.1-register.isi.json5 new file mode 100644 index 0000000..6e0cb28 --- /dev/null +++ b/examples/iroha_client_cli/json/tutorial-5-asset.1-register.isi.json5 @@ -0,0 +1,11 @@ +{ + Register: { + NewAssetDefinition: { + id: "time#looking_glass", + value_type: "Quantity", + mintable: "Once", + // FIXME: remove empty metadata requirement + metadata: {} + } + } +} \ No newline at end of file diff --git a/examples/iroha_client_cli/json/tutorial-5-asset.2-mint.isi.json5 b/examples/iroha_client_cli/json/tutorial-5-asset.2-mint.isi.json5 new file mode 100644 index 0000000..9e64c95 --- /dev/null +++ b/examples/iroha_client_cli/json/tutorial-5-asset.2-mint.isi.json5 @@ -0,0 +1,8 @@ +{ + Mint: { + object: "42_u32", + destination_id: { + AssetId: "time##white_rabbit@looking_glass" + } + } +} \ No newline at end of file diff --git a/examples/iroha_client_cli/json/tutorial-5-asset.3-burn.isi.json5 b/examples/iroha_client_cli/json/tutorial-5-asset.3-burn.isi.json5 new file mode 100644 index 0000000..b830587 --- /dev/null +++ b/examples/iroha_client_cli/json/tutorial-5-asset.3-burn.isi.json5 @@ -0,0 +1,8 @@ +{ + Burn: { + object: "7_u32", + destination_id: { + AssetId: "time##white_rabbit@looking_glass" + } + } +} \ No newline at end of file diff --git a/Rust/.gitignore b/examples/rust/.gitignore similarity index 100% rename from Rust/.gitignore rename to examples/rust/.gitignore diff --git a/Rust/Cargo.lock b/examples/rust/Cargo.lock similarity index 100% rename from Rust/Cargo.lock rename to examples/rust/Cargo.lock diff --git a/Rust/Cargo.toml b/examples/rust/Cargo.toml similarity index 100% rename from Rust/Cargo.toml rename to examples/rust/Cargo.toml diff --git a/examples/rust/README.md b/examples/rust/README.md new file mode 100644 index 0000000..45224e5 --- /dev/null +++ b/examples/rust/README.md @@ -0,0 +1,3 @@ +# Rust examples for Iroha 2 + +WIP diff --git a/Rust/examples/client_account_definition.rs b/examples/rust/examples/client_account_definition.rs similarity index 100% rename from Rust/examples/client_account_definition.rs rename to examples/rust/examples/client_account_definition.rs diff --git a/Rust/examples/client_account_registration.rs b/examples/rust/examples/client_account_registration.rs similarity index 100% rename from Rust/examples/client_account_registration.rs rename to examples/rust/examples/client_account_registration.rs diff --git a/Rust/examples/client_asset_burning.rs b/examples/rust/examples/client_asset_burning.rs similarity index 100% rename from Rust/examples/client_asset_burning.rs rename to examples/rust/examples/client_asset_burning.rs diff --git a/Rust/examples/client_asset_minting.rs b/examples/rust/examples/client_asset_minting.rs similarity index 100% rename from Rust/examples/client_asset_minting.rs rename to examples/rust/examples/client_asset_minting.rs diff --git a/Rust/examples/client_asset_registration.rs b/examples/rust/examples/client_asset_registration.rs similarity index 100% rename from Rust/examples/client_asset_registration.rs rename to examples/rust/examples/client_asset_registration.rs diff --git a/Rust/examples/client_domain_registration.rs b/examples/rust/examples/client_domain_registration.rs similarity index 100% rename from Rust/examples/client_domain_registration.rs rename to examples/rust/examples/client_domain_registration.rs diff --git a/Rust/examples/client_json_config.rs b/examples/rust/examples/client_json_config.rs similarity index 100% rename from Rust/examples/client_json_config.rs rename to examples/rust/examples/client_json_config.rs diff --git a/Rust/examples/million_accounts_genesis.rs b/examples/rust/examples/million_accounts_genesis.rs similarity index 100% rename from Rust/examples/million_accounts_genesis.rs rename to examples/rust/examples/million_accounts_genesis.rs diff --git a/Rust/examples/tutorial-3-register-domain.rs b/examples/rust/examples/tutorial-3-register-domain.rs similarity index 100% rename from Rust/examples/tutorial-3-register-domain.rs rename to examples/rust/examples/tutorial-3-register-domain.rs diff --git a/Rust/examples/tutorial-4-register-account.rs b/examples/rust/examples/tutorial-4-register-account.rs similarity index 100% rename from Rust/examples/tutorial-4-register-account.rs rename to examples/rust/examples/tutorial-4-register-account.rs diff --git a/Rust/examples/tutorial-5-register-mint-burn-asset.rs b/examples/rust/examples/tutorial-5-register-mint-burn-asset.rs similarity index 100% rename from Rust/examples/tutorial-5-register-mint-burn-asset.rs rename to examples/rust/examples/tutorial-5-register-mint-burn-asset.rs diff --git a/Rust/src/lib.rs b/examples/rust/src/lib.rs similarity index 100% rename from Rust/src/lib.rs rename to examples/rust/src/lib.rs