/
errors.go
108 lines (87 loc) · 4.48 KB
/
errors.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
// nolint
package types
import (
"fmt"
"strings"
sdk "github.com/pokt-network/posmint/types"
)
type CodeType = sdk.CodeType
const (
DefaultCodespace sdk.CodespaceType = ModuleName
CodeUnauthorized CodeType = sdk.CodeUnauthorized
CodeInvalidValidator CodeType = 101
CodeInvalidDelegation CodeType = 102
CodeInvalidInput CodeType = 103
CodeValidatorJailed CodeType = 104
CodeValidatorNotJailed CodeType = 105
CodeMissingSelfDelegation CodeType = 106
CodeMissingSigningInfo CodeType = 108
CodeBadSend CodeType = 109
CodeInvalidStatus CodeType = 110
CodeMinimumStake CodeType = 111
CodeNotEnoughCoins CodeType = 112
CodeValidatorTombstoned CodeType = 113
CodeCantHandleEvidence CodeType = 114
CodeMinimumUnstake CodeType = 115
)
func ErrNilValidatorAddr(codespace sdk.CodespaceType) sdk.Error {
return sdk.NewError(codespace, CodeInvalidInput, "validator address is nil")
}
func ErrValidatorStatus(codespace sdk.CodespaceType) sdk.Error {
return sdk.NewError(codespace, CodeInvalidStatus, "validator status is not valid")
}
func ErrNoValidatorFound(codespace sdk.CodespaceType) sdk.Error {
return sdk.NewError(codespace, CodeInvalidValidator, "validator does not exist for that address")
}
func ErrNotEnoughCoins(codespace sdk.CodespaceType) sdk.Error {
return sdk.NewError(codespace, CodeNotEnoughCoins, "validator does not have enough coins in their account")
}
func ErrValidatorTombstoned(codespace sdk.CodespaceType) sdk.Error {
return sdk.NewError(codespace, CodeValidatorTombstoned, "Warning: validator is already tombstoned")
}
func ErrCantHandleEvidence(codespace sdk.CodespaceType) sdk.Error {
return sdk.NewError(codespace, CodeCantHandleEvidence, "Warning: the DS evidence is unable to be handled")
}
func ErrMinimumStake(codespace sdk.CodespaceType) sdk.Error {
return sdk.NewError(codespace, CodeMinimumStake, "validator isn't staking above the minimum")
}
func ErrMinimumUnstake(codespace sdk.CodespaceType) sdk.Error {
return sdk.NewError(codespace, CodeMinimumUnstake, "validator trying to begin unstaking has less than the minimum stake")
}
func ErrValidatorPubKeyExists(codespace sdk.CodespaceType) sdk.Error {
return sdk.NewError(codespace, CodeInvalidValidator, "validator already exist for this pubkey, must use new validator pubkey")
}
func ErrValidatorPubKeyTypeNotSupported(codespace sdk.CodespaceType, keyType string, supportedTypes []string) sdk.Error {
msg := fmt.Sprintf("validator pubkey type %s is not supported, must use %s", keyType, strings.Join(supportedTypes, ","))
return sdk.NewError(codespace, CodeInvalidValidator, msg)
}
func ErrBadSendAmount(codespace sdk.CodespaceType) sdk.Error {
return sdk.NewError(codespace, CodeBadSend, "the amount to send must be positive")
}
func ErrBadDenom(codespace sdk.CodespaceType) sdk.Error {
return sdk.NewError(codespace, CodeInvalidDelegation, "invalid coin denomination")
}
func ErrBadDelegationAmount(codespace sdk.CodespaceType) sdk.Error {
return sdk.NewError(codespace, CodeInvalidDelegation, "amount must be > 0")
}
func ErrNoValidatorForAddress(codespace sdk.CodespaceType) sdk.Error {
return sdk.NewError(codespace, CodeInvalidValidator, "that address is not associated with any known validator")
}
func ErrBadValidatorAddr(codespace sdk.CodespaceType) sdk.Error {
return sdk.NewError(codespace, CodeInvalidValidator, "validator does not exist for that address")
}
func ErrValidatorJailed(codespace sdk.CodespaceType) sdk.Error {
return sdk.NewError(codespace, CodeValidatorJailed, "validator still jailed, cannot yet be unjailed")
}
func ErrValidatorNotJailed(codespace sdk.CodespaceType) sdk.Error {
return sdk.NewError(codespace, CodeValidatorNotJailed, "validator not jailed, cannot be unjailed")
}
func ErrMissingSelfDelegation(codespace sdk.CodespaceType) sdk.Error {
return sdk.NewError(codespace, CodeMissingSelfDelegation, "validator has no self-delegation; cannot be unjailed")
}
func ErrSelfDelegationTooLowToUnjail(codespace sdk.CodespaceType) sdk.Error {
return sdk.NewError(codespace, CodeValidatorNotJailed, "validator's self delegation less than MinSelfDelegation, cannot be unjailed")
}
func ErrNoSigningInfoFound(codespace sdk.CodespaceType, address sdk.Address) sdk.Error {
return sdk.NewError(codespace, CodeMissingSigningInfo, fmt.Sprintf("no signing info found for address: %s", address))
}