Skip to content

Commit e162700

Browse files
committed
use base types for simulate result struct
1 parent ab4049d commit e162700

File tree

3 files changed

+169
-10
lines changed

3 files changed

+169
-10
lines changed

ethclient/ethclient.go

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -853,13 +853,21 @@ func (s SimulateBlock) MarshalJSON() ([]byte, error) {
853853
})
854854
}
855855

856+
//go:generate go run github.com/fjl/gencodec -type SimulateCallResult -field-override simulateCallResultMarshaling -out gen_simulate_call_result.go
857+
856858
// SimulateCallResult is the result of a simulated call.
857859
type SimulateCallResult struct {
858-
ReturnValue hexutil.Bytes `json:"returnData"`
859-
Logs []*types.Log `json:"logs"`
860-
GasUsed hexutil.Uint64 `json:"gasUsed"`
861-
Status hexutil.Uint64 `json:"status"`
862-
Error *CallError `json:"error,omitempty"`
860+
ReturnValue []byte `json:"returnData"`
861+
Logs []*types.Log `json:"logs"`
862+
GasUsed uint64 `json:"gasUsed"`
863+
Status uint64 `json:"status"`
864+
Error *CallError `json:"error,omitempty"`
865+
}
866+
867+
type simulateCallResultMarshaling struct {
868+
ReturnValue hexutil.Bytes
869+
GasUsed hexutil.Uint64
870+
Status hexutil.Uint64
863871
}
864872

865873
// CallError represents an error from a simulated call.
@@ -869,18 +877,28 @@ type CallError struct {
869877
Data string `json:"data,omitempty"`
870878
}
871879

880+
//go:generate go run github.com/fjl/gencodec -type SimulateBlockResult -field-override simulateBlockResultMarshaling -out gen_simulate_block_result.go
881+
872882
// SimulateBlockResult represents the result of a simulated block.
873883
type SimulateBlockResult struct {
874-
Number hexutil.Uint64 `json:"number"`
884+
Number uint64 `json:"number"`
875885
Hash common.Hash `json:"hash"`
876-
Timestamp hexutil.Uint64 `json:"timestamp"`
877-
GasLimit hexutil.Uint64 `json:"gasLimit"`
878-
GasUsed hexutil.Uint64 `json:"gasUsed"`
886+
Timestamp uint64 `json:"timestamp"`
887+
GasLimit uint64 `json:"gasLimit"`
888+
GasUsed uint64 `json:"gasUsed"`
879889
FeeRecipient common.Address `json:"miner"`
880-
BaseFeePerGas *hexutil.Big `json:"baseFeePerGas,omitempty"`
890+
BaseFeePerGas *big.Int `json:"baseFeePerGas,omitempty"`
881891
Calls []SimulateCallResult `json:"calls"`
882892
}
883893

894+
type simulateBlockResultMarshaling struct {
895+
Number hexutil.Uint64
896+
Timestamp hexutil.Uint64
897+
GasLimit hexutil.Uint64
898+
GasUsed hexutil.Uint64
899+
BaseFeePerGas *hexutil.Big
900+
}
901+
884902
// SimulateV1 executes transactions on top of a base state.
885903
func (ec *Client) SimulateV1(ctx context.Context, opts SimulateOptions, blockNrOrHash *rpc.BlockNumberOrHash) ([]SimulateBlockResult, error) {
886904
var result []SimulateBlockResult

ethclient/gen_simulate_block_result.go

Lines changed: 80 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ethclient/gen_simulate_call_result.go

Lines changed: 61 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)