Skip to content

Commit

Permalink
feat: right-align and prettify --sizes output (#7601)
Browse files Browse the repository at this point in the history
  • Loading branch information
DaniPopes authored Apr 9, 2024
1 parent 14daacf commit bbdb034
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 22 deletions.
11 changes: 11 additions & 0 deletions Cargo.lock

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

13 changes: 5 additions & 8 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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",
] }
Expand Down Expand Up @@ -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"
Expand All @@ -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"
Expand Down
12 changes: 6 additions & 6 deletions crates/cheatcodes/assets/cheatcodes.json

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

11 changes: 6 additions & 5 deletions crates/cheatcodes/spec/src/vm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
1 change: 1 addition & 0 deletions crates/common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 9 additions & 3 deletions crates/common/src/compile.rs
Original file line number Diff line number Diff line change
@@ -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::{
Expand All @@ -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},
Expand Down Expand Up @@ -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),
]);
}

Expand Down

0 comments on commit bbdb034

Please sign in to comment.