proposalutils

package
v0.52.0 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2025 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package proposalutils is copied from https://github.com/smartcontractkit/chainlink/blob/c2074f6d70cdf9164f15f4be3f7de8a8427919af/deployment/common/proposalutils/analyze.go#L1-L1 This is a temporary location.

Index

Constants

View Source
const (
	Indent       = "    "
	DoubleIndent = Indent + Indent
	// Magic number constants
	MinStructFieldsForPrettyFormat = 2
	MinDataLengthForMethodID       = 4
	DefaultAnalyzersCount          = 2
)

Variables

This section is empty.

Functions

func ContextGet

func ContextGet[T any](ctx *ArgumentContext, key string) (T, error)

func DescribeProposal

func DescribeProposal(proposal *mcmslib.Proposal, describedOperations []string) string

func DescribeTimelockProposal

func DescribeTimelockProposal(proposal *mcmslib.TimelockProposal, describedBatches [][]string) string

func GetChainNameBySelector

func GetChainNameBySelector(selector uint64) (string, error)

Types

type AddressArgument

type AddressArgument struct {
	Value string
}

func (AddressArgument) Annotation

func (a AddressArgument) Annotation(ctx *ArgumentContext) string

Annotation returns only the annotation if known, otherwise "".

func (AddressArgument) Describe

func (a AddressArgument) Describe(_ *ArgumentContext) string

type Analyzer

type Analyzer func(argName string, argAbi *abi.Type, argVal any, analyzers []Analyzer) Argument

Analyzer is an extension point of proposal decoding. You can implement your own Analyzer which returns your own Argument instance.

type Argument

type Argument interface {
	Describe(ctx *ArgumentContext) string
}

Argument is a unit of decoded proposal. Calling Describe on it returns human-readable representation of its content. Some implementations are recursive (arrays, structs) and require attention to formatting.

func BytesAndAddressAnalyzer

func BytesAndAddressAnalyzer(_ string, argAbi *abi.Type, argVal any, _ []Analyzer) Argument

func ChainSelectorAnalyzer

func ChainSelectorAnalyzer(argName string, argAbi *abi.Type, argVal any, _ []Analyzer) Argument

type ArgumentContext

type ArgumentContext struct {
	Ctx map[string]any
}

ArgumentContext is a storage for context that may need to Argument during its description. Refer to BytesAndAddressAnalyzer and ChainSelectorAnalyzer for usage examples

func NewArgumentContext

func NewArgumentContext(addresses deployment.AddressesByChain) *ArgumentContext

type ArrayArgument

type ArrayArgument struct {
	Elements []Argument
}

func (ArrayArgument) Describe

func (a ArrayArgument) Describe(context *ArgumentContext) string

type BytesArgument

type BytesArgument struct {
	Value []byte
}

func (BytesArgument) Describe

func (a BytesArgument) Describe(_ *ArgumentContext) string

type ChainSelectorArgument

type ChainSelectorArgument struct {
	Value uint64
}

func (ChainSelectorArgument) Describe

type DecodedCall

type DecodedCall struct {
	Address string
	Method  string
	Inputs  []NamedArgument
	Outputs []NamedArgument
}

func (*DecodedCall) Describe

func (d *DecodedCall) Describe(context *ArgumentContext) string

type NamedArgument

type NamedArgument struct {
	Name  string
	Value Argument
}

func (NamedArgument) Describe

func (n NamedArgument) Describe(context *ArgumentContext) string

type SimpleArgument

type SimpleArgument struct {
	Value string
}

func (SimpleArgument) Describe

func (s SimpleArgument) Describe(_ *ArgumentContext) string

type StructArgument

type StructArgument struct {
	Fields []NamedArgument
}

func (StructArgument) Describe

func (s StructArgument) Describe(context *ArgumentContext) string

type TxCallDecoder

type TxCallDecoder struct {
	Analyzers []Analyzer
}

func NewTxCallDecoder

func NewTxCallDecoder(extraAnalyzers []Analyzer) *TxCallDecoder

func (*TxCallDecoder) Analyze

func (p *TxCallDecoder) Analyze(address string, contractABI *abi.ABI, data []byte) (*DecodedCall, error)

Jump to

Keyboard shortcuts

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