abi

package
v0.0.0-...-15eb78e Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2022 License: AGPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const AccountReferenceType = "account"

AccountReferenceType is the ABI argument type string for account references

View Source
const AnyTransactionType = "txn"

AnyTransactionType is the ABI argument type string for a nonspecific transaction argument

View Source
const ApplicationReferenceType = "application"

ApplicationReferenceType is the ABI argument type string for application references

View Source
const AssetReferenceType = "asset"

AssetReferenceType is the ABI argument type string for asset references

Variables

This section is empty.

Functions

func IsReferenceType

func IsReferenceType(s string) bool

IsReferenceType checks if a type string represents a reference type argument, such as "account", "asset", or "application".

func IsTransactionType

func IsTransactionType(s string) bool

IsTransactionType checks if a type string represents a transaction type argument, such as "txn", "pay", "keyreg", etc.

func ParseArgJSONtoByteSlice

func ParseArgJSONtoByteSlice(argTypes []string, jsonArgs []string, applicationArgs *[][]byte) error

ParseArgJSONtoByteSlice convert input method arguments to ABI encoded bytes it converts funcArgTypes into a tuple type and apply changes over input argument string (in JSON format) if there are greater or equal to 15 inputs, then we compact the tailing inputs into one tuple

func ParseMethodSignature

func ParseMethodSignature(methodSig string) (name string, argTypes []string, returnType string, err error)

ParseMethodSignature parses a method of format `method(argType1,argType2,...)retType` into `method` {`argType1`,`argType2`,...} and `retType`

Types

type BaseType

type BaseType uint32

BaseType is an type-alias for uint32. A BaseType value indicates the type of an ABI value.

const (
	// Uint is the index (0) for `Uint` type in ABI encoding.
	Uint BaseType = iota
	// Byte is the index (1) for `Byte` type in ABI encoding.
	Byte
	// Ufixed is the index (2) for `UFixed` type in ABI encoding.
	Ufixed
	// Bool is the index (3) for `Bool` type in ABI encoding.
	Bool
	// ArrayStatic is the index (4) for static length array (<type>[length]) type in ABI encoding.
	ArrayStatic
	// Address is the index (5) for `Address` type in ABI encoding (an type alias of Byte[32]).
	Address
	// ArrayDynamic is the index (6) for dynamic length array (<type>[]) type in ABI encoding.
	ArrayDynamic
	// String is the index (7) for `String` type in ABI encoding (an type alias of Byte[]).
	String
	// Tuple is the index (8) for tuple `(<type 0>, ..., <type k>)` in ABI encoding.
	Tuple
)

type Type

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

Type is the struct that stores information about an ABI value's type.

func MakeTupleType

func MakeTupleType(argumentTypes []Type) (Type, error)

MakeTupleType makes tuple ABI type by taking an array of tuple element types as argument.

func TypeOf

func TypeOf(str string) (Type, error)

TypeOf parses an ABI type string. For example: `TypeOf("(uint64,byte[])")`

func (Type) ByteLen

func (t Type) ByteLen() (int, error)

ByteLen method calculates the byte length of a static ABI type.

func (Type) Decode

func (t Type) Decode(encoded []byte) (interface{}, error)

Decode is an ABI type method to decode bytes to go values from ABI encoding rules

func (Type) Encode

func (t Type) Encode(value interface{}) ([]byte, error)

Encode is an ABI type method to encode go values into bytes following ABI encoding rules

func (Type) Equal

func (t Type) Equal(t0 Type) bool

Equal method decides the equality of two types: t == t0.

func (Type) IsDynamic

func (t Type) IsDynamic() bool

IsDynamic method decides if an ABI type is dynamic or static.

func (Type) MarshalToJSON

func (t Type) MarshalToJSON(value interface{}) ([]byte, error)

MarshalToJSON convert golang value to JSON format from ABI type

func (Type) String

func (t Type) String() string

String serialize an ABI Type to a string in ABI encoding.

func (Type) UnmarshalFromJSON

func (t Type) UnmarshalFromJSON(jsonEncoded []byte) (interface{}, error)

UnmarshalFromJSON convert bytes to golang value following ABI type and encoding rules

Jump to

Keyboard shortcuts

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