analyzer

package
v0.80.2 Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AnalyzeRequest

type AnalyzeRequest struct {
	AnalyzerContext  AnalyzerContext
	ExecutionContext ExecutionContext
}

AnalyzeRequest encapsulates the analyzer and execution contexts passed to analyzer methods.

type AnalyzedBatchOperation

type AnalyzedBatchOperation interface {
	Annotated
	ChainSelector() uint64
	Calls() AnalyzedCalls
}

type AnalyzedBatchOperations

type AnalyzedBatchOperations []AnalyzedBatchOperation

type AnalyzedCall

type AnalyzedCall interface {
	Annotated
	To() string
	Name() string
	Inputs() AnalyzedParameters
	Outputs() AnalyzedParameters
	Data() []byte
	ContractType() string
	ContractVersion() string
	AdditionalFields() map[string]any
}

type AnalyzedCalls

type AnalyzedCalls []AnalyzedCall

type AnalyzedParameter

type AnalyzedParameter interface {
	Annotated
	Name() string
	Type() string
	Value() any
}

type AnalyzedParameters

type AnalyzedParameters []AnalyzedParameter

type AnalyzedProposal

type AnalyzedProposal interface {
	Annotated
	BatchOperations() AnalyzedBatchOperations
}

type AnalyzerContext

type AnalyzerContext interface {
	// Proposal returns the current proposal-level context.
	// This is primarily meaningful for ProposalAnalyzer execution.
	Proposal() AnalyzedProposal
	// BatchOperation returns the current batch operation context.
	// This is primarily meaningful for ProposalAnalyzer and BatchOperationAnalyzer execution.
	BatchOperation() AnalyzedBatchOperation
	// Call returns the current call-level context.
	// This is primarily meaningful for ProposalAnalyzer, BatchOperationAnalyzer and CallAnalyzer execution.
	Call() AnalyzedCall

	// GetAnnotationsFrom returns annotations from a specific analyzer.
	// This is useful for accessing results from dependency analyzers.
	// Returns empty slice if the analyzer ID is not found or no annotations exist.
	GetAnnotationsFrom(analyzerID string) Annotations
}

AnalyzerContext provides access to the current stage of analysis within the proposal structure. Only some accessor methods are relevant depending on which analyzer type is being executed. Analysis proceeds from the most granular components (parameters), up through calls and batch operations, to the full proposal. Therefore, context accessors are applicable for the current and higher (ancestor) analysis levels. Accessors may return zero values when invoked at stages where corresponding context is not available.

type Annotated

type Annotated interface {
	// AddAnnotations mutates the underlying analyzed object by appending annotations.
	// Implementations are expected to be used by a single analysis pipeline and are
	// not required to provide internal synchronization for concurrent mutation.
	AddAnnotations(annotations ...Annotation)
	Annotations() Annotations
}

type Annotation

type Annotation interface {
	Name() string
	Type() string
	Value() any
}

type Annotations

type Annotations []Annotation

type BaseAnalyzer

type BaseAnalyzer interface {
	ID() string
	// Dependencies returns the IDs of analyzers that must run before this analyzer.
	//
	// The returned strings MUST correspond to the ID() values of other registered analyzers.
	// Implementations MUST NOT introduce circular dependencies (directly or indirectly).
	//
	// Analyzers may depend only on other analyzers of the same type.
	// For example, a ProposalAnalyzer may only depend on other ProposalAnalyzer instances,
	// a BatchOperationAnalyzer may only depend on other BatchOperationAnalyzer instances,
	// and a CallAnalyzer may only depend on other CallAnalyzer instances.
	// This restriction exists because analyzers of different types are already executed in a fixed dependency order:
	// parameter analyzers run before call analyzers, which run before batch operation analyzers, which in turn run before proposal analyzers.
	Dependencies() []string
}

type BatchOperationAnalyzer

type BatchOperationAnalyzer interface {
	BaseAnalyzer
	CanAnalyze(ctx context.Context, req AnalyzeRequest, operation decoder.DecodedBatchOperation) bool
	Analyze(ctx context.Context, req AnalyzeRequest, operation decoder.DecodedBatchOperation) (Annotations, error)
}

type CallAnalyzer

type CallAnalyzer interface {
	BaseAnalyzer
	CanAnalyze(ctx context.Context, req AnalyzeRequest, call decoder.DecodedCall) bool
	Analyze(ctx context.Context, req AnalyzeRequest, call decoder.DecodedCall) (Annotations, error)
}

type ExecutionContext

type ExecutionContext interface {
	Domain() cldfdomain.Domain
	EnvironmentName() string
	BlockChains() chain.BlockChains
	DataStore() datastore.DataStore
}

type ParameterAnalyzer

type ParameterAnalyzer interface {
	BaseAnalyzer
	CanAnalyze(ctx context.Context, req AnalyzeRequest, param decoder.DecodedParameter) bool
	Analyze(ctx context.Context, req AnalyzeRequest, param decoder.DecodedParameter) (Annotations, error)
}

type ProposalAnalyzer

type ProposalAnalyzer interface {
	BaseAnalyzer
	CanAnalyze(ctx context.Context, req AnalyzeRequest, proposal decoder.DecodedTimelockProposal) bool
	Analyze(ctx context.Context, req AnalyzeRequest, proposal decoder.DecodedTimelockProposal) (Annotations, error)
}

Jump to

Keyboard shortcuts

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