-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Built-in Actor events for DDO (#1491)
* squashed commit to merge built-in Actor events to master
- Loading branch information
1 parent
859c731
commit 72e350a
Showing
49 changed files
with
1,966 additions
and
447 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
use fil_actors_runtime::runtime::Runtime; | ||
use fil_actors_runtime::{ActorError, EventBuilder}; | ||
use fvm_shared::deal::DealID; | ||
use fvm_shared::ActorID; | ||
|
||
/// Indicates a deal has been published. | ||
pub fn deal_published( | ||
rt: &impl Runtime, | ||
client: ActorID, | ||
provider: ActorID, | ||
deal_id: DealID, | ||
) -> Result<(), ActorError> { | ||
rt.emit_event( | ||
&EventBuilder::new() | ||
.typ("deal-published") | ||
.with_parties(deal_id, client, provider) | ||
.build()?, | ||
) | ||
} | ||
|
||
/// Indicates a deal has been activated. | ||
pub fn deal_activated( | ||
rt: &impl Runtime, | ||
deal_id: DealID, | ||
client: ActorID, | ||
provider: ActorID, | ||
) -> Result<(), ActorError> { | ||
rt.emit_event( | ||
&EventBuilder::new() | ||
.typ("deal-activated") | ||
.with_parties(deal_id, client, provider) | ||
.build()?, | ||
) | ||
} | ||
|
||
/// Indicates a deal has been terminated. | ||
pub fn deal_terminated( | ||
rt: &impl Runtime, | ||
deal_id: DealID, | ||
client: ActorID, | ||
provider: ActorID, | ||
) -> Result<(), ActorError> { | ||
rt.emit_event( | ||
&EventBuilder::new() | ||
.typ("deal-terminated") | ||
.with_parties(deal_id, client, provider) | ||
.build()?, | ||
) | ||
} | ||
|
||
/// Indicates a deal has been completed successfully. | ||
pub fn deal_completed( | ||
rt: &impl Runtime, | ||
deal_id: DealID, | ||
client: ActorID, | ||
provider: ActorID, | ||
) -> Result<(), ActorError> { | ||
rt.emit_event( | ||
&EventBuilder::new() | ||
.typ("deal-completed") | ||
.with_parties(deal_id, client, provider) | ||
.build()?, | ||
) | ||
} | ||
|
||
trait WithParties { | ||
fn with_parties(self, id: DealID, client: ActorID, provider: ActorID) -> EventBuilder; | ||
} | ||
|
||
impl WithParties for EventBuilder { | ||
fn with_parties(self, id: DealID, client: ActorID, provider: ActorID) -> EventBuilder { | ||
self.field_indexed("id", &id) | ||
.field_indexed("client", &client) | ||
.field_indexed("provider", &provider) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.