Skip to content

Commit

Permalink
fix: init issue
Browse files Browse the repository at this point in the history
  • Loading branch information
orionstardust committed Mar 21, 2024
1 parent ec12631 commit c1df4eb
Showing 1 changed file with 72 additions and 72 deletions.
144 changes: 72 additions & 72 deletions src/mapping.ts
Original file line number Diff line number Diff line change
Expand Up @@ -541,30 +541,30 @@ 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(
Expand Down Expand Up @@ -599,52 +599,52 @@ export function handleAuction_StartingPriceUpdated(
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();
}

0 comments on commit c1df4eb

Please sign in to comment.