Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[refactor]: Export iroha_crypto through iroha_client #4149

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion Cargo.lock

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

3 changes: 1 addition & 2 deletions client/benches/torii.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,9 @@ use criterion::{criterion_group, criterion_main, Criterion, Throughput};
use iroha::samples::{construct_executor, get_config};
use iroha_client::{
client::{asset, Client},
crypto::KeyPair,
data_model::prelude::*,
};
use iroha_crypto::KeyPair;
use iroha_data_model::isi::InstructionBox;
use iroha_genesis::{GenesisNetwork, RawGenesisBlockBuilder};
use iroha_primitives::unique_vec;
use iroha_version::Encode;
Expand Down
3 changes: 2 additions & 1 deletion client/benches/tps/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,8 @@ impl MeasurerUnit {

/// Submit initial transactions for measurement
fn ready(self) -> Result<Self> {
let keypair = iroha_crypto::KeyPair::generate().expect("Failed to generate KeyPair.");
let keypair =
iroha_client::crypto::KeyPair::generate().expect("Failed to generate KeyPair.");

let account_id = account_id(self.name);
let asset_id = asset_id(self.name);
Expand Down
2 changes: 1 addition & 1 deletion client/examples/tutorial.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,12 +114,12 @@ fn account_registration_test(config: &Configuration) -> Result<(), Error> {
// #region register_account_crates
use iroha_client::{
client::Client,
crypto::KeyPair,
data_model::{
metadata::UnlimitedMetadata,
prelude::{Account, AccountId, InstructionBox, Register},
},
};
use iroha_crypto::KeyPair;
// #endregion register_account_crates

// Create an Iroha client
Expand Down
18 changes: 9 additions & 9 deletions client/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ use eyre::{eyre, Result, WrapErr};
use futures_util::StreamExt;
use http_default::{AsyncWebSocketStream, WebSocketStream};
use iroha_config::{client::Configuration, client_api::ConfigurationDTO, torii::uri};
use iroha_crypto::{HashOf, KeyPair};
use iroha_logger::prelude::*;
use iroha_telemetry::metrics::Status;
use iroha_version::prelude::*;
Expand All @@ -24,6 +23,7 @@ use url::Url;

use self::{blocks_api::AsyncBlockStream, events_api::AsyncEventStream};
use crate::{
crypto::{HashOf, KeyPair},
data_model::{
block::SignedBlock,
isi::Instruction,
Expand Down Expand Up @@ -69,24 +69,24 @@ pub trait Sign {
/// Fails if signature creation fails
fn sign(
self,
key_pair: iroha_crypto::KeyPair,
) -> Result<SignedTransaction, iroha_crypto::error::Error>;
key_pair: crate::crypto::KeyPair,
) -> Result<SignedTransaction, crate::crypto::error::Error>;
}

impl Sign for TransactionBuilder {
fn sign(
self,
key_pair: iroha_crypto::KeyPair,
) -> Result<SignedTransaction, iroha_crypto::error::Error> {
key_pair: crate::crypto::KeyPair,
) -> Result<SignedTransaction, crate::crypto::error::Error> {
self.sign(key_pair)
}
}

impl Sign for SignedTransaction {
fn sign(
self,
key_pair: iroha_crypto::KeyPair,
) -> Result<SignedTransaction, iroha_crypto::error::Error> {
key_pair: crate::crypto::KeyPair,
) -> Result<SignedTransaction, crate::crypto::error::Error> {
self.sign(key_pair)
}
}
Expand Down Expand Up @@ -1699,8 +1699,8 @@ mod tests {
.parse()
.expect("Public key not in mulithash format"),
),
private_key: Some(iroha_crypto::PrivateKey::from_hex(
iroha_crypto::Algorithm::Ed25519,
private_key: Some(crate::crypto::PrivateKey::from_hex(
crate::crypto::Algorithm::Ed25519,
"9AC47ABF59B356E0BD7DCBBBB4DEC080E302156A48CA907E47CB6AEA1D32719E7233BFC89DCBD68C19FDE6CE6158225298EC1131B6A130D1AEB454C1AB5183C0"
).expect("Private key not hex encoded")),
account_id: Some(
Expand Down
4 changes: 3 additions & 1 deletion client/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ pub mod samples {
client::{Configuration, ConfigurationProxy},
torii::uri::DEFAULT_API_ADDR,
};
use iroha_crypto::KeyPair;

use crate::crypto::KeyPair;

/// Get sample client configuration.
pub fn get_client_config(key_pair: &KeyPair) -> Configuration {
Expand All @@ -38,4 +39,5 @@ pub mod samples {
}
}

pub use iroha_crypto as crypto;
pub use iroha_data_model as data_model;
3 changes: 1 addition & 2 deletions client/tests/integration/asset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@ use std::{str::FromStr as _, thread};
use eyre::Result;
use iroha_client::{
client::{self, QueryResult},
crypto::{KeyPair, PublicKey},
data_model::prelude::*,
};
use iroha_crypto::{KeyPair, PublicKey};
use iroha_data_model::isi::InstructionBox;
use iroha_primitives::fixed::Fixed;
use serde_json::json;
use test_network::*;
Expand Down
3 changes: 1 addition & 2 deletions client/tests/integration/asset_propagation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@ use std::{str::FromStr as _, thread};
use eyre::Result;
use iroha_client::{
client::{self, QueryResult},
crypto::KeyPair,
data_model::{
parameter::{default::MAX_TRANSACTIONS_IN_BLOCK, ParametersBuilder},
prelude::*,
},
};
use iroha_crypto::KeyPair;
use iroha_data_model::isi::InstructionBox;
use test_network::*;

use super::Configuration;
Expand Down
2 changes: 1 addition & 1 deletion client/tests/integration/burn_public_keys.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use iroha_client::{
client::{account, transaction, Client},
crypto::{HashOf, KeyPair, PublicKey},
data_model::{isi::Instruction, prelude::*, transaction::TransactionPayload},
};
use iroha_crypto::{HashOf, KeyPair, PublicKey};
use test_network::*;

fn submit(
Expand Down
6 changes: 4 additions & 2 deletions client/tests/integration/domain_owner.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
use eyre::Result;
use iroha_client::data_model::{account::SignatureCheckCondition, prelude::*};
use iroha_crypto::KeyPair;
use iroha_client::{
crypto::KeyPair,
data_model::{account::SignatureCheckCondition, prelude::*},
};
use serde_json::json;
use test_network::*;

Expand Down
12 changes: 7 additions & 5 deletions client/tests/integration/events/pipeline.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
use std::thread::{self, JoinHandle};

use eyre::Result;
use iroha_client::data_model::{
parameter::{default::MAX_TRANSACTIONS_IN_BLOCK, ParametersBuilder},
prelude::*,
use iroha_client::{
crypto::HashOf,
data_model::{
parameter::{default::MAX_TRANSACTIONS_IN_BLOCK, ParametersBuilder},
prelude::*,
},
};
use iroha_crypto::HashOf;
use test_network::*;

use super::Configuration;
Expand Down Expand Up @@ -75,7 +77,7 @@ fn test_with_instruction_and_status_and_port(
#[derive(Clone)]
struct Checker {
listener: iroha_client::client::Client,
hash: iroha_crypto::HashOf<TransactionPayload>,
hash: HashOf<TransactionPayload>,
}

impl Checker {
Expand Down
3 changes: 1 addition & 2 deletions client/tests/integration/multiple_blocks_created.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@ use std::thread;
use eyre::Result;
use iroha_client::{
client::{self, Client, QueryResult},
crypto::KeyPair,
data_model::{
parameter::{default::MAX_TRANSACTIONS_IN_BLOCK, ParametersBuilder},
prelude::*,
},
};
use iroha_crypto::KeyPair;
use iroha_data_model::isi::InstructionBox;
use test_network::*;

use super::Configuration;
Expand Down
2 changes: 1 addition & 1 deletion client/tests/integration/multisignature_account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ use std::thread;
use eyre::Result;
use iroha_client::{
client::{self, Client, QueryResult},
crypto::KeyPair,
data_model::prelude::*,
};
use iroha_crypto::KeyPair;
use test_network::*;

use super::Configuration;
Expand Down
2 changes: 1 addition & 1 deletion client/tests/integration/multisignature_transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ use std::{str::FromStr as _, thread, time::Duration};
use eyre::Result;
use iroha_client::{
client::{self, Client, QueryResult},
crypto::KeyPair,
data_model::{
parameter::{default::MAX_TRANSACTIONS_IN_BLOCK, ParametersBuilder},
prelude::*,
},
};
use iroha_config::client::Configuration as ClientConfiguration;
use iroha_crypto::KeyPair;
use test_network::*;

use super::Configuration;
Expand Down
9 changes: 5 additions & 4 deletions client/tests/integration/permissions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use std::{str::FromStr as _, thread, time::Duration};
use eyre::Result;
use iroha_client::{
client::{self, Client, QueryResult},
crypto::KeyPair,
data_model::prelude::*,
};
use iroha_genesis::GenesisNetwork;
Expand Down Expand Up @@ -80,7 +81,7 @@ fn permissions_disallow_asset_transfer() {
let asset_definition_id: AssetDefinitionId = "xor#wonderland".parse().expect("Valid");
let create_asset =
Register::asset_definition(AssetDefinition::quantity(asset_definition_id.clone()));
let mouse_keypair = iroha_crypto::KeyPair::generate().expect("Failed to generate KeyPair.");
let mouse_keypair = KeyPair::generate().expect("Failed to generate KeyPair.");

let alice_start_assets = get_assets(&iroha_client, &alice_id);
iroha_client
Expand Down Expand Up @@ -134,7 +135,7 @@ fn permissions_disallow_asset_burn() {
let asset_definition_id = AssetDefinitionId::from_str("xor#wonderland").expect("Valid");
let create_asset =
Register::asset_definition(AssetDefinition::quantity(asset_definition_id.clone()));
let mouse_keypair = iroha_crypto::KeyPair::generate().expect("Failed to generate KeyPair.");
let mouse_keypair = KeyPair::generate().expect("Failed to generate KeyPair.");

let alice_start_assets = get_assets(&iroha_client, &alice_id);

Expand Down Expand Up @@ -204,7 +205,7 @@ fn permissions_differ_not_only_by_names() {

let alice_id: AccountId = "alice@wonderland".parse().expect("Valid");
let mouse_id: AccountId = "mouse@wonderland".parse().expect("Valid");
let mouse_keypair = iroha_crypto::KeyPair::generate().expect("Failed to generate KeyPair.");
let mouse_keypair = KeyPair::generate().expect("Failed to generate KeyPair.");

// Registering `Store` asset definitions
let hat_definition_id: AssetDefinitionId = "hat#wonderland".parse().expect("Valid");
Expand Down Expand Up @@ -300,7 +301,7 @@ fn stored_vs_granted_token_payload() -> Result<()> {
let create_asset =
Register::asset_definition(AssetDefinition::store(asset_definition_id.clone()));
let mouse_id: AccountId = "mouse@wonderland".parse().expect("Valid");
let mouse_keypair = iroha_crypto::KeyPair::generate().expect("Failed to generate KeyPair.");
let mouse_keypair = KeyPair::generate().expect("Failed to generate KeyPair.");
let new_mouse_account = Account::new(mouse_id.clone(), [mouse_keypair.public_key().clone()]);
let instructions: [InstructionBox; 2] = [
Register::account(new_mouse_account).into(),
Expand Down
4 changes: 2 additions & 2 deletions client/tests/integration/queries/asset.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
use eyre::Result;
use iroha_client::{
client::{Client, ClientQueryError},
crypto::KeyPair,
data_model::{
asset::AssetValue,
isi::Instruction,
prelude::*,
query::{asset::FindTotalAssetQuantityByAssetDefinitionId, error::QueryExecutionFail},
},
};
use iroha_crypto::KeyPair;
use iroha_data_model::isi::Instruction;
use iroha_primitives::fixed::Fixed;
use test_network::*;

Expand Down
3 changes: 2 additions & 1 deletion client/tests/integration/roles.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use std::str::FromStr as _;
use eyre::Result;
use iroha_client::{
client::{self, QueryResult},
crypto::KeyPair,
data_model::prelude::*,
};
use serde_json::json;
Expand Down Expand Up @@ -52,7 +53,7 @@ fn register_and_grant_role_for_metadata_access() -> Result<()> {
let mouse_id = AccountId::from_str("mouse@wonderland")?;

// Registering Mouse
let mouse_key_pair = iroha_crypto::KeyPair::generate()?;
let mouse_key_pair = KeyPair::generate()?;
let register_mouse = Register::account(Account::new(
mouse_id.clone(),
[mouse_key_pair.public_key().clone()],
Expand Down
5 changes: 2 additions & 3 deletions client/tests/integration/transfer_asset.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
use iroha_client::{
client::{self, QueryResult},
data_model::{prelude::*, Registered},
crypto::KeyPair,
data_model::{isi::Instruction, prelude::*, Registered},
};
use iroha_crypto::KeyPair;
use iroha_data_model::isi::Instruction;
use iroha_primitives::fixed::Fixed;
use test_network::*;

Expand Down
2 changes: 1 addition & 1 deletion client/tests/integration/unregister_peer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ use std::thread;
use eyre::Result;
use iroha_client::{
client::{self, QueryResult},
crypto::KeyPair,
data_model::{
parameter::{default::MAX_TRANSACTIONS_IN_BLOCK, ParametersBuilder},
prelude::*,
},
};
use iroha_crypto::KeyPair;
use test_network::*;

use super::Configuration;
Expand Down
2 changes: 1 addition & 1 deletion client/tests/integration/upgrade.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ use std::{path::Path, str::FromStr as _};
use eyre::Result;
use iroha_client::{
client::{self, Client, QueryResult},
crypto::KeyPair,
data_model::prelude::*,
};
use iroha_crypto::KeyPair;
use iroha_logger::info;
use serde_json::json;
use test_network::*;
Expand Down
1 change: 0 additions & 1 deletion client_cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ maintenance = { status = "actively-developed" }
[dependencies]
iroha_client = { workspace = true }
iroha_primitives = { workspace = true }
iroha_crypto = { workspace = true }
iroha_config = { workspace = true }

color-eyre = { workspace = true }
Expand Down
6 changes: 5 additions & 1 deletion smart_contract/executor/derive/src/validate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,11 @@ impl FromAttributes for ValidateAttribute {
continue;
}

let Some(list) = accumulator.handle(attr.meta.require_list().map_err(darling::Error::from)) else { continue; };
let Some(list) =
accumulator.handle(attr.meta.require_list().map_err(darling::Error::from))
else {
continue;
};
let tokens = &list.tokens;

if path.is_ident("validate") {
Expand Down
Loading