Skip to content

Commit

Permalink
Put f64 in hyperlane-core behind float flag (#2788)
Browse files Browse the repository at this point in the history
  • Loading branch information
yorhodes authored Oct 9, 2023
1 parent 46b186c commit 401b32d
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion rust/hyperlane-base/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ backtrace = { workspace = true, optional = true }
backtrace-oneline = { path = "../utils/backtrace-oneline", optional = true }

ethers-prometheus = { path = "../ethers-prometheus", features = ["serde"] }
hyperlane-core = { path = "../hyperlane-core", features = ["agent"] }
hyperlane-core = { path = "../hyperlane-core", features = ["agent", "float"] }
hyperlane-ethereum = { path = "../chains/hyperlane-ethereum" }
hyperlane-fuel = { path = "../chains/hyperlane-fuel" }
hyperlane-sealevel = { path = "../chains/hyperlane-sealevel" }
Expand Down
1 change: 1 addition & 0 deletions rust/hyperlane-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ tokio = { workspace = true, features = ["rt", "time"] }

[features]
default = []
float = []
test-utils = ["dep:config"]
agent = ["ethers", "strum"]
strum = ["dep:strum"]
Expand Down
4 changes: 4 additions & 0 deletions rust/hyperlane-core/src/types/primitive_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ impl_fixed_uint_conversions!(ethers_core::types::U512, U256);
#[cfg(feature = "ethers")]
impl_fixed_uint_conversions!(ethers_core::types::U512, U128);

#[cfg(feature = "float")]
macro_rules! impl_f64_conversions {
($ty:ty) => {
impl $ty {
Expand Down Expand Up @@ -200,8 +201,11 @@ macro_rules! impl_f64_conversions {
};
}

#[cfg(feature = "float")]
impl_f64_conversions!(U128);
#[cfg(feature = "float")]
impl_f64_conversions!(U256);
#[cfg(feature = "float")]
impl_f64_conversions!(U512);

#[cfg(feature = "ethers")]
Expand Down
2 changes: 2 additions & 0 deletions rust/hyperlane-core/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ pub fn fmt_domain(domain: u32) -> String {
}

/// Formats the duration in the most appropriate time units.
#[cfg(feature = "float")]
pub fn fmt_duration(dur: Duration) -> String {
const MIN: f64 = 60.;
const HOUR: f64 = MIN * 60.;
Expand All @@ -97,6 +98,7 @@ pub fn fmt_duration(dur: Duration) -> String {

/// Formats the duration in the most appropriate time units and says "synced" if
/// the duration is 0.
#[cfg(feature = "float")]
pub fn fmt_sync_time(dur: Duration) -> String {
if dur.as_secs() == 0 {
"synced".into()
Expand Down

0 comments on commit 401b32d

Please sign in to comment.