diff --git a/Cargo.lock b/Cargo.lock index 6e48a7bc30f8..532cd24cfc5a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3275,6 +3275,7 @@ dependencies = [ "foundry-macros", "glob", "globset", + "num-format", "once_cell", "pretty_assertions", "rand 0.8.5", @@ -5219,6 +5220,16 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "51d515d32fb182ee37cda2ccdcb92950d6a3c2893aa280e540671c2cd0f3b1d9" +[[package]] +name = "num-format" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a652d9771a63711fd3c3deb670acfbe5c30a4072e664d7a3bf5a9e1056ac72c3" +dependencies = [ + "arrayvec", + "itoa", +] + [[package]] name = "num-integer" version = "0.1.46" diff --git a/Cargo.toml b/Cargo.toml index 661bcb128ce0..ad300a085c8f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -28,7 +28,8 @@ resolver = "2" [workspace.package] version = "0.2.0" edition = "2021" -rust-version = "1.76" # Remember to update clippy.toml as well +# Remember to update clippy.toml as well +rust-version = "1.76" authors = ["Foundry Contributors"] license = "MIT OR Apache-2.0" homepage = "https://github.com/foundry-rs/foundry" @@ -145,9 +146,7 @@ foundry-compilers = { version = "0.3.13", default-features = false } ## revm # no default features to avoid c-kzg revm = { version = "7.1", default-features = false, features = ["std"] } -revm-primitives = { version = "3", default-features = false, features = [ - "std", -] } +revm-primitives = { version = "3", default-features = false, features = ["std"] } revm-inspectors = { git = "https://github.com/paradigmxyz/evm-inspectors", rev = "ba0b6ab", features = [ "serde", ] } @@ -192,10 +191,7 @@ solang-parser = "=0.3.3" ## misc arrayvec = "0.7" base64 = "0.22" -chrono = { version = "0.4", default-features = false, features = [ - "clock", - "std", -] } +chrono = { version = "0.4", default-features = false, features = ["clock", "std"] } color-eyre = "0.6" derive_more = "0.99" evm-disassembler = "0.5" @@ -216,6 +212,7 @@ tracing-subscriber = "0.3" vergen = { version = "8", default-features = false } indexmap = "2.2" tikv-jemallocator = "0.5.4" +num-format = "0.4.4" axum = "0.6" hyper = "0.14" diff --git a/crates/cheatcodes/assets/cheatcodes.json b/crates/cheatcodes/assets/cheatcodes.json index 3b4d071d7589..102c810cdac2 100644 --- a/crates/cheatcodes/assets/cheatcodes.json +++ b/crates/cheatcodes/assets/cheatcodes.json @@ -418,32 +418,32 @@ }, { "name": "Gas", - "description": "", + "description": "Gas used. Returned by `lastCallGas`.", "fields": [ { "name": "gasLimit", "ty": "uint64", - "description": "" + "description": "The gas limit of the call." }, { "name": "gasTotalUsed", "ty": "uint64", - "description": "" + "description": "The total gas used." }, { "name": "gasMemoryUsed", "ty": "uint64", - "description": "" + "description": "The amount of gas used for memory expansion." }, { "name": "gasRefunded", "ty": "int64", - "description": "" + "description": "The amount of gas refunded." }, { "name": "gasRemaining", "ty": "uint64", - "description": "" + "description": "The amount of gas remaining." } ] } diff --git a/crates/cheatcodes/spec/src/vm.rs b/crates/cheatcodes/spec/src/vm.rs index c350690fcc26..7fb3e2922769 100644 --- a/crates/cheatcodes/spec/src/vm.rs +++ b/crates/cheatcodes/spec/src/vm.rs @@ -73,16 +73,17 @@ interface Vm { address emitter; } + /// Gas used. Returned by `lastCallGas`. struct Gas { - // The gas limit of the call. + /// The gas limit of the call. uint64 gasLimit; - // The total gas used. + /// The total gas used. uint64 gasTotalUsed; - // The amount of gas used for memory expansion. + /// The amount of gas used for memory expansion. uint64 gasMemoryUsed; - // The amount of gas refunded. + /// The amount of gas refunded. int64 gasRefunded; - // The amount of gas remaining. + /// The amount of gas remaining. uint64 gasRemaining; } diff --git a/crates/common/Cargo.toml b/crates/common/Cargo.toml index fb161da6127e..d458786f97b1 100644 --- a/crates/common/Cargo.toml +++ b/crates/common/Cargo.toml @@ -59,6 +59,7 @@ url = "2" walkdir = "2" yansi = "0.5" rustc-hash.workspace = true +num-format.workspace = true [dev-dependencies] foundry-macros.workspace = true diff --git a/crates/common/src/compile.rs b/crates/common/src/compile.rs index bba5e15d2775..baf73c992abd 100644 --- a/crates/common/src/compile.rs +++ b/crates/common/src/compile.rs @@ -1,7 +1,7 @@ //! Support for compiling [foundry_compilers::Project] use crate::{compact_to_contract, glob::GlobMatcher, term::SpinnerReporter, TestFunctionExt}; -use comfy_table::{presets::ASCII_MARKDOWN, Attribute, Cell, Color, Table}; +use comfy_table::{presets::ASCII_MARKDOWN, Attribute, Cell, CellAlignment, Color, Table}; use eyre::{Context, Result}; use foundry_block_explorers::contract::Metadata; use foundry_compilers::{ @@ -12,6 +12,7 @@ use foundry_compilers::{ Solc, SolcConfig, }; use foundry_linking::Linker; +use num_format::{Locale, ToFormattedString}; use rustc_hash::FxHashMap; use std::{ collections::{BTreeMap, HashMap}, @@ -417,10 +418,15 @@ impl Display for SizeReport { _ => Color::Red, }; + let locale = &Locale::en; table.add_row([ Cell::new(name).fg(color), - Cell::new(contract.size).fg(color), - Cell::new(margin).fg(color), + Cell::new(contract.size.to_formatted_string(locale)) + .set_alignment(CellAlignment::Right) + .fg(color), + Cell::new(margin.to_formatted_string(locale)) + .set_alignment(CellAlignment::Right) + .fg(color), ]); }