Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions src/mappings/nfts/claimSwap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { CollectionEntity as CE, Offer, Swap, TradeStatus } from '../../model'
import { unwrap } from '../utils/extract'
import { debug, pending, success } from '../utils/logger'
import { Context, createTokenId, isOffer } from '../utils/types'
import { calculateCollectionFloor, calculateCollectionOwnerCountAndDistribution } from '../utils/helper'
import { getSwapClaimedEvent } from './getters'

const OPERATION = TradeStatus.ACCEPTED
Expand Down Expand Up @@ -35,6 +36,18 @@ export async function handleClaimSwap(context: Context): Promise<void> {
}
}

const { floor } = await calculateCollectionFloor(context.store, collection.id, id)
const { ownerCount, distribution } = await calculateCollectionOwnerCountAndDistribution(
context.store,
collection.id,
event.currentOwner,
event.sent.owner
)
collection.floor = floor
collection.ownerCount = ownerCount
collection.distribution = distribution
collection.updatedAt = event.timestamp

success(OPERATION, `${id} by ${event.caller}`)

await context.store.save(entity)
Expand Down