Skip to main content

Module namespaced_storage

Module namespaced_storage 

Source
Expand description

ERC-7201 namespaced storage layouts.

solc’s storageLayout output only covers conventional storage. Namespaces declared with @custom:storage-location erc7201:<id> are computed with Solar and appended to it, so storage decoding labels namespaced fields as <id>.<field>.

Re-exportsΒ§

use alloy_primitives::U256; πŸ”’
use eyre::Result; πŸ”’
use foundry_compilers::ArtifactId; πŸ”’
use foundry_compilers::ProjectCompileOutput; πŸ”’
use foundry_compilers::artifacts::Remapping; πŸ”’
use foundry_compilers::artifacts::Sources; πŸ”’
use foundry_compilers::artifacts::StorageLayout; πŸ”’
use path_slash::PathExt; πŸ”’
use solar::ast::ContractKind; πŸ”’
use solar::ast::NatSpecKind; πŸ”’
use solar::data_structures::Never; πŸ”’
use solar::data_structures::map::FxIndexSet; πŸ”’
use solar::interface::ColorChoice; πŸ”’
use solar::interface::Session; πŸ”’
use solar::interface::config::CompileOpts; πŸ”’
use solar::interface::config::ImportRemapping; πŸ”’
use solar::interface::source_map::FileLoader; πŸ”’
use solar::interface::source_map::FileName; πŸ”’
use solar::interface::source_map::SourceMap; πŸ”’
use solar::sema::Compiler; πŸ”’
use solar::sema::CompilerRef; πŸ”’
use solar::sema::Gcx; πŸ”’
use solar::sema::hir; πŸ”’
use solar::sema::output::StorageLayoutOutput; πŸ”’
use std::collections::BTreeMap; πŸ”’
use std::collections::HashMap; πŸ”’
use std::io; πŸ”’
use std::ops::ControlFlow; πŸ”’
use std::path::Path; πŸ”’
use std::path::PathBuf; πŸ”’
use std::sync::Arc; πŸ”’

StructsΒ§

LibraryReferences πŸ”’
Collects the libraries that visited code refers to by name, type, modifier, or using, and the free functions it calls, so their bodies can be visited too.
NoFileLoader πŸ”’
Rejects filesystem access, so Standard JSON imports only resolve to the supplied sources.
StorageNamespace πŸ”’
A storage namespace declared by a struct in a contract or one of its bases.

ConstantsΒ§

ANNOTATION πŸ”’
The NatSpec tag content that marks a namespace; cheap to search for in source text.
SCOPE_PREFIX πŸ”’
Prefix of a type ID scoped to a namespace, erc7201(<namespace>)::<id>.
SCOPE_SEPARATOR πŸ”’
Separator between a scoped type ID’s namespace and the ID itself.

FunctionsΒ§

collect_storage_layouts πŸ”’
Returns namespaces declared in contract, its linearized bases, and the libraries their code references, once per declaration.
contracts_by_source πŸ”’
Maps (source, name) to contracts, with sources relative to root and slash-separated.
extend_storage_layout
Appends the ERC-7201 namespaces of contract, its bases, and the libraries they reference to its storage layout.
extend_storage_layouts
Returns layouts with the ERC-7201 namespaces of each contract appended.
find_contract
Returns the contract name declared in the source path, relative to root.
has_annotation πŸ”’
Returns whether source mentions an ERC-7201 storage location.
has_annotations
Returns whether any parsed source mentions an ERC-7201 storage location.
has_library_annotations πŸ”’
Returns whether any library declares a struct that mentions an ERC-7201 storage location.
lower
Lowers the parsed sources to HIR unless that has already happened.
merge_storage_namespaces πŸ”’
Merges namespaces, rejecting duplicate declarations before layout is modified.
parse_namespace πŸ”’
parse_standard_json
Parses Standard JSON sources, keyed by source unit name, without touching the filesystem.
project_storage_layouts
Returns the storage layouts of output’s artifacts with ERC-7201 namespaces appended.
referenced_libraries πŸ”’
Returns the libraries referenced by contracts, directly or through other libraries and free functions, in discovery order and excluding contracts themselves.
scope_layout πŸ”’
Scopes type IDs to namespace and attributes every entry to contract.
solar_error πŸ”’
storage_namespace
Returns the ERC-7201 namespace declared by a struct’s @custom:storage-location tag.
struct_namespace πŸ”’
Returns the namespace declared by struct id in contract, if any.
unscoped_type_id
Returns the type ID as the compiler wrote it, without the namespace scope scope_layout adds.