abigen

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2021 License: MPL-2.0 Imports: 13 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrConflictDef = errors.New("conflict struct definition with same name")

Functions

func FuncMap

func FuncMap() template.FuncMap

func GenCode

func GenCode(artifacts map[string]*compiler.Artifact, config *Config) error

Types

type CodeFile

type CodeFile struct {
	FileName string
	Code     []byte
}

type Config

type Config struct {
	Package string
	Output  string
	Name    string
}

type FieldDef

type FieldDef struct {
	Name string
	Type string
}

type Generator

type Generator struct {
	Artifacts map[string]*compiler.Artifact
	Config    *Config
	// contains filtered or unexported fields
}

func NewGenerator

func NewGenerator(cfg *Config, artifacts map[string]*compiler.Artifact) *Generator

func (*Generator) Gen

func (g *Generator) Gen() (res Result, err error)

type Result

type Result struct {
	AbiFiles []CodeFile
	BinFiles []CodeFile
}

type StructDef

type StructDef struct {
	Name    string
	Fields  []*FieldDef
	IsEvent bool
}

type StructDefExtractor

type StructDefExtractor struct {
	Defs map[string]*StructDef `json:"definitions"`
}

func LoadStructDef

func LoadStructDef(outputDir string) (*StructDefExtractor, error)

func NewStructDefExtractor

func NewStructDefExtractor() *StructDefExtractor

func (*StructDefExtractor) ExtractEvent

func (self *StructDefExtractor) ExtractEvent(e *abi.Event)

ExtractEvent generate event type, and record it for not duplicated.

func (*StructDefExtractor) ExtractFromAbi

func (self *StructDefExtractor) ExtractFromAbi(abi *abi.ABI) *StructDefExtractor

func (*StructDefExtractor) ExtractFromType

func (self *StructDefExtractor) ExtractFromType(typ *abi.Type) string

func (*StructDefExtractor) RenderGoCode

func (self *StructDefExtractor) RenderGoCode(packageName string) (string, error)

func (*StructDefExtractor) RenderGoCodeToFile

func (self *StructDefExtractor) RenderGoCodeToFile(packageName string, outputDir string) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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