scoreapi

package
v1.3.6 Latest Latest
Warning

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

Go to latest
Published: May 16, 2023 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NoSignatureError = errorBase + iota
	IllegalEventError
)
View Source
const (
	FlagReadOnly = 1 << iota
	FlagExternal
	FlagPayable
	FlagIsolated
)
View Source
const (
	FallbackMethodName = ""
)
View Source
const (
	KeyForPositionalParameters = "."
)

Variables

View Source
var (
	ErrNoSignature  = errors.NewBase(NoSignatureError, "NoSignatureError")
	ErrIllegalEvent = errors.NewBase(IllegalEventError, "IllegalEventError")
)

Functions

func FieldsToJSON added in v0.9.4

func FieldsToJSON(fields []Field, version module.JSONVersion) (interface{}, error)

func ParseHexIntParam added in v0.9.6

func ParseHexIntParam(bs []byte) (*common.HexInt, error)

ParseHexIntParam reproduce same decoding logics of parameter parsing of ICON.

def str_to_int(value: str) -> int:

if isinstance(value, int):
    return value

base = 16 if is_hex(value) else 10
return int(value, base)

Types

type DataType

type DataType int

DataType composed of following bits. ListDepth(4bits) + TypeTag(4bits)

const (
	Unknown DataType = iota
	Integer
	String
	Bytes
	Bool
	Address
	List
	Dict
	Struct
)

func DataTypeOf

func DataTypeOf(s string) DataType

DataTypeOf returns type for the specified name.

func ListTypeOf

func ListTypeOf(depth int, t DataType) DataType

func (DataType) ConvertBytesToJSO

func (t DataType) ConvertBytesToJSO(bs []byte) (interface{}, error)

ConvertBytesToJSO convert default bytes and event bytes into JSON value type.

func (DataType) ConvertBytesToTypedObj

func (t DataType) ConvertBytesToTypedObj(bs []byte) (*codec.TypedObj, error)

ConvertBytesToTypedObj convert default bytes into native type

func (DataType) ConvertJSONToTypedObj

func (t DataType) ConvertJSONToTypedObj(bs []byte, fields []Field, nullable bool) (*codec.TypedObj, error)

ConvertJSONToTypedObj decode json object comes from JSON.

func (DataType) Elem

func (t DataType) Elem() DataType

func (DataType) IsList

func (t DataType) IsList() bool

func (DataType) ListDepth

func (t DataType) ListDepth() int

func (DataType) String

func (t DataType) String() string

func (DataType) Tag

func (t DataType) Tag() TypeTag

func (DataType) UsableForEvent added in v1.3.0

func (t DataType) UsableForEvent() bool

func (DataType) UsableForInput added in v1.3.3

func (t DataType) UsableForInput() bool

func (DataType) ValidateEvent

func (t DataType) ValidateEvent(bs []byte) error

ValidateEvent validate event bytes.

func (DataType) ValidateInput

func (t DataType) ValidateInput(obj *codec.TypedObj, fields []Field, nullable bool) error

func (DataType) ValidateOutput

func (t DataType) ValidateOutput(obj *codec.TypedObj) error

type Field

type Field struct {
	Name   string
	Type   DataType
	Fields []Field
}

func (*Field) ToJSON added in v0.9.4

func (f *Field) ToJSON(v module.JSONVersion) (interface{}, error)

type Info

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

func NewInfo

func NewInfo(methods []*Method) *Info

func (*Info) Bytes

func (info *Info) Bytes() ([]byte, error)

func (*Info) CheckEventData

func (info *Info) CheckEventData(indexed [][]byte, data [][]byte) error

func (*Info) ConvertParamsToTypedObj

func (info *Info) ConvertParamsToTypedObj(method string, params []byte) (*codec.TypedObj, error)

func (*Info) EnsureParamsSequential

func (info *Info) EnsureParamsSequential(method string, params *codec.TypedObj) (*codec.TypedObj, error)

func (*Info) Equal

func (info *Info) Equal(info2 *Info) bool

func (*Info) GetMethod

func (info *Info) GetMethod(name string) *Method

func (*Info) RLPDecodeSelf

func (info *Info) RLPDecodeSelf(d codec.Decoder) error

func (*Info) RLPEncodeSelf

func (info *Info) RLPEncodeSelf(e codec.Encoder) error

func (*Info) String

func (info *Info) String() string

func (*Info) ToJSON

func (info *Info) ToJSON(v module.JSONVersion) (interface{}, error)

type Method

type Method struct {
	Type    MethodType
	Name    string
	Flags   int
	Indexed int
	Inputs  []Parameter
	Outputs []DataType
}

func (*Method) CheckEventData

func (a *Method) CheckEventData(indexed [][]byte, data [][]byte) error

func (*Method) ConvertParamsToTypedObj

func (a *Method) ConvertParamsToTypedObj(bs []byte, allowExtra bool) (*codec.TypedObj, error)

func (*Method) EnsureParamsSequential

func (a *Method) EnsureParamsSequential(paramObj *codec.TypedObj) (*codec.TypedObj, error)

func (*Method) EnsureResult

func (a *Method) EnsureResult(result *codec.TypedObj) error

func (*Method) IsCallable

func (a *Method) IsCallable() bool

func (*Method) IsEvent

func (a *Method) IsEvent() bool

func (*Method) IsExternal

func (a *Method) IsExternal() bool

func (*Method) IsFallback

func (a *Method) IsFallback() bool

func (*Method) IsIsolated

func (a *Method) IsIsolated() bool

func (*Method) IsPayable

func (a *Method) IsPayable() bool

func (*Method) IsReadOnly

func (a *Method) IsReadOnly() bool

func (*Method) Signature

func (a *Method) Signature() string

func (*Method) String added in v0.9.6

func (a *Method) String() string

func (*Method) ToJSON

func (a *Method) ToJSON(version module.JSONVersion) (interface{}, error)

type MethodType

type MethodType int
const (
	Function MethodType = iota
	Fallback
	Event
)

func (MethodType) String

func (t MethodType) String() string

type Parameter

type Parameter struct {
	Name    string
	Type    DataType
	Default []byte
	Fields  []Field
}

func (*Parameter) RLPDecodeSelf

func (p *Parameter) RLPDecodeSelf(d codec.Decoder) error

func (*Parameter) RLPEncodeSelf

func (p *Parameter) RLPEncodeSelf(e codec.Encoder) error

type TypeTag

type TypeTag int
const (
	TUnknown TypeTag = iota
	TInteger
	TString
	TBytes
	TBool
	TAddress
	TList
	TDict
	TStruct
)

func TypeTagOf

func TypeTagOf(s string) TypeTag

func (TypeTag) ConvertJSONToTypedObj

func (t TypeTag) ConvertJSONToTypedObj(bs []byte, fields []Field) (*codec.TypedObj, error)

func (TypeTag) String

func (t TypeTag) String() string

Jump to

Keyboard shortcuts

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