1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
use crate::rules::validation::Validation;
use crate::utils::Error;
use macros::Rule;
use odra::types::Address;

/// Makes sure the bidder is the one who cancels the [`Bid`](crate::bid_escrow::bid::Bid).
/// May return [Error::CannotCancelNotOwnedBid].
#[derive(Rule)]
pub struct HasPermissionsToCancelBid {
    canceller: Address,
    bidder: Address,
}

impl Validation for HasPermissionsToCancelBid {
    fn validate(&self) -> Result<(), Error> {
        if self.canceller != self.bidder {
            return Err(Error::CannotCancelNotOwnedBid);
        }
        Ok(())
    }
}