Module ethers_solc::utils
source · Expand description
Utility functions
Enums§
- RuntimeOrHandleNon-WebAssembly
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
Functions§
- Canonicalize the path, platform-agnostic
- Returns the same path config but with canonicalized paths.
- 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 Seestd::fs::create_dir_all()
- 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))$
- 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.
- 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
/Users/project/sources/contract.sol
->sources/contracts.sol