diff --git a/Cargo.toml b/Cargo.toml index 3af719d02..0fd54fbda 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -25,35 +25,35 @@ members = [ anyhow = "1.0" async-trait = "0.1" base64 = "0.13" -chacha20poly1305 = "0.10.0-pre.1" -curve25519-dalek-ng = "4.1.1" +chacha20poly1305 = { version = "0.10.1", optional = true } +curve25519-dalek-ng = { version = "4.1.1", optional = true } downcast-rs = "1.2" dyn-clone = "1.0" erased-serde = { version = "0.3.23", optional = true } futures-util = "0.3" -getrandom = "0.2.4" +getrandom = { version = "0.2.4", optional = true } hex = "0.4" -hmac = "0.11.0" +hmac = { version = "0.11.0", optional = true } log = "0.4" lru = "0.8.0" num-bigint = "0.4" once_cell = "1.12.0" parking_lot = "0.12.0" -pbkdf2 = "0.9.0" +pbkdf2 = { version = "0.9.0", optional = true } quick_cache = "0.3.0" -rand = { version = "0.8", features = ["getrandom"] } -secstr = { version = "0.5.0", features = ["serde"] } +rand = { version = "0.8", features = ["getrandom"] , optional = true } +secstr = { version = "0.5.0", features = ["serde"], optional = true } serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" -sha2 = "0.9.9" +sha2 = { version = "0.9.9", optional = true } thiserror = "1.0" tiny-jsonrpc = { version = "0.6.0", default-features = false, optional = true } tokio = { version = "1", default-features = false, features = ["sync"] } -zeroize = "1" +zeroize = { version = "1", optional = true } -ed25519-dalek = { git = "https://github.com/broxus/ed25519-dalek.git" } -tiny-bip39 = { git = "https://github.com/broxus/tiny-bip39.git", default-features = false } -tiny-hderive = { git = "https://github.com/broxus/tiny-hderive.git" } +ed25519-dalek = { git = "https://github.com/broxus/ed25519-dalek.git", optional = true } +tiny-bip39 = { git = "https://github.com/broxus/tiny-bip39.git", default-features = false, optional = true } +tiny-hderive = { git = "https://github.com/broxus/tiny-hderive.git", optional = true } ton_abi = { git = "https://github.com/broxus/ton-labs-abi" } ton_block = { git = "https://github.com/broxus/ton-labs-block.git" } @@ -62,7 +62,7 @@ ton_types = { git = "https://github.com/broxus/ton-labs-types.git" } nekoton-contracts = { path = "nekoton-contracts" } nekoton-abi = { path = "nekoton-abi", features = ["derive"] } -nekoton-utils = { path = "nekoton-utils", features = ["encryption"] } +nekoton-utils = { path = "nekoton-utils" } nekoton-proto = { path = "nekoton-proto", optional = true } [dev-dependencies] @@ -71,7 +71,7 @@ cargo-husky = { version = "1", features = ["default", "run-cargo-fmt", "run-carg tokio = { version = "1", features = ["rt-multi-thread", "macros"] } [features] -default = ["gql_transport"] +default = ["gql_transport", "wallet_core"] integration_test = [] web = [ "nekoton-contracts/web", @@ -79,12 +79,15 @@ web = [ "nekoton-utils/web", "getrandom/wasm-bindgen", "ton_abi/web", + "wallet_core" ] gql_transport = ["dep:erased-serde"] jrpc_transport = ["dep:tiny-jsonrpc"] proto_transport = ["dep:nekoton-proto"] extended_models = [] non_threadsafe = [] +wallet_core = ["dep:pbkdf2", "dep:chacha20poly1305", "dep:zeroize", "dep:secstr", "dep:hmac", "dep:ed25519-dalek", + "dep:tiny-bip39", "dep:tiny-hderive", "dep:sha2", "dep:getrandom", "dep:rand", "dep:curve25519-dalek-ng", "nekoton-utils/encryption"] [package.metadata.docs.rs] all-features = true diff --git a/nekoton-abi/src/tvm.rs b/nekoton-abi/src/tvm.rs index f489e62a4..9f716c014 100644 --- a/nekoton-abi/src/tvm.rs +++ b/nekoton-abi/src/tvm.rs @@ -153,7 +153,7 @@ pub fn call_msg( .map_err(|_| ExecutionError::FailedToRetrieveActions)?; let mut msgs = Vec::new(); - for (_, action) in actions.iter_mut().enumerate() { + for action in actions.iter_mut() { if let OutAction::SendMsg { out_msg, .. } = std::mem::replace(action, OutAction::None) { msgs.push(out_msg); } diff --git a/src/core/mod.rs b/src/core/mod.rs index 3b0d54058..531fc761b 100644 --- a/src/core/mod.rs +++ b/src/core/mod.rs @@ -11,7 +11,7 @@ pub mod contract_subscription; pub mod dens; pub mod generic_contract; pub mod keystore; -pub mod models; +pub use super::models; pub mod nft_wallet; pub mod owners_cache; pub mod parsing; diff --git a/src/core/transactions_tree/mod.rs b/src/core/transactions_tree/mod.rs index e38305b70..076d2597b 100644 --- a/src/core/transactions_tree/mod.rs +++ b/src/core/transactions_tree/mod.rs @@ -71,7 +71,7 @@ impl TransactionsTreeStream { } pub fn peek(&self) -> Option<&Message> { - self.messages.get(0) + self.messages.front() } async fn step(&mut self, mut message: Message) -> TransactionTreeResult { diff --git a/src/core/utils.rs b/src/core/utils.rs index cff7986ec..9731daad7 100644 --- a/src/core/utils.rs +++ b/src/core/utils.rs @@ -13,6 +13,7 @@ use nekoton_abi::{GenTimings, LastTransactionId, TransactionId}; use nekoton_utils::*; use crate::core::models::*; +#[cfg(feature = "wallet_core")] use crate::crypto::{SignedMessage, UnsignedMessage}; use crate::transport::models::RawTransaction; use crate::transport::Transport; diff --git a/src/lib.rs b/src/lib.rs index 3d0980f4c..79cc0a304 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -50,9 +50,13 @@ rust_2018_idioms )] +#[cfg(feature = "wallet_core")] pub mod core; +#[cfg(feature = "wallet_core")] pub mod crypto; +#[cfg(feature = "wallet_core")] pub mod external; +pub mod models; pub mod transport; pub use nekoton_abi as abi; diff --git a/src/core/models.rs b/src/models.rs similarity index 99% rename from src/core/models.rs rename to src/models.rs index 286ed987a..a36817f7b 100644 --- a/src/core/models.rs +++ b/src/models.rs @@ -968,6 +968,7 @@ pub enum MessageBodyError { FailedToDeserialize, } +#[cfg(feature = "wallet_core")] #[derive(thiserror::Error, Debug)] pub(super) enum AccountSubscriptionError { #[error("Invalid message destination")] diff --git a/src/transport/mod.rs b/src/transport/mod.rs index 7e034b7fe..9fe187884 100644 --- a/src/transport/mod.rs +++ b/src/transport/mod.rs @@ -3,7 +3,7 @@ use nekoton_utils::Clock; use serde::{Deserialize, Serialize}; use ton_block::MsgAddressInt; -use crate::core::models::{NetworkCapabilities, ReliableBehavior}; +use crate::models::{NetworkCapabilities, ReliableBehavior}; use self::models::*; diff --git a/src/transport/models.rs b/src/transport/models.rs index 90b3d6eec..ff92254a8 100644 --- a/src/transport/models.rs +++ b/src/transport/models.rs @@ -4,11 +4,10 @@ use serde::{Deserialize, Serialize}; use ton_block::{Account, AccountStuff, Transaction}; use ton_types::UInt256; +use crate::models::{ContractState, PendingTransaction}; use nekoton_abi::{ExecutionContext, GenTimings, LastTransactionId}; use nekoton_utils::{serde_account_stuff, Clock}; -use crate::core::models::{ContractState, PendingTransaction}; - #[allow(clippy::large_enum_variant)] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(rename_all = "camelCase", tag = "type")]