abiutils

package
v0.0.0-...-1b3c92d Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2020 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BOOL    = "bool"
	INT     = "int"
	UINT    = "uint"
	ADDRESS = "address"
	BYTES   = "bytes"
	STRING  = "string"
)

Variables

This section is empty.

Functions

func DecodeBigFromHex

func DecodeBigFromHex(hexStr string) (*big.Int, error)

十六进制转换为十进制

func TrimLeadingZero

func TrimLeadingZero(hexStr string) string

删除十六进制字符串前缀多余的0

Types

type InputData

type InputData struct {
	Param     SolidityDataType `json:"-"`         //参数的数据类型
	ParamName string           `json:"paramName"` //参数名
	Offset    int64            `json:"-"`         //偏移量,非值类型时为0
	Data      string           `json:"data"`      //数据内容
}

用于封装Transaction中Data字节数组的结构体

func (InputData) String

func (i InputData) String() string

type InputDatas

type InputDatas []InputData

type Kind

type Kind int

数据类型的类型

const (
	VALUE    Kind = iota //值类型
	VARIABLE             //动态类型
)

func (Kind) String

func (k Kind) String() string

type SolidityDataType

type SolidityDataType struct {
	Name     string `json:"name"`     // 类型名,如:int32
	Type     Kind   `json:"type"`     // 值类型或引用类型
	IsNumber bool   `json:"isNumber"` // 是否数字
	IsArray  bool   `json:"isArray"`  // 是否数组
	BitSize  int    `json:"bitSize"`  // 以bit为单位的长度,用于以后补0,仅对值类型生效
}

用于描述Solidity数据类型的结构体

func GetSolidityTypeByName

func GetSolidityTypeByName(name string) *SolidityDataType

通过参数类型获得相关信息 name = "uint" => returns { uint, value, 256 } // uint类型,值类型,256位 name = "string" => returns { string, variable, 0 } // string类型,非值类型,无意义 name = "byte3[10]" => returns { bytes3[10], value, 0} // bytes3数组类型,值类型,3*8*10=240位

func (SolidityDataType) String

func (t SolidityDataType) String() string

type SolidityDataTypes

type SolidityDataTypes []*SolidityDataType

type SolidityMethod

type SolidityMethod struct {
	Name       string     `json:"name"` // 方法标识,如:function foo(uint id, string name)
	InputDatas InputDatas `json:"params"`
}

用于描述Solidity函数的结构体

func TransformTxData

func TransformTxData(abiStr string, input []byte) (*SolidityMethod, error)

转换transaction中的input

Jump to

Keyboard shortcuts

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