utils

package
v1.4.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 2, 2025 License: AGPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

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

func GenerateLibraryPlaceholder(fullyQualifiedName string) string

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:

  1. Nodes with no dependencies (in-degree = 0) from predeploys are prioritized in their original order
  2. Nodes with no dependencies (in-degree = 0) from targetContracts are prioritized in their original order
  3. When multiple nodes become available for processing at the same time, nodes in predeploys are ordered according to their position in that list
  4. 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

func IsOptimizationTest(method abi.Method, prefixes []string) (bool, string)

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

func IsPropertyTest(method abi.Method, prefixes []string) (bool, string)

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL