From 498363de8e1f97022774455fc2ff32b46a43fc35 Mon Sep 17 00:00:00 2001 From: Dmitry Murzin Date: Thu, 14 Nov 2024 18:31:36 +0300 Subject: [PATCH] cargo fmt Signed-off-by: Dmitry Murzin --- Rust/examples/account_register.rs | 10 +++++++--- Rust/examples/asset_definition_register.rs | 5 +++-- Rust/examples/asset_store.rs | 5 ++++- Rust/examples/domain_transfer.rs | 9 +++++++-- Rust/examples/metadata.rs | 20 ++++++++++++-------- Rust/examples/roles.rs | 11 ++++++----- Rust/examples/status.rs | 2 +- Rust/examples/transaction.rs | 8 ++++---- Rust/src/lib.rs | 2 +- 9 files changed, 45 insertions(+), 27 deletions(-) diff --git a/Rust/examples/account_register.rs b/Rust/examples/account_register.rs index 7f53daf..6497de9 100644 --- a/Rust/examples/account_register.rs +++ b/Rust/examples/account_register.rs @@ -3,15 +3,15 @@ //! Depends on the `domain_register` example. use iroha::client::Client; -use iroha::data_model::Identifiable; use iroha::data_model::prelude::{ Account, AccountId, FindAccounts, Grant, QueryBuilderExt, Register, Revoke, }; -use iroha_executor_data_model::permission::account::CanRegisterAccount; +use iroha::data_model::Identifiable; use iroha_examples::{ AliceInChess, AliceInWonderland, BobInChess, BobInWonderland, Chess, ExampleDomain, MagnusInChess, }; +use iroha_executor_data_model::permission::account::CanRegisterAccount; fn main() -> iroha_examples::Result<()> { // An account is created for a signatory in a domain. @@ -50,7 +50,11 @@ fn register(as_who: &Client, account: AccountId) -> iroha_examples::Result<()> { .query(FindAccounts) .filter_with(|acc| acc.id.eq(account)) .execute_single()?; - println!("Account: {}\nRegistered by: {}", account.id(), as_who.account); + println!( + "Account: {}\nRegistered by: {}", + account.id(), + as_who.account + ); // Account: ed12...41@wonderland // Registered by: ed01...12@wonderland Ok(()) diff --git a/Rust/examples/asset_definition_register.rs b/Rust/examples/asset_definition_register.rs index f6b728c..55694be 100644 --- a/Rust/examples/asset_definition_register.rs +++ b/Rust/examples/asset_definition_register.rs @@ -10,11 +10,11 @@ use iroha::data_model::prelude::{ FindAssetsDefinitions, Metadata, NewAssetDefinition, NumericSpec, QueryBuilderExt, Register, Revoke, }; -use iroha_executor_data_model::permission::asset_definition::CanRegisterAssetDefinition; use iroha_examples::{ AliceInWonderland, BobInChess, Chess, ChessBook, ChessPawns, ExampleDomain, WonderlandMoney, WonderlandRoses, }; +use iroha_executor_data_model::permission::asset_definition::CanRegisterAssetDefinition; fn main() -> iroha_examples::Result<()> { let as_alice_in_wland = AliceInWonderland::client(); @@ -87,7 +87,8 @@ fn register(as_who: &Client, asset_definition: NewAssetDefinition) -> iroha_exam .execute_single()?; println!( "Asset definition: {}\nRegistered by: {}", - asset_definition.id(), as_who.account + asset_definition.id(), + as_who.account ); // Asset definition: pawn#chess // Registered by: ed01...12@wonderland diff --git a/Rust/examples/asset_store.rs b/Rust/examples/asset_store.rs index c0f84cb..1883ccb 100644 --- a/Rust/examples/asset_store.rs +++ b/Rust/examples/asset_store.rs @@ -6,7 +6,10 @@ use iroha::client::Client; use iroha::data_model::asset::{Asset, AssetValue}; -use iroha::data_model::prelude::{AssetId, FindAssets, Json, Metadata, Name, QueryBuilderExt, Register, RemoveKeyValue, SetKeyValue}; +use iroha::data_model::prelude::{ + AssetId, FindAssets, Json, Metadata, Name, QueryBuilderExt, Register, RemoveKeyValue, + SetKeyValue, +}; use iroha_examples::{AliceInWonderland, BobInChess, BookOfBobInChess}; fn main() -> iroha_examples::Result<()> { diff --git a/Rust/examples/domain_transfer.rs b/Rust/examples/domain_transfer.rs index 52a314f..4829d88 100644 --- a/Rust/examples/domain_transfer.rs +++ b/Rust/examples/domain_transfer.rs @@ -3,7 +3,9 @@ //! Depends on the `domain_register` example. use iroha::client::Client; -use iroha::data_model::prelude::{AccountId, DomainId, FindDomains, QueryBuilderExt, Transfer, Identifiable}; +use iroha::data_model::prelude::{ + AccountId, DomainId, FindDomains, Identifiable, QueryBuilderExt, Transfer, +}; use iroha_examples::{AliceInWonderland, BobInWonderland, ExampleDomain, Wonderland}; @@ -52,7 +54,10 @@ fn transfer( assert_eq!(domain.owned_by(), &to); println!( "Domain: {}\nTransferred\n\tfrom: {}\n\tto: {}\nby: {}", - domain.id(), from, to, as_who.account + domain.id(), + from, + to, + as_who.account ); // Domain: chess // Transferred diff --git a/Rust/examples/metadata.rs b/Rust/examples/metadata.rs index 7ae625c..ba622be 100644 --- a/Rust/examples/metadata.rs +++ b/Rust/examples/metadata.rs @@ -7,10 +7,12 @@ fn main() -> iroha_examples::Result<()> { let alice_in_wland = AliceInWonderland::id(); let as_alice_in_wland = AliceInWonderland::client(); let key = "key".parse::()?; - let value = as_alice_in_wland.query_single(FindAccountMetadata::new( - alice_in_wland.clone(), - key.clone(), - )).ok(); + let value = as_alice_in_wland + .query_single(FindAccountMetadata::new( + alice_in_wland.clone(), + key.clone(), + )) + .ok(); println!("metadata[{key}] of alice@wonderland: {value:?}"); as_alice_in_wland.submit_blocking(SetKeyValue::account( @@ -28,9 +30,11 @@ fn main() -> iroha_examples::Result<()> { as_alice_in_wland .submit_blocking(RemoveKeyValue::account(alice_in_wland.clone(), key.clone()))?; - as_alice_in_wland.query_single(FindAccountMetadata::new( - alice_in_wland.clone(), - key.clone(), - )).expect_err("key-value should be removed"); + as_alice_in_wland + .query_single(FindAccountMetadata::new( + alice_in_wland.clone(), + key.clone(), + )) + .expect_err("key-value should be removed"); Ok(()) } diff --git a/Rust/examples/roles.rs b/Rust/examples/roles.rs index a980cf9..b1c0cad 100644 --- a/Rust/examples/roles.rs +++ b/Rust/examples/roles.rs @@ -1,20 +1,21 @@ //! Shows how to work with permissions and roles. use iroha::data_model::prelude::*; -use iroha_executor_data_model::permission::asset_definition::CanRegisterAssetDefinition; use iroha_examples::*; +use iroha_executor_data_model::permission::asset_definition::CanRegisterAssetDefinition; use iroha_executor_data_model::permission::domain::*; fn main() -> Result<()> { let chess = Chess::id(); let bob_in_chess = BobInChess::id(); - + // define a role for managing chess let chess_manager: RoleId = "CHESS_MANAGER".parse()?; - let new_chess_manager = Role::new(chess_manager.clone(), bob_in_chess.clone()) - .add_permission(CanModifyDomainMetadata { + let new_chess_manager = Role::new(chess_manager.clone(), bob_in_chess.clone()).add_permission( + CanModifyDomainMetadata { domain: chess.clone(), - }); + }, + ); // grant the role to bob@chess let as_alice_in_wland = AliceInWonderland::client(); diff --git a/Rust/examples/status.rs b/Rust/examples/status.rs index 5e3db23..e320aa4 100644 --- a/Rust/examples/status.rs +++ b/Rust/examples/status.rs @@ -16,4 +16,4 @@ fn main() -> iroha_examples::Result<()> { // queue_size: 0, // } Ok(()) -} \ No newline at end of file +} diff --git a/Rust/examples/transaction.rs b/Rust/examples/transaction.rs index 5b0a0b6..aa1fcf6 100644 --- a/Rust/examples/transaction.rs +++ b/Rust/examples/transaction.rs @@ -18,14 +18,14 @@ fn main() -> iroha_examples::Result<()> { // on behalf of the account configured with the client let as_alice_in_wland = AliceInWonderland::client(); let signed_tx = as_alice_in_wland.build_transaction(instructions, Metadata::default()); - + let _tx_hash_1 = as_alice_in_wland.submit_transaction(&signed_tx)?; - + // Transaction 1 may or may not have been committed or rejected. // If you want synchronous behavior, use the _blocking variant: - + let _tx_hash_2 = as_alice_in_wland.submit_transaction_blocking(&signed_tx)?; - + // If this line has been reached, Transaction 2 has been committed. Ok(()) } diff --git a/Rust/src/lib.rs b/Rust/src/lib.rs index bfb3d92..64d2a60 100644 --- a/Rust/src/lib.rs +++ b/Rust/src/lib.rs @@ -323,4 +323,4 @@ pub type PawnsOfAliceInChess = ExampleAsset; /// `pawn##bob@chess` is defined in the `asset_numeric` example. pub type PawnsOfBobInChess = ExampleAsset; /// `book##bob@chess` is defined in the `asset_store` example. -pub type BookOfBobInChess = ExampleAsset; \ No newline at end of file +pub type BookOfBobInChess = ExampleAsset;