From cffe589a49148faf2a461fc3546d4f5df2fde1f9 Mon Sep 17 00:00:00 2001 From: orionstardust <justinono1990@outlook.com> Date: Thu, 21 Mar 2024 13:37:40 -0400 Subject: [PATCH] fix: init issue --- src/mapping.ts | 190 ++++++++++++++++++++++++------------------------- 1 file changed, 95 insertions(+), 95 deletions(-) diff --git a/src/mapping.ts b/src/mapping.ts index 34a3145..4610139 100644 --- a/src/mapping.ts +++ b/src/mapping.ts @@ -541,110 +541,110 @@ export function handleContract_RoyaltyPaid(event: RoyaltyPaidEvent): void { export function handleAuction_BuyItNowUpdated( event: Auction_BuyItNowUpdatedEvent ): void { - // emitter - let emitter = getOrCreateUser(event.transaction.from); - emitter.save(); - - // event - let ev = new Auction_BuyItNowUpdated(events.id(event)); - ev.emitter = emitter.id; - ev.transaction = transactions.log(event).id; - ev.timestamp = event.block.timestamp; - - ev.auctionId = event.params._auctionId; - ev.buyNowPrice = event.params._buyItNowPrice; - ev.save(); - - // update entity - let entity = getOrCreateAuction(event.params._auctionId, event); - if (!entity) { - log.warning("auction with id {} not found", [ - event.params._auctionId.toString(), - ]); - return; - } - entity.buyNowPrice = event.params._buyItNowPrice; - entity.save(); + // // emitter + // let emitter = getOrCreateUser(event.transaction.from); + // emitter.save(); + // + // // event + // let ev = new Auction_BuyItNowUpdated(events.id(event)); + // ev.emitter = emitter.id; + // ev.transaction = transactions.log(event).id; + // ev.timestamp = event.block.timestamp; + // + // ev.auctionId = event.params._auctionId; + // ev.buyNowPrice = event.params._buyItNowPrice; + // ev.save(); + // + // // update entity + // let entity = getOrCreateAuction(event.params._auctionId, event); + // if (!entity) { + // log.warning("auction with id {} not found", [ + // event.params._auctionId.toString(), + // ]); + // return; + // } + // entity.buyNowPrice = event.params._buyItNowPrice; + // entity.save(); } export function handleAuction_StartingPriceUpdated( event: Auction_StartingPriceUpdatedEvent ): void { // emitter - let emitter = getOrCreateUser(event.transaction.from); - emitter.save(); - - // event - let ev = new Auction_StartingPriceUpdated(events.id(event)); - ev.emitter = emitter.id; - ev.transaction = transactions.log(event).id; - ev.timestamp = event.block.timestamp; - - ev.auctionId = event.params._auctionId; - ev.startBidPrice = event.params._startPrice; - ev.save(); - - // update entity - let entity = getOrCreateAuction(event.params._auctionId, event); - if (!entity) { - log.warning("auction with id {} not found", [ - event.params._auctionId.toString(), - ]); - return; - } - entity.startBidPrice = event.params._startPrice; - entity.save(); + // let emitter = getOrCreateUser(event.transaction.from); + // emitter.save(); + // + // // event + // let ev = new Auction_StartingPriceUpdated(events.id(event)); + // ev.emitter = emitter.id; + // ev.transaction = transactions.log(event).id; + // ev.timestamp = event.block.timestamp; + // + // ev.auctionId = event.params._auctionId; + // ev.startBidPrice = event.params._startPrice; + // ev.save(); + // + // // update entity + // let entity = getOrCreateAuction(event.params._auctionId, event); + // if (!entity) { + // log.warning("auction with id {} not found", [ + // event.params._auctionId.toString(), + // ]); + // return; + // } + // entity.startBidPrice = event.params._startPrice; + // entity.save(); } export function handleAuction_BoughtNow( event: Auction_BoughtNowEvent ): void { - // emitter - let emitter = getOrCreateUser(event.transaction.from); - emitter.save(); - - // event - let ev = new Auction_BoughtNow(events.id(event)); - ev.emitter = emitter.id; - ev.transaction = transactions.log(event).id; - ev.timestamp = event.block.timestamp; - - ev.auctionId = event.params._auctionId; - ev.save(); - - // update entity - let auction = getOrCreateAuction(event.params._auctionId, event); - if (!auction) { - log.warning("auction with id {} not found", [ - event.params._auctionId.toString(), - ]); - return; - } - auction.claimed = true; - auction.claimAt = event.block.timestamp; - - let bid = getOrCreateBid( - auction.highestBidder, - auction.highestBid, - auction as Auction, - event - ); - bid.outbid = true; - - let user = getOrCreateUser(auction.highestBidder); - user.outbids = user.outbids.plus(BigInt.fromI32(1)); - user.save(); - - // Update Stats - let stats = Statistic.load("0")!; - stats.totalSalesVolume = stats.totalSalesVolume.plus(auction.buyNowPrice); - stats.save(); - - // update contract stats - let cStats = getOrCreateStatistics(auction.contractAddress); - cStats.totalSalesVolume = cStats.totalSalesVolume.plus(auction.buyNowPrice); - cStats.save(); - - bid.save(); - auction.save(); + // // emitter + // let emitter = getOrCreateUser(event.transaction.from); + // emitter.save(); + // + // // event + // let ev = new Auction_BoughtNow(events.id(event)); + // ev.emitter = emitter.id; + // ev.transaction = transactions.log(event).id; + // ev.timestamp = event.block.timestamp; + // + // ev.auctionId = event.params._auctionId; + // ev.save(); + // + // // update entity + // let auction = getOrCreateAuction(event.params._auctionId, event); + // if (!auction) { + // log.warning("auction with id {} not found", [ + // event.params._auctionId.toString(), + // ]); + // return; + // } + // auction.claimed = true; + // auction.claimAt = event.block.timestamp; + // + // let bid = getOrCreateBid( + // auction.highestBidder, + // auction.highestBid, + // auction as Auction, + // event + // ); + // bid.outbid = true; + // + // let user = getOrCreateUser(auction.highestBidder); + // user.outbids = user.outbids.plus(BigInt.fromI32(1)); + // user.save(); + // + // // Update Stats + // let stats = Statistic.load("0")!; + // stats.totalSalesVolume = stats.totalSalesVolume.plus(auction.buyNowPrice); + // stats.save(); + // + // // update contract stats + // let cStats = getOrCreateStatistics(auction.contractAddress); + // cStats.totalSalesVolume = cStats.totalSalesVolume.plus(auction.buyNowPrice); + // cStats.save(); + // + // bid.save(); + // auction.save(); }