sui_bridge/
error.rs

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