From b1455a5869581127d49d3727c7989cd88e848764 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marin=20Ver=C5=A1i=C4=87?= Date: Fri, 24 Nov 2023 15:48:10 +0300 Subject: [PATCH] [refactor] #4080: Export data model through iroha_client MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Marin Veršić --- Cargo.lock | 5 -- client/benches/torii.rs | 8 +- client/benches/tps/utils.rs | 10 ++- client/examples/million_accounts_genesis.rs | 2 +- client/examples/tutorial.rs | 56 ++++++++------ client/src/client.rs | 75 +++++++++---------- client/src/http.rs | 2 +- client/src/lib.rs | 2 + client/src/query_builder.rs | 13 ++-- client/tests/integration/add_account.rs | 3 +- client/tests/integration/add_domain.rs | 3 +- client/tests/integration/asset.rs | 12 +-- client/tests/integration/asset_propagation.rs | 12 +-- client/tests/integration/burn_public_keys.rs | 6 +- client/tests/integration/connected_peers.rs | 12 +-- client/tests/integration/domain_owner.rs | 2 +- client/tests/integration/events/data.rs | 4 +- .../tests/integration/events/notification.rs | 2 +- client/tests/integration/events/pipeline.rs | 4 +- .../integration/multiple_blocks_created.rs | 12 +-- .../integration/multisignature_account.rs | 6 +- .../integration/multisignature_transaction.rs | 12 +-- client/tests/integration/non_mintable.rs | 6 +- client/tests/integration/offline_peers.rs | 10 ++- client/tests/integration/pagination.rs | 6 +- client/tests/integration/permissions.rs | 6 +- client/tests/integration/queries/account.rs | 6 +- client/tests/integration/queries/asset.rs | 12 +-- client/tests/integration/queries/mod.rs | 10 ++- client/tests/integration/queries/role.rs | 6 +- client/tests/integration/query_errors.rs | 10 ++- client/tests/integration/restart_peer.rs | 6 +- client/tests/integration/roles.rs | 6 +- client/tests/integration/set_parameter.rs | 6 +- client/tests/integration/sorting.rs | 14 ++-- client/tests/integration/transfer_asset.rs | 6 +- .../integration/triggers/by_call_trigger.rs | 12 +-- .../integration/triggers/data_trigger.rs | 3 +- .../integration/triggers/event_trigger.rs | 6 +- .../integration/triggers/time_trigger.rs | 6 +- client/tests/integration/tx_history.rs | 6 +- client/tests/integration/tx_rollback.rs | 6 +- client/tests/integration/unregister_peer.rs | 12 +-- client/tests/integration/unstable_network.rs | 6 +- client/tests/integration/upgrade.rs | 6 +- client_cli/Cargo.toml | 1 - client_cli/README.md | 20 ++--- client_cli/src/main.rs | 9 ++- core/test_network/src/lib.rs | 8 +- data_model/Cargo.toml | 2 - smart_contract/executor/Cargo.toml | 1 - smart_contract/executor/derive/Cargo.toml | 1 - smart_contract/executor/derive/src/lib.rs | 4 +- smart_contract/executor/src/default.rs | 2 +- smart_contract/executor/src/lib.rs | 25 +++---- smart_contract/trigger/Cargo.toml | 1 - smart_contract/trigger/src/lib.rs | 2 +- 57 files changed, 286 insertions(+), 226 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 14830f7adea..9c70ec9200b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2731,7 +2731,6 @@ dependencies = [ "iroha_client", "iroha_config", "iroha_crypto", - "iroha_data_model", "iroha_primitives", "json5", "once_cell", @@ -2892,7 +2891,6 @@ dependencies = [ "derive_more", "displaydoc", "getset", - "iroha_client", "iroha_crypto", "iroha_data_model_derive", "iroha_ffi", @@ -2962,7 +2960,6 @@ dependencies = [ name = "iroha_executor" version = "2.0.0-pre-rc.20" dependencies = [ - "iroha_data_model", "iroha_executor_derive", "iroha_schema", "iroha_smart_contract", @@ -2976,7 +2973,6 @@ name = "iroha_executor_derive" version = "2.0.0-pre-rc.20" dependencies = [ "darling", - "iroha_data_model", "iroha_macro_utils", "manyhow", "proc-macro2", @@ -3283,7 +3279,6 @@ dependencies = [ name = "iroha_trigger" version = "2.0.0-pre-rc.20" dependencies = [ - "iroha_data_model", "iroha_smart_contract", "iroha_smart_contract_utils", "iroha_trigger_derive", diff --git a/client/benches/torii.rs b/client/benches/torii.rs index c35d90618e4..5dc72359570 100644 --- a/client/benches/torii.rs +++ b/client/benches/torii.rs @@ -4,10 +4,12 @@ use std::thread; use criterion::{criterion_group, criterion_main, Criterion, Throughput}; use iroha::samples::{construct_executor, get_config}; -use iroha_client::client::{asset, Client}; +use iroha_client::{ + client::{asset, Client}, + data_model::prelude::*, +}; use iroha_config::base::runtime_upgrades::Reload; use iroha_crypto::KeyPair; -use iroha_data_model::prelude::*; use iroha_genesis::{GenesisNetwork, RawGenesisBlockBuilder}; use iroha_primitives::unique_vec; use iroha_version::Encode; @@ -45,7 +47,7 @@ fn query_requests(criterion: &mut Criterion) { configuration .logger .max_log_level - .reload(iroha_data_model::Level::ERROR) + .reload(iroha_client::data_model::Level::ERROR) .expect("Should not fail"); let mut group = criterion.benchmark_group("query-requests"); let domain_id: DomainId = "domain".parse().expect("Valid"); diff --git a/client/benches/tps/utils.rs b/client/benches/tps/utils.rs index 34adf4fdf5e..d21611f7d53 100644 --- a/client/benches/tps/utils.rs +++ b/client/benches/tps/utils.rs @@ -11,10 +11,12 @@ use std::{ }; use eyre::{Result, WrapErr}; -use iroha_client::client::Client; -use iroha_data_model::{ - parameter::{default::MAX_TRANSACTIONS_IN_BLOCK, ParametersBuilder}, - prelude::*, +use iroha_client::{ + client::Client, + data_model::{ + parameter::{default::MAX_TRANSACTIONS_IN_BLOCK, ParametersBuilder}, + prelude::*, + }, }; use serde::Deserialize; use serde_json::json; diff --git a/client/examples/million_accounts_genesis.rs b/client/examples/million_accounts_genesis.rs index d781b2dfb73..079c0ecc7e5 100644 --- a/client/examples/million_accounts_genesis.rs +++ b/client/examples/million_accounts_genesis.rs @@ -2,7 +2,7 @@ use std::{thread, time::Duration}; use iroha::samples::{construct_executor, get_config}; -use iroha_data_model::prelude::*; +use iroha_client::data_model::prelude::*; use iroha_genesis::{GenesisNetwork, RawGenesisBlock, RawGenesisBlockBuilder}; use iroha_primitives::unique_vec; use test_network::{ diff --git a/client/examples/tutorial.rs b/client/examples/tutorial.rs index f95229602ed..a961a1932e7 100644 --- a/client/examples/tutorial.rs +++ b/client/examples/tutorial.rs @@ -3,9 +3,9 @@ use std::fs::File; use eyre::{Error, WrapErr}; +use iroha_client::data_model::TryToValue; // #region rust_config_crates use iroha_config::client::Configuration; -use iroha_data_model::TryToValue; // #endregion rust_config_crates fn main() { @@ -47,10 +47,12 @@ fn json_config_client_test(config: &Configuration) -> Result<(), Error> { fn domain_registration_test(config: &Configuration) -> Result<(), Error> { // #region domain_register_example_crates - use iroha_client::client::Client; - use iroha_data_model::{ - metadata::UnlimitedMetadata, - prelude::{Domain, DomainId, InstructionExpr, RegisterExpr}, + use iroha_client::{ + client::Client, + data_model::{ + metadata::UnlimitedMetadata, + prelude::{Domain, DomainId, InstructionExpr, RegisterExpr}, + }, }; // #endregion domain_register_example_crates @@ -91,9 +93,9 @@ fn domain_registration_test(config: &Configuration) -> Result<(), Error> { fn account_definition_test() -> Result<(), Error> { // #region account_definition_comparison - use iroha_data_model::prelude::AccountId; + use iroha_client::data_model::prelude::AccountId; - // Create an `iroha_data_model::AccountId` instance + // Create an `iroha_client::data_model::AccountId` instance // with a DomainId instance and a Domain ID for an account let longhand_account_id = AccountId::new("white_rabbit".parse()?, "looking_glass".parse()?); let account_id: AccountId = "white_rabbit@looking_glass" @@ -111,12 +113,14 @@ fn account_definition_test() -> Result<(), Error> { fn account_registration_test(config: &Configuration) -> Result<(), Error> { // #region register_account_crates - use iroha_client::client::Client; - use iroha_crypto::KeyPair; - use iroha_data_model::{ - metadata::UnlimitedMetadata, - prelude::{Account, AccountId, InstructionExpr, RegisterExpr}, + use iroha_client::{ + client::Client, + data_model::{ + metadata::UnlimitedMetadata, + prelude::{Account, AccountId, InstructionExpr, RegisterExpr}, + }, }; + use iroha_crypto::KeyPair; // #endregion register_account_crates // Create an Iroha client @@ -161,9 +165,11 @@ fn asset_registration_test(config: &Configuration) -> Result<(), Error> { // #region register_asset_crates use std::str::FromStr as _; - use iroha_client::client::Client; - use iroha_data_model::prelude::{ - AccountId, AssetDefinition, AssetDefinitionId, AssetId, IdBox, MintExpr, RegisterExpr, + use iroha_client::{ + client::Client, + data_model::prelude::{ + AccountId, AssetDefinition, AssetDefinitionId, AssetId, IdBox, MintExpr, RegisterExpr, + }, }; // #endregion register_asset_crates @@ -209,10 +215,12 @@ fn asset_minting_test(config: &Configuration) -> Result<(), Error> { // #region mint_asset_crates use std::str::FromStr; - use iroha_client::client::Client; - use iroha_data_model::{ - prelude::{AccountId, AssetDefinitionId, AssetId, MintExpr, ToValue}, - IdBox, + use iroha_client::{ + client::Client, + data_model::{ + prelude::{AccountId, AssetDefinitionId, AssetId, MintExpr, ToValue}, + IdBox, + }, }; // #endregion mint_asset_crates @@ -267,10 +275,12 @@ fn asset_burning_test(config: &Configuration) -> Result<(), Error> { // #region burn_asset_crates use std::str::FromStr; - use iroha_client::client::Client; - use iroha_data_model::{ - prelude::{AccountId, AssetDefinitionId, AssetId, BurnExpr, ToValue}, - IdBox, + use iroha_client::{ + client::Client, + data_model::{ + prelude::{AccountId, AssetDefinitionId, AssetId, BurnExpr, ToValue}, + IdBox, + }, }; // #endregion burn_asset_crates diff --git a/client/src/client.rs b/client/src/client.rs index 0978ff49d58..942e5444a8d 100644 --- a/client/src/client.rs +++ b/client/src/client.rs @@ -15,15 +15,6 @@ use futures_util::StreamExt; use http_default::{AsyncWebSocketStream, WebSocketStream}; use iroha_config::{client::Configuration, torii::uri, GetConfiguration, PostConfiguration}; use iroha_crypto::{HashOf, KeyPair}; -use iroha_data_model::{ - block::SignedBlock, - isi::Instruction, - predicate::PredicateBox, - prelude::*, - query::{Pagination, Query, Sorting}, - transaction::TransactionPayload, - BatchedResponse, ValidationFail, -}; use iroha_logger::prelude::*; use iroha_telemetry::metrics::Status; use iroha_version::prelude::*; @@ -34,6 +25,15 @@ use url::Url; use self::{blocks_api::AsyncBlockStream, events_api::AsyncEventStream}; use crate::{ + data_model::{ + block::SignedBlock, + isi::Instruction, + predicate::PredicateBox, + prelude::*, + query::{Pagination, Query, Sorting}, + transaction::TransactionPayload, + BatchedResponse, ValidationFail, + }, http::{Method as HttpMethod, RequestBuilder, Response, StatusCode}, http_default::{self, DefaultRequestBuilder, WebSocketError, WebSocketMessage}, query_builder::QueryRequestBuilder, @@ -144,7 +144,7 @@ where .map_err(Into::into) .wrap_err("Unexpected type")?; - self.query_request.request = iroha_data_model::query::QueryRequest::Cursor(cursor); + self.query_request.request = crate::data_model::query::QueryRequest::Cursor(cursor); Ok(value) } } @@ -263,7 +263,7 @@ where fn next(&mut self) -> Option { if self.client_cursor >= self.iter.len() { - let iroha_data_model::query::QueryRequest::Cursor(cursor) = + let crate::data_model::query::QueryRequest::Cursor(cursor) = &self.query_handler.query_request.request else { return None; @@ -323,18 +323,18 @@ macro_rules! impl_query_output { } impl_query_output! { bool, - iroha_data_model::Value, - iroha_data_model::numeric::NumericValue, - iroha_data_model::role::Role, - iroha_data_model::asset::Asset, - iroha_data_model::asset::AssetDefinition, - iroha_data_model::account::Account, - iroha_data_model::domain::Domain, - iroha_data_model::block::BlockHeader, - iroha_data_model::query::MetadataValue, - iroha_data_model::query::TransactionQueryOutput, - iroha_data_model::permission::PermissionTokenSchema, - iroha_data_model::trigger::Trigger, + crate::data_model::Value, + crate::data_model::numeric::NumericValue, + crate::data_model::role::Role, + crate::data_model::asset::Asset, + crate::data_model::asset::AssetDefinition, + crate::data_model::account::Account, + crate::data_model::domain::Domain, + crate::data_model::block::BlockHeader, + crate::data_model::query::MetadataValue, + crate::data_model::query::TransactionQueryOutput, + crate::data_model::permission::PermissionTokenSchema, + crate::data_model::trigger::Trigger, } /// Iroha client @@ -367,7 +367,7 @@ pub struct Client { pub struct QueryRequest { torii_url: Url, headers: HashMap, - request: iroha_data_model::query::QueryRequest>, + request: crate::data_model::query::QueryRequest>, } impl QueryRequest { @@ -378,8 +378,8 @@ impl QueryRequest { Self { torii_url: format!("http://{torii_url}").parse().unwrap(), headers: HashMap::new(), - request: iroha_data_model::query::QueryRequest::Query( - iroha_data_model::query::QueryWithParameters { + request: crate::data_model::query::QueryRequest::Query( + crate::data_model::query::QueryWithParameters { query: Vec::default(), sorting: Sorting::default(), pagination: Pagination::default(), @@ -397,12 +397,12 @@ impl QueryRequest { .headers(self.headers); match self.request { - iroha_data_model::query::QueryRequest::Query(query_with_params) => builder + crate::data_model::query::QueryRequest::Query(query_with_params) => builder .params(query_with_params.sorting().clone().into_query_parameters()) .params(query_with_params.pagination().into_query_parameters()) .params(query_with_params.fetch_size().into_query_parameters()) .body(query_with_params.query().clone()), - iroha_data_model::query::QueryRequest::Cursor(cursor) => { + crate::data_model::query::QueryRequest::Cursor(cursor) => { builder.params(Vec::from(cursor)) } } @@ -754,10 +754,10 @@ impl Client { /// ```ignore /// use eyre::Result; /// use iroha_client::{ + /// data_model::{predicate::PredicateBox, prelude::{Account, FindAllAccounts, Pagination}}, /// client::Client, /// http::{RequestBuilder, Response, Method}, /// }; - /// use iroha_data_model::{predicate::PredicateBox, prelude::{Account, FindAllAccounts, Pagination}}; /// /// struct YourAsyncRequest; /// @@ -821,8 +821,8 @@ impl Client { let query_request = QueryRequest { torii_url: self.torii_url.clone(), headers: self.headers.clone(), - request: iroha_data_model::query::QueryRequest::Query( - iroha_data_model::query::QueryWithParameters::new( + request: crate::data_model::query::QueryRequest::Query( + crate::data_model::query::QueryWithParameters::new( request, sorting, pagination, fetch_size, ), ), @@ -883,7 +883,7 @@ impl Client { #[cfg(debug_assertions)] pub fn request_with_cursor( &self, - cursor: iroha_data_model::query::cursor::ForwardCursor, + cursor: crate::data_model::query::cursor::ForwardCursor, ) -> QueryResult where O: QueryOutput, @@ -892,7 +892,7 @@ impl Client { let request = QueryRequest { torii_url: self.torii_url.clone(), headers: self.headers.clone(), - request: iroha_data_model::query::QueryRequest::Cursor(cursor), + request: crate::data_model::query::QueryRequest::Cursor(cursor), }; let response = request.clone().assemble().build()?.send()?; @@ -1386,7 +1386,7 @@ pub mod events_api { pub struct Events; impl FlowEvents for Events { - type Event = iroha_data_model::prelude::Event; + type Event = crate::data_model::prelude::Event; fn message(&self, message: Vec) -> Result { let event_socket_message = EventMessage::decode_all(&mut message.as_slice())?; @@ -1413,9 +1413,8 @@ mod blocks_api { pub mod flow { use std::num::NonZeroU64; - use iroha_data_model::block::stream::*; - use super::*; + use crate::data_model::block::stream::*; /// Initialization struct for Blocks API flow. pub struct Init { @@ -1466,7 +1465,7 @@ mod blocks_api { pub struct Events; impl FlowEvents for Events { - type Event = iroha_data_model::block::SignedBlock; + type Event = crate::data_model::block::SignedBlock; fn message(&self, message: Vec) -> Result { Ok(BlockMessage::decode_all(&mut message.as_slice()).map(Into::into)?) @@ -1758,9 +1757,9 @@ mod tests { #[cfg(test)] mod query_errors_handling { use http::Response; - use iroha_data_model::{asset::Asset, query::error::QueryExecutionFail, ValidationFail}; use super::*; + use crate::data_model::{asset::Asset, query::error::QueryExecutionFail, ValidationFail}; #[test] fn certain_errors() -> Result<()> { diff --git a/client/src/http.rs b/client/src/http.rs index 1a70a381c07..40ea3b923b0 100644 --- a/client/src/http.rs +++ b/client/src/http.rs @@ -149,8 +149,8 @@ pub mod ws { /// ```rust /// use eyre::Result; /// use url::Url; - /// use iroha_data_model::prelude::Event; /// use iroha_client::{ + /// data_model::prelude::Event, /// client::events_api::flow as events_api_flow, /// http::{ /// ws::conn_flow::{Events, Init, InitData}, diff --git a/client/src/lib.rs b/client/src/lib.rs index 02112f6400a..3d12fef5365 100644 --- a/client/src/lib.rs +++ b/client/src/lib.rs @@ -37,3 +37,5 @@ pub mod samples { .expect("Client config should build as all required fields were provided") } } + +pub use iroha_data_model as data_model; diff --git a/client/src/query_builder.rs b/client/src/query_builder.rs index 71fc1878d7f..e12b09f6769 100644 --- a/client/src/query_builder.rs +++ b/client/src/query_builder.rs @@ -1,13 +1,14 @@ use std::fmt::Debug; -use iroha_data_model::{ - predicate::PredicateBox, - query::{sorting::Sorting, FetchSize, Pagination, Query}, - Value, +use crate::{ + client::{Client, QueryOutput, QueryResult}, + data_model::{ + predicate::PredicateBox, + query::{sorting::Sorting, FetchSize, Pagination, Query}, + Value, + }, }; -use crate::client::{Client, QueryOutput, QueryResult}; - pub struct QueryRequestBuilder<'a, R> { client: &'a Client, request: R, diff --git a/client/tests/integration/add_account.rs b/client/tests/integration/add_account.rs index 32d5462c2fe..f463266399e 100644 --- a/client/tests/integration/add_account.rs +++ b/client/tests/integration/add_account.rs @@ -1,8 +1,7 @@ use std::thread; use eyre::Result; -use iroha_client::client; -use iroha_data_model::prelude::*; +use iroha_client::{client, data_model::prelude::*}; use test_network::*; #[test] diff --git a/client/tests/integration/add_domain.rs b/client/tests/integration/add_domain.rs index b10eaf4265b..f963fe31d10 100644 --- a/client/tests/integration/add_domain.rs +++ b/client/tests/integration/add_domain.rs @@ -1,8 +1,7 @@ use std::thread; use eyre::Result; -use iroha_client::client; -use iroha_data_model::prelude::*; +use iroha_client::{client, data_model::prelude::*}; use test_network::*; use super::Configuration; diff --git a/client/tests/integration/asset.rs b/client/tests/integration/asset.rs index 8f2059447b1..26e672fc857 100644 --- a/client/tests/integration/asset.rs +++ b/client/tests/integration/asset.rs @@ -1,9 +1,11 @@ use std::{str::FromStr as _, thread}; use eyre::Result; -use iroha_client::client::{self, QueryResult}; +use iroha_client::{ + client::{self, QueryResult}, + data_model::prelude::*, +}; use iroha_crypto::{KeyPair, PublicKey}; -use iroha_data_model::prelude::*; use iroha_primitives::fixed::Fixed; use serde_json::json; use test_network::*; @@ -92,7 +94,7 @@ fn client_add_asset_quantity_to_existing_asset_should_increase_asset_amount() -> let account_id = AccountId::from_str("alice@wonderland").expect("Valid"); let asset_definition_id = AssetDefinitionId::from_str("xor#wonderland").expect("Valid"); let create_asset = RegisterExpr::new(AssetDefinition::quantity(asset_definition_id.clone())); - let metadata = iroha_data_model::metadata::UnlimitedMetadata::default(); + let metadata = iroha_client::data_model::metadata::UnlimitedMetadata::default(); //When let quantity: u32 = 200; let mint = MintExpr::new( @@ -126,7 +128,7 @@ fn client_add_big_asset_quantity_to_existing_asset_should_increase_asset_amount( let asset_definition_id = AssetDefinitionId::from_str("xor#wonderland").expect("Valid"); let create_asset = RegisterExpr::new(AssetDefinition::big_quantity(asset_definition_id.clone())); - let metadata = iroha_data_model::metadata::UnlimitedMetadata::default(); + let metadata = iroha_client::data_model::metadata::UnlimitedMetadata::default(); //When let quantity: u128 = 2_u128.pow(65); let mint = MintExpr::new( @@ -160,7 +162,7 @@ fn client_add_asset_with_decimal_should_increase_asset_amount() -> Result<()> { let asset_definition_id = AssetDefinitionId::from_str("xor#wonderland").expect("Valid"); let identifiable_box = AssetDefinition::fixed(asset_definition_id.clone()); let create_asset = RegisterExpr::new(identifiable_box); - let metadata = iroha_data_model::metadata::UnlimitedMetadata::default(); + let metadata = iroha_client::data_model::metadata::UnlimitedMetadata::default(); //When let quantity: Fixed = Fixed::try_from(123.456_f64).unwrap(); diff --git a/client/tests/integration/asset_propagation.rs b/client/tests/integration/asset_propagation.rs index 50e7152a81e..fb50c5b3f2d 100644 --- a/client/tests/integration/asset_propagation.rs +++ b/client/tests/integration/asset_propagation.rs @@ -1,12 +1,14 @@ use std::{str::FromStr as _, thread}; use eyre::Result; -use iroha_client::client::{self, QueryResult}; -use iroha_crypto::KeyPair; -use iroha_data_model::{ - parameter::{default::MAX_TRANSACTIONS_IN_BLOCK, ParametersBuilder}, - prelude::*, +use iroha_client::{ + client::{self, QueryResult}, + data_model::{ + parameter::{default::MAX_TRANSACTIONS_IN_BLOCK, ParametersBuilder}, + prelude::*, + }, }; +use iroha_crypto::KeyPair; use test_network::*; use super::Configuration; diff --git a/client/tests/integration/burn_public_keys.rs b/client/tests/integration/burn_public_keys.rs index c69618ffa30..4c1431c0639 100644 --- a/client/tests/integration/burn_public_keys.rs +++ b/client/tests/integration/burn_public_keys.rs @@ -1,6 +1,8 @@ -use iroha_client::client::{account, transaction, Client}; +use iroha_client::{ + client::{account, transaction, Client}, + data_model::{isi::Instruction, prelude::*, transaction::TransactionPayload}, +}; use iroha_crypto::{HashOf, KeyPair, PublicKey}; -use iroha_data_model::{isi::Instruction, prelude::*, transaction::TransactionPayload}; use test_network::*; fn submit( diff --git a/client/tests/integration/connected_peers.rs b/client/tests/integration/connected_peers.rs index c649b2da531..0ad808b20c2 100644 --- a/client/tests/integration/connected_peers.rs +++ b/client/tests/integration/connected_peers.rs @@ -1,11 +1,13 @@ use std::thread; use eyre::{Context, Result}; -use iroha_client::client::Client; -use iroha_data_model::{ - parameter::{default::MAX_TRANSACTIONS_IN_BLOCK, ParametersBuilder}, - peer::Peer as DataModelPeer, - prelude::*, +use iroha_client::{ + client::Client, + data_model::{ + parameter::{default::MAX_TRANSACTIONS_IN_BLOCK, ParametersBuilder}, + peer::Peer as DataModelPeer, + prelude::*, + }, }; use test_network::*; diff --git a/client/tests/integration/domain_owner.rs b/client/tests/integration/domain_owner.rs index ab3f48e23b8..608eb38bdba 100644 --- a/client/tests/integration/domain_owner.rs +++ b/client/tests/integration/domain_owner.rs @@ -1,6 +1,6 @@ use eyre::Result; +use iroha_client::data_model::{account::SignatureCheckCondition, prelude::*}; use iroha_crypto::KeyPair; -use iroha_data_model::{account::SignatureCheckCondition, prelude::*}; use serde_json::json; use test_network::*; diff --git a/client/tests/integration/events/data.rs b/client/tests/integration/events/data.rs index e4c71bb6fad..161ec489ac7 100644 --- a/client/tests/integration/events/data.rs +++ b/client/tests/integration/events/data.rs @@ -1,7 +1,7 @@ use std::{fmt::Write as _, str::FromStr, sync::mpsc, thread}; use eyre::Result; -use iroha_data_model::{prelude::*, transaction::WasmSmartContract}; +use iroha_client::data_model::{prelude::*, transaction::WasmSmartContract}; use parity_scale_codec::Encode as _; use serde_json::json; use test_network::*; @@ -171,7 +171,7 @@ fn produce_multiple_events() -> Result<()> { "CanSetKeyValueInUserAccount".parse()?, &json!({ "account_id": alice_id }), ); - let role = iroha_data_model::role::Role::new(role_id.clone()) + let role = iroha_client::data_model::role::Role::new(role_id.clone()) .add_permission(token_1.clone()) .add_permission(token_2.clone()); let instructions = [RegisterExpr::new(role.clone())]; diff --git a/client/tests/integration/events/notification.rs b/client/tests/integration/events/notification.rs index 89b9a53a7ea..2c5cf522fd2 100644 --- a/client/tests/integration/events/notification.rs +++ b/client/tests/integration/events/notification.rs @@ -1,7 +1,7 @@ use std::{str::FromStr as _, sync::mpsc, thread, time::Duration}; use eyre::{eyre, Result, WrapErr}; -use iroha_data_model::prelude::*; +use iroha_client::data_model::prelude::*; use test_network::*; #[test] diff --git a/client/tests/integration/events/pipeline.rs b/client/tests/integration/events/pipeline.rs index 0d41bbb9f4a..8a9ce281d06 100644 --- a/client/tests/integration/events/pipeline.rs +++ b/client/tests/integration/events/pipeline.rs @@ -1,11 +1,11 @@ use std::thread::{self, JoinHandle}; use eyre::Result; -use iroha_crypto::HashOf; -use iroha_data_model::{ +use iroha_client::data_model::{ parameter::{default::MAX_TRANSACTIONS_IN_BLOCK, ParametersBuilder}, prelude::*, }; +use iroha_crypto::HashOf; use test_network::*; use super::Configuration; diff --git a/client/tests/integration/multiple_blocks_created.rs b/client/tests/integration/multiple_blocks_created.rs index 7f7c4066369..f2a13a8089b 100644 --- a/client/tests/integration/multiple_blocks_created.rs +++ b/client/tests/integration/multiple_blocks_created.rs @@ -1,12 +1,14 @@ use std::thread; use eyre::Result; -use iroha_client::client::{self, Client, QueryResult}; -use iroha_crypto::KeyPair; -use iroha_data_model::{ - parameter::{default::MAX_TRANSACTIONS_IN_BLOCK, ParametersBuilder}, - prelude::*, +use iroha_client::{ + client::{self, Client, QueryResult}, + data_model::{ + parameter::{default::MAX_TRANSACTIONS_IN_BLOCK, ParametersBuilder}, + prelude::*, + }, }; +use iroha_crypto::KeyPair; use test_network::*; use super::Configuration; diff --git a/client/tests/integration/multisignature_account.rs b/client/tests/integration/multisignature_account.rs index dfba65c7379..44f289dcfb1 100644 --- a/client/tests/integration/multisignature_account.rs +++ b/client/tests/integration/multisignature_account.rs @@ -1,9 +1,11 @@ use std::thread; use eyre::Result; -use iroha_client::client::{self, Client, QueryResult}; +use iroha_client::{ + client::{self, Client, QueryResult}, + data_model::prelude::*, +}; use iroha_crypto::KeyPair; -use iroha_data_model::prelude::*; use test_network::*; use super::Configuration; diff --git a/client/tests/integration/multisignature_transaction.rs b/client/tests/integration/multisignature_transaction.rs index abbe63bab8a..4d999d5c920 100644 --- a/client/tests/integration/multisignature_transaction.rs +++ b/client/tests/integration/multisignature_transaction.rs @@ -1,13 +1,15 @@ use std::{str::FromStr as _, thread, time::Duration}; use eyre::Result; -use iroha_client::client::{self, Client, QueryResult}; +use iroha_client::{ + client::{self, Client, QueryResult}, + data_model::{ + parameter::{default::MAX_TRANSACTIONS_IN_BLOCK, ParametersBuilder}, + prelude::*, + }, +}; use iroha_config::client::Configuration as ClientConfiguration; use iroha_crypto::KeyPair; -use iroha_data_model::{ - parameter::{default::MAX_TRANSACTIONS_IN_BLOCK, ParametersBuilder}, - prelude::*, -}; use test_network::*; use super::Configuration; diff --git a/client/tests/integration/non_mintable.rs b/client/tests/integration/non_mintable.rs index cee51a0bf86..1dca25910a2 100644 --- a/client/tests/integration/non_mintable.rs +++ b/client/tests/integration/non_mintable.rs @@ -1,8 +1,10 @@ use std::str::FromStr as _; use eyre::Result; -use iroha_client::client::{self, QueryResult}; -use iroha_data_model::{metadata::UnlimitedMetadata, prelude::*}; +use iroha_client::{ + client::{self, QueryResult}, + data_model::{metadata::UnlimitedMetadata, prelude::*}, +}; use test_network::*; #[test] diff --git a/client/tests/integration/offline_peers.rs b/client/tests/integration/offline_peers.rs index 5896aed3b20..86838146000 100644 --- a/client/tests/integration/offline_peers.rs +++ b/client/tests/integration/offline_peers.rs @@ -1,8 +1,10 @@ use eyre::Result; -use iroha_client::client::{self, QueryResult}; -use iroha_data_model::{ - parameter::{default::MAX_TRANSACTIONS_IN_BLOCK, ParametersBuilder}, - prelude::*, +use iroha_client::{ + client::{self, QueryResult}, + data_model::{ + parameter::{default::MAX_TRANSACTIONS_IN_BLOCK, ParametersBuilder}, + prelude::*, + }, }; use test_network::*; use tokio::runtime::Runtime; diff --git a/client/tests/integration/pagination.rs b/client/tests/integration/pagination.rs index 7a7f4141096..1ab7ab4c14d 100644 --- a/client/tests/integration/pagination.rs +++ b/client/tests/integration/pagination.rs @@ -1,8 +1,10 @@ use std::num::{NonZeroU32, NonZeroU64}; use eyre::Result; -use iroha_client::client::{asset, Client, QueryResult}; -use iroha_data_model::{asset::AssetDefinition, prelude::*, query::Pagination}; +use iroha_client::{ + client::{asset, Client, QueryResult}, + data_model::{asset::AssetDefinition, prelude::*, query::Pagination}, +}; use test_network::*; #[test] diff --git a/client/tests/integration/permissions.rs b/client/tests/integration/permissions.rs index 7fa9e93cd03..11234a6b16a 100644 --- a/client/tests/integration/permissions.rs +++ b/client/tests/integration/permissions.rs @@ -1,8 +1,10 @@ use std::{str::FromStr as _, thread, time::Duration}; use eyre::Result; -use iroha_client::client::{self, Client, QueryResult}; -use iroha_data_model::prelude::*; +use iroha_client::{ + client::{self, Client, QueryResult}, + data_model::prelude::*, +}; use iroha_genesis::GenesisNetwork; use serde_json::json; use test_network::{PeerBuilder, *}; diff --git a/client/tests/integration/queries/account.rs b/client/tests/integration/queries/account.rs index 8698eb77c3f..d19a4498361 100644 --- a/client/tests/integration/queries/account.rs +++ b/client/tests/integration/queries/account.rs @@ -1,8 +1,10 @@ use std::{collections::HashSet, str::FromStr as _}; use eyre::Result; -use iroha_client::client::{self, QueryResult}; -use iroha_data_model::prelude::*; +use iroha_client::{ + client::{self, QueryResult}, + data_model::prelude::*, +}; use test_network::*; #[test] diff --git a/client/tests/integration/queries/asset.rs b/client/tests/integration/queries/asset.rs index e833c801972..4748cd6d7c2 100644 --- a/client/tests/integration/queries/asset.rs +++ b/client/tests/integration/queries/asset.rs @@ -1,10 +1,12 @@ use eyre::Result; -use iroha_client::client::ClientQueryError; -use iroha_crypto::KeyPair; -use iroha_data_model::{ - prelude::*, - query::{asset::FindTotalAssetQuantityByAssetDefinitionId, error::QueryExecutionFail}, +use iroha_client::{ + client::ClientQueryError, + data_model::{ + prelude::*, + query::{asset::FindTotalAssetQuantityByAssetDefinitionId, error::QueryExecutionFail}, + }, }; +use iroha_crypto::KeyPair; use iroha_primitives::fixed::Fixed; use test_network::*; diff --git a/client/tests/integration/queries/mod.rs b/client/tests/integration/queries/mod.rs index 01c266191c7..df0104e07bc 100644 --- a/client/tests/integration/queries/mod.rs +++ b/client/tests/integration/queries/mod.rs @@ -1,10 +1,12 @@ use std::str::FromStr as _; use eyre::{bail, Result}; -use iroha_client::client::{self, ClientQueryError}; -use iroha_data_model::{ - prelude::*, - query::{cursor::ForwardCursor, error::QueryExecutionFail, MAX_FETCH_SIZE}, +use iroha_client::{ + client::{self, ClientQueryError}, + data_model::{ + prelude::*, + query::{cursor::ForwardCursor, error::QueryExecutionFail, MAX_FETCH_SIZE}, + }, }; use test_network::*; diff --git a/client/tests/integration/queries/role.rs b/client/tests/integration/queries/role.rs index 2151b809f34..5432dc2e547 100644 --- a/client/tests/integration/queries/role.rs +++ b/client/tests/integration/queries/role.rs @@ -1,8 +1,10 @@ use std::collections::HashSet; use eyre::Result; -use iroha_client::client::{self, QueryResult}; -use iroha_data_model::{prelude::*, query::error::QueryExecutionFail}; +use iroha_client::{ + client::{self, QueryResult}, + data_model::{prelude::*, query::error::QueryExecutionFail}, +}; use serde_json::json; use test_network::*; diff --git a/client/tests/integration/query_errors.rs b/client/tests/integration/query_errors.rs index 1d307b69e4a..9a27cb7740c 100644 --- a/client/tests/integration/query_errors.rs +++ b/client/tests/integration/query_errors.rs @@ -1,9 +1,11 @@ use std::str::FromStr; -use iroha_client::client::{self, ClientQueryError}; -use iroha_data_model::{ - prelude::*, - query::error::{FindError, QueryExecutionFail}, +use iroha_client::{ + client::{self, ClientQueryError}, + data_model::{ + prelude::*, + query::error::{FindError, QueryExecutionFail}, + }, }; #[test] diff --git a/client/tests/integration/restart_peer.rs b/client/tests/integration/restart_peer.rs index d3de54b4aaf..cfe153e3c9d 100644 --- a/client/tests/integration/restart_peer.rs +++ b/client/tests/integration/restart_peer.rs @@ -1,8 +1,10 @@ use std::{str::FromStr, sync::Arc}; use eyre::Result; -use iroha_client::client::{self, QueryResult}; -use iroha_data_model::prelude::*; +use iroha_client::{ + client::{self, QueryResult}, + data_model::prelude::*, +}; use iroha_primitives::unique_vec; use tempfile::TempDir; use test_network::*; diff --git a/client/tests/integration/roles.rs b/client/tests/integration/roles.rs index 326487c3fb7..a89a939c69d 100644 --- a/client/tests/integration/roles.rs +++ b/client/tests/integration/roles.rs @@ -1,8 +1,10 @@ use std::str::FromStr as _; use eyre::Result; -use iroha_client::client::{self, QueryResult}; -use iroha_data_model::prelude::*; +use iroha_client::{ + client::{self, QueryResult}, + data_model::prelude::*, +}; use serde_json::json; use test_network::*; diff --git a/client/tests/integration/set_parameter.rs b/client/tests/integration/set_parameter.rs index c31563db662..1308c7ea141 100644 --- a/client/tests/integration/set_parameter.rs +++ b/client/tests/integration/set_parameter.rs @@ -1,8 +1,10 @@ use std::str::FromStr; use eyre::Result; -use iroha_client::client::{self, QueryResult}; -use iroha_data_model::prelude::*; +use iroha_client::{ + client::{self, QueryResult}, + data_model::prelude::*, +}; use test_network::*; #[test] diff --git a/client/tests/integration/sorting.rs b/client/tests/integration/sorting.rs index a4452c3e241..31b974d2b05 100644 --- a/client/tests/integration/sorting.rs +++ b/client/tests/integration/sorting.rs @@ -5,12 +5,14 @@ use std::{ }; use eyre::{Result, WrapErr as _}; -use iroha_client::client::{self, QueryResult}; -use iroha_data_model::{ - account::Account, - predicate::{string, value, PredicateBox}, - prelude::*, - query::{Pagination, Sorting}, +use iroha_client::{ + client::{self, QueryResult}, + data_model::{ + account::Account, + predicate::{string, value, PredicateBox}, + prelude::*, + query::{Pagination, Sorting}, + }, }; use test_network::*; diff --git a/client/tests/integration/transfer_asset.rs b/client/tests/integration/transfer_asset.rs index 3eb2ae5883e..d8087401a8b 100644 --- a/client/tests/integration/transfer_asset.rs +++ b/client/tests/integration/transfer_asset.rs @@ -1,6 +1,8 @@ -use iroha_client::client::{self, QueryResult}; +use iroha_client::{ + client::{self, QueryResult}, + data_model::{prelude::*, Registered}, +}; use iroha_crypto::KeyPair; -use iroha_data_model::{prelude::*, Registered}; use iroha_primitives::fixed::Fixed; use test_network::*; diff --git a/client/tests/integration/triggers/by_call_trigger.rs b/client/tests/integration/triggers/by_call_trigger.rs index d7602a54cdb..a2b03df24d7 100644 --- a/client/tests/integration/triggers/by_call_trigger.rs +++ b/client/tests/integration/triggers/by_call_trigger.rs @@ -1,11 +1,13 @@ use std::{str::FromStr as _, sync::mpsc, thread, time::Duration}; use eyre::{eyre, Result, WrapErr}; -use iroha_client::client::{self, Client}; -use iroha_data_model::{ - prelude::*, - query::error::{FindError, QueryExecutionFail}, - transaction::Executable, +use iroha_client::{ + client::{self, Client}, + data_model::{ + prelude::*, + query::error::{FindError, QueryExecutionFail}, + transaction::Executable, + }, }; use iroha_genesis::GenesisNetwork; use iroha_logger::info; diff --git a/client/tests/integration/triggers/data_trigger.rs b/client/tests/integration/triggers/data_trigger.rs index a95c9ff4466..46744151559 100644 --- a/client/tests/integration/triggers/data_trigger.rs +++ b/client/tests/integration/triggers/data_trigger.rs @@ -1,6 +1,5 @@ use eyre::Result; -use iroha_client::client; -use iroha_data_model::prelude::*; +use iroha_client::{client, data_model::prelude::*}; use test_network::*; #[test] diff --git a/client/tests/integration/triggers/event_trigger.rs b/client/tests/integration/triggers/event_trigger.rs index 53a8aa55cd4..8b438d47fb9 100644 --- a/client/tests/integration/triggers/event_trigger.rs +++ b/client/tests/integration/triggers/event_trigger.rs @@ -1,8 +1,10 @@ use std::str::FromStr; use eyre::Result; -use iroha_client::client::{self, Client}; -use iroha_data_model::prelude::*; +use iroha_client::{ + client::{self, Client}, + data_model::prelude::*, +}; use test_network::*; #[test] diff --git a/client/tests/integration/triggers/time_trigger.rs b/client/tests/integration/triggers/time_trigger.rs index 959256b7f47..2a150f336c4 100644 --- a/client/tests/integration/triggers/time_trigger.rs +++ b/client/tests/integration/triggers/time_trigger.rs @@ -1,9 +1,11 @@ use std::{str::FromStr as _, time::Duration}; use eyre::Result; -use iroha_client::client::{self, Client, QueryResult}; +use iroha_client::{ + client::{self, Client, QueryResult}, + data_model::{prelude::*, transaction::WasmSmartContract}, +}; use iroha_config::sumeragi::default::DEFAULT_CONSENSUS_ESTIMATION_MS; -use iroha_data_model::{prelude::*, transaction::WasmSmartContract}; use iroha_logger::info; use test_network::*; diff --git a/client/tests/integration/tx_history.rs b/client/tests/integration/tx_history.rs index 3d85aa77740..15c2ef3c3e1 100644 --- a/client/tests/integration/tx_history.rs +++ b/client/tests/integration/tx_history.rs @@ -5,8 +5,10 @@ use std::{ }; use eyre::Result; -use iroha_client::client::{transaction, QueryResult}; -use iroha_data_model::{prelude::*, query::Pagination}; +use iroha_client::{ + client::{transaction, QueryResult}, + data_model::{prelude::*, query::Pagination}, +}; use test_network::*; use super::Configuration; diff --git a/client/tests/integration/tx_rollback.rs b/client/tests/integration/tx_rollback.rs index b7c03e2e20b..a8b1b918dc9 100644 --- a/client/tests/integration/tx_rollback.rs +++ b/client/tests/integration/tx_rollback.rs @@ -1,8 +1,10 @@ use std::str::FromStr as _; use eyre::Result; -use iroha_client::client::{self, QueryResult}; -use iroha_data_model::prelude::*; +use iroha_client::{ + client::{self, QueryResult}, + data_model::prelude::*, +}; use test_network::*; #[test] diff --git a/client/tests/integration/unregister_peer.rs b/client/tests/integration/unregister_peer.rs index 70d91345ea9..845f938de16 100644 --- a/client/tests/integration/unregister_peer.rs +++ b/client/tests/integration/unregister_peer.rs @@ -1,12 +1,14 @@ use std::thread; use eyre::Result; -use iroha_client::client::{self, QueryResult}; -use iroha_crypto::KeyPair; -use iroha_data_model::{ - parameter::{default::MAX_TRANSACTIONS_IN_BLOCK, ParametersBuilder}, - prelude::*, +use iroha_client::{ + client::{self, QueryResult}, + data_model::{ + parameter::{default::MAX_TRANSACTIONS_IN_BLOCK, ParametersBuilder}, + prelude::*, + }, }; +use iroha_crypto::KeyPair; use test_network::*; use super::Configuration; diff --git a/client/tests/integration/unstable_network.rs b/client/tests/integration/unstable_network.rs index f7f566b8aed..d0df5179a2c 100644 --- a/client/tests/integration/unstable_network.rs +++ b/client/tests/integration/unstable_network.rs @@ -1,8 +1,10 @@ use core::sync::atomic::Ordering; use std::thread; -use iroha_client::client::{self, Client, QueryResult}; -use iroha_data_model::{prelude::*, Level}; +use iroha_client::{ + client::{self, Client, QueryResult}, + data_model::{prelude::*, Level}, +}; use rand::seq::SliceRandom; use test_network::*; use tokio::runtime::Runtime; diff --git a/client/tests/integration/upgrade.rs b/client/tests/integration/upgrade.rs index 63490b138e9..5c1de0736c4 100644 --- a/client/tests/integration/upgrade.rs +++ b/client/tests/integration/upgrade.rs @@ -1,9 +1,11 @@ use std::{path::Path, str::FromStr as _}; use eyre::Result; -use iroha_client::client::{self, Client, QueryResult}; +use iroha_client::{ + client::{self, Client, QueryResult}, + data_model::prelude::*, +}; use iroha_crypto::KeyPair; -use iroha_data_model::prelude::*; use iroha_logger::info; use serde_json::json; use test_network::*; diff --git a/client_cli/Cargo.toml b/client_cli/Cargo.toml index 29ee5b8827b..12d6ffa40c5 100644 --- a/client_cli/Cargo.toml +++ b/client_cli/Cargo.toml @@ -24,7 +24,6 @@ maintenance = { status = "actively-developed" } [dependencies] iroha_client = { workspace = true } -iroha_data_model = { workspace = true } iroha_primitives = { workspace = true } iroha_crypto = { workspace = true } iroha_config = { workspace = true } diff --git a/client_cli/README.md b/client_cli/README.md index a2242468444..4c68cc53d97 100644 --- a/client_cli/README.md +++ b/client_cli/README.md @@ -22,7 +22,7 @@ The above command will produce the `iroha_client_cli` ELF executable file for Li Check [build and installation instructions](https://hyperledger.github.io/iroha-2-docs/guide/build-and-install.html) for more details. -## Usage +## Usage Run Iroha Client CLI: @@ -62,8 +62,8 @@ Check the [Bash guide in Iroha Tutorial](https://hyperledger.github.io/iroha-2-d ./iroha_client_cli domain register --id="Soramitsu" ./iroha_client_cli account register --id="White Rabbit@Soramitsu" --key="" ./iroha_client_cli asset register --id="XOR#Soramitsu" --value-type=Quantity -./iroha_client_cli asset mint --account="White Rabbit@Soramitsu" --asset="XOR#Soramitsu" --quantity=1010 -./iroha_client_cli asset get --account="White Rabbit@Soramitsu" --asset="XOR#Soramitsu" +./iroha_client_cli asset mint --account="White Rabbit@Soramitsu" --asset="XOR#Soramitsu" --quantity=1010 +./iroha_client_cli asset get --account="White Rabbit@Soramitsu" --asset="XOR#Soramitsu" ``` In this section we will show you how to use Iroha CLI Client to do the following: @@ -101,20 +101,20 @@ Additionally, you need to provide the `key` argument with the account's public k It's time to give something to the Account you created. Let's add some Assets of the type `Quantity` to the account. -To do so, you must first register an Asset Definition and only then add some Assets to the account. Specify the `asset` entity and then use the `register` and `mint` commands respectively. - +To do so, you must first register an Asset Definition and only then add some Assets to the account. Specify the `asset` entity and then use the `register` and `mint` commands respectively. + Every asset has its own value type. In this example, it is defined as `Quantity`, a 32-bit unsigned integer. We also support `BigQuantity` and `Fixed`, which are a 128-bit unsigned integer and a 64-bit fixed-precision binary fraction, as well as `Store` for key-value structured data. ```bash ./iroha_client_cli asset register --id="XOR#Soramitsu" --value-type=Quantity -./iroha_client_cli asset mint --account="White Rabbit@Soramitsu" --asset="XOR#Soramitsu" --quantity=1010 +./iroha_client_cli asset mint --account="White Rabbit@Soramitsu" --asset="XOR#Soramitsu" --quantity=1010 ``` You created `XOR#Soramitsu`, an asset of type `Quantity`, and then gave `1010` units of this asset to the account `White Rabbit@Soramitsu`. ### Query Account Assets Quantity -Because distributed systems heavily rely on the concept of _eventual_ consistency and Iroha works by awaiting consensus between peers, your request is not guaranteed to be processed (or be accepted) even if it is correctly formed. +Because distributed systems heavily rely on the concept of _eventual_ consistency and Iroha works by awaiting consensus between peers, your request is not guaranteed to be processed (or be accepted) even if it is correctly formed. While the Iroha Client will successfully send your transactions and the Iroha Peer will confirm receiving them, it is possible that your request will not appear in the next block. Different causes such as a transaction timeout, a faulty peer in the network, catastrophic failure of the peer that you've sent your data towards, and many other conditions naturally occurring inside of any blockchain may lead to a rejection of your transaction at many different stages of processing. @@ -128,7 +128,7 @@ Let's use Get Account Assets Query as an example. To know how many units of a particular asset an account has, use `asset get` with the specified account and asset: ```bash -./iroha_client_cli asset get --account="White Rabbit@Soramitsu" --asset="XOR#Soramitsu" +./iroha_client_cli asset get --account="White Rabbit@Soramitsu" --asset="XOR#Soramitsu" ``` This query returns the quantity of `XOR#Soramitsu` asset for the `White Rabbit@Soramitsu` account. @@ -141,7 +141,7 @@ Generally it looks like this: ./iroha_client_cli ENTITY list filter PREDICATE ``` -Where ENTITY is asset, account or domain and PREDICATE is condition used for filtering serialized using JSON5 (check `iroha_data_model::predicate::value::ValuePredicate` type). +Where ENTITY is asset, account or domain and PREDICATE is condition used for filtering serialized using JSON5 (check `iroha_client::data_model::predicate::value::ValuePredicate` type). Examples: @@ -174,7 +174,7 @@ These subcommands submit the provided wasm binary as an `Executable` to be execu ### Execute Multi-instruction Transactions The reference implementation of the Rust client, `iroha_client_cli`, is often used for diagnosing problems in other implementations. - + To test transactions in the JSON format (used in the genesis block and by other SDKs), pipe the transaction into the client and add the `json` subcommand to the arguments: ```bash diff --git a/client_cli/src/main.rs b/client_cli/src/main.rs index f2f98f9e05b..c16c633fd56 100644 --- a/client_cli/src/main.rs +++ b/client_cli/src/main.rs @@ -14,10 +14,11 @@ use color_eyre::{ }; use dialoguer::Confirm; use erased_serde::Serialize; -use iroha_client::client::{Client, QueryResult}; +use iroha_client::{ + client::{Client, QueryResult}, + data_model::prelude::*, +}; use iroha_config::{client::Configuration as ClientConfiguration, path::Path as ConfigPath}; -use iroha_crypto::prelude::*; -use iroha_data_model::prelude::*; use iroha_primitives::addr::SocketAddr; /// Metadata wrapper, which can be captured from cli arguments (from user supplied file). @@ -263,7 +264,7 @@ fn submit( } mod filter { - use iroha_data_model::predicate::PredicateBox; + use iroha_client::data_model::predicate::PredicateBox; use super::*; diff --git a/core/test_network/src/lib.rs b/core/test_network/src/lib.rs index 25ba5941fa8..93da80d6b8a 100644 --- a/core/test_network/src/lib.rs +++ b/core/test_network/src/lib.rs @@ -7,7 +7,10 @@ use std::{collections::BTreeMap, path::Path, sync::Arc, thread}; use eyre::Result; use futures::{prelude::*, stream::FuturesUnordered}; use iroha::Iroha; -use iroha_client::client::{Client, QueryOutput}; +use iroha_client::{ + client::{Client, QueryOutput}, + data_model::{isi::Instruction, peer::Peer as DataModelPeer, prelude::*, query::Query, Level}, +}; use iroha_config::{ base::proxy::{LoadFromEnv, Override}, client::Configuration as ClientConfiguration, @@ -16,9 +19,6 @@ use iroha_config::{ torii::Configuration as ToriiConfiguration, }; use iroha_crypto::prelude::*; -use iroha_data_model::{ - isi::Instruction, peer::Peer as DataModelPeer, prelude::*, query::Query, Level, -}; use iroha_genesis::{GenesisNetwork, RawGenesisBlock}; use iroha_logger::{Configuration as LoggerConfiguration, InstrumentFutures}; use iroha_primitives::{ diff --git a/data_model/Cargo.toml b/data_model/Cargo.toml index c04c3dba783..9b80ee2b6fc 100644 --- a/data_model/Cargo.toml +++ b/data_model/Cargo.toml @@ -55,8 +55,6 @@ base64 = { workspace = true, features = ["alloc"] } once_cell = { workspace = true, optional = true } [dev-dependencies] -iroha_client = { workspace = true } - trybuild = { workspace = true } criterion = { workspace = true } diff --git a/smart_contract/executor/Cargo.toml b/smart_contract/executor/Cargo.toml index 6e0eb5bcda7..b6ba7d299e3 100644 --- a/smart_contract/executor/Cargo.toml +++ b/smart_contract/executor/Cargo.toml @@ -17,7 +17,6 @@ debug = ["iroha_smart_contract/debug"] iroha_smart_contract_utils.workspace = true iroha_smart_contract.workspace = true iroha_executor_derive.workspace = true -iroha_data_model.workspace = true iroha_schema.workspace = true serde.workspace = true diff --git a/smart_contract/executor/derive/Cargo.toml b/smart_contract/executor/derive/Cargo.toml index ce43975f33a..652714e3625 100644 --- a/smart_contract/executor/derive/Cargo.toml +++ b/smart_contract/executor/derive/Cargo.toml @@ -15,7 +15,6 @@ workspace = true proc-macro = true [dependencies] -iroha_data_model.workspace = true iroha_macro_utils.workspace = true syn = { workspace = true, features = ["full", "derive"] } syn2 = { workspace = true, features = ["full", "derive"] } diff --git a/smart_contract/executor/derive/src/lib.rs b/smart_contract/executor/derive/src/lib.rs index d822a1887e1..b5795582d44 100644 --- a/smart_contract/executor/derive/src/lib.rs +++ b/smart_contract/executor/derive/src/lib.rs @@ -202,7 +202,7 @@ pub fn derive_ref_into_domain_owner(input: TokenStream) -> TokenStream { /// Implements the `iroha_executor::Validate` trait for the given `Executor` struct. As /// this trait has a `iroha_executor::prelude::Visit`, and the latter has an -/// `iroha_executor::iroha_data_model::evaluate::ExpressionEvaluator` +/// `iroha_executor::data_model::evaluate::ExpressionEvaluator` /// bound, at least these two should be implemented as well. /// /// Emits a compile error if the struct didn't have all the expected fields with corresponding @@ -309,7 +309,7 @@ pub fn derive_entrypoints(input: TokenStream2) -> TokenStream2 { emitter.finish_token_stream_with(result) } -/// Implements `iroha_executor::iroha_data_model::evaluate::ExpressionEvaluator` trait +/// Implements `iroha_executor::data_model::evaluate::ExpressionEvaluator` trait /// for the given `Executor` struct. /// /// Emits a compile error if the struct didn't have all the expected fields with corresponding diff --git a/smart_contract/executor/src/default.rs b/smart_contract/executor/src/default.rs index 78e46240d7f..771439e9742 100644 --- a/smart_contract/executor/src/default.rs +++ b/smart_contract/executor/src/default.rs @@ -1222,7 +1222,7 @@ pub mod executor { pub fn visit_upgrade_executor( executor: &mut V, authority: &AccountId, - _isi: Upgrade, + _isi: Upgrade, ) { if is_genesis(executor) { pass!(executor); diff --git a/smart_contract/executor/src/lib.rs b/smart_contract/executor/src/lib.rs index a8d9dea11e0..cdbb7fe199c 100644 --- a/smart_contract/executor/src/lib.rs +++ b/smart_contract/executor/src/lib.rs @@ -7,18 +7,15 @@ extern crate self as iroha_executor; use alloc::vec::Vec; -pub use iroha_data_model as data_model; -use iroha_data_model::{ - executor::Result, permission::PermissionTokenId, visit::Visit, ValidationFail, -}; +use data_model::{executor::Result, permission::PermissionTokenId, visit::Visit, ValidationFail}; #[cfg(not(test))] -use iroha_data_model::{prelude::*, smart_contract::payloads}; +use data_model::{prelude::*, smart_contract::payloads}; pub use iroha_schema::MetaMap; pub use iroha_smart_contract as smart_contract; pub use iroha_smart_contract_utils::{debug, encode_with_length_prefix}; #[cfg(not(test))] use iroha_smart_contract_utils::{decode_with_length_prefix_from_raw, encode_and_execute}; -pub use smart_contract::parse; +pub use smart_contract::{data_model, parse}; pub mod default; pub mod permission; @@ -221,17 +218,19 @@ pub mod prelude { pub use alloc::vec::Vec; - pub use iroha_data_model::{ - executor::{MigrationError, MigrationResult, Result}, - prelude::*, - visit::Visit, - ValidationFail, - }; pub use iroha_executor_derive::{ entrypoint, Constructor, ExpressionEvaluator, Token, Validate, ValidateEntrypoints, ValidateGrantRevoke, Visit, }; pub use iroha_smart_contract::{prelude::*, Context}; - pub use super::{deny, pass, PermissionTokenSchema, Validate}; + pub use super::{ + data_model::{ + executor::{MigrationError, MigrationResult, Result}, + prelude::*, + visit::Visit, + ValidationFail, + }, + deny, pass, PermissionTokenSchema, Validate, + }; } diff --git a/smart_contract/trigger/Cargo.toml b/smart_contract/trigger/Cargo.toml index 72da4d0677f..3e89ca3581c 100644 --- a/smart_contract/trigger/Cargo.toml +++ b/smart_contract/trigger/Cargo.toml @@ -17,4 +17,3 @@ debug = ["iroha_smart_contract/debug"] iroha_smart_contract_utils.workspace = true iroha_smart_contract.workspace = true iroha_trigger_derive.workspace = true -iroha_data_model.workspace = true diff --git a/smart_contract/trigger/src/lib.rs b/smart_contract/trigger/src/lib.rs index 84bb1d1f76a..0edf23d5dd4 100644 --- a/smart_contract/trigger/src/lib.rs +++ b/smart_contract/trigger/src/lib.rs @@ -4,12 +4,12 @@ #[cfg(not(test))] use data_model::smart_contract::payloads; -pub use iroha_data_model as data_model; pub use iroha_smart_contract as smart_contract; pub use iroha_smart_contract_utils::debug; #[cfg(not(test))] use iroha_smart_contract_utils::decode_with_length_prefix_from_raw; pub use iroha_trigger_derive::main; +pub use smart_contract::data_model; pub mod log { //! WASM logging utilities