Config

class moccasin.config.Config(root_path: Path | None)

Bases: object

A wrapper around the moccasin.toml file, it is also the main entry point for doing almost anything with moccasin.

This class reads the moccasin.toml file and sets up project configuration.

Attributes:

_project_root (Path): The root directory of the project. _toml_data (dict): The raw data from moccasin.toml. dependencies (list[str]): Project dependencies from moccasin.toml. project (dict[str, str]): Project data from moccasin.toml. extra_data (dict[str, Any]): Any additional data from moccasin.toml. networks (_Networks): Network configurations.

Args:

root_path (Path, optional): The root directory of the project. Defaults to None.

activate_boa()
property build_folder: str
property config_path: Path
property contracts_folder: str
property cov_config: str | None
property default_network: str
property default_network_name: str
dependencies: list[str]
property dot_env: str
expand_env_vars(value)
extra_data: dict[str, Any]
find_contract(contract_or_contract_path: str) Path
static find_project_root(start_path: Path | str | None = None) Path
get_active_network() Network
get_base_dependencies_install_path() Path
get_config_path() Path
get_default_db_path() Path
get_dependencies() list[str]
get_networks() dict[str, Network]
get_or_deploy_named_contract(*args, **kwargs) VyperContract | ZksyncContract | ABIContract
get_root() Path
property lib_folder: str
static load_config_from_root(project_root: Path | None = None) Config
static merge_configs(moccasin_config_dict: dict | TOMLDocument, pyproject_config_dict: dict | TOMLDocument) dict | TOMLDocument
static nested_tomlkit_update(toml_data: TOMLDocument, keys: list, value: str | int | float | bool | list | dict) TOMLDocument
networks: _Networks
property out_folder: str
project: dict[str, str]
property project_root: Path
property pyproject_path: Path
read_configs(moccasin_path: Path | None = None, pyproject_path: Path | None = None) dict
read_configs_preserve_comments(moccasin_config_path: Path | None = None, pyproject_config_path: Path | None = None) TOMLDocument
read_moccasin_config(config_path: Path | None = None) dict
static read_moccasin_toml(config_path: Path) dict
static read_moccasin_toml_preserve_comments(config_path: Path) TOMLDocument
read_pyproject_config(pyproject_path: Path | None = None) dict
static read_pyproject_toml(pyproject_path: Path) dict
static read_pyproject_toml_preserve_comments(config_path: Path) TOMLDocument
reload()
property script_folder: str
set_active_network(name_url_or_id: str | Network, activate_boa=True, **kwargs) Network
property src_folder: str
property test_folder: str
write_dependencies(dependencies: list)

Writes the dependencies to the config file.

If a moccasin.toml file exists, it will write there, otherwise, it’ll write to pyproject.toml.

This will overwrite the existing dependencies with the new ones. So if you wish to keep old ones, read from the dependencies first.