scenexpressioninterpreter

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2024 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const SCAddressNumLeadingZeros = 8

SCAddressNumLeadingZeros is the number of zero bytes every smart contract address begins with.

View Source
const SCAddressReservedPrefixLength = SCAddressNumLeadingZeros + 2

SCAddressReservedPrefixLength is the number of zero bytes every smart contract address begins with. Its value is 10. 10 = 8 zeros for all SC addresses + 2 zeros as placeholder for the VM type.

Variables

This section is empty.

Functions

func Keccak256

func Keccak256(data []byte) ([]byte, error)

Keccak256 cryptographic function TODO: externalize the same way as the file resolver

Types

type ExprInterpreter

type ExprInterpreter struct {
	FileResolver fr.FileResolver
	VMType       []byte
}

ExprInterpreter provides context for computing scenario values.

func (*ExprInterpreter) GetVMType

func (ei *ExprInterpreter) GetVMType() []byte

GetVMType yields the configured VM type, which is used for generating SC addresses. Will yield default value [0, 0] is not explicitly configured.

func (*ExprInterpreter) InterpretString

func (ei *ExprInterpreter) InterpretString(strRaw string) ([]byte, error)

InterpretString resolves a string to a byte slice according to the scenario value format. Supported rules are: - numbers: decimal, hex, binary, signed/unsigned - fixed length numbers: "u32:5", "i8:-3", etc. - ascii strings as "str:...", "“...", "”..." - "true"/"false" - "address:..." - "sc:..." (also an address) - "file:..." - "keccak256:..." - concatenation using |

func (*ExprInterpreter) InterpretSubTree

func (ei *ExprInterpreter) InterpretSubTree(obj oj.OJsonObject) ([]byte, error)

InterpretSubTree attempts to produce a value based on a JSON subtree. Subtrees are composed of strings, lists and maps. The idea is to intuitively represent serialized objects. Lists are evaluated by concatenating their items' representations. Maps are evaluated by concatenating their values' representations (keys are ignored). See InterpretString on how strings are being interpreted.

Jump to

Keyboard shortcuts

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