mirror of https://github.com/ethereum/go-ethereum
parent
eee96a5bb7
commit
8cf08e4b25
@ -0,0 +1,136 @@ |
||||
// generated by github.com/fjl/gencodec, do not edit.
|
||||
|
||||
package types |
||||
|
||||
import ( |
||||
"encoding/json" |
||||
"errors" |
||||
"math/big" |
||||
|
||||
"github.com/ethereum/go-ethereum/common" |
||||
"github.com/ethereum/go-ethereum/common/hexutil" |
||||
) |
||||
|
||||
func (h *Header) MarshalJSON() ([]byte, error) { |
||||
type HeaderJSON struct { |
||||
ParentHash *common.Hash `json:"parentHash"` |
||||
UncleHash *common.Hash `json:"sha3Uncles"` |
||||
Coinbase *common.Address `json:"miner"` |
||||
Root *common.Hash `json:"stateRoot"` |
||||
TxHash *common.Hash `json:"transactionsRoot"` |
||||
ReceiptHash *common.Hash `json:"receiptsRoot"` |
||||
Bloom *Bloom `json:"logsBloom"` |
||||
Difficulty *hexutil.Big `json:"difficulty"` |
||||
Number *hexutil.Big `json:"number"` |
||||
GasLimit *hexutil.Big `json:"gasLimit"` |
||||
GasUsed *hexutil.Big `json:"gasUsed"` |
||||
Time *hexutil.Big `json:"timestamp"` |
||||
Extra hexutil.Bytes `json:"extraData"` |
||||
MixDigest *common.Hash `json:"mixHash"` |
||||
Nonce *BlockNonce `json:"nonce"` |
||||
} |
||||
var enc HeaderJSON |
||||
enc.ParentHash = &h.ParentHash |
||||
enc.UncleHash = &h.UncleHash |
||||
enc.Coinbase = &h.Coinbase |
||||
enc.Root = &h.Root |
||||
enc.TxHash = &h.TxHash |
||||
enc.ReceiptHash = &h.ReceiptHash |
||||
enc.Bloom = &h.Bloom |
||||
enc.Difficulty = (*hexutil.Big)(h.Difficulty) |
||||
enc.Number = (*hexutil.Big)(h.Number) |
||||
enc.GasLimit = (*hexutil.Big)(h.GasLimit) |
||||
enc.GasUsed = (*hexutil.Big)(h.GasUsed) |
||||
enc.Time = (*hexutil.Big)(h.Time) |
||||
enc.Extra = h.Extra |
||||
enc.MixDigest = &h.MixDigest |
||||
enc.Nonce = &h.Nonce |
||||
return json.Marshal(&enc) |
||||
} |
||||
|
||||
func (h *Header) UnmarshalJSON(input []byte) error { |
||||
type HeaderJSON struct { |
||||
ParentHash *common.Hash `json:"parentHash"` |
||||
UncleHash *common.Hash `json:"sha3Uncles"` |
||||
Coinbase *common.Address `json:"miner"` |
||||
Root *common.Hash `json:"stateRoot"` |
||||
TxHash *common.Hash `json:"transactionsRoot"` |
||||
ReceiptHash *common.Hash `json:"receiptsRoot"` |
||||
Bloom *Bloom `json:"logsBloom"` |
||||
Difficulty *hexutil.Big `json:"difficulty"` |
||||
Number *hexutil.Big `json:"number"` |
||||
GasLimit *hexutil.Big `json:"gasLimit"` |
||||
GasUsed *hexutil.Big `json:"gasUsed"` |
||||
Time *hexutil.Big `json:"timestamp"` |
||||
Extra hexutil.Bytes `json:"extraData"` |
||||
MixDigest *common.Hash `json:"mixHash"` |
||||
Nonce *BlockNonce `json:"nonce"` |
||||
} |
||||
var dec HeaderJSON |
||||
if err := json.Unmarshal(input, &dec); err != nil { |
||||
return err |
||||
} |
||||
var x Header |
||||
if dec.ParentHash == nil { |
||||
return errors.New("missing required field 'parentHash' for Header") |
||||
} |
||||
x.ParentHash = *dec.ParentHash |
||||
if dec.UncleHash == nil { |
||||
return errors.New("missing required field 'sha3Uncles' for Header") |
||||
} |
||||
x.UncleHash = *dec.UncleHash |
||||
if dec.Coinbase == nil { |
||||
return errors.New("missing required field 'miner' for Header") |
||||
} |
||||
x.Coinbase = *dec.Coinbase |
||||
if dec.Root == nil { |
||||
return errors.New("missing required field 'stateRoot' for Header") |
||||
} |
||||
x.Root = *dec.Root |
||||
if dec.TxHash == nil { |
||||
return errors.New("missing required field 'transactionsRoot' for Header") |
||||
} |
||||
x.TxHash = *dec.TxHash |
||||
if dec.ReceiptHash == nil { |
||||
return errors.New("missing required field 'receiptsRoot' for Header") |
||||
} |
||||
x.ReceiptHash = *dec.ReceiptHash |
||||
if dec.Bloom == nil { |
||||
return errors.New("missing required field 'logsBloom' for Header") |
||||
} |
||||
x.Bloom = *dec.Bloom |
||||
if dec.Difficulty == nil { |
||||
return errors.New("missing required field 'difficulty' for Header") |
||||
} |
||||
x.Difficulty = (*big.Int)(dec.Difficulty) |
||||
if dec.Number == nil { |
||||
return errors.New("missing required field 'number' for Header") |
||||
} |
||||
x.Number = (*big.Int)(dec.Number) |
||||
if dec.GasLimit == nil { |
||||
return errors.New("missing required field 'gasLimit' for Header") |
||||
} |
||||
x.GasLimit = (*big.Int)(dec.GasLimit) |
||||
if dec.GasUsed == nil { |
||||
return errors.New("missing required field 'gasUsed' for Header") |
||||
} |
||||
x.GasUsed = (*big.Int)(dec.GasUsed) |
||||
if dec.Time == nil { |
||||
return errors.New("missing required field 'timestamp' for Header") |
||||
} |
||||
x.Time = (*big.Int)(dec.Time) |
||||
if dec.Extra == nil { |
||||
return errors.New("missing required field 'extraData' for Header") |
||||
} |
||||
x.Extra = dec.Extra |
||||
if dec.MixDigest == nil { |
||||
return errors.New("missing required field 'mixHash' for Header") |
||||
} |
||||
x.MixDigest = *dec.MixDigest |
||||
if dec.Nonce == nil { |
||||
return errors.New("missing required field 'nonce' for Header") |
||||
} |
||||
x.Nonce = *dec.Nonce |
||||
*h = x |
||||
return nil |
||||
} |
@ -0,0 +1,90 @@ |
||||
// generated by github.com/fjl/gencodec, do not edit.
|
||||
|
||||
package types |
||||
|
||||
import ( |
||||
"encoding/json" |
||||
"errors" |
||||
|
||||
"github.com/ethereum/go-ethereum/common" |
||||
"github.com/ethereum/go-ethereum/common/hexutil" |
||||
) |
||||
|
||||
func (l *Log) MarshalJSON() ([]byte, error) { |
||||
type LogJSON struct { |
||||
Address *common.Address `json:"address"` |
||||
Topics []common.Hash `json:"topics"` |
||||
Data hexutil.Bytes `json:"data"` |
||||
BlockNumber *hexutil.Uint64 `json:"blockNumber" optional:"yes"` |
||||
TxHash *common.Hash `json:"transactionHash"` |
||||
TxIndex *hexutil.Uint `json:"transactionIndex"` |
||||
BlockHash *common.Hash `json:"blockHash" optional:"yes"` |
||||
Index *hexutil.Uint `json:"logIndex"` |
||||
Removed *bool `json:"removed" optional:"yes"` |
||||
} |
||||
var enc LogJSON |
||||
enc.Address = &l.Address |
||||
enc.Topics = l.Topics |
||||
enc.Data = l.Data |
||||
enc.BlockNumber = (*hexutil.Uint64)(&l.BlockNumber) |
||||
enc.TxHash = &l.TxHash |
||||
enc.TxIndex = (*hexutil.Uint)(&l.TxIndex) |
||||
enc.BlockHash = &l.BlockHash |
||||
enc.Index = (*hexutil.Uint)(&l.Index) |
||||
enc.Removed = &l.Removed |
||||
return json.Marshal(&enc) |
||||
} |
||||
|
||||
func (l *Log) UnmarshalJSON(input []byte) error { |
||||
type LogJSON struct { |
||||
Address *common.Address `json:"address"` |
||||
Topics []common.Hash `json:"topics"` |
||||
Data hexutil.Bytes `json:"data"` |
||||
BlockNumber *hexutil.Uint64 `json:"blockNumber" optional:"yes"` |
||||
TxHash *common.Hash `json:"transactionHash"` |
||||
TxIndex *hexutil.Uint `json:"transactionIndex"` |
||||
BlockHash *common.Hash `json:"blockHash" optional:"yes"` |
||||
Index *hexutil.Uint `json:"logIndex"` |
||||
Removed *bool `json:"removed" optional:"yes"` |
||||
} |
||||
var dec LogJSON |
||||
if err := json.Unmarshal(input, &dec); err != nil { |
||||
return err |
||||
} |
||||
var x Log |
||||
if dec.Address == nil { |
||||
return errors.New("missing required field 'address' for Log") |
||||
} |
||||
x.Address = *dec.Address |
||||
if dec.Topics == nil { |
||||
return errors.New("missing required field 'topics' for Log") |
||||
} |
||||
x.Topics = dec.Topics |
||||
if dec.Data == nil { |
||||
return errors.New("missing required field 'data' for Log") |
||||
} |
||||
x.Data = dec.Data |
||||
if dec.BlockNumber != nil { |
||||
x.BlockNumber = uint64(*dec.BlockNumber) |
||||
} |
||||
if dec.TxHash == nil { |
||||
return errors.New("missing required field 'transactionHash' for Log") |
||||
} |
||||
x.TxHash = *dec.TxHash |
||||
if dec.TxIndex == nil { |
||||
return errors.New("missing required field 'transactionIndex' for Log") |
||||
} |
||||
x.TxIndex = uint(*dec.TxIndex) |
||||
if dec.BlockHash != nil { |
||||
x.BlockHash = *dec.BlockHash |
||||
} |
||||
if dec.Index == nil { |
||||
return errors.New("missing required field 'logIndex' for Log") |
||||
} |
||||
x.Index = uint(*dec.Index) |
||||
if dec.Removed != nil { |
||||
x.Removed = *dec.Removed |
||||
} |
||||
*l = x |
||||
return nil |
||||
} |
@ -0,0 +1,79 @@ |
||||
// generated by github.com/fjl/gencodec, do not edit.
|
||||
|
||||
package types |
||||
|
||||
import ( |
||||
"encoding/json" |
||||
"errors" |
||||
"math/big" |
||||
|
||||
"github.com/ethereum/go-ethereum/common" |
||||
"github.com/ethereum/go-ethereum/common/hexutil" |
||||
) |
||||
|
||||
func (r *Receipt) MarshalJSON() ([]byte, error) { |
||||
type ReceiptJSON struct { |
||||
PostState hexutil.Bytes `json:"root"` |
||||
CumulativeGasUsed *hexutil.Big `json:"cumulativeGasUsed"` |
||||
Bloom *Bloom `json:"logsBloom"` |
||||
Logs []*Log `json:"logs"` |
||||
TxHash *common.Hash `json:"transactionHash"` |
||||
ContractAddress *common.Address `json:"contractAddress" optional:"true"` |
||||
GasUsed *hexutil.Big `json:"gasUsed"` |
||||
} |
||||
var enc ReceiptJSON |
||||
enc.PostState = r.PostState |
||||
enc.CumulativeGasUsed = (*hexutil.Big)(r.CumulativeGasUsed) |
||||
enc.Bloom = &r.Bloom |
||||
enc.Logs = r.Logs |
||||
enc.TxHash = &r.TxHash |
||||
enc.ContractAddress = &r.ContractAddress |
||||
enc.GasUsed = (*hexutil.Big)(r.GasUsed) |
||||
return json.Marshal(&enc) |
||||
} |
||||
|
||||
func (r *Receipt) UnmarshalJSON(input []byte) error { |
||||
type ReceiptJSON struct { |
||||
PostState hexutil.Bytes `json:"root"` |
||||
CumulativeGasUsed *hexutil.Big `json:"cumulativeGasUsed"` |
||||
Bloom *Bloom `json:"logsBloom"` |
||||
Logs []*Log `json:"logs"` |
||||
TxHash *common.Hash `json:"transactionHash"` |
||||
ContractAddress *common.Address `json:"contractAddress" optional:"true"` |
||||
GasUsed *hexutil.Big `json:"gasUsed"` |
||||
} |
||||
var dec ReceiptJSON |
||||
if err := json.Unmarshal(input, &dec); err != nil { |
||||
return err |
||||
} |
||||
var x Receipt |
||||
if dec.PostState == nil { |
||||
return errors.New("missing required field 'root' for Receipt") |
||||
} |
||||
x.PostState = dec.PostState |
||||
if dec.CumulativeGasUsed == nil { |
||||
return errors.New("missing required field 'cumulativeGasUsed' for Receipt") |
||||
} |
||||
x.CumulativeGasUsed = (*big.Int)(dec.CumulativeGasUsed) |
||||
if dec.Bloom == nil { |
||||
return errors.New("missing required field 'logsBloom' for Receipt") |
||||
} |
||||
x.Bloom = *dec.Bloom |
||||
if dec.Logs == nil { |
||||
return errors.New("missing required field 'logs' for Receipt") |
||||
} |
||||
x.Logs = dec.Logs |
||||
if dec.TxHash == nil { |
||||
return errors.New("missing required field 'transactionHash' for Receipt") |
||||
} |
||||
x.TxHash = *dec.TxHash |
||||
if dec.ContractAddress != nil { |
||||
x.ContractAddress = *dec.ContractAddress |
||||
} |
||||
if dec.GasUsed == nil { |
||||
return errors.New("missing required field 'gasUsed' for Receipt") |
||||
} |
||||
x.GasUsed = (*big.Int)(dec.GasUsed) |
||||
*r = x |
||||
return nil |
||||
} |
@ -0,0 +1,99 @@ |
||||
// generated by github.com/fjl/gencodec, do not edit.
|
||||
|
||||
package types |
||||
|
||||
import ( |
||||
"encoding/json" |
||||
"errors" |
||||
"math/big" |
||||
|
||||
"github.com/ethereum/go-ethereum/common" |
||||
"github.com/ethereum/go-ethereum/common/hexutil" |
||||
) |
||||
|
||||
func (t *txdata) MarshalJSON() ([]byte, error) { |
||||
type txdataJSON struct { |
||||
AccountNonce *hexutil.Uint64 `json:"nonce"` |
||||
Price *hexutil.Big `json:"gasPrice"` |
||||
GasLimit *hexutil.Big `json:"gasLimit"` |
||||
Recipient *common.Address `json:"to" optional:"yes" rlp:"nil"` |
||||
Amount *hexutil.Big `json:"value"` |
||||
Payload hexutil.Bytes `json:"input"` |
||||
V *hexutil.Big `json:"v"` |
||||
R *hexutil.Big `json:"r"` |
||||
S *hexutil.Big `json:"s"` |
||||
Hash *common.Hash `json:"hash" optional:"yes" rlp:"-"` |
||||
} |
||||
var enc txdataJSON |
||||
enc.AccountNonce = (*hexutil.Uint64)(&t.AccountNonce) |
||||
enc.Price = (*hexutil.Big)(t.Price) |
||||
enc.GasLimit = (*hexutil.Big)(t.GasLimit) |
||||
enc.Recipient = t.Recipient |
||||
enc.Amount = (*hexutil.Big)(t.Amount) |
||||
enc.Payload = t.Payload |
||||
enc.V = (*hexutil.Big)(t.V) |
||||
enc.R = (*hexutil.Big)(t.R) |
||||
enc.S = (*hexutil.Big)(t.S) |
||||
enc.Hash = t.Hash |
||||
return json.Marshal(&enc) |
||||
} |
||||
|
||||
func (t *txdata) UnmarshalJSON(input []byte) error { |
||||
type txdataJSON struct { |
||||
AccountNonce *hexutil.Uint64 `json:"nonce"` |
||||
Price *hexutil.Big `json:"gasPrice"` |
||||
GasLimit *hexutil.Big `json:"gasLimit"` |
||||
Recipient *common.Address `json:"to" optional:"yes" rlp:"nil"` |
||||
Amount *hexutil.Big `json:"value"` |
||||
Payload hexutil.Bytes `json:"input"` |
||||
V *hexutil.Big `json:"v"` |
||||
R *hexutil.Big `json:"r"` |
||||
S *hexutil.Big `json:"s"` |
||||
Hash *common.Hash `json:"hash" optional:"yes" rlp:"-"` |
||||
} |
||||
var dec txdataJSON |
||||
if err := json.Unmarshal(input, &dec); err != nil { |
||||
return err |
||||
} |
||||
var x txdata |
||||
if dec.AccountNonce == nil { |
||||
return errors.New("missing required field 'nonce' for txdata") |
||||
} |
||||
x.AccountNonce = uint64(*dec.AccountNonce) |
||||
if dec.Price == nil { |
||||
return errors.New("missing required field 'gasPrice' for txdata") |
||||
} |
||||
x.Price = (*big.Int)(dec.Price) |
||||
if dec.GasLimit == nil { |
||||
return errors.New("missing required field 'gasLimit' for txdata") |
||||
} |
||||
x.GasLimit = (*big.Int)(dec.GasLimit) |
||||
if dec.Recipient != nil { |
||||
x.Recipient = dec.Recipient |
||||
} |
||||
if dec.Amount == nil { |
||||
return errors.New("missing required field 'value' for txdata") |
||||
} |
||||
x.Amount = (*big.Int)(dec.Amount) |
||||
if dec.Payload == nil { |
||||
return errors.New("missing required field 'input' for txdata") |
||||
} |
||||
x.Payload = dec.Payload |
||||
if dec.V == nil { |
||||
return errors.New("missing required field 'v' for txdata") |
||||
} |
||||
x.V = (*big.Int)(dec.V) |
||||
if dec.R == nil { |
||||
return errors.New("missing required field 'r' for txdata") |
||||
} |
||||
x.R = (*big.Int)(dec.R) |
||||
if dec.S == nil { |
||||
return errors.New("missing required field 's' for txdata") |
||||
} |
||||
x.S = (*big.Int)(dec.S) |
||||
if dec.Hash != nil { |
||||
x.Hash = dec.Hash |
||||
} |
||||
*t = x |
||||
return nil |
||||
} |
Loading…
Reference in new issue