dto

package
v0.0.0-...-aff2438 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const AddressLength = 20

Variables

This section is empty.

Functions

func Bytes2Hex

func Bytes2Hex(d []byte) string

Bytes2Hex returns the hexadecimal encoding of d.

func FromHex

func FromHex(s string) []byte

FromHex returns the bytes represented by the hexadecimal string s. s may be prefixed with "0x".

func Hex2Bytes

func Hex2Bytes(str string) []byte

Hex2Bytes returns the bytes represented by the hexadecimal string str.

func IsHexAddress

func IsHexAddress(s string) bool

IsHexAddress verifies whether a string can represent a valid hex-encoded Ethereum address or not.

Types

type Address

type Address [AddressLength]byte

Address represents the 20 byte address of an Ethereum account.

func BigToAddress

func BigToAddress(b *big.Int) Address

BigToAddress returns Address with byte values of b. If b is larger than len(h), b will be cropped from the left.

func BytesToAddress

func BytesToAddress(b []byte) Address

BytesToAddress returns Address with value b. If b is larger than len(h), b will be cropped from the left.

func HexToAddress

func HexToAddress(s string) Address

HexToAddress returns Address with byte values of s. If s is larger than len(h), s will be cropped from the left.

func (Address) Bytes

func (a Address) Bytes() []byte

Bytes gets the string representation of the underlying address.

func (Address) Format

func (a Address) Format(s fmt.State, c rune)

Format implements fmt.Formatter, forcing the byte slice to be formatted as is, without going through the stringer interface used for logging.

func (Address) Hex

func (a Address) Hex() string

Hex returns an EIP55-compliant hex string representation of the address.

func (Address) ImplementsGraphQLType

func (a Address) ImplementsGraphQLType(name string) bool

ImplementsGraphQLType returns true if Hash implements the specified GraphQL type.

func (Address) MarshalText

func (a Address) MarshalText() ([]byte, error)

MarshalText returns the hex representation of a.

func (*Address) Scan

func (a *Address) Scan(src interface{}) error

Scan implements Scanner for database/sql.

func (*Address) SetBytes

func (a *Address) SetBytes(b []byte)

SetBytes sets the address to the value of b. If b is larger than len(a) it will panic.

func (Address) String

func (a Address) String() string

String implements fmt.Stringer.

func (*Address) UnmarshalGraphQL

func (a *Address) UnmarshalGraphQL(input interface{}) error

UnmarshalGraphQL unmarshals the provided GraphQL query data.

func (*Address) UnmarshalJSON

func (a *Address) UnmarshalJSON(input []byte) error

UnmarshalJSON parses a hash in hex syntax.

func (*Address) UnmarshalText

func (a *Address) UnmarshalText(input []byte) error

UnmarshalText parses a hash in hex syntax.

func (Address) Value

func (a Address) Value() (driver.Value, error)

Value implements valuer for database/sql.

type Block

type Block struct {
	Number     *big.Int `json:"number"`
	Hash       string   `json:"hash"`
	ParentHash string   `json:"parentHash"`
	Author     string   `json:"author,omitempty"`
	Miner      string   `json:"miner,omitempty"`
	Size       *big.Int `json:"size"`
	GasUsed    *big.Int `json:"gasUsed"`
	Nonce      *big.Int `json:"nonce"`
	Timestamp  *big.Int `json:"timestamp"`
}

func (*Block) UnmarshalJSON

func (b *Block) UnmarshalJSON(data []byte) error

*

  • How to un-marshal the block struct using the Big.Int rather than the
  • `complexReturn` type.

type Error

type Error struct {
	Code    int         `json:"code"`
	Message string      `json:"message"`
	Data    interface{} `json:"data"`
}

type RequestResult

type RequestResult struct {
	ID      int             `json:"id"`
	Version string          `json:"jsonrpc"`
	Result  json.RawMessage `json:"result"`
	Error   *Error          `json:"error,omitempty"`
	Data    string          `json:"data,omitempty"`
}

func (*RequestResult) ToBigInt

func (pointer *RequestResult) ToBigInt() (*big.Int, error)

func (*RequestResult) ToBlock

func (pointer *RequestResult) ToBlock() (*Block, error)

func (*RequestResult) ToBoolean

func (pointer *RequestResult) ToBoolean() (bool, error)

func (pointer *RequestResult) ToComplexIntResponse() (types.ComplexIntResponse, error) {

if err := pointer.checkResponse(); err != nil {
	return types.ComplexIntResponse(0), err
}

result := (pointer).Result.(interface{})

var hex string

switch v := result.(type) {
//Testrpc returns a float64
case float64:
	hex = strconv.FormatFloat(v, 'E', 16, 64)
	break
default:
	hex = result.(string)
}

cleaned := strings.TrimPrefix(hex, "0x")

return types.ComplexIntResponse(cleaned), nil

}

func (*RequestResult) ToComplexString

func (pointer *RequestResult) ToComplexString() (types.ComplexString, error)

func (*RequestResult) ToInt

func (pointer *RequestResult) ToInt() (int64, error)

func (*RequestResult) ToSignTransactionResponse

func (pointer *RequestResult) ToSignTransactionResponse() (*SignTransactionResponse, error)

func (*RequestResult) ToString

func (pointer *RequestResult) ToString() (string, error)

func (*RequestResult) ToStringArray

func (pointer *RequestResult) ToStringArray() ([]string, error)

func (*RequestResult) ToSyncingResponse

func (pointer *RequestResult) ToSyncingResponse() (*SyncingResponse, error)

func (*RequestResult) ToTransactionReceipt

func (pointer *RequestResult) ToTransactionReceipt() (*TransactionReceipt, error)

func (*RequestResult) ToTransactionResponse

func (pointer *RequestResult) ToTransactionResponse() (*TransactionResponse, error)

func (*RequestResult) UnMarshalResult

func (pointer *RequestResult) UnMarshalResult(result interface{}) error

type RequestTransactionParameters

type RequestTransactionParameters struct {
	From     string `json:"from"`
	To       string `json:"to,omitempty"`
	Nonce    string `json:"nonce,omitempty"`
	Gas      string `json:"gas,omitempty"`
	GasPrice string `json:"gasPrice,omitempty"`
	Value    string `json:"value,omitempty"`
	Data     string `json:"data,omitempty"`
}

RequestTransactionParameters JSON

type SHHPostParameters

type SHHPostParameters struct {
	From     string   `json:"from"`
	To       string   `json:"to"`
	Topics   []string `json:"topics"`
	Payload  string   `json:"payload"`
	Priority string   `json:"priority"`
	TTL      string   `json:"ttl"`
}

type SignTransactionResponse

type SignTransactionResponse struct {
	Raw         types.ComplexString     `json:"raw"`
	Transaction SignedTransactionParams `json:"tx"`
}

type SignedTransactionParams

type SignedTransactionParams struct {
	Gas      *big.Int `json:gas`
	GasPrice *big.Int `json:gasPrice`
	Hash     string   `json:hash`
	Input    string   `json:input`
	Nonce    *big.Int `json:nonce`
	S        string   `json:s`
	R        string   `json:r`
	V        *big.Int `json:v`
	To       string   `json:to`
	Value    *big.Int `json:value`
}

func (*SignedTransactionParams) UnmarshalJSON

func (sp *SignedTransactionParams) UnmarshalJSON(data []byte) error

type SyncingResponse

type SyncingResponse struct {
	StartingBlock *big.Int `json:"startingBlock"`
	CurrentBlock  *big.Int `json:"currentBlock"`
	HighestBlock  *big.Int `json:"highestBlock"`
}

type TransactionLogs

type TransactionLogs struct {
	Address          string   `json:"address"`
	Topics           []string `json:"topics"`
	Data             string   `json:"data"`
	BlockNumber      *big.Int `json:"blockNumber"`
	TransactionHash  string   `json:"transactionHash"`
	TransactionIndex *big.Int `json:"transactionIndex"`
	BlockHash        string   `json:"blockHash"`
	LogIndex         *big.Int `json:"logIndex"`
	Removed          bool     `json:"removed"`
}

func (*TransactionLogs) UnmarshalJSON

func (r *TransactionLogs) UnmarshalJSON(data []byte) error

type TransactionParameters

type TransactionParameters struct {
	From     string
	To       string
	Nonce    *big.Int
	Gas      *big.Int
	GasPrice *big.Int
	Value    *big.Int
	Data     types.ComplexString
}

TransactionParameters GO transaction to make more easy controll the parameters

func (*TransactionParameters) Transform

Transform the GO transactions parameters to json style

type TransactionReceipt

type TransactionReceipt struct {
	TransactionHash   string            `json:"transactionHash"`
	TransactionIndex  *big.Int          `json:"transactionIndex"`
	BlockHash         string            `json:"blockHash"`
	BlockNumber       *big.Int          `json:"blockNumber"`
	From              string            `json:"from"`
	To                string            `json:"to"`
	CumulativeGasUsed *big.Int          `json:"cumulativeGasUsed"`
	GasUsed           *big.Int          `json:"gasUsed"`
	ContractAddress   string            `json:"contractAddress"`
	Logs              []TransactionLogs `json:"logs"`
	LogsBloom         string            `json:"logsBloom"`
	Root              string            `json:"string"`
	Status            bool              `json:"status"`
}

func (*TransactionReceipt) UnmarshalJSON

func (r *TransactionReceipt) UnmarshalJSON(data []byte) error

type TransactionResponse

type TransactionResponse struct {
	Hash             string              `json:"hash"`
	Nonce            *big.Int            `json:"nonce"`
	BlockHash        string              `json:"blockHash"`
	BlockNumber      *big.Int            `json:"blockNumber"`
	TransactionIndex *big.Int            `json:"transactionIndex"`
	From             string              `json:"from"`
	To               string              `json:"to"`
	Input            string              `json:"input"`
	Value            *big.Int            `json:"value"`
	GasPrice         *big.Int            `json:"gasPrice,omitempty"`
	Gas              *big.Int            `json:"gas,omitempty"`
	Data             types.ComplexString `json:"data,omitempty"`
}

func (*TransactionResponse) UnmarshalJSON

func (t *TransactionResponse) UnmarshalJSON(data []byte) error

Jump to

Keyboard shortcuts

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