iota_bridge/
error.rs

1// Copyright (c) Mysten Labs, Inc.
2// Modifications Copyright (c) 2024 IOTA Stiftung
3// SPDX-License-Identifier: Apache-2.0
4
5use crate::{crypto::BridgeAuthorityPublicKeyBytes, types::BridgeAction};
6
7#[derive(Debug, Clone, PartialEq, Eq)]
8pub enum BridgeError {
9    // The input is not an invalid transaction digest/hash
10    InvalidTxHash,
11    // The referenced transaction failed
12    OriginTxFailed,
13    // The referenced transaction does not exist
14    TxNotFound,
15    // Tx is not yet finalized
16    TxNotFinalized,
17    // No recognized bridge event in specified transaction and event position
18    NoBridgeEventsInTxPosition,
19    // Found a bridge event but not in a recognized Eth bridge contract
20    BridgeEventInUnrecognizedEthContract,
21    // Found a bridge event but not in a recognized IOTA bridge package
22    BridgeEventInUnrecognizedIotaPackage,
23    // Found BridgeEvent but not BridgeAction
24    BridgeEventNotActionable,
25    // Failure to serialize
26    BridgeSerialization(String),
27    // Internal Bridge error
28    Internal(String),
29    // Authority signature duplication
30    AuthoritySignatureDuplication(String),
31    // Too many errors when aggregating authority signatures
32    AuthoritySignatureAggregationTooManyErrors(String),
33    // Transient Ethereum provider error
34    TransientProvider(String),
35    // Ethereum provider error
36    Provider(String),
37    // TokenId is unknown
38    UnknownTokenId(u8),
39    // Invalid BridgeCommittee
40    InvalidBridgeCommittee(String),
41    // Invalid Bridge authority signature
42    InvalidBridgeAuthoritySignature((BridgeAuthorityPublicKeyBytes, String)),
43    // Entity is not in the Bridge committee or is blocklisted
44    InvalidBridgeAuthority(BridgeAuthorityPublicKeyBytes),
45    // Authority's base_url is invalid
46    InvalidAuthorityUrl(BridgeAuthorityPublicKeyBytes),
47    // Invalid Bridge Client request
48    InvalidBridgeClientRequest(String),
49    // Invalid ChainId
50    InvalidChainId,
51    // Message is signed by mismatched authority
52    MismatchedAuthoritySigner,
53    // Signature is over a mismatched action
54    MismatchedAction,
55    // Action is not a governance action
56    ActionIsNotGovernanceAction(BridgeAction),
57    // Client requested an non-approved governance action
58    GovernanceActionIsNotApproved,
59    // Authority has invalid url
60    AuthorityUrlInvalid,
61    // Action is not token transfer
62    ActionIsNotTokenTransferAction,
63    // IOTA transaction failure due to generic error
64    IotaTxFailureGeneric(String),
65    // Zero value bridge transfer should not be allowed
66    ZeroValueBridgeTransfer(String),
67    // Storage Error
68    Storage(String),
69    // REST API Error
70    RestAPI(String),
71    // Uncategorized error
72    Generic(String),
73}
74
75pub type BridgeResult<T> = Result<T, BridgeError>;