compose

package
v1.18.4 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2024 License: MIT Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const (
	VAR_PREFIX  = "$"
	FILE_PREFIX = "@"
	TIME_PREFIX = "$now"
)

Variables

View Source
var (
	ErrNoVersion      = errors.New("missing engine version")
	ErrInvalidVersion = errors.New("unsupported engine version")
	ErrNoPipeline     = errors.New("missing pipeline definition")
	ErrNoBaseKey      = errors.New("missing base account key, set with TZCOMPOSE_BASE_KEY")
	ErrNoAccount      = errors.New("missing account")
	ErrNoAccountName  = errors.New("emoty account name")
	ErrNoPipelineName = errors.New("empty pipeline name")
	ErrNoTaskType     = errors.New("missing task type")
	ErrSkip           = errors.New("skip task")
)
View Source
var NESTED_VAR = regexp.MustCompile(`\$[a-zA-Z0-9_-]+`)

Functions

func Clone

func Clone(ctx Context, version string, cfg CloneConfig) error

func ConvertTime

func ConvertTime(v string) (string, error)

func CreateVariable

func CreateVariable(v string) string

func Fetch

func Fetch[T any](ctx Context, url string) (*T, error)

func HasVersion

func HasVersion(ver string) bool

func IsFile

func IsFile(v string) bool

func IsTimeExpression

func IsTimeExpression(v string) bool

func IsVariable

func IsVariable(v string) bool

func Json added in v1.18.0

func Json(v any, indent ...string) string

func ParseFile

func ParseFile[T any](fpath string) (*T, error)

ParseFile parses file based on path given to spec

func ParseTime

func ParseTime(v string) (time.Time, error)

func ParseValue

func ParseValue(typ micheline.OpCode, value string) (any, error)

func ReadJsonFile

func ReadJsonFile[T any](name string) (*T, error)

func RegisterEngine

func RegisterEngine(ver string, v EngineFactory)

func Run

func Run(ctx Context, fpath string, mode RunMode) error

Types

type Account

type Account struct {
	Id         int
	Address    tezos.Address
	PrivateKey tezos.PrivateKey
}

type CloneConfig

type CloneConfig struct {
	Name     string
	Contract tezos.Address
	IndexUrl string
	NumOps   uint
	Path     string
	Mode     CloneMode
}

type CloneMode

type CloneMode byte
const (
	CloneModeFile CloneMode = iota
	CloneModeJson
	CloneModeBinary
	CloneModeUrl
	CloneModeArgs
)

func (*CloneMode) Set

func (m *CloneMode) Set(s string) (err error)

func (CloneMode) String

func (m CloneMode) String() string

type Context

type Context struct {
	context.Context
	BaseAccount Account
	MaxId       int
	Accounts    map[tezos.Address]Account
	Contracts   map[tezos.Address]*micheline.Script
	Variables   map[string]string
	Log         log.Logger
	// contains filtered or unexported fields
}

func NewContext

func NewContext(ctx context.Context) Context

func (*Context) AddAccount

func (c *Context) AddAccount(acc Account)

func (*Context) AddVariable

func (c *Context) AddVariable(key, val string)

func (*Context) Cache

func (c *Context) Cache() *PipelineCache

func (Context) Fetch

func (c Context) Fetch(u string, v any) error

func (Context) Filepath

func (c Context) Filepath() string

func (*Context) HeadBlock

func (c *Context) HeadBlock() *rpc.BlockHeaderLogEntry

func (*Context) Init

func (c *Context) Init() (err error)

func (*Context) MakeAccount

func (c *Context) MakeAccount(id int, alias string) (Account, error)

func (*Context) Params

func (c *Context) Params() *tezos.Params

func (*Context) ResolveAddress

func (c *Context) ResolveAddress(val any) (a tezos.Address, err error)

func (*Context) ResolveInt64

func (c *Context) ResolveInt64(val any) (i int64, err error)

func (Context) ResolveNestedVars

func (c Context) ResolveNestedVars(src string) (string, bool)

func (*Context) ResolvePrivateKey

func (c *Context) ResolvePrivateKey(val any) (sk tezos.PrivateKey, err error)

func (*Context) ResolveScript

func (c *Context) ResolveScript(addr tezos.Address) (*micheline.Script, error)

func (*Context) ResolveString

func (c *Context) ResolveString(val any) (string, error)

func (*Context) ResolveZ

func (c *Context) ResolveZ(val any) (z tezos.Z, err error)

func (*Context) RestoreLogger

func (c *Context) RestoreLogger()

func (*Context) Send

func (c *Context) Send(op *codec.Op, opts *rpc.CallOptions) (*rpc.Receipt, error)

func (Context) ShouldResume

func (c Context) ShouldResume() bool

func (*Context) SubscribeBlocks

func (c *Context) SubscribeBlocks(cb rpc.ObserverCallback) (int, error)

func (*Context) SwitchLogger

func (c *Context) SwitchLogger(tag, lvl string)

func (*Context) UnsubscribeBlocks

func (c *Context) UnsubscribeBlocks(id int) error

func (*Context) WaitNumBlocks

func (c *Context) WaitNumBlocks(n int) error

func (*Context) WithApiKey

func (c *Context) WithApiKey(k string) *Context

func (*Context) WithBase

func (c *Context) WithBase(k string) *Context

func (*Context) WithLogger

func (c *Context) WithLogger(l log.Logger) *Context

func (*Context) WithMode

func (c *Context) WithMode(m RunMode) *Context

func (*Context) WithPath

func (c *Context) WithPath(p string) *Context

func (*Context) WithResume

func (c *Context) WithResume(b bool) *Context

func (*Context) WithUrl

func (c *Context) WithUrl(u string) *Context

type Engine

type Engine interface {
	Clone(Context, []Op, CloneConfig) ([]byte, error)
	Validate(Context, string) error
	Run(Context, string) error
}

func New

func New(ver string) Engine

type EngineFactory

type EngineFactory func() Engine

type Op

type Op struct {
	Type       string            `json:"type"`
	Hash       string            `json:"hash"`
	Height     int               `json:"height"`
	OpP        int               `json:"op_p"`
	OpC        int               `json:"op_c"`
	OpI        int               `json:"op_i"`
	IsInternal bool              `json:"is_internal"`
	Sender     string            `json:"sender"`
	Receiver   string            `json:"receiver"`
	Amount     float64           `json:"volume"`
	Script     *micheline.Script `json:"script"`
	Params     *struct {
		Entrypoint string         `json:"entrypoint"`
		Prim       micheline.Prim `json:"prim"`
	} `json:"parameters"`

	// processed
	Url           string `json:"-"`
	PackedCode    string `json:"-"`
	PackedStorage string `json:"-"`
	PackedParams  string `json:"-"`
	Args          any    `json:"-"`
}

type PipelineCache

type PipelineCache struct {
	// contains filtered or unexported fields
}

func NewCache

func NewCache() *PipelineCache

func (PipelineCache) Get

func (c PipelineCache) Get() int

func (*PipelineCache) Load

func (c *PipelineCache) Load(hash uint64, reset bool) error

func (*PipelineCache) Update

func (c *PipelineCache) Update(idx int) error

type RunMode

type RunMode byte
const (
	RunModeValidate RunMode = iota
	RunModeSimulate
	RunModeExecute
)

type Spec

type Spec struct {
	Version  string `yaml:"version"`
	Filename string `yaml:"-"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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