Skip to content

Commit

Permalink
fix: with sets rarity score try#2
Browse files Browse the repository at this point in the history
  • Loading branch information
froid1911 committed Oct 24, 2023
1 parent 18f940a commit aabc475
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 9 deletions.
16 changes: 11 additions & 5 deletions src/mappings/diamond.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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();

Expand Down
13 changes: 9 additions & 4 deletions src/utils/helpers/diamond.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {
AavegotchiDiamond,
ERC1155ExecutedListing,
UpdateWearableSet,
} from "../../../generated/AavegotchiDiamond/AavegotchiDiamond";

import { RealmDiamond } from "../../../generated/RealmDiamond/RealmDiamond";
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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<BigInt>();
Expand Down Expand Up @@ -715,9 +722,7 @@ export function updateAavegotchiWearables(
]);
}

if (gotchi.status.equals(STATUS_AAVEGOTCHI)) {
gotchi.save();
}
return gotchi;
}

// @ts-ignore
Expand Down

0 comments on commit aabc475

Please sign in to comment.