Skip to content

Commit e601fff

Browse files
Merge pull request #45 from aavegotchi/fix/deprecatedAt
fix: deprecated at field for installation type
2 parents d8ad4ba + bbd49b7 commit e601fff

File tree

7 files changed

+59
-6
lines changed

7 files changed

+59
-6
lines changed

abis/InstallationDiamond.json

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2964,5 +2964,24 @@
29642964
],
29652965
"name": "UpgradeQueued",
29662966
"type": "event"
2967+
},
2968+
{
2969+
"anonymous": false,
2970+
"inputs": [
2971+
{
2972+
"indexed": false,
2973+
"internalType": "uint256",
2974+
"name": "_installationId",
2975+
"type": "uint256"
2976+
},
2977+
{
2978+
"indexed": false,
2979+
"internalType": "uint256",
2980+
"name": "_newDeprecatetime",
2981+
"type": "uint256"
2982+
}
2983+
],
2984+
"name": "EditDeprecateTime",
2985+
"type": "event"
29672986
}
29682987
]

schema.graphql

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -349,9 +349,12 @@ type EditDeprecateTimeEvent @entity {
349349
transaction: Bytes!
350350
contract: Bytes!
351351

352-
newDeprecatetime: Int
352+
newDeprecatetime: BigInt
353353
tileId: Int
354354
tileType: TileType
355+
356+
installationId: Int
357+
installationType: InstallationType
355358
}
356359

357360
type BounceGateEventStarted @entity {
@@ -464,6 +467,7 @@ type InstallationType @entity {
464467
craftTime: BigInt
465468
nextLevelId: BigInt
466469
deprecated: Boolean
470+
deprecatedAt: BigInt!
467471
alchemicaCost: [BigInt!]
468472
harvestRate: BigInt
469473
capacity: BigInt
@@ -479,7 +483,7 @@ type TileType @entity {
479483
width: Int!
480484
height: Int!
481485
deprecated: Boolean!
482-
deprecatedAt: Int
486+
deprecatedAt: BigInt!
483487
tileType: Int!
484488
craftTime: BigInt!
485489
alchemicaCost: [BigInt!]!

src/helper/installation.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ export function getOrCreateInstallationType(typeId: BigInt): InstallationType {
3434
if (!installationType) {
3535
installationType = new InstallationType(id);
3636
installationType.amount = BIGINT_ZERO;
37+
installationType.deprecatedAt = BIGINT_ZERO;
3738
installationType = updateInstallationType(installationType);
3839
}
3940
return installationType;

src/helper/tiles.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ export function getOrCreateTileType(tileId: BigInt): TileType {
2828
tile.alchemicaCost = data.alchemicaCost;
2929
tile.craftTime = data.craftTime;
3030
tile.deprecated = data.deprecated;
31+
tile.deprecatedAt = BIGINT_ZERO;
3132
tile.height = data.height;
3233
tile.width = data.width;
3334
tile.name = data.name;

src/mappings/installation.ts

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import {
33
AddInstallationType,
44
CraftTimeReduced,
55
DeprecateInstallation,
6+
EditDeprecateTime,
67
EditInstallationType,
78
MintInstallation,
89
MintInstallations,
@@ -12,7 +13,7 @@ import {
1213
UpgradeTimeReduced,
1314
URI,
1415
} from "../../generated/InstallationDiamond/InstallationDiamond";
15-
import { URIEvent } from "../../generated/schema";
16+
import { EditDeprecateTimeEvent, URIEvent } from "../../generated/schema";
1617
import { BIGINT_ONE, StatCategory } from "../helper/constants";
1718
import {
1819
createAddInstallationType,
@@ -277,3 +278,29 @@ export function handleURI(event: URI): void {
277278
installation.uri = event.params._value;
278279
installation.save();
279280
}
281+
282+
export function handleEditDeprecateTime(event: EditDeprecateTime): void {
283+
// create Event entity
284+
let id =
285+
event.transaction.from.toHexString() +
286+
"-" +
287+
event.params._installationId.toString() +
288+
"-" +
289+
event.block.number.toString();
290+
let eventEntity = new EditDeprecateTimeEvent(id);
291+
eventEntity.transaction = event.transaction.hash;
292+
eventEntity.block = event.block.number;
293+
eventEntity.timestamp = event.block.timestamp;
294+
eventEntity.contract = event.address;
295+
eventEntity.installationId = event.params._installationId.toI32();
296+
eventEntity.newDeprecatetime = event.params._newDeprecatetime;
297+
eventEntity.installationType = event.params._installationId.toString();
298+
eventEntity.save();
299+
300+
// update installationType
301+
let installationType = getOrCreateInstallationType(
302+
event.params._installationId
303+
);
304+
installationType.deprecatedAt = event.params._newDeprecatetime;
305+
installationType.save();
306+
}

src/mappings/tile.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -176,13 +176,12 @@ export function handleEditDeprecateTime(event: EditDeprecateTime): void {
176176
eventEntity.timestamp = event.block.timestamp;
177177
eventEntity.contract = event.address;
178178
eventEntity.tileId = event.params._tileId.toI32();
179-
eventEntity.newDeprecatetime = eventEntity.newDeprecatetime;
179+
eventEntity.newDeprecatetime = event.params._newDeprecatetime;
180180
eventEntity.tileType = event.params._tileId.toString();
181181
eventEntity.save();
182182

183183
// update tileType
184184
let tileType = getOrCreateTileType(event.params._tileId);
185-
tileType.deprecated = true;
186-
tileType.deprecatedAt = event.params._newDeprecatetime.toI32();
185+
tileType.deprecatedAt = event.params._newDeprecatetime;
187186
tileType.save();
188187
}

subgraph.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,3 +148,5 @@ dataSources:
148148
handler: handleUpgradeQueued
149149
- event: URI(string,indexed uint256)
150150
handler: handleURI
151+
- event: EditDeprecateTime(uint256,uint256)
152+
handler: handleEditDeprecateTime

0 commit comments

Comments
 (0)