github.com/onflow/flow-go@v0.35.7-crescendo-preview.23-atree-inlining/access/errors.go (about)

     1  package access
     2  
     3  import (
     4  	"errors"
     5  	"fmt"
     6  
     7  	"github.com/onflow/flow-go/model/flow"
     8  )
     9  
    10  // ErrUnknownReferenceBlock indicates that a transaction references an unknown block.
    11  var ErrUnknownReferenceBlock = errors.New("unknown reference block")
    12  
    13  // IncompleteTransactionError indicates that a transaction is missing one or more required fields.
    14  type IncompleteTransactionError struct {
    15  	MissingFields []string
    16  }
    17  
    18  func (e IncompleteTransactionError) Error() string {
    19  	return fmt.Sprintf("transaction is missing required fields: %s", e.MissingFields)
    20  }
    21  
    22  // ExpiredTransactionError indicates that a transaction has expired.
    23  type ExpiredTransactionError struct {
    24  	RefHeight, FinalHeight uint64
    25  }
    26  
    27  func (e ExpiredTransactionError) Error() string {
    28  	return fmt.Sprintf("transaction is expired: ref_height=%d final_height=%d", e.RefHeight, e.FinalHeight)
    29  }
    30  
    31  // InvalidScriptError indicates that a transaction contains an invalid Cadence script.
    32  type InvalidScriptError struct {
    33  	ParserErr error
    34  }
    35  
    36  func (e InvalidScriptError) Error() string {
    37  	return fmt.Sprintf("failed to parse transaction Cadence script: %s", e.ParserErr)
    38  }
    39  
    40  func (e InvalidScriptError) Unwrap() error {
    41  	return e.ParserErr
    42  }
    43  
    44  // InvalidGasLimitError indicates that a transaction specifies a gas limit that exceeds the maximum.
    45  type InvalidGasLimitError struct {
    46  	Maximum uint64
    47  	Actual  uint64
    48  }
    49  
    50  func (e InvalidGasLimitError) Error() string {
    51  	return fmt.Sprintf("transaction gas limit (%d) is not in the acceptable range (min: 1, max: %d)", e.Actual, e.Maximum)
    52  }
    53  
    54  // InvalidAddressError indicates that a transaction references an invalid flow Address
    55  // in either the Authorizers or Payer field.
    56  type InvalidAddressError struct {
    57  	Address flow.Address
    58  }
    59  
    60  func (e InvalidAddressError) Error() string {
    61  	return fmt.Sprintf("invalid address: %s", e.Address)
    62  }
    63  
    64  // DuplicatedSignatureError indicates that two signatures havs been provided for a key (combination of account and key index)
    65  type DuplicatedSignatureError struct {
    66  	Address  flow.Address
    67  	KeyIndex uint64
    68  }
    69  
    70  func (e DuplicatedSignatureError) Error() string {
    71  	return fmt.Sprintf("duplicated signature for key (address: %s, index: %d)", e.Address.String(), e.KeyIndex)
    72  }
    73  
    74  // InvalidSignatureError indicates that a transaction contains a signature
    75  // with a wrong format.
    76  type InvalidSignatureError struct {
    77  	Signature flow.TransactionSignature
    78  }
    79  
    80  func (e InvalidSignatureError) Error() string {
    81  	return fmt.Sprintf("invalid signature: %s", e.Signature)
    82  }
    83  
    84  // InvalidTxByteSizeError indicates that a transaction byte size exceeds the maximum.
    85  type InvalidTxByteSizeError struct {
    86  	Maximum uint64
    87  	Actual  uint64
    88  }
    89  
    90  func (e InvalidTxByteSizeError) Error() string {
    91  	return fmt.Sprintf("transaction byte size (%d) exceeds the maximum byte size allowed for a transaction (%d)", e.Actual, e.Maximum)
    92  }
    93  
    94  type InvalidTxRateLimitedError struct {
    95  	Payer flow.Address
    96  }
    97  
    98  func (e InvalidTxRateLimitedError) Error() string {
    99  	return fmt.Sprintf("transaction rate limited for payer (%s)", e.Payer)
   100  }