Skip to content

Commit

Permalink
rusk-wallet: reorder imports to align with convention
Browse files Browse the repository at this point in the history
  • Loading branch information
Neotamandua committed Nov 25, 2024
1 parent 245bedb commit 413b934
Show file tree
Hide file tree
Showing 20 changed files with 128 additions and 158 deletions.
24 changes: 11 additions & 13 deletions rusk-wallet/src/bin/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,27 +8,25 @@ mod history;

pub use history::TransactionHistory;

use std::fmt;
use std::path::PathBuf;

use clap::Subcommand;
use execution_core::{
stake::StakeData, transfer::data::ContractCall, BlsScalar,
CONTRACT_ID_BYTES,
};
use rusk_wallet::{
currency::{Dusk, Lux},
gas::{
Gas, DEFAULT_LIMIT_CALL, DEFAULT_LIMIT_DEPLOYMENT,
DEFAULT_LIMIT_TRANSFER, DEFAULT_PRICE, MIN_PRICE_DEPLOYMENT,
},
Address, Error, Profile, Wallet, EPOCH, MAX_PROFILES,
use execution_core::stake::StakeData;
use execution_core::transfer::data::ContractCall;
use execution_core::{BlsScalar, CONTRACT_ID_BYTES};
use rusk_wallet::currency::{Dusk, Lux};
use rusk_wallet::gas::{
Gas, DEFAULT_LIMIT_CALL, DEFAULT_LIMIT_DEPLOYMENT, DEFAULT_LIMIT_TRANSFER,
DEFAULT_PRICE, MIN_PRICE_DEPLOYMENT,
};
use rusk_wallet::{Address, Error, Profile, Wallet, EPOCH, MAX_PROFILES};
use wallet_core::BalanceInfo;

use crate::io::prompt;
use crate::settings::Settings;
use crate::{WalletFile, WalletPath};

use std::{fmt, path::PathBuf};

/// Commands that can be run against the Dusk wallet
#[allow(clippy::large_enum_variant)]
#[derive(PartialEq, Eq, Hash, Clone, Subcommand, Debug)]
Expand Down
4 changes: 2 additions & 2 deletions rusk-wallet/src/bin/command/history.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ use std::collections::hash_map::Entry;
use std::collections::HashMap;
use std::fmt::{self, Display};

use execution_core::transfer::Transaction;
use execution_core::{dusk, from_dusk};
use rusk_wallet::{BlockTransaction, DecodedNote, GraphQL};

use execution_core::{dusk, from_dusk, transfer::Transaction};

use crate::io::{self};
use crate::settings::Settings;

Expand Down
3 changes: 2 additions & 1 deletion rusk-wallet/src/bin/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@
//
// Copyright (c) DUSK NETWORK. All rights reserved.

use serde::Deserialize;
use std::collections::HashMap;
use std::path::Path;

use serde::Deserialize;
use url::Url;

use crate::Error;
Expand Down
17 changes: 6 additions & 11 deletions rusk-wallet/src/bin/interactive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,13 @@ use std::fmt::Display;

use bip39::{Language, Mnemonic, MnemonicType};
use inquire::{InquireError, Select};
use rusk_wallet::currency::Dusk;
use rusk_wallet::dat::{DatFileVersion, LATEST_VERSION};
use rusk_wallet::{Address, Error, Profile, Wallet, WalletPath, MAX_PROFILES};

use rusk_wallet::{
currency::Dusk,
dat::{DatFileVersion, LATEST_VERSION},
Address, Error, Profile, Wallet, WalletPath, MAX_PROFILES,
};

use crate::{
io::{self, prompt},
settings::Settings,
Command, GraphQL, RunResult, WalletFile,
};
use crate::io::{self, prompt};
use crate::settings::Settings;
use crate::{Command, GraphQL, RunResult, WalletFile};

/// Run the interactive UX loop with a loaded wallet
pub(crate) async fn run_loop(
Expand Down
16 changes: 7 additions & 9 deletions rusk-wallet/src/bin/interactive/command_menu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,16 @@ use std::fmt::Display;

use execution_core::transfer::data::MAX_MEMO_SIZE;
use inquire::{InquireError, Select};
use rusk_wallet::{
currency::Dusk,
gas::{
self, DEFAULT_LIMIT_CALL, DEFAULT_LIMIT_STAKE, DEFAULT_LIMIT_TRANSFER,
DEFAULT_PRICE, GAS_PER_DEPLOY_BYTE, MIN_PRICE_DEPLOYMENT,
},
Address, Wallet, MAX_FUNCTION_NAME_SIZE,
use rusk_wallet::currency::Dusk;
use rusk_wallet::gas::{
self, DEFAULT_LIMIT_CALL, DEFAULT_LIMIT_STAKE, DEFAULT_LIMIT_TRANSFER,
DEFAULT_PRICE, GAS_PER_DEPLOY_BYTE, MIN_PRICE_DEPLOYMENT,
};

use crate::{prompt, settings::Settings, Command, WalletFile};
use rusk_wallet::{Address, Wallet, MAX_FUNCTION_NAME_SIZE};

use super::ProfileOp;
use crate::settings::Settings;
use crate::{prompt, Command, WalletFile};

/// The command-menu items
#[derive(PartialEq, Eq, Hash, Clone, Debug)]
Expand Down
6 changes: 4 additions & 2 deletions rusk-wallet/src/bin/io/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@
//
// Copyright (c) DUSK NETWORK. All rights reserved.

use std::path::PathBuf;

use clap::{arg, Parser};

use crate::settings::{LogFormat, LogLevel};
use crate::Command;
use clap::{arg, Parser};
use std::path::PathBuf;

#[derive(Parser, Debug)]
#[command(
Expand Down
21 changes: 8 additions & 13 deletions rusk-wallet/src/bin/io/prompt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,31 +5,26 @@
// Copyright (c) DUSK NETWORK. All rights reserved.

use std::fmt::Display;
use std::io::stdout;
use std::path::PathBuf;
use std::println;
use std::str::FromStr;
use std::{io::stdout, println};

use crossterm::{
cursor::{Hide, Show},
ExecutableCommand,
};

use anyhow::Result;
use bip39::{ErrorKind, Language, Mnemonic};
use crossterm::cursor::{Hide, Show};
use crossterm::ExecutableCommand;
use execution_core::stake::MINIMUM_STAKE;

use inquire::ui::RenderConfig;
use inquire::validator::Validation;
use inquire::{
Confirm, CustomType, InquireError, Password, PasswordDisplayMode, Select,
Text,
};
use rusk_wallet::{
currency::{Dusk, Lux},
dat::DatFileVersion,
gas::{self, MempoolGasPrices},
Address, Error, MAX_CONVERTIBLE, MIN_CONVERTIBLE,
};
use rusk_wallet::currency::{Dusk, Lux};
use rusk_wallet::dat::DatFileVersion;
use rusk_wallet::gas::{self, MempoolGasPrices};
use rusk_wallet::{Address, Error, MAX_CONVERTIBLE, MIN_CONVERTIBLE};
use sha2::{Digest, Sha256};

pub(crate) fn ask_pwd(msg: &str) -> Result<String, InquireError> {
Expand Down
17 changes: 8 additions & 9 deletions rusk-wallet/src/bin/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,27 +12,26 @@ mod settings;

pub(crate) use command::{Command, RunResult};

use std::fs::{self, File};
use std::io::Write;

use bip39::{Language, Mnemonic, MnemonicType};
use clap::Parser;
use inquire::InquireError;
use rocksdb::ErrorKind;
use rusk_wallet::currency::Dusk;
use rusk_wallet::dat::{self, LATEST_VERSION};
use rusk_wallet::{
Error, GraphQL, Profile, SecureWalletFile, Wallet, WalletPath, EPOCH,
};
use tracing::{error, info, warn, Level};

use crate::command::TransactionHistory;
use crate::settings::{LogFormat, Settings};

use rusk_wallet::{
currency::Dusk,
dat::{self, LATEST_VERSION},
Error, GraphQL, Profile, SecureWalletFile, Wallet, WalletPath, EPOCH,
};

use config::Config;
use io::{prompt, status, WalletArgs};

use std::fs::{self, File};
use std::io::Write;

#[derive(Debug, Clone)]
pub(crate) struct WalletFile {
path: WalletPath,
Expand Down
8 changes: 4 additions & 4 deletions rusk-wallet/src/bin/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@
//
// Copyright (c) DUSK NETWORK. All rights reserved.

use crate::config::Network;
use crate::io::WalletArgs;

use rusk_wallet::{Error, RuesHttpClient};
use std::fmt;
use std::path::PathBuf;

use rusk_wallet::{Error, RuesHttpClient};
use tracing::Level;
use url::Url;

use crate::config::Network;
use crate::io::WalletArgs;

#[derive(clap::ValueEnum, Debug, Clone)]
pub(crate) enum LogFormat {
Json,
Expand Down
4 changes: 2 additions & 2 deletions rusk-wallet/src/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ use execution_core::transfer::phoenix::NoteLeaf;
use rocksdb::{DBWithThreadMode, MultiThreaded, Options};

use super::*;

use crate::{clients::TREE_LEAF, error::Error};
use crate::clients::TREE_LEAF;
use crate::error::Error;

type DB = DBWithThreadMode<MultiThreaded>;

Expand Down
42 changes: 17 additions & 25 deletions rusk-wallet/src/clients.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,38 +6,30 @@

mod sync;

use std::path::Path;
use std::sync::{Arc, Mutex};

use dusk_bytes::Serializable;
use execution_core::{
signatures::bls::PublicKey as BlsPublicKey,
transfer::{
moonlight::AccountData,
phoenix::{Note, NoteLeaf, Prove},
Transaction,
},
Error as ExecutionCoreError,
};
use execution_core::signatures::bls::PublicKey as BlsPublicKey;
use execution_core::transfer::moonlight::AccountData;
use execution_core::transfer::phoenix::{Note, NoteLeaf, Prove};
use execution_core::transfer::Transaction;
use execution_core::Error as ExecutionCoreError;
use flume::Receiver;
use rues::RuesHttpClient;
use tokio::{
task::JoinHandle,
time::{sleep, Duration},
};
use wallet_core::{
keys::{derive_phoenix_pk, derive_phoenix_sk, derive_phoenix_vk},
pick_notes,
use tokio::task::JoinHandle;
use tokio::time::{sleep, Duration};
use wallet_core::keys::{
derive_phoenix_pk, derive_phoenix_sk, derive_phoenix_vk,
};
use wallet_core::pick_notes;
use zeroize::Zeroize;

use std::{
path::Path,
sync::{Arc, Mutex},
};

use self::sync::sync_db;

use super::{cache::Cache, *};

use crate::{store::LocalStore, Error, MAX_PROFILES};
use super::cache::Cache;
use super::*;
use crate::store::LocalStore;
use crate::{Error, MAX_PROFILES};

const TRANSFER_CONTRACT: &str =
"0100000000000000000000000000000000000000000000000000000000000000";
Expand Down
3 changes: 1 addition & 2 deletions rusk-wallet/src/clients/sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,10 @@
use futures::StreamExt;
use rues::CONTRACTS_TARGET;

use super::*;
use crate::clients::{Cache, TRANSFER_CONTRACT};
use crate::Error;

use super::*;

pub(crate) async fn sync_db(
client: &RuesHttpClient,
cache: &Cache,
Expand Down
3 changes: 1 addition & 2 deletions rusk-wallet/src/dat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ use std::io::Read;
use wallet_core::Seed;

use crate::crypto::decrypt;
use crate::Error;
use crate::WalletPath;
use crate::{Error, WalletPath};

/// Binary prefix for old Dusk wallet files
pub const OLD_MAGIC: u32 = 0x1d0c15;
Expand Down
5 changes: 3 additions & 2 deletions rusk-wallet/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@
//
// Copyright (c) DUSK NETWORK. All rights reserved.

use inquire::InquireError;
use rand::Error as RngError;
use std::io;
use std::str::Utf8Error;

use inquire::InquireError;
use rand::Error as RngError;

use crate::gql::GraphQLError;

/// Errors returned by this library
Expand Down
2 changes: 1 addition & 1 deletion rusk-wallet/src/gql.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
//! graphql schema
use execution_core::transfer::Transaction;
use serde::Deserialize;
use tokio::time::{sleep, Duration};

use crate::{Error, RuesHttpClient};
use serde::Deserialize;

/// GraphQL is a helper struct that aggregates all queries done
/// to the Dusk GraphQL database.
Expand Down
19 changes: 7 additions & 12 deletions rusk-wallet/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,24 +27,19 @@ pub mod currency;
pub mod dat;
pub mod gas;

pub use rues::RuesHttpClient;

pub use error::Error;
pub use gql::{BlockTransaction, GraphQL};
pub use rues::RuesHttpClient;
pub use wallet::{
Address, DecodedNote, Profile, SecureWalletFile, Wallet, WalletPath,
};

pub use gql::{BlockTransaction, GraphQL};

use execution_core::{
dusk, from_dusk,
stake::StakeData,
transfer::phoenix::{
ArchivedNoteLeaf, Note, NoteOpening, PublicKey as PhoenixPublicKey,
SecretKey as PhoenixSecretKey, ViewKey as PhoenixViewKey,
},
BlsScalar,
use execution_core::stake::StakeData;
use execution_core::transfer::phoenix::{
ArchivedNoteLeaf, Note, NoteOpening, PublicKey as PhoenixPublicKey,
SecretKey as PhoenixSecretKey, ViewKey as PhoenixViewKey,
};
use execution_core::{dusk, from_dusk, BlsScalar};

use currency::Dusk;

Expand Down
4 changes: 2 additions & 2 deletions rusk-wallet/src/store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
//
// Copyright (c) DUSK NETWORK. All rights reserved.

use crate::clients::State;

use wallet_core::Seed;

use crate::clients::State;

/// Provides a valid wallet seed to dusk_wallet_core
#[derive(Clone)]
pub(crate) struct LocalStore {
Expand Down
Loading

0 comments on commit 413b934

Please sign in to comment.