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Β§
- Library
References π - 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. - NoFile
Loader π - Rejects filesystem access, so Standard JSON imports only resolve to the supplied sources.
- Storage
Namespace π - 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 torootand 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
layoutswith the ERC-7201 namespaces of each contract appended. - find_
contract - Returns the contract
namedeclared in the sourcepath, relative toroot. - has_
annotation π - Returns whether
sourcementions 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
layoutis 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 excludingcontractsthemselves. - scope_
layout π - Scopes type IDs to
namespaceand attributes every entry tocontract. - solar_
error π - storage_
namespace - Returns the ERC-7201 namespace declared by a structβs
@custom:storage-locationtag. - struct_
namespace π - Returns the namespace declared by struct
idincontract, if any. - unscoped_
type_ id - Returns the type ID as the compiler wrote it, without the namespace scope
scope_layoutadds.