compilation

package
v1.5.1 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2026 License: AGPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const ArtifactHashCacheFileName = ".medusa-artifact-hash"

ArtifactHashCacheFileName is the name of the file used to store the artifact hash.

Variables

This section is empty.

Functions

func ComputeArtifactHash added in v1.5.0

func ComputeArtifactHash(compilations []types.Compilation) string

ComputeArtifactHash computes a SHA-256 hash of all compiled contract bytecode from the provided compilations. The hash is computed deterministically by sorting contract names before hashing.

func GetDefaultPlatformConfig

func GetDefaultPlatformConfig(platform string) platforms.PlatformConfig

GetDefaultPlatformConfig obtains a PlatformConfig from the default generator for the provided platform.

func GetSupportedCompilationPlatforms

func GetSupportedCompilationPlatforms() []string

GetSupportedCompilationPlatforms obtains a list of strings which represent platform identifiers supported by methods in this package.

func IsSupportedCompilationPlatform

func IsSupportedCompilationPlatform(platform string) bool

IsSupportedCompilationPlatform returns a boolean status indicating if a platform identifier is supported within this package.

func NotifyArtifactHashStatus added in v1.5.0

func NotifyArtifactHashStatus(
	compilations []types.Compilation,
	cacheDirectory string,
	logger *logging.Logger,
)

NotifyArtifactHashStatus compares the current artifact hash with a cached hash and logs an appropriate message. It also updates the cache with the new hash. The cacheDirectory parameter specifies where the cache file is stored.

func SaveArtifactHashCache added in v1.5.0

func SaveArtifactHashCache(directory string, cache *ArtifactHashCache) error

SaveArtifactHashCache saves the artifact hash cache to the specified directory. Returns an error if the cache cannot be written.

Types

type ArtifactHashCache added in v1.5.0

type ArtifactHashCache struct {
	// Hash is the SHA-256 hash of the compiled bytecode.
	Hash string `json:"hash"`
	// Timestamp is when the hash was computed.
	Timestamp time.Time `json:"timestamp"`
}

ArtifactHashCache stores the hash of compilation artifacts along with metadata.

func LoadArtifactHashCache added in v1.5.0

func LoadArtifactHashCache(directory string) *ArtifactHashCache

LoadArtifactHashCache loads the artifact hash cache from the specified directory. Returns nil if the cache file does not exist or cannot be parsed.

type CompilationConfig

type CompilationConfig struct {
	// Platform references an identifier indicating which compilation platform to use.
	// PlatformConfig is a structure dependent on the defined Platform.
	Platform string `json:"platform"`

	// PlatformConfig describes the Platform-specific configuration needed to compile.
	PlatformConfig *json.RawMessage `json:"platformConfig"`
}

CompilationConfig describes the configuration options used to compile a smart contract target.

func NewCompilationConfig

func NewCompilationConfig(platform string) (*CompilationConfig, error)

NewCompilationConfig returns a CompilationConfig with default values for a given platform identifier. If an error occurs, it is returned instead.

func NewCompilationConfigFromPlatformConfig

func NewCompilationConfigFromPlatformConfig(platformConfig platforms.PlatformConfig) (*CompilationConfig, error)

NewCompilationConfigFromPlatformConfig takes a platforms.PlatformConfig and wraps it in a generic CompilationConfig. This allows many platform config types to be serialized/deserialized to their appropriate types and supported generally.

func (*CompilationConfig) Compile

func (c *CompilationConfig) Compile() ([]types.Compilation, string, error)

Compile takes a generic CompilationConfig and deserializes the inner platforms.PlatformConfig, which is then used to compile the underlying targets. Returns a list of compilations returned by the platform provider or an error if one occurs. Command-line input may also be returned in either case.

func (*CompilationConfig) GetPlatformConfig

func (c *CompilationConfig) GetPlatformConfig() (platforms.PlatformConfig, error)

GetPlatformConfig will return the de-serialized version of platforms.PlatformConfig for a given CompilationConfig

func (*CompilationConfig) SetPlatformConfig

func (c *CompilationConfig) SetPlatformConfig(platformConfig platforms.PlatformConfig) error

SetPlatformConfig replaces the current platform config with the one provided as an argument Note that non-nil platform configs will not be accepted

func (*CompilationConfig) SetTarget

func (c *CompilationConfig) SetTarget(newTarget string) error

SetTarget will update the compilation target in the underlying PlatformConfig

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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