Documentation
¶
Overview ¶
Package types
@author: xwc1125
Package types ¶
@author: xwc1125
Package types ¶
@author: xwc1125
Package types ¶
@author: xwc1125
Package types ¶
@author: xwc1125
Package types ¶
@author: xwc1125
Package types ¶
@author: xwc1125
Package types ¶
@author: xwc1125
Index ¶
- Constants
- Variables
- func IsEmptyHash(h Hash) bool
- func IsHexAddress(s string) bool
- type Addr
- type Address
- func (a Address) Big() *big.Int
- func (a Address) Bytes() []byte
- func (a Address) Format(s fmt.State, c rune)
- func (a Address) FromBytes(b []byte) (Addr, error)
- func (a Address) FromStr(addr string) (Addr, error)
- func (a Address) Hash() Hash
- func (a Address) Hex() string
- func (a Address) Len() int
- func (a Address) MarshalText() ([]byte, error)
- func (a Address) Nil() bool
- func (a *Address) Scan(src interface{}) error
- func (a *Address) SetBytes(b []byte)
- func (a Address) String() string
- func (a Address) TerminalString() string
- func (a *Address) UnmarshalJSON(input []byte) error
- func (a *Address) UnmarshalText(input []byte) error
- func (a Address) Validate(addr string) bool
- func (a Address) Value() (driver.Value, error)
- type CallMsg
- type DomainAddress
- func (a DomainAddress) Big() *big.Int
- func (a DomainAddress) Bytes() []byte
- func (a *DomainAddress) DecodeRLP(s *rlp.Stream) error
- func (a *DomainAddress) EncodeRLP(w io.Writer) error
- func (a DomainAddress) Format(s fmt.State, c rune)
- func (a DomainAddress) FromBytes(b []byte) (Addr, error)
- func (a DomainAddress) FromStr(addr string) (Addr, error)
- func (a DomainAddress) Hash() Hash
- func (a DomainAddress) Len() int
- func (a DomainAddress) Nil() bool
- func (a DomainAddress) String() string
- func (a *DomainAddress) UnmarshalJSON(data []byte) error
- func (a DomainAddress) Validate(addr string) bool
- func (a DomainAddress) Value() (driver.Value, error)
- type Hash
- func (h Hash) Big() *big.Int
- func (h Hash) Bytes() []byte
- func (h Hash) Format(s fmt.State, c rune)
- func (h Hash) Generate(rand *rand.Rand, size int) reflect.Value
- func (h Hash) Hex() string
- func (h Hash) HexNoPrefix() string
- func (h Hash) MarshalText() ([]byte, error)
- func (h Hash) Nil() bool
- func (h *Hash) Scan(src interface{}) error
- func (h *Hash) SetBytes(b []byte)
- func (h Hash) String() string
- func (h Hash) TerminalString() string
- func (h *Hash) UnmarshalJSON(input []byte) error
- func (h *Hash) UnmarshalText(input []byte) error
- func (h Hash) Value() (driver.Value, error)
- type MixedcaseAddress
- func (ma *MixedcaseAddress) Address() Address
- func (ma *MixedcaseAddress) MarshalJSON() ([]byte, error)
- func (ma *MixedcaseAddress) Original() string
- func (ma *MixedcaseAddress) String() string
- func (ma *MixedcaseAddress) UnmarshalJSON(input []byte) error
- func (ma *MixedcaseAddress) ValidChecksum() bool
- type MultiHash
- func (h MultiHash) Big() *big.Int
- func (h MultiHash) Bytes() []byte
- func (h MultiHash) Format(s fmt.State, c rune)
- func (h MultiHash) MarshalJSON() ([]byte, error)
- func (h MultiHash) MarshalText() ([]byte, error)
- func (h MultiHash) Nil() bool
- func (h *MultiHash) SetBytes(b []byte)
- func (h MultiHash) String() string
- func (h MultiHash) TerminalString() string
- func (h *MultiHash) UnmarshalJSON(data []byte) error
- func (h *MultiHash) UnmarshalText(input []byte) error
- type StorageSize
- type TxType
- type TxTypes
- type UnprefixedAddress
- type UnprefixedHash
- type WriteCounter
Constants ¶
const AddressLength = 20
const HashLength = 32
HashLength hash长度
const TxTypeUnknown = "UNKNOWN"
Variables ¶
var ( EmptyHash = Hash{} EmptyCode = sha3.Keccak256(nil) EmptyCodeHash = BytesToHash(EmptyCode) EmptyRootHash = HexToHash("56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421") )
var (
EmptyAddress = Address{}
)
var ( EmptyDomainAddress = DomainAddress{ Addr: EmptyAddress, } )
var (
EmptyMultiHash = MultiHash{}
)
Functions ¶
func IsEmptyHash ¶
func IsHexAddress ¶
IsHexAddress verifies whether a string can represent a valid hex-encoded SuperChain address or not.
Types ¶
type Addr ¶
type Addr interface {
Len() int // 地址长度
Bytes() []byte // 地址bytes
FromBytes(b []byte) (Addr, error) // 将bytes转换为address对象
String() string // 地址转换为string [implements fmt.Stringer]
FromStr(addr string) (Addr, error) // 将字符串转换为address对象
Validate(addr string) bool // 验证地址正确性
Nil() bool // 判断地址是否为空
Hash() Hash // 地址的hash
Format(s fmt.State, c rune) // 地址格式化
}
type Address ¶
type Address [AddressLength]byte
Address represents the 20 byte address of an account.
func BigToAddress ¶
BigToAddress returns Address with byte values of b. If b is larger than len(h), b will be cropped from the left.
func BytesToAddress ¶
BytesToAddress returns Address with value b. If b is larger than len(h), b will be cropped from the left.
func DomainToAddress ¶
DomainToAddress domainAddr转Address。addr格式:xxx@chain5j.com或0xxxxxxxx
func HexToAddress ¶
HexToAddress returns Address with byte values of s. If s is larger than len(h), s will be cropped from the left.
func StringToAddress ¶
func (Address) Format ¶
Format implements fmt.Formatter, forcing the byte slice to be formatted as is, without going through the stringer interface used for logging.
func (Address) MarshalText ¶
MarshalText returns the hex representation of a.
func (*Address) SetBytes ¶
SetBytes sets the address to the value of b. If b is larger than len(a) it will panic.
func (Address) TerminalString ¶
TerminalString String implements fmt.Stringer.
func (*Address) UnmarshalJSON ¶
UnmarshalJSON parses a hash in hex syntax.
func (*Address) UnmarshalText ¶
UnmarshalText parses a hash in hex syntax.
type CallMsg ¶
type CallMsg struct {
From Address // the sender of the 'transaction'
To *Address // the destination contract (nil for contract creation)
Gas uint64 // if 0, the call executes with near-infinite gas
GasPrice *big.Int // wei <-> gas exchange ratio
Value *big.Int // amount of wei sent along with the call
Data []byte // input data, usually an ABI-encoded contract method invocation
}
CallMsg contains parameters for contract calls.
type DomainAddress ¶
type DomainAddress struct {
Addr Address `json:"addr"` // address
DomainAddr string `json:"domainAddr"` // domainAddr
}
func FromDomainAddress ¶
func FromDomainAddress(addr string) DomainAddress
FromDomainAddress domainAddress 转换为DomainAddress对象。addr格式:xxx@chain5j.com:0xxxxxxxx
func NewDomainAddress ¶
func NewDomainAddress(domain string, addr Address) DomainAddress
func (DomainAddress) Big ¶
func (a DomainAddress) Big() *big.Int
func (DomainAddress) Bytes ¶
func (a DomainAddress) Bytes() []byte
func (DomainAddress) Hash ¶
func (a DomainAddress) Hash() Hash
func (DomainAddress) Len ¶
func (a DomainAddress) Len() int
func (DomainAddress) Nil ¶
func (a DomainAddress) Nil() bool
func (DomainAddress) String ¶
func (a DomainAddress) String() string
func (*DomainAddress) UnmarshalJSON ¶
func (a *DomainAddress) UnmarshalJSON(data []byte) error
func (DomainAddress) Validate ¶
func (a DomainAddress) Validate(addr string) bool
type Hash ¶
type Hash [HashLength]byte
func BytesToHash ¶
func StringToHash ¶
func (Hash) Format ¶
Format implements fmt.Formatter, forcing the byte slice to be formatted as is, without going through the stringer interface used for logging.
func (Hash) HexNoPrefix ¶
func (Hash) MarshalText ¶
MarshalText returns the hex representation of h.
func (*Hash) SetBytes ¶
SetBytes sets the hash to the value of b. If b is larger than len(h), b will be cropped from the left.
func (Hash) String ¶
String implements the stringer interface and is used also by the logger when doing full logging into a file.
func (Hash) TerminalString ¶
TerminalString implements log.TerminalStringer, formatting a string for console output during logging.
func (*Hash) UnmarshalJSON ¶
UnmarshalJSON parses a hash in hex syntax.
func (*Hash) UnmarshalText ¶
UnmarshalText parses a hash in hex syntax.
type MixedcaseAddress ¶
type MixedcaseAddress struct {
// contains filtered or unexported fields
}
MixedcaseAddress retains the original string, which may or may not be correctly checksummed
func NewMixedcaseAddress ¶
func NewMixedcaseAddress(addr Address) MixedcaseAddress
NewMixedcaseAddress constructor (mainly for testing)
func NewMixedcaseAddressFromString ¶
func NewMixedcaseAddressFromString(hexaddr string) (*MixedcaseAddress, error)
NewMixedcaseAddressFromString is mainly meant for unit-testing
func (*MixedcaseAddress) Address ¶
func (ma *MixedcaseAddress) Address() Address
Address returns the address
func (*MixedcaseAddress) MarshalJSON ¶
func (ma *MixedcaseAddress) MarshalJSON() ([]byte, error)
MarshalJSON marshals the original value
func (*MixedcaseAddress) Original ¶
func (ma *MixedcaseAddress) Original() string
Original returns the mixed-case input string
func (*MixedcaseAddress) String ¶
func (ma *MixedcaseAddress) String() string
String implements fmt.Stringer
func (*MixedcaseAddress) UnmarshalJSON ¶
func (ma *MixedcaseAddress) UnmarshalJSON(input []byte) error
UnmarshalJSON parses MixedcaseAddress
func (*MixedcaseAddress) ValidChecksum ¶
func (ma *MixedcaseAddress) ValidChecksum() bool
ValidChecksum returns true if the address has valid checksum
type MultiHash ¶ added in v1.0.4
type MultiHash []byte
func BytesToMultiHash ¶ added in v1.0.4
func StringToMultiHash ¶ added in v1.0.4
func (MultiHash) Format ¶ added in v1.0.4
Format implements fmt.Formatter, forcing the byte slice to be formatted as is, without going through the stringer interface used for logging. log会调用此接口
func (MultiHash) MarshalJSON ¶ added in v1.0.4
func (MultiHash) MarshalText ¶ added in v1.0.4
func (MultiHash) TerminalString ¶ added in v1.0.4
func (*MultiHash) UnmarshalJSON ¶ added in v1.0.4
func (*MultiHash) UnmarshalText ¶ added in v1.0.4
UnmarshalText .
type StorageSize ¶
type StorageSize float64
StorageSize is a wrapper around a float value that supports user friendly formatting.
func (StorageSize) String ¶
func (s StorageSize) String() string
String implements the stringer interface.
func (StorageSize) TerminalString ¶
func (s StorageSize) TerminalString() string
TerminalString implements log.TerminalStringer, formatting a string for console output during logging.
type UnprefixedAddress ¶
type UnprefixedAddress Address
UnprefixedAddress allows marshaling an Address without 0x prefix.
func (UnprefixedAddress) MarshalText ¶
func (a UnprefixedAddress) MarshalText() ([]byte, error)
MarshalText encodes the address as hex.
func (*UnprefixedAddress) UnmarshalText ¶
func (a *UnprefixedAddress) UnmarshalText(input []byte) error
UnmarshalText decodes the address from hex. The 0x prefix is optional.
type UnprefixedHash ¶
type UnprefixedHash Hash
UnprefixedHash allows marshaling a Hash without 0x prefix.
func (UnprefixedHash) MarshalText ¶
func (h UnprefixedHash) MarshalText() ([]byte, error)
MarshalText encodes the hash as hex.
func (*UnprefixedHash) UnmarshalText ¶
func (h *UnprefixedHash) UnmarshalText(input []byte) error
UnmarshalText decodes the hash from hex. The 0x prefix is optional.
type WriteCounter ¶
type WriteCounter StorageSize