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

Remove excess features #1278

Merged
merged 4 commits into from
Sep 21, 2023
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: 1 addition & 0 deletions Cargo.lock

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

3 changes: 3 additions & 0 deletions bindings/core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ serde = { version = "1.0.188", default-features = false }
serde_json = { version = "1.0.107", default-features = false }
thiserror = { version = "1.0.48", default-features = false }
tokio = { version = "1.32.0", default-features = false }
url = { version = "2.4.1", default-features = false, features = [
"serde",
] }
zeroize = { version = "1.6.0", default-features = false }

[features]
Expand Down
2 changes: 1 addition & 1 deletion bindings/core/src/method/wallet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ use iota_sdk::{
},
ClientOptions,
},
Url,
};
use serde::{Deserialize, Serialize};
use url::Url;

use crate::method::account::AccountMethod;
#[cfg(feature = "stronghold")]
Expand Down
39 changes: 19 additions & 20 deletions sdk/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -138,20 +138,19 @@ tokio = { version = "1.32.0", default-features = false, features = [
[features]
default = ["client", "wallet", "tls"]

irc_27 = ["url", "serde"]
irc_30 = ["url", "serde"]
ledger_nano = ["iota-ledger-nano"]
mqtt = ["std", "regex", "rumqttc", "dep:once_cell"]
irc_27 = ["serde", "dep:url"]
irc_30 = ["serde", "dep:url"]
ledger_nano = ["dep:iota-ledger-nano"]
mqtt = ["std", "tls", "dep:regex", "dep:rumqttc", "dep:once_cell"]
participation = ["storage"]
rand = ["dep:rand"]
rocksdb = ["dep:rocksdb", "storage"]
rocksdb = ["storage", "dep:rocksdb"]
serde = [
"serde_repr",
"hashbrown/serde",
"packable/serde",
"primitive-types/serde_no_std",
"iota-crypto/serde",
"zeroize?/serde",
thibault-martinez marked this conversation as resolved.
Show resolved Hide resolved
"dep:serde_repr",
]
std = [
"packable/std",
Expand All @@ -167,34 +166,34 @@ std = [
]
storage = ["iota-crypto/chacha", "dep:time", "dep:anymap", "dep:once_cell"]
stronghold = [
"iota_stronghold",
"iota-crypto/chacha",
"dep:iota_stronghold",
"dep:time",
"dep:anymap",
"dep:once_cell",
]
tls = ["reqwest?/rustls-tls", "rumqttc?/use-rustls"]
events = []
private_key_secret_manager = ["bs58"]
private_key_secret_manager = ["dep:bs58"]

client = [
"async-trait",
"futures",
"instant",
"std",
"serde",
"iota-crypto/bip39",
"iota-crypto/bip39-en",
"iota-crypto/bip44",
"iota-crypto/keccak",
"iota-crypto/random",
"iota-crypto/slip10",
"log",
"reqwest",
"serde",
"std",
"thiserror",
"tokio",
"url",
"zeroize",
"dep:async-trait",
"dep:futures",
"dep:instant",
"dep:log",
"dep:reqwest",
"dep:thiserror",
"dep:tokio",
"dep:url",
"dep:zeroize",
]
wallet = ["client"]

Expand Down
3 changes: 2 additions & 1 deletion sdk/examples/wallet/participation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@
use iota_sdk::{
client::node_manager::node::Node,
wallet::{account::types::participation::ParticipationEventRegistrationOptions, Result},
Url, Wallet,
Wallet,
};
use url::Url;

// The node that runs the participation plugin
const PARTICPATION_NODE_URL: &str = "https://api.testnet.shimmer.network";
Expand Down
3 changes: 1 addition & 2 deletions sdk/src/client/api/high_level.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use crate::{
constants::FIVE_MINUTES_IN_SECONDS,
error::{Error, Result},
node_api::indexer::query_parameters::QueryParameter,
Client,
unix_timestamp_now, Client,
},
types::block::{
address::Bech32Address,
Expand All @@ -22,7 +22,6 @@ use crate::{
slot::SlotIndex,
BlockId,
},
utils::unix_timestamp_now,
};

impl Client {
Expand Down
2 changes: 1 addition & 1 deletion sdk/src/client/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ impl ClientInner {
// request the node info every time, so we don't create invalid transactions/blocks.
#[cfg(target_family = "wasm")]
{
let current_time = crate::utils::unix_timestamp_now().as_secs() as u32;
let current_time = crate::client::unix_timestamp_now().as_secs() as u32;
if let Some(last_sync) = *self.last_sync.lock().await {
if current_time < last_sync {
return Ok(self.network_info.read().await.clone());
Expand Down
3 changes: 1 addition & 2 deletions sdk/src/client/node_manager/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
use std::hash::Hash;

use serde::{Deserialize, Serialize};

use crate::Url;
use url::Url;

/// Node authentication object.
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, Hash)]
Expand Down
6 changes: 6 additions & 0 deletions sdk/src/client/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -197,3 +197,9 @@ impl Password {
self.0.as_bytes()
}
}

pub fn unix_timestamp_now() -> core::time::Duration {
instant::SystemTime::now()
.duration_since(instant::SystemTime::UNIX_EPOCH)
.expect("time went backwards")
}
2 changes: 0 additions & 2 deletions sdk/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ pub mod utils;
pub use crypto;
pub use packable;
pub use primitive_types::U256;
#[cfg(feature = "url")]
pub use url::Url;

#[cfg(feature = "wallet")]
pub type Wallet = self::wallet::Wallet<client::secret::SecretManager>;
7 changes: 0 additions & 7 deletions sdk/src/utils/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,3 @@

#[cfg(feature = "serde")]
pub mod serde;

#[cfg(feature = "instant")]
pub fn unix_timestamp_now() -> core::time::Duration {
instant::SystemTime::now()
.duration_since(instant::SystemTime::UNIX_EPOCH)
.expect("time went backwards")
}
4 changes: 2 additions & 2 deletions sdk/src/wallet/account/operations/syncing/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ where
let syc_start_time = instant::Instant::now();

// Prevent syncing the account multiple times simultaneously
let time_now = crate::utils::unix_timestamp_now().as_millis();
let time_now = crate::client::unix_timestamp_now().as_millis();
let mut last_synced = self.last_synced.lock().await;
log::debug!("[SYNC] last time synced before {}ms", time_now - *last_synced);
if !options.force_syncing && time_now - *last_synced < MIN_SYNC_INTERVAL {
Expand Down Expand Up @@ -86,7 +86,7 @@ where

let balance = self.balance().await?;
// Update last_synced mutex
let time_now = crate::utils::unix_timestamp_now().as_millis();
let time_now = crate::client::unix_timestamp_now().as_millis();
*last_synced = time_now;
log::debug!("[SYNC] finished syncing in {:.2?}", syc_start_time.elapsed());
Ok(balance)
Expand Down
3 changes: 1 addition & 2 deletions sdk/src/wallet/account/operations/syncing/transactions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@
// SPDX-License-Identifier: Apache-2.0

use crate::{
client::secret::SecretManage,
client::{secret::SecretManage, unix_timestamp_now},
types::{
api::core::response::TransactionState,
block::{input::Input, output::OutputId, BlockId},
},
utils::unix_timestamp_now,
wallet::account::{
types::{InclusionState, Transaction},
Account, AccountDetails,
Expand Down
2 changes: 1 addition & 1 deletion sdk/src/wallet/account/operations/transaction/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ where
payload: signed_transaction_data.transaction_payload,
block_id,
network_id,
timestamp: crate::utils::unix_timestamp_now().as_millis(),
timestamp: crate::client::unix_timestamp_now().as_millis(),
inclusion_state: InclusionState::Pending,
incoming: false,
note: options.and_then(|o| o.note),
Expand Down
3 changes: 2 additions & 1 deletion sdk/src/wallet/core/operations/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

use std::collections::{HashMap, HashSet};

use url::Url;

use super::storage::SaveLoadWallet;
use crate::{
client::{
Expand All @@ -14,7 +16,6 @@ use crate::{
Client, ClientBuilder,
},
wallet::{Wallet, WalletBuilder},
Url,
};

impl<S: 'static + SecretManage> Wallet<S> {
Expand Down
2 changes: 1 addition & 1 deletion sdk/tests/wallet/backup_restore.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ use iota_sdk::{
secret::{mnemonic::MnemonicSecretManager, stronghold::StrongholdSecretManager, SecretManager},
},
wallet::{ClientOptions, Result, Wallet},
Url,
};
use url::Url;

use crate::wallet::common::{setup, tear_down, NODE_LOCAL, NODE_OTHER};

Expand Down
2 changes: 1 addition & 1 deletion sdk/tests/wallet/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ use iota_sdk::{
client::constants::SHIMMER_COIN_TYPE,
client::node_manager::node::{Node, NodeDto},
wallet::Error,
Url,
};
use iota_sdk::{
client::{
Expand All @@ -17,6 +16,7 @@ use iota_sdk::{
types::block::address::Bech32Address,
wallet::{ClientOptions, Result, Wallet},
};
use url::Url;

#[cfg(feature = "storage")]
use crate::wallet::common::NODE_OTHER;
Expand Down
Loading