-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlib.rs
More file actions
57 lines (49 loc) · 2.11 KB
/
lib.rs
File metadata and controls
57 lines (49 loc) · 2.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
//! Inter-protocol message types for the bridge subprotocol.
//!
//! This crate exposes the incoming bridge messages and shared withdrawal output
//! payload so other subprotocols can dispatch withdrawals without pulling in the
//! bridge implementation crate.
use std::any::Any;
use ssz_derive::{Decode, Encode};
use strata_asm_common::{InterprotoMsg, SubprotocolId};
use strata_asm_txs_bridge_v1::BRIDGE_V1_SUBPROTOCOL_ID;
use strata_bridge_types::{OperatorIdx, OperatorSelection, WithdrawOutput};
use strata_crypto::EvenPublicKey;
/// Incoming message types received from other subprotocols.
///
/// This enum represents all possible message types that the bridge subprotocol can
/// receive from other subprotocols in the ASM.
#[derive(Clone, Debug, Eq, PartialEq, Encode, Decode)]
#[ssz(enum_behaviour = "union")]
pub enum BridgeIncomingMsg {
/// Emitted after a checkpoint proof has been validated. Contains the withdrawal command
/// specifying the destination descriptor and amount to be withdrawn.
DispatchWithdrawal(DispatchWithdrawalPayload),
/// Emitted by the admin subprotocol when the operator set is updated.
/// Adds new operators by public key and removes existing operators by index.
UpdateOperatorSet(UpdateOperatorSetPayload),
}
/// Payload for [`BridgeIncomingMsg::DispatchWithdrawal`].
#[derive(Clone, Debug, Eq, PartialEq, Encode, Decode)]
pub struct DispatchWithdrawalPayload {
/// The withdrawal output (destination + amount).
pub output: WithdrawOutput,
/// User's operator selection for withdrawal assignment.
pub selected_operator: OperatorSelection,
}
/// Payload for [`BridgeIncomingMsg::UpdateOperatorSet`].
#[derive(Clone, Debug, Eq, PartialEq, Encode, Decode)]
pub struct UpdateOperatorSetPayload {
/// Operator public keys to add to the bridge multisig.
pub add_members: Vec<EvenPublicKey>,
/// Operator indices to remove from the bridge multisig.
pub remove_members: Vec<OperatorIdx>,
}
impl InterprotoMsg for BridgeIncomingMsg {
fn id(&self) -> SubprotocolId {
BRIDGE_V1_SUBPROTOCOL_ID
}
fn as_dyn_any(&self) -> &dyn Any {
self
}
}