forc_pkg

Function dependency_namespace

Source
pub fn dependency_namespace(
    lib_namespace_map: &HashMap<NodeIx, Root>,
    compiled_contract_deps: &CompiledContractDeps,
    graph: &Graph,
    node: NodeIx,
    engines: &Engines,
    contract_id_value: Option<String>,
    experimental: ExperimentalFeatures,
) -> Result<Root, Vec1<CompileError>>
Expand description

Builds the dependency namespace for the package at the given node index within the graph.

This function is designed to be called for each node in order of compilation.

This function ensures that if core exists in the graph (the vastly common case) it is also present within the namespace. This is a necessity for operators to work for example.

This function also ensures that if std exists in the graph, then the std prelude will also be added.

contract_id_value should only be Some when producing the dependency_namespace for a contract with tests enabled. This allows us to provide a contract’s CONTRACT_ID constant to its own unit tests.