Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixes a bug in get_all_by_seller
Browse files Browse the repository at this point in the history
gangov committed Aug 30, 2024
1 parent 796871c commit dfef066
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion contracts/auctions/src/storage.rs
Original file line number Diff line number Diff line change
@@ -117,7 +117,10 @@ pub fn save_auction_by_seller(
let mut seller_auctions_list: Vec<Auction> =
env.storage().instance().get(seller).unwrap_or(vec![&env]);

seller_auctions_list.push_back(auction.clone());
match seller_auctions_list.iter().position(|a| a.id == auction.id) {
Some(existing_idx) => seller_auctions_list.set(existing_idx as u32, auction.clone()),
None => seller_auctions_list.push_back(auction.clone()),
};

env.storage().instance().set(seller, &seller_auctions_list);

0 comments on commit dfef066

Please sign in to comment.