From de7d3a61c5c16b444f65667a81a9e5ef379f7844 Mon Sep 17 00:00:00 2001 From: Raman Shekhawat Date: Mon, 9 Sep 2024 14:52:56 +0530 Subject: [PATCH] update buyerPrice on Counter response --- src/mappings/marketplace/events/counter_offer_answered.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/mappings/marketplace/events/counter_offer_answered.ts b/src/mappings/marketplace/events/counter_offer_answered.ts index 2b18665b..0f6c7b7c 100644 --- a/src/mappings/marketplace/events/counter_offer_answered.ts +++ b/src/mappings/marketplace/events/counter_offer_answered.ts @@ -15,6 +15,7 @@ import { CounterOfferResponseCounter, CounterOfferResponseReject, ListingType, + CounterOffer, } from '../../../model' import { CommonContext, BlockHeader, EventItem } from '../../types/contexts' import { Sns } from '../../../common/sns' @@ -96,6 +97,13 @@ export async function counterOfferAnswered( assert(listing.state.listingType === ListingType.Offer, 'Listing is not an offer') listing.updatedAt = new Date(block.timestamp ?? 0) + if (data.response.__kind === 'Counter') { + const counterOffer = await ctx.store.findOneByOrFail(CounterOffer, { id: `${listing.id}-${account.id}` }) + counterOffer.buyerPrice = data.response.value + + await ctx.store.save(counterOffer) + } + if (item.extrinsic) { await Sns.getInstance().send({ id: item.id,