Skip to content

Commit

Permalink
Getting listed regions by account
Browse files Browse the repository at this point in the history
  • Loading branch information
Szegoo committed Feb 24, 2024
1 parent c21ac8c commit 581e47d
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions contracts/coretime_market/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,19 @@ pub mod coretime_market {
}

#[ink(message)]
pub fn listed_regions(&self) -> Vec<RawRegionId> {
self.listed_regions.clone()
pub fn listed_regions(&self, maybe_who: Option<AccountId>) -> Vec<RawRegionId> {
if let Some(who) = maybe_who {
self.listed_regions
.clone()
.into_iter()
.filter(|region_id| {
let Some(listing) = self.listings.get(region_id) else { return false };
listing.seller == who
})
.collect()
} else {
self.listed_regions.clone()
}
}

#[ink(message)]
Expand Down

0 comments on commit 581e47d

Please sign in to comment.