go-ethereum/ethclient/gen_simulate_call_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

61 lines
1.6 KiB
Go

// Code generated by github.com/fjl/gencodec. DO NOT EDIT.
package ethclient
import (
"encoding/json"
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/core/types"
)
var _ = (*simulateCallResultMarshaling)(nil)
// MarshalJSON marshals as JSON.
func (s SimulateCallResult) MarshalJSON() ([]byte, error) {
type SimulateCallResult struct {
ReturnValue hexutil.Bytes `json:"returnData"`
Logs []*types.Log `json:"logs"`
GasUsed hexutil.Uint64 `json:"gasUsed"`
Status hexutil.Uint64 `json:"status"`
Error *CallError `json:"error,omitempty"`
}
var enc SimulateCallResult
enc.ReturnValue = s.ReturnValue
enc.Logs = s.Logs
enc.GasUsed = hexutil.Uint64(s.GasUsed)
enc.Status = hexutil.Uint64(s.Status)
enc.Error = s.Error
return json.Marshal(&enc)
}
// UnmarshalJSON unmarshals from JSON.
func (s *SimulateCallResult) UnmarshalJSON(input []byte) error {
type SimulateCallResult struct {
ReturnValue *hexutil.Bytes `json:"returnData"`
Logs []*types.Log `json:"logs"`
GasUsed *hexutil.Uint64 `json:"gasUsed"`
Status *hexutil.Uint64 `json:"status"`
Error *CallError `json:"error,omitempty"`
}
var dec SimulateCallResult
if err := json.Unmarshal(input, &dec); err != nil {
return err
}
if dec.ReturnValue != nil {
s.ReturnValue = *dec.ReturnValue
}
if dec.Logs != nil {
s.Logs = dec.Logs
}
if dec.GasUsed != nil {
s.GasUsed = uint64(*dec.GasUsed)
}
if dec.Status != nil {
s.Status = uint64(*dec.Status)
}
if dec.Error != nil {
s.Error = dec.Error
}
return nil
}