diff --git a/anychain-core/Cargo.toml b/anychain-core/Cargo.toml index f0aaa80..06bf194 100644 --- a/anychain-core/Cargo.toml +++ b/anychain-core/Cargo.toml @@ -23,12 +23,6 @@ base58 = { workspace = true , optional = true } rand_core = { workspace = true } serde_json = { workspace = true } sha2 = { workspace = true } -# rand = { workspace = true } -# ethereum-types = { workspace = true } -# blake2b_simd = { workspace = true } -# libsecp256k1 = { workspace = true } -# bls-signatures = { workspace = true } -# rlp = { workspace = true } [features] default = ["std"] diff --git a/anychain-core/src/address.rs b/anychain-core/src/address.rs index 22cddc2..000fb56 100644 --- a/anychain-core/src/address.rs +++ b/anychain-core/src/address.rs @@ -1,10 +1,11 @@ -use crate::format::Format; -use crate::no_std::*; -use crate::public_key::{PublicKey, PublicKeyError}; -use core::{ - fmt::{Debug, Display}, - hash::Hash, - str::FromStr, +use crate::{ + format::Format, + no_std::{ + fmt::{Debug, Display}, + hash::Hash, + FromStr, String, + }, + public_key::{PublicKey, PublicKeyError}, }; /// The interface for a generic address. diff --git a/anychain-core/src/amount.rs b/anychain-core/src/amount.rs index 2bfbaa4..d883a29 100644 --- a/anychain-core/src/amount.rs +++ b/anychain-core/src/amount.rs @@ -1,7 +1,10 @@ -use crate::no_std::*; -use core::{ - fmt::{Debug, Display}, - hash::Hash, +use { + crate::no_std::{ + fmt::{Debug, Display}, + hash::Hash, + String, + }, + thiserror::Error, }; /// The interface for a generic amount. diff --git a/anychain-core/src/error.rs b/anychain-core/src/error.rs index 0e2bccd..5e1d444 100644 --- a/anychain-core/src/error.rs +++ b/anychain-core/src/error.rs @@ -1,8 +1,10 @@ -use crate::AddressError; -use crate::AmountError; -use crate::FormatError; -use crate::PublicKeyError; -use crate::TransactionError; +use crate::{ + no_std::{ + fmt::Error as FmtError, io::Error as IoError, num::ParseIntError as NumParseIntError, + String, + }, + AddressError, AmountError, FormatError, PublicKeyError, TransactionError, +}; #[derive(Debug, Error)] pub enum Error { @@ -25,14 +27,14 @@ pub enum Error { InvalidFormat(#[from] FormatError), #[error("io error: {0:}")] - Io(#[from] ::std::io::Error), + Io(#[from] IoError), #[error("fmt error: {0:}")] - Fmt(#[from] ::std::fmt::Error), + Fmt(#[from] FmtError), #[error("fromHex error: {0:}")] FromHex(#[from] ::hex::FromHexError), #[error("parsing error: {0:}")] - ParseInt(#[from] ::std::num::ParseIntError), + ParseInt(#[from] NumParseIntError), } diff --git a/anychain-core/src/format.rs b/anychain-core/src/format.rs index 724a457..66886a1 100644 --- a/anychain-core/src/format.rs +++ b/anychain-core/src/format.rs @@ -1,7 +1,10 @@ -use crate::no_std::*; -use core::{ - fmt::{Debug, Display}, - hash::Hash, +use { + crate::no_std::{ + fmt::{Debug, Display}, + hash::Hash, + String, Vec, + }, + thiserror::Error, }; /// The interface for a generic format. diff --git a/anychain-core/src/network.rs b/anychain-core/src/network.rs index 81e882e..5b968e9 100644 --- a/anychain-core/src/network.rs +++ b/anychain-core/src/network.rs @@ -1,8 +1,10 @@ -use crate::no_std::*; -use core::{ - fmt::{Debug, Display}, - hash::Hash, - str::FromStr, +use { + crate::no_std::{ + fmt::{Debug, Display}, + hash::Hash, + FromStr, String, + }, + thiserror::Error, }; /// The interface for a generic network. @@ -12,7 +14,7 @@ pub trait Network: const NAME: &'static str; } -#[derive(Debug, thiserror::Error)] +#[derive(Debug, Error)] pub enum NetworkError { #[error("invalid extended private key prefix: {0}")] InvalidExtendedPrivateKeyPrefix(String), diff --git a/anychain-core/src/no_std/mod.rs b/anychain-core/src/no_std/mod.rs index 6564857..6c1e569 100644 --- a/anychain-core/src/no_std/mod.rs +++ b/anychain-core/src/no_std/mod.rs @@ -4,10 +4,18 @@ pub use alloc::{ borrow::ToOwned, format, string::FromUtf8Error, string::String, string::ToString, vec, vec::Vec, }; +#[cfg(not(feature = "std"))] +#[doc(hidden)] +pub use core::{ + hash, num, + {fmt, str::FromStr}, +}; + #[cfg(feature = "std")] #[doc(hidden)] pub use std::{ - borrow::ToOwned, format, string::FromUtf8Error, string::String, string::ToString, vec, vec::Vec, + borrow::ToOwned, fmt, format, hash, num, str::FromStr, string::FromUtf8Error, string::String, + string::ToString, vec, vec::Vec, }; #[cfg(not(feature = "std"))] diff --git a/anychain-core/src/public_key.rs b/anychain-core/src/public_key.rs index bfd78af..30dcfec 100644 --- a/anychain-core/src/public_key.rs +++ b/anychain-core/src/public_key.rs @@ -1,9 +1,13 @@ -use crate::address::{Address, AddressError}; -use crate::format::Format; -use crate::no_std::*; -use core::{ - fmt::{Debug, Display}, - str::FromStr, +use { + crate::{ + address::{Address, AddressError}, + format::Format, + no_std::{ + fmt::{Debug, Display}, + FromStr, String, + }, + }, + thiserror::Error, }; /// Generic public key. diff --git a/anychain-core/src/transaction.rs b/anychain-core/src/transaction.rs index 4d8cda7..8816751 100644 --- a/anychain-core/src/transaction.rs +++ b/anychain-core/src/transaction.rs @@ -1,12 +1,17 @@ -use crate::address::{Address, AddressError}; -use crate::amount::AmountError; -use crate::format::Format; -use crate::no_std::*; -use crate::public_key::PublicKey; -use crate::utilities::crypto::keccak256; -use core::{ - fmt::{Debug, Display}, - hash::Hash, +use { + crate::{ + address::{Address, AddressError}, + amount::AmountError, + format::Format, + no_std::{ + fmt::{Debug, Display}, + hash::Hash, + String, Vec, + }, + public_key::PublicKey, + utilities::crypto::keccak256, + }, + thiserror::Error, }; /** @@ -48,7 +53,7 @@ pub trait Transaction: Clone + Send + Sync + 'static { fn to_transaction_id(&self) -> Result; } -#[derive(Debug, thiserror::Error)] +#[derive(Debug, Error)] pub enum TransactionError { #[error("{0}")] AddressError(#[from] AddressError),