nef

package
v0.0.0-...-886a677 Latest Latest
Warning

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

Go to latest
Published: Dec 8, 2024 License: MIT Imports: 11 Imported by: 2

Documentation

Index

Constants

View Source
const (
	// Magic is a magic File header constant.
	Magic uint32 = 0x3346454E
	// MaxSourceURLLength is the maximum allowed source URL length.
	MaxSourceURLLength = 256
)

Variables

This section is empty.

Functions

This section is empty.

Types

type File

type File struct {
	Header
	Source   string        `json:"source"`
	Tokens   []MethodToken `json:"tokens"`
	Script   []byte        `json:"script"`
	Checksum uint32        `json:"checksum"`
}

File represents a compiled contract file structure according to the NEF3 standard.

func FileFromBytes

func FileFromBytes(source []byte) (File, error)

FileFromBytes returns a NEF File deserialized from the given bytes.

func NewFile

func NewFile(script []byte) (*File, error)

NewFile returns a new NEF3 file with the script specified.

func (File) Bytes

func (n File) Bytes() ([]byte, error)

Bytes returns a byte array with a serialized NEF File. It performs the resulting NEF file size check and returns an error if serialized slice length exceeds stackitem.MaxSize.

func (File) BytesLong

func (n File) BytesLong() ([]byte, error)

BytesLong returns a byte array with a serialized NEF File. It performs no resulting slice check.

func (*File) CalculateChecksum

func (n *File) CalculateChecksum() uint32

CalculateChecksum returns first 4 bytes of double-SHA256(Header) converted to uint32. CalculateChecksum doesn't perform the resulting serialized NEF size check, and return the checksum irrespectively to the size limit constraint. It's a caller's duty to check the resulting NEF size.

func (*File) DecodeBinary

func (n *File) DecodeBinary(r *io.BinReader)

DecodeBinary implements the io.Serializable interface.

func (*File) EncodeBinary

func (n *File) EncodeBinary(w *io.BinWriter)

EncodeBinary implements the io.Serializable interface.

type Header struct {
	Magic    uint32 `json:"magic"`
	Compiler string `json:"compiler"`
}

Header represents a File header.

func (*Header) DecodeBinary

func (h *Header) DecodeBinary(r *io.BinReader)

DecodeBinary implements the io.Serializable interface.

func (*Header) EncodeBinary

func (h *Header) EncodeBinary(w *io.BinWriter)

EncodeBinary implements the io.Serializable interface.

type MethodToken

type MethodToken struct {
	// Hash is contract hash.
	Hash util.Uint160 `json:"hash"`
	// Method is method name.
	Method string `json:"method"`
	// ParamCount is method parameter count.
	ParamCount uint16 `json:"paramcount"`
	// HasReturn is true if method returns value.
	HasReturn bool `json:"hasreturnvalue"`
	// CallFlag is a set of call flags the method will be called with.
	CallFlag callflag.CallFlag `json:"callflags"`
}

MethodToken is contract method description.

func (*MethodToken) DecodeBinary

func (t *MethodToken) DecodeBinary(r *io.BinReader)

DecodeBinary implements io.Serializable.

func (*MethodToken) EncodeBinary

func (t *MethodToken) EncodeBinary(w *io.BinWriter)

EncodeBinary implements io.Serializable.

Jump to

Keyboard shortcuts

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