Skip to content

Commit

Permalink
Fix after rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
Arjentix committed Feb 23, 2022
1 parent 8309021 commit 80ffebe
Show file tree
Hide file tree
Showing 7 changed files with 361 additions and 715 deletions.
2 changes: 1 addition & 1 deletion core/src/smartcontracts/isi/asset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ pub mod isi {

Ok(AssetEvent::new(
asset_id.clone(),
DataStatus::Updated(Updated::Asset(AssetUpdated::Burned)),
DataStatus::Updated(Updated::Asset(AssetUpdated::Sent)),
))
})
}
Expand Down
46 changes: 24 additions & 22 deletions core/src/smartcontracts/isi/triggers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,12 @@ pub mod isi {
self,
_authority: <Account as Identifiable>::Id,
wsv: &WorldStateView<W>,
) -> Result<Vec<DataEvent>, Self::Error> {
) -> Result<(), Self::Error> {
let new_trigger = self.object.clone();
wsv.triggers.add(new_trigger)?;
Ok(vec![DataEvent::new(self.object.id, DataStatus::Created)])
wsv.modify_triggers(|triggers| {
triggers.add(new_trigger)?;
Ok(TriggerEvent::Created(self.object.id))
})
}
}

Expand All @@ -39,10 +41,12 @@ pub mod isi {
self,
_authority: <Account as Identifiable>::Id,
wsv: &WorldStateView<W>,
) -> Result<Vec<DataEvent>, Self::Error> {
) -> Result<(), Self::Error> {
let trigger = self.object_id.clone();
wsv.triggers.remove(trigger)?;
Ok(vec![DataEvent::new(self.object_id, DataStatus::Deleted)])
wsv.modify_triggers(|triggers| {
triggers.remove(trigger)?;
Ok(TriggerEvent::Deleted(self.object_id))
})
}
}

Expand All @@ -54,15 +58,14 @@ pub mod isi {
self,
_authority: <Account as Identifiable>::Id,
wsv: &WorldStateView<W>,
) -> Result<Vec<DataEvent>, Self::Error> {
) -> Result<(), Self::Error> {
let trigger = self.destination_id.clone();
wsv.triggers.mod_repeats(trigger, |n| {
n.checked_add(self.object).ok_or(MathError::Overflow)
})?;
Ok(vec![DataEvent::new(
self.destination_id,
Updated::Trigger(TriggerUpdated::Extended),
)])
wsv.modify_triggers(|triggers| {
triggers.mod_repeats(trigger, |n| {
n.checked_add(self.object).ok_or(MathError::Overflow)
})?;
Ok(TriggerEvent::Extended(self.destination_id))
})
}
}

Expand All @@ -74,15 +77,14 @@ pub mod isi {
self,
_authority: <Account as Identifiable>::Id,
wsv: &WorldStateView<W>,
) -> Result<Vec<DataEvent>, Self::Error> {
) -> Result<(), Self::Error> {
let trigger = self.destination_id.clone();
wsv.triggers.mod_repeats(trigger, |n| {
n.checked_sub(self.object).ok_or(MathError::Overflow)
})?;
Ok(vec![DataEvent::new(
self.destination_id,
Updated::Trigger(TriggerUpdated::Shortened),
)])
wsv.modify_triggers(|triggers| {
triggers.mod_repeats(trigger, |n| {
n.checked_sub(self.object).ok_or(MathError::Overflow)
})?;
Ok(TriggerEvent::Shortened(self.destination_id))
})
}
}
}
Loading

0 comments on commit 80ffebe

Please sign in to comment.