From 69a8cdbcb6557eb77ec3dd5c1ba819b5e6edc697 Mon Sep 17 00:00:00 2001 From: roiLeo Date: Mon, 23 Jun 2025 17:30:52 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A7=20claim=20swap=20calculate=20colle?= =?UTF-8?q?ction=20data?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/mappings/nfts/claimSwap.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/mappings/nfts/claimSwap.ts b/src/mappings/nfts/claimSwap.ts index d5fbce6..5da709a 100644 --- a/src/mappings/nfts/claimSwap.ts +++ b/src/mappings/nfts/claimSwap.ts @@ -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 @@ -35,6 +36,18 @@ export async function handleClaimSwap(context: Context): Promise { } } + 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)