Documentation
¶
Index ¶
- func BinTestByType(contract *compilationTypes.CompiledContract, ...) (assertionTests, propertyTests, optimizationTests []abi.Method, ...)
- func BuildLibraryNameMapping(compilations []types.Compilation) map[string]string
- func GenerateLibraryPlaceholder(fullyQualifiedName string) string
- func GetDeploymentOrder(dependencies map[string][]string, predeploys []string, ...) ([]string, error)
- func IsOptimizationTest(method abi.Method, prefixes []string) (bool, string)
- func IsPropertyTest(method abi.Method, prefixes []string) (bool, string)
- func ResolvePlaceholderLibraryReferences(placeholderToLibrary map[string]any, availableLibraries map[string]string)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BinTestByType ¶ added in v0.1.4
func BinTestByType(contract *compilationTypes.CompiledContract, propertyTestPrefixes, optimizationTestPrefixes []string, testViewMethods bool) (assertionTests, propertyTests, optimizationTests []abi.Method, warnings []string)
BinTestByType sorts a contract's methods by whether they are assertion, property, or optimization tests. Returns lists of methods for each test type, plus any warnings for methods with test prefixes but invalid signatures.
func BuildLibraryNameMapping ¶ added in v1.3.0
func BuildLibraryNameMapping(compilations []types.Compilation) map[string]string
BuildLibraryNameMapping builds a map of fully qualified library names to short names by scanning the compilation artifacts for contracts of type "library".
Fully qualified names (like "path/to/File.sol:LibraryName") are used for placeholder generation, while short names ("LibraryName") are used for linking references in contract bytecode.
func GenerateLibraryPlaceholder ¶ added in v1.3.0
GenerateLibraryPlaceholder creates a library placeholder based on the keccak256 hash of the fully qualified library name according to Solidity's algorithm
func GetDeploymentOrder ¶ added in v1.3.0
func GetDeploymentOrder(dependencies map[string][]string, predeploys []string, targetContracts []string) ([]string, error)
GetDeploymentOrder returns a topologically sorted list of libraries/contracts based on their dependencies. This ensures libraries are deployed before contracts that depend on them.
The function uses a modified Kahn's algorithm for topological sorting, with special handling for target contracts:
- Nodes with no dependencies (in-degree = 0) from predeploys are prioritized in their original order
- Nodes with no dependencies (in-degree = 0) from targetContracts are prioritized in their original order
- When multiple nodes become available for processing at the same time, nodes in predeploys are ordered according to their position in that list
- When multiple nodes become available for processing at the same time, nodes in targetContracts are ordered according to their position in that list
This way the deployment order respects both dependency constraints (libraries first) and preserves the desired order of predeploys and target contracts when possible.
func IsOptimizationTest ¶
IsOptimizationTest checks whether the method is an optimization test given potential naming prefixes it must conform to and its underlying input/output arguments. Returns (isValid, warningMessage). If the method has a prefix but invalid signature, warningMessage explains why.
func IsPropertyTest ¶
IsPropertyTest checks whether the method is a property test given potential naming prefixes it must conform to and its underlying input/output arguments. Returns (isValid, warningMessage). If the method has a prefix but invalid signature, warningMessage explains why.
func ResolvePlaceholderLibraryReferences ¶ added in v1.3.0
func ResolvePlaceholderLibraryReferences(placeholderToLibrary map[string]any, availableLibraries map[string]string)
ResolvePlaceholderLibraryReferences resolves library placeholder references to their actual library names by identifying placeholders and mapping them to the corresponding library using the fully qualified library name's hash
Types ¶
This section is empty.