abi

package
v0.0.7-alphanet Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2023 License: GPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// number of bits in chain big.Word
	WordBits = 32 << (uint64(^big.Word(0)) >> 63)

	// number of bytes in chain big.Word
	WordBytes = WordBits / 8

	// number of bytes in chain vm word
	WordSize = 32
)
View Source
const (
	IntTy byte = iota
	UintTy
	BoolTy
	StringTy
	SliceTy
	ArrayTy
	AddressTy
	TokenStandardTy
	FixedBytesTy
	BytesTy
	HashTy
)

Type enumerator

Variables

View Source
var PoolOfIntPools = &intPoolPool{
	pools: make([]*IntPool, 0, poolDefaultCap),
}

Functions

func PaddedBigBytes

func PaddedBigBytes(bigint *big.Int, n int) []byte

func U256

func U256(n *big.Int) []byte

U256 converts a big Int into a 256bit VM number.

Types

type ABIContract

type ABIContract struct {
	Methods   map[string]Method
	Variables map[string]Variable
}

func JSONToABIContract

func JSONToABIContract(reader io.Reader) ABIContract

func (*ABIContract) MethodById

func (abi *ABIContract) MethodById(sigdata []byte) (*Method, error)

MethodById looks up a method by the 4-byte id returns nil if none found

func (ABIContract) PackMethod

func (abi ABIContract) PackMethod(name string, args ...interface{}) ([]byte, error)

func (ABIContract) PackMethodPanic

func (abi ABIContract) PackMethodPanic(name string, args ...interface{}) []byte

func (ABIContract) PackVariable

func (abi ABIContract) PackVariable(name string, args ...interface{}) ([]byte, error)

func (ABIContract) PackVariablePanic

func (abi ABIContract) PackVariablePanic(name string, args ...interface{}) []byte

func (*ABIContract) UnmarshalJSON

func (abi *ABIContract) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.Unmarshaler interface

func (ABIContract) UnpackEmptyMethod

func (abi ABIContract) UnpackEmptyMethod(name string, input []byte) (err error)

func (ABIContract) UnpackMethod

func (abi ABIContract) UnpackMethod(v interface{}, name string, input []byte) (err error)

func (ABIContract) UnpackVariable

func (abi ABIContract) UnpackVariable(v interface{}, name string, input []byte) (err error)

func (ABIContract) UnpackVariablePanic

func (abi ABIContract) UnpackVariablePanic(v interface{}, name string, input []byte)

type Argument

type Argument struct {
	Name    string
	Type    Type
	Indexed bool // indexed is only used by events
}

Argument holds the name of the argument and the corresponding type. Types are used when packing and testing arguments.

func (*Argument) UnmarshalJSON

func (argument *Argument) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.Unmarshaler interface

type Arguments

type Arguments []Argument

func (Arguments) Pack

func (arguments Arguments) Pack(args ...interface{}) ([]byte, error)

Pack performs the operation Go format -> Hexdata

func (Arguments) Unpack

func (arguments Arguments) Unpack(v interface{}, data []byte) error

Unpack performs the operation hexdata -> Go format

func (Arguments) UnpackValues

func (arguments Arguments) UnpackValues(data []byte) ([]interface{}, error)

UnpackValues can be used to unpack ABI-encoded hexdata according to the ABI-specification, without supplying a struct to unpack into. Instead, this method returns a list containing the values. An atomic argument will be a list with one element.

type IntPool

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

intPool is a pool of big integers that can be reused for all big.Int operations.

func (*IntPool) Get

func (p *IntPool) Get() *big.Int

get retrieves a big int from the pool, allocating one if the pool is empty. Note, the returned int's amount is arbitrary and will not be zeroed!

func (*IntPool) GetZero

func (p *IntPool) GetZero() *big.Int

getZero retrieves a big int from the pool, setting it to zero or allocating a new one if the pool is empty.

func (*IntPool) Put

func (p *IntPool) Put(is ...*big.Int)

put returns an allocated big int to the pool to be later reused by get calls. Note, the values as saved as is; neither put nor get zeroes the ints out!

type Method

type Method struct {
	Name string

	Inputs Arguments
	// contains filtered or unexported fields
}

func (Method) Id

func (method Method) Id() []byte

func (Method) Sig

func (method Method) Sig() string

func (Method) String

func (method Method) String() string

type Type

type Type struct {
	Elem *Type

	Kind reflect.Kind
	Type reflect.Type
	Size int
	T    byte // Our own type checking
	// contains filtered or unexported fields
}

Type is the reflection of the supported argument type

func NewType

func NewType(t string) (typ Type, err error)

NewType creates a new reflection type of abi type given in t.

func (Type) String

func (t Type) String() (out string)

String implements Stringer

type Variable

type Variable struct {
	Name   string
	Inputs Arguments
}

Variable is used only in built-in contracts

func (Variable) String

func (v Variable) String() string

Jump to

Keyboard shortcuts

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