errors.sol

Overview

This Solidity source file defines an abstract contract named Errors which centralizes the definition of error codes used throughout the system. These error codes are represented as constant unsigned 16-bit integers (uint16) and cover a broad range of failure scenarios such as public key validation errors, transaction list issues, replay protection failures, signature verification problems, wallet recovery errors, and security card-related faults.

By using a centralized error contract, the system ensures consistent error handling and reporting across multiple contracts or modules, facilitating maintainability, debugging, and integration. The contract also includes a version identifier string (versionErrors) that can be used to track or enforce compatibility of error definitions.

Contract: Errors

Description

The Errors contract is declared as abstract, meaning it is not meant to be instantiated directly but rather to be inherited by other contracts that require access to standardized error codes.

Properties

Name

Type

Description

versionErrors

string

Version identifier of the error codes, currently "1.0.0".

ERR_ZERO_PUBKEY

uint16

Error code for a zero (empty) public key.

ERR_REPEATING_KEY

uint16

Error code for detecting duplicate public keys.

ERR_BAD_LEN

uint16

Error code for invalid length of data or input.

ERR_TOO_SMALL_VALUE

uint16

Error code indicating a value that is too small.

ERR_LOW_BALANCE

uint16

Error code for insufficient balance in an account.

ERR_TRX_NOT_FOUND

uint16

Error code when a transaction is missing or not found.

ERR_TRX_WAITLIST_OVERFLOWED

uint16

Error code indicating the transaction waitlist is full.

ERR_MAX_CLEANUP_TXNS_INVALID

uint16

Error code for invalid maximum cleanup transactions count.

ERR_MESSAGE_IS_EXIST

uint16

Error code indicating a replayed or duplicate message.

ERR_MESSAGE_WITH_HUGE_EXPIREAT

uint16

Error code for messages with an excessively large expiration timestamp.

ERR_MESSAGE_EXPIRED

uint16

Error code for expired messages.

ERR_NOT_OWNER

uint16

Error code indicating the caller is not the owner.

ERR_INVALID_SIGNATURE

uint16

Error code for an invalid cryptographic signature.

ERR_FACTOR_EXPIRED

uint16

Error code indicating an expired factor (possibly for two-factor authentication).

ERR_INVALID_SENDER_ADDR

uint16

Error code for invalid sender address detected.

ERR_INVALID_PROOF

uint16

Error code for an invalid Groth16 zero-knowledge proof.

ERR_FACTOR_NOT_FOUND

uint16

Error code when a required factor is not found.

ERR_JWK_EXPIRED

uint16

Error code indicating that a JSON Web Key (JWK) has expired.

ERR_JWK_NOT_FOUND

uint16

Error code when a JWK is not found.

ERR_INVALID_JWK

uint16

Error code indicating the JWK is invalid.

ERR_TLS_DATA

uint16

Error code related to TLS (Transport Layer Security) data issues.

ERR_FACTOR_TIMESTAMP_TOO_BIG

uint16

Error code for a factor timestamp exceeding acceptable range.

ERR_REPEATING_CERT

uint16

Error code for duplicate certificate entries.

ERR_CERT_NOT_FOUND

uint16

Error code when a certificate is not found.

ERR_JWK_TIMESTAMP_TOO_BIG

uint16

Error code for JWK with a timestamp too large.

ERR_SEED_PHRASE_NEW_CANDIDATE_EXISTS

uint16

Error code indicating a new seed phrase candidate already exists during wallet recovery.

ERR_SEED_PHRASE_NEW_CANDIDATE_NOT_FOUND

uint16

Error code when the new seed phrase candidate is not found.

ERR_CARD_IS_TURNED_ON

uint16

Error code signaling a security card that is already activated.

ERR_NO_CARDS

uint16

Error code when there are no security cards available.

ERR_TOO_MUCH_CARDS_ADDED

uint16

Error code for exceeding the allowable number of security cards.

ERR_CARD_EXISTS

uint16

Error code indicating the security card already exists.

ERR_CARD_IS_TURNED_OFF

uint16

Error code for a security card that is deactivated.

ERR_CARD_NOT_FOUND

uint16

Error code when a security card is not found.

Usage

Contracts inheriting from Errors can refer to these constants to revert transactions or emit error events with standardized error codes. This approach reduces the risk of mismatched or ambiguous error reporting.

Example usage snippet:

if (publicKey == address(0)) {
    revert(uint16(Errors.ERR_ZERO_PUBKEY));
}

Implementation Details

Interaction with Other System Components

Diagram: Errors Contract Structure

classDiagram
class Errors {
<<abstract>>
+string versionErrors
+uint16 ERR_ZERO_PUBKEY
+uint16 ERR_REPEATING_KEY
+uint16 ERR_BAD_LEN
+uint16 ERR_TOO_SMALL_VALUE
+uint16 ERR_LOW_BALANCE
+uint16 ERR_TRX_NOT_FOUND
+uint16 ERR_TRX_WAITLIST_OVERFLOWED
+uint16 ERR_MAX_CLEANUP_TXNS_INVALID
+uint16 ERR_MESSAGE_IS_EXIST
+uint16 ERR_MESSAGE_WITH_HUGE_EXPIREAT
+uint16 ERR_MESSAGE_EXPIRED
+uint16 ERR_NOT_OWNER
+uint16 ERR_INVALID_SIGNATURE
+uint16 ERR_FACTOR_EXPIRED
+uint16 ERR_INVALID_SENDER_ADDR
+uint16 ERR_INVALID_PROOF
+uint16 ERR_FACTOR_NOT_FOUND
+uint16 ERR_JWK_EXPIRED
+uint16 ERR_JWK_NOT_FOUND
+uint16 ERR_INVALID_JWK
+uint16 ERR_TLS_DATA
+uint16 ERR_FACTOR_TIMESTAMP_TOO_BIG
+uint16 ERR_REPEATING_CERT
+uint16 ERR_CERT_NOT_FOUND
+uint16 ERR_JWK_TIMESTAMP_TOO_BIG
+uint16 ERR_SEED_PHRASE_NEW_CANDIDATE_EXISTS
+uint16 ERR_SEED_PHRASE_NEW_CANDIDATE_NOT_FOUND
+uint16 ERR_CARD_IS_TURNED_ON
+uint16 ERR_NO_CARDS
+uint16 ERR_TOO_MUCH_CARDS_ADDED
+uint16 ERR_CARD_EXISTS
+uint16 ERR_CARD_IS_TURNED_OFF
+uint16 ERR_CARD_NOT_FOUND
}