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::NatSpecKind; πŸ”’
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Β§

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.

FunctionsΒ§

collect_storage_layouts πŸ”’
Returns namespaces declared in contract and its linearized bases, 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 and its bases 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.
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.
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.