-
Notifications
You must be signed in to change notification settings - Fork 178
/
errors.go
92 lines (72 loc) · 2.74 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
package access
import (
"errors"
"fmt"
"github.com/onflow/flow-go/model/flow"
)
// ErrUnknownReferenceBlock indicates that a transaction references an unknown block.
var ErrUnknownReferenceBlock = errors.New("unknown reference block")
// IncompleteTransactionError indicates that a transaction is missing one or more required fields.
type IncompleteTransactionError struct {
MissingFields []string
}
func (e IncompleteTransactionError) Error() string {
return fmt.Sprintf("transaction is missing required fields: %s", e.MissingFields)
}
// ExpiredTransactionError indicates that a transaction has expired.
type ExpiredTransactionError struct {
RefHeight, FinalHeight uint64
}
func (e ExpiredTransactionError) Error() string {
return fmt.Sprintf("transaction is expired: ref_height=%d final_height=%d", e.RefHeight, e.FinalHeight)
}
// InvalidScriptError indicates that a transaction contains an invalid Cadence script.
type InvalidScriptError struct {
ParserErr error
}
func (e InvalidScriptError) Error() string {
return fmt.Sprintf("failed to parse transaction Cadence script: %s", e.ParserErr)
}
func (e InvalidScriptError) Unwrap() error {
return e.ParserErr
}
// InvalidGasLimitError indicates that a transaction specifies a gas limit that exceeds the maximum.
type InvalidGasLimitError struct {
Maximum uint64
Actual uint64
}
func (e InvalidGasLimitError) Error() string {
return fmt.Sprintf("transaction gas limit (%d) exceeds the maximum gas limit (%d)", e.Actual, e.Maximum)
}
// InvalidAddressError indicates that a transaction references an invalid flow Address
// in either the Authorizers or Payer field.
type InvalidAddressError struct {
Address flow.Address
}
func (e InvalidAddressError) Error() string {
return fmt.Sprintf("invalid address: %s", e.Address)
}
// DuplicatedSignatureError indicates that two signatures havs been provided for a key (combination of account and key index)
type DuplicatedSignatureError struct {
Address flow.Address
KeyIndex uint64
}
func (e DuplicatedSignatureError) Error() string {
return fmt.Sprintf("duplicated signature for key (address: %s, index: %d)", e.Address.String(), e.KeyIndex)
}
// InvalidSignatureError indicates that a transaction contains a signature
// with a wrong format.
type InvalidSignatureError struct {
Signature flow.TransactionSignature
}
func (e InvalidSignatureError) Error() string {
return fmt.Sprintf("invalid signature: %s", e.Signature)
}
// InvalidTxByteSizeError indicates that a transaction byte size exceeds the maximum.
type InvalidTxByteSizeError struct {
Maximum uint64
Actual uint64
}
func (e InvalidTxByteSizeError) Error() string {
return fmt.Sprintf("transaction byte size (%d) exceeds the maximum byte size allowed for a transaction (%d)", e.Actual, e.Maximum)
}