Skip to content

Commit

Permalink
Update polter.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
cinnabarhorse committed Nov 26, 2024
1 parent 8ed095b commit 2cc81df
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/mappings/polter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1888,6 +1888,30 @@ export function handleTransfer(event: Transfer): void {
let gotchiResponse = contract.try_getAavegotchi(BigInt.fromString(tokenId));

if (!gotchiResponse.reverted) {
if (
gotchiResponse.value.status.equals(STATUS_CLOSED_PORTAL) &&
event.params._to.toHexString() == ZERO_ADDRESS
) {
//an aavegotchi (or possibly a closed portal) that has either been sacrificed or bridged back to Polygon
let gotchi = getOrCreateAavegotchi(tokenId, event, false);
let portal = getOrCreatePortal(tokenId, false);

if (gotchi) {
gotchi = updateAavegotchiInfo(gotchi, event.params._tokenId, event);
gotchi = updateAavegotchiWearables(gotchi, event);
gotchi.claimedAt = event.block.number;
gotchi.claimedTime = event.block.timestamp;
gotchi.gotchiId = event.params._tokenId;

gotchi.save();
}

if (portal) {
portal.owner = newOwner.id;
portal.save();
}
}

if (gotchiResponse.value.status.equals(STATUS_CLOSED_PORTAL)) {
let portal = getOrCreatePortal(tokenId, true);
portal.status = PORTAL_STATUS_BOUGHT;
Expand Down

0 comments on commit 2cc81df

Please sign in to comment.