micheline

package
v0.9.9 Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2021 License: MIT Imports: 17 Imported by: 28

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 (
	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
)
View Source
const PATH_SEPARATOR = "."

Variables

View Source
var (
	IManager     = Interface("MANAGER")
	ISetDelegate = Interface("SET_DELEGATE")
	ITzip5       = Interface("TZIP-005")
	ITzip7       = Interface("TZIP-007")
	ITzip12      = Interface("TZIP-012")
	IDexter      = Interface("DEXTER")
)
View Source
var (
	InvalidPrim = Prim{}
	EmptyPrim   = Prim{Type: PrimNullary, OpCode: 255}
)
View Source
var BigmapRefType = Prim{
	Type:   PrimNullary,
	OpCode: T_INT,
}
View Source
var PrimSkip = errors.New("skip branch")

Functions

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 added in v0.9.5

func KeyHash(buf []byte) tezos.ExprHash

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 BigmapDiff

type BigmapDiff []BigmapDiffElem

func (BigmapDiff) MarshalBinary

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

func (*BigmapDiff) UnmarshalBinary

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

type BigmapDiffElem

type BigmapDiffElem struct {
	Action    DiffAction
	Id        int64
	SourceId  int64 // used on copy
	DestId    int64 // used on copy
	KeyHash   tezos.ExprHash
	Key       Prim // works with any type
	Value     Prim
	KeyType   Prim // used on alloc/copy, uses Prim for native marshalling
	ValueType Prim // used on alloc/copy, uses Prim for native marshalling
}

func (BigmapDiffElem) Encoding

func (e BigmapDiffElem) Encoding() PrimType

func (BigmapDiffElem) GetKey

func (e BigmapDiffElem) GetKey(typ Type) Key

func (BigmapDiffElem) GetKeyPtr

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

func (BigmapDiffElem) MarshalJSON

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

func (*BigmapDiffElem) UnmarshalJSON

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

TODO: lazy_storage_diff updates

type Bool

type Bool byte
const (
	False Bool = 0x00
	True  Bool = 0xff
)

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
	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 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"`
	Call    string    `json:"call"`
	Branch  string    `json:"branch"`
	Typedef []Typedef `json:"type"`
	Prim    *Prim     `json:"prim,omitempty"`
}

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 (
	FeatureAccountFactory Features = 1 << iota
	FeatureContractFactory
	FeatureSetDelegate
	FeatureLambda
	FeatureTransferTokens
	FeatureChainId
	FeatureTicket
	FeatureSapling
)

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 Interface

type Interface string

func (Interface) Matches

func (m Interface) Matches(e Entrypoints) bool

search all interfaces in the list of entrypoints

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      tezos.Address
	KeyKey       tezos.Key
	SignatureKey tezos.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() tezos.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 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_MUTEZ     // 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
	T_SAPLING_TRANSACTION   // 84
	I_SAPLING_EMPTY_STATE   // 85
	I_SAPLING_VERIFY_UPDATE // 86
	T_TICKET                // 87
	I_TICKET                // 88
	I_READ_TICKET           // 89
	I_SPLIT_TICKET          // 8A
	I_JOIN_TICKETS          // 8B
	I_GET_AND_UPDATE        // 8C
)

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) MapEntrypoint

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

func (Parameters) MarshalBinary

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

stay compatible with v005 transaction serialization

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      []Prim   // 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)
}

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 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 NewInt64

func NewInt64(i int64) Prim

func NewPairType

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

func NewPairValue

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

func NewPrim

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

func NewSeq

func NewSeq(args ...Prim) Prim

func NewString

func NewString(s string) Prim

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) Clone

func (p Prim) Clone() Prim

func (Prim) ContainsOpCode

func (p Prim) ContainsOpCode(typ OpCode) bool

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) FindLabels

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

func (Prim) FindOpCodes

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

func (Prim) FoldPair added in v0.9.4

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)

func (Prim) GetPath

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

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 added in v0.9.2

func (p Prim) GetVarOrFieldAnno() string

func (Prim) HasAnno

func (p Prim) HasAnno() bool

func (Prim) HasFieldAnno

func (p Prim) HasFieldAnno() bool

func (Prim) HasSimilarChildTypes added in v0.9.9

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, mutez), 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 added in v0.9.2

func (p Prim) HasVarOrFieldAnno() bool

func (Prim) Index

func (p Prim) Index(label string) ([]int, 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) IsEmptyBigmap added in v0.9.9

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) 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) IsOperation

func (p Prim) IsOperation() 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) 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) LooksLikeLambda

func (p Prim) LooksLikeLambda() bool

Checks if a Prim looks like a lambda type.

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) MatchesAnno

func (p Prim) MatchesAnno(anno string) bool

func (Prim) MigrateToBabylonStorage

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

func (*Prim) StripAnno

func (p *Prim) StripAnno(name string)

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 added in v0.9.9

func (p Prim) UnfoldPairRecursive(typ Type) []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) UnpackJSON

func (p *Prim) UnpackJSON(val interface{}) error

func (*Prim) UnpackPrimitive

func (p *Prim) UnpackPrimitive(val map[string]interface{}) error

func (*Prim) UnpackScalar

func (p *Prim) UnpackScalar(val interface{}) error

func (*Prim) UnpackSequence

func (p *Prim) UnpackSequence(val []interface{}) 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.

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 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) BigmapTypesByName added in v0.9.8

func (s *Script) BigmapTypesByName() map[string]Type

Returns a named map containing all bigmaps defined in contracts storgae spec. Names are derived from Michelson type annotations and if missing, a sequence number. Optionally appends a sequence number to prevent duplicate names.

func (*Script) BigmapsById

func (s *Script) BigmapsById() []int64

Returns a list of bigmaps referenced by a contracts current storage. Note that in rare cases when storage type uses a T_OR branch above its bigmap type definitions and the relevant branch is inactive/hidden the storage value lacks bigmap references and this function will return an empty list, even though bigmaps exist.

func (*Script) BigmapsByName

func (s *Script) BigmapsByName() map[string]int64

Returns a named map containing all bigmaps currently referenced by a contracts storage value. Names are derived from Michelson type annotations and if missing, a sequence number. Optionally appends a sequence number to prevent duplicate names.

func (*Script) CodeHash

func (s *Script) CodeHash() []byte

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

func (*Script) Entrypoints

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

func (*Script) Features

func (s *Script) Features() Features

func (*Script) Implements

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

func (*Script) InterfaceHash

func (s *Script) InterfaceHash() []byte

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) MarshalBinary

func (p Script) MarshalBinary() ([]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 added in v0.9.9

func (s *Script) ParamType() Type

func (*Script) SearchEntrypointName

func (s *Script) SearchEntrypointName(name string) string

func (*Script) StorageHash

func (s *Script) StorageHash() []byte

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

type Stack

type Stack []Prim

func NewStack

func NewStack(args ...Prim) *Stack

func (Stack) Dump added in v0.9.9

func (s Stack) Dump() string

func (Stack) DumpIdent added in v0.9.9

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 NewType

func NewType(p Prim) Type

func NewTypePtr

func NewTypePtr(p Prim) *Type

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 added in v0.9.9

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) 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) Right

func (t Type) Right() Type

func (Type) SearchEntrypointName added in v0.9.9

func (t Type) SearchEntrypointName(name string) string

returns path to named entrypoint

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

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"`
}

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) (tezos.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) (tezos.Key, bool)

func (*Value) GetSignature

func (v *Value) GetSignature(label string) (tezos.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) 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 added in v0.9.5

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) Walk

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

type ValueWalkerFunc

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

type Z

type Z big.Int

A variable length sequence of bytes, encoding a Zarith number. Each byte has a running unary size bit: the most significant bit of each byte tells if this is the last byte in the sequence (0) or if there is more to read (1). The second most significant bit of the first byte is reserved for the sign (positive if zero). Size and sign bits ignored, data is then the binary representation of the absolute value of the number in little endian order.

func (*Z) Big

func (z *Z) Big() *big.Int

func (*Z) DecodeBuffer

func (z *Z) DecodeBuffer(buf *bytes.Buffer) error

func (*Z) EncodeBuffer

func (z *Z) EncodeBuffer(buf *bytes.Buffer) error

func (*Z) Int64

func (z *Z) Int64() int64

func (*Z) MarshalBinary

func (z *Z) MarshalBinary() ([]byte, error)

func (*Z) Set

func (z *Z) Set(b *big.Int) *Z

func (*Z) SetInt64

func (z *Z) SetInt64(i int64) *Z

func (*Z) UnmarshalBinary

func (z *Z) UnmarshalBinary(data []byte) error

Jump to

Keyboard shortcuts

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