micheline

package
v1.18.4 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2024 License: MIT Imports: 21 Imported by: 2

Documentation

Index

Constants

View Source
const (
	TypeAnnoPrefix  = ":"
	VarAnnoPrefix   = "%"
	FieldAnnoPrefix = "@"
)
View Source
const (
	TypeStruct = "struct"
	TypeUnion  = "union"
)

Extra Types

View Source
const (
	CONST_ENTRYPOINT  = "@entrypoint"
	CONST_KEY         = "@key"
	CONST_VALUE       = "@value"
	CONST_ITEM        = "@item"
	CONST_PARAM       = "@param"
	CONST_RETURN      = "@return"
	CONST_UNION_LEFT  = "@or_0"
	CONST_UNION_RIGHT = "@or_1"
)

Default names

View Source
const (
	PATH_SEPARATOR          = "."
	DEFAULT                 = "default"
	PRIM                    = "prim"
	INT                     = "int"
	BYTES                   = "bytes"
	STRING                  = "string"
	ROOT                    = "root"
	ANNOTS                  = "annots"
	ARGS                    = "args"
	DO                      = "do"
	SET_DELEGATE            = "set_delegate"
	REMOVE_DELEGATE         = "remove_delegate"
	DEPOSIT                 = "deposit"
	STAKE                   = "stake"
	UNSTAKE                 = "unstake"
	FINALIZE_UNSTAKE        = "finalize_unstake"
	SET_DELEGATE_PARAMETERS = "set_delegate_parameters"
)
View Source
const (
	EMPTY_LABEL       = `@%%@` // illegal Michelson annotation value
	RENDER_TYPE_PRIM  = 0      // silently output primitive tree instead if human-readable
	RENDER_TYPE_FAIL  = 1      // return error if human-readable formatting fails
	RENDER_TYPE_PANIC = 2      // panic with error if human-readable formatting fails
	RENDER_TYPE_DEBUG = 3      // return error and primitives
)

Variables

View Source
var (
	IManager     = Interface("MANAGER")
	ISetDelegate = Interface("SET_DELEGATE")
	ITzip5       = Interface("TZIP-005")
	ITzip7       = Interface("TZIP-007")
	ITzip12      = Interface("TZIP-012")

	WellKnownInterfaces = []Interface{
		IManager,
		ISetDelegate,
		ITzip5,
		ITzip7,
		ITzip12,
	}
)
View Source
var (
	InvalidPrim = Prim{}
	EmptyPrim   = Prim{Type: PrimNullary, OpCode: 255}

	PrimSkip        = errors.New("skip branch")
	ErrTypeMismatch = errors.New("type mismatch")
)
View Source
var BigmapRefType = Prim{
	Type:   PrimNullary,
	OpCode: T_INT,
}
View Source
var InterfaceSpecs = map[Interface][]Prim{

	IManager: {

		NewCodeAnno(T_LAMBDA, "%do", NewCode(T_UNIT), NewCode(T_LIST, NewCode(T_OPERATION))),

		NewCodeAnno(T_UNIT, "%default"),
	},

	ISetDelegate: {

		NewCodeAnno(T_OPTION, "%setDelegate", NewCode(T_KEY_HASH)),
	},

	ITzip5: {

		NewPairType(
			NewCodeAnno(T_ADDRESS, ":from"),
			NewPairType(
				NewCodeAnno(T_ADDRESS, ":to"),
				NewCodeAnno(T_NAT, ":value"),
			),
			"%transfer",
		),

		NewPairType(
			NewCodeAnno(T_ADDRESS, ":owner"),
			NewCode(T_CONTRACT, NewCode(T_NAT)),
			"%getBalance",
		),

		NewPairType(
			NewCode(T_UNIT),
			NewCode(T_CONTRACT, NewCode(T_NAT)),
			"%getTotalSupply",
		),
	},

	ITzip7: {

		NewPairType(
			NewCodeAnno(T_ADDRESS, ":from"),
			NewPairType(
				NewCodeAnno(T_ADDRESS, ":to"),
				NewCodeAnno(T_NAT, ":value"),
			),
			"%transfer",
		),

		NewPairType(
			NewCodeAnno(T_ADDRESS, ":spender"),
			NewCodeAnno(T_NAT, ":value"),
			"%approve",
		),

		NewPairType(
			NewPairType(
				NewCodeAnno(T_ADDRESS, ":owner"),
				NewCodeAnno(T_ADDRESS, ":spender"),
			),
			NewCode(T_CONTRACT, NewCode(T_NAT)),
			"%getAllowance",
		),

		NewPairType(
			NewCodeAnno(T_ADDRESS, ":owner"),
			NewCode(T_CONTRACT, NewCode(T_NAT)),
			"%getBalance",
		),

		NewPairType(
			NewCode(T_UNIT),
			NewCode(T_CONTRACT, NewCode(T_NAT)),
			"%getTotalSupply",
		),
	},

	ITzip12: {

		NewCodeAnno(T_LIST, "%transfer",
			NewPairType(
				NewCodeAnno(T_ADDRESS, "%from_"),
				NewCodeAnno(T_LIST, "%txs",
					NewPairType(
						NewCodeAnno(T_ADDRESS, "%to_"),
						NewPairType(
							NewCodeAnno(T_NAT, "%token_id"),
							NewCodeAnno(T_NAT, "%amount"),
						),
					),
				),
			),
		),

		NewCodeAnno(T_LIST, "%update_operators",
			NewCode(T_OR,
				NewPairType(
					NewCodeAnno(T_ADDRESS, "%owner"),
					NewPairType(
						NewCodeAnno(T_ADDRESS, "%operator"),
						NewCodeAnno(T_NAT, "%token_id"),
					),
					"%add_operator",
				),
				NewPairType(
					NewCodeAnno(T_ADDRESS, "%owner"),
					NewPairType(
						NewCodeAnno(T_ADDRESS, "%operator"),
						NewCodeAnno(T_NAT, "%token_id"),
					),
					"%remove_operator",
				),
			),
		),
	},
}

WellKnownInterfaces contains entrypoint types for standard call interfaces and other known contracts.

View Source
var (
	Unit = NewCode(D_UNIT)
)

Functions

func DetectBigmapTypes

func DetectBigmapTypes(typ Prim) map[string]Type

Returns a map of all known bigmap type definitions inside a given prim. Keys are derived from type annotations. Unlabeled bigmaps are prefixed `bigmap_` followed by a unique sequence number. Duplicate names are prevented by adding by a unique sequence number as well.

func DetectBigmaps

func DetectBigmaps(typ, storage Prim) map[string]int64

Returns a map of named bigmap ids obtained from a storage type and a storage value. In the edge case where a T_OR branch hides an exsting bigmap behind a None value, the hidden bigmap is not detected.

func DisableLog

func DisableLog()

DisableLog disables all library log output. Logging output is disabled by default until either UseLogger or SetLogWriter are called.

func IsEqualPrim

func IsEqualPrim(p1, p2 Prim, withAnno bool) bool

func IsManagerTz

func IsManagerTz(buf []byte) bool

func KeyHash

func KeyHash(buf []byte) mavryk.ExprHash

func Trace

func Trace(fn func(log LogFn))

Trace is a function closure wrapper that forwards trace calls to an output function if set. Call UseTrace() to set a function of type LogFn

func UnmarshalScriptType

func UnmarshalScriptType(data []byte) (param Type, storage Type, err error)

UnmarshalScriptType is an optimized binary unmarshaller which decodes type trees only. Use this to access smart contract types when script and storage are not required.

func UseLogger

func UseLogger(logger logpkg.Logger)

UseLogger uses a specified Logger to output package logging info. This should be used in preference to SetLogWriter if the caller is also using logpkg.

Types

type BigmapEvent

type BigmapEvent struct {
	Action    DiffAction      `json:"action"`
	Id        int64           `json:"big_map,string"`
	KeyHash   mavryk.ExprHash `json:"key_hash"`                   // update/remove
	Key       Prim            `json:"key"`                        // update/remove
	Value     Prim            `json:"value"`                      // update
	KeyType   Prim            `json:"key_type"`                   // alloc
	ValueType Prim            `json:"value_type"`                 // alloc
	SourceId  int64           `json:"source_big_map,string"`      // copy
	DestId    int64           `json:"destination_big_map,string"` // copy
}

func (BigmapEvent) Encoding

func (e BigmapEvent) Encoding() PrimType

func (BigmapEvent) GetKey

func (e BigmapEvent) GetKey(typ Type) Key

func (BigmapEvent) GetKeyPtr

func (e BigmapEvent) GetKeyPtr(typ Type) *Key

func (BigmapEvent) MarshalJSON

func (e BigmapEvent) MarshalJSON() ([]byte, error)

func (*BigmapEvent) UnmarshalJSON

func (e *BigmapEvent) UnmarshalJSON(data []byte) error

type BigmapEvents

type BigmapEvents []BigmapEvent

func (BigmapEvents) Filter

func (l BigmapEvents) Filter(id int64) BigmapEvents

func (BigmapEvents) MarshalBinary

func (b BigmapEvents) MarshalBinary() ([]byte, error)

func (*BigmapEvents) UnmarshalBinary

func (b *BigmapEvents) UnmarshalBinary(data []byte) error

type Ciphertext

type Ciphertext struct {
	Cv         []byte
	Epk        []byte
	PayloadEnc []byte
	NonceEnc   []byte
	PayloadOut []byte
	NonceOut   []byte
}

func (Ciphertext) MarshalJSON

func (c Ciphertext) MarshalJSON() ([]byte, error)

TODO

func (*Ciphertext) UnmarshalJSON

func (c *Ciphertext) UnmarshalJSON(data []byte) error

type Code

type Code struct {
	Param   Prim // call types
	Storage Prim // storage types
	Code    Prim // program code
	View    Prim // view code (i.e. list of views, may be empty)
	BadCode Prim // catch-all for ill-formed contracts
}

func (*Code) DecodeBuffer

func (c *Code) DecodeBuffer(buf *bytes.Buffer) error

func (Code) MarshalBinary

func (c Code) MarshalBinary() ([]byte, error)

func (Code) MarshalJSON

func (c Code) MarshalJSON() ([]byte, error)

func (*Code) UnmarshalBinary

func (c *Code) UnmarshalBinary(data []byte) error

func (*Code) UnmarshalJSON

func (c *Code) UnmarshalJSON(data []byte) error

type ConstantDict

type ConstantDict map[string]Prim

func (*ConstantDict) Add

func (d *ConstantDict) Add(address mavryk.ExprHash, value Prim)

func (ConstantDict) Get

func (d ConstantDict) Get(address mavryk.ExprHash) (Prim, bool)

func (ConstantDict) GetString

func (d ConstantDict) GetString(address string) (Prim, bool)

func (ConstantDict) Has

func (d ConstantDict) Has(address mavryk.ExprHash) bool

type DiffAction

type DiffAction byte
const (
	DiffActionUpdate DiffAction = iota
	DiffActionRemove
	DiffActionCopy
	DiffActionAlloc
)

func ParseDiffAction

func ParseDiffAction(data string) (DiffAction, error)

func (DiffAction) MarshalText

func (a DiffAction) MarshalText() ([]byte, error)

func (DiffAction) String

func (a DiffAction) String() string

func (*DiffAction) UnmarshalText

func (a *DiffAction) UnmarshalText(data []byte) error

type Entrypoint

type Entrypoint struct {
	Id      int       `json:"id"`
	Name    string    `json:"name"`
	Branch  string    `json:"branch"`
	Typedef []Typedef `json:"type"`
	Prim    *Prim     `json:"prim,omitempty"`
}

func (Entrypoint) IsCallback

func (e Entrypoint) IsCallback() bool

func (Entrypoint) Type

func (e Entrypoint) Type() Type

type Entrypoints

type Entrypoints map[string]Entrypoint

func (Entrypoints) FindBranch

func (e Entrypoints) FindBranch(branch string) (Entrypoint, bool)

func (Entrypoints) FindId

func (e Entrypoints) FindId(id int) (Entrypoint, bool)

type Features

type Features uint16
const (
	FeatureSpendable Features = 1 << iota
	FeatureDelegatable
	FeatureAccountFactory
	FeatureContractFactory
	FeatureSetDelegate
	FeatureLambda
	FeatureTransferTokens
	FeatureChainId
	FeatureTicket
	FeatureSapling
	FeatureView
	FeatureGlobalConstant
	FeatureTimelock
)

func (Features) Array

func (f Features) Array() []string

func (Features) Contains

func (f Features) Contains(x Features) bool

func (Features) MarshalJSON

func (f Features) MarshalJSON() ([]byte, error)

func (Features) String

func (f Features) String() string

type GenericEvent

type GenericEvent struct {
	EventKind LazyKind `json:"kind"`
	ObjectId  int64    `json:"id,string"`
}

func (*GenericEvent) Id

func (d *GenericEvent) Id() int64

func (*GenericEvent) Kind

func (d *GenericEvent) Kind() LazyKind

type Interface

type Interface string

func (Interface) Contains

func (m Interface) Contains(e Entrypoint) bool

func (Interface) ContainsStrict

func (m Interface) ContainsStrict(e Entrypoint) bool

func (Interface) Matches

func (m Interface) Matches(e Entrypoints) bool

Checks if a contract implements all entrypoints required by a standard interface without requiring argument labels to match. This is a looser definition of interface compliance, but in line with the Michelson type system which ignores annotation labels for type equality.

This check uses extracted Typedefs to avoid issues when the Micheline primitive structure diverges from the defined interface (e.g. due to comb type unfolding).

func (Interface) MatchesStrict

func (m Interface) MatchesStrict(e Entrypoints) bool

Checks if a contract strictly implements all standard interface entrypoints including argument types and argument names (annotations).

This check uses extracted Typedefs to avoid issues when the Micheline primitive structure diverges from the defined interface (e.g. due to comb type unfolding).

func (Interface) PrimOf

func (m Interface) PrimOf(name string) Prim

func (Interface) String

func (m Interface) String() string

func (Interface) TypeOf

func (m Interface) TypeOf(name string) Type

type Interfaces

type Interfaces []Interface

func (Interfaces) Contains

func (i Interfaces) Contains(x Interface) bool

func (Interfaces) MarshalJSON

func (i Interfaces) MarshalJSON() ([]byte, error)

func (Interfaces) MarshalText

func (i Interfaces) MarshalText() ([]byte, error)

func (*Interfaces) Parse

func (i *Interfaces) Parse(s string) error

func (Interfaces) String

func (i Interfaces) String() string

func (*Interfaces) UnmarshalText

func (i *Interfaces) UnmarshalText(b []byte) error

type Key

type Key struct {
	Type Type
	// TODO: refactor into simple Prim
	IntKey       *big.Int
	StringKey    string
	BytesKey     []byte
	BoolKey      bool
	AddrKey      mavryk.Address
	KeyKey       mavryk.Key
	SignatureKey mavryk.Signature
	TimeKey      time.Time
	PrimKey      Prim
}

Comparable key as used in bigmaps and maps

func DecodeKey

func DecodeKey(typ Type, b []byte) (Key, error)

func NewKey

func NewKey(typ Type, key Prim) (Key, error)

func NewKeyPtr

func NewKeyPtr(typ Type, key Prim) (*Key, error)

func ParseKey

func ParseKey(typ OpCode, val string) (Key, error)

query string parsing used for lookup

func (Key) Bytes

func (k Key) Bytes() []byte

func (Key) Hash

func (k Key) Hash() mavryk.ExprHash

func (Key) IsPacked

func (k Key) IsPacked() bool

func (Key) MarshalBinary

func (k Key) MarshalBinary() ([]byte, error)

func (Key) MarshalJSON

func (k Key) MarshalJSON() ([]byte, error)

func (Key) Prim

func (k Key) Prim() Prim

func (Key) PrimPtr

func (k Key) PrimPtr() *Prim

func (Key) String

func (k Key) String() string

func (Key) Unpack

func (k Key) Unpack() (Key, error)

func (Key) UnpackPrim

func (k Key) UnpackPrim() (p Prim, err error)

type LazyBigmapEvent

type LazyBigmapEvent struct {
	BigmapId int64 `json:"id,string"`
	Diff     struct {
		Action  DiffAction `json:"action"`
		Updates []struct {
			KeyHash mavryk.ExprHash `json:"key_hash"` // update/remove
			Key     Prim            `json:"key"`      // update/remove
			Value   Prim            `json:"value"`    // update
		} `json:"updates"` // update
		KeyType   Prim  `json:"key_type"`      // alloc
		ValueType Prim  `json:"value_type"`    // alloc
		SourceId  int64 `json:"source,string"` // copy
	} `json:"diff"`
}

func (*LazyBigmapEvent) Id

func (d *LazyBigmapEvent) Id() int64

func (*LazyBigmapEvent) Kind

func (d *LazyBigmapEvent) Kind() LazyKind

type LazyEvent

type LazyEvent interface {
	Kind() LazyKind
	Id() int64
}

type LazyEvents

type LazyEvents []LazyEvent

func (LazyEvents) BigmapEvents

func (d LazyEvents) BigmapEvents() BigmapEvents

func (*LazyEvents) UnmarshalJSON

func (d *LazyEvents) UnmarshalJSON(data []byte) error

type LazyKind

type LazyKind string
const (
	LazyKindInvalid LazyKind = ""
	LazyKindBigmap  LazyKind = "big_map"
	LazyKindSapling LazyKind = "sapling_state"
)

func ParseLazyKind

func ParseLazyKind(data string) LazyKind

func (LazyKind) IsValid

func (k LazyKind) IsValid() bool

func (LazyKind) MarshalText

func (k LazyKind) MarshalText() ([]byte, error)

func (LazyKind) String

func (k LazyKind) String() string

func (*LazyKind) UnmarshalText

func (k *LazyKind) UnmarshalText(data []byte) error

type LazySaplingEvent

type LazySaplingEvent struct {
	PoolId int64           `json:"id,string"`
	Diff   SaplingDiffElem `json:"diff"`
}

func (*LazySaplingEvent) Id

func (d *LazySaplingEvent) Id() int64

func (*LazySaplingEvent) Kind

func (d *LazySaplingEvent) Kind() LazyKind

type LogFn

type LogFn logpkg.LogfFn

LogFn is a shot alias for a log function of type func(string, interface...)

type OpCode

type OpCode byte
const (
	// Keys
	K_PARAMETER OpCode = iota // 00
	K_STORAGE                 // 01
	K_CODE                    // 02

	// Data
	D_FALSE // 03
	D_ELT   // 04
	D_LEFT  // 05
	D_NONE  // 06
	D_PAIR  // 07
	D_RIGHT // 08
	D_SOME  // 09
	D_TRUE  // 0A
	D_UNIT  // 0B

	// instructions
	I_PACK             // 0C
	I_UNPACK           // 0D
	I_BLAKE2B          // 0E
	I_SHA256           // 0F
	I_SHA512           // 10
	I_ABS              // 11
	I_ADD              // 12
	I_AMOUNT           // 13
	I_AND              // 14
	I_BALANCE          // 15
	I_CAR              // 16
	I_CDR              // 17
	I_CHECK_SIGNATURE  // 18
	I_COMPARE          // 19
	I_CONCAT           // 1A
	I_CONS             // 1B
	I_CREATE_ACCOUNT   // 1C
	I_CREATE_CONTRACT  // 1D
	I_IMPLICIT_ACCOUNT // 1E
	I_DIP              // 1F
	I_DROP             // 20
	I_DUP              // 21
	I_EDIV             // 22
	I_EMPTY_MAP        // 23
	I_EMPTY_SET        // 24
	I_EQ               // 25
	I_EXEC             // 26
	I_FAILWITH         // 27
	I_GE               // 28
	I_GET              // 29
	I_GT               // 2A
	I_HASH_KEY         // 2B
	I_IF               // 2C
	I_IF_CONS          // 2D
	I_IF_LEFT          // 2E
	I_IF_NONE          // 2F
	I_INT              // 30
	I_LAMBDA           // 31
	I_LE               // 32
	I_LEFT             // 33
	I_LOOP             // 34
	I_LSL              // 35
	I_LSR              // 36
	I_LT               // 37
	I_MAP              // 38
	I_MEM              // 39
	I_MUL              // 3A
	I_NEG              // 3B
	I_NEQ              // 3C
	I_NIL              // 3D
	I_NONE             // 3E
	I_NOT              // 3F
	I_NOW              // 40
	I_OR               // 41
	I_PAIR             // 42
	I_PUSH             // 43
	I_RIGHT            // 44
	I_SIZE             // 45
	I_SOME             // 46
	I_SOURCE           // 47
	I_SENDER           // 48
	I_SELF             // 49
	I_STEPS_TO_QUOTA   // 4A
	I_SUB              // 4B
	I_SWAP             // 4C
	I_TRANSFER_TOKENS  // 4D
	I_SET_DELEGATE     // 4E
	I_UNIT             // 4F
	I_UPDATE           // 50
	I_XOR              // 51
	I_ITER             // 52
	I_LOOP_LEFT        // 53
	I_ADDRESS          // 54
	I_CONTRACT         // 55
	I_ISNAT            // 56
	I_CAST             // 57
	I_RENAME           // 58

	// Types
	T_BOOL      // 59
	T_CONTRACT  // 5A
	T_INT       // 5B
	T_KEY       // 5C
	T_KEY_HASH  // 5D
	T_LAMBDA    // 5E
	T_LIST      // 5F
	T_MAP       // 60
	T_BIG_MAP   // 61
	T_NAT       // 62
	T_OPTION    // 63
	T_OR        // 64
	T_PAIR      // 65
	T_SET       // 66
	T_SIGNATURE // 67
	T_STRING    // 68
	T_BYTES     // 69
	T_MUMAV     // 6A
	T_TIMESTAMP // 6B
	T_UNIT      // 6C
	T_OPERATION // 6D
	T_ADDRESS   // 6E

	// v002 addition
	I_SLICE // 6F

	// v005 addition
	// https://blog.nomadic-labs.com/michelson-updates-in-005.html
	I_DIG           // 70
	I_DUG           // 71
	I_EMPTY_BIG_MAP // 72
	I_APPLY         // 73
	T_CHAIN_ID      // 74
	I_CHAIN_ID      // 75

	// v008 additions
	I_LEVEL              // 76
	I_SELF_ADDRESS       // 77
	T_NEVER              // 78
	I_NEVER              // 79
	I_UNPAIR             // 7A
	I_VOTING_POWER       // 7B
	I_TOTAL_VOTING_POWER // 7C
	I_KECCAK             // 7D
	I_SHA3               // 7E
	I_PAIRING_CHECK      // 7F
	T_BLS12_381_G1       // 80
	T_BLS12_381_G2       // 81
	T_BLS12_381_FR       // 82
	T_SAPLING_STATE      // 83

	I_SAPLING_EMPTY_STATE   // 85
	I_SAPLING_VERIFY_UPDATE // 86
	T_TICKET                // 87

	I_READ_TICKET    // 89
	I_SPLIT_TICKET   // 8A
	I_JOIN_TICKETS   // 8B
	I_GET_AND_UPDATE // 8C

	// v011 additions
	T_CHEST      // 8D
	T_CHEST_KEY  // 8E
	I_OPEN_CHEST // 8F
	I_VIEW       // 90
	K_VIEW       // 91
	H_CONSTANT   // 92

	// v012 additions
	I_SUB_MUMAV // 93

	// v013 additions
	T_TX_ROLLUP_L2_ADDRESS // 94
	I_MIN_BLOCK_TIME       // 95
	T_SAPLING_TRANSACTION  // 96

	// v014 additions
	I_EMIT // 97

	// v015 additions
	D_LAMBDA_REC // 98
	I_LAMBDA_REC // 99
	I_TICKET     // 9A

	// v016 additions
	I_BYTES // 9B
	I_NAT   // 9C
)

Michelson V1 Primitives

func InferKeyType

func InferKeyType(val string) OpCode

func ParseKeyType

func ParseKeyType(typ string) (OpCode, error)

func ParseOpCode

func ParseOpCode(str string) (OpCode, error)

func (OpCode) Byte

func (o OpCode) Byte() byte

func (OpCode) IsKeyCode

func (op OpCode) IsKeyCode() bool

func (OpCode) IsTypeCode

func (op OpCode) IsTypeCode() bool

func (OpCode) IsValid

func (op OpCode) IsValid() bool

func (OpCode) MarshalText

func (op OpCode) MarshalText() ([]byte, error)

func (OpCode) PrimType

func (op OpCode) PrimType() PrimType

func (OpCode) String

func (op OpCode) String() string

func (OpCode) TypeCode

func (op OpCode) TypeCode() OpCode

type Parameters

type Parameters struct {
	Entrypoint string `json:"entrypoint"`
	Value      Prim   `json:"value"`
}

func (Parameters) Branch

func (p Parameters) Branch(prefix string, eps Entrypoints) string

func (*Parameters) DecodeBuffer

func (p *Parameters) DecodeBuffer(buf *bytes.Buffer) error

func (Parameters) EncodeBuffer

func (p Parameters) EncodeBuffer(buf *bytes.Buffer) error

func (Parameters) MapEntrypoint

func (p Parameters) MapEntrypoint(typ Type) (Entrypoint, Prim, error)

func (Parameters) MarshalBinary

func (p Parameters) MarshalBinary() ([]byte, error)

func (Parameters) MarshalJSON

func (p Parameters) MarshalJSON() ([]byte, error)

func (*Parameters) UnmarshalBinary

func (p *Parameters) UnmarshalBinary(data []byte) error

func (*Parameters) UnmarshalJSON

func (p *Parameters) UnmarshalJSON(data []byte) error

func (Parameters) Unwrap

func (p Parameters) Unwrap(branch string) Prim

type Prim

type Prim struct {
	Type      PrimType // primitive type
	OpCode    OpCode   // primitive opcode (invalid on sequences, strings, bytes, int)
	Args      PrimList // optional arguments
	Anno      []string // optional type annotations
	Int       *big.Int // optional data
	String    string   // optional data
	Bytes     []byte   // optional data
	WasPacked bool     // true when content was unpacked (and no type info is available)
	Path      []int    // optional path to this prim (use to track type structure)
}

func ASSERT_CMPEQ

func ASSERT_CMPEQ() Prim

Macros

func DELEGATE_ENTRY

func DELEGATE_ENTRY() Prim

'set_delegate'/'remove_delegate' entrypoints

func DO_ENTRY

func DO_ENTRY() Prim

Macros

func DUUP

func DUUP() Prim

func IFCMPNEQ

func IFCMPNEQ(left, right Prim) Prim

func NewAddress

func NewAddress(a mavryk.Address) Prim

func NewBig

func NewBig(i *big.Int) Prim

func NewBigmapRef

func NewBigmapRef(id int64) Prim

func NewBigmapRefType

func NewBigmapRefType(anno string) Prim

func NewBytes

func NewBytes(b []byte) Prim

func NewCode

func NewCode(c OpCode, args ...Prim) Prim

func NewCodeAnno

func NewCodeAnno(c OpCode, anno string, args ...Prim) Prim

func NewCombPair

func NewCombPair(contents ...Prim) Prim

func NewCombPairType

func NewCombPairType(contents ...Prim) Prim

func NewInt64

func NewInt64(i int64) Prim

func NewKeyHash

func NewKeyHash(a mavryk.Address) Prim

func NewMap

func NewMap(elts ...Prim) Prim

func NewMapElem

func NewMapElem(k, v Prim) Prim

func NewMapType

func NewMapType(k, v Prim, anno ...string) Prim

func NewMumav

func NewMumav(n mavryk.N) Prim

func NewNat

func NewNat(i *big.Int) Prim

func NewOptType

func NewOptType(e Prim, anno ...string) Prim

func NewOption

func NewOption(p ...Prim) Prim

func NewPair

func NewPair(l, r Prim) Prim

func NewPairType

func NewPairType(l, r Prim, anno ...string) Prim

func NewPrim

func NewPrim(c OpCode, anno ...string) Prim

func NewSeq

func NewSeq(args ...Prim) Prim

func NewSetType

func NewSetType(e Prim, anno ...string) Prim

func NewString

func NewString(s string) Prim

func NewUnion

func NewUnion(path []int, prim Prim) Prim

func NewZ

func NewZ(z mavryk.Z) Prim

func ParsePrim

func ParsePrim(typ Typedef, val string, optimized bool) (p Prim, err error)

func TicketValue

func TicketValue(v Prim, ticketer mavryk.Address, amount mavryk.Z) Prim

Wraps ticket content into structure that is compatible with ticket type. This is necessary for transfer_ticket calls which use explicit fields for value, amount and ticketer.

func UNPAIR

func UNPAIR() Prim

func (Prim) BuildType

func (p Prim) BuildType() Type

build matching type tree for value

func (Prim) CanUnfold

func (p Prim) CanUnfold(typ Type) bool

Detects whether a primitive contains a regular pair or any form of container type. Pairs can be unfolded into flat sequences.

func (Prim) CanUnfoldType

func (p Prim) CanUnfoldType() bool

func (Prim) Clone

func (p Prim) Clone() Prim

func (Prim) CloneNoAnnots

func (p Prim) CloneNoAnnots() Prim

func (Prim) Compare

func (p Prim) Compare(p2 Prim) int

func (Prim) Constants

func (p Prim) Constants() []mavryk.ExprHash

func (Prim) ContainsOpCode

func (p Prim) ContainsOpCode(typ OpCode) bool

func (Prim) Decode

func (p Prim) Decode(v interface{}) error

Decode unmarshals a prim tree into a Go struct. The mapping uses Go struct tags to define primitive paths that are mapped to each struct member. Types are converted between Micheline and Go when possible.

Examples of struct field tags and their meanings:

// maps Micheline path 0/0/0 to string field and fails on type mismatch
Field string `prim:",path=0/0/1"`

// ignore type errors and do not update struct field
Field string  `prim:",path=0/0/1,nofail"`

// ignore struct field
Field string  `prim:"-"`

func (*Prim) DecodeBuffer

func (p *Prim) DecodeBuffer(buf *bytes.Buffer) error

func (Prim) Dump

func (p Prim) Dump() string

func (Prim) DumpLimit

func (p Prim) DumpLimit(n int) string

func (Prim) EncodeBuffer

func (p Prim) EncodeBuffer(buf *bytes.Buffer) error

func (Prim) EncodeJSON

func (p Prim) EncodeJSON(buf *bytes.Buffer)

func (Prim) Features

func (p Prim) Features() Features

func (Prim) FindBigmapByName

func (p Prim) FindBigmapByName(name string) (Prim, bool)

func (Prim) FindLabel

func (p Prim) FindLabel(label string) (Prim, bool)

FindLabel searches a nested type annotation path. Must be used on a type prim. Path segments are separated by dot (.)

func (Prim) FindLabels

func (p Prim) FindLabels(label string) ([]Prim, bool)

func (Prim) FindOpCodes

func (p Prim) FindOpCodes(typ OpCode) ([]Prim, bool)

func (Prim) FoldPair

func (p Prim) FoldPair() Prim

Turns a pair sequence into a right-hand pair tree

func (Prim) GetFieldAnno

func (p Prim) GetFieldAnno() string

func (Prim) GetFieldAnnoAny

func (p Prim) GetFieldAnnoAny() string

prefers FieldAnno, first anno otherwise

func (Prim) GetIndex

func (p Prim) GetIndex(index []int) (Prim, error)

GetIndex returns a nested primitive at path index.

func (Prim) GetIndexExt

func (p Prim) GetIndexExt(index []int, typ OpCode) (Prim, error)

GetIndex returns a nested primitive at path index if the primitive matches the expected opcode. This only works on type trees. Value trees lack opcode info.

func (Prim) GetPath

func (p Prim) GetPath(path string) (Prim, error)

GetPath returns a nested primitive at path. Path segments are separated by slash (/). Works on both type and value primitive trees.

func (Prim) GetPathExt

func (p Prim) GetPathExt(path string, typ OpCode) (Prim, error)

GetPathExt returns a nested primitive at path if the primitive matches the expected opcode. Path segments are separated by slash (/). Works on both type and value primitive trees.

func (Prim) GetTypeAnno

func (p Prim) GetTypeAnno() string

func (Prim) GetTypeAnnoAny

func (p Prim) GetTypeAnnoAny() string

prefers TypeAnno, first anno otherwise

func (Prim) GetVarAnno

func (p Prim) GetVarAnno() string

func (Prim) GetVarAnnoAny

func (p Prim) GetVarAnnoAny() string

prefers VarAnno, first anno otherwise

func (Prim) GetVarOrFieldAnno

func (p Prim) GetVarOrFieldAnno() string

func (Prim) HasAnno

func (p Prim) HasAnno() bool

func (Prim) HasFieldAnno

func (p Prim) HasFieldAnno() bool

func (Prim) HasIndex

func (p Prim) HasIndex(index []int) bool

HasIndex returns true when a nested primitive exists at path defined by index.

func (Prim) HasSimilarChildTypes

func (p Prim) HasSimilarChildTypes() bool

Checks if all children have the same type by generating a type tree from values. Can be used to identfy containers based on the existence of similar records.

Works for simple and nested primitives but may mis-detect ambiguous simple types like PrimInt (used for int, nat, timestamp, mumav), or PrimString resp. PrimBytes. May also misdetect when optional types like T_OR, T_OPTION are used and their values are nil since we cannot detect embedded type here.

func (Prim) HasTypeAnno

func (p Prim) HasTypeAnno() bool

func (Prim) HasVarAnno

func (p Prim) HasVarAnno() bool

func (Prim) HasVarOrFieldAnno

func (p Prim) HasVarOrFieldAnno() bool

func (Prim) Hash64

func (p Prim) Hash64() uint64

func (Prim) Implements

func (p Prim) Implements(t Type) bool

func (Prim) ImplementsType

func (p Prim) ImplementsType(t Typedef) bool

func (*Prim) Insert

func (p *Prim) Insert(src Prim, path []int)

func (Prim) IsConstant

func (p Prim) IsConstant() bool

func (Prim) IsContainerType

func (p Prim) IsContainerType() bool

func (Prim) IsConvertedComb

func (p Prim) IsConvertedComb() bool

Checks if a Prim looks like an optimized (i.e. flat) comb sequence.

func (Prim) IsElt

func (p Prim) IsElt() bool

func (Prim) IsEmpty

func (p Prim) IsEmpty() bool

func (Prim) IsEmptyBigmap

func (p Prim) IsEmptyBigmap() bool

func (Prim) IsEqual

func (p Prim) IsEqual(p2 Prim) bool

func (Prim) IsEqualWithAnno

func (p Prim) IsEqualWithAnno(p2 Prim) bool

func (Prim) IsInstruction

func (p Prim) IsInstruction() bool

func (Prim) IsLambda

func (p Prim) IsLambda() bool

func (Prim) IsList

func (p Prim) IsList() bool

func (Prim) IsMap

func (p Prim) IsMap() bool

func (Prim) IsNil

func (p Prim) IsNil() bool

func (Prim) IsPacked

func (p Prim) IsPacked() bool

Checks if a primitve contains a packed value such as a byte sequence generated with PACK (starting with 0x05), an address or ascii/utf string.

func (Prim) IsPackedAny

func (p Prim) IsPackedAny() bool

func (Prim) IsPair

func (p Prim) IsPair() bool

func (Prim) IsScalar

func (p Prim) IsScalar() bool

returns true when the prim can be expressed as a single value key/value pairs (ie. prims with annots) do not fit into this category used when mapping complex big map values to JSON objects

func (Prim) IsScalarType

func (p Prim) IsScalarType() bool

func (Prim) IsSequence

func (p Prim) IsSequence() bool

func (Prim) IsSet

func (p Prim) IsSet() bool

func (Prim) IsTicket

func (p Prim) IsTicket() bool

func (Prim) IsValid

func (p Prim) IsValid() bool

func (Prim) LabelIndex

func (p Prim) LabelIndex(label string) ([]int, bool)

LabelIndex returns the indexed path to a type annotation label and true if path exists. Path segments are separated by dot (.)

func (Prim) LooksLikeCode

func (p Prim) LooksLikeCode() bool

Checks if a Prim looks like a lambda type.

func (Prim) LooksLikeContainer

func (p Prim) LooksLikeContainer() bool

Checks if a Prim looks like a container type. This is necessary to distinguish optimized comb pairs from other container types.

func (Prim) LooksLikeMap

func (p Prim) LooksLikeMap() bool

func (Prim) LooksLikeSet

func (p Prim) LooksLikeSet() bool

func (Prim) MarshalBinary

func (p Prim) MarshalBinary() ([]byte, error)

func (Prim) MarshalJSON

func (p Prim) MarshalJSON() ([]byte, error)

func (Prim) MarshalYAML

func (p Prim) MarshalYAML() (any, error)

func (Prim) MatchesAnno

func (p Prim) MatchesAnno(anno string) bool

func (Prim) MigrateToBabylonStorage

func (p Prim) MigrateToBabylonStorage(managerHash []byte) Prim

func (Prim) Pack

func (p Prim) Pack() []byte

Packs produces a packed serialization for of a primitive's contents that is prefixed with a 0x5 byte.

func (*Prim) SetIndex

func (p *Prim) SetIndex(index []int, dst Prim) error

SetIndex replaces a nested primitive at path index with dst.

func (*Prim) SetIndexExt

func (p *Prim) SetIndexExt(index []int, typ PrimType, dst Prim) error

SetIndexExt replaces a nested primitive at path index if the primitive matches the expected primitive type. This function works best with value trees which lack opcode info. Use as extra cross-check when replacing prims.

func (*Prim) SetPath

func (p *Prim) SetPath(path string, dst Prim) error

SetPath replaces a nested primitive at path with dst. Path segments are separated by slash (/). Works on both type and value primitive trees.

func (*Prim) SetPathExt

func (p *Prim) SetPathExt(path string, typ PrimType, dst Prim) error

SetPathExt replaces a nested primitive at path with dst if the primitive matches the expected type. Path segments are separated by slash (/). Works on best on value primitive trees.

func (Prim) Size

func (p Prim) Size() int

func (*Prim) StripAnno

func (p *Prim) StripAnno(name string)

func (Prim) ToBytes

func (p Prim) ToBytes() []byte

func (Prim) UnfoldPair

func (p Prim) UnfoldPair(typ Type) []Prim

Converts a pair tree into a flat sequence. While Michelson optimized comb pairs are only used for right-side combs, this function applies to all pairs. It makes use of the type definition to identify which contained type is a regular pair, an already unfolded pair sequence or anther container type.

- Works both on value trees and type trees. - When called on already converted comb sequences this function is a noop.

func (Prim) UnfoldPairRecursive

func (p Prim) UnfoldPairRecursive(typ Type) []Prim

func (Prim) UnfoldTypeRecursive

func (p Prim) UnfoldTypeRecursive(path []int) []Prim

func (*Prim) UnmarshalBinary

func (p *Prim) UnmarshalBinary(data []byte) error

func (*Prim) UnmarshalJSON

func (p *Prim) UnmarshalJSON(data []byte) error

func (Prim) Unpack

func (p Prim) Unpack() (pp Prim, err error)

Unpacks all primitive contents that looks like packed and returns a new primitive tree.

func (Prim) UnpackAll

func (p Prim) UnpackAll() (Prim, error)

func (Prim) UnpackAllAsciiStrings

func (p Prim) UnpackAllAsciiStrings() Prim

UnpackAllAsciiStrings recursively converts all ASCII strings inside byte prims.

func (Prim) UnpackAsciiString

func (p Prim) UnpackAsciiString() Prim

UnpackAsciiString converts ASCII strings inside byte prims.

func (*Prim) UnpackJSON

func (p *Prim) UnpackJSON(val any) error

func (*Prim) UnpackPrimitive

func (p *Prim) UnpackPrimitive(val map[string]any) error

func (*Prim) UnpackSequence

func (p *Prim) UnpackSequence(val []any) error

func (Prim) Value

func (p Prim) Value(as OpCode) interface{}

Returns a typed/decoded value from an encoded primitive.

func (*Prim) Visit

func (p *Prim) Visit(f PrimVisitorFunc) error

Visit traverses the prim tree in pre-order and allows the callback to alter the contents of a visited node.

func (Prim) Walk

func (p Prim) Walk(f PrimWalkerFunc) error

Walk traverses the prim tree in pre-order in read-only mode, forwarding value copies to the callback.

func (Prim) WithAnno

func (p Prim) WithAnno(anno string) Prim

type PrimList

type PrimList []Prim

func (PrimList) Last

func (l PrimList) Last() Prim

type PrimMarshaler

type PrimMarshaler interface {
	MarshalPrim() (Prim, error)
}

type PrimType

type PrimType byte
const (
	PrimInt          PrimType = iota // 00 {name: 'int'}
	PrimString                       // 01 {name: 'string'}
	PrimSequence                     // 02 []
	PrimNullary                      // 03 {name: 'prim', len: 0, annots: false},
	PrimNullaryAnno                  // 04 {name: 'prim', len: 0, annots: true},
	PrimUnary                        // 05 {name: 'prim', len: 1, annots: false},
	PrimUnaryAnno                    // 06 {name: 'prim', len: 1, annots: true},
	PrimBinary                       // 07 {name: 'prim', len: 2, annots: false},
	PrimBinaryAnno                   // 08 {name: 'prim', len: 2, annots: true},
	PrimVariadicAnno                 // 09 {name: 'prim', len: n, annots: true},
	PrimBytes                        // 0A {name: 'bytes' }
)

func ParsePrimType

func ParsePrimType(val string) (PrimType, error)

func (PrimType) IsValid

func (t PrimType) IsValid() bool

func (PrimType) MarshalText

func (t PrimType) MarshalText() ([]byte, error)

func (PrimType) String

func (t PrimType) String() string

non-normative strings, use for debugging only

func (PrimType) TypeCode

func (t PrimType) TypeCode() OpCode

type PrimUnmarshaler

type PrimUnmarshaler interface {
	UnmarshalPrim(Prim) error
}

type PrimVisitorFunc

type PrimVisitorFunc func(p *Prim) error

PrimWalkerFunc is the callback function signature used while traversing a prim tree. The callback may change the contents of the visited node, including altering nested child nodes and annotations.

type PrimWalkerFunc

type PrimWalkerFunc func(p Prim) error

PrimWalkerFunc is the callback function signature used while traversing a prim tree in read-only mode.

type SaplingDiffElem

type SaplingDiffElem struct {
	Action   DiffAction    `json:"action"`
	Updates  SaplingUpdate `json:"updates"`
	MemoSize int           `json:"memo_size"`
}

type SaplingUpdate

type SaplingUpdate struct {
	Commitments [][]byte     `json:"commitments"`
	Ciphertexts []Ciphertext `json:"ciphertexts"`
	Nullifiers  [][]byte     `json:"nullifiers"`
}

type Script

type Script struct {
	Code    Code `json:"code"`    // code section, i.e. parameter & storage types, code
	Storage Prim `json:"storage"` // data section, i.e. initial contract storage
}

func MakeManagerScript

func MakeManagerScript(managerHash []byte) (*Script, error)

func NewScript

func NewScript() *Script

func (Script) BigmapTypes

func (s Script) BigmapTypes() map[string]Type

Returns a map of all known bigmap type definitions inside the scripts storage type. Unlabeled bigmaps are prefixed `bigmap_` followed by a unique sequence number. Duplicate names are prevented by adding by a unique sequence number as well.

func (Script) Bigmaps

func (s Script) Bigmaps() map[string]int64

Returns named bigmap ids from the script's storage type and current value.

func (Script) CodeHash

func (s Script) CodeHash() uint64

Returns the first 4 bytes of the SHA256 hash from a binary encoded code section of a contract.

func (Script) Constants

func (s Script) Constants() []mavryk.ExprHash

func (*Script) DecodeBuffer

func (p *Script) DecodeBuffer(buf *bytes.Buffer) error

func (Script) EncodeBuffer

func (p Script) EncodeBuffer(buf *bytes.Buffer) error

func (Script) Entrypoints

func (s Script) Entrypoints(withPrim bool) (Entrypoints, error)

func (*Script) ExpandConstants

func (s *Script) ExpandConstants(dict ConstantDict)

func (*Script) Features

func (s *Script) Features() Features

func (*Script) Implements

func (s *Script) Implements(i Interface) bool

func (*Script) ImplementsStrict

func (s *Script) ImplementsStrict(i Interface) bool

func (Script) InterfaceHash

func (s Script) InterfaceHash() uint64

Returns the first 4 bytes of the SHA256 hash from a binary encoded parameter type definition. This value is sufficiently unique to identify contracts with exactly the same entrypoints including annotations.

To identify syntactically equal entrypoints with or without annotations use `IsEqual()`, `IsEqualWithAnno()` or `IsEqualPrim()`.

func (*Script) Interfaces

func (s *Script) Interfaces() Interfaces

func (*Script) InterfacesStrict

func (s *Script) InterfacesStrict() Interfaces

func (Script) IsValid

func (s Script) IsValid() bool

func (Script) MarshalBinary

func (p Script) MarshalBinary() ([]byte, error)

func (Script) MarshalJSON

func (p Script) MarshalJSON() ([]byte, error)

func (*Script) MigrateToBabylonAddDo

func (s *Script) MigrateToBabylonAddDo(managerHash []byte)

Patch params, storage and code

func (*Script) MigrateToBabylonSetDelegate

func (s *Script) MigrateToBabylonSetDelegate(managerHash []byte)

func (Script) ParamType

func (s Script) ParamType() Type

func (Script) ResolveEntrypointPath

func (s Script) ResolveEntrypointPath(name string) string

func (Script) StorageHash

func (s Script) StorageHash() uint64

Returns the first 4 bytes of the SHA256 hash from a binary encoded storage type definition. This value is sufficiently unique to identify contracts with exactly the same entrypoints including annotations.

func (Script) StorageType

func (s Script) StorageType() Type

func (*Script) UnmarshalBinary

func (p *Script) UnmarshalBinary(data []byte) error

func (Script) Views

func (s Script) Views(withPrim, withCode bool) (Views, error)

type Stack

type Stack []Prim

func NewStack

func NewStack(args ...Prim) *Stack

func (Stack) Dump

func (s Stack) Dump() string

func (Stack) DumpIdent

func (s Stack) DumpIdent(indent int) string

func (*Stack) Empty

func (s *Stack) Empty() bool

func (*Stack) Len

func (s *Stack) Len() int

func (*Stack) Peek

func (s *Stack) Peek() Prim

func (*Stack) Pop

func (s *Stack) Pop() Prim

func (*Stack) Push

func (s *Stack) Push(args ...Prim)

type Type

type Type struct {
	Prim
}

func MustParseType

func MustParseType(s string) (t Type)

func NewType

func NewType(p Prim) Type

func NewTypePtr

func NewTypePtr(p Prim) *Type

func ParseType

func ParseType(s string) (t Type, err error)

func TicketType

func TicketType(t Prim) Type

Wraps ticket value type into type structure that is compatible with ticket values. This is necessary because T_TICKET uses an implicit structure (extra fields amount, ticketer) in addition to the defined value.

func (Type) Clone

func (t Type) Clone() Type

func (Type) Entrypoints

func (t Type) Entrypoints(withPrim bool) (Entrypoints, error)

func (Type) HasLabel

func (t Type) HasLabel() bool

func (Type) IsEqual

func (t Type) IsEqual(t2 Type) bool

func (Type) IsEqualWithAnno

func (t Type) IsEqualWithAnno(t2 Type) bool

func (Type) IsSimilar

func (t Type) IsSimilar(t2 Type) bool

func (Type) Label

func (t Type) Label() string

func (Type) Left

func (t Type) Left() Type

func (Type) MarshalJSON

func (t Type) MarshalJSON() ([]byte, error)

func (Type) ResolveEntrypointPath

func (t Type) ResolveEntrypointPath(name string) string

returns path to named entrypoint

func (Type) Right

func (t Type) Right() Type

func (Type) Typedef

func (t Type) Typedef(name string) Typedef

func (Type) TypedefPtr

func (t Type) TypedefPtr(name string) *Typedef

func (*Type) UnmarshalBinary

func (t *Type) UnmarshalBinary(buf []byte) error

func (*Type) UnmarshalJSON

func (t *Type) UnmarshalJSON(buf []byte) error

type Typedef

type Typedef struct {
	Name     string    `json:"name"`               // annotation label | @key | @value | @item | @params | @return
	Type     string    `json:"type"`               // opcode or struct | union
	Optional bool      `json:"optional,omitempty"` // Union only
	Args     []Typedef `json:"args,omitempty"`
	Path     []int     `json:"path"` // type tree original path to this element
}

func (Typedef) Equal

func (a Typedef) Equal(b Typedef) bool

func (Typedef) IsValid

func (a Typedef) IsValid() bool

func (Typedef) Left

func (t Typedef) Left() Typedef

func (Typedef) Marshal

func (t Typedef) Marshal(v any, optimized bool) (Prim, error)

Marshal takes a scalar or nested Go type and populates a Micheline primitive tree compatible with type t. This method is compatible with most contract entrypoints, contract storage, bigmap values, etc. Use optimized to control whether the target prims contain values in optimized form (binary addresses, numeric timestamps) or string form.

Note: This is work in progress. Several data types are still unsupported and entrypoint mapping requires some extra boilerplate:

// Entrypoint example (without error handling for brevity)
eps, _ := script.Entrypoints(true)
ep, _ := eps["name"]

// marshal to prim tree
// Note: be mindful of the way entrypoint typedefs are structured:
// - 1 arg: use scalar value in ep.Typedef[0]
// - >1 arg: use entire list in ep.Typedef but wrap into struct
typ := ep.Typedef[0]
if len(ep.Typedef) > 1 {
    typ = micheline.Typedef{
        Name: micheline.CONST_ENTRYPOINT,
        Type: micheline.TypeStruct,
        Args: ep.Typedef,
    }
}

// then use the type to marshal into primitives
prim, err := typ.Marshal(args, true)

func (Typedef) OpCode

func (t Typedef) OpCode() OpCode

func (Typedef) Right

func (t Typedef) Right() Typedef

func (Typedef) Similar

func (a Typedef) Similar(b Typedef) bool

func (Typedef) StrictEqual

func (t Typedef) StrictEqual(v Typedef) bool

func (Typedef) String

func (t Typedef) String() string

func (Typedef) Unfold

func (t Typedef) Unfold() Typedef

type Value

type Value struct {
	Type   Type
	Value  Prim
	Render int
	// contains filtered or unexported fields
}

func NewValue

func NewValue(typ Type, val Prim) Value

func NewValuePtr

func NewValuePtr(typ Type, val Prim) *Value

func (*Value) Decode

func (v *Value) Decode(buf []byte) error

func (Value) Dump

func (e Value) Dump() string

func (Value) DumpLimit

func (e Value) DumpLimit(n int) string

func (Value) DumpTo

func (e Value) DumpTo(w io.Writer)

func (*Value) FixType

func (e *Value) FixType()

func (*Value) GetAddress

func (v *Value) GetAddress(label string) (mavryk.Address, bool)

func (*Value) GetBig

func (v *Value) GetBig(label string) (*big.Int, bool)

func (*Value) GetBool

func (v *Value) GetBool(label string) (bool, bool)

func (*Value) GetBytes

func (v *Value) GetBytes(label string) ([]byte, bool)

func (*Value) GetInt64

func (v *Value) GetInt64(label string) (int64, bool)

func (*Value) GetKey

func (v *Value) GetKey(label string) (mavryk.Key, bool)

func (*Value) GetSignature

func (v *Value) GetSignature(label string) (mavryk.Signature, bool)

func (*Value) GetString

func (v *Value) GetString(label string) (string, bool)

func (*Value) GetTime

func (v *Value) GetTime(label string) (time.Time, bool)

func (*Value) GetValue

func (v *Value) GetValue(label string) (interface{}, bool)

func (*Value) GetZ

func (v *Value) GetZ(label string) (*mavryk.Z, bool)

func (Value) IsPacked

func (v Value) IsPacked() bool

func (Value) IsPackedAny

func (v Value) IsPackedAny() bool

func (*Value) Map

func (e *Value) Map() (interface{}, error)

func (Value) MarshalJSON

func (e Value) MarshalJSON() ([]byte, error)

func (*Value) Unmarshal

func (v *Value) Unmarshal(val interface{}) error

func (Value) Unpack

func (v Value) Unpack() (Value, error)

func (Value) UnpackAll

func (v Value) UnpackAll() (Value, error)

func (Value) UnpackAllAsciiStrings

func (v Value) UnpackAllAsciiStrings() Value

func (*Value) Walk

func (v *Value) Walk(label string, fn ValueWalkerFunc) error

type ValueWalkerFunc

type ValueWalkerFunc func(label string, value interface{}) error

type View

type View struct {
	Name   string
	Param  Type
	Retval Type
	Code   Prim
	Prim   Prim
}

func NewView

func NewView(p Prim) View

func NewViewPtr

func NewViewPtr(p Prim) *View

func (View) Clone

func (v View) Clone() View

func (View) IsEqual

func (v View) IsEqual(v2 View) bool

func (View) IsEqualWithAnno

func (v View) IsEqualWithAnno(v2 View) bool

func (View) IsEqualWithCode

func (v View) IsEqualWithCode(v2 View) bool

func (View) IsValid

func (v View) IsValid() bool

func (View) MarshalJSON

func (v View) MarshalJSON() ([]byte, error)

func (View) Typedef

func (v View) Typedef() Typedef

func (View) TypedefPtr

func (v View) TypedefPtr(name string) *Typedef

type Views

type Views map[string]View

Jump to

Keyboard shortcuts

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