|
6 | 6 | use crate::mapping_slots::MappingSlots;
|
7 | 7 | use alloy_dyn_abi::{DynSolType, DynSolValue};
|
8 | 8 | use alloy_primitives::{B256, U256, hex};
|
| 9 | +use foundry_common_fmt::format_token_raw; |
9 | 10 | use foundry_compilers::artifacts::{Storage, StorageLayout, StorageType};
|
10 | 11 | use serde::Serialize;
|
11 | 12 | use std::{str::FromStr, sync::Arc};
|
@@ -175,8 +176,8 @@ impl Serialize for DecodedSlotValues {
|
175 | 176 | use serde::ser::SerializeStruct;
|
176 | 177 |
|
177 | 178 | let mut state = serializer.serialize_struct("DecodedSlotValues", 2)?;
|
178 |
| - state.serialize_field("previousValue", &format_value(&self.previous_value))?; |
179 |
| - state.serialize_field("newValue", &format_value(&self.new_value))?; |
| 179 | + state.serialize_field("previousValue", &format_token_raw(&self.previous_value))?; |
| 180 | + state.serialize_field("newValue", &format_token_raw(&self.new_value))?; |
180 | 181 | state.end()
|
181 | 182 | }
|
182 | 183 | }
|
@@ -586,7 +587,7 @@ impl SlotIdentifier {
|
586 | 587 | && let Ok(sol_type) = DynSolType::parse(key_type_label)
|
587 | 588 | && let Ok(decoded) = sol_type.abi_decode(&key.0)
|
588 | 589 | {
|
589 |
| - let decoded_key_str = format_value(&decoded); |
| 590 | + let decoded_key_str = format_token_raw(&decoded); |
590 | 591 | decoded_keys.push(decoded_key_str.clone());
|
591 | 592 | label = format!("{label}[{decoded_key_str}]");
|
592 | 593 | } else {
|
@@ -663,31 +664,6 @@ fn get_array_base_indices(dyn_type: &DynSolType) -> String {
|
663 | 664 | }
|
664 | 665 | }
|
665 | 666 |
|
666 |
| -/// Formats a [`DynSolValue`] as a raw string without type information and only the value itself. |
667 |
| -pub fn format_value(value: &DynSolValue) -> String { |
668 |
| - match value { |
669 |
| - DynSolValue::Bool(b) => b.to_string(), |
670 |
| - DynSolValue::Int(i, _) => i.to_string(), |
671 |
| - DynSolValue::Uint(u, _) => u.to_string(), |
672 |
| - DynSolValue::FixedBytes(bytes, size) => hex::encode_prefixed(&bytes.0[..*size]), |
673 |
| - DynSolValue::Address(addr) => addr.to_string(), |
674 |
| - DynSolValue::Function(func) => func.as_address_and_selector().1.to_string(), |
675 |
| - DynSolValue::Bytes(bytes) => hex::encode_prefixed(bytes), |
676 |
| - DynSolValue::String(s) => s.clone(), |
677 |
| - DynSolValue::Array(values) | DynSolValue::FixedArray(values) => { |
678 |
| - let formatted: Vec<String> = values.iter().map(format_value).collect(); |
679 |
| - format!("[{}]", formatted.join(", ")) |
680 |
| - } |
681 |
| - DynSolValue::Tuple(values) => { |
682 |
| - let formatted: Vec<String> = values.iter().map(format_value).collect(); |
683 |
| - format!("({})", formatted.join(", ")) |
684 |
| - } |
685 |
| - DynSolValue::CustomStruct { name: _, prop_names: _, tuple } => { |
686 |
| - format_value(&DynSolValue::Tuple(tuple.clone())) |
687 |
| - } |
688 |
| - } |
689 |
| -} |
690 |
| - |
691 | 667 | /// Checks if a given type label represents a struct type.
|
692 | 668 | pub fn is_struct(s: &str) -> bool {
|
693 | 669 | s.starts_with("struct ")
|
|
0 commit comments