github.com/hyperledger/burrow@v0.34.5-0.20220512172541-77f09336001d/rpc/web3/ethclient/types.go (about) 1 package ethclient 2 3 import ( 4 "github.com/hyperledger/burrow/binary" 5 "github.com/hyperledger/burrow/crypto" 6 "github.com/hyperledger/burrow/encoding/web3hex" 7 "github.com/hyperledger/burrow/rpc/rpcevents" 8 ) 9 10 // These types partially duplicate some of those web3/types.go, the should probably be unified at some point but 11 // the types in web3/types.go are generated and some are incorrect so adding ones used by client here 12 13 type EthLog struct { 14 Topics []string `json:"topics"` 15 // Hex representation of a Keccak 256 hash 16 TransactionHash string `json:"transactionHash"` 17 // Sender of the transaction 18 Address string `json:"address"` 19 // The hex representation of the Keccak 256 of the RLP encoded block 20 BlockHash string `json:"blockHash"` 21 // The hex representation of the block's height 22 BlockNumber string `json:"blockNumber"` 23 // Hex representation of a variable length byte array 24 Data string `json:"data"` 25 // Hex representation of the integer 26 LogIndex string `json:"logIndex"` 27 // Hex representation of the integer 28 TransactionIndex string `json:"transactionIndex"` 29 } 30 31 // This is wrong in web3/types.go 32 type EthSendTransactionParam struct { 33 // Address of the sender 34 From string `json:"from"` 35 // address of the receiver. null when its a contract creation transaction 36 To string `json:"to,omitempty"` 37 // The data field sent with the transaction 38 Gas string `json:"gas,omitempty"` 39 // The gas price willing to be paid by the sender in Wei 40 GasPrice string `json:"gasPrice,omitempty"` 41 // The gas limit provided by the sender in Wei 42 Value string `json:"value,omitempty"` 43 // Hex representation of a Keccak 256 hash 44 Data string `json:"data"` 45 // A number only to be used once 46 Nonce string `json:"nonce,omitempty"` 47 } 48 49 type Filter struct { 50 *rpcevents.BlockRange 51 Addresses []crypto.Address 52 Topics []binary.Word256 53 } 54 55 func (f *Filter) EthFilter() *EthFilter { 56 topics := make([]string, len(f.Topics)) 57 for i, t := range f.Topics { 58 topics[i] = web3hex.Encoder.BytesTrim(t[:]) 59 } 60 addresses := make([]string, len(f.Addresses)) 61 for i, a := range f.Addresses { 62 addresses[i] = web3hex.Encoder.Address(a) 63 } 64 return &EthFilter{ 65 FromBlock: logBound(f.GetStart()), 66 ToBlock: logBound(f.GetEnd()), 67 Addresses: addresses, 68 Topics: topics, 69 } 70 } 71 72 type Receipt struct { 73 // The hex representation of the block's height 74 BlockNumber string `json:"blockNumber"` 75 // Hex representation of the integer 76 CumulativeGasUsed string `json:"cumulativeGasUsed"` 77 // Hex representation of the integer 78 GasUsed string `json:"gasUsed"` 79 // An array of all the logs triggered during the transaction 80 Logs []EthLog `json:"logs"` 81 // A 2048 bit bloom filter from the logs of the transaction. Each log sets 3 bits though taking the low-order 11 bits of each of the first three pairs of bytes in a Keccak 256 hash of the log's byte series 82 TransactionIndex string `json:"transactionIndex"` 83 // Whether or not the transaction threw an error. 84 Status string `json:"status"` 85 // The hex representation of the Keccak 256 of the RLP encoded block 86 BlockHash string `json:"blockHash"` 87 // The contract address created, if the transaction was a contract creation, otherwise null 88 ContractAddress string `json:"contractAddress"` 89 // The sender of the transaction 90 From string `json:"from"` 91 // A 2048 bit bloom filter from the logs of the transaction. Each log sets 3 bits though taking the low-order 11 bits of each of the first three pairs of bytes in a Keccak 256 hash of the log's byte series 92 LogsBloom string `json:"logsBloom"` 93 // Destination address of the transaction 94 To string `json:"to"` 95 // Hex representation of a Keccak 256 hash 96 TransactionHash string `json:"transactionHash"` 97 } 98 99 // Duplicated here to allow for arrays of addresses 100 type EthFilter struct { 101 // The hex representation of the block's height 102 FromBlock string `json:"fromBlock,omitempty"` 103 // The hex representation of the block's height 104 ToBlock string `json:"toBlock,omitempty"` 105 // Yes this is JSON address since allowed to be singular 106 Addresses []string `json:"address,omitempty"` 107 // Array of 32 Bytes DATA topics. Topics are order-dependent. Each topic can also be an array of DATA with 'or' options 108 Topics []string `json:"topics,omitempty"` 109 } 110 111 type Block struct { 112 // Hex representation of a Keccak 256 hash 113 Sha3Uncles string `json:"sha3Uncles"` 114 // Hex representation of a Keccak 256 hash 115 TransactionsRoot string `json:"transactionsRoot"` 116 // Hex representation of a Keccak 256 hash 117 ParentHash string `json:"parentHash"` 118 // The address of the beneficiary to whom the mining rewards were given or null when its the pending block 119 Miner string `json:"miner"` 120 // Integer of the difficulty for this block 121 Difficulty string `json:"difficulty"` 122 // The total used gas by all transactions in this block 123 GasUsed string `json:"gasUsed"` 124 // The unix timestamp for when the block was collated 125 Timestamp string `json:"timestamp"` 126 // Array of transaction objects, or 32 Bytes transaction hashes depending on the last given parameter 127 Transactions []string `json:"transactions"` 128 // The block number or null when its the pending block 129 Number string `json:"number"` 130 // The block hash or null when its the pending block 131 Hash string `json:"hash"` 132 // Array of uncle hashes 133 Uncles []string `json:"uncles"` 134 // Hex representation of a Keccak 256 hash 135 ReceiptsRoot string `json:"receiptsRoot"` 136 // The 'extra data' field of this block 137 ExtraData string `json:"extraData"` 138 // Hex representation of a Keccak 256 hash 139 StateRoot string `json:"stateRoot"` 140 // Integer of the total difficulty of the chain until this block 141 TotalDifficulty string `json:"totalDifficulty"` 142 // Integer the size of this block in bytes 143 Size string `json:"size"` 144 // The maximum gas allowed in this block 145 GasLimit string `json:"gasLimit"` 146 // Randomly selected number to satisfy the proof-of-work or null when its the pending block 147 Nonce string `json:"nonce"` 148 // The bloom filter for the logs of the block or null when its the pending block 149 LogsBloom string `json:"logsBloom"` 150 }