Skip to content

Commit

Permalink
Add estimate gas with block overrides (#98)
Browse files Browse the repository at this point in the history
  • Loading branch information
hiepnv90 authored Nov 26, 2024
1 parent 5f3cf28 commit 3e4764f
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions pkg/eth/simulator.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 3e4764f

Please sign in to comment.