ethabi

package
v0.10.6 Latest Latest
Warning

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

Go to latest
Published: Jun 15, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EthereumAddressSize            int = 20
	NumberOfERC20TransferArguments int = 2
	ERC20TransferCallDataSize          = SelectorSize + 2*abiSlotSize // selector + _to + _value
)
View Source
const SelectorSize = 4

Variables

View Source
var UnsupportedType = errors.New("unsupported type")

Functions

func IsERC20TransferSelector

func IsERC20TransferSelector(id Selector) bool

IsERC20TransferSelector checks that selector is an ERC20Transfer function selector

func MakeJsonABI

func MakeJsonABI(methods []Method) ([]byte, error)

Types

type ArgType

type ArgType byte
const (
	IntType ArgType = iota
	UintType
	BytesType
	BoolType
	StringType

	SliceType
	TupleType

	AddressType    // we use this type only for erc20 transfers
	FixedBytesType // we use this type only for payment asset
)

Type enumerator

func (ArgType) String

func (t ArgType) String() string

type Argument

type Argument struct {
	Name string
	Type Type
}

func NewArgumentFromRideTypeMeta

func NewArgumentFromRideTypeMeta(name string, rideT meta.Type) (Argument, error)

type Arguments

type Arguments []Argument

func (Arguments) UnpackRideValues

func (arguments Arguments) UnpackRideValues(output []byte) (_ []DataType, paymentsSliceIndex, slotsReadTotal int, _ error)

UnpackRideValues 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 BigInt

type BigInt struct {
	V *big.Int
}

type Bool

type Bool bool

func (Bool) EncodeToABI added in v0.10.2

func (b Bool) EncodeToABI() []byte

type Bytes

type Bytes []byte

type DataType

type DataType interface {
	// contains filtered or unexported methods
}

type DecodedArg

type DecodedArg struct {
	Soltype Argument
	Value   DataType
}

func (*DecodedArg) DecodedValue

func (da *DecodedArg) DecodedValue() interface{}

func (*DecodedArg) InternalType

func (da *DecodedArg) InternalType() byte

func (*DecodedArg) String

func (da *DecodedArg) String() string

type DecodedCallData

type DecodedCallData struct {
	Signature Signature
	Name      string
	Inputs    []DecodedArg
	Payments  []Payment
}

DecodedCallData is an internal type to represent a method call parsed according to an ABI method signature.

func (DecodedCallData) String

func (cd DecodedCallData) String() string

String implements stringer interface for DecodedCallData

type ERC20TransferArguments

type ERC20TransferArguments struct {
	Recipient [EthereumAddressSize]byte
	Amount    int64
}

func GetERC20TransferArguments

func GetERC20TransferArguments(decodedData *DecodedCallData) (ERC20TransferArguments, error)

GetERC20TransferArguments parses DecodedCallData to ERC20TransferArguments

type Int

type Int int64

func (Int) EncodeToABI added in v0.10.2

func (i Int) EncodeToABI() []byte

type List

type List []DataType

type Method

type Method struct {
	RawName string // RawName is the raw method name parsed from ABI
	Inputs  Arguments
	// Sig returns the methods string signature according to the ABI spec.
	// e.g.		function foo(uint32 a, int b) = "foo(uint32,int256)"
	// Please note that "int" is substitute for its canonical representation "int256"
	Payments *Argument
	Sig      Signature
}

func NewMethodFromRideFunctionMeta

func NewMethodFromRideFunctionMeta(rideF meta.Function, addPayments bool) (Method, error)

func (*Method) String

func (m *Method) String() string

type MethodsMap

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

func NewErc20MethodsMap

func NewErc20MethodsMap() MethodsMap

func NewMethodsMapFromRideDAppMeta

func NewMethodsMapFromRideDAppMeta(dApp meta.DApp) (MethodsMap, error)

func (MethodsMap) MarshalJSON

func (mm MethodsMap) MarshalJSON() ([]byte, error)

func (MethodsMap) MethodBySelector

func (mm MethodsMap) MethodBySelector(id Selector) (Method, error)

func (MethodsMap) ParseCallDataRide

func (mm MethodsMap) ParseCallDataRide(data []byte, sanityChecksEnabled bool) (*DecodedCallData, error)

type Payment

type Payment struct {
	PresentAssetID bool
	AssetID        crypto.Digest
	Amount         int64
}

type Selector

type Selector [SelectorSize]byte

func NewSelector

func NewSelector(sig Signature) Selector

func NewSelectorFromBytes

func NewSelectorFromBytes(a []byte) (Selector, error)

func (*Selector) FromHex

func (s *Selector) FromHex(hexSelector string) error

func (Selector) Hex

func (s Selector) Hex() string

func (Selector) String

func (s Selector) String() string

type Signature

type Signature string

func NewSignatureFromRideFunctionMeta

func NewSignatureFromRideFunctionMeta(fn meta.Function, addPayments bool) (Signature, error)

func (Signature) Selector

func (s Signature) Selector() Selector

func (Signature) String

func (s Signature) String() string

type String

type String string

func (String) EncodeToABI added in v0.10.2

func (s String) EncodeToABI() []byte

type Type

type Type struct {
	Elem *Type // nested types for SliceType
	Size int
	T    ArgType // Our own type checking

	// Tuple relative fields
	TupleRawName string    // Raw struct name defined in source code, may be empty.
	TupleFields  Arguments // Type and name information of all tuple fields
	// contains filtered or unexported fields
}

Type is the reflection of the supported argument type.

func AbiTypeFromRideTypeMeta

func AbiTypeFromRideTypeMeta(metaT meta.Type) (abiT Type, err error)

func (*Type) String

func (t *Type) String() string

Jump to

Keyboard shortcuts

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