Skip to content

Commit

Permalink
Add the gateway message to ErrValidationFailure
Browse files Browse the repository at this point in the history
  • Loading branch information
omerfirmak committed Dec 4, 2023
1 parent 3248d59 commit 36d13b5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
8 changes: 3 additions & 5 deletions rpc/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -1158,7 +1158,7 @@ func makeJSONErrorFromGatewayError(err error) *jsonrpc.Error {
case gateway.InsufficientAccountBalance:
return ErrInsufficientAccountBalance
case gateway.ValidateFailure:
return ErrValidationFailure
return ErrValidationFailure.CloneWithData(gatewayErr.Message)
case gateway.ContractBytecodeSizeTooLarge, gateway.ContractClassObjectSizeTooLarge:
return ErrContractClassSizeTooLarge
case gateway.DuplicatedTransaction:
Expand All @@ -1174,9 +1174,7 @@ func makeJSONErrorFromGatewayError(err error) *jsonrpc.Error {
case gateway.InvalidContractClassVersion:
return ErrUnsupportedContractClassVersion
default:
unexpectedErr := *ErrUnexpectedError
unexpectedErr.Data = gatewayErr.Message
return &unexpectedErr
return ErrUnexpectedError.CloneWithData(gatewayErr.Message)
}
}

Expand Down Expand Up @@ -1664,7 +1662,7 @@ func (h *Handler) callAndLogErr(f func() error, msg string) {
}

func (h *Handler) SpecVersion() (string, *jsonrpc.Error) {
return "0.6.0-rc4", nil
return "0.6.0-rc5", nil
}

func (h *Handler) LegacySpecVersion() (string, *jsonrpc.Error) {
Expand Down
2 changes: 1 addition & 1 deletion rpc/handlers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3672,7 +3672,7 @@ func TestSpecVersion(t *testing.T) {
handler := rpc.New(nil, nil, 0, nil, nil, nil, "", nil)
version, rpcErr := handler.SpecVersion()
require.Nil(t, rpcErr)
require.Equal(t, "0.6.0-rc4", version)
require.Equal(t, "0.6.0-rc5", version)

legacyVersion, rpcErr := handler.LegacySpecVersion()
require.Nil(t, rpcErr)
Expand Down

0 comments on commit 36d13b5

Please sign in to comment.