go-ethereum/ethclient/gen_simulate_block_result.go
hero5512 c37bd67019
ethclient: add support for eth_simulateV1 (#32856)
Adds ethclient support for the eth_simulateV1 RPC method, which allows
simulating transactions on top of a base state without making changes to
the blockchain.

---------

Co-authored-by: Sina Mahmoodi <itz.s1na@gmail.com>
2025-10-16 17:32:55 +02:00

80 lines
2.3 KiB
Go

// Code generated by github.com/fjl/gencodec. DO NOT EDIT.
package ethclient
import (
"encoding/json"
"math/big"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/hexutil"
)
var _ = (*simulateBlockResultMarshaling)(nil)
// MarshalJSON marshals as JSON.
func (s SimulateBlockResult) MarshalJSON() ([]byte, error) {
type SimulateBlockResult struct {
Number *hexutil.Big `json:"number"`
Hash common.Hash `json:"hash"`
Timestamp hexutil.Uint64 `json:"timestamp"`
GasLimit hexutil.Uint64 `json:"gasLimit"`
GasUsed hexutil.Uint64 `json:"gasUsed"`
FeeRecipient common.Address `json:"miner"`
BaseFeePerGas *hexutil.Big `json:"baseFeePerGas,omitempty"`
Calls []SimulateCallResult `json:"calls"`
}
var enc SimulateBlockResult
enc.Number = (*hexutil.Big)(s.Number)
enc.Hash = s.Hash
enc.Timestamp = hexutil.Uint64(s.Timestamp)
enc.GasLimit = hexutil.Uint64(s.GasLimit)
enc.GasUsed = hexutil.Uint64(s.GasUsed)
enc.FeeRecipient = s.FeeRecipient
enc.BaseFeePerGas = (*hexutil.Big)(s.BaseFeePerGas)
enc.Calls = s.Calls
return json.Marshal(&enc)
}
// UnmarshalJSON unmarshals from JSON.
func (s *SimulateBlockResult) UnmarshalJSON(input []byte) error {
type SimulateBlockResult struct {
Number *hexutil.Big `json:"number"`
Hash *common.Hash `json:"hash"`
Timestamp *hexutil.Uint64 `json:"timestamp"`
GasLimit *hexutil.Uint64 `json:"gasLimit"`
GasUsed *hexutil.Uint64 `json:"gasUsed"`
FeeRecipient *common.Address `json:"miner"`
BaseFeePerGas *hexutil.Big `json:"baseFeePerGas,omitempty"`
Calls []SimulateCallResult `json:"calls"`
}
var dec SimulateBlockResult
if err := json.Unmarshal(input, &dec); err != nil {
return err
}
if dec.Number != nil {
s.Number = (*big.Int)(dec.Number)
}
if dec.Hash != nil {
s.Hash = *dec.Hash
}
if dec.Timestamp != nil {
s.Timestamp = uint64(*dec.Timestamp)
}
if dec.GasLimit != nil {
s.GasLimit = uint64(*dec.GasLimit)
}
if dec.GasUsed != nil {
s.GasUsed = uint64(*dec.GasUsed)
}
if dec.FeeRecipient != nil {
s.FeeRecipient = *dec.FeeRecipient
}
if dec.BaseFeePerGas != nil {
s.BaseFeePerGas = (*big.Int)(dec.BaseFeePerGas)
}
if dec.Calls != nil {
s.Calls = dec.Calls
}
return nil
}