From aabc475677246c3549253d7f045b63b45efb1b64 Mon Sep 17 00:00:00 2001 From: Frank Date: Tue, 24 Oct 2023 12:58:58 +0200 Subject: [PATCH] fix: with sets rarity score try#2 --- src/mappings/diamond.ts | 16 +++++++++++----- src/utils/helpers/diamond.ts | 13 +++++++++---- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/src/mappings/diamond.ts b/src/mappings/diamond.ts index 48140af..48031b3 100644 --- a/src/mappings/diamond.ts +++ b/src/mappings/diamond.ts @@ -98,6 +98,7 @@ import { BIGINT_ZERO, ZERO_ADDRESS, BLOCK_DISABLE_OLD_LENDING_EVENTS, + STATUS_AAVEGOTCHI, } from "../utils/constants"; import { Address, BigInt, log, Bytes } from "@graphprotocol/graph-ts"; @@ -286,7 +287,11 @@ export function handleSpendSkillpoints(event: SpendSkillpoints): void { event )!; gotchi = updateAavegotchiInfo(gotchi, event.params._tokenId, event); - updateAavegotchiWearables(gotchi, event); + gotchi = updateAavegotchiWearables(gotchi, event); + + if (gotchi.status.equals(STATUS_AAVEGOTCHI)) { + gotchi.save(); + } } // - event: EquipWearables(indexed uint256,uint256,uint256) @@ -300,7 +305,11 @@ export function handleEquipWearables(event: EquipWearables): void { gotchi = updateAavegotchiInfo(gotchi, event.params._tokenId, event); - updateAavegotchiWearables(gotchi, event); + gotchi = updateAavegotchiWearables(gotchi, event); + + if (gotchi.status.equals(STATUS_AAVEGOTCHI)) { + gotchi.save(); + } } // - event: SetAavegotchiName(indexed uint256,string,string) @@ -1126,9 +1135,6 @@ export function handleGotchiLendingAdded(event: GotchiLendingAdded): void { } } let gotchi = getOrCreateAavegotchi(event.params.tokenId.toString(), event)!; - if (!gotchi.modifiedRarityScore) { - gotchi = updateAavegotchiInfo(gotchi, event.params.tokenId, event); - } gotchi.lending = BigInt.fromString(lending.id); gotchi.save(); diff --git a/src/utils/helpers/diamond.ts b/src/utils/helpers/diamond.ts index b6bb5d1..0928531 100644 --- a/src/utils/helpers/diamond.ts +++ b/src/utils/helpers/diamond.ts @@ -1,6 +1,7 @@ import { AavegotchiDiamond, ERC1155ExecutedListing, + UpdateWearableSet, } from "../../../generated/AavegotchiDiamond/AavegotchiDiamond"; import { RealmDiamond } from "../../../generated/RealmDiamond/RealmDiamond"; @@ -79,6 +80,12 @@ export function getOrCreateAavegotchi( gotchi.historicalPrices = []; gotchi.kinship = BigInt.fromI32(50); gotchi.withSetsRarityScore = BIGINT_ZERO; + gotchi = updateAavegotchiInfo( + gotchi, + BigInt.fromString(gotchi.id), + event + ); + gotchi = updateAavegotchiWearables(gotchi, event); } else if (gotchi == null && !createIfNotFound) { return null; } @@ -609,7 +616,7 @@ export function getOrCreateParcel( export function updateAavegotchiWearables( gotchi: Aavegotchi, event: ethereum.Event -): void { +): Aavegotchi { let contract = AavegotchiDiamond.bind(event.address); let bigInts = new Array(); @@ -715,9 +722,7 @@ export function updateAavegotchiWearables( ]); } - if (gotchi.status.equals(STATUS_AAVEGOTCHI)) { - gotchi.save(); - } + return gotchi; } // @ts-ignore