#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub struct Intent {
pub scope: IntentScope,
pub version: IntentVersion,
pub app_id: IntentAppId,
}
impl Intent {
pub fn new(scope: IntentScope, version: IntentVersion, app_id: IntentAppId) -> Self {
Self {
scope,
version,
app_id,
}
}
pub fn to_bytes(self) -> [u8; 3] {
[self.scope as u8, self.version as u8, self.app_id as u8]
}
pub fn scope(self) -> IntentScope {
self.scope
}
pub fn version(self) -> IntentVersion {
self.version
}
pub fn app_id(self) -> IntentAppId {
self.app_id
}
}
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
#[repr(u8)]
#[non_exhaustive]
pub enum IntentScope {
TransactionData = 0, TransactionEffects = 1, CheckpointSummary = 2, PersonalMessage = 3, SenderSignedTransaction = 4, ProofOfPossession = 5, HeaderDigest = 6, BridgeEventUnused = 7, ConsensusBlock = 8, }
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
#[repr(u8)]
#[non_exhaustive]
pub enum IntentVersion {
V0 = 0,
}
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
#[repr(u8)]
#[non_exhaustive]
pub enum IntentAppId {
Sui = 0,
Narwhal = 1,
Consensus = 2,
}