diff --git a/crates/core/component/auction/src/component/auction.rs b/crates/core/component/auction/src/component/auction.rs index e726bba09f..f14203768c 100644 --- a/crates/core/component/auction/src/component/auction.rs +++ b/crates/core/component/auction/src/component/auction.rs @@ -6,6 +6,8 @@ use std::sync::Arc; use tendermint::v0_37::abci; use tracing::instrument; +use crate::{auction::id::AuctionId, state_key}; + pub struct Auction {} impl Auction {} @@ -43,7 +45,15 @@ impl Component for Auction { /// Extension trait providing read access to auction data. #[async_trait] -pub trait StateReadExt: StateRead {} +pub trait StateReadExt: StateRead { + /// Returns `true` if the suppied `auction_id` is already used. + async fn auction_id_exists(&self, auction_id: AuctionId) -> bool { + self.get_raw(&state_key::auction_store::by_id(auction_id)) + .await + .expect("no storage errors") + .map_or(false, |_| true) + } +} impl StateReadExt for T {}