Skip to content

Commit

Permalink
handle nil gas and gasPrice in backend test client for estimateGas
Browse files Browse the repository at this point in the history
  • Loading branch information
jinhoonbang committed Feb 14, 2024
1 parent ef212f6 commit de2d7f9
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions core/chains/evm/client/simulated_backend_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -728,6 +728,28 @@ func toCallMsg(params map[string]interface{}) ethereum.CallMsg {
callMsg.Value = value
}

switch gas := params["gas"].(type) {
case nil:
// This parameter is not required so nil is acceptable
case uint64:
callMsg.Gas = gas
case hexutil.Uint64:
callMsg.Gas = uint64(gas)
default:
panic("unexpected type of 'gas' parameter; try hexutil.Uint64, or uint64")
}

switch gasPrice := params["gasPrice"].(type) {
case nil:
// This parameter is not required so nil is acceptable
case *big.Int:
callMsg.GasPrice = gasPrice
case *hexutil.Big:
callMsg.GasPrice = gasPrice.ToInt()
default:
panic("unexpected type of 'gasPrice' parameter; try *big.Int, or *hexutil.Big")
}

return callMsg
}

Expand Down

0 comments on commit de2d7f9

Please sign in to comment.