types

package
v0.0.0-...-9de16bd Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2021 License: GPL-3.0 Imports: 4 Imported by: 0

Documentation

Overview

Package types contains the types used to interact with the json-rpc interface. It exists for users of fab3 types to use them without importing the fabric protobuf definitions.

Index

Constants

View Source
const (
	// HexEncodedAddressLegnth is 20 bytes, which is 40 chars when hex-encoded
	HexEncodedAddressLegnth = 40
	// HexEncodedTopicLegnth is 32 bytes, which is 64 hex chars when hex-encoded
	HexEncodedTopicLegnth = 64
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AddressFilter

type AddressFilter []string // 20 Byte Addresses, OR'd together

func NewAddressFilter

func NewAddressFilter(s string) (AddressFilter, error)

NewAddressFilter takes a string and checks that is the correct length to represent a topic and strips the 0x

type Block

type Block struct {
	BlockData
	Transactions []interface{} `json:"transactions"` // transactions: Array - Array of transaction objects, or 32 Bytes transaction hashes depending on the last given parameter.
}

Block is an eth return struct defined https://github.com/ethereum/wiki/wiki/JSON-RPC#returns-26

func (*Block) MarshalJSON

func (originalBlk *Block) MarshalJSON() ([]byte, error)

MarshalJSON marshals the data differently based on whether transactions are full or just tx hashes

type BlockData

type BlockData struct {
	Number           string `json:"number"`     // number: QUANTITY - the block number. null when its pending block.
	Hash             string `json:"hash"`       // hash: DATA, 32 Bytes - hash of the block. null when its pending block.
	ParentHash       string `json:"parentHash"` // parentHash: DATA, 32 Bytes - hash of the parent block.
	Nonce            string
	GasLimit         string `json:"gasLimit"` // gasLimit: QUANTITY - the maximum gas allowed in this block.
	Sha3Uncles       string
	LogsBloom        string
	TransactionsRoot string
	StateRoot        string
	ReceiptsRoot     string
	Miner            string
	Difficulty       string
	TotalDifficulty  string
	ExtraData        string
	Size             string
	GasUsed          string
	Timestamp        string
	Transactions     string
	Uncles           string
}

BlockData contains the fields that are constant in a Block object

type EthArgs

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

type Filter

type Filter struct {
	GetLogsArgs
	Time     int64  `json:"time"`
	FilterID string `json:"filterId"`
}

type GetLogsArgs

type GetLogsArgs struct {
	FromBlock string        `json:"fromBlock,omitempty"`
	ToBlock   string        `json:"toBlock,omitempty"`
	Address   AddressFilter `json:"address,omitempty"`
	Topics    TopicsFilter  `json:"topics,omitempty"`
	BlockHash string        `json:"blockHash,omitempty"`
}

func (*GetLogsArgs) UnmarshalJSON

func (gla *GetLogsArgs) UnmarshalJSON(data []byte) error

type Log

type Log struct {
	Address     string   `json:"address"`
	Topics      []string `json:"topics"`
	Data        string   `json:"data,omitempty"`
	BlockNumber string   `json:"blockNumber"`
	TxHash      string   `json:"transactionHash"`
	TxIndex     string   `json:"transactionIndex"`
	BlockHash   string   `json:"blockHash"`
	Index       string   `json:"logIndex"`
}

type TopicFilter

type TopicFilter []string // 32 Byte Topics, OR'd together

func NewTopicFilter

func NewTopicFilter(s string) (TopicFilter, error)

NewTopicFilter takes a string and checks that is the correct length to represent a topic and strips the 0x

type TopicsFilter

type TopicsFilter []TopicFilter // TopicFilter, AND'd together

func NewTopicsFilter

func NewTopicsFilter(tf ...TopicFilter) TopicsFilter

type Transaction

type Transaction struct {
	BlockHash   string `json:"blockHash"`   // DATA, 32 Bytes - hash of the block where this transaction was in. null when its pending.
	BlockNumber string `json:"blockNumber"` // QUANTITY - block number where this transaction was in. null when its pending.
	To          string `json:"to"`          // DATA, 20 Bytes - address of the receiver. null when its a contract creation transaction.

	From             string `json:"from"`             // DATA, 20 Bytes - address of the sender.
	Input            string `json:"input"`            // DATA - the data send along with the transaction.
	TransactionIndex string `json:"transactionIndex"` // QUANTITY - integer of the transactions index position in the block. null when its pending.
	Nonce            string `json:"nonce"`
	Hash             string `json:"hash"` // DATA, 32 Bytes - hash of the transaction.
	Gas              string `json:"gas"`
	GasPrice         string `json:"gasPrice"` // QUANTITY - gas price provided by the sender in Wei.
	Value            string `json:"value"`    // QUANTITY - value transferred in Wei.
}

Transaction represents an ethereum evm transaction.

https://github.com/ethereum/wiki/wiki/JSON-RPC#returns-28

func (*Transaction) MarshalJSON

func (tx *Transaction) MarshalJSON() ([]byte, error)

MarshalJSON will json marshal the tx object as well as setting the Gas Price and Value fields as Ox0

type TxReceipt

type TxReceipt struct {
	TransactionHash   string `json:"transactionHash"`
	TransactionIndex  string `json:"transactionIndex"`
	BlockHash         string `json:"blockHash"`
	BlockNumber       string `json:"blockNumber"`
	From              string `json:"from"`
	To                string `json:"to"`
	CumulativeGasUsed int    `json:"cumulativeGasUsed"`
	GasUsed           int    `json:"gasUsed"`
	ContractAddress   string `json:"contractAddress,omitempty"`
	Logs              []Log  `json:"logs"`
	LogsBloom         string `json:"logs_bloom"`
	Status            string `json:"status"`
}

func (*TxReceipt) MarshalJSON

func (txReceipt *TxReceipt) MarshalJSON() ([]byte, error)

MarshalJSON will json marshal the transaction receipt and set Logs to an empty []Log if none returned

Jump to

Keyboard shortcuts

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