Skip to content

Commit

Permalink
fix: add missing getters for data model structs (#4707)
Browse files Browse the repository at this point in the history
Signed-off-by: Shanin Roman <[email protected]>
  • Loading branch information
Erigara authored Jun 7, 2024
1 parent e9557e5 commit 4362c94
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 4 deletions.
Binary file modified configs/swarm/executor.wasm
Binary file not shown.
1 change: 1 addition & 0 deletions data_model/src/asset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ mod model {
#[getset(get_copy = "pub")]
pub value_type: AssetValueType,
/// Is the asset mintable
#[getset(get_copy = "pub")]
pub mintable: Mintable,
/// IPFS link to the [`AssetDefinition`] logo
#[getset(get = "pub")]
Expand Down
23 changes: 20 additions & 3 deletions data_model/src/events/data/events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use iroha_primitives::numeric::Numeric;

pub use self::model::*;
use super::*;
use crate::metadata::MetadataValueBox;

macro_rules! data_event {
($item:item) => {
Expand Down Expand Up @@ -38,7 +39,6 @@ macro_rules! data_event {
#[model]
mod model {
use super::*;
use crate::metadata::MetadataValueBox;

/// Generic [`MetadataChanged`] struct.
/// Contains the changed metadata (`(key, value)` pair), either inserted or removed, which is determined by the wrapping event.
Expand All @@ -58,8 +58,8 @@ mod model {
// TODO: Generics are not supported. Figure out what to do
//#[getset(get = "pub")]
#[ffi_type]
pub struct MetadataChanged<ID> {
pub target_id: ID,
pub struct MetadataChanged<Id> {
pub target_id: Id,
pub key: Name,
pub value: MetadataValueBox,
}
Expand Down Expand Up @@ -606,6 +606,23 @@ impl DataEvent {
}
}

impl<Id> MetadataChanged<Id> {
/// Getter for `target_id`
pub fn target_id(&self) -> &Id {
&self.target_id
}

/// Getter for `target_id`
pub fn key(&self) -> &Name {
&self.key
}

/// Getter for `value`
pub fn value(&self) -> &MetadataValueBox {
&self.value
}
}

pub mod prelude {
pub use super::{
account::{AccountEvent, AccountEventSet, AccountPermissionChanged, AccountRoleChanged},
Expand Down
12 changes: 12 additions & 0 deletions data_model/src/events/time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,18 @@ impl Schedule {
}
}

impl TimeInterval {
/// Getter for `since`
pub fn since(&self) -> &Duration {
&self.since
}

/// Getter for `length`
pub fn length(&self) -> &Duration {
&self.length
}
}

impl From<TimeInterval> for Range<Duration> {
#[inline]
fn from(interval: TimeInterval) -> Self {
Expand Down
1 change: 0 additions & 1 deletion data_model/src/peer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ mod model {
#[ffi_type]
pub struct PeerId {
/// Address of the [`Peer`]'s entrypoint.
// TODO: Derive with getset once FFI impl is fixed
pub address: SocketAddr,
/// Public Key of the [`Peer`].
pub public_key: PublicKey,
Expand Down

0 comments on commit 4362c94

Please sign in to comment.