2018-08-09 01:06:34 +00:00
|
|
|
package types
|
|
|
|
|
|
|
|
import (
|
|
|
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
|
|
)
|
|
|
|
|
2018-11-28 22:19:22 +00:00
|
|
|
// Ethermint error codes
|
2018-08-09 01:06:34 +00:00
|
|
|
const (
|
2018-11-28 22:19:22 +00:00
|
|
|
// DefaultCodespace reserves a Codespace for Ethermint.
|
|
|
|
DefaultCodespace sdk.CodespaceType = "ethermint"
|
2018-08-09 01:06:34 +00:00
|
|
|
|
2019-09-18 13:51:18 +00:00
|
|
|
CodeInvalidValue sdk.CodeType = 1
|
|
|
|
CodeInvalidChainID sdk.CodeType = 2
|
|
|
|
CodeInvalidSender sdk.CodeType = 3
|
|
|
|
CodeVMExecution sdk.CodeType = 4
|
|
|
|
CodeInvalidIntrinsicGas sdk.CodeType = 5
|
2018-08-09 01:06:34 +00:00
|
|
|
)
|
|
|
|
|
2019-07-02 19:36:22 +00:00
|
|
|
// CodeToDefaultMsg takes the CodeType variable and returns the error string
|
|
|
|
func CodeToDefaultMsg(code sdk.CodeType) string {
|
2018-08-09 01:06:34 +00:00
|
|
|
switch code {
|
2018-11-28 22:19:22 +00:00
|
|
|
case CodeInvalidValue:
|
|
|
|
return "invalid value"
|
2018-12-18 16:10:04 +00:00
|
|
|
case CodeInvalidChainID:
|
|
|
|
return "invalid chain ID"
|
2019-09-18 13:51:18 +00:00
|
|
|
case CodeInvalidSender:
|
|
|
|
return "could not derive sender from transaction"
|
|
|
|
case CodeVMExecution:
|
|
|
|
return "error while executing evm transaction"
|
|
|
|
case CodeInvalidIntrinsicGas:
|
|
|
|
return "invalid intrinsic gas"
|
2018-08-09 01:06:34 +00:00
|
|
|
default:
|
|
|
|
return sdk.CodeToDefaultMsg(code)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-09-18 13:51:18 +00:00
|
|
|
// ErrInvalidValue returns a standardized SDK error resulting from an invalid value.
|
2018-11-28 22:19:22 +00:00
|
|
|
func ErrInvalidValue(msg string) sdk.Error {
|
|
|
|
return sdk.NewError(DefaultCodespace, CodeInvalidValue, msg)
|
|
|
|
}
|
|
|
|
|
2019-09-18 13:51:18 +00:00
|
|
|
// ErrInvalidChainID returns a standardized SDK error resulting from an invalid chain ID.
|
2018-12-18 16:10:04 +00:00
|
|
|
func ErrInvalidChainID(msg string) sdk.Error {
|
|
|
|
return sdk.NewError(DefaultCodespace, CodeInvalidChainID, msg)
|
2018-08-09 01:06:34 +00:00
|
|
|
}
|
2019-09-18 13:51:18 +00:00
|
|
|
|
|
|
|
// ErrInvalidSender returns a standardized SDK error resulting from an invalid transaction sender.
|
|
|
|
func ErrInvalidSender(msg string) sdk.Error {
|
|
|
|
return sdk.NewError(DefaultCodespace, CodeInvalidSender, msg)
|
|
|
|
}
|
|
|
|
|
|
|
|
// ErrVMExecution returns a standardized SDK error resulting from an error in EVM execution.
|
|
|
|
func ErrVMExecution(msg string) sdk.Error {
|
|
|
|
return sdk.NewError(DefaultCodespace, CodeVMExecution, msg)
|
|
|
|
}
|
|
|
|
|
|
|
|
// ErrVMExecution returns a standardized SDK error resulting from an error in EVM execution.
|
|
|
|
func ErrInvalidIntrinsicGas(msg string) sdk.Error {
|
|
|
|
return sdk.NewError(DefaultCodespace, CodeInvalidIntrinsicGas, msg)
|
|
|
|
}
|