Skip to content

Commit

Permalink
chore: fix protobuf enum names (linting)
Browse files Browse the repository at this point in the history
  • Loading branch information
tzdybal committed Oct 6, 2024
1 parent e0bdd5c commit 0974e2a
Show file tree
Hide file tree
Showing 4 changed files with 110 additions and 106 deletions.
16 changes: 8 additions & 8 deletions errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,40 +94,40 @@ func getGRPCStatus(err error, grpcCode codes.Code, daCode pbda.ErrorCode) *statu

// GRPCStatus returns the gRPC status with details for an ErrBlobNotFound error.
func (e *ErrBlobNotFound) GRPCStatus() *status.Status {
return getGRPCStatus(e, codes.NotFound, pbda.ErrorCode_BlobNotFound)
return getGRPCStatus(e, codes.NotFound, pbda.ErrorCode_ERROR_CODE_BLOB_NOT_FOUND)
}

// GRPCStatus returns the gRPC status with details for an ErrBlobSizeOverLimit error.
func (e *ErrBlobSizeOverLimit) GRPCStatus() *status.Status {
return getGRPCStatus(e, codes.ResourceExhausted, pbda.ErrorCode_BlobSizeOverLimit)
return getGRPCStatus(e, codes.ResourceExhausted, pbda.ErrorCode_ERROR_CODE_BLOB_SIZE_OVER_LIMIT)
}

// GRPCStatus returns the gRPC status with details for an ErrTxTimedOut error.
func (e *ErrTxTimedOut) GRPCStatus() *status.Status {
return getGRPCStatus(e, codes.DeadlineExceeded, pbda.ErrorCode_TxTimedOut)
return getGRPCStatus(e, codes.DeadlineExceeded, pbda.ErrorCode_ERROR_CODE_TX_TIMED_OUT)
}

// GRPCStatus returns the gRPC status with details for an ErrTxAlreadyInMempool error.
func (e *ErrTxAlreadyInMempool) GRPCStatus() *status.Status {
return getGRPCStatus(e, codes.AlreadyExists, pbda.ErrorCode_TxAlreadyInMempool)
return getGRPCStatus(e, codes.AlreadyExists, pbda.ErrorCode_ERROR_CODE_TX_ALREADY_IN_MEMPOOL)
}

// GRPCStatus returns the gRPC status with details for an ErrTxIncorrectAccountSequence error.
func (e *ErrTxIncorrectAccountSequence) GRPCStatus() *status.Status {
return getGRPCStatus(e, codes.InvalidArgument, pbda.ErrorCode_TxIncorrectAccountSequence)
return getGRPCStatus(e, codes.InvalidArgument, pbda.ErrorCode_ERROR_CODE_TX_INCORRECT_ACCOUNT_SEQUENCE)
}

// GRPCStatus returns the gRPC status with details for an ErrTxTooLarge error.
func (e *ErrTxTooLarge) GRPCStatus() *status.Status {
return getGRPCStatus(e, codes.ResourceExhausted, pbda.ErrorCode_TxTooLarge)
return getGRPCStatus(e, codes.ResourceExhausted, pbda.ErrorCode_ERROR_CODE_TX_TOO_LARGE)
}

// GRPCStatus returns the gRPC status with details for an ErrContextDeadline error.
func (e *ErrContextDeadline) GRPCStatus() *status.Status {
return getGRPCStatus(e, codes.DeadlineExceeded, pbda.ErrorCode_ContextDeadline)
return getGRPCStatus(e, codes.DeadlineExceeded, pbda.ErrorCode_ERROR_CODE_CONTEXT_DEADLINE)
}

// GRPCStatus returns the gRPC status with details for an ErrFutureHeight error.
func (e *ErrFutureHeight) GRPCStatus() *status.Status {
return getGRPCStatus(e, codes.OutOfRange, pbda.ErrorCode_FutureHeight)
return getGRPCStatus(e, codes.OutOfRange, pbda.ErrorCode_ERROR_CODE_FUTURE_HEIGHT)
}
18 changes: 9 additions & 9 deletions proto/da/da.proto
Original file line number Diff line number Diff line change
Expand Up @@ -132,15 +132,15 @@ message ValidateResponse {
}

enum ErrorCode {
Unknown = 0;
BlobNotFound = 32001;
BlobSizeOverLimit = 32002;
TxTimedOut = 32003;
TxAlreadyInMempool = 32004;
TxIncorrectAccountSequence = 32005;
TxTooLarge = 32006;
ContextDeadline = 32007;
FutureHeight = 32008;
ERROR_CODE_UNKNOWN = 0;
ERROR_CODE_BLOB_NOT_FOUND = 32001;
ERROR_CODE_BLOB_SIZE_OVER_LIMIT = 32002;
ERROR_CODE_TX_TIMED_OUT = 32003;
ERROR_CODE_TX_ALREADY_IN_MEMPOOL = 32004;
ERROR_CODE_TX_INCORRECT_ACCOUNT_SEQUENCE = 32005;
ERROR_CODE_TX_TOO_LARGE = 32006;
ERROR_CODE_CONTEXT_DEADLINE = 32007;
ERROR_CODE_FUTURE_HEIGHT = 32008;
}

message ErrorDetails {
Expand Down
16 changes: 8 additions & 8 deletions proxy/grpc/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,21 +31,21 @@ func tryToMapError(err error) error {

func errorForCode(code pbda.ErrorCode) error {
switch code {
case pbda.ErrorCode_BlobNotFound:
case pbda.ErrorCode_ERROR_CODE_BLOB_NOT_FOUND:
return &da.ErrBlobNotFound{}
case pbda.ErrorCode_BlobSizeOverLimit:
case pbda.ErrorCode_ERROR_CODE_BLOB_SIZE_OVER_LIMIT:
return &da.ErrBlobSizeOverLimit{}
case pbda.ErrorCode_TxTimedOut:
case pbda.ErrorCode_ERROR_CODE_TX_TIMED_OUT:
return &da.ErrTxTimedOut{}
case pbda.ErrorCode_TxAlreadyInMempool:
case pbda.ErrorCode_ERROR_CODE_TX_ALREADY_IN_MEMPOOL:
return &da.ErrTxAlreadyInMempool{}
case pbda.ErrorCode_TxIncorrectAccountSequence:
case pbda.ErrorCode_ERROR_CODE_TX_INCORRECT_ACCOUNT_SEQUENCE:
return &da.ErrTxIncorrectAccountSequence{}
case pbda.ErrorCode_TxTooLarge:
case pbda.ErrorCode_ERROR_CODE_TX_TOO_LARGE:
return &da.ErrTxTooLarge{}
case pbda.ErrorCode_ContextDeadline:
case pbda.ErrorCode_ERROR_CODE_CONTEXT_DEADLINE:
return &da.ErrContextDeadline{}
case pbda.ErrorCode_FutureHeight:
case pbda.ErrorCode_ERROR_CODE_FUTURE_HEIGHT:
return &da.ErrFutureHeight{}
default:
return errors.New("unknown error code")
Expand Down
166 changes: 85 additions & 81 deletions types/pb/da/da.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 0974e2a

Please sign in to comment.