Skip to main content

Module slot_identifier

Module slot_identifier 

Source
Expand description

Storage slot identification and decoding utilities for Solidity storage layouts.

This module provides functionality to identify and decode storage slots based on Solidity storage layout information from the compiler.

Re-exportsΒ§

use crate::mapping_slots::MappingSlots; πŸ”’
use alloy_dyn_abi::DynSolType; πŸ”’
use alloy_dyn_abi::DynSolValue; πŸ”’
use alloy_primitives::B256; πŸ”’
use alloy_primitives::U256; πŸ”’
use alloy_primitives::hex; πŸ”’
use alloy_primitives::hex; πŸ”’
use alloy_primitives::keccak256; πŸ”’
use alloy_primitives::map::B256Map; πŸ”’
use foundry_common_fmt::format_token_raw; πŸ”’
use foundry_compilers::artifacts::Storage; πŸ”’
use foundry_compilers::artifacts::StorageLayout; πŸ”’
use foundry_compilers::artifacts::StorageType; πŸ”’
use serde::Serialize; πŸ”’
use serde::Serialize; πŸ”’
use std::collections::BTreeMap; πŸ”’
use std::str::FromStr; πŸ”’
use std::sync::Arc; πŸ”’
use tracing::trace; πŸ”’

StructsΒ§

DecodedSlotValues
Decoded storage slot values
SlotIdentifier
Storage slot identifier that uses Solidity [StorageLayout] to identify storage slots.
SlotInfo
Information about a storage slot including its label, type, and decoded values.
StorageTypeInfo
Wrapper type that holds both the original type label and the parsed DynSolType.

ConstantsΒ§

ENCODING_BYTES
β€œbytes” encoding type for bytes and string types, which use either inplace or keccak256 hash-based storage depending on length
ENCODING_DYN_ARRAY
β€œdynamic_array” encoding type for dynamic arrays, which uses keccak256 hash-based storage
ENCODING_INPLACE
β€œinplace” encoding type for variables that fit in one storage slot i.e 32 bytes
ENCODING_MAPPING
β€œmapping” encoding type for Solidity mappings, which use keccak256 hash-based storage

FunctionsΒ§

get_array_base_indices πŸ”’
Returns the base indices for array types, e.g. β€œ[0][0]” for 2D arrays.
is_struct
Checks if a given type label represents a struct type.
parse_sol_type πŸ”’
Parses a storage type label into a [DynSolType], returning None for labels that have no direct ABI equivalent (mappings, structs).
serialize_mapping_keys πŸ”’
Custom serializer for mapping keys
serialize_slot_type πŸ”’
Custom serializer for StorageTypeInfo that only outputs the label