Skip to main content

snowbridge_outbound_queue_primitives/
lib.rs

1// SPDX-License-Identifier: Apache-2.0
2// SPDX-FileCopyrightText: 2023 Snowfork <hello@snowfork.com>
3#![cfg_attr(not(feature = "std"), no_std)]
4//! # Outbound
5//!
6//! Common traits and types
7pub mod v1;
8pub mod v2;
9
10use codec::{Decode, DecodeWithMemTracking, Encode};
11use frame_support::PalletError;
12use scale_info::TypeInfo;
13use sp_arithmetic::traits::{BaseArithmetic, Unsigned};
14use Debug;
15
16pub use snowbridge_verification_primitives::*;
17
18/// The operating mode of Channels and Gateway contract on Ethereum.
19#[derive(Copy, Clone, Encode, Decode, DecodeWithMemTracking, PartialEq, Eq, Debug, TypeInfo)]
20pub enum OperatingMode {
21	/// Normal operations. Allow sending and receiving messages.
22	Normal,
23	/// Reject outbound messages. This allows receiving governance messages but does now allow
24	/// enqueuing of new messages from the Ethereum side. This can be used to close off a
25	/// deprecated channel or pause the bridge for upgrade operations.
26	RejectingOutboundMessages,
27}
28
29/// A trait for getting the local costs associated with sending a message.
30pub trait SendMessageFeeProvider {
31	type Balance: BaseArithmetic + Unsigned + Copy;
32
33	/// The local component of the message processing fees in native currency
34	fn local_fee() -> Self::Balance;
35}
36
37/// Reasons why sending to Ethereum could not be initiated
38#[derive(
39	Copy, Clone, Encode, Decode, DecodeWithMemTracking, PartialEq, Eq, Debug, PalletError, TypeInfo,
40)]
41pub enum SendError {
42	/// Message is too large to be safely executed on Ethereum
43	MessageTooLarge,
44	/// The bridge has been halted for maintenance
45	Halted,
46	/// Invalid Channel
47	InvalidChannel,
48	/// Invalid Origin
49	InvalidOrigin,
50}