Skip to content

Commit

Permalink
cargo fmt
Browse files Browse the repository at this point in the history
Signed-off-by: Dmitry Murzin <[email protected]>
  • Loading branch information
dima74 committed Nov 14, 2024
1 parent cd7529d commit 498363d
Show file tree
Hide file tree
Showing 9 changed files with 45 additions and 27 deletions.
10 changes: 7 additions & 3 deletions Rust/examples/account_register.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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(())
Expand Down
5 changes: 3 additions & 2 deletions Rust/examples/asset_definition_register.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion Rust/examples/asset_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<()> {
Expand Down
9 changes: 7 additions & 2 deletions Rust/examples/domain_transfer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};

Expand Down Expand Up @@ -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
Expand Down
20 changes: 12 additions & 8 deletions Rust/examples/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::<Name>()?;
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(
Expand All @@ -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(())
}
11 changes: 6 additions & 5 deletions Rust/examples/roles.rs
Original file line number Diff line number Diff line change
@@ -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();
Expand Down
2 changes: 1 addition & 1 deletion Rust/examples/status.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ fn main() -> iroha_examples::Result<()> {
// queue_size: 0,
// }
Ok(())
}
}
8 changes: 4 additions & 4 deletions Rust/examples/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(())
}
2 changes: 1 addition & 1 deletion Rust/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -323,4 +323,4 @@ pub type PawnsOfAliceInChess = ExampleAsset<ChessPawns, AliceInChess>;
/// `pawn##bob@chess` is defined in the `asset_numeric` example.
pub type PawnsOfBobInChess = ExampleAsset<ChessPawns, BobInChess>;
/// `book##bob@chess` is defined in the `asset_store` example.
pub type BookOfBobInChess = ExampleAsset<ChessBook, BobInChess>;
pub type BookOfBobInChess = ExampleAsset<ChessBook, BobInChess>;

0 comments on commit 498363d

Please sign in to comment.