Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add missing getters for data model structs #4707

Merged
merged 1 commit into from
Jun 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading