From 839e841aaee6d97e2ff3991503fe098e2fdd3063 Mon Sep 17 00:00:00 2001 From: Hiep Date: Tue, 26 Nov 2024 11:19:01 +0700 Subject: [PATCH] Add estimate gas with block overrides --- pkg/eth/simulator.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/pkg/eth/simulator.go b/pkg/eth/simulator.go index 11b8c8f..bc077ac 100644 --- a/pkg/eth/simulator.go +++ b/pkg/eth/simulator.go @@ -45,6 +45,20 @@ func (s *Simulator) CallContract( return s.gethClient.CallContract(ctx, msg, blockNumber, overrides) } +func (s *Simulator) EstimateGasWithBlockOverrides( + ctx context.Context, msg ethereum.CallMsg, blockNumber *big.Int, + overrides *map[common.Address]gethclient.OverrideAccount, + blockOverrides gethclient.BlockOverrides, +) (uint64, error) { + var gas hexutil.Uint64 + err := s.c.CallContext( + ctx, &gas, "eth_estimateGas", mev.ToCallArg(msg), + toBlockNumArg(blockNumber), overrides, blockOverrides, + ) + + return uint64(gas), err +} + func toBlockNumArg(number *big.Int) string { if number == nil { return "latest"