Skip to content

Commit

Permalink
feat: update buyerPrice on counter response (#1268)
Browse files Browse the repository at this point in the history
update buyerPrice on Counter response
  • Loading branch information
justraman authored Sep 11, 2024
1 parent 23fbb6e commit f1bf3e3
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/mappings/marketplace/events/counter_offer_answered.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
CounterOfferResponseCounter,
CounterOfferResponseReject,
ListingType,
CounterOffer,
} from '../../../model'
import { CommonContext, BlockHeader, EventItem } from '../../types/contexts'
import { Sns } from '../../../common/sns'
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit f1bf3e3

Please sign in to comment.