diff --git a/src/mappings/diamond.ts b/src/mappings/diamond.ts index 58fc5e1..eda842b 100644 --- a/src/mappings/diamond.ts +++ b/src/mappings/diamond.ts @@ -323,7 +323,7 @@ export function handleUseConsumables(event: UseConsumables): void { let itemTypes = event.params._itemIds; let quantities = event.params._quantities; for (let i = 0; i < event.params._itemIds.length; i++) { - let itemType = getOrCreateItemType(itemTypes[i].toString()); + let itemType = getOrCreateItemType(itemTypes[i].toString())!; itemType.consumed = itemType.consumed.plus(quantities[i]); itemType.save(); } @@ -766,7 +766,9 @@ export function handleERC1155ListingRemoved( //ERC1155 Item Types export function handleAddItemType(event: AddItemType): void { - let itemType = getOrCreateItemType(event.params._itemType.svgId.toString()); + let itemType = getOrCreateItemType( + event.params._itemType.svgId.toString() + )!; let itemInfo = event.params._itemType; @@ -800,7 +802,7 @@ export function handleItemTypeMaxQuantity(event: ItemTypeMaxQuantity): void { let itemId = itemIds[index]; let maxQuantity = quantities[index]; - let itemType = getOrCreateItemType(itemId.toString()); + let itemType = getOrCreateItemType(itemId.toString())!; itemType.maxQuantity = maxQuantity; itemType.save(); } @@ -816,7 +818,7 @@ export function handlePurchaseItemsWithGhst( let itemId = itemIds[index]; let quantity = quantities[index]; - let itemType = getOrCreateItemType(itemId.toString()); + let itemType = getOrCreateItemType(itemId.toString())!; itemType.totalQuantity = itemType.totalQuantity.plus(quantity); itemType.save(); } @@ -832,7 +834,7 @@ export function handlePurchaseItemsWithVouchers( let itemId = itemIds[index]; let quantity = quantities[index]; - let itemType = getOrCreateItemType(itemId.toString()); + let itemType = getOrCreateItemType(itemId.toString())!; itemType.totalQuantity = itemType.totalQuantity.plus(quantity); itemType.save(); } @@ -846,7 +848,7 @@ export function handleMigrateVouchers(event: MigrateVouchers): void { let itemId = itemIds[index]; let quantity = quantities[index]; - let itemType = getOrCreateItemType(itemId.toString()); + let itemType = getOrCreateItemType(itemId.toString())!; itemType.totalQuantity = itemType.totalQuantity.plus(quantity); itemType.save(); } @@ -877,7 +879,7 @@ export function handleUpdateWearableSet(event: UpdateWearableSet): void { } export function handleItemModifiersSet(event: ItemModifiersSet): void { - let itemType = getOrCreateItemType(event.params._wearableId.toString()); + let itemType = getOrCreateItemType(event.params._wearableId.toString())!; itemType.traitModifiers = event.params._traitModifiers; itemType.rarityScoreModifier = event.params._rarityScoreModifier; itemType.save(); @@ -886,7 +888,7 @@ export function handleItemModifiersSet(event: ItemModifiersSet): void { export function handleWearableSlotPositionsSet( event: WearableSlotPositionsSet ): void { - let itemType = getOrCreateItemType(event.params._wearableId.toString()); + let itemType = getOrCreateItemType(event.params._wearableId.toString())!; itemType.slotPositions = event.params._slotPositions; itemType.save(); } @@ -928,7 +930,7 @@ export function handleERC1155ListingUpdated(event: UpdateERC1155Listing): void { } export function handleUpdateItemPrice(event: UpdateItemPrice): void { - let item = getOrCreateItemType(event.params._itemId.toString()); + let item = getOrCreateItemType(event.params._itemId.toString())!; item.ghstPrice = event.params._priceInWei; item.save(); } diff --git a/src/utils/helpers/diamond.ts b/src/utils/helpers/diamond.ts index 191983d..704c87c 100644 --- a/src/utils/helpers/diamond.ts +++ b/src/utils/helpers/diamond.ts @@ -139,7 +139,7 @@ export function getOrCreateERC1155Purchase( export function getOrCreateItemType( id: string, createIfNotFound: boolean = true -): ItemType { +): ItemType | null { let itemType = ItemType.load(id); if (itemType == null && createIfNotFound) { @@ -147,7 +147,7 @@ export function getOrCreateItemType( itemType.consumed = BIGINT_ZERO; } - return itemType as ItemType; + return itemType; } export function getOrCreateWearableSet( @@ -294,18 +294,17 @@ export function updateERC1155ListingInfo( listing.rarityLevel = rarityLevel; //items - } else { + } else if (listing.category.toI32() < 3) { let itemType = getOrCreateItemType( listingInfo.erc1155TypeId.toString(), false ); - if (itemType) { - listing.rarityLevel = itemMaxQuantityToRarity( - itemType.maxQuantity - ); + if (!itemType) { + return listing; } + listing.rarityLevel = itemMaxQuantityToRarity(itemType.maxQuantity); // brs modifier listing.rarityScoreModifier = BigInt.fromI32( itemType.rarityScoreModifier diff --git a/subgraph.yaml b/subgraph.yaml index 79ef7b4..7a1acc7 100644 --- a/subgraph.yaml +++ b/subgraph.yaml @@ -1,9 +1,9 @@ specVersion: 0.0.3 # features: -# - grafting +# - grafting # graft: -# base: QmdDkULLPVJoy6es7aKd9g6XfkfL2e6DfkNSEoa314HmSi # Subgraph ID of base subgraph -# block: 29354838 # Block number +# base: QmV3LtUtUCiD774HXR3D9SJBNgw2VNcXZM9McyMGTfotBQ # Subgraph ID of base subgraph +# block: 39550000 # Block number description: Aavegotchi Core Matic repository: schema: