-
Notifications
You must be signed in to change notification settings - Fork 305
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add skeleton for ActionDutchAuctionWithdraw
- Loading branch information
Showing
9 changed files
with
182 additions
and
0 deletions.
There are no files selected for viewing
Binary file not shown.
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
41 changes: 41 additions & 0 deletions
41
crates/core/component/auction/src/auction/dutch/actions/withdraw.rs
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,41 @@ | ||
use crate::auction::dutch::DutchAuctionauction_id; | ||
use anyhow::anyhow; | ||
use penumbra_proto::{core::component::auction::v1alpha1 as pb, DomainType}; | ||
use serde::{Deserialize, Serialize}; | ||
|
||
#[derive(Debug, Clone, Serialize, Deserialize)] | ||
#[serde( | ||
try_from = "pb::ActionDutchAuctionWithdraw", | ||
into = "pb::ActionDutchAuctionWithdraw" | ||
)] | ||
pub struct ActionDutchAuctionWithdraw { | ||
pub auction_id: AuctionId, | ||
} | ||
|
||
/* Protobuf impls */ | ||
impl DomainType for ActionDutchAuctionWithdraw { | ||
type Proto = pb::ActionDutchAuctionWithdraw; | ||
} | ||
|
||
impl From<ActionDutchAuctionWithdraw> for pb::ActionDutchAuctionWithdraw { | ||
fn from(domain: ActionDutchAuctionWithdraw) -> Self { | ||
pb::ActionDutchAuctionWithdraw { | ||
auction_id: Some(domain.auction_id.into()), | ||
} | ||
} | ||
} | ||
|
||
impl TryFrom<pb::ActionDutchAuctionWithdraw> for ActionDutchAuctionWithdraw { | ||
type Error = anyhow::Error; | ||
|
||
fn try_from(msg: pb::ActionDutchAuctionWithdraw) -> Result<Self, Self::Error> { | ||
Ok(ActionDutchAuctionWithdraw { | ||
auction_id: msg | ||
.auction_id | ||
.ok_or_else(|| { | ||
anyhow!("ActionDutchAuctionWithdraw message is missing an auction_id") | ||
})? | ||
.try_into()?, | ||
}) | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
crates/core/component/auction/src/component/action_handler/dutch/mod.rs
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 |
---|---|---|
@@ -1,2 +1,3 @@ | ||
mod end; | ||
mod schedule; | ||
mod withdraw; |
18 changes: 18 additions & 0 deletions
18
crates/core/component/auction/src/component/action_handler/dutch/withdraw.rs
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,18 @@ | ||
use anyhow::Result; | ||
use async_trait::async_trait; | ||
use cnidarium::StateWrite; | ||
use cnidarium_component::ActionHandler; | ||
|
||
use crate::auction::dutch::actions::ActionDutchAuctionWithdraw; | ||
|
||
#[async_trait] | ||
impl ActionHandler for ActionDutchAuctionWithdraw { | ||
type CheckStatelessContext = (); | ||
async fn check_stateless(&self, _context: ()) -> Result<()> { | ||
Ok(()) | ||
} | ||
|
||
async fn check_and_execute<S: StateWrite>(&self, mut _state: S) -> Result<()> { | ||
Ok(()) | ||
} | ||
} |
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
Binary file not shown.
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