From 4536bc8ebf9a90ac6c613f3d272bc312455019be Mon Sep 17 00:00:00 2001 From: Frank Date: Wed, 22 Feb 2023 11:19:04 +0100 Subject: [PATCH 1/3] fix missing item type --- src/utils/helpers/diamond.ts | 2 +- subgraph.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/utils/helpers/diamond.ts b/src/utils/helpers/diamond.ts index 191983d..0cb0651 100644 --- a/src/utils/helpers/diamond.ts +++ b/src/utils/helpers/diamond.ts @@ -289,7 +289,7 @@ export function updateERC1155ListingInfo( listing.quantity = listingInfo.quantity; //tickets - if (listing.category.toI32() === 3) { + if (listing.category.toI32() < 3) { let rarityLevel = listing.erc1155TypeId; listing.rarityLevel = rarityLevel; diff --git a/subgraph.yaml b/subgraph.yaml index 79ef7b4..f09d60a 100644 --- a/subgraph.yaml +++ b/subgraph.yaml @@ -3,7 +3,7 @@ specVersion: 0.0.3 # - grafting # graft: # base: QmdDkULLPVJoy6es7aKd9g6XfkfL2e6DfkNSEoa314HmSi # Subgraph ID of base subgraph -# block: 29354838 # Block number +# block: 39550000 # Block number description: Aavegotchi Core Matic repository: schema: From 9fe38b1bb85fac0b3e929f04c35c77097bfc0472 Mon Sep 17 00:00:00 2001 From: Frank Date: Wed, 22 Feb 2023 11:28:53 +0100 Subject: [PATCH 2/3] updated grafting --- src/utils/helpers/diamond.ts | 4 ++-- subgraph.yaml | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/utils/helpers/diamond.ts b/src/utils/helpers/diamond.ts index 0cb0651..463675c 100644 --- a/src/utils/helpers/diamond.ts +++ b/src/utils/helpers/diamond.ts @@ -289,12 +289,12 @@ export function updateERC1155ListingInfo( listing.quantity = listingInfo.quantity; //tickets - if (listing.category.toI32() < 3) { + if (listing.category.toI32() === 3) { let rarityLevel = listing.erc1155TypeId; listing.rarityLevel = rarityLevel; //items - } else { + } else if (listing.category.toI32() < 3) { let itemType = getOrCreateItemType( listingInfo.erc1155TypeId.toString(), false diff --git a/subgraph.yaml b/subgraph.yaml index f09d60a..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: 39550000 # Block number +# base: QmV3LtUtUCiD774HXR3D9SJBNgw2VNcXZM9McyMGTfotBQ # Subgraph ID of base subgraph +# block: 39550000 # Block number description: Aavegotchi Core Matic repository: schema: From eaa3a836707ab6a3b01e6c63554d25e45509faf5 Mon Sep 17 00:00:00 2001 From: Frank Date: Wed, 22 Feb 2023 11:35:59 +0100 Subject: [PATCH 3/3] fixed issues with itemType --- src/mappings/diamond.ts | 20 +++++++++++--------- src/utils/helpers/diamond.ts | 11 +++++------ 2 files changed, 16 insertions(+), 15 deletions(-) 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 463675c..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( @@ -300,12 +300,11 @@ export function updateERC1155ListingInfo( 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