common

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2026 License: MIT Imports: 30 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddTimeStampToFileName

func AddTimeStampToFileName(fileName string) string

func CompileWorkflowToWasm added in v1.1.0

func CompileWorkflowToWasm(workflowPath string) ([]byte, error)

CompileWorkflowToWasm compiles the workflow at workflowPath and returns the WASM binary. It runs the sequence of commands from getBuildCmds (make build + copy for WASM, or single build for Go/TS), then reads the temp WASM file.

func CompressBrotli added in v1.4.0

func CompressBrotli(data []byte) ([]byte, error)

CompressBrotli applies Brotli compression to the given data.

func ComputeHashKey

func ComputeHashKey(owner common.Address, workflowName string) [32]byte

func DecompressBrotli added in v1.4.0

func DecompressBrotli(data []byte) ([]byte, error)

DecompressBrotli decompresses Brotli-compressed data.

func DeleteFileIfExists

func DeleteFileIfExists(filePath string) error

func EncodeBase64ToFile added in v1.4.0

func EncodeBase64ToFile(data []byte, path string) error

EncodeBase64ToFile base64-encodes data and writes the result to the given path.

func EnsureBrotliBase64 added in v1.4.0

func EnsureBrotliBase64(data []byte) ([]byte, error)

EnsureBrotliBase64 returns data in brotli-compressed, base64-encoded form. If the input is raw WASM (starts with \0asm), it compresses and encodes. Otherwise it assumes the data is already in br64 form and returns it as-is.

func EnsureOutputExtension added in v1.4.0

func EnsureOutputExtension(outputPath string) string

EnsureOutputExtension appends .wasm, .br, and/or .b64 suffixes as needed so the returned path always ends with ".wasm.br.b64".

func EnsureRawWasm added in v1.4.0

func EnsureRawWasm(data []byte) ([]byte, error)

EnsureRawWasm returns raw WASM bytes. If data is already raw WASM (starts with \0asm), it is returned as-is. Otherwise the data is assumed to be base64-encoded brotli-compressed WASM and is decoded then decompressed.

func EnsureTool added in v1.0.2

func EnsureTool(bin string) error

EnsureTool checks that the binary exists on PATH

func EnsureWasmExtension added in v1.4.0

func EnsureWasmExtension(outputPath string) string

EnsureWasmExtension appends ".wasm" if the path doesn't already end with it.

func FetchURL added in v1.4.0

func FetchURL(url string) ([]byte, error)

FetchURL performs an HTTP GET and returns the response body bytes.

func GetDirectoryName

func GetDirectoryName() (string, error)

func GetWorkflowLanguage

func GetWorkflowLanguage(inputFile string) string

GetWorkflowLanguage determines the workflow language based on the file extension Note: inputFile can be a file path (e.g., "main.ts", "main.go", or "workflow.wasm") or a directory (for Go workflows, e.g., ".") Returns constants.WorkflowLanguageTypeScript for .ts or .tsx files, constants.WorkflowLanguageWasm for .wasm files, constants.WorkflowLanguageGolang otherwise

func IsBinaryFile

func IsBinaryFile(fileName string) (bool, error)

There is only a small group of acceptable file extensions by this tool and only few of them are considered to be binary files

func IsRawWasm added in v1.4.0

func IsRawWasm(data []byte) bool

IsRawWasm returns true if data starts with the WASM magic number ("\0asm").

func IsURL added in v1.4.0

func IsURL(s string) bool

IsURL returns true when s begins with http:// or https://.

func ResolveConfigPath added in v1.4.0

func ResolveConfigPath(v *viper.Viper, defaultPath string) string

ResolveConfigPath returns the config path based on the --no-config, --config, and --default-config flag convention. defaultPath is the value from workflow.yaml settings.

func ResolveWorkflowPath added in v1.1.0

func ResolveWorkflowPath(workflowDir, pathFromYAML string) (absPath string, err error)

ResolveWorkflowPath turns a workflow-path value from YAML (e.g. "." or "main.ts") into an absolute path to the main file. When pathFromYAML is "." or "", looks for main.go then main.ts under workflowDir. Callers can use GetWorkflowLanguage on the result to get the language.

func SimTransactOpts

func SimTransactOpts() *bind.TransactOpts

SimTransactOpts is useful to generate just the calldata for a given gethwrapper method.

func ToStringSlice

func ToStringSlice(args []any) []string

toStringSlice converts a slice of any type to a slice of strings. If an element is a byte slice, it prints it as hex.

func ValidateEventSignature

func ValidateEventSignature(l *zerolog.Logger, tx *seth.DecodedTransaction, e abi.Event) (bool, int)

func ValidatePrivateKey

func ValidatePrivateKey(key string) error

ValidatePrivateKey validates the input string is a valid Ethereum private key

func WorkflowPathRootAndMain added in v1.1.0

func WorkflowPathRootAndMain(workflowPath string) (rootDir, mainFile string, err error)

WorkflowPathRootAndMain returns the absolute root directory and main file name for a workflow path (e.g. "workflowName/main.go" -> rootDir, "main.go"). Use with GetWorkflowLanguage(mainFile) for consistent language detection.

func WriteChangesetFile added in v1.0.6

func WriteChangesetFile(fileName string, changesetFile *inttypes.ChangesetFile, settings *settings.Settings) error

func WriteJsonToFile

func WriteJsonToFile(j interface{}, filePath string) error

Types

This section is empty.

Jump to

Keyboard shortcuts

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