Module foundry_compilers_core::utils
source · Expand description
Utility functions
Constants§
- Support for configuring the EVM version https://blog.soliditylang.org/2018/03/08/solidity-0.4.21-release-announcement/
- Bug fix for configuring the EVM version with Constantinople https://blog.soliditylang.org/2018/03/08/solidity-0.4.21-release-announcement/
- Prague support https://github.com/ethereum/solidity/pull/15152 Was merged between 0.8.26 and 0.8.27, so we are expecting it to be available in 0.8.27
- Extensions acceptable by solc compiler.
Statics§
- A regex that matches the import path and identifier of a solidity import statement with the named groups “path”, “id”.
- A regex that matches an alias within an import statement
- A regex that matches the version part of a solidity pragma as follows:
pragma solidity ^0.5.2;
=>^0.5.2
statement with the named group “version”. - A regex that matches the SDPX license identifier statement with the named group “license”.
- A regex used to remove extra lines in flatenned files
- A regex that matches version pragma in a Vyper
Functions§
- Canonicalize the path, platform-agnostic.
- Returns the same path config but with canonicalized paths.
- Given the regex and the target string, find all occurrences of named groups within the string. This method returns the tuple of matches
(a, b)
wherea
is the match for the entire regex andb
is the match for the first named group. - Finds the common ancestor of both paths
- Find the common ancestor, if any, between the given paths
- Create a regex that matches any library or contract name inside a file
- Creates the parent directory of the
file
and all its ancestors if it does not exist. - Attempts to find a file with different case that exists next to the
non_existing
file - Returns the right subpath in a dir
- Returns all path parts from any solidity import statement in a string,
import "./contracts/Contract.sol";
->"./contracts/Contract.sol"
. - Returns the solidity version pragma from the given input:
pragma solidity ^0.5.2;
=>^0.5.2
- Reads the list of Solc versions that have been installed in the machine. The version list is sorted in ascending order. Checks for installed solc versions under the given path as
<root>/<major.minor.path>
, (e.g.:~/.svm/0.8.10
) and returns them sorted in ascending order - Attempts to determine if the given source is a local, relative import.
- Returns the 36 char (deprecated) fully qualified name placeholder
- Returns the library placeholder for the given name The placeholder is a 34 character prefix of the hex encoding of the keccak256 hash of the fully qualified library name.
- Returns the library hash placeholder as
$hex(library_hash(name))$
- Returns a normalized Solidity file path for the given import path based on the specified directory.
- Move a range by a specified offset
- Reads the json file and deserialize it into the provided type.
- Tries to find an absolute import like
src/interfaces/IConfig.sol
incwd
, moving up the path until theroot
is reached. - Returns the path to the library if the source path is in fact determined to be a library path, and it exists. Note: this does not handle relative imports or remappings.
- Same as source_files but only returns files acceptable by Solc compiler.
- Returns a list of unique paths to all folders under
root
that contain at least one solidity file (*.sol
). - Returns a list of absolute paths to all the solidity files under the root, or the file itself, if the path is a solidity file.
- Returns an iterator that yields all solidity/yul files funder under the given root path or the
root
itself, if it is a sol/yul file - Returns the source name for the given source path, the ancestors of the root path.
- Strips
root
fromsource
and returns the relative path. - Strips
root
fromsource
and returns the relative path. - Writes serializes the provided value to JSON and writes it to a file.