chore: use revert error code for execution reverted

This commit is contained in:
Matthias Seitz 2025-03-20 12:47:12 +01:00 committed by Jared Wasinger
parent 624a5d8b23
commit 87fdcf31eb
2 changed files with 3 additions and 3 deletions

View file

@ -36,7 +36,7 @@ type revertError struct {
// ErrorCode returns the JSON error code for a revert.
// See: https://github.com/ethereum/wiki/wiki/JSON-RPC-Error-Codes-Improvement-Proposal
func (e *revertError) ErrorCode() int {
return 3
return errCodeReverted
}
// ErrorData returns the hex encoded revert reason.
@ -106,7 +106,7 @@ const (
errCodeClientLimitExceeded = -38026
errCodeInternalError = -32603
errCodeInvalidParams = -32602
errCodeReverted = -32000
errCodeReverted = 3
errCodeVMError = -32015
)

View file

@ -248,7 +248,7 @@ func (sim *simulator) processBlock(ctx context.Context, block *simBlock, header,
if errors.Is(result.Err, vm.ErrExecutionReverted) {
// If the result contains a revert reason, try to unpack it.
revertErr := newRevertError(result.Revert())
callRes.Error = &callError{Message: revertErr.Error(), Code: errCodeReverted, Data: revertErr.ErrorData().(string)}
callRes.Error = &callError{Message: revertErr.Error(), Code: revertErr.ErrorCode(), Data: revertErr.ErrorData().(string)}
} else {
callRes.Error = &callError{Message: result.Err.Error(), Code: errCodeVMError}
}