bee_block/output/unlock_condition/
state_controller_address.rs

1// Copyright 2021-2022 IOTA Stiftung
2// SPDX-License-Identifier: Apache-2.0
3
4use derive_more::From;
5
6use crate::address::Address;
7
8/// Defines the State Controller Address that owns this output, that is, it can unlock it with the proper Unlock in a
9/// transaction that state transitions the alias output.
10#[derive(Clone, Debug, Eq, PartialEq, Ord, PartialOrd, From, packable::Packable)]
11#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
12pub struct StateControllerAddressUnlockCondition(Address);
13
14impl StateControllerAddressUnlockCondition {
15    /// The [`UnlockCondition`](crate::output::UnlockCondition) kind of an [`StateControllerAddressUnlockCondition`].
16    pub const KIND: u8 = 4;
17
18    /// Creates a new [`StateControllerAddressUnlockCondition`].
19    #[inline(always)]
20    pub fn new(address: Address) -> Self {
21        Self(address)
22    }
23
24    /// Returns the address of a [`StateControllerAddressUnlockCondition`].
25    #[inline(always)]
26    pub fn address(&self) -> &Address {
27        &self.0
28    }
29}
30
31#[cfg(feature = "dto")]
32#[allow(missing_docs)]
33pub mod dto {
34    use serde::{Deserialize, Serialize};
35
36    use crate::address::dto::AddressDto;
37
38    #[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)]
39    pub struct StateControllerAddressUnlockConditionDto {
40        #[serde(rename = "type")]
41        pub kind: u8,
42        pub address: AddressDto,
43    }
44}