From 7cd8cfbc6c091786b40cbc8f4b954e695833878f Mon Sep 17 00:00:00 2001 From: narayanprusty Date: Fri, 13 Oct 2023 01:01:31 +0100 Subject: [PATCH 01/42] migrate fakegotchi subgraph --- abis/Contract.json | 9796 +++++++++++++++++++++ abis/diamond_erc1155.json | 1 + abis/diamond_erc721.json | 1264 +++ datasources.json | 11 + package.json | 3 +- schema.graphql | 267 + src/constants.ts | 20 + src/diamonds/constants.ts | 20 + src/diamonds/fakeGotchisCard.ts | 159 + src/diamonds/fakeGotchisNFT.ts | 358 + src/fetch/account.ts | 203 + src/fetch/erc1155.ts | 111 + src/fetch/erc165.ts | 13 + src/fetch/erc721.ts | 125 + src/helper/entities.ts | 88 + src/helper/json.ts | 27 + src/ownable.ts | 27 + subgraph.mumbai.yaml | 60 + subgraph.yaml | 60 + tests/handleERC721ExecutedListing.test.ts | 6 +- tests/handleERC721ListingAdded.test.ts | 2 +- tests/handleEquip.test.ts | 2 +- tests/handleInteract.test.ts | 2 +- tests/handleSetAavegotchiName.test.ts | 2 +- tests/handleSpendSkillpoints.test.ts | 2 +- tests/handleTransfer.test.ts | 280 + tests/handleTransferERC721.test.ts | 4 +- tests/handleUseConsumable.test.ts | 2 +- yarn.lock | 39 +- 29 files changed, 12941 insertions(+), 13 deletions(-) create mode 100644 abis/Contract.json create mode 100644 abis/diamond_erc1155.json create mode 100644 abis/diamond_erc721.json create mode 100644 datasources.json create mode 100644 src/constants.ts create mode 100644 src/diamonds/constants.ts create mode 100644 src/diamonds/fakeGotchisCard.ts create mode 100644 src/diamonds/fakeGotchisNFT.ts create mode 100644 src/fetch/account.ts create mode 100644 src/fetch/erc1155.ts create mode 100644 src/fetch/erc165.ts create mode 100644 src/fetch/erc721.ts create mode 100644 src/helper/entities.ts create mode 100644 src/helper/json.ts create mode 100644 src/ownable.ts create mode 100644 tests/handleTransfer.test.ts diff --git a/abis/Contract.json b/abis/Contract.json new file mode 100644 index 0000000..428192c --- /dev/null +++ b/abis/Contract.json @@ -0,0 +1,9796 @@ +[ + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "_owner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "_operator", + "type": "address" + }, + { + "indexed": false, + "internalType": "bool", + "name": "_approved", + "type": "bool" + } + ], + "name": "PetOperatorApprovalForAll", + "type": "event" + }, + { + "inputs": [ + { "internalType": "uint256", "name": "_tokenId", "type": "uint256" } + ], + "name": "aavegotchiClaimTime", + "outputs": [ + { + "internalType": "uint256", + "name": "claimTime_", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "_owner", "type": "address" } + ], + "name": "allAavegotchisOfOwner", + "outputs": [ + { + "components": [ + { + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + }, + { + "internalType": "string", + "name": "name", + "type": "string" + }, + { + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "internalType": "uint256", + "name": "randomNumber", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "status", + "type": "uint256" + }, + { + "internalType": "int16[6]", + "name": "numericTraits", + "type": "int16[6]" + }, + { + "internalType": "int16[6]", + "name": "modifiedNumericTraits", + "type": "int16[6]" + }, + { + "internalType": "uint16[16]", + "name": "equippedWearables", + "type": "uint16[16]" + }, + { + "internalType": "address", + "name": "collateral", + "type": "address" + }, + { + "internalType": "address", + "name": "escrow", + "type": "address" + }, + { + "internalType": "uint256", + "name": "stakedAmount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "minimumStake", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "kinship", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "lastInteracted", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "experience", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "toNextLevel", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "usedSkillPoints", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "level", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "hauntId", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "baseRarityScore", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "modifiedRarityScore", + "type": "uint256" + }, + { + "internalType": "bool", + "name": "locked", + "type": "bool" + }, + { + "components": [ + { + "internalType": "uint256", + "name": "balance", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "itemId", + "type": "uint256" + }, + { + "components": [ + { + "internalType": "string", + "name": "name", + "type": "string" + }, + { + "internalType": "string", + "name": "description", + "type": "string" + }, + { + "internalType": "string", + "name": "author", + "type": "string" + }, + { + "internalType": "int8[6]", + "name": "traitModifiers", + "type": "int8[6]" + }, + { + "internalType": "bool[16]", + "name": "slotPositions", + "type": "bool[16]" + }, + { + "internalType": "uint8[]", + "name": "allowedCollaterals", + "type": "uint8[]" + }, + { + "components": [ + { + "internalType": "uint8", + "name": "x", + "type": "uint8" + }, + { + "internalType": "uint8", + "name": "y", + "type": "uint8" + }, + { + "internalType": "uint8", + "name": "width", + "type": "uint8" + }, + { + "internalType": "uint8", + "name": "height", + "type": "uint8" + } + ], + "internalType": "struct Dimensions", + "name": "dimensions", + "type": "tuple" + }, + { + "internalType": "uint256", + "name": "ghstPrice", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "maxQuantity", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "totalQuantity", + "type": "uint256" + }, + { + "internalType": "uint32", + "name": "svgId", + "type": "uint32" + }, + { + "internalType": "uint8", + "name": "rarityScoreModifier", + "type": "uint8" + }, + { + "internalType": "bool", + "name": "canPurchaseWithGhst", + "type": "bool" + }, + { + "internalType": "uint16", + "name": "minLevel", + "type": "uint16" + }, + { + "internalType": "bool", + "name": "canBeTransferred", + "type": "bool" + }, + { + "internalType": "uint8", + "name": "category", + "type": "uint8" + }, + { + "internalType": "int16", + "name": "kinshipBonus", + "type": "int16" + }, + { + "internalType": "uint32", + "name": "experienceBonus", + "type": "uint32" + } + ], + "internalType": "struct ItemType", + "name": "itemType", + "type": "tuple" + } + ], + "internalType": "struct ItemTypeIO[]", + "name": "items", + "type": "tuple[]" + } + ], + "internalType": "struct AavegotchiInfo[]", + "name": "aavegotchiInfos_", + "type": "tuple[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_approved", + "type": "address" + }, + { "internalType": "uint256", "name": "_tokenId", "type": "uint256" } + ], + "name": "approve", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "_owner", "type": "address" } + ], + "name": "balanceOf", + "outputs": [ + { "internalType": "uint256", "name": "balance_", "type": "uint256" } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "uint256", "name": "_tokenId", "type": "uint256" } + ], + "name": "getAavegotchi", + "outputs": [ + { + "components": [ + { + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + }, + { + "internalType": "string", + "name": "name", + "type": "string" + }, + { + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "internalType": "uint256", + "name": "randomNumber", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "status", + "type": "uint256" + }, + { + "internalType": "int16[6]", + "name": "numericTraits", + "type": "int16[6]" + }, + { + "internalType": "int16[6]", + "name": "modifiedNumericTraits", + "type": "int16[6]" + }, + { + "internalType": "uint16[16]", + "name": "equippedWearables", + "type": "uint16[16]" + }, + { + "internalType": "address", + "name": "collateral", + "type": "address" + }, + { + "internalType": "address", + "name": "escrow", + "type": "address" + }, + { + "internalType": "uint256", + "name": "stakedAmount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "minimumStake", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "kinship", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "lastInteracted", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "experience", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "toNextLevel", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "usedSkillPoints", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "level", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "hauntId", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "baseRarityScore", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "modifiedRarityScore", + "type": "uint256" + }, + { + "internalType": "bool", + "name": "locked", + "type": "bool" + }, + { + "components": [ + { + "internalType": "uint256", + "name": "balance", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "itemId", + "type": "uint256" + }, + { + "components": [ + { + "internalType": "string", + "name": "name", + "type": "string" + }, + { + "internalType": "string", + "name": "description", + "type": "string" + }, + { + "internalType": "string", + "name": "author", + "type": "string" + }, + { + "internalType": "int8[6]", + "name": "traitModifiers", + "type": "int8[6]" + }, + { + "internalType": "bool[16]", + "name": "slotPositions", + "type": "bool[16]" + }, + { + "internalType": "uint8[]", + "name": "allowedCollaterals", + "type": "uint8[]" + }, + { + "components": [ + { + "internalType": "uint8", + "name": "x", + "type": "uint8" + }, + { + "internalType": "uint8", + "name": "y", + "type": "uint8" + }, + { + "internalType": "uint8", + "name": "width", + "type": "uint8" + }, + { + "internalType": "uint8", + "name": "height", + "type": "uint8" + } + ], + "internalType": "struct Dimensions", + "name": "dimensions", + "type": "tuple" + }, + { + "internalType": "uint256", + "name": "ghstPrice", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "maxQuantity", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "totalQuantity", + "type": "uint256" + }, + { + "internalType": "uint32", + "name": "svgId", + "type": "uint32" + }, + { + "internalType": "uint8", + "name": "rarityScoreModifier", + "type": "uint8" + }, + { + "internalType": "bool", + "name": "canPurchaseWithGhst", + "type": "bool" + }, + { + "internalType": "uint16", + "name": "minLevel", + "type": "uint16" + }, + { + "internalType": "bool", + "name": "canBeTransferred", + "type": "bool" + }, + { + "internalType": "uint8", + "name": "category", + "type": "uint8" + }, + { + "internalType": "int16", + "name": "kinshipBonus", + "type": "int16" + }, + { + "internalType": "uint32", + "name": "experienceBonus", + "type": "uint32" + } + ], + "internalType": "struct ItemType", + "name": "itemType", + "type": "tuple" + } + ], + "internalType": "struct ItemTypeIO[]", + "name": "items", + "type": "tuple[]" + } + ], + "internalType": "struct AavegotchiInfo", + "name": "aavegotchiInfo_", + "type": "tuple" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "uint256", "name": "_tokenId", "type": "uint256" } + ], + "name": "getApproved", + "outputs": [ + { + "internalType": "address", + "name": "approved_", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "_owner", "type": "address" }, + { + "internalType": "address", + "name": "_operator", + "type": "address" + } + ], + "name": "isApprovedForAll", + "outputs": [ + { "internalType": "bool", "name": "approved_", "type": "bool" } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "_owner", "type": "address" }, + { + "internalType": "address", + "name": "_operator", + "type": "address" + } + ], + "name": "isPetOperatorForAll", + "outputs": [ + { "internalType": "bool", "name": "approved_", "type": "bool" } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "name", + "outputs": [{ "internalType": "string", "name": "", "type": "string" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "uint256", "name": "_tokenId", "type": "uint256" } + ], + "name": "ownerOf", + "outputs": [ + { "internalType": "address", "name": "owner_", "type": "address" } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "_from", "type": "address" }, + { "internalType": "address", "name": "_to", "type": "address" }, + { + "internalType": "uint256[]", + "name": "_tokenIds", + "type": "uint256[]" + }, + { "internalType": "bytes", "name": "_data", "type": "bytes" } + ], + "name": "safeBatchTransferFrom", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "_from", "type": "address" }, + { "internalType": "address", "name": "_to", "type": "address" }, + { "internalType": "uint256", "name": "_tokenId", "type": "uint256" } + ], + "name": "safeTransferFrom", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "_from", "type": "address" }, + { "internalType": "address", "name": "_to", "type": "address" }, + { + "internalType": "uint256", + "name": "_tokenId", + "type": "uint256" + }, + { "internalType": "bytes", "name": "_data", "type": "bytes" } + ], + "name": "safeTransferFrom", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_operator", + "type": "address" + }, + { "internalType": "bool", "name": "_approved", "type": "bool" } + ], + "name": "setApprovalForAll", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_operator", + "type": "address" + }, + { "internalType": "bool", "name": "_approved", "type": "bool" } + ], + "name": "setPetOperatorForAll", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "symbol", + "outputs": [{ "internalType": "string", "name": "", "type": "string" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "uint256", "name": "_index", "type": "uint256" } + ], + "name": "tokenByIndex", + "outputs": [ + { "internalType": "uint256", "name": "tokenId_", "type": "uint256" } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "_owner", "type": "address" } + ], + "name": "tokenIdsOfOwner", + "outputs": [ + { + "internalType": "uint32[]", + "name": "tokenIds_", + "type": "uint32[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "_owner", "type": "address" }, + { "internalType": "uint256", "name": "_index", "type": "uint256" } + ], + "name": "tokenOfOwnerByIndex", + "outputs": [ + { "internalType": "uint256", "name": "tokenId_", "type": "uint256" } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "uint256", "name": "_tokenId", "type": "uint256" } + ], + "name": "tokenURI", + "outputs": [{ "internalType": "string", "name": "", "type": "string" }], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [], + "name": "totalSupply", + "outputs": [ + { + "internalType": "uint256", + "name": "totalSupply_", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "_from", "type": "address" }, + { "internalType": "address", "name": "_to", "type": "address" }, + { "internalType": "uint256", "name": "_tokenId", "type": "uint256" } + ], + "name": "transferFrom", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint256", + "name": "_tokenId", + "type": "uint256" + } + ], + "name": "ClaimAavegotchi", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint256", + "name": "_tokenId", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "_time", + "type": "uint256" + } + ], + "name": "LockAavegotchi", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint256", + "name": "_tokenId", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "string", + "name": "_oldName", + "type": "string" + }, + { + "indexed": false, + "internalType": "string", + "name": "_newName", + "type": "string" + } + ], + "name": "SetAavegotchiName", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint256", + "name": "_batchId", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256[]", + "name": "tokenIds", + "type": "uint256[]" + } + ], + "name": "SetBatchId", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint256", + "name": "_tokenId", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "int16[4]", + "name": "_values", + "type": "int16[4]" + } + ], + "name": "SpendSkillpoints", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint256", + "name": "_tokenId", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "_time", + "type": "uint256" + } + ], + "name": "UnLockAavegotchi", + "type": "event" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "_experience", + "type": "uint256" + } + ], + "name": "aavegotchiLevel", + "outputs": [ + { "internalType": "uint256", "name": "level_", "type": "uint256" } + ], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [ + { "internalType": "string", "name": "_name", "type": "string" } + ], + "name": "aavegotchiNameAvailable", + "outputs": [ + { "internalType": "bool", "name": "available_", "type": "bool" } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "uint256", "name": "_tokenId", "type": "uint256" } + ], + "name": "availableSkillPoints", + "outputs": [ + { "internalType": "uint256", "name": "", "type": "uint256" } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "int16[6]", + "name": "_numericTraits", + "type": "int16[6]" + } + ], + "name": "baseRarityScore", + "outputs": [ + { + "internalType": "uint256", + "name": "rarityScore_", + "type": "uint256" + } + ], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "_tokenId", + "type": "uint256" + }, + { "internalType": "uint256", "name": "_option", "type": "uint256" }, + { + "internalType": "uint256", + "name": "_stakeAmount", + "type": "uint256" + } + ], + "name": "claimAavegotchi", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "currentHaunt", + "outputs": [ + { + "internalType": "uint256", + "name": "hauntId_", + "type": "uint256" + }, + { + "components": [ + { + "internalType": "uint256", + "name": "hauntMaxSize", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "portalPrice", + "type": "uint256" + }, + { + "internalType": "bytes3", + "name": "bodyColor", + "type": "bytes3" + }, + { + "internalType": "uint24", + "name": "totalCount", + "type": "uint24" + } + ], + "internalType": "struct Haunt", + "name": "haunt_", + "type": "tuple" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "uint256", "name": "_tokenId", "type": "uint256" } + ], + "name": "getNumericTraits", + "outputs": [ + { + "internalType": "int16[6]", + "name": "numericTraits_", + "type": "int16[6]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "ghstAddress", + "outputs": [ + { + "internalType": "address", + "name": "contract_", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256[]", + "name": "_tokenIds", + "type": "uint256[]" + } + ], + "name": "interact", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "uint256", "name": "_tokenId", "type": "uint256" } + ], + "name": "kinship", + "outputs": [ + { "internalType": "uint256", "name": "score_", "type": "uint256" } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "uint256", "name": "_tokenId", "type": "uint256" } + ], + "name": "modifiedTraitsAndRarityScore", + "outputs": [ + { + "internalType": "int16[6]", + "name": "numericTraits_", + "type": "int16[6]" + }, + { + "internalType": "uint256", + "name": "rarityScore_", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "uint256", "name": "_tokenId", "type": "uint256" } + ], + "name": "portalAavegotchiTraits", + "outputs": [ + { + "components": [ + { + "internalType": "uint256", + "name": "randomNumber", + "type": "uint256" + }, + { + "internalType": "int16[6]", + "name": "numericTraits", + "type": "int16[6]" + }, + { + "internalType": "address", + "name": "collateralType", + "type": "address" + }, + { + "internalType": "uint256", + "name": "minimumStake", + "type": "uint256" + } + ], + "internalType": "struct PortalAavegotchiTraitsIO[10]", + "name": "portalAavegotchiTraits_", + "type": "tuple[10]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "int16[6]", + "name": "_numericTraits", + "type": "int16[6]" + } + ], + "name": "rarityMultiplier", + "outputs": [ + { + "internalType": "uint256", + "name": "multiplier_", + "type": "uint256" + } + ], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [], + "name": "revenueShares", + "outputs": [ + { + "components": [ + { + "internalType": "address", + "name": "burnAddress", + "type": "address" + }, + { + "internalType": "address", + "name": "daoAddress", + "type": "address" + }, + { + "internalType": "address", + "name": "rarityFarming", + "type": "address" + }, + { + "internalType": "address", + "name": "pixelCraft", + "type": "address" + } + ], + "internalType": "struct AavegotchiGameFacet.RevenueSharesIO", + "name": "", + "type": "tuple" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "_tokenId", + "type": "uint256" + }, + { "internalType": "string", "name": "_name", "type": "string" } + ], + "name": "setAavegotchiName", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "_tokenId", + "type": "uint256" + }, + { + "internalType": "int16[4]", + "name": "_values", + "type": "int16[4]" + } + ], + "name": "spendSkillPoints", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "_owner", "type": "address" }, + { "internalType": "uint256", "name": "_count", "type": "uint256" }, + { "internalType": "uint256", "name": "_skip", "type": "uint256" }, + { "internalType": "bool", "name": "all", "type": "bool" } + ], + "name": "tokenIdsWithKinship", + "outputs": [ + { + "components": [ + { + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "kinship", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "lastInteracted", + "type": "uint256" + } + ], + "internalType": "struct AavegotchiGameFacet.TokenIdsWithKinship[]", + "name": "tokenIdsWithKinship_", + "type": "tuple[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "_experience", + "type": "uint256" + } + ], + "name": "xpUntilNextLevel", + "outputs": [ + { + "internalType": "uint256", + "name": "requiredXp_", + "type": "uint256" + } + ], + "stateMutability": "pure", + "type": "function" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256[]", + "name": "tokenIds", + "type": "uint256[]" + } + ], + "name": "AddedAavegotchiBatch", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256[]", + "name": "ids", + "type": "uint256[]" + }, + { + "indexed": false, + "internalType": "uint256[]", + "name": "values", + "type": "uint256[]" + } + ], + "name": "AddedItemsBatch", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256[]", + "name": "tokenIds", + "type": "uint256[]" + } + ], + "name": "WithdrawnBatch", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256[]", + "name": "ids", + "type": "uint256[]" + }, + { + "indexed": false, + "internalType": "uint256[]", + "name": "values", + "type": "uint256[]" + } + ], + "name": "WithdrawnItems", + "type": "event" + }, + { + "inputs": [], + "name": "childChainManager", + "outputs": [ + { "internalType": "address", "name": "", "type": "address" } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "_user", "type": "address" }, + { "internalType": "bytes", "name": "_depositData", "type": "bytes" } + ], + "name": "deposit", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_newChildChainManager", + "type": "address" + } + ], + "name": "setChildChainManager", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256[]", + "name": "_tokenIds", + "type": "uint256[]" + } + ], + "name": "withdrawAavegotchiBatch", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256[]", + "name": "_ids", + "type": "uint256[]" + }, + { + "internalType": "uint256[]", + "name": "_values", + "type": "uint256[]" + } + ], + "name": "withdrawItemsBatch", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint256", + "name": "_tokenId", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "_reduceAmount", + "type": "uint256" + } + ], + "name": "DecreaseStake", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint256", + "name": "_fromTokenId", + "type": "uint256" + }, + { + "indexed": true, + "internalType": "uint256", + "name": "_toTokenId", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "experience", + "type": "uint256" + } + ], + "name": "ExperienceTransfer", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint256", + "name": "_tokenId", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "_stakeAmount", + "type": "uint256" + } + ], + "name": "IncreaseStake", + "type": "event" + }, + { + "inputs": [ + { "internalType": "uint256", "name": "_tokenId", "type": "uint256" } + ], + "name": "collateralBalance", + "outputs": [ + { + "internalType": "address", + "name": "collateralType_", + "type": "address" + }, + { "internalType": "address", "name": "escrow_", "type": "address" }, + { "internalType": "uint256", "name": "balance_", "type": "uint256" } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "_hauntId", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_collateralId", + "type": "uint256" + } + ], + "name": "collateralInfo", + "outputs": [ + { + "components": [ + { + "internalType": "address", + "name": "collateralType", + "type": "address" + }, + { + "components": [ + { + "internalType": "int16[6]", + "name": "modifiers", + "type": "int16[6]" + }, + { + "internalType": "bytes3", + "name": "primaryColor", + "type": "bytes3" + }, + { + "internalType": "bytes3", + "name": "secondaryColor", + "type": "bytes3" + }, + { + "internalType": "bytes3", + "name": "cheekColor", + "type": "bytes3" + }, + { + "internalType": "uint8", + "name": "svgId", + "type": "uint8" + }, + { + "internalType": "uint8", + "name": "eyeShapeSvgId", + "type": "uint8" + }, + { + "internalType": "uint16", + "name": "conversionRate", + "type": "uint16" + }, + { + "internalType": "bool", + "name": "delisted", + "type": "bool" + } + ], + "internalType": "struct AavegotchiCollateralTypeInfo", + "name": "collateralTypeInfo", + "type": "tuple" + } + ], + "internalType": "struct AavegotchiCollateralTypeIO", + "name": "collateralInfo_", + "type": "tuple" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "uint256", "name": "_hauntId", "type": "uint256" } + ], + "name": "collaterals", + "outputs": [ + { + "internalType": "address[]", + "name": "collateralTypes_", + "type": "address[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "_tokenId", + "type": "uint256" + }, + { "internalType": "uint256", "name": "_toId", "type": "uint256" } + ], + "name": "decreaseAndDestroy", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "_tokenId", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_reduceAmount", + "type": "uint256" + } + ], + "name": "decreaseStake", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "getAllCollateralTypes", + "outputs": [ + { "internalType": "address[]", "name": "", "type": "address[]" } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "uint256", "name": "_hauntId", "type": "uint256" } + ], + "name": "getCollateralInfo", + "outputs": [ + { + "components": [ + { + "internalType": "address", + "name": "collateralType", + "type": "address" + }, + { + "components": [ + { + "internalType": "int16[6]", + "name": "modifiers", + "type": "int16[6]" + }, + { + "internalType": "bytes3", + "name": "primaryColor", + "type": "bytes3" + }, + { + "internalType": "bytes3", + "name": "secondaryColor", + "type": "bytes3" + }, + { + "internalType": "bytes3", + "name": "cheekColor", + "type": "bytes3" + }, + { + "internalType": "uint8", + "name": "svgId", + "type": "uint8" + }, + { + "internalType": "uint8", + "name": "eyeShapeSvgId", + "type": "uint8" + }, + { + "internalType": "uint16", + "name": "conversionRate", + "type": "uint16" + }, + { + "internalType": "bool", + "name": "delisted", + "type": "bool" + } + ], + "internalType": "struct AavegotchiCollateralTypeInfo", + "name": "collateralTypeInfo", + "type": "tuple" + } + ], + "internalType": "struct AavegotchiCollateralTypeIO[]", + "name": "collateralInfo_", + "type": "tuple[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "_tokenId", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_stakeAmount", + "type": "uint256" + } + ], + "name": "increaseStake", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_collateralToken", + "type": "address" + }, + { "internalType": "uint8", "name": "_svgId", "type": "uint8" } + ], + "name": "setCollateralEyeShapeSvgId", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "anonymous": false, + "inputs": [ + { + "components": [ + { + "internalType": "address", + "name": "collateralType", + "type": "address" + }, + { + "components": [ + { + "internalType": "int16[6]", + "name": "modifiers", + "type": "int16[6]" + }, + { + "internalType": "bytes3", + "name": "primaryColor", + "type": "bytes3" + }, + { + "internalType": "bytes3", + "name": "secondaryColor", + "type": "bytes3" + }, + { + "internalType": "bytes3", + "name": "cheekColor", + "type": "bytes3" + }, + { + "internalType": "uint8", + "name": "svgId", + "type": "uint8" + }, + { + "internalType": "uint8", + "name": "eyeShapeSvgId", + "type": "uint8" + }, + { + "internalType": "uint16", + "name": "conversionRate", + "type": "uint16" + }, + { + "internalType": "bool", + "name": "delisted", + "type": "bool" + } + ], + "internalType": "struct AavegotchiCollateralTypeInfo", + "name": "collateralTypeInfo", + "type": "tuple" + } + ], + "indexed": false, + "internalType": "struct AavegotchiCollateralTypeIO", + "name": "_collateralType", + "type": "tuple" + } + ], + "name": "AddCollateralType", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "components": [ + { + "internalType": "string", + "name": "name", + "type": "string" + }, + { + "internalType": "string", + "name": "description", + "type": "string" + }, + { + "internalType": "string", + "name": "author", + "type": "string" + }, + { + "internalType": "int8[6]", + "name": "traitModifiers", + "type": "int8[6]" + }, + { + "internalType": "bool[16]", + "name": "slotPositions", + "type": "bool[16]" + }, + { + "internalType": "uint8[]", + "name": "allowedCollaterals", + "type": "uint8[]" + }, + { + "components": [ + { + "internalType": "uint8", + "name": "x", + "type": "uint8" + }, + { + "internalType": "uint8", + "name": "y", + "type": "uint8" + }, + { + "internalType": "uint8", + "name": "width", + "type": "uint8" + }, + { + "internalType": "uint8", + "name": "height", + "type": "uint8" + } + ], + "internalType": "struct Dimensions", + "name": "dimensions", + "type": "tuple" + }, + { + "internalType": "uint256", + "name": "ghstPrice", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "maxQuantity", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "totalQuantity", + "type": "uint256" + }, + { + "internalType": "uint32", + "name": "svgId", + "type": "uint32" + }, + { + "internalType": "uint8", + "name": "rarityScoreModifier", + "type": "uint8" + }, + { + "internalType": "bool", + "name": "canPurchaseWithGhst", + "type": "bool" + }, + { + "internalType": "uint16", + "name": "minLevel", + "type": "uint16" + }, + { + "internalType": "bool", + "name": "canBeTransferred", + "type": "bool" + }, + { + "internalType": "uint8", + "name": "category", + "type": "uint8" + }, + { + "internalType": "int16", + "name": "kinshipBonus", + "type": "int16" + }, + { + "internalType": "uint32", + "name": "experienceBonus", + "type": "uint32" + } + ], + "indexed": false, + "internalType": "struct ItemType", + "name": "_itemType", + "type": "tuple" + } + ], + "name": "AddItemType", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "components": [ + { + "internalType": "string", + "name": "name", + "type": "string" + }, + { + "internalType": "uint8[]", + "name": "allowedCollaterals", + "type": "uint8[]" + }, + { + "internalType": "uint16[]", + "name": "wearableIds", + "type": "uint16[]" + }, + { + "internalType": "int8[5]", + "name": "traitsBonuses", + "type": "int8[5]" + } + ], + "indexed": false, + "internalType": "struct WearableSet", + "name": "_wearableSet", + "type": "tuple" + } + ], + "name": "AddWearableSet", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint256", + "name": "_hauntId", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "_hauntMaxSize", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "_portalPrice", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "bytes32", + "name": "_bodyColor", + "type": "bytes32" + } + ], + "name": "CreateHaunt", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "previousDao", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newDao", + "type": "address" + } + ], + "name": "DaoTransferred", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "previousDaoTreasury", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newDaoTreasury", + "type": "address" + } + ], + "name": "DaoTreasuryTransferred", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "gameManager_", + "type": "address" + }, + { + "indexed": true, + "internalType": "uint256", + "name": "limit_", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "refreshTime_", + "type": "uint256" + } + ], + "name": "GameManagerAdded", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "gameManager_", + "type": "address" + } + ], + "name": "GameManagerRemoved", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256[]", + "name": "_tokenIds", + "type": "uint256[]" + }, + { + "indexed": false, + "internalType": "uint256[]", + "name": "_xpValues", + "type": "uint256[]" + } + ], + "name": "GrantExperience", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "newItemManager_", + "type": "address" + } + ], + "name": "ItemManagerAdded", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "itemManager_", + "type": "address" + } + ], + "name": "ItemManagerRemoved", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "_wearableId", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "int8[6]", + "name": "_traitModifiers", + "type": "int8[6]" + }, + { + "indexed": false, + "internalType": "uint8", + "name": "_rarityScoreModifier", + "type": "uint8" + } + ], + "name": "ItemModifiersSet", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256[]", + "name": "_itemIds", + "type": "uint256[]" + }, + { + "indexed": false, + "internalType": "uint256[]", + "name": "_maxQuanities", + "type": "uint256[]" + } + ], + "name": "ItemTypeMaxQuantity", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256[]", + "name": "_tokenIds", + "type": "uint256[]" + }, + { + "indexed": false, + "internalType": "uint256[]", + "name": "_xpValues", + "type": "uint256[]" + } + ], + "name": "RemoveExperience", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "int16[6]", + "name": "_oldModifiers", + "type": "int16[6]" + }, + { + "indexed": false, + "internalType": "int16[6]", + "name": "_newModifiers", + "type": "int16[6]" + } + ], + "name": "UpdateCollateralModifiers", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "_setId", + "type": "uint256" + }, + { + "components": [ + { + "internalType": "string", + "name": "name", + "type": "string" + }, + { + "internalType": "uint8[]", + "name": "allowedCollaterals", + "type": "uint8[]" + }, + { + "internalType": "uint16[]", + "name": "wearableIds", + "type": "uint16[]" + }, + { + "internalType": "int8[5]", + "name": "traitsBonuses", + "type": "int8[5]" + } + ], + "indexed": false, + "internalType": "struct WearableSet", + "name": "_wearableSet", + "type": "tuple" + } + ], + "name": "UpdateWearableSet", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "_wearableId", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "bool[16]", + "name": "_slotPositions", + "type": "bool[16]" + } + ], + "name": "WearableSlotPositionsSet", + "type": "event" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "_hauntId", + "type": "uint256" + }, + { + "components": [ + { + "internalType": "address", + "name": "collateralType", + "type": "address" + }, + { + "components": [ + { + "internalType": "int16[6]", + "name": "modifiers", + "type": "int16[6]" + }, + { + "internalType": "bytes3", + "name": "primaryColor", + "type": "bytes3" + }, + { + "internalType": "bytes3", + "name": "secondaryColor", + "type": "bytes3" + }, + { + "internalType": "bytes3", + "name": "cheekColor", + "type": "bytes3" + }, + { + "internalType": "uint8", + "name": "svgId", + "type": "uint8" + }, + { + "internalType": "uint8", + "name": "eyeShapeSvgId", + "type": "uint8" + }, + { + "internalType": "uint16", + "name": "conversionRate", + "type": "uint16" + }, + { + "internalType": "bool", + "name": "delisted", + "type": "bool" + } + ], + "internalType": "struct AavegotchiCollateralTypeInfo", + "name": "collateralTypeInfo", + "type": "tuple" + } + ], + "internalType": "struct AavegotchiCollateralTypeIO[]", + "name": "_collateralTypes", + "type": "tuple[]" + } + ], + "name": "addCollateralTypes", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address[]", + "name": "_newGameManagers", + "type": "address[]" + }, + { + "internalType": "uint256[]", + "name": "_limits", + "type": "uint256[]" + } + ], + "name": "addGameManagers", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address[]", + "name": "_newItemManagers", + "type": "address[]" + } + ], + "name": "addItemManagers", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "string", + "name": "name", + "type": "string" + }, + { + "internalType": "string", + "name": "description", + "type": "string" + }, + { + "internalType": "string", + "name": "author", + "type": "string" + }, + { + "internalType": "int8[6]", + "name": "traitModifiers", + "type": "int8[6]" + }, + { + "internalType": "bool[16]", + "name": "slotPositions", + "type": "bool[16]" + }, + { + "internalType": "uint8[]", + "name": "allowedCollaterals", + "type": "uint8[]" + }, + { + "components": [ + { + "internalType": "uint8", + "name": "x", + "type": "uint8" + }, + { + "internalType": "uint8", + "name": "y", + "type": "uint8" + }, + { + "internalType": "uint8", + "name": "width", + "type": "uint8" + }, + { + "internalType": "uint8", + "name": "height", + "type": "uint8" + } + ], + "internalType": "struct Dimensions", + "name": "dimensions", + "type": "tuple" + }, + { + "internalType": "uint256", + "name": "ghstPrice", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "maxQuantity", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "totalQuantity", + "type": "uint256" + }, + { + "internalType": "uint32", + "name": "svgId", + "type": "uint32" + }, + { + "internalType": "uint8", + "name": "rarityScoreModifier", + "type": "uint8" + }, + { + "internalType": "bool", + "name": "canPurchaseWithGhst", + "type": "bool" + }, + { + "internalType": "uint16", + "name": "minLevel", + "type": "uint16" + }, + { + "internalType": "bool", + "name": "canBeTransferred", + "type": "bool" + }, + { + "internalType": "uint8", + "name": "category", + "type": "uint8" + }, + { + "internalType": "int16", + "name": "kinshipBonus", + "type": "int16" + }, + { + "internalType": "uint32", + "name": "experienceBonus", + "type": "uint32" + } + ], + "internalType": "struct ItemType[]", + "name": "_itemTypes", + "type": "tuple[]" + } + ], + "name": "addItemTypes", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "string", + "name": "name", + "type": "string" + }, + { + "internalType": "string", + "name": "description", + "type": "string" + }, + { + "internalType": "string", + "name": "author", + "type": "string" + }, + { + "internalType": "int8[6]", + "name": "traitModifiers", + "type": "int8[6]" + }, + { + "internalType": "bool[16]", + "name": "slotPositions", + "type": "bool[16]" + }, + { + "internalType": "uint8[]", + "name": "allowedCollaterals", + "type": "uint8[]" + }, + { + "components": [ + { + "internalType": "uint8", + "name": "x", + "type": "uint8" + }, + { + "internalType": "uint8", + "name": "y", + "type": "uint8" + }, + { + "internalType": "uint8", + "name": "width", + "type": "uint8" + }, + { + "internalType": "uint8", + "name": "height", + "type": "uint8" + } + ], + "internalType": "struct Dimensions", + "name": "dimensions", + "type": "tuple" + }, + { + "internalType": "uint256", + "name": "ghstPrice", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "maxQuantity", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "totalQuantity", + "type": "uint256" + }, + { + "internalType": "uint32", + "name": "svgId", + "type": "uint32" + }, + { + "internalType": "uint8", + "name": "rarityScoreModifier", + "type": "uint8" + }, + { + "internalType": "bool", + "name": "canPurchaseWithGhst", + "type": "bool" + }, + { + "internalType": "uint16", + "name": "minLevel", + "type": "uint16" + }, + { + "internalType": "bool", + "name": "canBeTransferred", + "type": "bool" + }, + { + "internalType": "uint8", + "name": "category", + "type": "uint8" + }, + { + "internalType": "int16", + "name": "kinshipBonus", + "type": "int16" + }, + { + "internalType": "uint32", + "name": "experienceBonus", + "type": "uint32" + } + ], + "internalType": "struct ItemType[]", + "name": "_itemTypes", + "type": "tuple[]" + }, + { "internalType": "string", "name": "_svg", "type": "string" }, + { + "components": [ + { + "internalType": "bytes32", + "name": "svgType", + "type": "bytes32" + }, + { + "internalType": "uint256[]", + "name": "sizes", + "type": "uint256[]" + } + ], + "internalType": "struct LibSvg.SvgTypeAndSizes[]", + "name": "_typesAndSizes", + "type": "tuple[]" + } + ], + "name": "addItemTypesAndSvgs", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "string", + "name": "name", + "type": "string" + }, + { + "internalType": "uint8[]", + "name": "allowedCollaterals", + "type": "uint8[]" + }, + { + "internalType": "uint16[]", + "name": "wearableIds", + "type": "uint16[]" + }, + { + "internalType": "int8[5]", + "name": "traitsBonuses", + "type": "int8[5]" + } + ], + "internalType": "struct WearableSet[]", + "name": "_wearableSets", + "type": "tuple[]" + } + ], + "name": "addWearableSets", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint24", + "name": "_hauntMaxSize", + "type": "uint24" + }, + { + "internalType": "uint96", + "name": "_portalPrice", + "type": "uint96" + }, + { "internalType": "bytes3", "name": "_bodyColor", "type": "bytes3" } + ], + "name": "createHaunt", + "outputs": [ + { "internalType": "uint256", "name": "hauntId_", "type": "uint256" } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "uint24", + "name": "_hauntMaxSize", + "type": "uint24" + }, + { + "internalType": "uint96", + "name": "_portalPrice", + "type": "uint96" + }, + { + "internalType": "bytes3", + "name": "_bodyColor", + "type": "bytes3" + }, + { + "components": [ + { + "internalType": "address", + "name": "collateralType", + "type": "address" + }, + { + "components": [ + { + "internalType": "int16[6]", + "name": "modifiers", + "type": "int16[6]" + }, + { + "internalType": "bytes3", + "name": "primaryColor", + "type": "bytes3" + }, + { + "internalType": "bytes3", + "name": "secondaryColor", + "type": "bytes3" + }, + { + "internalType": "bytes3", + "name": "cheekColor", + "type": "bytes3" + }, + { + "internalType": "uint8", + "name": "svgId", + "type": "uint8" + }, + { + "internalType": "uint8", + "name": "eyeShapeSvgId", + "type": "uint8" + }, + { + "internalType": "uint16", + "name": "conversionRate", + "type": "uint16" + }, + { + "internalType": "bool", + "name": "delisted", + "type": "bool" + } + ], + "internalType": "struct AavegotchiCollateralTypeInfo", + "name": "collateralTypeInfo", + "type": "tuple" + } + ], + "internalType": "struct AavegotchiCollateralTypeIO[]", + "name": "_collateralTypes", + "type": "tuple[]" + }, + { + "internalType": "string", + "name": "_collateralSvg", + "type": "string" + }, + { + "components": [ + { + "internalType": "bytes32", + "name": "svgType", + "type": "bytes32" + }, + { + "internalType": "uint256[]", + "name": "sizes", + "type": "uint256[]" + } + ], + "internalType": "struct LibSvg.SvgTypeAndSizes[]", + "name": "_collateralTypesAndSizes", + "type": "tuple[]" + }, + { + "internalType": "string", + "name": "_eyeShapeSvg", + "type": "string" + }, + { + "components": [ + { + "internalType": "bytes32", + "name": "svgType", + "type": "bytes32" + }, + { + "internalType": "uint256[]", + "name": "sizes", + "type": "uint256[]" + } + ], + "internalType": "struct LibSvg.SvgTypeAndSizes[]", + "name": "_eyeShapeTypesAndSizes", + "type": "tuple[]" + } + ], + "internalType": "struct DAOFacet.CreateHauntPayload", + "name": "_payload", + "type": "tuple" + } + ], + "name": "createHauntWithPayload", + "outputs": [ + { "internalType": "uint256", "name": "hauntId_", "type": "uint256" } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "_manager", "type": "address" } + ], + "name": "gameManagerBalance", + "outputs": [ + { "internalType": "uint256", "name": "", "type": "uint256" } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "_manager", "type": "address" } + ], + "name": "gameManagerRefreshTime", + "outputs": [ + { "internalType": "uint256", "name": "", "type": "uint256" } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256[]", + "name": "_tokenIds", + "type": "uint256[]" + }, + { + "internalType": "uint256[]", + "name": "_xpValues", + "type": "uint256[]" + } + ], + "name": "grantExperience", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "_manager", "type": "address" } + ], + "name": "isGameManager", + "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "_to", "type": "address" }, + { + "internalType": "uint256[]", + "name": "_itemIds", + "type": "uint256[]" + }, + { + "internalType": "uint256[]", + "name": "_quantities", + "type": "uint256[]" + } + ], + "name": "mintItems", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256[]", + "name": "_tokenIds", + "type": "uint256[]" + }, + { + "internalType": "uint256[]", + "name": "_xpValues", + "type": "uint256[]" + } + ], + "name": "removeExperience", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address[]", + "name": "_gameManagers", + "type": "address[]" + } + ], + "name": "removeGameManagers", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address[]", + "name": "_itemManagers", + "type": "address[]" + } + ], + "name": "removeItemManagers", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "_newDao", "type": "address" }, + { + "internalType": "address", + "name": "_newDaoTreasury", + "type": "address" + } + ], + "name": "setDao", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "_wearableId", + "type": "uint256" + }, + { + "internalType": "int8[6]", + "name": "_traitModifiers", + "type": "int8[6]" + }, + { + "internalType": "uint8", + "name": "_rarityScoreModifier", + "type": "uint8" + } + ], + "name": "setItemTraitModifiersAndRarityModifier", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "_wearableId", + "type": "uint256" + }, + { + "internalType": "bool[16]", + "name": "_slotPositions", + "type": "bool[16]" + } + ], + "name": "setWearableSlotPositions", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_collateralType", + "type": "address" + }, + { + "internalType": "int16[6]", + "name": "_modifiers", + "type": "int16[6]" + } + ], + "name": "updateCollateralModifiers", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256[]", + "name": "_itemIds", + "type": "uint256[]" + }, + { + "internalType": "uint256[]", + "name": "_maxQuantities", + "type": "uint256[]" + } + ], + "name": "updateItemTypeMaxQuantity", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256[]", + "name": "_setIds", + "type": "uint256[]" + }, + { + "components": [ + { + "internalType": "string", + "name": "name", + "type": "string" + }, + { + "internalType": "uint8[]", + "name": "allowedCollaterals", + "type": "uint8[]" + }, + { + "internalType": "uint16[]", + "name": "wearableIds", + "type": "uint16[]" + }, + { + "internalType": "int8[5]", + "name": "traitsBonuses", + "type": "int8[5]" + } + ], + "internalType": "struct WearableSet[]", + "name": "_wearableSets", + "type": "tuple[]" + } + ], + "name": "updateWearableSets", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "listingFeeInWei", + "type": "uint256" + } + ], + "name": "ChangedListingFee", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint256", + "name": "listingId", + "type": "uint256" + }, + { + "indexed": true, + "internalType": "address", + "name": "seller", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "buyer", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "erc1155TokenAddress", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "erc1155TypeId", + "type": "uint256" + }, + { + "indexed": true, + "internalType": "uint256", + "name": "category", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "_quantity", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "priceInWei", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "time", + "type": "uint256" + } + ], + "name": "ERC1155ExecutedListing", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint256", + "name": "listingId", + "type": "uint256" + }, + { + "indexed": true, + "internalType": "address", + "name": "seller", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "erc1155TokenAddress", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "erc1155TypeId", + "type": "uint256" + }, + { + "indexed": true, + "internalType": "uint256", + "name": "category", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "quantity", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "priceInWei", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "time", + "type": "uint256" + } + ], + "name": "ERC1155ListingAdd", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint256", + "name": "listingId", + "type": "uint256" + } + ], + "name": "ERC1155ListingCancelled", + "type": "event" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "_listingId", + "type": "uint256" + } + ], + "name": "cancelERC1155Listing", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256[]", + "name": "_listingIds", + "type": "uint256[]" + } + ], + "name": "cancelERC1155Listings", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "_listingId", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_quantity", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_priceInWei", + "type": "uint256" + } + ], + "name": "executeERC1155Listing", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_erc1155TokenAddress", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_erc1155TypeId", + "type": "uint256" + } + ], + "name": "getERC1155Category", + "outputs": [ + { + "internalType": "uint256", + "name": "category_", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "_listingId", + "type": "uint256" + } + ], + "name": "getERC1155Listing", + "outputs": [ + { + "components": [ + { + "internalType": "uint256", + "name": "listingId", + "type": "uint256" + }, + { + "internalType": "address", + "name": "seller", + "type": "address" + }, + { + "internalType": "address", + "name": "erc1155TokenAddress", + "type": "address" + }, + { + "internalType": "uint256", + "name": "erc1155TypeId", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "category", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "quantity", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "priceInWei", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "timeCreated", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "timeLastPurchased", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "sourceListingId", + "type": "uint256" + }, + { "internalType": "bool", "name": "sold", "type": "bool" }, + { + "internalType": "bool", + "name": "cancelled", + "type": "bool" + } + ], + "internalType": "struct ERC1155Listing", + "name": "listing_", + "type": "tuple" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_erc1155TokenAddress", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_erc1155TypeId", + "type": "uint256" + }, + { "internalType": "address", "name": "_owner", "type": "address" } + ], + "name": "getERC1155ListingFromToken", + "outputs": [ + { + "components": [ + { + "internalType": "uint256", + "name": "listingId", + "type": "uint256" + }, + { + "internalType": "address", + "name": "seller", + "type": "address" + }, + { + "internalType": "address", + "name": "erc1155TokenAddress", + "type": "address" + }, + { + "internalType": "uint256", + "name": "erc1155TypeId", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "category", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "quantity", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "priceInWei", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "timeCreated", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "timeLastPurchased", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "sourceListingId", + "type": "uint256" + }, + { "internalType": "bool", "name": "sold", "type": "bool" }, + { + "internalType": "bool", + "name": "cancelled", + "type": "bool" + } + ], + "internalType": "struct ERC1155Listing", + "name": "listing_", + "type": "tuple" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "_category", + "type": "uint256" + }, + { "internalType": "string", "name": "_sort", "type": "string" }, + { "internalType": "uint256", "name": "_length", "type": "uint256" } + ], + "name": "getERC1155Listings", + "outputs": [ + { + "components": [ + { + "internalType": "uint256", + "name": "listingId", + "type": "uint256" + }, + { + "internalType": "address", + "name": "seller", + "type": "address" + }, + { + "internalType": "address", + "name": "erc1155TokenAddress", + "type": "address" + }, + { + "internalType": "uint256", + "name": "erc1155TypeId", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "category", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "quantity", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "priceInWei", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "timeCreated", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "timeLastPurchased", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "sourceListingId", + "type": "uint256" + }, + { "internalType": "bool", "name": "sold", "type": "bool" }, + { + "internalType": "bool", + "name": "cancelled", + "type": "bool" + } + ], + "internalType": "struct ERC1155Listing[]", + "name": "listings_", + "type": "tuple[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getListingFeeInWei", + "outputs": [ + { "internalType": "uint256", "name": "", "type": "uint256" } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "_owner", "type": "address" }, + { + "internalType": "uint256", + "name": "_category", + "type": "uint256" + }, + { "internalType": "string", "name": "_sort", "type": "string" }, + { "internalType": "uint256", "name": "_length", "type": "uint256" } + ], + "name": "getOwnerERC1155Listings", + "outputs": [ + { + "components": [ + { + "internalType": "uint256", + "name": "listingId", + "type": "uint256" + }, + { + "internalType": "address", + "name": "seller", + "type": "address" + }, + { + "internalType": "address", + "name": "erc1155TokenAddress", + "type": "address" + }, + { + "internalType": "uint256", + "name": "erc1155TypeId", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "category", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "quantity", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "priceInWei", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "timeCreated", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "timeLastPurchased", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "sourceListingId", + "type": "uint256" + }, + { "internalType": "bool", "name": "sold", "type": "bool" }, + { + "internalType": "bool", + "name": "cancelled", + "type": "bool" + } + ], + "internalType": "struct ERC1155Listing[]", + "name": "listings_", + "type": "tuple[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "address", + "name": "erc1155TokenAddress", + "type": "address" + }, + { + "internalType": "uint256", + "name": "erc1155TypeId", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "category", + "type": "uint256" + } + ], + "internalType": "struct ERC1155MarketplaceFacet.Category[]", + "name": "_categories", + "type": "tuple[]" + } + ], + "name": "setERC1155Categories", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_erc1155TokenAddress", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_erc1155TypeId", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_quantity", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_priceInWei", + "type": "uint256" + } + ], + "name": "setERC1155Listing", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "_listingFeeInWei", + "type": "uint256" + } + ], + "name": "setListingFee", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_erc1155TokenAddress", + "type": "address" + }, + { + "internalType": "uint256[]", + "name": "_erc1155TypeIds", + "type": "uint256[]" + }, + { "internalType": "address", "name": "_owner", "type": "address" } + ], + "name": "updateBatchERC1155Listing", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_erc1155TokenAddress", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_erc1155TypeId", + "type": "uint256" + }, + { "internalType": "address", "name": "_owner", "type": "address" } + ], + "name": "updateERC1155Listing", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint256", + "name": "listingId", + "type": "uint256" + }, + { + "indexed": true, + "internalType": "address", + "name": "seller", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "buyer", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "erc721TokenAddress", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "erc721TokenId", + "type": "uint256" + }, + { + "indexed": true, + "internalType": "uint256", + "name": "category", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "priceInWei", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "time", + "type": "uint256" + } + ], + "name": "ERC721ExecutedListing", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint256", + "name": "listingId", + "type": "uint256" + }, + { + "indexed": true, + "internalType": "address", + "name": "seller", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "erc721TokenAddress", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "erc721TokenId", + "type": "uint256" + }, + { + "indexed": true, + "internalType": "uint256", + "name": "category", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "time", + "type": "uint256" + } + ], + "name": "ERC721ListingAdd", + "type": "event" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_erc721TokenAddress", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_erc721TokenId", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_priceInWei", + "type": "uint256" + } + ], + "name": "addERC721Listing", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "_listingId", + "type": "uint256" + } + ], + "name": "cancelERC721Listing", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_erc721TokenAddress", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_erc721TokenId", + "type": "uint256" + } + ], + "name": "cancelERC721ListingByToken", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256[]", + "name": "_listingIds", + "type": "uint256[]" + } + ], + "name": "cancelERC721Listings", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "_listingId", + "type": "uint256" + } + ], + "name": "executeERC721Listing", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "_listingId", + "type": "uint256" + } + ], + "name": "getAavegotchiListing", + "outputs": [ + { + "components": [ + { + "internalType": "uint256", + "name": "listingId", + "type": "uint256" + }, + { + "internalType": "address", + "name": "seller", + "type": "address" + }, + { + "internalType": "address", + "name": "erc721TokenAddress", + "type": "address" + }, + { + "internalType": "uint256", + "name": "erc721TokenId", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "category", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "priceInWei", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "timeCreated", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "timePurchased", + "type": "uint256" + }, + { + "internalType": "bool", + "name": "cancelled", + "type": "bool" + } + ], + "internalType": "struct ERC721Listing", + "name": "listing_", + "type": "tuple" + }, + { + "components": [ + { + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + }, + { + "internalType": "string", + "name": "name", + "type": "string" + }, + { + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "internalType": "uint256", + "name": "randomNumber", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "status", + "type": "uint256" + }, + { + "internalType": "int16[6]", + "name": "numericTraits", + "type": "int16[6]" + }, + { + "internalType": "int16[6]", + "name": "modifiedNumericTraits", + "type": "int16[6]" + }, + { + "internalType": "uint16[16]", + "name": "equippedWearables", + "type": "uint16[16]" + }, + { + "internalType": "address", + "name": "collateral", + "type": "address" + }, + { + "internalType": "address", + "name": "escrow", + "type": "address" + }, + { + "internalType": "uint256", + "name": "stakedAmount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "minimumStake", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "kinship", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "lastInteracted", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "experience", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "toNextLevel", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "usedSkillPoints", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "level", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "hauntId", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "baseRarityScore", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "modifiedRarityScore", + "type": "uint256" + }, + { + "internalType": "bool", + "name": "locked", + "type": "bool" + }, + { + "components": [ + { + "internalType": "uint256", + "name": "balance", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "itemId", + "type": "uint256" + }, + { + "components": [ + { + "internalType": "string", + "name": "name", + "type": "string" + }, + { + "internalType": "string", + "name": "description", + "type": "string" + }, + { + "internalType": "string", + "name": "author", + "type": "string" + }, + { + "internalType": "int8[6]", + "name": "traitModifiers", + "type": "int8[6]" + }, + { + "internalType": "bool[16]", + "name": "slotPositions", + "type": "bool[16]" + }, + { + "internalType": "uint8[]", + "name": "allowedCollaterals", + "type": "uint8[]" + }, + { + "components": [ + { + "internalType": "uint8", + "name": "x", + "type": "uint8" + }, + { + "internalType": "uint8", + "name": "y", + "type": "uint8" + }, + { + "internalType": "uint8", + "name": "width", + "type": "uint8" + }, + { + "internalType": "uint8", + "name": "height", + "type": "uint8" + } + ], + "internalType": "struct Dimensions", + "name": "dimensions", + "type": "tuple" + }, + { + "internalType": "uint256", + "name": "ghstPrice", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "maxQuantity", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "totalQuantity", + "type": "uint256" + }, + { + "internalType": "uint32", + "name": "svgId", + "type": "uint32" + }, + { + "internalType": "uint8", + "name": "rarityScoreModifier", + "type": "uint8" + }, + { + "internalType": "bool", + "name": "canPurchaseWithGhst", + "type": "bool" + }, + { + "internalType": "uint16", + "name": "minLevel", + "type": "uint16" + }, + { + "internalType": "bool", + "name": "canBeTransferred", + "type": "bool" + }, + { + "internalType": "uint8", + "name": "category", + "type": "uint8" + }, + { + "internalType": "int16", + "name": "kinshipBonus", + "type": "int16" + }, + { + "internalType": "uint32", + "name": "experienceBonus", + "type": "uint32" + } + ], + "internalType": "struct ItemType", + "name": "itemType", + "type": "tuple" + } + ], + "internalType": "struct ItemTypeIO[]", + "name": "items", + "type": "tuple[]" + } + ], + "internalType": "struct AavegotchiInfo", + "name": "aavegotchiInfo_", + "type": "tuple" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "_category", + "type": "uint256" + }, + { "internalType": "string", "name": "_sort", "type": "string" }, + { "internalType": "uint256", "name": "_length", "type": "uint256" } + ], + "name": "getAavegotchiListings", + "outputs": [ + { + "components": [ + { + "components": [ + { + "internalType": "uint256", + "name": "listingId", + "type": "uint256" + }, + { + "internalType": "address", + "name": "seller", + "type": "address" + }, + { + "internalType": "address", + "name": "erc721TokenAddress", + "type": "address" + }, + { + "internalType": "uint256", + "name": "erc721TokenId", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "category", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "priceInWei", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "timeCreated", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "timePurchased", + "type": "uint256" + }, + { + "internalType": "bool", + "name": "cancelled", + "type": "bool" + } + ], + "internalType": "struct ERC721Listing", + "name": "listing_", + "type": "tuple" + }, + { + "components": [ + { + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + }, + { + "internalType": "string", + "name": "name", + "type": "string" + }, + { + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "internalType": "uint256", + "name": "randomNumber", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "status", + "type": "uint256" + }, + { + "internalType": "int16[6]", + "name": "numericTraits", + "type": "int16[6]" + }, + { + "internalType": "int16[6]", + "name": "modifiedNumericTraits", + "type": "int16[6]" + }, + { + "internalType": "uint16[16]", + "name": "equippedWearables", + "type": "uint16[16]" + }, + { + "internalType": "address", + "name": "collateral", + "type": "address" + }, + { + "internalType": "address", + "name": "escrow", + "type": "address" + }, + { + "internalType": "uint256", + "name": "stakedAmount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "minimumStake", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "kinship", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "lastInteracted", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "experience", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "toNextLevel", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "usedSkillPoints", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "level", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "hauntId", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "baseRarityScore", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "modifiedRarityScore", + "type": "uint256" + }, + { + "internalType": "bool", + "name": "locked", + "type": "bool" + }, + { + "components": [ + { + "internalType": "uint256", + "name": "balance", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "itemId", + "type": "uint256" + }, + { + "components": [ + { + "internalType": "string", + "name": "name", + "type": "string" + }, + { + "internalType": "string", + "name": "description", + "type": "string" + }, + { + "internalType": "string", + "name": "author", + "type": "string" + }, + { + "internalType": "int8[6]", + "name": "traitModifiers", + "type": "int8[6]" + }, + { + "internalType": "bool[16]", + "name": "slotPositions", + "type": "bool[16]" + }, + { + "internalType": "uint8[]", + "name": "allowedCollaterals", + "type": "uint8[]" + }, + { + "components": [ + { + "internalType": "uint8", + "name": "x", + "type": "uint8" + }, + { + "internalType": "uint8", + "name": "y", + "type": "uint8" + }, + { + "internalType": "uint8", + "name": "width", + "type": "uint8" + }, + { + "internalType": "uint8", + "name": "height", + "type": "uint8" + } + ], + "internalType": "struct Dimensions", + "name": "dimensions", + "type": "tuple" + }, + { + "internalType": "uint256", + "name": "ghstPrice", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "maxQuantity", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "totalQuantity", + "type": "uint256" + }, + { + "internalType": "uint32", + "name": "svgId", + "type": "uint32" + }, + { + "internalType": "uint8", + "name": "rarityScoreModifier", + "type": "uint8" + }, + { + "internalType": "bool", + "name": "canPurchaseWithGhst", + "type": "bool" + }, + { + "internalType": "uint16", + "name": "minLevel", + "type": "uint16" + }, + { + "internalType": "bool", + "name": "canBeTransferred", + "type": "bool" + }, + { + "internalType": "uint8", + "name": "category", + "type": "uint8" + }, + { + "internalType": "int16", + "name": "kinshipBonus", + "type": "int16" + }, + { + "internalType": "uint32", + "name": "experienceBonus", + "type": "uint32" + } + ], + "internalType": "struct ItemType", + "name": "itemType", + "type": "tuple" + } + ], + "internalType": "struct ItemTypeIO[]", + "name": "items", + "type": "tuple[]" + } + ], + "internalType": "struct AavegotchiInfo", + "name": "aavegotchiInfo_", + "type": "tuple" + } + ], + "internalType": "struct ERC721MarketplaceFacet.AavegotchiListing[]", + "name": "listings_", + "type": "tuple[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_erc721TokenAddress", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_erc721TokenId", + "type": "uint256" + } + ], + "name": "getERC721Category", + "outputs": [ + { + "internalType": "uint256", + "name": "category_", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "_listingId", + "type": "uint256" + } + ], + "name": "getERC721Listing", + "outputs": [ + { + "components": [ + { + "internalType": "uint256", + "name": "listingId", + "type": "uint256" + }, + { + "internalType": "address", + "name": "seller", + "type": "address" + }, + { + "internalType": "address", + "name": "erc721TokenAddress", + "type": "address" + }, + { + "internalType": "uint256", + "name": "erc721TokenId", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "category", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "priceInWei", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "timeCreated", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "timePurchased", + "type": "uint256" + }, + { + "internalType": "bool", + "name": "cancelled", + "type": "bool" + } + ], + "internalType": "struct ERC721Listing", + "name": "listing_", + "type": "tuple" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_erc721TokenAddress", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_erc721TokenId", + "type": "uint256" + }, + { "internalType": "address", "name": "_owner", "type": "address" } + ], + "name": "getERC721ListingFromToken", + "outputs": [ + { + "components": [ + { + "internalType": "uint256", + "name": "listingId", + "type": "uint256" + }, + { + "internalType": "address", + "name": "seller", + "type": "address" + }, + { + "internalType": "address", + "name": "erc721TokenAddress", + "type": "address" + }, + { + "internalType": "uint256", + "name": "erc721TokenId", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "category", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "priceInWei", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "timeCreated", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "timePurchased", + "type": "uint256" + }, + { + "internalType": "bool", + "name": "cancelled", + "type": "bool" + } + ], + "internalType": "struct ERC721Listing", + "name": "listing_", + "type": "tuple" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "_category", + "type": "uint256" + }, + { "internalType": "string", "name": "_sort", "type": "string" }, + { "internalType": "uint256", "name": "_length", "type": "uint256" } + ], + "name": "getERC721Listings", + "outputs": [ + { + "components": [ + { + "internalType": "uint256", + "name": "listingId", + "type": "uint256" + }, + { + "internalType": "address", + "name": "seller", + "type": "address" + }, + { + "internalType": "address", + "name": "erc721TokenAddress", + "type": "address" + }, + { + "internalType": "uint256", + "name": "erc721TokenId", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "category", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "priceInWei", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "timeCreated", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "timePurchased", + "type": "uint256" + }, + { + "internalType": "bool", + "name": "cancelled", + "type": "bool" + } + ], + "internalType": "struct ERC721Listing[]", + "name": "listings_", + "type": "tuple[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "_owner", "type": "address" }, + { + "internalType": "uint256", + "name": "_category", + "type": "uint256" + }, + { "internalType": "string", "name": "_sort", "type": "string" }, + { "internalType": "uint256", "name": "_length", "type": "uint256" } + ], + "name": "getOwnerAavegotchiListings", + "outputs": [ + { + "components": [ + { + "components": [ + { + "internalType": "uint256", + "name": "listingId", + "type": "uint256" + }, + { + "internalType": "address", + "name": "seller", + "type": "address" + }, + { + "internalType": "address", + "name": "erc721TokenAddress", + "type": "address" + }, + { + "internalType": "uint256", + "name": "erc721TokenId", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "category", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "priceInWei", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "timeCreated", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "timePurchased", + "type": "uint256" + }, + { + "internalType": "bool", + "name": "cancelled", + "type": "bool" + } + ], + "internalType": "struct ERC721Listing", + "name": "listing_", + "type": "tuple" + }, + { + "components": [ + { + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + }, + { + "internalType": "string", + "name": "name", + "type": "string" + }, + { + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "internalType": "uint256", + "name": "randomNumber", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "status", + "type": "uint256" + }, + { + "internalType": "int16[6]", + "name": "numericTraits", + "type": "int16[6]" + }, + { + "internalType": "int16[6]", + "name": "modifiedNumericTraits", + "type": "int16[6]" + }, + { + "internalType": "uint16[16]", + "name": "equippedWearables", + "type": "uint16[16]" + }, + { + "internalType": "address", + "name": "collateral", + "type": "address" + }, + { + "internalType": "address", + "name": "escrow", + "type": "address" + }, + { + "internalType": "uint256", + "name": "stakedAmount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "minimumStake", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "kinship", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "lastInteracted", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "experience", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "toNextLevel", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "usedSkillPoints", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "level", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "hauntId", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "baseRarityScore", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "modifiedRarityScore", + "type": "uint256" + }, + { + "internalType": "bool", + "name": "locked", + "type": "bool" + }, + { + "components": [ + { + "internalType": "uint256", + "name": "balance", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "itemId", + "type": "uint256" + }, + { + "components": [ + { + "internalType": "string", + "name": "name", + "type": "string" + }, + { + "internalType": "string", + "name": "description", + "type": "string" + }, + { + "internalType": "string", + "name": "author", + "type": "string" + }, + { + "internalType": "int8[6]", + "name": "traitModifiers", + "type": "int8[6]" + }, + { + "internalType": "bool[16]", + "name": "slotPositions", + "type": "bool[16]" + }, + { + "internalType": "uint8[]", + "name": "allowedCollaterals", + "type": "uint8[]" + }, + { + "components": [ + { + "internalType": "uint8", + "name": "x", + "type": "uint8" + }, + { + "internalType": "uint8", + "name": "y", + "type": "uint8" + }, + { + "internalType": "uint8", + "name": "width", + "type": "uint8" + }, + { + "internalType": "uint8", + "name": "height", + "type": "uint8" + } + ], + "internalType": "struct Dimensions", + "name": "dimensions", + "type": "tuple" + }, + { + "internalType": "uint256", + "name": "ghstPrice", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "maxQuantity", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "totalQuantity", + "type": "uint256" + }, + { + "internalType": "uint32", + "name": "svgId", + "type": "uint32" + }, + { + "internalType": "uint8", + "name": "rarityScoreModifier", + "type": "uint8" + }, + { + "internalType": "bool", + "name": "canPurchaseWithGhst", + "type": "bool" + }, + { + "internalType": "uint16", + "name": "minLevel", + "type": "uint16" + }, + { + "internalType": "bool", + "name": "canBeTransferred", + "type": "bool" + }, + { + "internalType": "uint8", + "name": "category", + "type": "uint8" + }, + { + "internalType": "int16", + "name": "kinshipBonus", + "type": "int16" + }, + { + "internalType": "uint32", + "name": "experienceBonus", + "type": "uint32" + } + ], + "internalType": "struct ItemType", + "name": "itemType", + "type": "tuple" + } + ], + "internalType": "struct ItemTypeIO[]", + "name": "items", + "type": "tuple[]" + } + ], + "internalType": "struct AavegotchiInfo", + "name": "aavegotchiInfo_", + "type": "tuple" + } + ], + "internalType": "struct ERC721MarketplaceFacet.AavegotchiListing[]", + "name": "listings_", + "type": "tuple[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "_owner", "type": "address" }, + { + "internalType": "uint256", + "name": "_category", + "type": "uint256" + }, + { "internalType": "string", "name": "_sort", "type": "string" }, + { "internalType": "uint256", "name": "_length", "type": "uint256" } + ], + "name": "getOwnerERC721Listings", + "outputs": [ + { + "components": [ + { + "internalType": "uint256", + "name": "listingId", + "type": "uint256" + }, + { + "internalType": "address", + "name": "seller", + "type": "address" + }, + { + "internalType": "address", + "name": "erc721TokenAddress", + "type": "address" + }, + { + "internalType": "uint256", + "name": "erc721TokenId", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "category", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "priceInWei", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "timeCreated", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "timePurchased", + "type": "uint256" + }, + { + "internalType": "bool", + "name": "cancelled", + "type": "bool" + } + ], + "internalType": "struct ERC721Listing[]", + "name": "listings_", + "type": "tuple[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_erc721TokenAddress", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_erc721TokenId", + "type": "uint256" + }, + { "internalType": "address", "name": "_owner", "type": "address" } + ], + "name": "updateERC721Listing", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint256", + "name": "_tokenId", + "type": "uint256" + }, + { + "indexed": true, + "internalType": "address", + "name": "_erc20Contract", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "_from", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "_to", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "_depositAmount", + "type": "uint256" + } + ], + "name": "Erc20Deposited", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint256", + "name": "_tokenId", + "type": "uint256" + }, + { + "indexed": true, + "internalType": "address", + "name": "_erc20Contract", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "_from", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "_to", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "_transferAmount", + "type": "uint256" + } + ], + "name": "TransferEscrow", + "type": "event" + }, + { + "inputs": [ + { + "internalType": "uint256[]", + "name": "_tokenIds", + "type": "uint256[]" + }, + { + "internalType": "address[]", + "name": "_erc20Contracts", + "type": "address[]" + }, + { + "internalType": "uint256[]", + "name": "_values", + "type": "uint256[]" + } + ], + "name": "batchDepositERC20", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256[]", + "name": "_tokenIds", + "type": "uint256[]" + }, + { + "internalType": "uint256[]", + "name": "_values", + "type": "uint256[]" + } + ], + "name": "batchDepositGHST", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "_tokenId", + "type": "uint256" + }, + { + "internalType": "address", + "name": "_erc20Contract", + "type": "address" + }, + { "internalType": "uint256", "name": "_value", "type": "uint256" } + ], + "name": "depositERC20", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "_tokenId", + "type": "uint256" + }, + { + "internalType": "address", + "name": "_erc20Contract", + "type": "address" + } + ], + "name": "escrowBalance", + "outputs": [ + { "internalType": "uint256", "name": "", "type": "uint256" } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "_tokenId", + "type": "uint256" + }, + { + "internalType": "address", + "name": "_erc20Contract", + "type": "address" + }, + { + "internalType": "address", + "name": "_recipient", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_transferAmount", + "type": "uint256" + } + ], + "name": "transferEscrow", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint256", + "name": "_tokenId", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint16[16]", + "name": "_oldWearables", + "type": "uint16[16]" + }, + { + "indexed": false, + "internalType": "uint16[16]", + "name": "_newWearables", + "type": "uint16[16]" + } + ], + "name": "EquipWearables", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "_toContract", + "type": "address" + }, + { + "indexed": true, + "internalType": "uint256", + "name": "_toTokenId", + "type": "uint256" + }, + { + "indexed": true, + "internalType": "uint256", + "name": "_tokenTypeId", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "_value", + "type": "uint256" + } + ], + "name": "TransferToParent", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint256", + "name": "_tokenId", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256[]", + "name": "_itemIds", + "type": "uint256[]" + }, + { + "indexed": false, + "internalType": "uint256[]", + "name": "_quantities", + "type": "uint256[]" + } + ], + "name": "UseConsumables", + "type": "event" + }, + { + "inputs": [ + { "internalType": "address", "name": "_owner", "type": "address" }, + { "internalType": "uint256", "name": "_id", "type": "uint256" } + ], + "name": "balanceOf", + "outputs": [ + { "internalType": "uint256", "name": "bal_", "type": "uint256" } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address[]", + "name": "_owners", + "type": "address[]" + }, + { "internalType": "uint256[]", "name": "_ids", "type": "uint256[]" } + ], + "name": "balanceOfBatch", + "outputs": [ + { "internalType": "uint256[]", "name": "bals", "type": "uint256[]" } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_tokenContract", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_tokenId", + "type": "uint256" + }, + { "internalType": "uint256", "name": "_id", "type": "uint256" } + ], + "name": "balanceOfToken", + "outputs": [ + { "internalType": "uint256", "name": "value", "type": "uint256" } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "_tokenId", + "type": "uint256" + }, + { + "internalType": "uint16[16]", + "name": "_wearablesToEquip", + "type": "uint16[16]" + } + ], + "name": "equipWearables", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "uint256", "name": "_tokenId", "type": "uint256" } + ], + "name": "equippedWearables", + "outputs": [ + { + "internalType": "uint16[16]", + "name": "wearableIds_", + "type": "uint16[16]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256[]", + "name": "_wearableIds", + "type": "uint256[]" + } + ], + "name": "findWearableSets", + "outputs": [ + { + "internalType": "uint256[]", + "name": "wearableSetIds_", + "type": "uint256[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "uint256", "name": "_itemId", "type": "uint256" } + ], + "name": "getItemType", + "outputs": [ + { + "components": [ + { + "internalType": "string", + "name": "name", + "type": "string" + }, + { + "internalType": "string", + "name": "description", + "type": "string" + }, + { + "internalType": "string", + "name": "author", + "type": "string" + }, + { + "internalType": "int8[6]", + "name": "traitModifiers", + "type": "int8[6]" + }, + { + "internalType": "bool[16]", + "name": "slotPositions", + "type": "bool[16]" + }, + { + "internalType": "uint8[]", + "name": "allowedCollaterals", + "type": "uint8[]" + }, + { + "components": [ + { + "internalType": "uint8", + "name": "x", + "type": "uint8" + }, + { + "internalType": "uint8", + "name": "y", + "type": "uint8" + }, + { + "internalType": "uint8", + "name": "width", + "type": "uint8" + }, + { + "internalType": "uint8", + "name": "height", + "type": "uint8" + } + ], + "internalType": "struct Dimensions", + "name": "dimensions", + "type": "tuple" + }, + { + "internalType": "uint256", + "name": "ghstPrice", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "maxQuantity", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "totalQuantity", + "type": "uint256" + }, + { + "internalType": "uint32", + "name": "svgId", + "type": "uint32" + }, + { + "internalType": "uint8", + "name": "rarityScoreModifier", + "type": "uint8" + }, + { + "internalType": "bool", + "name": "canPurchaseWithGhst", + "type": "bool" + }, + { + "internalType": "uint16", + "name": "minLevel", + "type": "uint16" + }, + { + "internalType": "bool", + "name": "canBeTransferred", + "type": "bool" + }, + { + "internalType": "uint8", + "name": "category", + "type": "uint8" + }, + { + "internalType": "int16", + "name": "kinshipBonus", + "type": "int16" + }, + { + "internalType": "uint32", + "name": "experienceBonus", + "type": "uint32" + } + ], + "internalType": "struct ItemType", + "name": "itemType_", + "type": "tuple" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256[]", + "name": "_itemIds", + "type": "uint256[]" + } + ], + "name": "getItemTypes", + "outputs": [ + { + "components": [ + { + "internalType": "string", + "name": "name", + "type": "string" + }, + { + "internalType": "string", + "name": "description", + "type": "string" + }, + { + "internalType": "string", + "name": "author", + "type": "string" + }, + { + "internalType": "int8[6]", + "name": "traitModifiers", + "type": "int8[6]" + }, + { + "internalType": "bool[16]", + "name": "slotPositions", + "type": "bool[16]" + }, + { + "internalType": "uint8[]", + "name": "allowedCollaterals", + "type": "uint8[]" + }, + { + "components": [ + { + "internalType": "uint8", + "name": "x", + "type": "uint8" + }, + { + "internalType": "uint8", + "name": "y", + "type": "uint8" + }, + { + "internalType": "uint8", + "name": "width", + "type": "uint8" + }, + { + "internalType": "uint8", + "name": "height", + "type": "uint8" + } + ], + "internalType": "struct Dimensions", + "name": "dimensions", + "type": "tuple" + }, + { + "internalType": "uint256", + "name": "ghstPrice", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "maxQuantity", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "totalQuantity", + "type": "uint256" + }, + { + "internalType": "uint32", + "name": "svgId", + "type": "uint32" + }, + { + "internalType": "uint8", + "name": "rarityScoreModifier", + "type": "uint8" + }, + { + "internalType": "bool", + "name": "canPurchaseWithGhst", + "type": "bool" + }, + { + "internalType": "uint16", + "name": "minLevel", + "type": "uint16" + }, + { + "internalType": "bool", + "name": "canBeTransferred", + "type": "bool" + }, + { + "internalType": "uint8", + "name": "category", + "type": "uint8" + }, + { + "internalType": "int16", + "name": "kinshipBonus", + "type": "int16" + }, + { + "internalType": "uint32", + "name": "experienceBonus", + "type": "uint32" + } + ], + "internalType": "struct ItemType[]", + "name": "itemTypes_", + "type": "tuple[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "uint256", "name": "_index", "type": "uint256" } + ], + "name": "getWearableSet", + "outputs": [ + { + "components": [ + { + "internalType": "string", + "name": "name", + "type": "string" + }, + { + "internalType": "uint8[]", + "name": "allowedCollaterals", + "type": "uint8[]" + }, + { + "internalType": "uint16[]", + "name": "wearableIds", + "type": "uint16[]" + }, + { + "internalType": "int8[5]", + "name": "traitsBonuses", + "type": "int8[5]" + } + ], + "internalType": "struct WearableSet", + "name": "wearableSet_", + "type": "tuple" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getWearableSets", + "outputs": [ + { + "components": [ + { + "internalType": "string", + "name": "name", + "type": "string" + }, + { + "internalType": "uint8[]", + "name": "allowedCollaterals", + "type": "uint8[]" + }, + { + "internalType": "uint16[]", + "name": "wearableIds", + "type": "uint16[]" + }, + { + "internalType": "int8[5]", + "name": "traitsBonuses", + "type": "int8[5]" + } + ], + "internalType": "struct WearableSet[]", + "name": "wearableSets_", + "type": "tuple[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "_account", "type": "address" } + ], + "name": "itemBalances", + "outputs": [ + { + "components": [ + { + "internalType": "uint256", + "name": "itemId", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "balance", + "type": "uint256" + } + ], + "internalType": "struct ItemsFacet.ItemIdIO[]", + "name": "bals_", + "type": "tuple[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_tokenContract", + "type": "address" + }, + { "internalType": "uint256", "name": "_tokenId", "type": "uint256" } + ], + "name": "itemBalancesOfToken", + "outputs": [ + { + "components": [ + { + "internalType": "uint256", + "name": "itemId", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "balance", + "type": "uint256" + } + ], + "internalType": "struct ItemsFacet.ItemIdIO[]", + "name": "bals_", + "type": "tuple[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_tokenContract", + "type": "address" + }, + { "internalType": "uint256", "name": "_tokenId", "type": "uint256" } + ], + "name": "itemBalancesOfTokenWithTypes", + "outputs": [ + { + "components": [ + { + "internalType": "uint256", + "name": "balance", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "itemId", + "type": "uint256" + }, + { + "components": [ + { + "internalType": "string", + "name": "name", + "type": "string" + }, + { + "internalType": "string", + "name": "description", + "type": "string" + }, + { + "internalType": "string", + "name": "author", + "type": "string" + }, + { + "internalType": "int8[6]", + "name": "traitModifiers", + "type": "int8[6]" + }, + { + "internalType": "bool[16]", + "name": "slotPositions", + "type": "bool[16]" + }, + { + "internalType": "uint8[]", + "name": "allowedCollaterals", + "type": "uint8[]" + }, + { + "components": [ + { + "internalType": "uint8", + "name": "x", + "type": "uint8" + }, + { + "internalType": "uint8", + "name": "y", + "type": "uint8" + }, + { + "internalType": "uint8", + "name": "width", + "type": "uint8" + }, + { + "internalType": "uint8", + "name": "height", + "type": "uint8" + } + ], + "internalType": "struct Dimensions", + "name": "dimensions", + "type": "tuple" + }, + { + "internalType": "uint256", + "name": "ghstPrice", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "maxQuantity", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "totalQuantity", + "type": "uint256" + }, + { + "internalType": "uint32", + "name": "svgId", + "type": "uint32" + }, + { + "internalType": "uint8", + "name": "rarityScoreModifier", + "type": "uint8" + }, + { + "internalType": "bool", + "name": "canPurchaseWithGhst", + "type": "bool" + }, + { + "internalType": "uint16", + "name": "minLevel", + "type": "uint16" + }, + { + "internalType": "bool", + "name": "canBeTransferred", + "type": "bool" + }, + { + "internalType": "uint8", + "name": "category", + "type": "uint8" + }, + { + "internalType": "int16", + "name": "kinshipBonus", + "type": "int16" + }, + { + "internalType": "uint32", + "name": "experienceBonus", + "type": "uint32" + } + ], + "internalType": "struct ItemType", + "name": "itemType", + "type": "tuple" + } + ], + "internalType": "struct ItemTypeIO[]", + "name": "itemBalancesOfTokenWithTypes_", + "type": "tuple[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "_owner", "type": "address" } + ], + "name": "itemBalancesWithTypes", + "outputs": [ + { + "components": [ + { + "internalType": "uint256", + "name": "balance", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "itemId", + "type": "uint256" + }, + { + "components": [ + { + "internalType": "string", + "name": "name", + "type": "string" + }, + { + "internalType": "string", + "name": "description", + "type": "string" + }, + { + "internalType": "string", + "name": "author", + "type": "string" + }, + { + "internalType": "int8[6]", + "name": "traitModifiers", + "type": "int8[6]" + }, + { + "internalType": "bool[16]", + "name": "slotPositions", + "type": "bool[16]" + }, + { + "internalType": "uint8[]", + "name": "allowedCollaterals", + "type": "uint8[]" + }, + { + "components": [ + { + "internalType": "uint8", + "name": "x", + "type": "uint8" + }, + { + "internalType": "uint8", + "name": "y", + "type": "uint8" + }, + { + "internalType": "uint8", + "name": "width", + "type": "uint8" + }, + { + "internalType": "uint8", + "name": "height", + "type": "uint8" + } + ], + "internalType": "struct Dimensions", + "name": "dimensions", + "type": "tuple" + }, + { + "internalType": "uint256", + "name": "ghstPrice", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "maxQuantity", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "totalQuantity", + "type": "uint256" + }, + { + "internalType": "uint32", + "name": "svgId", + "type": "uint32" + }, + { + "internalType": "uint8", + "name": "rarityScoreModifier", + "type": "uint8" + }, + { + "internalType": "bool", + "name": "canPurchaseWithGhst", + "type": "bool" + }, + { + "internalType": "uint16", + "name": "minLevel", + "type": "uint16" + }, + { + "internalType": "bool", + "name": "canBeTransferred", + "type": "bool" + }, + { + "internalType": "uint8", + "name": "category", + "type": "uint8" + }, + { + "internalType": "int16", + "name": "kinshipBonus", + "type": "int16" + }, + { + "internalType": "uint32", + "name": "experienceBonus", + "type": "uint32" + } + ], + "internalType": "struct ItemType", + "name": "itemType", + "type": "tuple" + } + ], + "internalType": "struct ItemTypeIO[]", + "name": "output_", + "type": "tuple[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "string", "name": "_value", "type": "string" } + ], + "name": "setBaseURI", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "totalWearableSets", + "outputs": [ + { "internalType": "uint256", "name": "", "type": "uint256" } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "uint256", "name": "_id", "type": "uint256" } + ], + "name": "uri", + "outputs": [{ "internalType": "string", "name": "", "type": "string" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "_tokenId", + "type": "uint256" + }, + { + "internalType": "uint256[]", + "name": "_itemIds", + "type": "uint256[]" + }, + { + "internalType": "uint256[]", + "name": "_quantities", + "type": "uint256[]" + } + ], + "name": "useConsumables", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_fromContract", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_fromTokenId", + "type": "uint256" + }, + { + "internalType": "address", + "name": "_toContract", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_toTokenId", + "type": "uint256" + }, + { + "internalType": "uint256[]", + "name": "_ids", + "type": "uint256[]" + }, + { + "internalType": "uint256[]", + "name": "_values", + "type": "uint256[]" + } + ], + "name": "batchTransferAsChild", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_fromContract", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_fromTokenId", + "type": "uint256" + }, + { "internalType": "address", "name": "_to", "type": "address" }, + { + "internalType": "uint256[]", + "name": "_ids", + "type": "uint256[]" + }, + { + "internalType": "uint256[]", + "name": "_values", + "type": "uint256[]" + } + ], + "name": "batchTransferFromParent", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "_from", "type": "address" }, + { + "internalType": "address", + "name": "_toContract", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_toTokenId", + "type": "uint256" + }, + { + "internalType": "uint256[]", + "name": "_ids", + "type": "uint256[]" + }, + { + "internalType": "uint256[]", + "name": "_values", + "type": "uint256[]" + } + ], + "name": "batchTransferToParent", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "_to", "type": "address" }, + { + "internalType": "uint256[]", + "name": "_itemIds", + "type": "uint256[]" + }, + { + "internalType": "uint256[]", + "name": "_values", + "type": "uint256[]" + } + ], + "name": "extractItemsFromDiamond", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "_to", "type": "address" }, + { + "internalType": "uint256", + "name": "_tokenId", + "type": "uint256" + }, + { + "internalType": "uint256[]", + "name": "_itemIds", + "type": "uint256[]" + }, + { + "internalType": "uint256[]", + "name": "_values", + "type": "uint256[]" + } + ], + "name": "extractItemsFromSacrificedGotchi", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "", "type": "address" }, + { "internalType": "address", "name": "", "type": "address" }, + { "internalType": "uint256[]", "name": "", "type": "uint256[]" }, + { "internalType": "uint256[]", "name": "", "type": "uint256[]" }, + { "internalType": "bytes", "name": "", "type": "bytes" } + ], + "name": "onERC1155BatchReceived", + "outputs": [{ "internalType": "bytes4", "name": "", "type": "bytes4" }], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "", "type": "address" }, + { "internalType": "address", "name": "", "type": "address" }, + { "internalType": "uint256", "name": "", "type": "uint256" }, + { "internalType": "uint256", "name": "", "type": "uint256" }, + { "internalType": "bytes", "name": "", "type": "bytes" } + ], + "name": "onERC1155Received", + "outputs": [{ "internalType": "bytes4", "name": "", "type": "bytes4" }], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "_from", "type": "address" }, + { "internalType": "address", "name": "_to", "type": "address" }, + { + "internalType": "uint256[]", + "name": "_ids", + "type": "uint256[]" + }, + { + "internalType": "uint256[]", + "name": "_values", + "type": "uint256[]" + }, + { "internalType": "bytes", "name": "_data", "type": "bytes" } + ], + "name": "safeBatchTransferFrom", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "_from", "type": "address" }, + { "internalType": "address", "name": "_to", "type": "address" }, + { "internalType": "uint256", "name": "_id", "type": "uint256" }, + { "internalType": "uint256", "name": "_value", "type": "uint256" }, + { "internalType": "bytes", "name": "_data", "type": "bytes" } + ], + "name": "safeTransferFrom", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_fromContract", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_fromTokenId", + "type": "uint256" + }, + { + "internalType": "address", + "name": "_toContract", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_toTokenId", + "type": "uint256" + }, + { "internalType": "uint256", "name": "_id", "type": "uint256" }, + { "internalType": "uint256", "name": "_value", "type": "uint256" } + ], + "name": "transferAsChild", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_fromContract", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_fromTokenId", + "type": "uint256" + }, + { "internalType": "address", "name": "_to", "type": "address" }, + { "internalType": "uint256", "name": "_id", "type": "uint256" }, + { "internalType": "uint256", "name": "_value", "type": "uint256" } + ], + "name": "transferFromParent", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "_from", "type": "address" }, + { + "internalType": "address", + "name": "_toContract", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_toTokenId", + "type": "uint256" + }, + { "internalType": "uint256", "name": "_id", "type": "uint256" }, + { "internalType": "uint256", "name": "_value", "type": "uint256" } + ], + "name": "transferToParent", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "userAddress", + "type": "address" + }, + { + "indexed": false, + "internalType": "address payable", + "name": "relayerAddress", + "type": "address" + }, + { + "indexed": false, + "internalType": "bytes", + "name": "functionSignature", + "type": "bytes" + } + ], + "name": "MetaTransactionExecuted", + "type": "event" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "userAddress", + "type": "address" + }, + { + "internalType": "bytes", + "name": "functionSignature", + "type": "bytes" + }, + { "internalType": "bytes32", "name": "sigR", "type": "bytes32" }, + { "internalType": "bytes32", "name": "sigS", "type": "bytes32" }, + { "internalType": "uint8", "name": "sigV", "type": "uint8" } + ], + "name": "executeMetaTransaction", + "outputs": [{ "internalType": "bytes", "name": "", "type": "bytes" }], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "user", "type": "address" } + ], + "name": "getNonce", + "outputs": [ + { "internalType": "uint256", "name": "nonce_", "type": "uint256" } + ], + "stateMutability": "view", + "type": "function" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "_from", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "_to", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "_tokenId", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "_numAavegotchisToPurchase", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "_totalPrice", + "type": "uint256" + } + ], + "name": "BuyPortals", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "_from", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "_to", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "_tokenId", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "_numAavegotchisToPurchase", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "_totalPrice", + "type": "uint256" + } + ], + "name": "Xingyun", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "_from", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "_to", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "_tokenId", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "_numAavegotchisToPurchase", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "_hauntId", + "type": "uint256" + } + ], + "name": "MintPortals", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "_buyer", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "_to", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256[]", + "name": "_itemIds", + "type": "uint256[]" + }, + { + "indexed": false, + "internalType": "uint256[]", + "name": "_quantities", + "type": "uint256[]" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "_totalPrice", + "type": "uint256" + } + ], + "name": "PurchaseItemsWithGhst", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "_buyer", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "_to", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256[]", + "name": "_itemIds", + "type": "uint256[]" + }, + { + "indexed": false, + "internalType": "uint256[]", + "name": "_quantities", + "type": "uint256[]" + } + ], + "name": "PurchaseItemsWithVouchers", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "_buyer", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "_to", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256[]", + "name": "_itemIds", + "type": "uint256[]" + }, + { + "indexed": false, + "internalType": "uint256[]", + "name": "_quantities", + "type": "uint256[]" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "_totalPrice", + "type": "uint256" + } + ], + "name": "PurchaseTransferItemsWithGhst", + "type": "event" + }, + { + "inputs": [ + { "internalType": "address", "name": "_to", "type": "address" }, + { "internalType": "uint256", "name": "_ghst", "type": "uint256" } + ], + "name": "buyPortals", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "_to", "type": "address" }, + { "internalType": "uint256", "name": "_amount", "type": "uint256" } + ], + "name": "mintPortals", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "_to", "type": "address" }, + { + "internalType": "uint256[]", + "name": "_itemIds", + "type": "uint256[]" + }, + { + "internalType": "uint256[]", + "name": "_quantities", + "type": "uint256[]" + } + ], + "name": "purchaseItemsWithGhst", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "_to", "type": "address" }, + { + "internalType": "uint256[]", + "name": "_itemIds", + "type": "uint256[]" + }, + { + "internalType": "uint256[]", + "name": "_quantities", + "type": "uint256[]" + } + ], + "name": "purchaseTransferItemsWithGhst", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "_svgType", + "type": "bytes32" + }, + { + "internalType": "uint256", + "name": "_numLayers", + "type": "uint256" + } + ], + "name": "deleteLastSvgLayers", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "uint256", "name": "_tokenId", "type": "uint256" } + ], + "name": "getAavegotchiSvg", + "outputs": [ + { "internalType": "string", "name": "ag_", "type": "string" } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "uint256", "name": "_itemId", "type": "uint256" } + ], + "name": "getItemSvg", + "outputs": [ + { "internalType": "string", "name": "ag_", "type": "string" } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "_svgType", + "type": "bytes32" + }, + { "internalType": "uint256", "name": "_itemId", "type": "uint256" } + ], + "name": "getSvg", + "outputs": [ + { "internalType": "string", "name": "svg_", "type": "string" } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "_svgType", + "type": "bytes32" + }, + { + "internalType": "uint256[]", + "name": "_itemIds", + "type": "uint256[]" + } + ], + "name": "getSvgs", + "outputs": [ + { "internalType": "string[]", "name": "svgs_", "type": "string[]" } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "uint256", "name": "_tokenId", "type": "uint256" } + ], + "name": "portalAavegotchisSvg", + "outputs": [ + { + "internalType": "string[10]", + "name": "svg_", + "type": "string[10]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "_hauntId", + "type": "uint256" + }, + { + "internalType": "address", + "name": "_collateralType", + "type": "address" + }, + { + "internalType": "int16[6]", + "name": "_numericTraits", + "type": "int16[6]" + }, + { + "internalType": "uint16[16]", + "name": "equippedWearables", + "type": "uint16[16]" + } + ], + "name": "previewAavegotchi", + "outputs": [ + { "internalType": "string", "name": "ag_", "type": "string" } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256[]", + "name": "_itemIds", + "type": "uint256[]" + }, + { + "components": [ + { "internalType": "uint8", "name": "x", "type": "uint8" }, + { "internalType": "uint8", "name": "y", "type": "uint8" }, + { + "internalType": "uint8", + "name": "width", + "type": "uint8" + }, + { + "internalType": "uint8", + "name": "height", + "type": "uint8" + } + ], + "internalType": "struct Dimensions[]", + "name": "_dimensions", + "type": "tuple[]" + } + ], + "name": "setItemsDimensions", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "uint256", + "name": "sleeveId", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "wearableId", + "type": "uint256" + } + ], + "internalType": "struct SvgFacet.Sleeve[]", + "name": "_sleeves", + "type": "tuple[]" + } + ], + "name": "setSleeves", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "string", "name": "_svg", "type": "string" }, + { + "components": [ + { + "internalType": "bytes32", + "name": "svgType", + "type": "bytes32" + }, + { + "internalType": "uint256[]", + "name": "sizes", + "type": "uint256[]" + } + ], + "internalType": "struct LibSvg.SvgTypeAndSizes[]", + "name": "_typesAndSizes", + "type": "tuple[]" + } + ], + "name": "storeSvg", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "string", "name": "_svg", "type": "string" }, + { + "components": [ + { + "internalType": "bytes32", + "name": "svgType", + "type": "bytes32" + }, + { + "internalType": "uint256[]", + "name": "ids", + "type": "uint256[]" + }, + { + "internalType": "uint256[]", + "name": "sizes", + "type": "uint256[]" + } + ], + "internalType": "struct LibSvg.SvgTypeAndIdsAndSizes[]", + "name": "_typesAndIdsAndSizes", + "type": "tuple[]" + } + ], + "name": "updateSvg", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "uint256", "name": "_tokenId", "type": "uint256" } + ], + "name": "getAavegotchiSideSvgs", + "outputs": [ + { "internalType": "string[]", "name": "ag_", "type": "string[]" } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "uint256", "name": "_itemId", "type": "uint256" } + ], + "name": "getItemSvgs", + "outputs": [ + { "internalType": "string[]", "name": "svg_", "type": "string[]" } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "_hauntId", + "type": "uint256" + }, + { + "internalType": "address", + "name": "_collateralType", + "type": "address" + }, + { + "internalType": "int16[6]", + "name": "_numericTraits", + "type": "int16[6]" + }, + { + "internalType": "uint16[16]", + "name": "equippedWearables", + "type": "uint16[16]" + } + ], + "name": "previewSideAavegotchi", + "outputs": [ + { "internalType": "string[]", "name": "ag_", "type": "string[]" } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "uint256", + "name": "itemId", + "type": "uint256" + }, + { + "internalType": "string", + "name": "side", + "type": "string" + }, + { + "components": [ + { + "internalType": "uint8", + "name": "x", + "type": "uint8" + }, + { + "internalType": "uint8", + "name": "y", + "type": "uint8" + }, + { + "internalType": "uint8", + "name": "width", + "type": "uint8" + }, + { + "internalType": "uint8", + "name": "height", + "type": "uint8" + } + ], + "internalType": "struct Dimensions", + "name": "dimensions", + "type": "tuple" + } + ], + "internalType": "struct SvgViewsFacet.SideViewDimensionsArgs[]", + "name": "_sideViewDimensions", + "type": "tuple[]" + } + ], + "name": "setSideViewDimensions", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256[]", + "name": "_tokenIds", + "type": "uint256[]" + } + ], + "name": "OpenPortals", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + } + ], + "name": "PortalOpened", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "randomNumber", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "_vrfTimeSet", + "type": "uint256" + } + ], + "name": "VrfRandomNumber", + "type": "event" + }, + { + "inputs": [ + { "internalType": "uint256", "name": "_newFee", "type": "uint256" }, + { + "internalType": "bytes32", + "name": "_keyHash", + "type": "bytes32" + }, + { + "internalType": "address", + "name": "_vrfCoordinator", + "type": "address" + }, + { "internalType": "address", "name": "_link", "type": "address" } + ], + "name": "changeVrf", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "keyHash", + "outputs": [ + { "internalType": "bytes32", "name": "", "type": "bytes32" } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "link", + "outputs": [ + { "internalType": "address", "name": "", "type": "address" } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "linkBalance", + "outputs": [ + { + "internalType": "uint256", + "name": "linkBalance_", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256[]", + "name": "_tokenIds", + "type": "uint256[]" + } + ], + "name": "openPortals", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "_requestId", + "type": "bytes32" + }, + { + "internalType": "uint256", + "name": "_randomNumber", + "type": "uint256" + } + ], + "name": "rawFulfillRandomness", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "_to", "type": "address" }, + { "internalType": "uint256", "name": "_value", "type": "uint256" } + ], + "name": "removeLinkTokens", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "vrfCoordinator", + "outputs": [ + { "internalType": "address", "name": "", "type": "address" } + ], + "stateMutability": "view", + "type": "function" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "_owner", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256[]", + "name": "_ids", + "type": "uint256[]" + }, + { + "indexed": false, + "internalType": "uint256[]", + "name": "_values", + "type": "uint256[]" + } + ], + "name": "MigrateVouchers", + "type": "event" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "internalType": "uint256[]", + "name": "ids", + "type": "uint256[]" + }, + { + "internalType": "uint256[]", + "name": "values", + "type": "uint256[]" + } + ], + "internalType": "struct VoucherMigrationFacet.VouchersOwner[]", + "name": "_vouchersOwners", + "type": "tuple[]" + } + ], + "name": "migrateVouchers", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint256", + "name": "_tokenId", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "kinship", + "type": "uint256" + } + ], + "name": "AavegotchiInteract", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint256", + "name": "listingId", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "category", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "time", + "type": "uint256" + } + ], + "name": "ERC1155ListingCancelled", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint256", + "name": "listingId", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "category", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "time", + "type": "uint256" + } + ], + "name": "ERC1155ListingRemoved", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint256", + "name": "listingId", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "quantity", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "priceInWei", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "time", + "type": "uint256" + } + ], + "name": "UpdateERC1155Listing", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint256", + "name": "listingId", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "category", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "time", + "type": "uint256" + } + ], + "name": "ERC721ListingCancelled", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint256", + "name": "listingId", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "category", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "time", + "type": "uint256" + } + ], + "name": "ERC721ListingRemoved", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "components": [ + { + "internalType": "bytes32", + "name": "svgType", + "type": "bytes32" + }, + { + "internalType": "uint256[]", + "name": "sizes", + "type": "uint256[]" + } + ], + "indexed": false, + "internalType": "struct LibSvg.SvgTypeAndSizes[]", + "name": "_typesAndSizes", + "type": "tuple[]" + } + ], + "name": "StoreSvg", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "components": [ + { + "internalType": "bytes32", + "name": "svgType", + "type": "bytes32" + }, + { + "internalType": "uint256[]", + "name": "ids", + "type": "uint256[]" + }, + { + "internalType": "uint256[]", + "name": "sizes", + "type": "uint256[]" + } + ], + "indexed": false, + "internalType": "struct LibSvg.SvgTypeAndIdsAndSizes[]", + "name": "_typesAndIdsAndSizes", + "type": "tuple[]" + } + ], + "name": "UpdateSvg", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "components": [ + { + "internalType": "address", + "name": "facetAddress", + "type": "address" + }, + { + "internalType": "enum IDiamondCut.FacetCutAction", + "name": "action", + "type": "uint8" + }, + { + "internalType": "bytes4[]", + "name": "functionSelectors", + "type": "bytes4[]" + } + ], + "indexed": false, + "internalType": "struct IDiamondCut.FacetCut[]", + "name": "_diamondCut", + "type": "tuple[]" + }, + { + "indexed": false, + "internalType": "address", + "name": "_init", + "type": "address" + }, + { + "indexed": false, + "internalType": "bytes", + "name": "_calldata", + "type": "bytes" + } + ], + "name": "DiamondCut", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "previousOwner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "OwnershipTransferred", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "_owner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "_operator", + "type": "address" + }, + { + "indexed": false, + "internalType": "bool", + "name": "_approved", + "type": "bool" + } + ], + "name": "ApprovalForAll", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "_operator", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "_from", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "_to", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256[]", + "name": "_ids", + "type": "uint256[]" + }, + { + "indexed": false, + "internalType": "uint256[]", + "name": "_values", + "type": "uint256[]" + } + ], + "name": "TransferBatch", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "_fromContract", + "type": "address" + }, + { + "indexed": true, + "internalType": "uint256", + "name": "_fromTokenId", + "type": "uint256" + }, + { + "indexed": true, + "internalType": "uint256", + "name": "_tokenTypeId", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "_value", + "type": "uint256" + } + ], + "name": "TransferFromParent", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "_operator", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "_from", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "_to", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "_id", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "_value", + "type": "uint256" + } + ], + "name": "TransferSingle", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "_toContract", + "type": "address" + }, + { + "indexed": true, + "internalType": "uint256", + "name": "_toTokenId", + "type": "uint256" + }, + { + "indexed": true, + "internalType": "uint256", + "name": "_tokenTypeId", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "_value", + "type": "uint256" + } + ], + "name": "TransferToParent", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "string", + "name": "_value", + "type": "string" + }, + { + "indexed": true, + "internalType": "uint256", + "name": "_id", + "type": "uint256" + } + ], + "name": "URI", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "_owner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "_approved", + "type": "address" + }, + { + "indexed": true, + "internalType": "uint256", + "name": "_tokenId", + "type": "uint256" + } + ], + "name": "Approval", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "_owner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "_operator", + "type": "address" + }, + { + "indexed": false, + "internalType": "bool", + "name": "_approved", + "type": "bool" + } + ], + "name": "ApprovalForAll", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "_from", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "_to", + "type": "address" + }, + { + "indexed": true, + "internalType": "uint256", + "name": "_tokenId", + "type": "uint256" + } + ], + "name": "Transfer", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "_itemId", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "_priceInWei", + "type": "uint256" + } + ], + "name": "UpdateItemPrice", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint32", + "name": "listingId", + "type": "uint32" + } + ], + "name": "GotchiLendingAdd", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint32", + "name": "listingId", + "type": "uint32" + } + ], + "name": "GotchiLendingEnd", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint32", + "name": "listingId", + "type": "uint32" + } + ], + "name": "GotchiLendingExecute", + "type": "event" + }, + { + "inputs": [ + { + "internalType": "uint32", + "name": "_erc721TokenId", + "type": "uint32" + }, + { + "internalType": "uint96", + "name": "_initialCost", + "type": "uint96" + }, + { "internalType": "uint32", "name": "_period", "type": "uint32" }, + { + "internalType": "uint8[3]", + "name": "_revenueSplit", + "type": "uint8[3]" + }, + { + "internalType": "address", + "name": "_originalOwner", + "type": "address" + }, + { + "internalType": "address", + "name": "_thirdParty", + "type": "address" + }, + { + "internalType": "uint32", + "name": "_whitelistId", + "type": "uint32" + }, + { + "internalType": "address[]", + "name": "_revenueTokens", + "type": "address[]" + } + ], + "name": "addGotchiLending", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint32", + "name": "_listingId", + "type": "uint32" + }, + { + "internalType": "uint32", + "name": "_erc721TokenId", + "type": "uint32" + }, + { + "internalType": "uint96", + "name": "_initialCost", + "type": "uint96" + }, + { "internalType": "uint32", "name": "_period", "type": "uint32" }, + { + "internalType": "uint8[3]", + "name": "_revenueSplit", + "type": "uint8[3]" + } + ], + "name": "agreeGotchiLending", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "uint32", "name": "_listingId", "type": "uint32" } + ], + "name": "cancelGotchiLending", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint32", + "name": "_erc721TokenId", + "type": "uint32" + } + ], + "name": "cancelGotchiLendingByToken", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "uint32", "name": "_tokenId", "type": "uint32" } + ], + "name": "claimAndEndGotchiLending", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "uint32", "name": "_tokenId", "type": "uint32" } + ], + "name": "claimGotchiLending", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint32", + "name": "_erc721TokenId", + "type": "uint32" + } + ], + "name": "getGotchiLendingFromToken", + "outputs": [ + { + "components": [ + { + "internalType": "address", + "name": "lender", + "type": "address" + }, + { + "internalType": "uint96", + "name": "initialCost", + "type": "uint96" + }, + { + "internalType": "address", + "name": "borrower", + "type": "address" + }, + { + "internalType": "uint32", + "name": "listingId", + "type": "uint32" + }, + { + "internalType": "uint32", + "name": "erc721TokenId", + "type": "uint32" + }, + { + "internalType": "uint32", + "name": "whitelistId", + "type": "uint32" + }, + { + "internalType": "address", + "name": "originalOwner", + "type": "address" + }, + { + "internalType": "uint40", + "name": "timeCreated", + "type": "uint40" + }, + { + "internalType": "uint40", + "name": "timeAgreed", + "type": "uint40" + }, + { + "internalType": "bool", + "name": "canceled", + "type": "bool" + }, + { + "internalType": "bool", + "name": "completed", + "type": "bool" + }, + { + "internalType": "address", + "name": "thirdParty", + "type": "address" + }, + { + "internalType": "uint8[3]", + "name": "revenueSplit", + "type": "uint8[3]" + }, + { + "internalType": "uint40", + "name": "lastClaimed", + "type": "uint40" + }, + { + "internalType": "uint32", + "name": "period", + "type": "uint32" + }, + { + "internalType": "address[]", + "name": "revenueTokens", + "type": "address[]" + } + ], + "internalType": "struct GotchiLending", + "name": "listing_", + "type": "tuple" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint32", + "name": "_erc721TokenId", + "type": "uint32" + } + ], + "name": "getGotchiLendingIdByToken", + "outputs": [{ "internalType": "uint32", "name": "", "type": "uint32" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "uint32", "name": "_listingId", "type": "uint32" } + ], + "name": "getGotchiLendingListingInfo", + "outputs": [ + { + "components": [ + { + "internalType": "address", + "name": "lender", + "type": "address" + }, + { + "internalType": "uint96", + "name": "initialCost", + "type": "uint96" + }, + { + "internalType": "address", + "name": "borrower", + "type": "address" + }, + { + "internalType": "uint32", + "name": "listingId", + "type": "uint32" + }, + { + "internalType": "uint32", + "name": "erc721TokenId", + "type": "uint32" + }, + { + "internalType": "uint32", + "name": "whitelistId", + "type": "uint32" + }, + { + "internalType": "address", + "name": "originalOwner", + "type": "address" + }, + { + "internalType": "uint40", + "name": "timeCreated", + "type": "uint40" + }, + { + "internalType": "uint40", + "name": "timeAgreed", + "type": "uint40" + }, + { + "internalType": "bool", + "name": "canceled", + "type": "bool" + }, + { + "internalType": "bool", + "name": "completed", + "type": "bool" + }, + { + "internalType": "address", + "name": "thirdParty", + "type": "address" + }, + { + "internalType": "uint8[3]", + "name": "revenueSplit", + "type": "uint8[3]" + }, + { + "internalType": "uint40", + "name": "lastClaimed", + "type": "uint40" + }, + { + "internalType": "uint32", + "name": "period", + "type": "uint32" + }, + { + "internalType": "address[]", + "name": "revenueTokens", + "type": "address[]" + } + ], + "internalType": "struct GotchiLending", + "name": "listing_", + "type": "tuple" + }, + { + "components": [ + { + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + }, + { + "internalType": "string", + "name": "name", + "type": "string" + }, + { + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "internalType": "uint256", + "name": "randomNumber", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "status", + "type": "uint256" + }, + { + "internalType": "int16[6]", + "name": "numericTraits", + "type": "int16[6]" + }, + { + "internalType": "int16[6]", + "name": "modifiedNumericTraits", + "type": "int16[6]" + }, + { + "internalType": "uint16[16]", + "name": "equippedWearables", + "type": "uint16[16]" + }, + { + "internalType": "address", + "name": "collateral", + "type": "address" + }, + { + "internalType": "address", + "name": "escrow", + "type": "address" + }, + { + "internalType": "uint256", + "name": "stakedAmount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "minimumStake", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "kinship", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "lastInteracted", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "experience", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "toNextLevel", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "usedSkillPoints", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "level", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "hauntId", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "baseRarityScore", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "modifiedRarityScore", + "type": "uint256" + }, + { + "internalType": "bool", + "name": "locked", + "type": "bool" + }, + { + "components": [ + { + "internalType": "uint256", + "name": "balance", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "itemId", + "type": "uint256" + }, + { + "components": [ + { + "internalType": "string", + "name": "name", + "type": "string" + }, + { + "internalType": "string", + "name": "description", + "type": "string" + }, + { + "internalType": "string", + "name": "author", + "type": "string" + }, + { + "internalType": "int8[6]", + "name": "traitModifiers", + "type": "int8[6]" + }, + { + "internalType": "bool[16]", + "name": "slotPositions", + "type": "bool[16]" + }, + { + "internalType": "uint8[]", + "name": "allowedCollaterals", + "type": "uint8[]" + }, + { + "components": [ + { + "internalType": "uint8", + "name": "x", + "type": "uint8" + }, + { + "internalType": "uint8", + "name": "y", + "type": "uint8" + }, + { + "internalType": "uint8", + "name": "width", + "type": "uint8" + }, + { + "internalType": "uint8", + "name": "height", + "type": "uint8" + } + ], + "internalType": "struct Dimensions", + "name": "dimensions", + "type": "tuple" + }, + { + "internalType": "uint256", + "name": "ghstPrice", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "maxQuantity", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "totalQuantity", + "type": "uint256" + }, + { + "internalType": "uint32", + "name": "svgId", + "type": "uint32" + }, + { + "internalType": "uint8", + "name": "rarityScoreModifier", + "type": "uint8" + }, + { + "internalType": "bool", + "name": "canPurchaseWithGhst", + "type": "bool" + }, + { + "internalType": "uint16", + "name": "minLevel", + "type": "uint16" + }, + { + "internalType": "bool", + "name": "canBeTransferred", + "type": "bool" + }, + { + "internalType": "uint8", + "name": "category", + "type": "uint8" + }, + { + "internalType": "int16", + "name": "kinshipBonus", + "type": "int16" + }, + { + "internalType": "uint32", + "name": "experienceBonus", + "type": "uint32" + } + ], + "internalType": "struct ItemType", + "name": "itemType", + "type": "tuple" + } + ], + "internalType": "struct ItemTypeIO[]", + "name": "items", + "type": "tuple[]" + } + ], + "internalType": "struct AavegotchiInfo", + "name": "aavegotchiInfo_", + "type": "tuple" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "bytes32", "name": "_status", "type": "bytes32" }, + { "internalType": "uint256", "name": "_length", "type": "uint256" } + ], + "name": "getGotchiLendings", + "outputs": [ + { + "components": [ + { + "internalType": "address", + "name": "lender", + "type": "address" + }, + { + "internalType": "uint96", + "name": "initialCost", + "type": "uint96" + }, + { + "internalType": "address", + "name": "borrower", + "type": "address" + }, + { + "internalType": "uint32", + "name": "listingId", + "type": "uint32" + }, + { + "internalType": "uint32", + "name": "erc721TokenId", + "type": "uint32" + }, + { + "internalType": "uint32", + "name": "whitelistId", + "type": "uint32" + }, + { + "internalType": "address", + "name": "originalOwner", + "type": "address" + }, + { + "internalType": "uint40", + "name": "timeCreated", + "type": "uint40" + }, + { + "internalType": "uint40", + "name": "timeAgreed", + "type": "uint40" + }, + { + "internalType": "bool", + "name": "canceled", + "type": "bool" + }, + { + "internalType": "bool", + "name": "completed", + "type": "bool" + }, + { + "internalType": "address", + "name": "thirdParty", + "type": "address" + }, + { + "internalType": "uint8[3]", + "name": "revenueSplit", + "type": "uint8[3]" + }, + { + "internalType": "uint40", + "name": "lastClaimed", + "type": "uint40" + }, + { + "internalType": "uint32", + "name": "period", + "type": "uint32" + }, + { + "internalType": "address[]", + "name": "revenueTokens", + "type": "address[]" + } + ], + "internalType": "struct GotchiLending[]", + "name": "listings_", + "type": "tuple[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "uint32", "name": "_listingId", "type": "uint32" } + ], + "name": "getLendingListingInfo", + "outputs": [ + { + "components": [ + { + "internalType": "address", + "name": "lender", + "type": "address" + }, + { + "internalType": "uint96", + "name": "initialCost", + "type": "uint96" + }, + { + "internalType": "address", + "name": "borrower", + "type": "address" + }, + { + "internalType": "uint32", + "name": "listingId", + "type": "uint32" + }, + { + "internalType": "uint32", + "name": "erc721TokenId", + "type": "uint32" + }, + { + "internalType": "uint32", + "name": "whitelistId", + "type": "uint32" + }, + { + "internalType": "address", + "name": "originalOwner", + "type": "address" + }, + { + "internalType": "uint40", + "name": "timeCreated", + "type": "uint40" + }, + { + "internalType": "uint40", + "name": "timeAgreed", + "type": "uint40" + }, + { + "internalType": "bool", + "name": "canceled", + "type": "bool" + }, + { + "internalType": "bool", + "name": "completed", + "type": "bool" + }, + { + "internalType": "address", + "name": "thirdParty", + "type": "address" + }, + { + "internalType": "uint8[3]", + "name": "revenueSplit", + "type": "uint8[3]" + }, + { + "internalType": "uint40", + "name": "lastClaimed", + "type": "uint40" + }, + { + "internalType": "uint32", + "name": "period", + "type": "uint32" + }, + { + "internalType": "address[]", + "name": "revenueTokens", + "type": "address[]" + } + ], + "internalType": "struct GotchiLending", + "name": "listing_", + "type": "tuple" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "_lender", "type": "address" }, + { "internalType": "bytes32", "name": "_status", "type": "bytes32" }, + { "internalType": "uint256", "name": "_length", "type": "uint256" } + ], + "name": "getOwnerGotchiLendings", + "outputs": [ + { + "components": [ + { + "internalType": "address", + "name": "lender", + "type": "address" + }, + { + "internalType": "uint96", + "name": "initialCost", + "type": "uint96" + }, + { + "internalType": "address", + "name": "borrower", + "type": "address" + }, + { + "internalType": "uint32", + "name": "listingId", + "type": "uint32" + }, + { + "internalType": "uint32", + "name": "erc721TokenId", + "type": "uint32" + }, + { + "internalType": "uint32", + "name": "whitelistId", + "type": "uint32" + }, + { + "internalType": "address", + "name": "originalOwner", + "type": "address" + }, + { + "internalType": "uint40", + "name": "timeCreated", + "type": "uint40" + }, + { + "internalType": "uint40", + "name": "timeAgreed", + "type": "uint40" + }, + { + "internalType": "bool", + "name": "canceled", + "type": "bool" + }, + { + "internalType": "bool", + "name": "completed", + "type": "bool" + }, + { + "internalType": "address", + "name": "thirdParty", + "type": "address" + }, + { + "internalType": "uint8[3]", + "name": "revenueSplit", + "type": "uint8[3]" + }, + { + "internalType": "uint40", + "name": "lastClaimed", + "type": "uint40" + }, + { + "internalType": "uint32", + "name": "period", + "type": "uint32" + }, + { + "internalType": "address[]", + "name": "revenueTokens", + "type": "address[]" + } + ], + "internalType": "struct GotchiLending[]", + "name": "listings_", + "type": "tuple[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint32", + "name": "_erc721TokenId", + "type": "uint32" + } + ], + "name": "isAavegotchiLent", + "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], + "stateMutability": "view", + "type": "function" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint32", + "name": "whitelistId", + "type": "uint32" + } + ], + "name": "WhitelistCreated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint32", + "name": "whitelistId", + "type": "uint32" + } + ], + "name": "WhitelistUpdated", + "type": "event" + }, + { + "inputs": [ + { "internalType": "string", "name": "_name", "type": "string" }, + { + "internalType": "address[]", + "name": "_whitelistAddresses", + "type": "address[]" + } + ], + "name": "createWhitelist", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint32", + "name": "_whitelistId", + "type": "uint32" + } + ], + "name": "getWhitelist", + "outputs": [ + { + "components": [ + { + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "internalType": "string", + "name": "name", + "type": "string" + }, + { + "internalType": "address[]", + "name": "addresses", + "type": "address[]" + } + ], + "internalType": "struct Whitelist", + "name": "", + "type": "tuple" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getWhitelists", + "outputs": [ + { + "components": [ + { + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "internalType": "string", + "name": "name", + "type": "string" + }, + { + "internalType": "address[]", + "name": "addresses", + "type": "address[]" + } + ], + "internalType": "struct Whitelist[]", + "name": "", + "type": "tuple[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint32", + "name": "_whitelistId", + "type": "uint32" + }, + { + "internalType": "address[]", + "name": "_whitelistAddresses", + "type": "address[]" + } + ], + "name": "updateWhitelist", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint32", + "name": "listingId", + "type": "uint32" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "time", + "type": "uint256" + } + ], + "name": "GotchiLendingCancel", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint32", + "name": "listingId", + "type": "uint32" + }, + { + "indexed": false, + "internalType": "address[]", + "name": "tokenAddresses", + "type": "address[]" + }, + { + "indexed": false, + "internalType": "uint256[]", + "name": "amounts", + "type": "uint256[]" + } + ], + "name": "GotchiLendingClaim", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint256", + "name": "listingId", + "type": "uint256" + }, + { + "indexed": true, + "internalType": "address", + "name": "buyer", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "recipient", + "type": "address" + } + ], + "name": "ERC721ExecutedToRecipient", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint256", + "name": "listingId", + "type": "uint256" + }, + { + "indexed": true, + "internalType": "address", + "name": "buyer", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "recipient", + "type": "address" + } + ], + "name": "ERC1155ExecutedToRecipient", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint32", + "name": "listingId", + "type": "uint32" + }, + { + "indexed": true, + "internalType": "address", + "name": "lender", + "type": "address" + }, + { + "indexed": true, + "internalType": "uint32", + "name": "tokenId", + "type": "uint32" + }, + { + "indexed": false, + "internalType": "uint96", + "name": "initialCost", + "type": "uint96" + }, + { + "indexed": false, + "internalType": "uint32", + "name": "period", + "type": "uint32" + }, + { + "indexed": false, + "internalType": "uint8[3]", + "name": "revenueSplit", + "type": "uint8[3]" + }, + { + "indexed": false, + "internalType": "address", + "name": "originalOwner", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "thirdParty", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint32", + "name": "whitelistId", + "type": "uint32" + }, + { + "indexed": false, + "internalType": "address[]", + "name": "revenueTokens", + "type": "address[]" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "timeCreated", + "type": "uint256" + } + ], + "name": "GotchiLendingAdded", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint32", + "name": "listingId", + "type": "uint32" + }, + { + "indexed": true, + "internalType": "address", + "name": "lender", + "type": "address" + }, + { + "indexed": true, + "internalType": "uint32", + "name": "tokenId", + "type": "uint32" + }, + { + "indexed": false, + "internalType": "uint96", + "name": "initialCost", + "type": "uint96" + }, + { + "indexed": false, + "internalType": "uint32", + "name": "period", + "type": "uint32" + }, + { + "indexed": false, + "internalType": "uint8[3]", + "name": "revenueSplit", + "type": "uint8[3]" + }, + { + "indexed": false, + "internalType": "address", + "name": "originalOwner", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "thirdParty", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint32", + "name": "whitelistId", + "type": "uint32" + }, + { + "indexed": false, + "internalType": "address[]", + "name": "revenueTokens", + "type": "address[]" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "timeCanceled", + "type": "uint256" + } + ], + "name": "GotchiLendingCanceled", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint32", + "name": "listingId", + "type": "uint32" + }, + { + "indexed": true, + "internalType": "address", + "name": "lender", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "borrower", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint32", + "name": "tokenId", + "type": "uint32" + }, + { + "indexed": false, + "internalType": "uint96", + "name": "initialCost", + "type": "uint96" + }, + { + "indexed": false, + "internalType": "uint32", + "name": "period", + "type": "uint32" + }, + { + "indexed": false, + "internalType": "uint8[3]", + "name": "revenueSplit", + "type": "uint8[3]" + }, + { + "indexed": false, + "internalType": "address", + "name": "originalOwner", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "thirdParty", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint32", + "name": "whitelistId", + "type": "uint32" + }, + { + "indexed": false, + "internalType": "address[]", + "name": "revenueTokens", + "type": "address[]" + }, + { + "indexed": false, + "internalType": "uint256[]", + "name": "amounts", + "type": "uint256[]" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "timeClaimed", + "type": "uint256" + } + ], + "name": "GotchiLendingClaimed", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint32", + "name": "listingId", + "type": "uint32" + }, + { + "indexed": true, + "internalType": "address", + "name": "lender", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "borrower", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint32", + "name": "tokenId", + "type": "uint32" + }, + { + "indexed": false, + "internalType": "uint96", + "name": "initialCost", + "type": "uint96" + }, + { + "indexed": false, + "internalType": "uint32", + "name": "period", + "type": "uint32" + }, + { + "indexed": false, + "internalType": "uint8[3]", + "name": "revenueSplit", + "type": "uint8[3]" + }, + { + "indexed": false, + "internalType": "address", + "name": "originalOwner", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "thirdParty", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint32", + "name": "whitelistId", + "type": "uint32" + }, + { + "indexed": false, + "internalType": "address[]", + "name": "revenueTokens", + "type": "address[]" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "timeEnded", + "type": "uint256" + } + ], + "name": "GotchiLendingEnded", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint32", + "name": "listingId", + "type": "uint32" + }, + { + "indexed": true, + "internalType": "address", + "name": "lender", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "borrower", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint32", + "name": "tokenId", + "type": "uint32" + }, + { + "indexed": false, + "internalType": "uint96", + "name": "initialCost", + "type": "uint96" + }, + { + "indexed": false, + "internalType": "uint32", + "name": "period", + "type": "uint32" + }, + { + "indexed": false, + "internalType": "uint8[3]", + "name": "revenueSplit", + "type": "uint8[3]" + }, + { + "indexed": false, + "internalType": "address", + "name": "originalOwner", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "thirdParty", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint32", + "name": "whitelistId", + "type": "uint32" + }, + { + "indexed": false, + "internalType": "address[]", + "name": "revenueTokens", + "type": "address[]" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "timeAgreed", + "type": "uint256" + } + ], + "name": "GotchiLendingExecuted", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint256", + "name": "id", + "type": "uint256" + }, + { + "indexed": true, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "NewSeriesStarted", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "_nftDiamond", + "type": "address" + } + ], + "name": "NftAddressUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "_owner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "_operator", + "type": "address" + }, + { + "indexed": false, + "internalType": "bool", + "name": "_approved", + "type": "bool" + } + ], + "name": "ApprovalForAll", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "_operator", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "_from", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "_to", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256[]", + "name": "_ids", + "type": "uint256[]" + }, + { + "indexed": false, + "internalType": "uint256[]", + "name": "_values", + "type": "uint256[]" + } + ], + "name": "TransferBatch", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "_operator", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "_from", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "_to", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "_id", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "_value", + "type": "uint256" + } + ], + "name": "TransferSingle", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "string", + "name": "_value", + "type": "string" + }, + { + "indexed": true, + "internalType": "uint256", + "name": "_id", + "type": "uint256" + } + ], + "name": "URI", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "_aavegotchiDiamond", + "type": "address" + } + ], + "name": "AavegotchiAddressUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "_cardDiamond", + "type": "address" + } + ], + "name": "CardAddressUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint256", + "name": "id", + "type": "uint256" + }, + { + "indexed": true, + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "indexed": false, + "internalType": "string", + "name": "fileHash", + "type": "string" + }, + { + "indexed": false, + "internalType": "bytes32", + "name": "name", + "type": "bytes32" + }, + { + "indexed": false, + "internalType": "address", + "name": "publisher", + "type": "address" + }, + { + "indexed": false, + "internalType": "string", + "name": "publisherName", + "type": "string" + }, + { + "indexed": false, + "internalType": "string", + "name": "externalLink", + "type": "string" + }, + { + "indexed": false, + "internalType": "string", + "name": "description", + "type": "string" + }, + { + "indexed": false, + "internalType": "address", + "name": "artist", + "type": "address" + }, + { + "indexed": false, + "internalType": "string", + "name": "artistName", + "type": "string" + }, + { + "indexed": false, + "internalType": "uint256[2]", + "name": "royalty", + "type": "uint256[2]" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "rarity", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "createdAt", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint8", + "name": "status", + "type": "uint8" + } + ], + "name": "MetadataActionLog", + "type": "event" + } +] diff --git a/abis/diamond_erc1155.json b/abis/diamond_erc1155.json new file mode 100644 index 0000000..8dc8ea3 --- /dev/null +++ b/abis/diamond_erc1155.json @@ -0,0 +1 @@ +[{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"_aavegotchiDiamond","type":"address"}],"name":"AavegotchiAddressUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"_fakeGotchisNftDiamond","type":"address"}],"name":"FakeGotchisNftAddressUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"id","type":"uint256"},{"indexed":true,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"NewSeriesStarted","type":"event"},{"inputs":[{"internalType":"address","name":"_owner","type":"address"},{"internalType":"uint256","name":"_id","type":"uint256"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"bal_","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address[]","name":"_owners","type":"address[]"},{"internalType":"uint256[]","name":"_ids","type":"uint256[]"}],"name":"balanceOfBatch","outputs":[{"internalType":"uint256[]","name":"bals","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_cardOwner","type":"address"},{"internalType":"uint256","name":"_cardSeriesId","type":"uint256"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"burn","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_owner","type":"address"},{"internalType":"address","name":"_operator","type":"address"}],"name":"isApprovedForAll","outputs":[{"internalType":"bool","name":"approved_","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"bytes","name":"","type":"bytes"}],"name":"onERC1155Received","outputs":[{"internalType":"bytes4","name":"","type":"bytes4"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"_from","type":"address"},{"internalType":"address","name":"_to","type":"address"},{"internalType":"uint256[]","name":"_ids","type":"uint256[]"},{"internalType":"uint256[]","name":"_amounts","type":"uint256[]"},{"internalType":"bytes","name":"_data","type":"bytes"}],"name":"safeBatchTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_from","type":"address"},{"internalType":"address","name":"_to","type":"address"},{"internalType":"uint256","name":"_id","type":"uint256"},{"internalType":"uint256","name":"_amount","type":"uint256"},{"internalType":"bytes","name":"_data","type":"bytes"}],"name":"safeTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_aavegotchiDiamond","type":"address"}],"name":"setAavegotchiAddress","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_operator","type":"address"},{"internalType":"bool","name":"_approved","type":"bool"}],"name":"setApprovalForAll","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"_uri","type":"string"}],"name":"setBaseURI","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_fakeGotchisNftDiamond","type":"address"}],"name":"setFakeGotchisNftAddress","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"startNewSeries","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_id","type":"uint256"}],"name":"uri","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"anonymous":false,"inputs":[{"components":[{"internalType":"address","name":"facetAddress","type":"address"},{"internalType":"enum IDiamondCut.FacetCutAction","name":"action","type":"uint8"},{"internalType":"bytes4[]","name":"functionSelectors","type":"bytes4[]"}],"indexed":false,"internalType":"struct IDiamondCut.FacetCut[]","name":"_diamondCut","type":"tuple[]"},{"indexed":false,"internalType":"address","name":"_init","type":"address"},{"indexed":false,"internalType":"bytes","name":"_calldata","type":"bytes"}],"name":"DiamondCut","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_owner","type":"address"},{"indexed":true,"internalType":"address","name":"_operator","type":"address"},{"indexed":false,"internalType":"bool","name":"_approved","type":"bool"}],"name":"ApprovalForAll","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_operator","type":"address"},{"indexed":true,"internalType":"address","name":"_from","type":"address"},{"indexed":true,"internalType":"address","name":"_to","type":"address"},{"indexed":false,"internalType":"uint256[]","name":"_ids","type":"uint256[]"},{"indexed":false,"internalType":"uint256[]","name":"_values","type":"uint256[]"}],"name":"TransferBatch","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_operator","type":"address"},{"indexed":true,"internalType":"address","name":"_from","type":"address"},{"indexed":true,"internalType":"address","name":"_to","type":"address"},{"indexed":false,"internalType":"uint256","name":"_id","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_value","type":"uint256"}],"name":"TransferSingle","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"string","name":"_value","type":"string"},{"indexed":true,"internalType":"uint256","name":"_id","type":"uint256"}],"name":"URI","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_owner","type":"address"},{"indexed":true,"internalType":"address","name":"_approved","type":"address"},{"indexed":true,"internalType":"uint256","name":"_tokenId","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_owner","type":"address"},{"indexed":true,"internalType":"address","name":"_operator","type":"address"},{"indexed":false,"internalType":"bool","name":"_approved","type":"bool"}],"name":"ApprovalForAll","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_owner","type":"address"},{"indexed":true,"internalType":"uint256","name":"_tokenId","type":"uint256"}],"name":"Mint","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_from","type":"address"},{"indexed":true,"internalType":"address","name":"_to","type":"address"},{"indexed":true,"internalType":"uint256","name":"_tokenId","type":"uint256"}],"name":"Transfer","type":"event"},{"anonymous":false,"inputs":[{"components":[{"internalType":"address","name":"facetAddress","type":"address"},{"internalType":"enum IDiamondCut.FacetCutAction","name":"action","type":"uint8"},{"internalType":"bytes4[]","name":"functionSelectors","type":"bytes4[]"}],"indexed":false,"internalType":"struct IDiamondCut.FacetCut[]","name":"_diamondCut","type":"tuple[]"},{"indexed":false,"internalType":"address","name":"_init","type":"address"},{"indexed":false,"internalType":"bytes","name":"_calldata","type":"bytes"}],"name":"DiamondCut","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_owner","type":"address"},{"indexed":true,"internalType":"address","name":"_operator","type":"address"},{"indexed":false,"internalType":"bool","name":"_approved","type":"bool"}],"name":"ApprovalForAll","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_operator","type":"address"},{"indexed":true,"internalType":"address","name":"_from","type":"address"},{"indexed":true,"internalType":"address","name":"_to","type":"address"},{"indexed":false,"internalType":"uint256[]","name":"_ids","type":"uint256[]"},{"indexed":false,"internalType":"uint256[]","name":"_values","type":"uint256[]"}],"name":"TransferBatch","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_operator","type":"address"},{"indexed":true,"internalType":"address","name":"_from","type":"address"},{"indexed":true,"internalType":"address","name":"_to","type":"address"},{"indexed":false,"internalType":"uint256","name":"_id","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_value","type":"uint256"}],"name":"TransferSingle","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"string","name":"_value","type":"string"},{"indexed":true,"internalType":"uint256","name":"_id","type":"uint256"}],"name":"URI","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_owner","type":"address"},{"indexed":true,"internalType":"address","name":"_approved","type":"address"},{"indexed":true,"internalType":"uint256","name":"_tokenId","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_owner","type":"address"},{"indexed":true,"internalType":"address","name":"_operator","type":"address"},{"indexed":false,"internalType":"bool","name":"_approved","type":"bool"}],"name":"ApprovalForAll","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_owner","type":"address"},{"indexed":true,"internalType":"uint256","name":"_tokenId","type":"uint256"}],"name":"Mint","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_from","type":"address"},{"indexed":true,"internalType":"address","name":"_to","type":"address"},{"indexed":true,"internalType":"uint256","name":"_tokenId","type":"uint256"}],"name":"Transfer","type":"event"}] \ No newline at end of file diff --git a/abis/diamond_erc721.json b/abis/diamond_erc721.json new file mode 100644 index 0000000..e79b92c --- /dev/null +++ b/abis/diamond_erc721.json @@ -0,0 +1,1264 @@ +[ + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "_aavegotchiDiamond", + "type": "address" + } + ], + "name": "AavegotchiAddressUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "_fakeGotchisCardDiamond", + "type": "address" + } + ], + "name": "FakeGotchisCardAddressUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "_ghstContract", + "type": "address" + } + ], + "name": "GhstAddressUpdated", + "type": "event" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_approved", + "type": "address" + }, + { "internalType": "uint256", "name": "_tokenId", "type": "uint256" } + ], + "name": "approve", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "_owner", "type": "address" } + ], + "name": "balanceOf", + "outputs": [ + { "internalType": "uint256", "name": "balance_", "type": "uint256" } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "uint256", "name": "_tokenId", "type": "uint256" } + ], + "name": "getApproved", + "outputs": [ + { + "internalType": "address", + "name": "approved_", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "_owner", "type": "address" }, + { + "internalType": "address", + "name": "_operator", + "type": "address" + } + ], + "name": "isApprovedForAll", + "outputs": [ + { "internalType": "bool", "name": "approved_", "type": "bool" } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "_tokenId", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_salePrice", + "type": "uint256" + } + ], + "name": "multiRoyaltyInfo", + "outputs": [ + { + "internalType": "address[]", + "name": "receivers", + "type": "address[]" + }, + { + "internalType": "uint256[]", + "name": "royaltyAmounts", + "type": "uint256[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "name", + "outputs": [{ "internalType": "string", "name": "", "type": "string" }], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [ + { "internalType": "uint256", "name": "_tokenId", "type": "uint256" } + ], + "name": "ownerOf", + "outputs": [ + { "internalType": "address", "name": "owner_", "type": "address" } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "_from", "type": "address" }, + { "internalType": "address", "name": "_to", "type": "address" }, + { + "internalType": "uint256[]", + "name": "_tokenIds", + "type": "uint256[]" + }, + { "internalType": "bytes", "name": "_data", "type": "bytes" } + ], + "name": "safeBatchTransfer", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "_from", "type": "address" }, + { "internalType": "address", "name": "_to", "type": "address" }, + { "internalType": "uint256", "name": "_tokenId", "type": "uint256" } + ], + "name": "safeTransferFrom", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "_from", "type": "address" }, + { "internalType": "address", "name": "_to", "type": "address" }, + { + "internalType": "uint256", + "name": "_tokenId", + "type": "uint256" + }, + { "internalType": "bytes", "name": "_data", "type": "bytes" } + ], + "name": "safeTransferFrom", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_aavegotchiDiamond", + "type": "address" + } + ], + "name": "setAavegotchiAddress", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_operator", + "type": "address" + }, + { "internalType": "bool", "name": "_approved", "type": "bool" } + ], + "name": "setApprovalForAll", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_fakeGotchisCardDiamond", + "type": "address" + } + ], + "name": "setFakeGotchisCardAddress", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_ghstContract", + "type": "address" + } + ], + "name": "setGhstAddress", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "symbol", + "outputs": [{ "internalType": "string", "name": "", "type": "string" }], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [ + { "internalType": "uint256", "name": "_index", "type": "uint256" } + ], + "name": "tokenByIndex", + "outputs": [ + { "internalType": "uint256", "name": "tokenId_", "type": "uint256" } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "_owner", "type": "address" } + ], + "name": "tokenIdsOfOwner", + "outputs": [ + { + "internalType": "uint256[]", + "name": "tokenIds_", + "type": "uint256[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "uint256", "name": "_tokenId", "type": "uint256" } + ], + "name": "tokenURI", + "outputs": [{ "internalType": "string", "name": "", "type": "string" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "totalSupply", + "outputs": [ + { "internalType": "uint256", "name": "", "type": "uint256" } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "_from", "type": "address" }, + { "internalType": "address", "name": "_to", "type": "address" }, + { "internalType": "uint256", "name": "_tokenId", "type": "uint256" } + ], + "name": "transferFrom", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint256", + "name": "id", + "type": "uint256" + }, + { + "components": [ + { + "internalType": "address", + "name": "publisher", + "type": "address" + }, + { + "internalType": "uint16[2]", + "name": "royalty", + "type": "uint16[2]" + }, + { + "internalType": "uint16", + "name": "editions", + "type": "uint16" + }, + { + "internalType": "uint32", + "name": "flagCount", + "type": "uint32" + }, + { + "internalType": "uint32", + "name": "likeCount", + "type": "uint32" + }, + { + "internalType": "address", + "name": "artist", + "type": "address" + }, + { + "internalType": "uint40", + "name": "createdAt", + "type": "uint40" + }, + { + "internalType": "uint8", + "name": "status", + "type": "uint8" + }, + { + "internalType": "bool", + "name": "minted", + "type": "bool" + }, + { + "internalType": "string", + "name": "name", + "type": "string" + }, + { + "internalType": "string", + "name": "description", + "type": "string" + }, + { + "internalType": "string", + "name": "externalLink", + "type": "string" + }, + { + "internalType": "string", + "name": "artistName", + "type": "string" + }, + { + "internalType": "string", + "name": "publisherName", + "type": "string" + }, + { + "internalType": "string", + "name": "fileHash", + "type": "string" + }, + { + "internalType": "string", + "name": "fileType", + "type": "string" + }, + { + "internalType": "string", + "name": "thumbnailHash", + "type": "string" + }, + { + "internalType": "string", + "name": "thumbnailType", + "type": "string" + } + ], + "indexed": false, + "internalType": "struct Metadata", + "name": "metaData", + "type": "tuple" + } + ], + "name": "MetadataActionLog", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint256", + "name": "_id", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "address", + "name": "_declinedBy", + "type": "address" + } + ], + "name": "MetadataDecline", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint256", + "name": "_id", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "address", + "name": "_flaggedBy", + "type": "address" + } + ], + "name": "MetadataFlag", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint256", + "name": "_id", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "address", + "name": "_likedBy", + "type": "address" + } + ], + "name": "MetadataLike", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint256", + "name": "_id", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "address", + "name": "_reviewer", + "type": "address" + } + ], + "name": "ReviewPass", + "type": "event" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "string", + "name": "name", + "type": "string" + }, + { + "internalType": "string", + "name": "publisherName", + "type": "string" + }, + { + "internalType": "string", + "name": "externalLink", + "type": "string" + }, + { + "internalType": "string", + "name": "description", + "type": "string" + }, + { + "internalType": "address", + "name": "artist", + "type": "address" + }, + { + "internalType": "string", + "name": "artistName", + "type": "string" + }, + { + "internalType": "uint16[2]", + "name": "royalty", + "type": "uint16[2]" + }, + { + "internalType": "uint16", + "name": "editions", + "type": "uint16" + }, + { + "internalType": "string", + "name": "fileHash", + "type": "string" + }, + { + "internalType": "string", + "name": "fileType", + "type": "string" + }, + { + "internalType": "string", + "name": "thumbnailHash", + "type": "string" + }, + { + "internalType": "string", + "name": "thumbnailType", + "type": "string" + } + ], + "internalType": "struct MetadataFacet.MetadataInput", + "name": "mData", + "type": "tuple" + }, + { "internalType": "uint256", "name": "series", "type": "uint256" } + ], + "name": "addMetadata", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "uint256", "name": "_id", "type": "uint256" }, + { "internalType": "bool", "name": "isBadFaith", "type": "bool" } + ], + "name": "declineMetadata", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "uint256", "name": "_id", "type": "uint256" } + ], + "name": "flag", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "uint256", "name": "_id", "type": "uint256" } + ], + "name": "getMetadata", + "outputs": [ + { + "components": [ + { + "internalType": "address", + "name": "publisher", + "type": "address" + }, + { + "internalType": "uint16[2]", + "name": "royalty", + "type": "uint16[2]" + }, + { + "internalType": "uint16", + "name": "editions", + "type": "uint16" + }, + { + "internalType": "uint32", + "name": "flagCount", + "type": "uint32" + }, + { + "internalType": "uint32", + "name": "likeCount", + "type": "uint32" + }, + { + "internalType": "address", + "name": "artist", + "type": "address" + }, + { + "internalType": "uint40", + "name": "createdAt", + "type": "uint40" + }, + { + "internalType": "uint8", + "name": "status", + "type": "uint8" + }, + { + "internalType": "bool", + "name": "minted", + "type": "bool" + }, + { + "internalType": "string", + "name": "name", + "type": "string" + }, + { + "internalType": "string", + "name": "description", + "type": "string" + }, + { + "internalType": "string", + "name": "externalLink", + "type": "string" + }, + { + "internalType": "string", + "name": "artistName", + "type": "string" + }, + { + "internalType": "string", + "name": "publisherName", + "type": "string" + }, + { + "internalType": "string", + "name": "fileHash", + "type": "string" + }, + { + "internalType": "string", + "name": "fileType", + "type": "string" + }, + { + "internalType": "string", + "name": "thumbnailHash", + "type": "string" + }, + { + "internalType": "string", + "name": "thumbnailType", + "type": "string" + } + ], + "internalType": "struct Metadata", + "name": "", + "type": "tuple" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "uint256", "name": "_id", "type": "uint256" } + ], + "name": "like", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "uint256", "name": "_id", "type": "uint256" } + ], + "name": "mint", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "uint256", "name": "_id", "type": "uint256" } + ], + "name": "passReview", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "anonymous": false, + "inputs": [ + { + "components": [ + { + "internalType": "address", + "name": "facetAddress", + "type": "address" + }, + { + "internalType": "enum IDiamondCut.FacetCutAction", + "name": "action", + "type": "uint8" + }, + { + "internalType": "bytes4[]", + "name": "functionSelectors", + "type": "bytes4[]" + } + ], + "indexed": false, + "internalType": "struct IDiamondCut.FacetCut[]", + "name": "_diamondCut", + "type": "tuple[]" + }, + { + "indexed": false, + "internalType": "address", + "name": "_init", + "type": "address" + }, + { + "indexed": false, + "internalType": "bytes", + "name": "_calldata", + "type": "bytes" + } + ], + "name": "DiamondCut", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "previousOwner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "OwnershipTransferred", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "_owner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "_operator", + "type": "address" + }, + { + "indexed": false, + "internalType": "bool", + "name": "_approved", + "type": "bool" + } + ], + "name": "ApprovalForAll", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "_operator", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "_from", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "_to", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256[]", + "name": "_ids", + "type": "uint256[]" + }, + { + "indexed": false, + "internalType": "uint256[]", + "name": "_values", + "type": "uint256[]" + } + ], + "name": "TransferBatch", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "_operator", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "_from", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "_to", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "_id", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "_value", + "type": "uint256" + } + ], + "name": "TransferSingle", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "string", + "name": "_value", + "type": "string" + }, + { + "indexed": true, + "internalType": "uint256", + "name": "_id", + "type": "uint256" + } + ], + "name": "URI", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "_owner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "_approved", + "type": "address" + }, + { + "indexed": true, + "internalType": "uint256", + "name": "_tokenId", + "type": "uint256" + } + ], + "name": "Approval", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "_owner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "_operator", + "type": "address" + }, + { + "indexed": false, + "internalType": "bool", + "name": "_approved", + "type": "bool" + } + ], + "name": "ApprovalForAll", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "_owner", + "type": "address" + }, + { + "indexed": true, + "internalType": "uint256", + "name": "_tokenId", + "type": "uint256" + } + ], + "name": "Mint", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "_from", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "_to", + "type": "address" + }, + { + "indexed": true, + "internalType": "uint256", + "name": "_tokenId", + "type": "uint256" + } + ], + "name": "Transfer", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "components": [ + { + "internalType": "address", + "name": "facetAddress", + "type": "address" + }, + { + "internalType": "enum IDiamondCut.FacetCutAction", + "name": "action", + "type": "uint8" + }, + { + "internalType": "bytes4[]", + "name": "functionSelectors", + "type": "bytes4[]" + } + ], + "indexed": false, + "internalType": "struct IDiamondCut.FacetCut[]", + "name": "_diamondCut", + "type": "tuple[]" + }, + { + "indexed": false, + "internalType": "address", + "name": "_init", + "type": "address" + }, + { + "indexed": false, + "internalType": "bytes", + "name": "_calldata", + "type": "bytes" + } + ], + "name": "DiamondCut", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "previousOwner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "OwnershipTransferred", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "_owner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "_operator", + "type": "address" + }, + { + "indexed": false, + "internalType": "bool", + "name": "_approved", + "type": "bool" + } + ], + "name": "ApprovalForAll", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "_operator", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "_from", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "_to", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256[]", + "name": "_ids", + "type": "uint256[]" + }, + { + "indexed": false, + "internalType": "uint256[]", + "name": "_values", + "type": "uint256[]" + } + ], + "name": "TransferBatch", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "_operator", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "_from", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "_to", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "_id", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "_value", + "type": "uint256" + } + ], + "name": "TransferSingle", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "string", + "name": "_value", + "type": "string" + }, + { + "indexed": true, + "internalType": "uint256", + "name": "_id", + "type": "uint256" + } + ], + "name": "URI", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "_owner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "_approved", + "type": "address" + }, + { + "indexed": true, + "internalType": "uint256", + "name": "_tokenId", + "type": "uint256" + } + ], + "name": "Approval", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "_owner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "_operator", + "type": "address" + }, + { + "indexed": false, + "internalType": "bool", + "name": "_approved", + "type": "bool" + } + ], + "name": "ApprovalForAll", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "_owner", + "type": "address" + }, + { + "indexed": true, + "internalType": "uint256", + "name": "_tokenId", + "type": "uint256" + } + ], + "name": "Mint", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "_from", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "_to", + "type": "address" + }, + { + "indexed": true, + "internalType": "uint256", + "name": "_tokenId", + "type": "uint256" + } + ], + "name": "Transfer", + "type": "event" + } +] diff --git a/datasources.json b/datasources.json new file mode 100644 index 0000000..b299ebb --- /dev/null +++ b/datasources.json @@ -0,0 +1,11 @@ +{ + "output": "generated/", + "chain": "matic", + "datasources": [ + { + "address": "0x86935f11c86623dec8a25696e1c19a8659cbf95d", + "startBlock": 11516320, + "module": ["erc721", "ownable"] + } + ] +} diff --git a/package.json b/package.json index 2bd5aa1..2db7656 100644 --- a/package.json +++ b/package.json @@ -25,6 +25,7 @@ "ethers": "^5.5.4", "jest": "^27.4.7", "json-diff": "^0.7.1", - "matchstick-as": "^0.6.0" + "matchstick-as": "^0.6.0", + "@amxx/graphprotocol-utils": "^1.1.0" } } diff --git a/schema.graphql b/schema.graphql index 6b57142..e113b82 100644 --- a/schema.graphql +++ b/schema.graphql @@ -410,3 +410,270 @@ type ERC721BuyOrder @entity { canceledAt: BigInt canceled: Boolean } + +interface Event { + id: ID! + transaction: Transaction! + emitter: Account! + timestamp: BigInt! +} +type Transaction @entity(immutable: true) { + id: ID! + timestamp: BigInt! + blockNumber: BigInt! + events: [Event!]! @derivedFrom(field: "transaction") +} + +type Account @entity { + id: Bytes! + asERC1155: ERC1155Contract + ERC1155balances: [ERC1155Balance!]! @derivedFrom(field: "account") + ERC1155operatorOwner: [ERC1155Operator!]! @derivedFrom(field: "owner") + ERC1155operatorOperator: [ERC1155Operator!]! @derivedFrom(field: "operator") + ERC1155transferFromEvent: [ERC1155Transfer!]! @derivedFrom(field: "from") + ERC1155transferToEvent: [ERC1155Transfer!]! @derivedFrom(field: "to") + ERC1155transferOperatorEvent: [ERC1155Transfer!]! + @derivedFrom(field: "operator") + + asERC721: ERC721Contract + ERC721tokens: [ERC721Token!]! @derivedFrom(field: "owner") + ERC721operatorOwner: [ERC721Operator!]! @derivedFrom(field: "owner") + ERC721operatorOperator: [ERC721Operator!]! @derivedFrom(field: "operator") + ERC721transferFromEvent: [ERC721Transfer!]! @derivedFrom(field: "from") + ERC721transferToEvent: [ERC721Transfer!]! @derivedFrom(field: "to") + + events: [Event!]! @derivedFrom(field: "emitter") + + tokens: String! # from array + amountTokens: Int! + + currentUniquePiecesOwned: Int! + totalUniquePiecesOwned: Int! + + currentUniquePiecesOwnedArray: String! # from array + totalUniquePiecesOwnedArray: String! # from array + totalPiecesOwnedArray: String! # from array +} + +# Cards +type ERC1155Contract @entity(immutable: true) { + id: Bytes! + asAccount: Account! + tokens: [ERC1155Token!]! @derivedFrom(field: "contract") + balances: [ERC1155Balance!]! @derivedFrom(field: "contract") + operators: [ERC1155Operator!]! @derivedFrom(field: "contract") + transfers: [ERC1155Transfer!]! @derivedFrom(field: "contract") +} +type ERC1155Token @entity { + id: ID! + contract: ERC1155Contract! + identifier: BigInt! + uri: String + totalSupply: ERC1155Balance! + balances: [ERC1155Balance!]! @derivedFrom(field: "token") + transfers: [ERC1155Transfer!]! @derivedFrom(field: "token") + metadata: MetadataActionLog +} +type ERC1155Balance @entity { + id: ID! + contract: ERC1155Contract! + token: ERC1155Token! + account: Account + value: BigDecimal! + valueExact: BigInt! + transferFromEvent: [ERC1155Transfer!]! @derivedFrom(field: "fromBalance") + transferToEvent: [ERC1155Transfer!]! @derivedFrom(field: "toBalance") +} +type ERC1155Operator @entity { + id: ID! + contract: ERC1155Contract! + owner: Account! + operator: Account! + approved: Boolean! +} +type ERC1155Transfer implements Event @entity(immutable: true) { + id: ID! + emitter: Account! + transaction: Transaction! + timestamp: BigInt! + contract: ERC1155Contract! + token: ERC1155Token! + operator: Account! + from: Account + fromBalance: ERC1155Balance + to: Account + toBalance: ERC1155Balance + value: BigDecimal! + valueExact: BigInt! +} + +# NFT 721 +type ERC721Contract @entity(immutable: true) { + id: Bytes! + asAccount: Account! + supportsMetadata: Boolean + name: String + symbol: String + tokens: [ERC721Token!]! @derivedFrom(field: "contract") + operators: [ERC721Operator!]! @derivedFrom(field: "contract") + transfers: [ERC721Transfer!]! @derivedFrom(field: "contract") +} +type ERC721Token @entity { + id: ID! + contract: ERC721Contract! + identifier: BigInt! + owner: Account! + approval: Account! + uri: String + transfers: [ERC721Transfer!]! @derivedFrom(field: "token") + metadata: MetadataActionLog + + fileHash: String + name: String + publisher: Account + publisherName: String + externalLink: String + description: String + artist: Account + artistName: String + editions: Int + fileType: String + thumbnailHash: String + thumbnailType: String +} +type ERC721Operator @entity { + id: ID! + contract: ERC721Contract! + owner: Account! + operator: Account! + approved: Boolean! +} +type ERC721Transfer implements Event @entity(immutable: true) { + id: ID! + emitter: Account! + transaction: Transaction! + timestamp: BigInt! + contract: ERC721Contract! + token: ERC721Token! + from: Account! + to: Account! +} + +type MetadataActionLog implements Event @entity { + id: ID! + emitter: Account! + transaction: Transaction! + timestamp: BigInt! + sender: Account + minted: Boolean + fileHash: String + name: String + publisher: Account + publisherName: String + externalLink: String + description: String + artist: Account + artistName: String + royalty: [Int!] + createdAt: BigInt + editions: Int + fileType: String + thumbnailHash: String + thumbnailType: String + flagCount: Int + flags: [MetadataFlag!]! @derivedFrom(field: "metadata") + likeCount: Int + likes: [MetadataLike!]! @derivedFrom(field: "metadata") + status: Int +} + +type MetadataFlag implements Event @entity(immutable: true) { + id: ID! + emitter: Account! + transaction: Transaction! + timestamp: BigInt! + token: ERC721Token + sender: Account + + flaggedBy: Account + metadata: MetadataActionLog +} + +type MetadataLike implements Event @entity(immutable: true) { + id: ID! + emitter: Account! + transaction: Transaction! + timestamp: BigInt! + token: ERC721Token + sender: Account + + likedBy: Account + metadata: MetadataActionLog +} + +type MetadataDecline implements Event @entity(immutable: true) { + id: ID! + emitter: Account! + transaction: Transaction! + timestamp: BigInt! + token: ERC721Token + sender: Account + + declinedBy: Account + metadata: MetadataActionLog +} + +type ReviewPass implements Event @entity(immutable: true) { + id: ID! + emitter: Account! + transaction: Transaction! + timestamp: BigInt! + token: ERC721Token + sender: Account + + reviewer: Account + metadata: MetadataActionLog +} + +type Generation @entity { + "a generation is a series" + id: ID! + amount: Int +} + +type TotalStatistic @entity { + id: ID! + totalOwners: Int + totalOwnersArray: [Bytes!]! + + totalFakeGotchiPieces: Int + totalNFTs: Int + totalNFTsArray: String! + + burnedNFTs: Int + burnedCards: Int + + tokenIdCounter: Int + + totalEditionsMinted: Int! + totalEditionsCirculating: Int! + + totalEditionsCirculatingArray: String! +} + +type NFTStatistic @entity { + id: ID! + metadata: MetadataActionLog + holders: [NFTHolder!]! @derivedFrom(field: "nftStats") + burned: Int + amountHolder: Int + totalSupply: Int + tokenIds: [BigInt!]! +} + +type NFTHolder @entity { + id: ID! + nftStats: NFTStatistic + holder: Account + amount: Int +} diff --git a/src/constants.ts b/src/constants.ts new file mode 100644 index 0000000..8fba3a1 --- /dev/null +++ b/src/constants.ts @@ -0,0 +1,20 @@ +import { Address, BigInt } from "@graphprotocol/graph-ts"; + +export const BIGINT_ZERO = BigInt.fromI32(0); +export const BIGINT_ONE = BigInt.fromI32(1); +export const ADDRESS_ZERO = Address.fromString( + "0x0000000000000000000000000000000000000000" +); + +export const ADDRESS_BURN = Address.fromString( + "0xffffffffffffffffffffffffffffffffffffffff" +); + +export const ADDRESS_DEAD = Address.fromString( + "0x000000000000000000000000000000000000dead" +); + +export const METADATA_STATUS_PENDING = 0; +export const METADATA_STATUS_PAUSED = 1; +export const METADATA_STATUS_APPROVED = 2; +export const METADATA_STATUS_DECLINED = 3; diff --git a/src/diamonds/constants.ts b/src/diamonds/constants.ts new file mode 100644 index 0000000..8fba3a1 --- /dev/null +++ b/src/diamonds/constants.ts @@ -0,0 +1,20 @@ +import { Address, BigInt } from "@graphprotocol/graph-ts"; + +export const BIGINT_ZERO = BigInt.fromI32(0); +export const BIGINT_ONE = BigInt.fromI32(1); +export const ADDRESS_ZERO = Address.fromString( + "0x0000000000000000000000000000000000000000" +); + +export const ADDRESS_BURN = Address.fromString( + "0xffffffffffffffffffffffffffffffffffffffff" +); + +export const ADDRESS_DEAD = Address.fromString( + "0x000000000000000000000000000000000000dead" +); + +export const METADATA_STATUS_PENDING = 0; +export const METADATA_STATUS_PAUSED = 1; +export const METADATA_STATUS_APPROVED = 2; +export const METADATA_STATUS_DECLINED = 3; diff --git a/src/diamonds/fakeGotchisCard.ts b/src/diamonds/fakeGotchisCard.ts new file mode 100644 index 0000000..23948e8 --- /dev/null +++ b/src/diamonds/fakeGotchisCard.ts @@ -0,0 +1,159 @@ +import { ADDRESS_ZERO, BIGINT_ONE } from "../constants"; + +import { ethereum, BigInt } from "@graphprotocol/graph-ts"; + +import { + Account, + ERC1155Contract, + ERC1155Transfer, + Generation, +} from "../../generated/schema"; + +import { + ApprovalForAll as ApprovalForAllEvent, + TransferBatch as TransferBatchEvent, + TransferSingle as TransferSingleEvent, + URI as URIEvent, + NewSeriesStarted as NewSeriesStartedEvent, + NewSeriesStarted, +} from "../../generated/FAKEGotchisCardDiamond/IERC1155"; + +import { + constants, + decimals, + events, + transactions, +} from "@amxx/graphprotocol-utils"; + +import { fetchAccount } from "../fetch/account"; + +import { + fetchERC1155, + fetchERC1155Token, + fetchERC1155Balance, + fetchERC721Operator, + replaceURI, +} from "../fetch/erc1155"; + +function registerTransfer( + event: ethereum.Event, + suffix: string, + contract: ERC1155Contract, + operator: Account, + from: Account, + to: Account, + id: BigInt, + value: BigInt +): void { + let token = fetchERC1155Token(contract, id); + let ev = new ERC1155Transfer(events.id(event).concat(suffix)); + ev.emitter = token.contract; + ev.transaction = transactions.log(event).id; + ev.timestamp = event.block.timestamp; + ev.contract = contract.id; + ev.token = token.id; + ev.operator = operator.id; + ev.value = decimals.toDecimals(value); + ev.valueExact = value; + + if (from.id == constants.ADDRESS_ZERO) { + let totalSupply = fetchERC1155Balance(token, null); + totalSupply.valueExact = totalSupply.valueExact.plus(value); + totalSupply.value = decimals.toDecimals(totalSupply.valueExact); + totalSupply.save(); + } else { + let balance = fetchERC1155Balance(token, from); + balance.valueExact = balance.valueExact.minus(value); + balance.value = decimals.toDecimals(balance.valueExact); + balance.save(); + + ev.from = from.id; + ev.fromBalance = balance.id; + } + + if (to.id == constants.ADDRESS_ZERO) { + let totalSupply = fetchERC1155Balance(token, null); + totalSupply.valueExact = totalSupply.valueExact.minus(value); + totalSupply.value = decimals.toDecimals(totalSupply.valueExact); + totalSupply.save(); + } else { + let balance = fetchERC1155Balance(token, to); + balance.valueExact = balance.valueExact.plus(value); + balance.value = decimals.toDecimals(balance.valueExact); + balance.save(); + + ev.to = to.id; + ev.toBalance = balance.id; + } + + token.save(); + ev.save(); +} + +export function handleTransferSingle(event: TransferSingleEvent): void { + let contract = fetchERC1155(event.address); + let operator = fetchAccount(event.params._operator); + let from = fetchAccount(event.params._from); + let to = fetchAccount(event.params._to); + + registerTransfer( + event, + "", + contract, + operator, + from, + to, + event.params._id, + event.params._value + ); +} + +export function handleTransferBatch(event: TransferBatchEvent): void { + let contract = fetchERC1155(event.address); + let operator = fetchAccount(event.params._operator); + let from = fetchAccount(event.params._from); + let to = fetchAccount(event.params._to); + + let ids = event.params._ids; + let values = event.params._values; + + // If this equality doesn't hold (some devs actually don't follox the ERC specifications) then we just can't make + // sens of what is happening. Don't try to make something out of stupid code, and just throw the event. This + // contract doesn't follow the standard anyway. + if (ids.length == values.length) { + for (let i = 0; i < ids.length; ++i) { + registerTransfer( + event, + "/".concat(i.toString()), + contract, + operator, + from, + to, + ids[i], + values[i] + ); + } + } +} + +export function handleApprovalForAll(event: ApprovalForAllEvent): void { + let contract = fetchERC1155(event.address); + let owner = fetchAccount(event.params._owner); + let operator = fetchAccount(event.params._operator); + let delegation = fetchERC721Operator(contract, owner, operator); + delegation.approved = event.params._approved; + delegation.save(); +} + +export function handleURI(event: URIEvent): void { + let contract = fetchERC1155(event.address); + let token = fetchERC1155Token(contract, event.params._id); + token.uri = replaceURI(event.params._value, event.params._id); + token.save(); +} + +export function handleNewSeriesStarted(event: NewSeriesStarted): void { + let series = new Generation(event.params.id.toString()); + series.amount = event.params.amount.toI32(); + series.save(); +} diff --git a/src/diamonds/fakeGotchisNFT.ts b/src/diamonds/fakeGotchisNFT.ts new file mode 100644 index 0000000..e738907 --- /dev/null +++ b/src/diamonds/fakeGotchisNFT.ts @@ -0,0 +1,358 @@ +import { + ERC721Transfer, + MetadataActionLog, + MetadataDecline, + MetadataFlag, + MetadataLike, + ReviewPass +} from "../../generated/schema"; + +import { + MetadataActionLog as MetadataActionLogEvent, + MetadataLike as MetadataLikeEvent, + MetadataDecline as MetadataDeclineEvent, + ReviewPass as ReviewPassEvent, + Approval as ApprovalEvent, + ApprovalForAll as ApprovalForAllEvent, + Transfer as TransferEvent, + MetadataFlag as MetadataFlagEvent +} from "../../generated/FAKEGotchisNFTDiamond/IERC721"; +import { events, transactions } from "@amxx/graphprotocol-utils"; + +import { + addToOwnersIfNotExists, + fetchAccount, + removeFromOwnersIfExistsAndBalanceNotZero, + updateAccountStatsFrom, + updateAccountStatsTo, + updateTotalStatsBurn, + updateTotalStatsMint +} from "../fetch/account"; + +import { + METADATA_STATUS_APPROVED, + METADATA_STATUS_DECLINED, + METADATA_STATUS_PAUSED, + METADATA_STATUS_PENDING +} from "../constants"; + +import { + fetchERC721, + fetchERC721Token, + fetchERC721Operator +} from "../fetch/erc721"; +import { BigInt } from "@graphprotocol/graph-ts"; +import { + getNFTHolder, + getOrCreateNFTStatistic, + getOrCreateStats, + isBurn, + isMint, + isTransfer +} from "../helper/entities"; + +export function handleTransfer(event: TransferEvent): void { + const isMintFlag = isMint(event); + const isBurnFlag = isBurn(event); + const isTransferFlag = isTransfer(event); + + // fetch contract + const contract = fetchERC721(event.address); + if (contract == null) { + return; + } + contract.save(); + + // fetch sender and receiver + let from = fetchAccount(event.params._from); + let to = fetchAccount(event.params._to); + + // update token owner + let token = fetchERC721Token(contract, event.params._tokenId); + token.owner = to.id; + token.save(); + + // create event entity + let ev = new ERC721Transfer(events.id(event)); + ev.emitter = contract.id; + ev.transaction = transactions.log(event).id; + ev.timestamp = event.block.timestamp; + ev.contract = contract.id; + ev.token = token.id; + ev.from = from.id; + ev.to = to.id; + ev.save(); + + // fetch metadata + let metadata = MetadataActionLog.load(token.metadata!)!; + let nftStats = getOrCreateNFTStatistic(metadata.id); + + let stats = getOrCreateStats(); + // update account entity + if (isMintFlag || isTransferFlag) { + to = updateAccountStatsTo(to, metadata.id); + to.amountTokens = to.amountTokens + 1; + + let receiver = getNFTHolder(event.params._to, metadata.id); + receiver.amount = receiver.amount + 1; + receiver.save(); + + // nftStats = updateHolderMint(nftStats, event.params._to, 1); + if (receiver.amount == 1) { + nftStats.amountHolder = nftStats.amountHolder + 1; + } + + stats = addToOwnersIfNotExists(stats, event.params._to); + } + + if (isBurnFlag || isTransferFlag) { + from = updateAccountStatsFrom(from, metadata.id); + from.amountTokens = from.amountTokens - 1; + + let sender = getNFTHolder(event.params._from, metadata.id); + sender.amount = sender.amount - 1; + sender.save(); + + if (sender.amount == 0) { + nftStats.amountHolder = nftStats.amountHolder - 1; + } + + stats = removeFromOwnersIfExistsAndBalanceNotZero( + stats, + event.params._from, + from.amountTokens + ); + } + + if (isMintFlag) { + stats = updateTotalStatsMint(stats, metadata); + + nftStats.totalSupply = nftStats.totalSupply + 1; + let tokens = nftStats.tokenIds; + tokens.push(event.params._tokenId); + nftStats.tokenIds = tokens; + } + + if (isBurnFlag) { + stats = updateTotalStatsBurn(stats, metadata); + + nftStats.burned = nftStats.burned + 1; + nftStats.totalSupply = nftStats.totalSupply - 1; + + let tokens = nftStats.tokenIds; + let index = tokens.indexOf(event.params._tokenId); + tokens.splice(index, 1); + nftStats.tokenIds = tokens; + + token.editions = token.editions - 1; + + metadata.editions = metadata.editions - 1; + } + + nftStats.save(); + metadata.save(); + stats.save(); + to.save(); + from.save(); +} + +export function handleApproval(event: ApprovalEvent): void { + let contract = fetchERC721(event.address); + if (contract != null) { + let token = fetchERC721Token(contract, event.params._tokenId); + let owner = fetchAccount(event.params._owner); + let approved = fetchAccount(event.params._approved); + + token.owner = owner.id; + token.approval = approved.id; + + token.save(); + owner.save(); + approved.save(); + + // let ev = new Approval(events.id(event)) + // ev.emitter = contract.id + // ev.transaction = transactions.log(event).id + // ev.timestamp = event.block.timestamp + // ev.token = token.id + // ev.owner = owner.id + // ev.approved = approved.id + // ev.save() + } +} + +export function handleApprovalForAll(event: ApprovalForAllEvent): void { + let contract = fetchERC721(event.address); + if (contract != null) { + let owner = fetchAccount(event.params._owner); + let operator = fetchAccount(event.params._operator); + let delegation = fetchERC721Operator(contract, owner, operator); + + delegation.approved = event.params._approved; + + delegation.save(); + + // let ev = new ApprovalForAll(events.id(event)) + // ev.emitter = contract.id + // ev.transaction = transactions.log(event).id + // ev.timestamp = event.block.timestamp + // ev.delegation = delegation.id + // ev.owner = owner.id + // ev.operator = operator.id + // ev.approved = event.params.approved + // ev.save() + } +} + +export function handleMetadataActionLog(event: MetadataActionLogEvent): void { + let contract = fetchERC721(event.address); + if (contract != null) { + let ev = MetadataActionLog.load(event.params.id.toString()); + if (!ev) { + ev = new MetadataActionLog(event.params.id.toString()); + ev.flagCount = 0; + ev.likeCount = 0; + } + let artist = fetchAccount(event.params.metaData.artist); + let publisher = fetchAccount(event.params.metaData.publisher); + + ev.emitter = contract.id; + ev.transaction = transactions.log(event).id; + ev.timestamp = event.block.timestamp; + ev.minted = event.params.metaData.minted; + ev.artist = artist.id; + ev.artistName = event.params.metaData.artistName; + ev.createdAt = event.params.metaData.createdAt; + ev.description = event.params.metaData.description; + ev.externalLink = event.params.metaData.externalLink; + ev.fileHash = event.params.metaData.fileHash; + ev.name = event.params.metaData.name; + ev.publisher = publisher.id; + ev.publisherName = event.params.metaData.publisherName; + ev.royalty = event.params.metaData.royalty; + ev.status = event.params.metaData.status; + ev.editions = event.params.metaData.editions; + ev.fileType = event.params.metaData.fileType; + ev.thumbnailHash = event.params.metaData.thumbnailHash; + ev.thumbnailType = event.params.metaData.thumbnailType; + + ev.save(); + + if (ev.status == METADATA_STATUS_APPROVED) { + // Update Global Stats + let stats = getOrCreateStats(); + stats.totalFakeGotchiPieces = stats.totalFakeGotchiPieces + 1; + + // create tokens tokens and attach metadata + let startId = stats.tokenIdCounter; + stats.tokenIdCounter = stats.tokenIdCounter + ev.editions; + for (let i = 0; i < ev.editions; i++) { + let id = startId + i; + let token = fetchERC721Token(contract, BigInt.fromI32(id)); + token.metadata = ev.id; + token.owner = ev.publisher!; + token.contract = event.address; + token.artist = event.params.metaData.artist; + token.artistName = event.params.metaData.artistName; + token.description = event.params.metaData.description; + token.externalLink = event.params.metaData.externalLink; + token.fileHash = event.params.metaData.fileHash; + token.name = event.params.metaData.name; + token.publisher = event.params.metaData.publisher; + token.publisherName = event.params.metaData.publisherName; + token.editions = event.params.metaData.editions; + token.fileType = event.params.metaData.fileType; + token.thumbnailHash = event.params.metaData.thumbnailHash; + token.thumbnailType = event.params.metaData.thumbnailType; + token.save(); + } + stats.save(); + } + } +} + +export function handleMetadataFlag(event: MetadataFlagEvent): void { + let metadata = MetadataActionLog.load(event.params._id.toString())!; + metadata.flagCount = metadata.flagCount + 1; + if (metadata.flagCount == 10) { + metadata.status = METADATA_STATUS_PAUSED; + } + metadata.save(); + + let flagger = fetchAccount(event.params._flaggedBy); + flagger.save(); + + let metadataflaggedEv = new MetadataFlag(events.id(event)); + let contract = fetchERC721(event.address)!; + let token = fetchERC721Token(contract, event.params._id); + metadataflaggedEv.emitter = contract.id; + metadataflaggedEv.transaction = transactions.log(event).id; + metadataflaggedEv.timestamp = event.block.timestamp; + metadataflaggedEv.token = token.id; + + metadataflaggedEv.flaggedBy = flagger.id; + metadataflaggedEv.metadata = metadata.id; + metadataflaggedEv.save(); +} + +export function handleMetadataLike(event: MetadataLikeEvent): void { + let metadata = MetadataActionLog.load(event.params._id.toString())!; + metadata.likeCount = metadata.likeCount + 1; + metadata.save(); + + let liker = fetchAccount(event.params._likedBy); + liker.save(); + + let metadatalikedEv = new MetadataLike(events.id(event)); + let contract = fetchERC721(event.address)!; + let token = fetchERC721Token(contract, event.params._id); + metadatalikedEv.emitter = contract.id; + metadatalikedEv.transaction = transactions.log(event).id; + metadatalikedEv.timestamp = event.block.timestamp; + metadatalikedEv.token = token.id; + + metadatalikedEv.likedBy = liker.id; + metadatalikedEv.metadata = metadata.id; + metadatalikedEv.save(); +} + +export function handleMetadataDecline(event: MetadataDeclineEvent): void { + let metadata = MetadataActionLog.load(event.params._id.toString())!; + metadata.status = METADATA_STATUS_DECLINED; + metadata.save(); + + let decliner = fetchAccount(event.params._declinedBy); + decliner.save(); + + let metadatalikedEv = new MetadataDecline(events.id(event)); + let contract = fetchERC721(event.address)!; + let token = fetchERC721Token(contract, event.params._id); + metadatalikedEv.emitter = contract.id; + metadatalikedEv.transaction = transactions.log(event).id; + metadatalikedEv.timestamp = event.block.timestamp; + metadatalikedEv.token = token.id; + + metadatalikedEv.declinedBy = decliner.id; + metadatalikedEv.metadata = metadata.id; + metadatalikedEv.save(); +} + +export function handleReviewPass(event: ReviewPassEvent): void { + let metadata = MetadataActionLog.load(event.params._id.toString())!; + metadata.status = METADATA_STATUS_PENDING; + metadata.save(); + + let reviewer = fetchAccount(event.params._reviewer); + reviewer.save(); + + let reviewPassed = new ReviewPass(events.id(event)); + let contract = fetchERC721(event.address)!; + let token = fetchERC721Token(contract, event.params._id); + reviewPassed.emitter = contract.id; + reviewPassed.transaction = transactions.log(event).id; + reviewPassed.timestamp = event.block.timestamp; + reviewPassed.token = token.id; + reviewPassed.reviewer = reviewer.id; + reviewPassed.metadata = metadata.id; + reviewPassed.save(); +} diff --git a/src/fetch/account.ts b/src/fetch/account.ts new file mode 100644 index 0000000..49ec43a --- /dev/null +++ b/src/fetch/account.ts @@ -0,0 +1,203 @@ +import { Address, BigInt, Bytes, json, log } from "@graphprotocol/graph-ts"; + +import { + Account, + MetadataActionLog, + NFTStatistic, + TotalStatistic +} from "../../generated/schema"; +import { BIGINT_ONE, BIGINT_ZERO } from "../constants"; +import { createJsonFromJSONObject } from "../helper/json"; + +export function fetchAccount(address: Address): Account { + let account = Account.load(address); + if (!account) { + account = new Account(address); + account.tokens = "{}"; + account.amountTokens = 0; + + account.currentUniquePiecesOwned = 0; + account.currentUniquePiecesOwnedArray = "{}"; + account.totalUniquePiecesOwned = 0; + account.totalUniquePiecesOwnedArray = "{}"; + + account.totalPiecesOwnedArray = "{}"; + + account.save(); + } + return account; +} + +export function updateAccountStatsFrom( + account: Account, + metadataId: string +): Account { + const parsedJsonCurrent = json.fromString( + account.currentUniquePiecesOwnedArray + ); + const jsonObjCurrent = parsedJsonCurrent.toObject(); + + // fetch amount of first series + const entryCurrent = jsonObjCurrent.get(metadataId); + + let newAmount = BIGINT_ONE; + if (entryCurrent) { + newAmount = entryCurrent.toBigInt().minus(BIGINT_ONE); + } + if (newAmount.equals(BIGINT_ZERO)) { + account.currentUniquePiecesOwned = account.currentUniquePiecesOwned - 1; + } + + // received on token of that series, therefore +1 + jsonObjCurrent.set(metadataId, json.fromString(newAmount.toString())); + + let newString = createJsonFromJSONObject(jsonObjCurrent); + + account.currentUniquePiecesOwnedArray = newString; + + return account; +} + +export function updateAccountStatsTo( + account: Account, + metadataId: string +): Account { + const parsedJsonTotal = json.fromString( + account.totalUniquePiecesOwnedArray + ); + const jsonObjTotal = parsedJsonTotal.toObject(); + + const parsedJsonCurrent = json.fromString( + account.currentUniquePiecesOwnedArray + ); + const jsonObjCurrent = parsedJsonCurrent.toObject(); + + if (jsonObjTotal == null || jsonObjCurrent == null) { + return account; + } + + // fetch amount of first series + const entryTotal = jsonObjTotal.get(metadataId); + const entryCurrent = jsonObjCurrent.get(metadataId); + + let newAmount = BIGINT_ONE; + if (entryCurrent) { + newAmount = entryCurrent.toBigInt().plus(BIGINT_ONE); + } + + if (!entryTotal) { + account.totalUniquePiecesOwned = account.totalUniquePiecesOwned + 1; + jsonObjTotal.set(metadataId, json.fromString(newAmount.toString())); + } + + // update currentPiecesOwned + if (newAmount.equals(BIGINT_ONE)) { + // new piece + account.currentUniquePiecesOwned = account.currentUniquePiecesOwned + 1; + } + + // received on token of that series, therefore +1 + jsonObjCurrent.set(metadataId, json.fromString(newAmount.toString())); + + // create new json object string + let newString = createJsonFromJSONObject(jsonObjTotal); + + account.totalUniquePiecesOwnedArray = newString; + + newString = createJsonFromJSONObject(jsonObjCurrent); + + account.currentUniquePiecesOwnedArray = newString; + + return account; +} + +export function updateTotalStatsMint( + stats: TotalStatistic, + metaData: MetadataActionLog +): TotalStatistic { + const parsedJsonTotal = json.fromString( + stats.totalEditionsCirculatingArray + ); + const jsonObjTotal = parsedJsonTotal.toObject(); + const element = jsonObjTotal.get(metaData.id); + if (!element) { + stats.totalEditionsCirculating = stats.totalEditionsCirculating + 1; + jsonObjTotal.set(metaData.id, json.fromString("1")); + stats.totalEditionsMinted = stats.totalEditionsMinted + 1; + } else { + const newAmount = element.toI64() + 1; + if (newAmount == 1) { + stats.totalEditionsCirculating = stats.totalEditionsCirculating + 1; + } + jsonObjTotal.set(metaData.id, json.fromString(newAmount.toString())); + } + + stats.totalEditionsCirculatingArray = createJsonFromJSONObject( + jsonObjTotal + ); + + stats.totalNFTs = stats.totalNFTs + 1; + + return stats; +} + +export function updateTotalStatsBurn( + stats: TotalStatistic, + metaData: MetadataActionLog +): TotalStatistic { + const parsedJsonTotal = json.fromString( + stats.totalEditionsCirculatingArray + ); + const jsonObjTotal = parsedJsonTotal.toObject(); + const element = jsonObjTotal.get(metaData.id); + if (element) { + const newAmount = element.toI64() - 1; + if (newAmount == 0) { + stats.totalEditionsCirculating = stats.totalEditionsCirculating - 1; + } + + jsonObjTotal.set(metaData.id, json.fromString(newAmount.toString())); + } + + stats.totalEditionsCirculatingArray = createJsonFromJSONObject( + jsonObjTotal + ); + + stats.totalNFTs = stats.totalNFTs - 1; + stats.burnedNFTs = stats.burnedNFTs + 1; + return stats; +} + +export function addToOwnersIfNotExists( + totalStats: TotalStatistic, + owner: Bytes +): TotalStatistic { + let ownersArray = totalStats.totalOwnersArray; + if (ownersArray.indexOf(owner) == -1) { + ownersArray.push(owner); + totalStats.totalOwnersArray = ownersArray; + totalStats.totalOwners = ownersArray.length; + } + + return totalStats; +} + +export function removeFromOwnersIfExistsAndBalanceNotZero( + totalStats: TotalStatistic, + owner: Bytes, + amount: i32 +): TotalStatistic { + if (amount > 0) { + return totalStats; + } + + let ownersArray = totalStats.totalOwnersArray; + let index = ownersArray.indexOf(owner); + if (index != -1) { + ownersArray.splice(index, 1); + totalStats.totalOwnersArray = ownersArray; + totalStats.totalOwners = ownersArray.length; + } + + return totalStats; +} diff --git a/src/fetch/erc1155.ts b/src/fetch/erc1155.ts new file mode 100644 index 0000000..4c6dd4a --- /dev/null +++ b/src/fetch/erc1155.ts @@ -0,0 +1,111 @@ +import { Address, BigInt } from "@graphprotocol/graph-ts"; + +import { + Account, + ERC1155Contract, + ERC1155Token, + ERC1155Balance, + ERC1155Operator, +} from "../../generated/schema"; + +import { IERC1155 } from "../../generated/FAKEGotchisCardDiamond/IERC1155"; + +import { constants } from "@amxx/graphprotocol-utils"; + +import { fetchAccount } from "./account"; + +export function replaceURI(uri: string, identifier: BigInt): string { + return uri.replaceAll( + "{id}", + identifier + .toHex() + .slice(2) + .padStart(64, "0") + ); +} + +export function fetchERC1155(address: Address): ERC1155Contract { + let contract = ERC1155Contract.load(address); + if (!contract) { + contract = new ERC1155Contract(address); + contract.asAccount = address; + contract.save(); + + let account = fetchAccount(address); + account.asERC1155 = address; + account.save(); + } + + return contract; +} + +export function fetchERC1155Token( + contract: ERC1155Contract, + identifier: BigInt +): ERC1155Token { + let id = contract.id + .toHex() + .concat("/") + .concat(identifier.toHex()); + let token = ERC1155Token.load(id); + + if (token == null) { + let erc1155 = IERC1155.bind(Address.fromBytes(contract.id)); + let try_uri = erc1155.try_uri(identifier); + token = new ERC1155Token(id); + token.contract = contract.id; + token.identifier = identifier; + token.totalSupply = fetchERC1155Balance(token as ERC1155Token, null).id; + token.uri = try_uri.reverted + ? null + : replaceURI(try_uri.value, identifier); + token.save(); + } + + return token as ERC1155Token; +} + +export function fetchERC1155Balance( + token: ERC1155Token, + account: Account | null +): ERC1155Balance { + let id = token.id + .concat("/") + .concat(account ? account.id.toHex() : "totalSupply"); + let balance = ERC1155Balance.load(id); + + if (balance == null) { + balance = new ERC1155Balance(id); + balance.contract = token.contract; + balance.token = token.id; + balance.account = account ? account.id : null; + balance.value = constants.BIGDECIMAL_ZERO; + balance.valueExact = constants.BIGINT_ZERO; + balance.save(); + } + + return balance as ERC1155Balance; +} + +export function fetchERC721Operator( + contract: ERC1155Contract, + owner: Account, + operator: Account +): ERC1155Operator { + let id = contract.id + .toHex() + .concat("/") + .concat(owner.id.toHex()) + .concat("/") + .concat(operator.id.toHex()); + let op = ERC1155Operator.load(id); + + if (op == null) { + op = new ERC1155Operator(id); + op.contract = contract.id; + op.owner = owner.id; + op.operator = operator.id; + } + + return op as ERC1155Operator; +} diff --git a/src/fetch/erc165.ts b/src/fetch/erc165.ts new file mode 100644 index 0000000..41d3bb3 --- /dev/null +++ b/src/fetch/erc165.ts @@ -0,0 +1,13 @@ +import { ethereum, Bytes } from '@graphprotocol/graph-ts' + +export function supportsInterface(contract: ethereum.SmartContract, interfaceId: String, expected: boolean = true): boolean { + let result = ethereum.call(new ethereum.SmartContractCall( + contract._name, // '', + contract._address, // address, + 'supportsInterface', // '', + 'supportsInterface(bytes4):(bool)', + [ethereum.Value.fromFixedBytes(Bytes.fromHexString(interfaceId) as Bytes)] + )) + + return result != null && (result as Array)[0].toBoolean() == expected +} diff --git a/src/fetch/erc721.ts b/src/fetch/erc721.ts new file mode 100644 index 0000000..02e85c4 --- /dev/null +++ b/src/fetch/erc721.ts @@ -0,0 +1,125 @@ +import { + Address, + BigInt, + Bytes, + JSONValue, + TypedMap +} from "@graphprotocol/graph-ts"; + +import { + Account, + ERC721Contract, + ERC721Token, + ERC721Operator +} from "../../generated/schema"; + +import { constants } from "@amxx/graphprotocol-utils"; + +import { fetchAccount } from "./account"; +import { IERC721 } from "../../generated/FAKEGotchisNFTDiamond/IERC721"; + +export function fetchERC721(address: Address): ERC721Contract | null { + let erc721 = IERC721.bind(address); + + // Try load entry + let contract = ERC721Contract.load(address); + if (contract != null) { + return contract; + } + + // Detect using ERC165 + let detectionId = address.concat(Bytes.fromHexString("80ac58cd")); // Address + ERC721 + let detectionAccount = Account.load(detectionId); + + // On missing cache + if (detectionAccount == null) { + detectionAccount = new Account(detectionId); + detectionAccount.tokens = "{}"; + let introspection_01ffc9a7 = true; + let introspection_80ac58cd = true; + let introspection_00000000 = true; + let isERC721 = + introspection_01ffc9a7 && + introspection_80ac58cd && + introspection_00000000; + detectionAccount.asERC721 = isERC721 ? address : null; + + detectionAccount.amountTokens = 0; + + detectionAccount.currentUniquePiecesOwned = 0; + detectionAccount.currentUniquePiecesOwnedArray = "{}"; + detectionAccount.totalUniquePiecesOwned = 0; + detectionAccount.totalUniquePiecesOwnedArray = "{}"; + + detectionAccount.totalPiecesOwnedArray = "{}"; + + detectionAccount.save(); + } + + // If an ERC721, build entry + if (detectionAccount.asERC721) { + contract = new ERC721Contract(address); + let try_name = erc721.try_name(); + let try_symbol = erc721.try_symbol(); + contract.name = try_name.reverted ? "" : try_name.value; + contract.symbol = try_symbol.reverted ? "" : try_symbol.value; + contract.supportsMetadata = true; + contract.asAccount = address; + contract.save(); + + let account = fetchAccount(address); + account.asERC721 = address; + account.save(); + } + + return contract; +} + +export function fetchERC721Token( + contract: ERC721Contract, + identifier: BigInt +): ERC721Token { + let id = contract.id + .toHex() + .concat("/") + .concat(identifier.toHex()); + let token = ERC721Token.load(id); + + if (token == null) { + token = new ERC721Token(id); + token.contract = contract.id; + token.identifier = identifier; + token.approval = fetchAccount(constants.ADDRESS_ZERO).id; + + if (contract.supportsMetadata) { + let erc721 = IERC721.bind(Address.fromBytes(contract.id)); + let try_tokenURI = erc721.try_tokenURI(identifier); + token.uri = try_tokenURI.reverted ? "" : try_tokenURI.value; + } + } + + return token as ERC721Token; +} + +export function fetchERC721Operator( + contract: ERC721Contract, + owner: Account, + operator: Account +): ERC721Operator { + let id = contract.id + .toHex() + .concat("/") + .concat(owner.id.toHex()) + .concat("/") + .concat(operator.id.toHex()); + let op = ERC721Operator.load(id); + + if (op == null) { + op = new ERC721Operator(id); + op.contract = contract.id; + op.owner = owner.id; + op.operator = operator.id; + } + + return op as ERC721Operator; +} diff --git a/src/helper/entities.ts b/src/helper/entities.ts new file mode 100644 index 0000000..74a69db --- /dev/null +++ b/src/helper/entities.ts @@ -0,0 +1,88 @@ +import { Address, BigInt, Bytes, ethereum } from "@graphprotocol/graph-ts"; +import { Transfer } from "../../generated/FAKEGotchisNFTDiamond/IERC721"; +import { + NFTHolder, + NFTStatistic, + TotalStatistic +} from "../../generated/schema"; +import { ADDRESS_BURN, ADDRESS_DEAD, ADDRESS_ZERO } from "../constants"; + +// export function getOrCreateCard(id: BigInt): Card + +export function getOrCreateStats(): TotalStatistic { + let stat = TotalStatistic.load("0"); + if (!stat) { + stat = new TotalStatistic("0"); + stat.burnedCards = 0; + stat.burnedNFTs = 0; + stat.totalNFTs = 0; + stat.totalOwners = 0; + stat.totalFakeGotchiPieces = 0; + stat.totalNFTsArray = "{}"; + stat.totalOwnersArray = new Array(); + stat.tokenIdCounter = 0; + stat.totalEditionsCirculating = 0; + stat.totalEditionsMinted = 0; + stat.totalEditionsCirculatingArray = "{}"; + } + + return stat; +} + +export function getOrCreateNFTStatistic(metadataId: string): NFTStatistic { + let stat = NFTStatistic.load(metadataId); + if (!stat) { + stat = new NFTStatistic(metadataId); + stat.burned = 0; + stat.metadata = metadataId; + stat.amountHolder = 0; + stat.totalSupply = 0; + stat.tokenIds = new Array(); + } + + return stat; +} + +export function getNFTHolder( + holderAddress: Address, + metadataId: string +): NFTHolder { + let id = holderAddress.toHexString() + "-" + metadataId; + let holder = NFTHolder.load(id); + if (!holder) { + holder = new NFTHolder(id); + holder.amount = 0; + holder.holder = holderAddress; + holder.nftStats = metadataId; + } + + return holder; +} + +export function isMint(event: Transfer): boolean { + let from = event.params._from; + + if ([ADDRESS_ZERO, ADDRESS_BURN].indexOf(from) !== -1) { + return true; + } + + return false; +} + +export function isBurn(event: Transfer): boolean { + let to = event.params._to; + + if ([ADDRESS_ZERO, ADDRESS_BURN, ADDRESS_DEAD].indexOf(to) !== -1) { + return true; + } + + return false; +} + +export function isTransfer(event: Transfer): boolean { + if (!isBurn(event) && !isMint(event)) { + return true; + } + + return false; +} diff --git a/src/helper/json.ts b/src/helper/json.ts new file mode 100644 index 0000000..a083fcc --- /dev/null +++ b/src/helper/json.ts @@ -0,0 +1,27 @@ +import { + BigInt, + json, + JSONValueKind, + JSONValue, + log +} from "@graphprotocol/graph-ts"; +import { TypedMap } from "@graphprotocol/graph-ts"; + +export function createJsonFromJSONObject( + obj: TypedMap +): string { + let newString = "{"; + for (let i = 0; i < obj.entries.length; i++) { + let key = obj.entries[i].key; + let value = obj.entries[i].value; + + if (i != 0) { + newString += ","; + } + + newString += `"${key.toString()}":${value.toBigInt().toString()}`; + } + newString += "}"; + + return newString; +} diff --git a/src/ownable.ts b/src/ownable.ts new file mode 100644 index 0000000..f03af27 --- /dev/null +++ b/src/ownable.ts @@ -0,0 +1,27 @@ +import { OwnershipTransferred } from "@openzeppelin/subgraphs/generated/schema"; + +import { OwnershipTransferred as OwnershipTransferredEvent } from "@openzeppelin/subgraphs/generated/ownable/Ownable"; + +import { events, transactions } from "@amxx/graphprotocol-utils"; + +import { fetchAccount } from "./fetch/account"; + +import { fetchOwnable } from "@openzeppelin/subgraphs/src/fetch/ownable"; + +export function handleOwnershipTransferred( + event: OwnershipTransferredEvent +): void { + let contract = fetchOwnable(event.address); + let owner = fetchAccount(event.params.newOwner); + + contract.owner = owner.id; + contract.save(); + + let ev = new OwnershipTransferred(events.id(event)); + ev.emitter = contract.id; + ev.transaction = transactions.log(event).id; + ev.timestamp = event.block.timestamp; + ev.contract = contract.id; + ev.owner = owner.id; + ev.save(); +} diff --git a/subgraph.mumbai.yaml b/subgraph.mumbai.yaml index a053da8..0f18bb5 100644 --- a/subgraph.mumbai.yaml +++ b/subgraph.mumbai.yaml @@ -243,3 +243,63 @@ dataSources: - event: KinshipBurned(uint256,uint256) handler: handleKinshipBurned file: ./src/mappings/diamond.ts + - kind: ethereum/contract + name: FAKEGotchisCardDiamond + network: mumbai + source: + address: "0x118c19F39a4Ad9032B7b7b228A2Cd927d3FddA13" + abi: IERC1155 + startBlock: 28400000 + mapping: + kind: ethereum/events + apiVersion: 0.0.5 + language: wasm/assemblyscript + entities: + - Card + abis: + - name: IERC721 + file: ./abis/diamond_erc721.json + - name: IERC1155 + file: ./abis/diamond_erc1155.json + eventHandlers: + - event: NewSeriesStarted(indexed uint256,indexed uint256) + handler: handleNewSeriesStarted + - event: TransferSingle(indexed address,indexed address,indexed address,uint256,uint256) + handler: handleTransferSingle + - event: TransferBatch(indexed address,indexed address,indexed address,uint256[],uint256[]) + handler: handleTransferBatch + - event: URI(string,indexed uint256) + handler: handleURI + file: ./src/diamonds/fakeGotchisCard.ts + - kind: ethereum/contract + name: FAKEGotchisNFTDiamond + network: mumbai + source: + address: "0x330088c3372f4F78cF023DF16E1e1564109191dc" + abi: IERC721 + startBlock: 28400000 + mapping: + kind: ethereum/events + apiVersion: 0.0.5 + language: wasm/assemblyscript + entities: + - NFT + abis: + - name: IERC721 + file: ./abis/diamond_erc721.json + - name: IERC1155 + file: ./abis/diamond_erc1155.json + eventHandlers: + - event: Transfer(indexed address,indexed address,indexed uint256) + handler: handleTransfer + - event: MetadataActionLog(indexed uint256,(address,uint16[2],uint16,uint32,uint32,address,uint40,uint8,bool,string,string,string,string,string,string,string,string,string)) + handler: handleMetadataActionLog + - event: MetadataFlag(indexed uint256,address) + handler: handleMetadataFlag + - event: MetadataLike(indexed uint256,address) + handler: handleMetadataLike + - event: ReviewPass(indexed uint256,address) + handler: handleReviewPass + - event: MetadataDecline(indexed uint256,address) + handler: handleMetadataDecline + file: ./src/diamonds/fakeGotchisNFT.ts \ No newline at end of file diff --git a/subgraph.yaml b/subgraph.yaml index 15504e2..9634895 100644 --- a/subgraph.yaml +++ b/subgraph.yaml @@ -243,3 +243,63 @@ dataSources: - event: KinshipBurned(uint256,uint256) handler: handleKinshipBurned file: ./src/mappings/diamond.ts + - kind: ethereum/contract + name: FAKEGotchisCardDiamond + network: matic + source: + address: "0x9f6BcC63e86D44c46e85564E9383E650dc0b56D7" + abi: IERC1155 + startBlock: 34520146 + mapping: + kind: ethereum/events + apiVersion: 0.0.6 + language: wasm/assemblyscript + entities: + - Card + abis: + - name: IERC721 + file: ./abis/diamond_erc721.json + - name: IERC1155 + file: ./abis/diamond_erc1155.json + eventHandlers: + - event: NewSeriesStarted(indexed uint256,indexed uint256) + handler: handleNewSeriesStarted + - event: TransferSingle(indexed address,indexed address,indexed address,uint256,uint256) + handler: handleTransferSingle + - event: TransferBatch(indexed address,indexed address,indexed address,uint256[],uint256[]) + handler: handleTransferBatch + - event: URI(string,indexed uint256) + handler: handleURI + file: ./src/diamonds/fakeGotchisCard.ts + - kind: ethereum/contract + name: FAKEGotchisNFTDiamond + network: matic + source: + address: "0xA4E3513c98b30d4D7cc578d2C328Bd550725D1D0" + abi: IERC721 + startBlock: 34520176 + mapping: + kind: ethereum/events + apiVersion: 0.0.6 + language: wasm/assemblyscript + entities: + - NFT + abis: + - name: IERC721 + file: ./abis/diamond_erc721.json + - name: IERC1155 + file: ./abis/diamond_erc1155.json + eventHandlers: + - event: Transfer(indexed address,indexed address,indexed uint256) + handler: handleTransfer + - event: MetadataActionLog(indexed uint256,(address,uint16[2],uint16,uint32,uint32,address,uint40,uint8,bool,string,string,string,string,string,string,string,string,string)) + handler: handleMetadataActionLog + - event: MetadataFlag(indexed uint256,address) + handler: handleMetadataFlag + - event: MetadataLike(indexed uint256,address) + handler: handleMetadataLike + - event: ReviewPass(indexed uint256,address) + handler: handleReviewPass + - event: MetadataDecline(indexed uint256,address) + handler: handleMetadataDecline + file: ./src/diamonds/fakeGotchisNFT.ts diff --git a/tests/handleERC721ExecutedListing.test.ts b/tests/handleERC721ExecutedListing.test.ts index 38dd74e..09c16c8 100644 --- a/tests/handleERC721ExecutedListing.test.ts +++ b/tests/handleERC721ExecutedListing.test.ts @@ -43,7 +43,7 @@ test("handleERC721Listing - should add price to historicalPrices of aavegotchi i gotchi.gotchiId = BIGINT_ONE; gotchi.kinship = BIGINT_ZERO; gotchi.gotchiId = BIGINT_ONE; - gotchi.portal = "1"; + // gotchi.portal = "1"; gotchi.hauntId = BIGINT_ONE; gotchi.name = "Test"; gotchi.nameLowerCase = "test"; @@ -139,7 +139,7 @@ test("handleERC721Listing - should set blockCreated to block number when listing gotchi.gotchiId = BIGINT_ONE; gotchi.kinship = BIGINT_ZERO; gotchi.gotchiId = BIGINT_ONE; - gotchi.portal = "1"; + // gotchi.portal = "1"; gotchi.hauntId = BIGINT_ONE; gotchi.name = "Test"; gotchi.nameLowerCase = "test"; @@ -201,7 +201,7 @@ test("handleERC721Listing - reorg: should set block created if cancel events hap gotchi.gotchiId = BIGINT_ONE; gotchi.kinship = BIGINT_ZERO; gotchi.gotchiId = BIGINT_ONE; - gotchi.portal = "1"; + // gotchi.portal = "1"; gotchi.hauntId = BIGINT_ONE; gotchi.name = "Test"; gotchi.nameLowerCase = "test"; diff --git a/tests/handleERC721ListingAdded.test.ts b/tests/handleERC721ListingAdded.test.ts index 2bc4915..df225ca 100644 --- a/tests/handleERC721ListingAdded.test.ts +++ b/tests/handleERC721ListingAdded.test.ts @@ -29,7 +29,7 @@ test("should add gotchi name lower case if token is an aavegtochi", () => { gotchi.gotchiId = BIGINT_ONE; gotchi.kinship = BIGINT_ZERO; gotchi.gotchiId = BIGINT_ONE; - gotchi.portal = "1"; + // gotchi.portal = "1"; gotchi.hauntId = BIGINT_ONE; gotchi.name = "Test"; gotchi.nameLowerCase = "test"; diff --git a/tests/handleEquip.test.ts b/tests/handleEquip.test.ts index 96b29ce..73563b0 100644 --- a/tests/handleEquip.test.ts +++ b/tests/handleEquip.test.ts @@ -19,7 +19,7 @@ test("should update withSetsRarityScore", () => { gotchi.gotchiId = BIGINT_ONE; gotchi.kinship = BIGINT_ZERO; gotchi.gotchiId = BIGINT_ONE; - gotchi.portal = "1"; + // gotchi.portal = "1"; gotchi.hauntId = BIGINT_ONE; gotchi.name = "Test"; gotchi.nameLowerCase = "test"; diff --git a/tests/handleInteract.test.ts b/tests/handleInteract.test.ts index 697540d..4cb09d3 100644 --- a/tests/handleInteract.test.ts +++ b/tests/handleInteract.test.ts @@ -25,7 +25,7 @@ test("Count as interacted if gotchi is claimed", () => { gotchi.gotchiId = BIGINT_ONE; gotchi.kinship = BIGINT_ZERO; gotchi.gotchiId = BIGINT_ONE; - gotchi.portal = "1"; + // gotchi.portal = "1"; gotchi.hauntId = BIGINT_ONE; gotchi.name = "Test"; gotchi.nameLowerCase = "Test"; diff --git a/tests/handleSetAavegotchiName.test.ts b/tests/handleSetAavegotchiName.test.ts index 0cbf020..085a062 100644 --- a/tests/handleSetAavegotchiName.test.ts +++ b/tests/handleSetAavegotchiName.test.ts @@ -20,7 +20,7 @@ test("should update nameToLower on Listing entity of Aavegotchi", () => { gotchi.gotchiId = BIGINT_ONE; gotchi.kinship = BIGINT_ZERO; gotchi.gotchiId = BIGINT_ONE; - gotchi.portal = "1"; + // gotchi.portal = "1"; gotchi.hauntId = BIGINT_ONE; gotchi.name = "Test"; gotchi.nameLowerCase = "test"; diff --git a/tests/handleSpendSkillpoints.test.ts b/tests/handleSpendSkillpoints.test.ts index 76d1fc7..8627510 100644 --- a/tests/handleSpendSkillpoints.test.ts +++ b/tests/handleSpendSkillpoints.test.ts @@ -18,7 +18,7 @@ test("should update withSetsRarityScore", () => { gotchi.gotchiId = BIGINT_ONE; gotchi.kinship = BIGINT_ZERO; gotchi.gotchiId = BIGINT_ONE; - gotchi.portal = "1"; + // gotchi.portal = "1"; gotchi.hauntId = BIGINT_ONE; gotchi.name = "Test"; gotchi.nameLowerCase = "test"; diff --git a/tests/handleTransfer.test.ts b/tests/handleTransfer.test.ts new file mode 100644 index 0000000..2a23b64 --- /dev/null +++ b/tests/handleTransfer.test.ts @@ -0,0 +1,280 @@ +import { + Address, + BigInt, + Bytes, + ethereum, + store, +} from "@graphprotocol/graph-ts"; +import { + describe, + test, + beforeAll, + newMockEvent, + assert, + createMockedFunction, +} from "matchstick-as/assembly/index"; +import { Transfer } from "../generated/FAKEGotchisNFTDiamond/IERC721"; +import { + Account, + ERC721Token, + MetadataActionLog, + NFTHolder, + NFTStatistic, + Transaction, +} from "../generated/schema"; +import { + ADDRESS_DEAD, + ADDRESS_ZERO, + BIGINT_ONE, + BIGINT_ZERO, +} from "../src/constants"; +import { handleTransfer } from "../src/diamonds/fakeGotchisNFT"; + +export function createTransferEvent( + from: string, + to: string, + tokenId: i32 +): Transfer { + let mockEvent = newMockEvent(); + let event = new Transfer( + mockEvent.address, + mockEvent.logIndex, + mockEvent.transactionLogIndex, + mockEvent.logType, + mockEvent.block, + mockEvent.transaction, + mockEvent.parameters, + null + ); + event.parameters = new Array(); + let fromAddress = new ethereum.EventParam( + "_from", + ethereum.Value.fromAddress(Address.fromString(from)) + ); + let toAddress = new ethereum.EventParam( + "_to", + ethereum.Value.fromAddress(Address.fromString(to)) + ); + let tokenIdNumber = new ethereum.EventParam( + "_tokenId", + ethereum.Value.fromI32(tokenId) + ); + + event.parameters.push(fromAddress); + event.parameters.push(toAddress); + event.parameters.push(tokenIdNumber); + + return event; +} + +const sender = "0xacb0ba5da1101f204356420f87e1f1047ac65c8c"; +const receiver = "0x46a3a41bd932244dd08186e4c19f1a7e48cbcdf4"; +const tokenId = 1; +const event = createTransferEvent(sender, receiver, tokenId); + +describe("handleTransfer", () => { + beforeAll(() => { + const transaction = new Transaction("abc"); + const log = new MetadataActionLog("1"); + log.emitter = Bytes.fromHexString(sender); + log.transaction = transaction.id; + log.timestamp = BIGINT_ZERO; + log.editions = 1; + + const tokenEntityId = event.transaction + .to!.toHex() + .concat("/") + .concat(BIGINT_ONE.toHex()); + const token = new ERC721Token(tokenEntityId); + token.metadata = "1"; + token.contract = ADDRESS_DEAD; + token.identifier = BIGINT_ONE; + token.owner = ADDRESS_DEAD; + token.approval = ADDRESS_ZERO; + token.editions = 0; + + const senderAccount = new Account(Bytes.fromHexString(sender)); + senderAccount.totalPiecesOwnedArray = "{}"; + senderAccount.totalUniquePiecesOwnedArray = "{}"; + senderAccount.totalUniquePiecesOwned = 0; + senderAccount.currentUniquePiecesOwned = 0; + senderAccount.currentUniquePiecesOwnedArray = "{}"; + senderAccount.tokens = "{}"; + senderAccount.amountTokens = 0; + + const holder = new NFTHolder( + "0x46a3a41bd932244dd08186e4c19f1a7e48cbcdf4-1" + ); + holder.amount = 0; + holder.holder = Address.fromString(receiver); + holder.nftStats = "1"; + + store.set("MetadataActionLog", "1", log); + store.set("ERC721Token", tokenEntityId, token); + store.set("Account", sender, senderAccount); + // store.set("NFTStatistic", "1", nftStats); + store.set( + "NFTHolder", + "0x46a3a41bd932244dd08186e4c19f1a7e48cbcdf4-1", + holder + ); + + createMockedFunction( + event.transaction.to!, + "name", + "name():(string)" + ).returns([ethereum.Value.fromString("Ghost")]); + + createMockedFunction( + event.transaction.to!, + "symbol", + "symbol():(string)" + ).returns([ethereum.Value.fromString("GHST")]); + + createMockedFunction( + event.transaction.to!, + "tokenURI", + "tokenURI(uint256):(string)" + ) + .withArgs([ethereum.Value.fromUnsignedBigInt(BIGINT_ONE)]) + .returns([ethereum.Value.fromString("https://app.aavegotchi.com")]); + + createMockedFunction( + event.transaction.to!, + "tokenURI", + "tokenURI(uint256):(string)" + ) + .withArgs([ + ethereum.Value.fromUnsignedBigInt(BIGINT_ONE.plus(BIGINT_ONE)), + ]) + .returns([ethereum.Value.fromString("https://app.aavegotchi.com")]); + }); + + test("it should update total, nft and holder stats if tx is mint", () => { + const event = createTransferEvent( + ADDRESS_ZERO.toHexString(), + receiver, + tokenId + ); + handleTransfer(event); + + // total stats + assert.fieldEquals( + "TotalStatistic", + "0", + "totalEditionsCirculating", + "1" + ); + assert.fieldEquals("TotalStatistic", "0", "totalEditionsMinted", "1"); + assert.fieldEquals("TotalStatistic", "0", "totalNFTs", "1"); + assert.fieldEquals("TotalStatistic", "0", "burnedNFTs", "0"); + assert.fieldEquals("TotalStatistic", "0", "totalOwners", "1"); + + // nft stats + assert.fieldEquals("NFTStatistic", "1", "burned", "0"); + assert.fieldEquals("NFTStatistic", "1", "amountHolder", "1"); + assert.fieldEquals("NFTStatistic", "1", "totalSupply", "1"); + assert.fieldEquals("NFTStatistic", "1", "metadata", "1"); + assert.fieldEquals("NFTStatistic", "1", "tokenIds", "[1]"); + + // NFT Holder Stats + let idSender = receiver + "-1"; + assert.fieldEquals("NFTHolder", idSender, "holder", receiver); + assert.fieldEquals("NFTHolder", idSender, "amount", "1"); + assert.fieldEquals("NFTHolder", idSender, "nftStats", "1"); + + // account stats + assert.fieldEquals("Account", receiver, "totalUniquePiecesOwned", "1"); + assert.fieldEquals( + "Account", + receiver, + "currentUniquePiecesOwned", + "1" + ); + }); + + test("it should update total, nft and holder stats if tx is transfer", () => { + const event = createTransferEvent(receiver, sender, tokenId); + handleTransfer(event); + + // Total Stats + assert.fieldEquals( + "TotalStatistic", + "0", + "totalEditionsCirculating", + "1" + ); + assert.fieldEquals("TotalStatistic", "0", "totalEditionsMinted", "1"); + assert.fieldEquals("TotalStatistic", "0", "totalNFTs", "1"); + assert.fieldEquals("TotalStatistic", "0", "burnedNFTs", "0"); + assert.fieldEquals("TotalStatistic", "0", "totalOwners", "1"); + + // NFT Stats + assert.fieldEquals("NFTStatistic", "1", "burned", "0"); + assert.fieldEquals("NFTStatistic", "1", "amountHolder", "1"); + assert.fieldEquals("NFTStatistic", "1", "totalSupply", "1"); + assert.fieldEquals("NFTStatistic", "1", "metadata", "1"); + assert.fieldEquals("NFTStatistic", "1", "tokenIds", "[1]"); + + // NFT Holder Stats + let idSender = receiver + "-1"; + assert.fieldEquals("NFTHolder", idSender, "holder", receiver); + assert.fieldEquals("NFTHolder", idSender, "amount", "0"); + assert.fieldEquals("NFTHolder", idSender, "nftStats", "1"); + + let idReceiver = sender + "-1"; + assert.fieldEquals("NFTHolder", idReceiver, "holder", sender); + assert.fieldEquals("NFTHolder", idReceiver, "amount", "1"); + assert.fieldEquals("NFTHolder", idReceiver, "nftStats", "1"); + + // Account + assert.fieldEquals("Account", receiver, "totalUniquePiecesOwned", "1"); + assert.fieldEquals( + "Account", + receiver, + "currentUniquePiecesOwned", + "0" + ); + + assert.fieldEquals("Account", sender, "totalUniquePiecesOwned", "1"); + assert.fieldEquals("Account", sender, "currentUniquePiecesOwned", "1"); + }); + + test("it should update total, nft and holder stats if tx is burn", () => { + const event = createTransferEvent( + sender, + ADDRESS_ZERO.toHexString(), + tokenId + ); + handleTransfer(event); + + // Total Stats + assert.fieldEquals( + "TotalStatistic", + "0", + "totalEditionsCirculating", + "0" + ); + assert.fieldEquals("TotalStatistic", "0", "totalEditionsMinted", "1"); + assert.fieldEquals("TotalStatistic", "0", "totalNFTs", "0"); + assert.fieldEquals("TotalStatistic", "0", "burnedNFTs", "1"); + assert.fieldEquals("TotalStatistic", "0", "totalOwners", "0"); + + // NFT Stats + assert.fieldEquals("NFTStatistic", "1", "burned", "1"); + assert.fieldEquals("NFTStatistic", "1", "amountHolder", "0"); + assert.fieldEquals("NFTStatistic", "1", "totalSupply", "0"); + assert.fieldEquals("NFTStatistic", "1", "metadata", "1"); + assert.fieldEquals("NFTStatistic", "1", "tokenIds", "[]"); + + // NFT Holder Stats + let idSender = sender + "-1"; + assert.fieldEquals("NFTHolder", idSender, "holder", sender); + assert.fieldEquals("NFTHolder", idSender, "amount", "0"); + assert.fieldEquals("NFTHolder", idSender, "nftStats", "1"); + + // Account + assert.fieldEquals("Account", sender, "totalUniquePiecesOwned", "1"); + assert.fieldEquals("Account", sender, "currentUniquePiecesOwned", "0"); + }); +}); diff --git a/tests/handleTransferERC721.test.ts b/tests/handleTransferERC721.test.ts index 3b16fdf..7701f90 100644 --- a/tests/handleTransferERC721.test.ts +++ b/tests/handleTransferERC721.test.ts @@ -114,7 +114,7 @@ test("handleTransferERC721 - should change owner of aavegotchi entity if token i gotchi.gotchiId = BIGINT_ONE; gotchi.kinship = BIGINT_ZERO; gotchi.gotchiId = BIGINT_ONE; - gotchi.portal = "1"; + // gotchi.portal = "1"; gotchi.hauntId = BIGINT_ONE; gotchi.name = "Test"; gotchi.nameLowerCase = "test"; @@ -217,7 +217,7 @@ test("handleTransferERC721 - should set owner to 0x0 of aavegotchi entity if got gotchi.gotchiId = BIGINT_ONE; gotchi.kinship = BIGINT_ZERO; gotchi.gotchiId = BIGINT_ONE; - gotchi.portal = "1"; + // gotchi.portal = "1"; gotchi.hauntId = BIGINT_ONE; gotchi.name = "Test"; gotchi.nameLowerCase = "test"; diff --git a/tests/handleUseConsumable.test.ts b/tests/handleUseConsumable.test.ts index 348ab1c..d1c7475 100644 --- a/tests/handleUseConsumable.test.ts +++ b/tests/handleUseConsumable.test.ts @@ -18,7 +18,7 @@ test("handleUseConsumable - happy case", () => { gotchi.locked = true; gotchi.gotchiId = BIGINT_ONE; gotchi.kinship = BIGINT_ZERO; - gotchi.portal = "1"; + // gotchi.portal = "1"; gotchi.hauntId = BIGINT_ONE; gotchi.name = "Test"; gotchi.nameLowerCase = "test"; diff --git a/yarn.lock b/yarn.lock index d239ba9..a304397 100644 --- a/yarn.lock +++ b/yarn.lock @@ -32,6 +32,14 @@ "@jridgewell/gen-mapping" "^0.3.0" "@jridgewell/trace-mapping" "^0.3.9" +"@amxx/graphprotocol-utils@^1.1.0": + version "1.1.0" + resolved "https://registry.yarnpkg.com/@amxx/graphprotocol-utils/-/graphprotocol-utils-1.1.0.tgz#2e947df618adfc44f620eac8121f6def32f250e7" + integrity sha512-oVHp/EMNyl2c54n+EmTzDweQ3yuHGAyIEesIMYOu+lMBUFRgLDKBhrp9c4XB4zJ6JKs0DsCxuKuN7CIjweIjdg== + dependencies: + "@graphprotocol/graph-ts" "^0.26.0" + yargs "^17.5.1" + "@babel/code-frame@^7.0.0", "@babel/code-frame@^7.12.13", "@babel/code-frame@^7.22.13": version "7.22.13" resolved "https://registry.yarnpkg.com/@babel/code-frame/-/code-frame-7.22.13.tgz#e3c1c099402598483b7a8c46a721d1038803755e" @@ -727,6 +735,13 @@ dependencies: assemblyscript "0.19.10" +"@graphprotocol/graph-ts@^0.26.0": + version "0.26.0" + resolved "https://registry.yarnpkg.com/@graphprotocol/graph-ts/-/graph-ts-0.26.0.tgz#576f995531eebaca4374901aeaff499219e382e8" + integrity sha512-GW/emOJl+35MXgmIxTnUK7dJtPCaB9u5aAwoLVqJ8swogC794O92UrXMVrAJsherUriu+yI9bLMGmNPOIi60jw== + dependencies: + assemblyscript "0.19.10" + "@ipld/dag-cbor@^7.0.0": version "7.0.3" resolved "https://registry.yarnpkg.com/@ipld/dag-cbor/-/dag-cbor-7.0.3.tgz#aa31b28afb11a807c3d627828a344e5521ac4a1e" @@ -2133,6 +2148,15 @@ cliui@^7.0.2: strip-ansi "^6.0.0" wrap-ansi "^7.0.0" +cliui@^8.0.1: + version "8.0.1" + resolved "https://registry.yarnpkg.com/cliui/-/cliui-8.0.1.tgz#0c04b075db02cbfe60dc8e6cf2f5486b1a3608aa" + integrity sha512-BSeNnyus75C4//NQ9gQt1/csTXyo/8Sb+afLAkzAptFuMsod9HFokGNudZpi/oQV73hnVK+sR+5PVRMd+Dr7YQ== + dependencies: + string-width "^4.2.0" + strip-ansi "^6.0.1" + wrap-ansi "^7.0.0" + clone@^1.0.2: version "1.0.4" resolved "https://registry.yarnpkg.com/clone/-/clone-1.0.4.tgz#da309cc263df15994c688ca902179ca3c7cd7c7e" @@ -6079,7 +6103,7 @@ yargs-parser@^20.2.2: resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-20.2.9.tgz#2eb7dc3b0289718fc295f362753845c41a0c94ee" integrity sha512-y11nGElTIV+CT3Zv9t7VKl+Q3hTQoT9a1Qzezhhl6Rp21gJ/IVTW7Z3y9EWXhuUBC2Shnf+DX0antecpAwSP8w== -yargs-parser@^21.0.0: +yargs-parser@^21.0.0, yargs-parser@^21.1.1: version "21.1.1" resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-21.1.1.tgz#9096bceebf990d21bb31fa9516e0ede294a77d35" integrity sha512-tVpsJW7DdjecAiFpbIB1e3qxIQsE6NoPc5/eTdrbbIC4h0LVsWhnoa3g+m2HclBIujHzsxZ4VJVA+GUuc2/LBw== @@ -6097,6 +6121,19 @@ yargs@^16.2.0: y18n "^5.0.5" yargs-parser "^20.2.2" +yargs@^17.5.1: + version "17.7.2" + resolved "https://registry.yarnpkg.com/yargs/-/yargs-17.7.2.tgz#991df39aca675a192b816e1e0363f9d75d2aa269" + integrity sha512-7dSzzRQ++CKnNI/krKnYRV7JKKPUXMEh61soaHKg9mrWEhzFWhFnxPxGl+69cD1Ou63C13NUPCnmIcrvqCuM6w== + dependencies: + cliui "^8.0.1" + escalade "^3.1.1" + get-caller-file "^2.0.5" + require-directory "^2.1.1" + string-width "^4.2.3" + y18n "^5.0.5" + yargs-parser "^21.1.1" + yn@3.1.1: version "3.1.1" resolved "https://registry.yarnpkg.com/yn/-/yn-3.1.1.tgz#1e87401a09d767c1d5eab26a6e4c185182d2eb50" From 29b2ed0bba5f2627a4d0db1ca790f40272c01df5 Mon Sep 17 00:00:00 2001 From: narayanprusty Date: Sun, 15 Oct 2023 23:35:29 +0100 Subject: [PATCH 02/42] updated readme --- README.md | 129 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 129 insertions(+) diff --git a/README.md b/README.md index d582048..cf9d504 100644 --- a/README.md +++ b/README.md @@ -63,6 +63,135 @@ test("handleMintPortals - should update portal status and stats entity", () => { }); ``` + + +## Example Queries + +In this section we provide some example queries which should help you to get first ideas of what to fetch from the graph and how to do it. You can insert all events on the Playground and get the results. If you need help on how to integrate those queries in your app please take a look into the [General Section](https://docs.aavegotchi.com/subgraphs/general). +Events + +## Events on chain + +You can query the subgraph for almost every event happened on chain. +``` +{ + erc1155Transfers { + from { + id + } + to { + id + } + valueExact + } + + metadataFlags { + flaggedBy { + id + } + metadata { + id + } + } + + metadataLikes { + likedBy { + id + } + metadata { + id + } + } +} +``` + +## Account owned NFTs + +You can fetch the NFTs of one Account with the following query: + +``` +account(id:"0x01c28a969a7d0ba03419c8c80be59928c4732cd9") { + id + ERC721tokens(first: 5) { + metadata { + name + artistName + description + } + } + ERC1155balances { + id + } + } + +``` + +## Account balances of Cards +Its also possible to fetch the Accounts with Cards. +``` +{ + erc1155Balances(orderBy: valueExact orderDirection: desc where: {account_not:null valueExact_gt: 0}) { + account { + id + } + valueExact + } +} +``` +## New NFT proposals +Further its also possible to fetch upcoming NFTs. +``` +{ + metadataActionLogs(where: {status: 0}) { + name + publisher { + id + } + publisherName + artist { + id + } + artistName + fileHash + flagCount + likeCount + } +} +``` + +The status codes defined as follows: +``` +export const METADATA_STATUS_PENDING = 0; +export const METADATA_STATUS_PAUSED = 1; +export const METADATA_STATUS_APPROVED = 2; +export const METADATA_STATUS_DECLINED = 3; +``` + +## Stats +Additionally we store some useful statistics on the subgraph. You can combine this with a block number and create a chart out of it. + +``` +{ + totalStatistics { + totalOwners + totalFakeGotchiPieces + totalNFTs + burnedNFTs + burnedCards + } + + nftstatistics { + holders(first: 3) { + id + amount + } + burned + amountHolder + totalSupply + } +} +``` + ## Contribute If you want to contribute it would be best to start with a fork. A new branch called feat/name, fix/bug or docs/docTitle for the specific scope. Afterwards please create a PR with a the prefix `WIP:`. From 528c5e0d74ba0a63553f231b932f82ca1b4f9e0f Mon Sep 17 00:00:00 2001 From: narayanprusty Date: Mon, 16 Oct 2023 23:04:50 +0100 Subject: [PATCH 03/42] added metadata to erc721listing --- schema.graphql | 13 +++++++++++++ src/utils/helpers/diamond.ts | 23 +++++++++++++++++++++++ tests/.latest.json | 2 +- tests/handleERC721ExecutedListing.test.ts | 18 +++++++++++++++++- tests/handleERC721ListingAdded.test.ts | 6 +++++- 5 files changed, 59 insertions(+), 3 deletions(-) diff --git a/schema.graphql b/schema.graphql index e113b82..6765b19 100644 --- a/schema.graphql +++ b/schema.graphql @@ -201,6 +201,19 @@ type ERC721Listing @entity { whitelist: Whitelist priceUpdatedAt: BigInt + + fileHash: String + name: String + publisher: Account + publisherName: String + externalLink: String + description: String + artist: Account + artistName: String + editions: Int + fileType: String + thumbnailHash: String + thumbnailType: String } type ERC1155Listing @entity { diff --git a/src/utils/helpers/diamond.ts b/src/utils/helpers/diamond.ts index b6bb5d1..0b1f031 100644 --- a/src/utils/helpers/diamond.ts +++ b/src/utils/helpers/diamond.ts @@ -21,7 +21,9 @@ import { Whitelist, ClaimedToken, ERC721BuyOrder, + ERC721Contract, } from "../../../generated/schema"; +import { fetchERC721, fetchERC721Token } from "../../fetch/erc721"; import { BIGINT_ZERO, STATUS_AAVEGOTCHI, ZERO_ADDRESS } from "../constants"; import { Address, @@ -207,6 +209,27 @@ export function updateERC721ListingInfo( listing.blockCreated = event.block.number; } + let erc721Contract = fetchERC721(listingInfo.erc721TokenAddress); + + // if (erc721Contract != null) { + // let erc721Token = fetchERC721Token( + // erc721Contract, + // listingInfo.erc721TokenId + // ); + + // listing.fileHash = erc721Token.fileHash; + // listing.name = erc721Token.name; + // listing.publisher = erc721Token.publisher; + // listing.externalLink = erc721Token.externalLink; + // listing.description = erc721Token.description; + // listing.artist = erc721Token.artist; + // listing.artistName = erc721Token.artistName; + // listing.editions = erc721Token.editions; + // listing.fileType = erc721Token.fileType; + // listing.thumbnailHash = erc721Token.thumbnailHash; + // listing.thumbnailType = erc721Token.thumbnailType; + // } + if (listing.category.toI32() <= 2) { let portal = getOrCreatePortal( listingInfo.erc721TokenId.toString(), diff --git a/tests/.latest.json b/tests/.latest.json index 1880dc2..a5b1358 100644 --- a/tests/.latest.json +++ b/tests/.latest.json @@ -1,4 +1,4 @@ { "version": "0.5.4", - "timestamp": 1697108080727 + "timestamp": 1697489093052 } \ No newline at end of file diff --git a/tests/handleERC721ExecutedListing.test.ts b/tests/handleERC721ExecutedListing.test.ts index 09c16c8..cc11066 100644 --- a/tests/handleERC721ExecutedListing.test.ts +++ b/tests/handleERC721ExecutedListing.test.ts @@ -18,7 +18,7 @@ import { getERC721ListingMock, } from "./mocks"; import { getOrCreatePortal } from "../src/utils/helpers/diamond"; -import { Aavegotchi, ERC721Listing, ItemType } from "../generated/schema"; +import { Aavegotchi, ERC721Contract, ERC721Listing, ItemType } from "../generated/schema"; test("handleERC721Listing - should add price to historicalPrices of aavegotchi if listing is aavegotchi", () => { // prepare event @@ -83,6 +83,10 @@ test("handleERC721Listing - should add price to historicalPrices of aavegotchi i listing.blockCreated = BIGINT_ZERO; listing.save(); + let erc721Contract = new ERC721Contract(event.params.erc721TokenAddress); + erc721Contract.asAccount = Address.fromString(ZERO_ADDRESS); + erc721Contract.save(); + //try_getERC721Listing createMockedFunction( event.address, @@ -114,6 +118,10 @@ test("handleERC721Listing - should add price to historicalPrices of portal if li portal.save(); + let erc721Contract = new ERC721Contract(event.params.erc721TokenAddress); + erc721Contract.asAccount = Address.fromString(ZERO_ADDRESS); + erc721Contract.save(); + createMockedFunction( event.address, "getERC721Listing", @@ -179,6 +187,10 @@ test("handleERC721Listing - should set blockCreated to block number when listing listing.blockCreated = BIGINT_ZERO; listing.save(); + let erc721Contract = new ERC721Contract(event.params.erc721TokenAddress); + erc721Contract.asAccount = Address.fromString(ZERO_ADDRESS); + erc721Contract.save(); + //try_getERC721Listing createMockedFunction( event.address, @@ -241,6 +253,10 @@ test("handleERC721Listing - reorg: should set block created if cancel events hap listing.blockCreated = BIGINT_ZERO; listing.save(); + let erc721Contract = new ERC721Contract(Address.fromString("0x86935F11C86623deC8a25696E1C19a8659CbF95d")); + erc721Contract.asAccount = Address.fromString(ZERO_ADDRESS); + erc721Contract.save(); + //try_getERC721Listing createMockedFunction( event.address, diff --git a/tests/handleERC721ListingAdded.test.ts b/tests/handleERC721ListingAdded.test.ts index df225ca..0662fad 100644 --- a/tests/handleERC721ListingAdded.test.ts +++ b/tests/handleERC721ListingAdded.test.ts @@ -18,7 +18,7 @@ import { getERC721ListingMock, } from "./mocks"; import { getOrCreatePortal } from "../src/utils/helpers/diamond"; -import { Aavegotchi } from "../generated/schema"; +import { Aavegotchi, ERC721Contract } from "../generated/schema"; test("should add gotchi name lower case if token is an aavegtochi", () => { // prepare event @@ -54,6 +54,10 @@ test("should add gotchi name lower case if token is an aavegtochi", () => { gotchi.timesTraded = BIGINT_ONE; gotchi.save(); + let erc721Contract = new ERC721Contract(event.params.erc721TokenAddress); + erc721Contract.asAccount = Address.fromString(ZERO_ADDRESS); + erc721Contract.save(); + //try_getERC721Listing createMockedFunction( event.address, From 34a9bac7c159f0f9f451775610e7dad1e0f852c5 Mon Sep 17 00:00:00 2001 From: narayanprusty Date: Mon, 16 Oct 2023 23:07:02 +0100 Subject: [PATCH 04/42] store metadata --- src/utils/helpers/diamond.ts | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/src/utils/helpers/diamond.ts b/src/utils/helpers/diamond.ts index 0b1f031..d82beb3 100644 --- a/src/utils/helpers/diamond.ts +++ b/src/utils/helpers/diamond.ts @@ -211,24 +211,24 @@ export function updateERC721ListingInfo( let erc721Contract = fetchERC721(listingInfo.erc721TokenAddress); - // if (erc721Contract != null) { - // let erc721Token = fetchERC721Token( - // erc721Contract, - // listingInfo.erc721TokenId - // ); + if (erc721Contract != null) { + let erc721Token = fetchERC721Token( + erc721Contract, + listingInfo.erc721TokenId + ); - // listing.fileHash = erc721Token.fileHash; - // listing.name = erc721Token.name; - // listing.publisher = erc721Token.publisher; - // listing.externalLink = erc721Token.externalLink; - // listing.description = erc721Token.description; - // listing.artist = erc721Token.artist; - // listing.artistName = erc721Token.artistName; - // listing.editions = erc721Token.editions; - // listing.fileType = erc721Token.fileType; - // listing.thumbnailHash = erc721Token.thumbnailHash; - // listing.thumbnailType = erc721Token.thumbnailType; - // } + listing.fileHash = erc721Token.fileHash; + listing.name = erc721Token.name; + listing.publisher = erc721Token.publisher; + listing.externalLink = erc721Token.externalLink; + listing.description = erc721Token.description; + listing.artist = erc721Token.artist; + listing.artistName = erc721Token.artistName; + listing.editions = erc721Token.editions; + listing.fileType = erc721Token.fileType; + listing.thumbnailHash = erc721Token.thumbnailHash; + listing.thumbnailType = erc721Token.thumbnailType; + } if (listing.category.toI32() <= 2) { let portal = getOrCreatePortal( From 6601eb74424d98d24dcf73346ca35e9bd0c3a4ed Mon Sep 17 00:00:00 2001 From: narayanprusty Date: Tue, 17 Oct 2023 23:33:51 +0100 Subject: [PATCH 05/42] removed TotalStatistics --- README.md | 2 +- schema.graphql | 37 +++++++++++++++++------------------- src/fetch/account.ts | 18 +++++++++--------- src/helper/entities.ts | 26 ++++++++++++++++++++----- src/utils/helpers/diamond.ts | 12 ++++++++++++ tests/.latest.json | 4 ++-- tests/handleTransfer.test.ts | 30 ++++++++++++++--------------- 7 files changed, 77 insertions(+), 52 deletions(-) diff --git a/README.md b/README.md index cf9d504..9e24bcd 100644 --- a/README.md +++ b/README.md @@ -172,7 +172,7 @@ Additionally we store some useful statistics on the subgraph. You can combine th ``` { - totalStatistics { + statistics { totalOwners totalFakeGotchiPieces totalNFTs diff --git a/schema.graphql b/schema.graphql index 6765b19..0c3b381 100644 --- a/schema.graphql +++ b/schema.graphql @@ -287,6 +287,23 @@ type Statistic @entity { totalWearablesVolume: BigInt! totalConsumablesVolume: BigInt! totalTicketsVolume: BigInt! + + totalOwners: Int + totalOwnersArray: [Bytes!]! + + totalFakeGotchiPieces: Int + totalNFTs: Int + totalNFTsArray: String! + + burnedNFTs: Int + burnedCards: Int + + tokenIdCounter: Int + + totalEditionsMinted: Int! + totalEditionsCirculating: Int! + + totalEditionsCirculatingArray: String! } type ItemType @entity { @@ -654,26 +671,6 @@ type Generation @entity { amount: Int } -type TotalStatistic @entity { - id: ID! - totalOwners: Int - totalOwnersArray: [Bytes!]! - - totalFakeGotchiPieces: Int - totalNFTs: Int - totalNFTsArray: String! - - burnedNFTs: Int - burnedCards: Int - - tokenIdCounter: Int - - totalEditionsMinted: Int! - totalEditionsCirculating: Int! - - totalEditionsCirculatingArray: String! -} - type NFTStatistic @entity { id: ID! metadata: MetadataActionLog diff --git a/src/fetch/account.ts b/src/fetch/account.ts index 49ec43a..cc597c7 100644 --- a/src/fetch/account.ts +++ b/src/fetch/account.ts @@ -4,7 +4,7 @@ import { Account, MetadataActionLog, NFTStatistic, - TotalStatistic + Statistic, } from "../../generated/schema"; import { BIGINT_ONE, BIGINT_ZERO } from "../constants"; import { createJsonFromJSONObject } from "../helper/json"; @@ -112,9 +112,9 @@ export function updateAccountStatsTo( } export function updateTotalStatsMint( - stats: TotalStatistic, + stats: Statistic, metaData: MetadataActionLog -): TotalStatistic { +): Statistic { const parsedJsonTotal = json.fromString( stats.totalEditionsCirculatingArray ); @@ -142,9 +142,9 @@ export function updateTotalStatsMint( } export function updateTotalStatsBurn( - stats: TotalStatistic, + stats: Statistic, metaData: MetadataActionLog -): TotalStatistic { +): Statistic { const parsedJsonTotal = json.fromString( stats.totalEditionsCirculatingArray ); @@ -169,9 +169,9 @@ export function updateTotalStatsBurn( } export function addToOwnersIfNotExists( - totalStats: TotalStatistic, + totalStats: Statistic, owner: Bytes -): TotalStatistic { +): Statistic { let ownersArray = totalStats.totalOwnersArray; if (ownersArray.indexOf(owner) == -1) { ownersArray.push(owner); @@ -183,10 +183,10 @@ export function addToOwnersIfNotExists( } export function removeFromOwnersIfExistsAndBalanceNotZero( - totalStats: TotalStatistic, + totalStats: Statistic, owner: Bytes, amount: i32 -): TotalStatistic { +): Statistic { if (amount > 0) { return totalStats; } diff --git a/src/helper/entities.ts b/src/helper/entities.ts index 74a69db..ce41e90 100644 --- a/src/helper/entities.ts +++ b/src/helper/entities.ts @@ -3,16 +3,16 @@ import { Transfer } from "../../generated/FAKEGotchisNFTDiamond/IERC721"; import { NFTHolder, NFTStatistic, - TotalStatistic + Statistic } from "../../generated/schema"; -import { ADDRESS_BURN, ADDRESS_DEAD, ADDRESS_ZERO } from "../constants"; +import { ADDRESS_BURN, ADDRESS_DEAD, ADDRESS_ZERO, BIGINT_ZERO } from "../constants"; // export function getOrCreateCard(id: BigInt): Card -export function getOrCreateStats(): TotalStatistic { - let stat = TotalStatistic.load("0"); +export function getOrCreateStats(): Statistic { + let stat = Statistic.load("0"); if (!stat) { - stat = new TotalStatistic("0"); + stat = new Statistic("0"); stat.burnedCards = 0; stat.burnedNFTs = 0; stat.totalNFTs = 0; @@ -24,6 +24,22 @@ export function getOrCreateStats(): TotalStatistic { stat.totalEditionsCirculating = 0; stat.totalEditionsMinted = 0; stat.totalEditionsCirculatingArray = "{}"; + + stat.portalsBought = BIGINT_ZERO; + stat.portalsOpened = BIGINT_ZERO; + stat.aavegotchisClaimed = BIGINT_ZERO; + stat.erc721ActiveListingCount = BIGINT_ZERO; + stat.erc1155ActiveListingCount = BIGINT_ZERO; + stat.erc721TotalVolume = BIGINT_ZERO; + stat.erc1155TotalVolume = BIGINT_ZERO; + + //new + stat.totalWearablesVolume = BIGINT_ZERO; + stat.totalConsumablesVolume = BIGINT_ZERO; + stat.totalTicketsVolume = BIGINT_ZERO; + + stat.aavegotchisBorrowed = BIGINT_ZERO; + stat.aavegotchisSacrificed = BIGINT_ZERO; } return stat; diff --git a/src/utils/helpers/diamond.ts b/src/utils/helpers/diamond.ts index d82beb3..7446279 100644 --- a/src/utils/helpers/diamond.ts +++ b/src/utils/helpers/diamond.ts @@ -572,6 +572,18 @@ export function getStatisticEntity(): Statistic { stats.aavegotchisBorrowed = BIGINT_ZERO; stats.aavegotchisSacrificed = BIGINT_ZERO; + stats.burnedCards = 0; + stats.burnedNFTs = 0; + stats.totalNFTs = 0; + stats.totalOwners = 0; + stats.totalFakeGotchiPieces = 0; + stats.totalNFTsArray = "{}"; + stats.totalOwnersArray = new Array(); + stats.tokenIdCounter = 0; + stats.totalEditionsCirculating = 0; + stats.totalEditionsMinted = 0; + stats.totalEditionsCirculatingArray = "{}"; + stats.save(); } diff --git a/tests/.latest.json b/tests/.latest.json index a5b1358..fb4f7de 100644 --- a/tests/.latest.json +++ b/tests/.latest.json @@ -1,4 +1,4 @@ { - "version": "0.5.4", - "timestamp": 1697489093052 + "version": "0.6.0", + "timestamp": 1697580641107 } \ No newline at end of file diff --git a/tests/handleTransfer.test.ts b/tests/handleTransfer.test.ts index 2a23b64..b009656 100644 --- a/tests/handleTransfer.test.ts +++ b/tests/handleTransfer.test.ts @@ -160,15 +160,15 @@ describe("handleTransfer", () => { // total stats assert.fieldEquals( - "TotalStatistic", + "Statistic", "0", "totalEditionsCirculating", "1" ); - assert.fieldEquals("TotalStatistic", "0", "totalEditionsMinted", "1"); - assert.fieldEquals("TotalStatistic", "0", "totalNFTs", "1"); - assert.fieldEquals("TotalStatistic", "0", "burnedNFTs", "0"); - assert.fieldEquals("TotalStatistic", "0", "totalOwners", "1"); + assert.fieldEquals("Statistic", "0", "totalEditionsMinted", "1"); + assert.fieldEquals("Statistic", "0", "totalNFTs", "1"); + assert.fieldEquals("Statistic", "0", "burnedNFTs", "0"); + assert.fieldEquals("Statistic", "0", "totalOwners", "1"); // nft stats assert.fieldEquals("NFTStatistic", "1", "burned", "0"); @@ -199,15 +199,15 @@ describe("handleTransfer", () => { // Total Stats assert.fieldEquals( - "TotalStatistic", + "Statistic", "0", "totalEditionsCirculating", "1" ); - assert.fieldEquals("TotalStatistic", "0", "totalEditionsMinted", "1"); - assert.fieldEquals("TotalStatistic", "0", "totalNFTs", "1"); - assert.fieldEquals("TotalStatistic", "0", "burnedNFTs", "0"); - assert.fieldEquals("TotalStatistic", "0", "totalOwners", "1"); + assert.fieldEquals("Statistic", "0", "totalEditionsMinted", "1"); + assert.fieldEquals("Statistic", "0", "totalNFTs", "1"); + assert.fieldEquals("Statistic", "0", "burnedNFTs", "0"); + assert.fieldEquals("Statistic", "0", "totalOwners", "1"); // NFT Stats assert.fieldEquals("NFTStatistic", "1", "burned", "0"); @@ -250,15 +250,15 @@ describe("handleTransfer", () => { // Total Stats assert.fieldEquals( - "TotalStatistic", + "Statistic", "0", "totalEditionsCirculating", "0" ); - assert.fieldEquals("TotalStatistic", "0", "totalEditionsMinted", "1"); - assert.fieldEquals("TotalStatistic", "0", "totalNFTs", "0"); - assert.fieldEquals("TotalStatistic", "0", "burnedNFTs", "1"); - assert.fieldEquals("TotalStatistic", "0", "totalOwners", "0"); + assert.fieldEquals("Statistic", "0", "totalEditionsMinted", "1"); + assert.fieldEquals("Statistic", "0", "totalNFTs", "0"); + assert.fieldEquals("Statistic", "0", "burnedNFTs", "1"); + assert.fieldEquals("Statistic", "0", "totalOwners", "0"); // NFT Stats assert.fieldEquals("NFTStatistic", "1", "burned", "1"); From 1ae0890d17b34efbe51ed43b4a90131581a33328 Mon Sep 17 00:00:00 2001 From: narayanprusty Date: Thu, 26 Oct 2023 21:50:31 +0100 Subject: [PATCH 06/42] merge account into user entity --- package.json | 3 +- schema.graphql | 135 +++++++++++----------- src/diamonds/fakeGotchisCard.ts | 33 +++--- src/diamonds/fakeGotchisNFT.ts | 43 +++---- src/fetch/account.ts | 29 +---- src/fetch/erc1155.ts | 21 ++-- src/fetch/erc721.ts | 25 ++-- src/helper/entities.ts | 2 +- src/ownable.ts | 10 +- src/utils/helpers/diamond.ts | 9 ++ tests/.latest.json | 2 +- tests/handleERC721ExecutedListing.test.ts | 8 +- tests/handleERC721ListingAdded.test.ts | 2 +- tests/handleTransfer.test.ts | 36 +++--- yarn.lock | 13 +++ 15 files changed, 188 insertions(+), 183 deletions(-) diff --git a/package.json b/package.json index 2db7656..bee4720 100644 --- a/package.json +++ b/package.json @@ -17,7 +17,8 @@ "dependencies": { "@2fd/graphdoc": "^2.4.0", "@graphprotocol/graph-cli": "0.59.0", - "@graphprotocol/graph-ts": "0.31.0" + "@graphprotocol/graph-ts": "0.31.0", + "@openzeppelin/subgraphs": "^0.1.8" }, "devDependencies": { "apollo-fetch": "^0.7.0", diff --git a/schema.graphql b/schema.graphql index 0c3b381..5b1ea63 100644 --- a/schema.graphql +++ b/schema.graphql @@ -151,6 +151,34 @@ type User @entity { # borrowedGotchis: [GotchiLending!]! @derivedFrom(field: "borrower") # lendGotchis: [GotchiLending!]! @derivedFrom(field: "originalOwner") + + asERC1155: ERC1155Contract + ERC1155balances: [ERC1155Balance!]! @derivedFrom(field: "account") + ERC1155operatorOwner: [ERC1155Operator!]! @derivedFrom(field: "owner") + ERC1155operatorOperator: [ERC1155Operator!]! @derivedFrom(field: "operator") + ERC1155transferFromEvent: [ERC1155Transfer!]! @derivedFrom(field: "from") + ERC1155transferToEvent: [ERC1155Transfer!]! @derivedFrom(field: "to") + ERC1155transferOperatorEvent: [ERC1155Transfer!]! + @derivedFrom(field: "operator") + + asERC721: ERC721Contract + ERC721tokens: [ERC721Token!]! @derivedFrom(field: "owner") + ERC721operatorOwner: [ERC721Operator!]! @derivedFrom(field: "owner") + ERC721operatorOperator: [ERC721Operator!]! @derivedFrom(field: "operator") + ERC721transferFromEvent: [ERC721Transfer!]! @derivedFrom(field: "from") + ERC721transferToEvent: [ERC721Transfer!]! @derivedFrom(field: "to") + + events: [Event!]! @derivedFrom(field: "emitter") + + tokens: String! # from array + amountTokens: Int! + + currentUniquePiecesOwned: Int! + totalUniquePiecesOwned: Int! + + currentUniquePiecesOwnedArray: String! # from array + totalUniquePiecesOwnedArray: String! # from array + totalPiecesOwnedArray: String! # from array } type ERC721Listing @entity { @@ -204,11 +232,11 @@ type ERC721Listing @entity { fileHash: String name: String - publisher: Account + publisher: User publisherName: String externalLink: String description: String - artist: Account + artist: User artistName: String editions: Int fileType: String @@ -444,7 +472,7 @@ type ERC721BuyOrder @entity { interface Event { id: ID! transaction: Transaction! - emitter: Account! + emitter: User! timestamp: BigInt! } type Transaction @entity(immutable: true) { @@ -454,41 +482,10 @@ type Transaction @entity(immutable: true) { events: [Event!]! @derivedFrom(field: "transaction") } -type Account @entity { - id: Bytes! - asERC1155: ERC1155Contract - ERC1155balances: [ERC1155Balance!]! @derivedFrom(field: "account") - ERC1155operatorOwner: [ERC1155Operator!]! @derivedFrom(field: "owner") - ERC1155operatorOperator: [ERC1155Operator!]! @derivedFrom(field: "operator") - ERC1155transferFromEvent: [ERC1155Transfer!]! @derivedFrom(field: "from") - ERC1155transferToEvent: [ERC1155Transfer!]! @derivedFrom(field: "to") - ERC1155transferOperatorEvent: [ERC1155Transfer!]! - @derivedFrom(field: "operator") - - asERC721: ERC721Contract - ERC721tokens: [ERC721Token!]! @derivedFrom(field: "owner") - ERC721operatorOwner: [ERC721Operator!]! @derivedFrom(field: "owner") - ERC721operatorOperator: [ERC721Operator!]! @derivedFrom(field: "operator") - ERC721transferFromEvent: [ERC721Transfer!]! @derivedFrom(field: "from") - ERC721transferToEvent: [ERC721Transfer!]! @derivedFrom(field: "to") - - events: [Event!]! @derivedFrom(field: "emitter") - - tokens: String! # from array - amountTokens: Int! - - currentUniquePiecesOwned: Int! - totalUniquePiecesOwned: Int! - - currentUniquePiecesOwnedArray: String! # from array - totalUniquePiecesOwnedArray: String! # from array - totalPiecesOwnedArray: String! # from array -} - # Cards type ERC1155Contract @entity(immutable: true) { id: Bytes! - asAccount: Account! + asAccount: User! tokens: [ERC1155Token!]! @derivedFrom(field: "contract") balances: [ERC1155Balance!]! @derivedFrom(field: "contract") operators: [ERC1155Operator!]! @derivedFrom(field: "contract") @@ -508,7 +505,7 @@ type ERC1155Balance @entity { id: ID! contract: ERC1155Contract! token: ERC1155Token! - account: Account + account: User value: BigDecimal! valueExact: BigInt! transferFromEvent: [ERC1155Transfer!]! @derivedFrom(field: "fromBalance") @@ -517,21 +514,21 @@ type ERC1155Balance @entity { type ERC1155Operator @entity { id: ID! contract: ERC1155Contract! - owner: Account! - operator: Account! + owner: User! + operator: User! approved: Boolean! } type ERC1155Transfer implements Event @entity(immutable: true) { id: ID! - emitter: Account! + emitter: User! transaction: Transaction! timestamp: BigInt! contract: ERC1155Contract! token: ERC1155Token! - operator: Account! - from: Account + operator: User! + from: User fromBalance: ERC1155Balance - to: Account + to: User toBalance: ERC1155Balance value: BigDecimal! valueExact: BigInt! @@ -540,7 +537,7 @@ type ERC1155Transfer implements Event @entity(immutable: true) { # NFT 721 type ERC721Contract @entity(immutable: true) { id: Bytes! - asAccount: Account! + asAccount: User! supportsMetadata: Boolean name: String symbol: String @@ -552,19 +549,19 @@ type ERC721Token @entity { id: ID! contract: ERC721Contract! identifier: BigInt! - owner: Account! - approval: Account! + owner: User! + approval: User! uri: String transfers: [ERC721Transfer!]! @derivedFrom(field: "token") metadata: MetadataActionLog fileHash: String name: String - publisher: Account + publisher: User publisherName: String externalLink: String description: String - artist: Account + artist: User artistName: String editions: Int fileType: String @@ -574,35 +571,35 @@ type ERC721Token @entity { type ERC721Operator @entity { id: ID! contract: ERC721Contract! - owner: Account! - operator: Account! + owner: User! + operator: User! approved: Boolean! } type ERC721Transfer implements Event @entity(immutable: true) { id: ID! - emitter: Account! + emitter: User! transaction: Transaction! timestamp: BigInt! contract: ERC721Contract! token: ERC721Token! - from: Account! - to: Account! + from: User! + to: User! } type MetadataActionLog implements Event @entity { id: ID! - emitter: Account! + emitter: User! transaction: Transaction! timestamp: BigInt! - sender: Account + sender: User minted: Boolean fileHash: String name: String - publisher: Account + publisher: User publisherName: String externalLink: String description: String - artist: Account + artist: User artistName: String royalty: [Int!] createdAt: BigInt @@ -619,49 +616,49 @@ type MetadataActionLog implements Event @entity { type MetadataFlag implements Event @entity(immutable: true) { id: ID! - emitter: Account! + emitter: User! transaction: Transaction! timestamp: BigInt! token: ERC721Token - sender: Account + sender: User - flaggedBy: Account + flaggedBy: User metadata: MetadataActionLog } type MetadataLike implements Event @entity(immutable: true) { id: ID! - emitter: Account! + emitter: User! transaction: Transaction! timestamp: BigInt! token: ERC721Token - sender: Account + sender: User - likedBy: Account + likedBy: User metadata: MetadataActionLog } type MetadataDecline implements Event @entity(immutable: true) { id: ID! - emitter: Account! + emitter: User! transaction: Transaction! timestamp: BigInt! token: ERC721Token - sender: Account + sender: User - declinedBy: Account + declinedBy: User metadata: MetadataActionLog } type ReviewPass implements Event @entity(immutable: true) { id: ID! - emitter: Account! + emitter: User! transaction: Transaction! timestamp: BigInt! token: ERC721Token - sender: Account + sender: User - reviewer: Account + reviewer: User metadata: MetadataActionLog } @@ -684,6 +681,6 @@ type NFTStatistic @entity { type NFTHolder @entity { id: ID! nftStats: NFTStatistic - holder: Account + holder: User amount: Int } diff --git a/src/diamonds/fakeGotchisCard.ts b/src/diamonds/fakeGotchisCard.ts index 23948e8..247a19d 100644 --- a/src/diamonds/fakeGotchisCard.ts +++ b/src/diamonds/fakeGotchisCard.ts @@ -3,7 +3,7 @@ import { ADDRESS_ZERO, BIGINT_ONE } from "../constants"; import { ethereum, BigInt } from "@graphprotocol/graph-ts"; import { - Account, + User, ERC1155Contract, ERC1155Transfer, Generation, @@ -25,8 +25,6 @@ import { transactions, } from "@amxx/graphprotocol-utils"; -import { fetchAccount } from "../fetch/account"; - import { fetchERC1155, fetchERC1155Token, @@ -34,20 +32,21 @@ import { fetchERC721Operator, replaceURI, } from "../fetch/erc1155"; +import { getOrCreateUser } from "../utils/helpers/diamond"; function registerTransfer( event: ethereum.Event, suffix: string, contract: ERC1155Contract, - operator: Account, - from: Account, - to: Account, + operator: User, + from: User, + to: User, id: BigInt, value: BigInt ): void { let token = fetchERC1155Token(contract, id); let ev = new ERC1155Transfer(events.id(event).concat(suffix)); - ev.emitter = token.contract; + ev.emitter = token.contract.toHexString(); ev.transaction = transactions.log(event).id; ev.timestamp = event.block.timestamp; ev.contract = contract.id; @@ -56,7 +55,7 @@ function registerTransfer( ev.value = decimals.toDecimals(value); ev.valueExact = value; - if (from.id == constants.ADDRESS_ZERO) { + if (from.id == constants.ADDRESS_ZERO.toHexString()) { let totalSupply = fetchERC1155Balance(token, null); totalSupply.valueExact = totalSupply.valueExact.plus(value); totalSupply.value = decimals.toDecimals(totalSupply.valueExact); @@ -71,7 +70,7 @@ function registerTransfer( ev.fromBalance = balance.id; } - if (to.id == constants.ADDRESS_ZERO) { + if (to.id == constants.ADDRESS_ZERO.toHexString()) { let totalSupply = fetchERC1155Balance(token, null); totalSupply.valueExact = totalSupply.valueExact.minus(value); totalSupply.value = decimals.toDecimals(totalSupply.valueExact); @@ -92,9 +91,9 @@ function registerTransfer( export function handleTransferSingle(event: TransferSingleEvent): void { let contract = fetchERC1155(event.address); - let operator = fetchAccount(event.params._operator); - let from = fetchAccount(event.params._from); - let to = fetchAccount(event.params._to); + let operator = getOrCreateUser(event.params._operator.toHex()); + let from = getOrCreateUser(event.params._from.toHex()); + let to = getOrCreateUser(event.params._to.toHex()); registerTransfer( event, @@ -110,9 +109,9 @@ export function handleTransferSingle(event: TransferSingleEvent): void { export function handleTransferBatch(event: TransferBatchEvent): void { let contract = fetchERC1155(event.address); - let operator = fetchAccount(event.params._operator); - let from = fetchAccount(event.params._from); - let to = fetchAccount(event.params._to); + let operator = getOrCreateUser(event.params._operator.toHex()); + let from = getOrCreateUser(event.params._from.toHex()); + let to = getOrCreateUser(event.params._to.toHex()); let ids = event.params._ids; let values = event.params._values; @@ -138,8 +137,8 @@ export function handleTransferBatch(event: TransferBatchEvent): void { export function handleApprovalForAll(event: ApprovalForAllEvent): void { let contract = fetchERC1155(event.address); - let owner = fetchAccount(event.params._owner); - let operator = fetchAccount(event.params._operator); + let operator = getOrCreateUser(event.params._operator.toHex()); + let owner = getOrCreateUser(event.params._owner.toHex()); let delegation = fetchERC721Operator(contract, owner, operator); delegation.approved = event.params._approved; delegation.save(); diff --git a/src/diamonds/fakeGotchisNFT.ts b/src/diamonds/fakeGotchisNFT.ts index e738907..8f973d6 100644 --- a/src/diamonds/fakeGotchisNFT.ts +++ b/src/diamonds/fakeGotchisNFT.ts @@ -21,7 +21,6 @@ import { events, transactions } from "@amxx/graphprotocol-utils"; import { addToOwnersIfNotExists, - fetchAccount, removeFromOwnersIfExistsAndBalanceNotZero, updateAccountStatsFrom, updateAccountStatsTo, @@ -29,6 +28,7 @@ import { updateTotalStatsMint } from "../fetch/account"; + import { METADATA_STATUS_APPROVED, METADATA_STATUS_DECLINED, @@ -50,6 +50,7 @@ import { isMint, isTransfer } from "../helper/entities"; +import { getOrCreateUser } from "../utils/helpers/diamond"; export function handleTransfer(event: TransferEvent): void { const isMintFlag = isMint(event); @@ -64,8 +65,8 @@ export function handleTransfer(event: TransferEvent): void { contract.save(); // fetch sender and receiver - let from = fetchAccount(event.params._from); - let to = fetchAccount(event.params._to); + let from = getOrCreateUser(event.params._from.toHexString()); + let to = getOrCreateUser(event.params._to.toHexString()); // update token owner let token = fetchERC721Token(contract, event.params._tokenId); @@ -74,7 +75,7 @@ export function handleTransfer(event: TransferEvent): void { // create event entity let ev = new ERC721Transfer(events.id(event)); - ev.emitter = contract.id; + ev.emitter = contract.id.toHexString(); ev.transaction = transactions.log(event).id; ev.timestamp = event.block.timestamp; ev.contract = contract.id; @@ -160,8 +161,8 @@ export function handleApproval(event: ApprovalEvent): void { let contract = fetchERC721(event.address); if (contract != null) { let token = fetchERC721Token(contract, event.params._tokenId); - let owner = fetchAccount(event.params._owner); - let approved = fetchAccount(event.params._approved); + let owner = getOrCreateUser(event.params._owner.toHexString()); + let approved = getOrCreateUser(event.params._approved.toHexString()); token.owner = owner.id; token.approval = approved.id; @@ -184,8 +185,8 @@ export function handleApproval(event: ApprovalEvent): void { export function handleApprovalForAll(event: ApprovalForAllEvent): void { let contract = fetchERC721(event.address); if (contract != null) { - let owner = fetchAccount(event.params._owner); - let operator = fetchAccount(event.params._operator); + let owner = getOrCreateUser(event.params._owner.toHexString()); + let operator = getOrCreateUser(event.params._operator.toHexString()); let delegation = fetchERC721Operator(contract, owner, operator); delegation.approved = event.params._approved; @@ -213,10 +214,10 @@ export function handleMetadataActionLog(event: MetadataActionLogEvent): void { ev.flagCount = 0; ev.likeCount = 0; } - let artist = fetchAccount(event.params.metaData.artist); - let publisher = fetchAccount(event.params.metaData.publisher); + let artist = getOrCreateUser(event.params.metaData.artist.toHexString()); + let publisher = getOrCreateUser(event.params.metaData.publisher.toHexString()); - ev.emitter = contract.id; + ev.emitter = contract.id.toHexString(); ev.transaction = transactions.log(event).id; ev.timestamp = event.block.timestamp; ev.minted = event.params.metaData.minted; @@ -252,13 +253,13 @@ export function handleMetadataActionLog(event: MetadataActionLogEvent): void { token.metadata = ev.id; token.owner = ev.publisher!; token.contract = event.address; - token.artist = event.params.metaData.artist; + token.artist = event.params.metaData.artist.toHexString(); token.artistName = event.params.metaData.artistName; token.description = event.params.metaData.description; token.externalLink = event.params.metaData.externalLink; token.fileHash = event.params.metaData.fileHash; token.name = event.params.metaData.name; - token.publisher = event.params.metaData.publisher; + token.publisher = event.params.metaData.publisher.toHexString(); token.publisherName = event.params.metaData.publisherName; token.editions = event.params.metaData.editions; token.fileType = event.params.metaData.fileType; @@ -279,13 +280,13 @@ export function handleMetadataFlag(event: MetadataFlagEvent): void { } metadata.save(); - let flagger = fetchAccount(event.params._flaggedBy); + let flagger = getOrCreateUser(event.params._flaggedBy.toHexString()); flagger.save(); let metadataflaggedEv = new MetadataFlag(events.id(event)); let contract = fetchERC721(event.address)!; let token = fetchERC721Token(contract, event.params._id); - metadataflaggedEv.emitter = contract.id; + metadataflaggedEv.emitter = contract.id.toHexString(); metadataflaggedEv.transaction = transactions.log(event).id; metadataflaggedEv.timestamp = event.block.timestamp; metadataflaggedEv.token = token.id; @@ -300,13 +301,13 @@ export function handleMetadataLike(event: MetadataLikeEvent): void { metadata.likeCount = metadata.likeCount + 1; metadata.save(); - let liker = fetchAccount(event.params._likedBy); + let liker = getOrCreateUser(event.params._likedBy.toHexString()); liker.save(); let metadatalikedEv = new MetadataLike(events.id(event)); let contract = fetchERC721(event.address)!; let token = fetchERC721Token(contract, event.params._id); - metadatalikedEv.emitter = contract.id; + metadatalikedEv.emitter = contract.id.toHexString(); metadatalikedEv.transaction = transactions.log(event).id; metadatalikedEv.timestamp = event.block.timestamp; metadatalikedEv.token = token.id; @@ -321,13 +322,13 @@ export function handleMetadataDecline(event: MetadataDeclineEvent): void { metadata.status = METADATA_STATUS_DECLINED; metadata.save(); - let decliner = fetchAccount(event.params._declinedBy); + let decliner = getOrCreateUser(event.params._declinedBy.toHexString()); decliner.save(); let metadatalikedEv = new MetadataDecline(events.id(event)); let contract = fetchERC721(event.address)!; let token = fetchERC721Token(contract, event.params._id); - metadatalikedEv.emitter = contract.id; + metadatalikedEv.emitter = contract.id.toHexString(); metadatalikedEv.transaction = transactions.log(event).id; metadatalikedEv.timestamp = event.block.timestamp; metadatalikedEv.token = token.id; @@ -342,13 +343,13 @@ export function handleReviewPass(event: ReviewPassEvent): void { metadata.status = METADATA_STATUS_PENDING; metadata.save(); - let reviewer = fetchAccount(event.params._reviewer); + let reviewer = getOrCreateUser(event.params._reviewer.toHexString()); reviewer.save(); let reviewPassed = new ReviewPass(events.id(event)); let contract = fetchERC721(event.address)!; let token = fetchERC721Token(contract, event.params._id); - reviewPassed.emitter = contract.id; + reviewPassed.emitter = contract.id.toHexString(); reviewPassed.transaction = transactions.log(event).id; reviewPassed.timestamp = event.block.timestamp; reviewPassed.token = token.id; diff --git a/src/fetch/account.ts b/src/fetch/account.ts index cc597c7..538dd5f 100644 --- a/src/fetch/account.ts +++ b/src/fetch/account.ts @@ -1,7 +1,7 @@ import { Address, BigInt, Bytes, json, log } from "@graphprotocol/graph-ts"; import { - Account, + User, MetadataActionLog, NFTStatistic, Statistic, @@ -9,29 +9,10 @@ import { import { BIGINT_ONE, BIGINT_ZERO } from "../constants"; import { createJsonFromJSONObject } from "../helper/json"; -export function fetchAccount(address: Address): Account { - let account = Account.load(address); - if (!account) { - account = new Account(address); - account.tokens = "{}"; - account.amountTokens = 0; - - account.currentUniquePiecesOwned = 0; - account.currentUniquePiecesOwnedArray = "{}"; - account.totalUniquePiecesOwned = 0; - account.totalUniquePiecesOwnedArray = "{}"; - - account.totalPiecesOwnedArray = "{}"; - - account.save(); - } - return account; -} - export function updateAccountStatsFrom( - account: Account, + account: User, metadataId: string -): Account { +): User { const parsedJsonCurrent = json.fromString( account.currentUniquePiecesOwnedArray ); @@ -59,9 +40,9 @@ export function updateAccountStatsFrom( } export function updateAccountStatsTo( - account: Account, + account: User, metadataId: string -): Account { +): User { const parsedJsonTotal = json.fromString( account.totalUniquePiecesOwnedArray ); diff --git a/src/fetch/erc1155.ts b/src/fetch/erc1155.ts index 4c6dd4a..af9d74f 100644 --- a/src/fetch/erc1155.ts +++ b/src/fetch/erc1155.ts @@ -1,7 +1,7 @@ import { Address, BigInt } from "@graphprotocol/graph-ts"; import { - Account, + User, ERC1155Contract, ERC1155Token, ERC1155Balance, @@ -11,8 +11,7 @@ import { import { IERC1155 } from "../../generated/FAKEGotchisCardDiamond/IERC1155"; import { constants } from "@amxx/graphprotocol-utils"; - -import { fetchAccount } from "./account"; +import { getOrCreateUser } from "../utils/helpers/diamond"; export function replaceURI(uri: string, identifier: BigInt): string { return uri.replaceAll( @@ -28,10 +27,10 @@ export function fetchERC1155(address: Address): ERC1155Contract { let contract = ERC1155Contract.load(address); if (!contract) { contract = new ERC1155Contract(address); - contract.asAccount = address; + contract.asAccount = address.toHex(); contract.save(); - let account = fetchAccount(address); + let account = getOrCreateUser(address.toHex()); account.asERC1155 = address; account.save(); } @@ -67,11 +66,11 @@ export function fetchERC1155Token( export function fetchERC1155Balance( token: ERC1155Token, - account: Account | null + account: User | null ): ERC1155Balance { let id = token.id .concat("/") - .concat(account ? account.id.toHex() : "totalSupply"); + .concat(account ? account.id.toString() : "totalSupply"); let balance = ERC1155Balance.load(id); if (balance == null) { @@ -89,15 +88,15 @@ export function fetchERC1155Balance( export function fetchERC721Operator( contract: ERC1155Contract, - owner: Account, - operator: Account + owner: User, + operator: User ): ERC1155Operator { let id = contract.id .toHex() .concat("/") - .concat(owner.id.toHex()) + .concat(owner.id.toString()) .concat("/") - .concat(operator.id.toHex()); + .concat(operator.id.toString()); let op = ERC1155Operator.load(id); if (op == null) { diff --git a/src/fetch/erc721.ts b/src/fetch/erc721.ts index 02e85c4..98d2003 100644 --- a/src/fetch/erc721.ts +++ b/src/fetch/erc721.ts @@ -7,7 +7,7 @@ import { } from "@graphprotocol/graph-ts"; import { - Account, + User, ERC721Contract, ERC721Token, ERC721Operator @@ -15,8 +15,8 @@ import { import { constants } from "@amxx/graphprotocol-utils"; -import { fetchAccount } from "./account"; import { IERC721 } from "../../generated/FAKEGotchisNFTDiamond/IERC721"; +import { getOrCreateUser } from "../utils/helpers/diamond"; export function fetchERC721(address: Address): ERC721Contract | null { let erc721 = IERC721.bind(address); @@ -29,11 +29,14 @@ export function fetchERC721(address: Address): ERC721Contract | null { // Detect using ERC165 let detectionId = address.concat(Bytes.fromHexString("80ac58cd")); // Address + ERC721 - let detectionAccount = Account.load(detectionId); + let detectionAccount = User.load(detectionId.toHex()); // On missing cache if (detectionAccount == null) { - detectionAccount = new Account(detectionId); + detectionAccount = new User(detectionId.toHex()); + detectionAccount.gotchisLentOut = new Array(); + detectionAccount.gotchisBorrowed = new Array(); + detectionAccount.tokens = "{}"; let introspection_01ffc9a7 = true; let introspection_80ac58cd = true; @@ -64,10 +67,10 @@ export function fetchERC721(address: Address): ERC721Contract | null { contract.name = try_name.reverted ? "" : try_name.value; contract.symbol = try_symbol.reverted ? "" : try_symbol.value; contract.supportsMetadata = true; - contract.asAccount = address; + contract.asAccount = address.toHex(); contract.save(); - let account = fetchAccount(address); + let account = getOrCreateUser(address.toHex()); account.asERC721 = address; account.save(); } @@ -89,7 +92,7 @@ export function fetchERC721Token( token = new ERC721Token(id); token.contract = contract.id; token.identifier = identifier; - token.approval = fetchAccount(constants.ADDRESS_ZERO).id; + token.approval = getOrCreateUser(constants.ADDRESS_ZERO.toHex()).id; if (contract.supportsMetadata) { let erc721 = IERC721.bind(Address.fromBytes(contract.id)); @@ -103,15 +106,15 @@ export function fetchERC721Token( export function fetchERC721Operator( contract: ERC721Contract, - owner: Account, - operator: Account + owner: User, + operator: User ): ERC721Operator { let id = contract.id .toHex() .concat("/") - .concat(owner.id.toHex()) + .concat(owner.id.toString()) .concat("/") - .concat(operator.id.toHex()); + .concat(operator.id.toString()); let op = ERC721Operator.load(id); if (op == null) { diff --git a/src/helper/entities.ts b/src/helper/entities.ts index ce41e90..a4c394f 100644 --- a/src/helper/entities.ts +++ b/src/helper/entities.ts @@ -68,7 +68,7 @@ export function getNFTHolder( if (!holder) { holder = new NFTHolder(id); holder.amount = 0; - holder.holder = holderAddress; + holder.holder = holderAddress.toHexString(); holder.nftStats = metadataId; } diff --git a/src/ownable.ts b/src/ownable.ts index f03af27..0afa52e 100644 --- a/src/ownable.ts +++ b/src/ownable.ts @@ -4,17 +4,17 @@ import { OwnershipTransferred as OwnershipTransferredEvent } from "@openzeppelin import { events, transactions } from "@amxx/graphprotocol-utils"; -import { fetchAccount } from "./fetch/account"; - import { fetchOwnable } from "@openzeppelin/subgraphs/src/fetch/ownable"; +import { getOrCreateUser } from "./utils/helpers/diamond"; +import { Bytes } from "@graphprotocol/graph-ts"; export function handleOwnershipTransferred( event: OwnershipTransferredEvent ): void { let contract = fetchOwnable(event.address); - let owner = fetchAccount(event.params.newOwner); + let owner = getOrCreateUser(event.params.newOwner.toHex()); - contract.owner = owner.id; + contract.owner = Bytes.fromHexString(owner.id); contract.save(); let ev = new OwnershipTransferred(events.id(event)); @@ -22,6 +22,6 @@ export function handleOwnershipTransferred( ev.transaction = transactions.log(event).id; ev.timestamp = event.block.timestamp; ev.contract = contract.id; - ev.owner = owner.id; + ev.owner = Bytes.fromHexString(owner.id); ev.save(); } diff --git a/src/utils/helpers/diamond.ts b/src/utils/helpers/diamond.ts index 7446279..8ae9387 100644 --- a/src/utils/helpers/diamond.ts +++ b/src/utils/helpers/diamond.ts @@ -98,6 +98,15 @@ export function getOrCreateUser( user = new User(id); user.gotchisLentOut = new Array(); user.gotchisBorrowed = new Array(); + user.tokens = "{}"; + user.amountTokens = 0; + + user.currentUniquePiecesOwned = 0; + user.currentUniquePiecesOwnedArray = "{}"; + user.totalUniquePiecesOwned = 0; + user.totalUniquePiecesOwnedArray = "{}"; + + user.totalPiecesOwnedArray = "{}"; } return user as User; diff --git a/tests/.latest.json b/tests/.latest.json index fb4f7de..a875f3d 100644 --- a/tests/.latest.json +++ b/tests/.latest.json @@ -1,4 +1,4 @@ { "version": "0.6.0", - "timestamp": 1697580641107 + "timestamp": 1698352149205 } \ No newline at end of file diff --git a/tests/handleERC721ExecutedListing.test.ts b/tests/handleERC721ExecutedListing.test.ts index cc11066..5033db3 100644 --- a/tests/handleERC721ExecutedListing.test.ts +++ b/tests/handleERC721ExecutedListing.test.ts @@ -84,7 +84,7 @@ test("handleERC721Listing - should add price to historicalPrices of aavegotchi i listing.save(); let erc721Contract = new ERC721Contract(event.params.erc721TokenAddress); - erc721Contract.asAccount = Address.fromString(ZERO_ADDRESS); + erc721Contract.asAccount = ZERO_ADDRESS; erc721Contract.save(); //try_getERC721Listing @@ -119,7 +119,7 @@ test("handleERC721Listing - should add price to historicalPrices of portal if li portal.save(); let erc721Contract = new ERC721Contract(event.params.erc721TokenAddress); - erc721Contract.asAccount = Address.fromString(ZERO_ADDRESS); + erc721Contract.asAccount = ZERO_ADDRESS; erc721Contract.save(); createMockedFunction( @@ -188,7 +188,7 @@ test("handleERC721Listing - should set blockCreated to block number when listing listing.save(); let erc721Contract = new ERC721Contract(event.params.erc721TokenAddress); - erc721Contract.asAccount = Address.fromString(ZERO_ADDRESS); + erc721Contract.asAccount = ZERO_ADDRESS; erc721Contract.save(); //try_getERC721Listing @@ -254,7 +254,7 @@ test("handleERC721Listing - reorg: should set block created if cancel events hap listing.save(); let erc721Contract = new ERC721Contract(Address.fromString("0x86935F11C86623deC8a25696E1C19a8659CbF95d")); - erc721Contract.asAccount = Address.fromString(ZERO_ADDRESS); + erc721Contract.asAccount = ZERO_ADDRESS; erc721Contract.save(); //try_getERC721Listing diff --git a/tests/handleERC721ListingAdded.test.ts b/tests/handleERC721ListingAdded.test.ts index 0662fad..57f6495 100644 --- a/tests/handleERC721ListingAdded.test.ts +++ b/tests/handleERC721ListingAdded.test.ts @@ -55,7 +55,7 @@ test("should add gotchi name lower case if token is an aavegtochi", () => { gotchi.save(); let erc721Contract = new ERC721Contract(event.params.erc721TokenAddress); - erc721Contract.asAccount = Address.fromString(ZERO_ADDRESS); + erc721Contract.asAccount = ZERO_ADDRESS; erc721Contract.save(); //try_getERC721Listing diff --git a/tests/handleTransfer.test.ts b/tests/handleTransfer.test.ts index b009656..d085459 100644 --- a/tests/handleTransfer.test.ts +++ b/tests/handleTransfer.test.ts @@ -15,12 +15,12 @@ import { } from "matchstick-as/assembly/index"; import { Transfer } from "../generated/FAKEGotchisNFTDiamond/IERC721"; import { - Account, ERC721Token, MetadataActionLog, NFTHolder, NFTStatistic, Transaction, + User, } from "../generated/schema"; import { ADDRESS_DEAD, @@ -76,7 +76,7 @@ describe("handleTransfer", () => { beforeAll(() => { const transaction = new Transaction("abc"); const log = new MetadataActionLog("1"); - log.emitter = Bytes.fromHexString(sender); + log.emitter = sender; log.transaction = transaction.id; log.timestamp = BIGINT_ZERO; log.editions = 1; @@ -89,11 +89,11 @@ describe("handleTransfer", () => { token.metadata = "1"; token.contract = ADDRESS_DEAD; token.identifier = BIGINT_ONE; - token.owner = ADDRESS_DEAD; - token.approval = ADDRESS_ZERO; + token.owner = ADDRESS_DEAD.toHexString(); + token.approval = ADDRESS_ZERO.toHexString(); token.editions = 0; - const senderAccount = new Account(Bytes.fromHexString(sender)); + const senderAccount = new User(sender); senderAccount.totalPiecesOwnedArray = "{}"; senderAccount.totalUniquePiecesOwnedArray = "{}"; senderAccount.totalUniquePiecesOwned = 0; @@ -101,17 +101,19 @@ describe("handleTransfer", () => { senderAccount.currentUniquePiecesOwnedArray = "{}"; senderAccount.tokens = "{}"; senderAccount.amountTokens = 0; + senderAccount.gotchisLentOut = new Array(); + senderAccount.gotchisBorrowed = new Array(); const holder = new NFTHolder( "0x46a3a41bd932244dd08186e4c19f1a7e48cbcdf4-1" ); holder.amount = 0; - holder.holder = Address.fromString(receiver); + holder.holder = receiver; holder.nftStats = "1"; store.set("MetadataActionLog", "1", log); store.set("ERC721Token", tokenEntityId, token); - store.set("Account", sender, senderAccount); + store.set("User", sender, senderAccount); // store.set("NFTStatistic", "1", nftStats); store.set( "NFTHolder", @@ -184,9 +186,9 @@ describe("handleTransfer", () => { assert.fieldEquals("NFTHolder", idSender, "nftStats", "1"); // account stats - assert.fieldEquals("Account", receiver, "totalUniquePiecesOwned", "1"); + assert.fieldEquals("User", receiver, "totalUniquePiecesOwned", "1"); assert.fieldEquals( - "Account", + "User", receiver, "currentUniquePiecesOwned", "1" @@ -227,17 +229,17 @@ describe("handleTransfer", () => { assert.fieldEquals("NFTHolder", idReceiver, "amount", "1"); assert.fieldEquals("NFTHolder", idReceiver, "nftStats", "1"); - // Account - assert.fieldEquals("Account", receiver, "totalUniquePiecesOwned", "1"); + // User + assert.fieldEquals("User", receiver, "totalUniquePiecesOwned", "1"); assert.fieldEquals( - "Account", + "User", receiver, "currentUniquePiecesOwned", "0" ); - assert.fieldEquals("Account", sender, "totalUniquePiecesOwned", "1"); - assert.fieldEquals("Account", sender, "currentUniquePiecesOwned", "1"); + assert.fieldEquals("User", sender, "totalUniquePiecesOwned", "1"); + assert.fieldEquals("User", sender, "currentUniquePiecesOwned", "1"); }); test("it should update total, nft and holder stats if tx is burn", () => { @@ -273,8 +275,8 @@ describe("handleTransfer", () => { assert.fieldEquals("NFTHolder", idSender, "amount", "0"); assert.fieldEquals("NFTHolder", idSender, "nftStats", "1"); - // Account - assert.fieldEquals("Account", sender, "totalUniquePiecesOwned", "1"); - assert.fieldEquals("Account", sender, "currentUniquePiecesOwned", "0"); + // User + assert.fieldEquals("User", sender, "totalUniquePiecesOwned", "1"); + assert.fieldEquals("User", sender, "currentUniquePiecesOwned", "0"); }); }); diff --git a/yarn.lock b/yarn.lock index a304397..07eb9bd 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1098,6 +1098,19 @@ chalk "^4" fast-levenshtein "^3.0.0" +"@openzeppelin/contracts@^4.6.0": + version "4.9.3" + resolved "https://registry.yarnpkg.com/@openzeppelin/contracts/-/contracts-4.9.3.tgz#00d7a8cf35a475b160b3f0293a6403c511099364" + integrity sha512-He3LieZ1pP2TNt5JbkPA4PNT9WC3gOTOlDcFGJW4Le4QKqwmiNJCRt44APfxMxvq7OugU/cqYuPcSBzOw38DAg== + +"@openzeppelin/subgraphs@^0.1.8": + version "0.1.8" + resolved "https://registry.yarnpkg.com/@openzeppelin/subgraphs/-/subgraphs-0.1.8.tgz#2e4076ecbd6017a7f5e8215b35827c32b06f8d38" + integrity sha512-I7A/m1FZ4Z4m9gttVxsQ6Dt2j53PMug/qj/Jyd4JnkgL4OmdunzsYZbj8dfcBG4nbAeMK3H7V9dKCEqB6PAKHw== + dependencies: + "@amxx/graphprotocol-utils" "^1.1.0" + "@openzeppelin/contracts" "^4.6.0" + "@peculiar/asn1-schema@^2.3.6": version "2.3.6" resolved "https://registry.yarnpkg.com/@peculiar/asn1-schema/-/asn1-schema-2.3.6.tgz#3dd3c2ade7f702a9a94dfb395c192f5fa5d6b922" From 2eb02d0c5e4f6c690ade797f6e76bfe7720a979d Mon Sep 17 00:00:00 2001 From: narayanprusty Date: Thu, 26 Oct 2023 21:53:33 +0100 Subject: [PATCH 07/42] unified constants --- src/constants.ts | 20 -------------------- src/diamonds/fakeGotchisCard.ts | 2 -- src/diamonds/fakeGotchisNFT.ts | 2 +- src/fetch/account.ts | 2 +- src/helper/entities.ts | 2 +- src/utils/constants.ts | 19 ++++++++++++++++++- 6 files changed, 21 insertions(+), 26 deletions(-) delete mode 100644 src/constants.ts diff --git a/src/constants.ts b/src/constants.ts deleted file mode 100644 index 8fba3a1..0000000 --- a/src/constants.ts +++ /dev/null @@ -1,20 +0,0 @@ -import { Address, BigInt } from "@graphprotocol/graph-ts"; - -export const BIGINT_ZERO = BigInt.fromI32(0); -export const BIGINT_ONE = BigInt.fromI32(1); -export const ADDRESS_ZERO = Address.fromString( - "0x0000000000000000000000000000000000000000" -); - -export const ADDRESS_BURN = Address.fromString( - "0xffffffffffffffffffffffffffffffffffffffff" -); - -export const ADDRESS_DEAD = Address.fromString( - "0x000000000000000000000000000000000000dead" -); - -export const METADATA_STATUS_PENDING = 0; -export const METADATA_STATUS_PAUSED = 1; -export const METADATA_STATUS_APPROVED = 2; -export const METADATA_STATUS_DECLINED = 3; diff --git a/src/diamonds/fakeGotchisCard.ts b/src/diamonds/fakeGotchisCard.ts index 247a19d..83e8c40 100644 --- a/src/diamonds/fakeGotchisCard.ts +++ b/src/diamonds/fakeGotchisCard.ts @@ -1,5 +1,3 @@ -import { ADDRESS_ZERO, BIGINT_ONE } from "../constants"; - import { ethereum, BigInt } from "@graphprotocol/graph-ts"; import { diff --git a/src/diamonds/fakeGotchisNFT.ts b/src/diamonds/fakeGotchisNFT.ts index 8f973d6..01c46cc 100644 --- a/src/diamonds/fakeGotchisNFT.ts +++ b/src/diamonds/fakeGotchisNFT.ts @@ -34,7 +34,7 @@ import { METADATA_STATUS_DECLINED, METADATA_STATUS_PAUSED, METADATA_STATUS_PENDING -} from "../constants"; +} from "../utils/constants"; import { fetchERC721, diff --git a/src/fetch/account.ts b/src/fetch/account.ts index 538dd5f..9331675 100644 --- a/src/fetch/account.ts +++ b/src/fetch/account.ts @@ -6,7 +6,7 @@ import { NFTStatistic, Statistic, } from "../../generated/schema"; -import { BIGINT_ONE, BIGINT_ZERO } from "../constants"; +import { BIGINT_ONE, BIGINT_ZERO } from "../utils/constants"; import { createJsonFromJSONObject } from "../helper/json"; export function updateAccountStatsFrom( diff --git a/src/helper/entities.ts b/src/helper/entities.ts index a4c394f..aae2c71 100644 --- a/src/helper/entities.ts +++ b/src/helper/entities.ts @@ -5,7 +5,7 @@ import { NFTStatistic, Statistic } from "../../generated/schema"; -import { ADDRESS_BURN, ADDRESS_DEAD, ADDRESS_ZERO, BIGINT_ZERO } from "../constants"; +import { ADDRESS_BURN, ADDRESS_DEAD, ADDRESS_ZERO, BIGINT_ZERO } from "../utils/constants"; // export function getOrCreateCard(id: BigInt): Card diff --git a/src/utils/constants.ts b/src/utils/constants.ts index 551ce96..95d49c8 100644 --- a/src/utils/constants.ts +++ b/src/utils/constants.ts @@ -1,4 +1,4 @@ -import { BigDecimal, BigInt } from "@graphprotocol/graph-ts"; +import { BigDecimal, BigInt, Address } from "@graphprotocol/graph-ts"; import { toDecimal } from "./decimals"; export const ZERO_ADDRESS = "0x0000000000000000000000000000000000000000"; @@ -17,3 +17,20 @@ export let STATUS_OPEN_PORTAL = BigInt.fromI32(2); export let STATUS_AAVEGOTCHI = BigInt.fromI32(3); export let BLOCK_DISABLE_OLD_LENDING_EVENTS = BigInt.fromI32(31313604); + +export const ADDRESS_ZERO = Address.fromString( + "0x0000000000000000000000000000000000000000" +); + +export const ADDRESS_BURN = Address.fromString( + "0xffffffffffffffffffffffffffffffffffffffff" +); + +export const ADDRESS_DEAD = Address.fromString( + "0x000000000000000000000000000000000000dead" +); + +export const METADATA_STATUS_PENDING = 0; +export const METADATA_STATUS_PAUSED = 1; +export const METADATA_STATUS_APPROVED = 2; +export const METADATA_STATUS_DECLINED = 3; From 15d6f80e327a5219e89f1cc4bfaa4f233c569586 Mon Sep 17 00:00:00 2001 From: narayanprusty Date: Thu, 26 Oct 2023 22:04:08 +0100 Subject: [PATCH 08/42] folders cleanup --- src/diamonds/constants.ts | 20 ------------------- src/{diamonds => mappings}/fakeGotchisCard.ts | 0 src/{diamonds => mappings}/fakeGotchisNFT.ts | 0 src/{ => mappings}/ownable.ts | 2 +- src/utils/constants.ts | 2 ++ subgraph.mumbai.yaml | 4 ++-- subgraph.yaml | 4 ++-- tests/handleTransfer.test.ts | 4 ++-- 8 files changed, 9 insertions(+), 27 deletions(-) delete mode 100644 src/diamonds/constants.ts rename src/{diamonds => mappings}/fakeGotchisCard.ts (100%) rename src/{diamonds => mappings}/fakeGotchisNFT.ts (100%) rename src/{ => mappings}/ownable.ts (94%) diff --git a/src/diamonds/constants.ts b/src/diamonds/constants.ts deleted file mode 100644 index 8fba3a1..0000000 --- a/src/diamonds/constants.ts +++ /dev/null @@ -1,20 +0,0 @@ -import { Address, BigInt } from "@graphprotocol/graph-ts"; - -export const BIGINT_ZERO = BigInt.fromI32(0); -export const BIGINT_ONE = BigInt.fromI32(1); -export const ADDRESS_ZERO = Address.fromString( - "0x0000000000000000000000000000000000000000" -); - -export const ADDRESS_BURN = Address.fromString( - "0xffffffffffffffffffffffffffffffffffffffff" -); - -export const ADDRESS_DEAD = Address.fromString( - "0x000000000000000000000000000000000000dead" -); - -export const METADATA_STATUS_PENDING = 0; -export const METADATA_STATUS_PAUSED = 1; -export const METADATA_STATUS_APPROVED = 2; -export const METADATA_STATUS_DECLINED = 3; diff --git a/src/diamonds/fakeGotchisCard.ts b/src/mappings/fakeGotchisCard.ts similarity index 100% rename from src/diamonds/fakeGotchisCard.ts rename to src/mappings/fakeGotchisCard.ts diff --git a/src/diamonds/fakeGotchisNFT.ts b/src/mappings/fakeGotchisNFT.ts similarity index 100% rename from src/diamonds/fakeGotchisNFT.ts rename to src/mappings/fakeGotchisNFT.ts diff --git a/src/ownable.ts b/src/mappings/ownable.ts similarity index 94% rename from src/ownable.ts rename to src/mappings/ownable.ts index 0afa52e..a5f3814 100644 --- a/src/ownable.ts +++ b/src/mappings/ownable.ts @@ -5,7 +5,7 @@ import { OwnershipTransferred as OwnershipTransferredEvent } from "@openzeppelin import { events, transactions } from "@amxx/graphprotocol-utils"; import { fetchOwnable } from "@openzeppelin/subgraphs/src/fetch/ownable"; -import { getOrCreateUser } from "./utils/helpers/diamond"; +import { getOrCreateUser } from "../utils/helpers/diamond"; import { Bytes } from "@graphprotocol/graph-ts"; export function handleOwnershipTransferred( diff --git a/src/utils/constants.ts b/src/utils/constants.ts index 95d49c8..9b202ef 100644 --- a/src/utils/constants.ts +++ b/src/utils/constants.ts @@ -34,3 +34,5 @@ export const METADATA_STATUS_PENDING = 0; export const METADATA_STATUS_PAUSED = 1; export const METADATA_STATUS_APPROVED = 2; export const METADATA_STATUS_DECLINED = 3; + + diff --git a/subgraph.mumbai.yaml b/subgraph.mumbai.yaml index 0f18bb5..d1ebc55 100644 --- a/subgraph.mumbai.yaml +++ b/subgraph.mumbai.yaml @@ -270,7 +270,7 @@ dataSources: handler: handleTransferBatch - event: URI(string,indexed uint256) handler: handleURI - file: ./src/diamonds/fakeGotchisCard.ts + file: ./src/mappings/fakeGotchisCard.ts - kind: ethereum/contract name: FAKEGotchisNFTDiamond network: mumbai @@ -302,4 +302,4 @@ dataSources: handler: handleReviewPass - event: MetadataDecline(indexed uint256,address) handler: handleMetadataDecline - file: ./src/diamonds/fakeGotchisNFT.ts \ No newline at end of file + file: ./src/mappings/fakeGotchisNFT.ts \ No newline at end of file diff --git a/subgraph.yaml b/subgraph.yaml index 9634895..0fe1b1a 100644 --- a/subgraph.yaml +++ b/subgraph.yaml @@ -270,7 +270,7 @@ dataSources: handler: handleTransferBatch - event: URI(string,indexed uint256) handler: handleURI - file: ./src/diamonds/fakeGotchisCard.ts + file: ./src/mappings/fakeGotchisCard.ts - kind: ethereum/contract name: FAKEGotchisNFTDiamond network: matic @@ -302,4 +302,4 @@ dataSources: handler: handleReviewPass - event: MetadataDecline(indexed uint256,address) handler: handleMetadataDecline - file: ./src/diamonds/fakeGotchisNFT.ts + file: ./src/mappings/fakeGotchisNFT.ts diff --git a/tests/handleTransfer.test.ts b/tests/handleTransfer.test.ts index d085459..6c78458 100644 --- a/tests/handleTransfer.test.ts +++ b/tests/handleTransfer.test.ts @@ -27,8 +27,8 @@ import { ADDRESS_ZERO, BIGINT_ONE, BIGINT_ZERO, -} from "../src/constants"; -import { handleTransfer } from "../src/diamonds/fakeGotchisNFT"; +} from "../src/utils/constants"; +import { handleTransfer } from "../src/mappings/fakeGotchisNFT"; export function createTransferEvent( from: string, From 69cb280216c3b7cb525d501830c469b2a9f74359 Mon Sep 17 00:00:00 2001 From: narayanprusty Date: Mon, 30 Oct 2023 19:24:28 +0000 Subject: [PATCH 09/42] removed operator --- schema.graphql | 26 ++------------------------ src/fetch/erc1155.ts | 24 ------------------------ src/fetch/erc721.ts | 26 +------------------------- src/mappings/fakeGotchisCard.ts | 16 ---------------- src/mappings/fakeGotchisNFT.ts | 24 ------------------------ tests/.latest.json | 2 +- 6 files changed, 4 insertions(+), 114 deletions(-) diff --git a/schema.graphql b/schema.graphql index 5b1ea63..d6ddd26 100644 --- a/schema.graphql +++ b/schema.graphql @@ -154,17 +154,11 @@ type User @entity { asERC1155: ERC1155Contract ERC1155balances: [ERC1155Balance!]! @derivedFrom(field: "account") - ERC1155operatorOwner: [ERC1155Operator!]! @derivedFrom(field: "owner") - ERC1155operatorOperator: [ERC1155Operator!]! @derivedFrom(field: "operator") ERC1155transferFromEvent: [ERC1155Transfer!]! @derivedFrom(field: "from") ERC1155transferToEvent: [ERC1155Transfer!]! @derivedFrom(field: "to") - ERC1155transferOperatorEvent: [ERC1155Transfer!]! - @derivedFrom(field: "operator") - asERC721: ERC721Contract + asERC721: ERC721Contract ERC721tokens: [ERC721Token!]! @derivedFrom(field: "owner") - ERC721operatorOwner: [ERC721Operator!]! @derivedFrom(field: "owner") - ERC721operatorOperator: [ERC721Operator!]! @derivedFrom(field: "operator") ERC721transferFromEvent: [ERC721Transfer!]! @derivedFrom(field: "from") ERC721transferToEvent: [ERC721Transfer!]! @derivedFrom(field: "to") @@ -488,7 +482,6 @@ type ERC1155Contract @entity(immutable: true) { asAccount: User! tokens: [ERC1155Token!]! @derivedFrom(field: "contract") balances: [ERC1155Balance!]! @derivedFrom(field: "contract") - operators: [ERC1155Operator!]! @derivedFrom(field: "contract") transfers: [ERC1155Transfer!]! @derivedFrom(field: "contract") } type ERC1155Token @entity { @@ -511,13 +504,6 @@ type ERC1155Balance @entity { transferFromEvent: [ERC1155Transfer!]! @derivedFrom(field: "fromBalance") transferToEvent: [ERC1155Transfer!]! @derivedFrom(field: "toBalance") } -type ERC1155Operator @entity { - id: ID! - contract: ERC1155Contract! - owner: User! - operator: User! - approved: Boolean! -} type ERC1155Transfer implements Event @entity(immutable: true) { id: ID! emitter: User! @@ -525,7 +511,6 @@ type ERC1155Transfer implements Event @entity(immutable: true) { timestamp: BigInt! contract: ERC1155Contract! token: ERC1155Token! - operator: User! from: User fromBalance: ERC1155Balance to: User @@ -542,7 +527,6 @@ type ERC721Contract @entity(immutable: true) { name: String symbol: String tokens: [ERC721Token!]! @derivedFrom(field: "contract") - operators: [ERC721Operator!]! @derivedFrom(field: "contract") transfers: [ERC721Transfer!]! @derivedFrom(field: "contract") } type ERC721Token @entity { @@ -568,13 +552,7 @@ type ERC721Token @entity { thumbnailHash: String thumbnailType: String } -type ERC721Operator @entity { - id: ID! - contract: ERC721Contract! - owner: User! - operator: User! - approved: Boolean! -} + type ERC721Transfer implements Event @entity(immutable: true) { id: ID! emitter: User! diff --git a/src/fetch/erc1155.ts b/src/fetch/erc1155.ts index af9d74f..69b6817 100644 --- a/src/fetch/erc1155.ts +++ b/src/fetch/erc1155.ts @@ -5,7 +5,6 @@ import { ERC1155Contract, ERC1155Token, ERC1155Balance, - ERC1155Operator, } from "../../generated/schema"; import { IERC1155 } from "../../generated/FAKEGotchisCardDiamond/IERC1155"; @@ -85,26 +84,3 @@ export function fetchERC1155Balance( return balance as ERC1155Balance; } - -export function fetchERC721Operator( - contract: ERC1155Contract, - owner: User, - operator: User -): ERC1155Operator { - let id = contract.id - .toHex() - .concat("/") - .concat(owner.id.toString()) - .concat("/") - .concat(operator.id.toString()); - let op = ERC1155Operator.load(id); - - if (op == null) { - op = new ERC1155Operator(id); - op.contract = contract.id; - op.owner = owner.id; - op.operator = operator.id; - } - - return op as ERC1155Operator; -} diff --git a/src/fetch/erc721.ts b/src/fetch/erc721.ts index 98d2003..79f111f 100644 --- a/src/fetch/erc721.ts +++ b/src/fetch/erc721.ts @@ -10,7 +10,6 @@ import { User, ERC721Contract, ERC721Token, - ERC721Operator } from "../../generated/schema"; import { constants } from "@amxx/graphprotocol-utils"; @@ -102,27 +101,4 @@ export function fetchERC721Token( } return token as ERC721Token; -} - -export function fetchERC721Operator( - contract: ERC721Contract, - owner: User, - operator: User -): ERC721Operator { - let id = contract.id - .toHex() - .concat("/") - .concat(owner.id.toString()) - .concat("/") - .concat(operator.id.toString()); - let op = ERC721Operator.load(id); - - if (op == null) { - op = new ERC721Operator(id); - op.contract = contract.id; - op.owner = owner.id; - op.operator = operator.id; - } - - return op as ERC721Operator; -} +} \ No newline at end of file diff --git a/src/mappings/fakeGotchisCard.ts b/src/mappings/fakeGotchisCard.ts index 83e8c40..d0ddec8 100644 --- a/src/mappings/fakeGotchisCard.ts +++ b/src/mappings/fakeGotchisCard.ts @@ -27,7 +27,6 @@ import { fetchERC1155, fetchERC1155Token, fetchERC1155Balance, - fetchERC721Operator, replaceURI, } from "../fetch/erc1155"; import { getOrCreateUser } from "../utils/helpers/diamond"; @@ -36,7 +35,6 @@ function registerTransfer( event: ethereum.Event, suffix: string, contract: ERC1155Contract, - operator: User, from: User, to: User, id: BigInt, @@ -49,7 +47,6 @@ function registerTransfer( ev.timestamp = event.block.timestamp; ev.contract = contract.id; ev.token = token.id; - ev.operator = operator.id; ev.value = decimals.toDecimals(value); ev.valueExact = value; @@ -89,7 +86,6 @@ function registerTransfer( export function handleTransferSingle(event: TransferSingleEvent): void { let contract = fetchERC1155(event.address); - let operator = getOrCreateUser(event.params._operator.toHex()); let from = getOrCreateUser(event.params._from.toHex()); let to = getOrCreateUser(event.params._to.toHex()); @@ -97,7 +93,6 @@ export function handleTransferSingle(event: TransferSingleEvent): void { event, "", contract, - operator, from, to, event.params._id, @@ -107,7 +102,6 @@ export function handleTransferSingle(event: TransferSingleEvent): void { export function handleTransferBatch(event: TransferBatchEvent): void { let contract = fetchERC1155(event.address); - let operator = getOrCreateUser(event.params._operator.toHex()); let from = getOrCreateUser(event.params._from.toHex()); let to = getOrCreateUser(event.params._to.toHex()); @@ -123,7 +117,6 @@ export function handleTransferBatch(event: TransferBatchEvent): void { event, "/".concat(i.toString()), contract, - operator, from, to, ids[i], @@ -133,15 +126,6 @@ export function handleTransferBatch(event: TransferBatchEvent): void { } } -export function handleApprovalForAll(event: ApprovalForAllEvent): void { - let contract = fetchERC1155(event.address); - let operator = getOrCreateUser(event.params._operator.toHex()); - let owner = getOrCreateUser(event.params._owner.toHex()); - let delegation = fetchERC721Operator(contract, owner, operator); - delegation.approved = event.params._approved; - delegation.save(); -} - export function handleURI(event: URIEvent): void { let contract = fetchERC1155(event.address); let token = fetchERC1155Token(contract, event.params._id); diff --git a/src/mappings/fakeGotchisNFT.ts b/src/mappings/fakeGotchisNFT.ts index 01c46cc..21b7c5c 100644 --- a/src/mappings/fakeGotchisNFT.ts +++ b/src/mappings/fakeGotchisNFT.ts @@ -39,7 +39,6 @@ import { import { fetchERC721, fetchERC721Token, - fetchERC721Operator } from "../fetch/erc721"; import { BigInt } from "@graphprotocol/graph-ts"; import { @@ -182,29 +181,6 @@ export function handleApproval(event: ApprovalEvent): void { } } -export function handleApprovalForAll(event: ApprovalForAllEvent): void { - let contract = fetchERC721(event.address); - if (contract != null) { - let owner = getOrCreateUser(event.params._owner.toHexString()); - let operator = getOrCreateUser(event.params._operator.toHexString()); - let delegation = fetchERC721Operator(contract, owner, operator); - - delegation.approved = event.params._approved; - - delegation.save(); - - // let ev = new ApprovalForAll(events.id(event)) - // ev.emitter = contract.id - // ev.transaction = transactions.log(event).id - // ev.timestamp = event.block.timestamp - // ev.delegation = delegation.id - // ev.owner = owner.id - // ev.operator = operator.id - // ev.approved = event.params.approved - // ev.save() - } -} - export function handleMetadataActionLog(event: MetadataActionLogEvent): void { let contract = fetchERC721(event.address); if (contract != null) { diff --git a/tests/.latest.json b/tests/.latest.json index a875f3d..d2ae00a 100644 --- a/tests/.latest.json +++ b/tests/.latest.json @@ -1,4 +1,4 @@ { "version": "0.6.0", - "timestamp": 1698352149205 + "timestamp": 1698693753326 } \ No newline at end of file From cb31f9a86cf1b6337161db9bb40d2ccc8b6028da Mon Sep 17 00:00:00 2001 From: narayanprusty Date: Mon, 30 Oct 2023 19:31:18 +0000 Subject: [PATCH 10/42] removed transfers --- schema.graphql | 35 ------------------------------- src/mappings/fakeGotchisCard.ts | 15 ------------- src/mappings/fakeGotchisNFT.ts | 37 --------------------------------- 3 files changed, 87 deletions(-) diff --git a/schema.graphql b/schema.graphql index d6ddd26..d1d335a 100644 --- a/schema.graphql +++ b/schema.graphql @@ -154,13 +154,9 @@ type User @entity { asERC1155: ERC1155Contract ERC1155balances: [ERC1155Balance!]! @derivedFrom(field: "account") - ERC1155transferFromEvent: [ERC1155Transfer!]! @derivedFrom(field: "from") - ERC1155transferToEvent: [ERC1155Transfer!]! @derivedFrom(field: "to") asERC721: ERC721Contract ERC721tokens: [ERC721Token!]! @derivedFrom(field: "owner") - ERC721transferFromEvent: [ERC721Transfer!]! @derivedFrom(field: "from") - ERC721transferToEvent: [ERC721Transfer!]! @derivedFrom(field: "to") events: [Event!]! @derivedFrom(field: "emitter") @@ -482,7 +478,6 @@ type ERC1155Contract @entity(immutable: true) { asAccount: User! tokens: [ERC1155Token!]! @derivedFrom(field: "contract") balances: [ERC1155Balance!]! @derivedFrom(field: "contract") - transfers: [ERC1155Transfer!]! @derivedFrom(field: "contract") } type ERC1155Token @entity { id: ID! @@ -491,7 +486,6 @@ type ERC1155Token @entity { uri: String totalSupply: ERC1155Balance! balances: [ERC1155Balance!]! @derivedFrom(field: "token") - transfers: [ERC1155Transfer!]! @derivedFrom(field: "token") metadata: MetadataActionLog } type ERC1155Balance @entity { @@ -501,22 +495,6 @@ type ERC1155Balance @entity { account: User value: BigDecimal! valueExact: BigInt! - transferFromEvent: [ERC1155Transfer!]! @derivedFrom(field: "fromBalance") - transferToEvent: [ERC1155Transfer!]! @derivedFrom(field: "toBalance") -} -type ERC1155Transfer implements Event @entity(immutable: true) { - id: ID! - emitter: User! - transaction: Transaction! - timestamp: BigInt! - contract: ERC1155Contract! - token: ERC1155Token! - from: User - fromBalance: ERC1155Balance - to: User - toBalance: ERC1155Balance - value: BigDecimal! - valueExact: BigInt! } # NFT 721 @@ -527,7 +505,6 @@ type ERC721Contract @entity(immutable: true) { name: String symbol: String tokens: [ERC721Token!]! @derivedFrom(field: "contract") - transfers: [ERC721Transfer!]! @derivedFrom(field: "contract") } type ERC721Token @entity { id: ID! @@ -536,7 +513,6 @@ type ERC721Token @entity { owner: User! approval: User! uri: String - transfers: [ERC721Transfer!]! @derivedFrom(field: "token") metadata: MetadataActionLog fileHash: String @@ -553,17 +529,6 @@ type ERC721Token @entity { thumbnailType: String } -type ERC721Transfer implements Event @entity(immutable: true) { - id: ID! - emitter: User! - transaction: Transaction! - timestamp: BigInt! - contract: ERC721Contract! - token: ERC721Token! - from: User! - to: User! -} - type MetadataActionLog implements Event @entity { id: ID! emitter: User! diff --git a/src/mappings/fakeGotchisCard.ts b/src/mappings/fakeGotchisCard.ts index d0ddec8..d3fffb8 100644 --- a/src/mappings/fakeGotchisCard.ts +++ b/src/mappings/fakeGotchisCard.ts @@ -3,7 +3,6 @@ import { ethereum, BigInt } from "@graphprotocol/graph-ts"; import { User, ERC1155Contract, - ERC1155Transfer, Generation, } from "../../generated/schema"; @@ -41,14 +40,6 @@ function registerTransfer( value: BigInt ): void { let token = fetchERC1155Token(contract, id); - let ev = new ERC1155Transfer(events.id(event).concat(suffix)); - ev.emitter = token.contract.toHexString(); - ev.transaction = transactions.log(event).id; - ev.timestamp = event.block.timestamp; - ev.contract = contract.id; - ev.token = token.id; - ev.value = decimals.toDecimals(value); - ev.valueExact = value; if (from.id == constants.ADDRESS_ZERO.toHexString()) { let totalSupply = fetchERC1155Balance(token, null); @@ -60,9 +51,6 @@ function registerTransfer( balance.valueExact = balance.valueExact.minus(value); balance.value = decimals.toDecimals(balance.valueExact); balance.save(); - - ev.from = from.id; - ev.fromBalance = balance.id; } if (to.id == constants.ADDRESS_ZERO.toHexString()) { @@ -76,12 +64,9 @@ function registerTransfer( balance.value = decimals.toDecimals(balance.valueExact); balance.save(); - ev.to = to.id; - ev.toBalance = balance.id; } token.save(); - ev.save(); } export function handleTransferSingle(event: TransferSingleEvent): void { diff --git a/src/mappings/fakeGotchisNFT.ts b/src/mappings/fakeGotchisNFT.ts index 21b7c5c..eee1426 100644 --- a/src/mappings/fakeGotchisNFT.ts +++ b/src/mappings/fakeGotchisNFT.ts @@ -1,5 +1,4 @@ import { - ERC721Transfer, MetadataActionLog, MetadataDecline, MetadataFlag, @@ -72,17 +71,6 @@ export function handleTransfer(event: TransferEvent): void { token.owner = to.id; token.save(); - // create event entity - let ev = new ERC721Transfer(events.id(event)); - ev.emitter = contract.id.toHexString(); - ev.transaction = transactions.log(event).id; - ev.timestamp = event.block.timestamp; - ev.contract = contract.id; - ev.token = token.id; - ev.from = from.id; - ev.to = to.id; - ev.save(); - // fetch metadata let metadata = MetadataActionLog.load(token.metadata!)!; let nftStats = getOrCreateNFTStatistic(metadata.id); @@ -156,31 +144,6 @@ export function handleTransfer(event: TransferEvent): void { from.save(); } -export function handleApproval(event: ApprovalEvent): void { - let contract = fetchERC721(event.address); - if (contract != null) { - let token = fetchERC721Token(contract, event.params._tokenId); - let owner = getOrCreateUser(event.params._owner.toHexString()); - let approved = getOrCreateUser(event.params._approved.toHexString()); - - token.owner = owner.id; - token.approval = approved.id; - - token.save(); - owner.save(); - approved.save(); - - // let ev = new Approval(events.id(event)) - // ev.emitter = contract.id - // ev.transaction = transactions.log(event).id - // ev.timestamp = event.block.timestamp - // ev.token = token.id - // ev.owner = owner.id - // ev.approved = approved.id - // ev.save() - } -} - export function handleMetadataActionLog(event: MetadataActionLogEvent): void { let contract = fetchERC721(event.address); if (contract != null) { From 10eabd7c90b1887fe16abb198bb64a5d8f0e4b19 Mon Sep 17 00:00:00 2001 From: narayanprusty Date: Mon, 30 Oct 2023 19:36:17 +0000 Subject: [PATCH 11/42] renamed ERC1155Balance to FakeGotchiCardBalance --- schema.graphql | 10 +++++----- src/fetch/erc1155.ts | 14 +++++++------- src/mappings/fakeGotchisCard.ts | 10 +++++----- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/schema.graphql b/schema.graphql index d1d335a..1d560f6 100644 --- a/schema.graphql +++ b/schema.graphql @@ -153,7 +153,7 @@ type User @entity { # lendGotchis: [GotchiLending!]! @derivedFrom(field: "originalOwner") asERC1155: ERC1155Contract - ERC1155balances: [ERC1155Balance!]! @derivedFrom(field: "account") + FakeGotchiCardBalances: [FakeGotchiCardBalance!]! @derivedFrom(field: "account") asERC721: ERC721Contract ERC721tokens: [ERC721Token!]! @derivedFrom(field: "owner") @@ -477,18 +477,18 @@ type ERC1155Contract @entity(immutable: true) { id: Bytes! asAccount: User! tokens: [ERC1155Token!]! @derivedFrom(field: "contract") - balances: [ERC1155Balance!]! @derivedFrom(field: "contract") + balances: [FakeGotchiCardBalance!]! @derivedFrom(field: "contract") } type ERC1155Token @entity { id: ID! contract: ERC1155Contract! identifier: BigInt! uri: String - totalSupply: ERC1155Balance! - balances: [ERC1155Balance!]! @derivedFrom(field: "token") + totalSupply: FakeGotchiCardBalance! + balances: [FakeGotchiCardBalance!]! @derivedFrom(field: "token") metadata: MetadataActionLog } -type ERC1155Balance @entity { +type FakeGotchiCardBalance @entity { id: ID! contract: ERC1155Contract! token: ERC1155Token! diff --git a/src/fetch/erc1155.ts b/src/fetch/erc1155.ts index 69b6817..453216a 100644 --- a/src/fetch/erc1155.ts +++ b/src/fetch/erc1155.ts @@ -4,7 +4,7 @@ import { User, ERC1155Contract, ERC1155Token, - ERC1155Balance, + FakeGotchiCardBalance, } from "../../generated/schema"; import { IERC1155 } from "../../generated/FAKEGotchisCardDiamond/IERC1155"; @@ -53,7 +53,7 @@ export function fetchERC1155Token( token = new ERC1155Token(id); token.contract = contract.id; token.identifier = identifier; - token.totalSupply = fetchERC1155Balance(token as ERC1155Token, null).id; + token.totalSupply = fetchFakeGotchiCardBalance(token as ERC1155Token, null).id; token.uri = try_uri.reverted ? null : replaceURI(try_uri.value, identifier); @@ -63,17 +63,17 @@ export function fetchERC1155Token( return token as ERC1155Token; } -export function fetchERC1155Balance( +export function fetchFakeGotchiCardBalance( token: ERC1155Token, account: User | null -): ERC1155Balance { +): FakeGotchiCardBalance { let id = token.id .concat("/") .concat(account ? account.id.toString() : "totalSupply"); - let balance = ERC1155Balance.load(id); + let balance = FakeGotchiCardBalance.load(id); if (balance == null) { - balance = new ERC1155Balance(id); + balance = new FakeGotchiCardBalance(id); balance.contract = token.contract; balance.token = token.id; balance.account = account ? account.id : null; @@ -82,5 +82,5 @@ export function fetchERC1155Balance( balance.save(); } - return balance as ERC1155Balance; + return balance as FakeGotchiCardBalance; } diff --git a/src/mappings/fakeGotchisCard.ts b/src/mappings/fakeGotchisCard.ts index d3fffb8..9699438 100644 --- a/src/mappings/fakeGotchisCard.ts +++ b/src/mappings/fakeGotchisCard.ts @@ -25,7 +25,7 @@ import { import { fetchERC1155, fetchERC1155Token, - fetchERC1155Balance, + fetchFakeGotchiCardBalance, replaceURI, } from "../fetch/erc1155"; import { getOrCreateUser } from "../utils/helpers/diamond"; @@ -42,24 +42,24 @@ function registerTransfer( let token = fetchERC1155Token(contract, id); if (from.id == constants.ADDRESS_ZERO.toHexString()) { - let totalSupply = fetchERC1155Balance(token, null); + let totalSupply = fetchFakeGotchiCardBalance(token, null); totalSupply.valueExact = totalSupply.valueExact.plus(value); totalSupply.value = decimals.toDecimals(totalSupply.valueExact); totalSupply.save(); } else { - let balance = fetchERC1155Balance(token, from); + let balance = fetchFakeGotchiCardBalance(token, from); balance.valueExact = balance.valueExact.minus(value); balance.value = decimals.toDecimals(balance.valueExact); balance.save(); } if (to.id == constants.ADDRESS_ZERO.toHexString()) { - let totalSupply = fetchERC1155Balance(token, null); + let totalSupply = fetchFakeGotchiCardBalance(token, null); totalSupply.valueExact = totalSupply.valueExact.minus(value); totalSupply.value = decimals.toDecimals(totalSupply.valueExact); totalSupply.save(); } else { - let balance = fetchERC1155Balance(token, to); + let balance = fetchFakeGotchiCardBalance(token, to); balance.valueExact = balance.valueExact.plus(value); balance.value = decimals.toDecimals(balance.valueExact); balance.save(); From dfcf27b7b004e02d322ab2b4c94899723fd98b2f Mon Sep 17 00:00:00 2001 From: narayanprusty Date: Mon, 30 Oct 2023 19:42:12 +0000 Subject: [PATCH 12/42] renamed ERC1155Token to FakeGotchiCardToken --- schema.graphql | 6 +++--- src/fetch/erc1155.ts | 16 ++++++++-------- src/mappings/fakeGotchisCard.ts | 6 +++--- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/schema.graphql b/schema.graphql index 1d560f6..e2e8309 100644 --- a/schema.graphql +++ b/schema.graphql @@ -476,10 +476,10 @@ type Transaction @entity(immutable: true) { type ERC1155Contract @entity(immutable: true) { id: Bytes! asAccount: User! - tokens: [ERC1155Token!]! @derivedFrom(field: "contract") + tokens: [FakeGotchiCardToken!]! @derivedFrom(field: "contract") balances: [FakeGotchiCardBalance!]! @derivedFrom(field: "contract") } -type ERC1155Token @entity { +type FakeGotchiCardToken @entity { id: ID! contract: ERC1155Contract! identifier: BigInt! @@ -491,7 +491,7 @@ type ERC1155Token @entity { type FakeGotchiCardBalance @entity { id: ID! contract: ERC1155Contract! - token: ERC1155Token! + token: FakeGotchiCardToken! account: User value: BigDecimal! valueExact: BigInt! diff --git a/src/fetch/erc1155.ts b/src/fetch/erc1155.ts index 453216a..112ad64 100644 --- a/src/fetch/erc1155.ts +++ b/src/fetch/erc1155.ts @@ -3,7 +3,7 @@ import { Address, BigInt } from "@graphprotocol/graph-ts"; import { User, ERC1155Contract, - ERC1155Token, + FakeGotchiCardToken, FakeGotchiCardBalance, } from "../../generated/schema"; @@ -37,34 +37,34 @@ export function fetchERC1155(address: Address): ERC1155Contract { return contract; } -export function fetchERC1155Token( +export function fetchFakeGotchiCardToken( contract: ERC1155Contract, identifier: BigInt -): ERC1155Token { +): FakeGotchiCardToken { let id = contract.id .toHex() .concat("/") .concat(identifier.toHex()); - let token = ERC1155Token.load(id); + let token = FakeGotchiCardToken.load(id); if (token == null) { let erc1155 = IERC1155.bind(Address.fromBytes(contract.id)); let try_uri = erc1155.try_uri(identifier); - token = new ERC1155Token(id); + token = new FakeGotchiCardToken(id); token.contract = contract.id; token.identifier = identifier; - token.totalSupply = fetchFakeGotchiCardBalance(token as ERC1155Token, null).id; + token.totalSupply = fetchFakeGotchiCardBalance(token as FakeGotchiCardToken, null).id; token.uri = try_uri.reverted ? null : replaceURI(try_uri.value, identifier); token.save(); } - return token as ERC1155Token; + return token as FakeGotchiCardToken; } export function fetchFakeGotchiCardBalance( - token: ERC1155Token, + token: FakeGotchiCardToken, account: User | null ): FakeGotchiCardBalance { let id = token.id diff --git a/src/mappings/fakeGotchisCard.ts b/src/mappings/fakeGotchisCard.ts index 9699438..fb9de67 100644 --- a/src/mappings/fakeGotchisCard.ts +++ b/src/mappings/fakeGotchisCard.ts @@ -24,7 +24,7 @@ import { import { fetchERC1155, - fetchERC1155Token, + fetchFakeGotchiCardToken, fetchFakeGotchiCardBalance, replaceURI, } from "../fetch/erc1155"; @@ -39,7 +39,7 @@ function registerTransfer( id: BigInt, value: BigInt ): void { - let token = fetchERC1155Token(contract, id); + let token = fetchFakeGotchiCardToken(contract, id); if (from.id == constants.ADDRESS_ZERO.toHexString()) { let totalSupply = fetchFakeGotchiCardBalance(token, null); @@ -113,7 +113,7 @@ export function handleTransferBatch(event: TransferBatchEvent): void { export function handleURI(event: URIEvent): void { let contract = fetchERC1155(event.address); - let token = fetchERC1155Token(contract, event.params._id); + let token = fetchFakeGotchiCardToken(contract, event.params._id); token.uri = replaceURI(event.params._value, event.params._id); token.save(); } From 495d9cf6bafedc4445252b13108c93a355da041f Mon Sep 17 00:00:00 2001 From: narayanprusty Date: Mon, 30 Oct 2023 19:47:01 +0000 Subject: [PATCH 13/42] renamed ERC721Token to FakeGotchiNFTToken --- schema.graphql | 14 +++++++------- src/fetch/erc721.ts | 12 ++++++------ src/mappings/fakeGotchisNFT.ts | 14 +++++++------- src/utils/helpers/diamond.ts | 4 ++-- tests/handleTransfer.test.ts | 6 +++--- 5 files changed, 25 insertions(+), 25 deletions(-) diff --git a/schema.graphql b/schema.graphql index e2e8309..1004ffe 100644 --- a/schema.graphql +++ b/schema.graphql @@ -156,7 +156,7 @@ type User @entity { FakeGotchiCardBalances: [FakeGotchiCardBalance!]! @derivedFrom(field: "account") asERC721: ERC721Contract - ERC721tokens: [ERC721Token!]! @derivedFrom(field: "owner") + FakeGotchiNFTTokens: [FakeGotchiNFTToken!]! @derivedFrom(field: "owner") events: [Event!]! @derivedFrom(field: "emitter") @@ -504,9 +504,9 @@ type ERC721Contract @entity(immutable: true) { supportsMetadata: Boolean name: String symbol: String - tokens: [ERC721Token!]! @derivedFrom(field: "contract") + tokens: [FakeGotchiNFTToken!]! @derivedFrom(field: "contract") } -type ERC721Token @entity { +type FakeGotchiNFTToken @entity { id: ID! contract: ERC721Contract! identifier: BigInt! @@ -562,7 +562,7 @@ type MetadataFlag implements Event @entity(immutable: true) { emitter: User! transaction: Transaction! timestamp: BigInt! - token: ERC721Token + token: FakeGotchiNFTToken sender: User flaggedBy: User @@ -574,7 +574,7 @@ type MetadataLike implements Event @entity(immutable: true) { emitter: User! transaction: Transaction! timestamp: BigInt! - token: ERC721Token + token: FakeGotchiNFTToken sender: User likedBy: User @@ -586,7 +586,7 @@ type MetadataDecline implements Event @entity(immutable: true) { emitter: User! transaction: Transaction! timestamp: BigInt! - token: ERC721Token + token: FakeGotchiNFTToken sender: User declinedBy: User @@ -598,7 +598,7 @@ type ReviewPass implements Event @entity(immutable: true) { emitter: User! transaction: Transaction! timestamp: BigInt! - token: ERC721Token + token: FakeGotchiNFTToken sender: User reviewer: User diff --git a/src/fetch/erc721.ts b/src/fetch/erc721.ts index 79f111f..97c2b1d 100644 --- a/src/fetch/erc721.ts +++ b/src/fetch/erc721.ts @@ -9,7 +9,7 @@ import { import { User, ERC721Contract, - ERC721Token, + FakeGotchiNFTToken, } from "../../generated/schema"; import { constants } from "@amxx/graphprotocol-utils"; @@ -77,18 +77,18 @@ export function fetchERC721(address: Address): ERC721Contract | null { return contract; } -export function fetchERC721Token( +export function fetchFakeGotchiNFTToken( contract: ERC721Contract, identifier: BigInt -): ERC721Token { +): FakeGotchiNFTToken { let id = contract.id .toHex() .concat("/") .concat(identifier.toHex()); - let token = ERC721Token.load(id); + let token = FakeGotchiNFTToken.load(id); if (token == null) { - token = new ERC721Token(id); + token = new FakeGotchiNFTToken(id); token.contract = contract.id; token.identifier = identifier; token.approval = getOrCreateUser(constants.ADDRESS_ZERO.toHex()).id; @@ -100,5 +100,5 @@ export function fetchERC721Token( } } - return token as ERC721Token; + return token as FakeGotchiNFTToken; } \ No newline at end of file diff --git a/src/mappings/fakeGotchisNFT.ts b/src/mappings/fakeGotchisNFT.ts index eee1426..b096aa6 100644 --- a/src/mappings/fakeGotchisNFT.ts +++ b/src/mappings/fakeGotchisNFT.ts @@ -37,7 +37,7 @@ import { import { fetchERC721, - fetchERC721Token, + fetchFakeGotchiNFTToken, } from "../fetch/erc721"; import { BigInt } from "@graphprotocol/graph-ts"; import { @@ -67,7 +67,7 @@ export function handleTransfer(event: TransferEvent): void { let to = getOrCreateUser(event.params._to.toHexString()); // update token owner - let token = fetchERC721Token(contract, event.params._tokenId); + let token = fetchFakeGotchiNFTToken(contract, event.params._tokenId); token.owner = to.id; token.save(); @@ -188,7 +188,7 @@ export function handleMetadataActionLog(event: MetadataActionLogEvent): void { stats.tokenIdCounter = stats.tokenIdCounter + ev.editions; for (let i = 0; i < ev.editions; i++) { let id = startId + i; - let token = fetchERC721Token(contract, BigInt.fromI32(id)); + let token = fetchFakeGotchiNFTToken(contract, BigInt.fromI32(id)); token.metadata = ev.id; token.owner = ev.publisher!; token.contract = event.address; @@ -224,7 +224,7 @@ export function handleMetadataFlag(event: MetadataFlagEvent): void { let metadataflaggedEv = new MetadataFlag(events.id(event)); let contract = fetchERC721(event.address)!; - let token = fetchERC721Token(contract, event.params._id); + let token = fetchFakeGotchiNFTToken(contract, event.params._id); metadataflaggedEv.emitter = contract.id.toHexString(); metadataflaggedEv.transaction = transactions.log(event).id; metadataflaggedEv.timestamp = event.block.timestamp; @@ -245,7 +245,7 @@ export function handleMetadataLike(event: MetadataLikeEvent): void { let metadatalikedEv = new MetadataLike(events.id(event)); let contract = fetchERC721(event.address)!; - let token = fetchERC721Token(contract, event.params._id); + let token = fetchFakeGotchiNFTToken(contract, event.params._id); metadatalikedEv.emitter = contract.id.toHexString(); metadatalikedEv.transaction = transactions.log(event).id; metadatalikedEv.timestamp = event.block.timestamp; @@ -266,7 +266,7 @@ export function handleMetadataDecline(event: MetadataDeclineEvent): void { let metadatalikedEv = new MetadataDecline(events.id(event)); let contract = fetchERC721(event.address)!; - let token = fetchERC721Token(contract, event.params._id); + let token = fetchFakeGotchiNFTToken(contract, event.params._id); metadatalikedEv.emitter = contract.id.toHexString(); metadatalikedEv.transaction = transactions.log(event).id; metadatalikedEv.timestamp = event.block.timestamp; @@ -287,7 +287,7 @@ export function handleReviewPass(event: ReviewPassEvent): void { let reviewPassed = new ReviewPass(events.id(event)); let contract = fetchERC721(event.address)!; - let token = fetchERC721Token(contract, event.params._id); + let token = fetchFakeGotchiNFTToken(contract, event.params._id); reviewPassed.emitter = contract.id.toHexString(); reviewPassed.transaction = transactions.log(event).id; reviewPassed.timestamp = event.block.timestamp; diff --git a/src/utils/helpers/diamond.ts b/src/utils/helpers/diamond.ts index 8ae9387..5831c32 100644 --- a/src/utils/helpers/diamond.ts +++ b/src/utils/helpers/diamond.ts @@ -23,7 +23,7 @@ import { ERC721BuyOrder, ERC721Contract, } from "../../../generated/schema"; -import { fetchERC721, fetchERC721Token } from "../../fetch/erc721"; +import { fetchERC721, fetchFakeGotchiNFTToken } from "../../fetch/erc721"; import { BIGINT_ZERO, STATUS_AAVEGOTCHI, ZERO_ADDRESS } from "../constants"; import { Address, @@ -221,7 +221,7 @@ export function updateERC721ListingInfo( let erc721Contract = fetchERC721(listingInfo.erc721TokenAddress); if (erc721Contract != null) { - let erc721Token = fetchERC721Token( + let erc721Token = fetchFakeGotchiNFTToken( erc721Contract, listingInfo.erc721TokenId ); diff --git a/tests/handleTransfer.test.ts b/tests/handleTransfer.test.ts index 6c78458..2bfeef1 100644 --- a/tests/handleTransfer.test.ts +++ b/tests/handleTransfer.test.ts @@ -15,7 +15,7 @@ import { } from "matchstick-as/assembly/index"; import { Transfer } from "../generated/FAKEGotchisNFTDiamond/IERC721"; import { - ERC721Token, + FakeGotchiNFTToken, MetadataActionLog, NFTHolder, NFTStatistic, @@ -85,7 +85,7 @@ describe("handleTransfer", () => { .to!.toHex() .concat("/") .concat(BIGINT_ONE.toHex()); - const token = new ERC721Token(tokenEntityId); + const token = new FakeGotchiNFTToken(tokenEntityId); token.metadata = "1"; token.contract = ADDRESS_DEAD; token.identifier = BIGINT_ONE; @@ -112,7 +112,7 @@ describe("handleTransfer", () => { holder.nftStats = "1"; store.set("MetadataActionLog", "1", log); - store.set("ERC721Token", tokenEntityId, token); + store.set("FakeGotchiNFTToken", tokenEntityId, token); store.set("User", sender, senderAccount); // store.set("NFTStatistic", "1", nftStats); store.set( From adee58c9a8c64587c58d290aba9b63dabe4759d4 Mon Sep 17 00:00:00 2001 From: narayanprusty Date: Mon, 30 Oct 2023 19:50:07 +0000 Subject: [PATCH 14/42] renamed ERC721Contract to FakeGotchiNFTContract --- schema.graphql | 6 +++--- src/fetch/erc721.ts | 10 ++++----- src/utils/helpers/diamond.ts | 8 +++---- tests/handleERC721ExecutedListing.test.ts | 26 +++++++++++------------ tests/handleERC721ListingAdded.test.ts | 8 +++---- 5 files changed, 29 insertions(+), 29 deletions(-) diff --git a/schema.graphql b/schema.graphql index 1004ffe..51cee95 100644 --- a/schema.graphql +++ b/schema.graphql @@ -155,7 +155,7 @@ type User @entity { asERC1155: ERC1155Contract FakeGotchiCardBalances: [FakeGotchiCardBalance!]! @derivedFrom(field: "account") - asERC721: ERC721Contract + asERC721: FakeGotchiNFTContract FakeGotchiNFTTokens: [FakeGotchiNFTToken!]! @derivedFrom(field: "owner") events: [Event!]! @derivedFrom(field: "emitter") @@ -498,7 +498,7 @@ type FakeGotchiCardBalance @entity { } # NFT 721 -type ERC721Contract @entity(immutable: true) { +type FakeGotchiNFTContract @entity(immutable: true) { id: Bytes! asAccount: User! supportsMetadata: Boolean @@ -508,7 +508,7 @@ type ERC721Contract @entity(immutable: true) { } type FakeGotchiNFTToken @entity { id: ID! - contract: ERC721Contract! + contract: FakeGotchiNFTContract! identifier: BigInt! owner: User! approval: User! diff --git a/src/fetch/erc721.ts b/src/fetch/erc721.ts index 97c2b1d..a24ceb0 100644 --- a/src/fetch/erc721.ts +++ b/src/fetch/erc721.ts @@ -8,7 +8,7 @@ import { import { User, - ERC721Contract, + FakeGotchiNFTContract, FakeGotchiNFTToken, } from "../../generated/schema"; @@ -17,11 +17,11 @@ import { constants } from "@amxx/graphprotocol-utils"; import { IERC721 } from "../../generated/FAKEGotchisNFTDiamond/IERC721"; import { getOrCreateUser } from "../utils/helpers/diamond"; -export function fetchERC721(address: Address): ERC721Contract | null { +export function fetchERC721(address: Address): FakeGotchiNFTContract | null { let erc721 = IERC721.bind(address); // Try load entry - let contract = ERC721Contract.load(address); + let contract = FakeGotchiNFTContract.load(address); if (contract != null) { return contract; } @@ -60,7 +60,7 @@ export function fetchERC721(address: Address): ERC721Contract | null { // If an ERC721, build entry if (detectionAccount.asERC721) { - contract = new ERC721Contract(address); + contract = new FakeGotchiNFTContract(address); let try_name = erc721.try_name(); let try_symbol = erc721.try_symbol(); contract.name = try_name.reverted ? "" : try_name.value; @@ -78,7 +78,7 @@ export function fetchERC721(address: Address): ERC721Contract | null { } export function fetchFakeGotchiNFTToken( - contract: ERC721Contract, + contract: FakeGotchiNFTContract, identifier: BigInt ): FakeGotchiNFTToken { let id = contract.id diff --git a/src/utils/helpers/diamond.ts b/src/utils/helpers/diamond.ts index 5831c32..e3fdf82 100644 --- a/src/utils/helpers/diamond.ts +++ b/src/utils/helpers/diamond.ts @@ -21,7 +21,7 @@ import { Whitelist, ClaimedToken, ERC721BuyOrder, - ERC721Contract, + FakeGotchiNFTContract, } from "../../../generated/schema"; import { fetchERC721, fetchFakeGotchiNFTToken } from "../../fetch/erc721"; import { BIGINT_ZERO, STATUS_AAVEGOTCHI, ZERO_ADDRESS } from "../constants"; @@ -218,11 +218,11 @@ export function updateERC721ListingInfo( listing.blockCreated = event.block.number; } - let erc721Contract = fetchERC721(listingInfo.erc721TokenAddress); + let FakeGotchiNFTContract = fetchERC721(listingInfo.erc721TokenAddress); - if (erc721Contract != null) { + if (FakeGotchiNFTContract != null) { let erc721Token = fetchFakeGotchiNFTToken( - erc721Contract, + FakeGotchiNFTContract, listingInfo.erc721TokenId ); diff --git a/tests/handleERC721ExecutedListing.test.ts b/tests/handleERC721ExecutedListing.test.ts index 5033db3..bc38989 100644 --- a/tests/handleERC721ExecutedListing.test.ts +++ b/tests/handleERC721ExecutedListing.test.ts @@ -18,7 +18,7 @@ import { getERC721ListingMock, } from "./mocks"; import { getOrCreatePortal } from "../src/utils/helpers/diamond"; -import { Aavegotchi, ERC721Contract, ERC721Listing, ItemType } from "../generated/schema"; +import { Aavegotchi, FakeGotchiNFTContract, ERC721Listing, ItemType } from "../generated/schema"; test("handleERC721Listing - should add price to historicalPrices of aavegotchi if listing is aavegotchi", () => { // prepare event @@ -83,9 +83,9 @@ test("handleERC721Listing - should add price to historicalPrices of aavegotchi i listing.blockCreated = BIGINT_ZERO; listing.save(); - let erc721Contract = new ERC721Contract(event.params.erc721TokenAddress); - erc721Contract.asAccount = ZERO_ADDRESS; - erc721Contract.save(); + let FakeGotchiNFTContract = new FakeGotchiNFTContract(event.params.erc721TokenAddress); + FakeGotchiNFTContract.asAccount = ZERO_ADDRESS; + FakeGotchiNFTContract.save(); //try_getERC721Listing createMockedFunction( @@ -118,9 +118,9 @@ test("handleERC721Listing - should add price to historicalPrices of portal if li portal.save(); - let erc721Contract = new ERC721Contract(event.params.erc721TokenAddress); - erc721Contract.asAccount = ZERO_ADDRESS; - erc721Contract.save(); + let FakeGotchiNFTContract = new FakeGotchiNFTContract(event.params.erc721TokenAddress); + FakeGotchiNFTContract.asAccount = ZERO_ADDRESS; + FakeGotchiNFTContract.save(); createMockedFunction( event.address, @@ -187,9 +187,9 @@ test("handleERC721Listing - should set blockCreated to block number when listing listing.blockCreated = BIGINT_ZERO; listing.save(); - let erc721Contract = new ERC721Contract(event.params.erc721TokenAddress); - erc721Contract.asAccount = ZERO_ADDRESS; - erc721Contract.save(); + let FakeGotchiNFTContract = new FakeGotchiNFTContract(event.params.erc721TokenAddress); + FakeGotchiNFTContract.asAccount = ZERO_ADDRESS; + FakeGotchiNFTContract.save(); //try_getERC721Listing createMockedFunction( @@ -253,9 +253,9 @@ test("handleERC721Listing - reorg: should set block created if cancel events hap listing.blockCreated = BIGINT_ZERO; listing.save(); - let erc721Contract = new ERC721Contract(Address.fromString("0x86935F11C86623deC8a25696E1C19a8659CbF95d")); - erc721Contract.asAccount = ZERO_ADDRESS; - erc721Contract.save(); + let FakeGotchiNFTContract = new FakeGotchiNFTContract(Address.fromString("0x86935F11C86623deC8a25696E1C19a8659CbF95d")); + FakeGotchiNFTContract.asAccount = ZERO_ADDRESS; + FakeGotchiNFTContract.save(); //try_getERC721Listing createMockedFunction( diff --git a/tests/handleERC721ListingAdded.test.ts b/tests/handleERC721ListingAdded.test.ts index 57f6495..a8c2e9b 100644 --- a/tests/handleERC721ListingAdded.test.ts +++ b/tests/handleERC721ListingAdded.test.ts @@ -18,7 +18,7 @@ import { getERC721ListingMock, } from "./mocks"; import { getOrCreatePortal } from "../src/utils/helpers/diamond"; -import { Aavegotchi, ERC721Contract } from "../generated/schema"; +import { Aavegotchi, FakeGotchiNFTContract } from "../generated/schema"; test("should add gotchi name lower case if token is an aavegtochi", () => { // prepare event @@ -54,9 +54,9 @@ test("should add gotchi name lower case if token is an aavegtochi", () => { gotchi.timesTraded = BIGINT_ONE; gotchi.save(); - let erc721Contract = new ERC721Contract(event.params.erc721TokenAddress); - erc721Contract.asAccount = ZERO_ADDRESS; - erc721Contract.save(); + let FakeGotchiNFTContract = new FakeGotchiNFTContract(event.params.erc721TokenAddress); + FakeGotchiNFTContract.asAccount = ZERO_ADDRESS; + FakeGotchiNFTContract.save(); //try_getERC721Listing createMockedFunction( From a5b098ca0f31b5dd2962f86cab43f56548f32002 Mon Sep 17 00:00:00 2001 From: narayanprusty Date: Mon, 30 Oct 2023 19:52:40 +0000 Subject: [PATCH 15/42] ERC721 contract renamed to FakeGotchiCardContract --- schema.graphql | 8 ++++---- src/fetch/erc1155.ts | 10 +++++----- src/mappings/fakeGotchisCard.ts | 4 ++-- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/schema.graphql b/schema.graphql index 51cee95..634f677 100644 --- a/schema.graphql +++ b/schema.graphql @@ -152,7 +152,7 @@ type User @entity { # borrowedGotchis: [GotchiLending!]! @derivedFrom(field: "borrower") # lendGotchis: [GotchiLending!]! @derivedFrom(field: "originalOwner") - asERC1155: ERC1155Contract + asERC1155: FakeGotchiCardContract FakeGotchiCardBalances: [FakeGotchiCardBalance!]! @derivedFrom(field: "account") asERC721: FakeGotchiNFTContract @@ -473,7 +473,7 @@ type Transaction @entity(immutable: true) { } # Cards -type ERC1155Contract @entity(immutable: true) { +type FakeGotchiCardContract @entity(immutable: true) { id: Bytes! asAccount: User! tokens: [FakeGotchiCardToken!]! @derivedFrom(field: "contract") @@ -481,7 +481,7 @@ type ERC1155Contract @entity(immutable: true) { } type FakeGotchiCardToken @entity { id: ID! - contract: ERC1155Contract! + contract: FakeGotchiCardContract! identifier: BigInt! uri: String totalSupply: FakeGotchiCardBalance! @@ -490,7 +490,7 @@ type FakeGotchiCardToken @entity { } type FakeGotchiCardBalance @entity { id: ID! - contract: ERC1155Contract! + contract: FakeGotchiCardContract! token: FakeGotchiCardToken! account: User value: BigDecimal! diff --git a/src/fetch/erc1155.ts b/src/fetch/erc1155.ts index 112ad64..be70664 100644 --- a/src/fetch/erc1155.ts +++ b/src/fetch/erc1155.ts @@ -2,7 +2,7 @@ import { Address, BigInt } from "@graphprotocol/graph-ts"; import { User, - ERC1155Contract, + FakeGotchiCardContract, FakeGotchiCardToken, FakeGotchiCardBalance, } from "../../generated/schema"; @@ -22,10 +22,10 @@ export function replaceURI(uri: string, identifier: BigInt): string { ); } -export function fetchERC1155(address: Address): ERC1155Contract { - let contract = ERC1155Contract.load(address); +export function fetchERC1155(address: Address): FakeGotchiCardContract { + let contract = FakeGotchiCardContract.load(address); if (!contract) { - contract = new ERC1155Contract(address); + contract = new FakeGotchiCardContract(address); contract.asAccount = address.toHex(); contract.save(); @@ -38,7 +38,7 @@ export function fetchERC1155(address: Address): ERC1155Contract { } export function fetchFakeGotchiCardToken( - contract: ERC1155Contract, + contract: FakeGotchiCardContract, identifier: BigInt ): FakeGotchiCardToken { let id = contract.id diff --git a/src/mappings/fakeGotchisCard.ts b/src/mappings/fakeGotchisCard.ts index fb9de67..3a14330 100644 --- a/src/mappings/fakeGotchisCard.ts +++ b/src/mappings/fakeGotchisCard.ts @@ -2,7 +2,7 @@ import { ethereum, BigInt } from "@graphprotocol/graph-ts"; import { User, - ERC1155Contract, + FakeGotchiCardContract, Generation, } from "../../generated/schema"; @@ -33,7 +33,7 @@ import { getOrCreateUser } from "../utils/helpers/diamond"; function registerTransfer( event: ethereum.Event, suffix: string, - contract: ERC1155Contract, + contract: FakeGotchiCardContract, from: User, to: User, id: BigInt, From 0e0970825bd7b76683ddea851143b939b44d0b69 Mon Sep 17 00:00:00 2001 From: narayanprusty Date: Wed, 8 Nov 2023 23:48:34 +0000 Subject: [PATCH 16/42] enhanced vars --- schema.graphql | 10 ++++------ src/fetch/erc721.ts | 4 ++-- src/mappings/fakeGotchisNFT.ts | 6 +++--- src/utils/helpers/diamond.ts | 4 ++-- tests/.latest.json | 2 +- tests/handleTransfer.test.ts | 4 ++-- 6 files changed, 14 insertions(+), 16 deletions(-) diff --git a/schema.graphql b/schema.graphql index 634f677..ea8dc34 100644 --- a/schema.graphql +++ b/schema.graphql @@ -153,15 +153,13 @@ type User @entity { # lendGotchis: [GotchiLending!]! @derivedFrom(field: "originalOwner") asERC1155: FakeGotchiCardContract - FakeGotchiCardBalances: [FakeGotchiCardBalance!]! @derivedFrom(field: "account") + fakeGotchiCardBalances: [FakeGotchiCardBalance!]! @derivedFrom(field: "account") asERC721: FakeGotchiNFTContract - FakeGotchiNFTTokens: [FakeGotchiNFTToken!]! @derivedFrom(field: "owner") + fakeGotchiNFTTokens: [FakeGotchiNFTToken!]! @derivedFrom(field: "owner") - events: [Event!]! @derivedFrom(field: "emitter") - - tokens: String! # from array - amountTokens: Int! + fakeGotchis: String! # from array + amountFakeGotchis: Int! currentUniquePiecesOwned: Int! totalUniquePiecesOwned: Int! diff --git a/src/fetch/erc721.ts b/src/fetch/erc721.ts index a24ceb0..09a39f1 100644 --- a/src/fetch/erc721.ts +++ b/src/fetch/erc721.ts @@ -36,7 +36,7 @@ export function fetchERC721(address: Address): FakeGotchiNFTContract | null { detectionAccount.gotchisLentOut = new Array(); detectionAccount.gotchisBorrowed = new Array(); - detectionAccount.tokens = "{}"; + detectionAccount.fakeGotchis = "{}"; let introspection_01ffc9a7 = true; let introspection_80ac58cd = true; let introspection_00000000 = true; @@ -46,7 +46,7 @@ export function fetchERC721(address: Address): FakeGotchiNFTContract | null { introspection_00000000; detectionAccount.asERC721 = isERC721 ? address : null; - detectionAccount.amountTokens = 0; + detectionAccount.amountFakeGotchis = 0; detectionAccount.currentUniquePiecesOwned = 0; detectionAccount.currentUniquePiecesOwnedArray = "{}"; diff --git a/src/mappings/fakeGotchisNFT.ts b/src/mappings/fakeGotchisNFT.ts index b096aa6..1a9867d 100644 --- a/src/mappings/fakeGotchisNFT.ts +++ b/src/mappings/fakeGotchisNFT.ts @@ -79,7 +79,7 @@ export function handleTransfer(event: TransferEvent): void { // update account entity if (isMintFlag || isTransferFlag) { to = updateAccountStatsTo(to, metadata.id); - to.amountTokens = to.amountTokens + 1; + to.amountFakeGotchis = to.amountFakeGotchis + 1; let receiver = getNFTHolder(event.params._to, metadata.id); receiver.amount = receiver.amount + 1; @@ -95,7 +95,7 @@ export function handleTransfer(event: TransferEvent): void { if (isBurnFlag || isTransferFlag) { from = updateAccountStatsFrom(from, metadata.id); - from.amountTokens = from.amountTokens - 1; + from.amountFakeGotchis = from.amountFakeGotchis - 1; let sender = getNFTHolder(event.params._from, metadata.id); sender.amount = sender.amount - 1; @@ -108,7 +108,7 @@ export function handleTransfer(event: TransferEvent): void { stats = removeFromOwnersIfExistsAndBalanceNotZero( stats, event.params._from, - from.amountTokens + from.amountFakeGotchis ); } diff --git a/src/utils/helpers/diamond.ts b/src/utils/helpers/diamond.ts index e3fdf82..4269e9c 100644 --- a/src/utils/helpers/diamond.ts +++ b/src/utils/helpers/diamond.ts @@ -98,8 +98,8 @@ export function getOrCreateUser( user = new User(id); user.gotchisLentOut = new Array(); user.gotchisBorrowed = new Array(); - user.tokens = "{}"; - user.amountTokens = 0; + user.fakeGotchis = "{}"; + user.amountFakeGotchis = 0; user.currentUniquePiecesOwned = 0; user.currentUniquePiecesOwnedArray = "{}"; diff --git a/tests/.latest.json b/tests/.latest.json index d2ae00a..7e8b20f 100644 --- a/tests/.latest.json +++ b/tests/.latest.json @@ -1,4 +1,4 @@ { "version": "0.6.0", - "timestamp": 1698693753326 + "timestamp": 1699487185248 } \ No newline at end of file diff --git a/tests/handleTransfer.test.ts b/tests/handleTransfer.test.ts index 2bfeef1..f9d6c39 100644 --- a/tests/handleTransfer.test.ts +++ b/tests/handleTransfer.test.ts @@ -99,8 +99,8 @@ describe("handleTransfer", () => { senderAccount.totalUniquePiecesOwned = 0; senderAccount.currentUniquePiecesOwned = 0; senderAccount.currentUniquePiecesOwnedArray = "{}"; - senderAccount.tokens = "{}"; - senderAccount.amountTokens = 0; + senderAccount.fakeGotchis = "{}"; + senderAccount.amountFakeGotchis = 0; senderAccount.gotchisLentOut = new Array(); senderAccount.gotchisBorrowed = new Array(); From 2dec7a1e6ff76e1f6555aba66a2f5134535d8fc5 Mon Sep 17 00:00:00 2001 From: narayanprusty Date: Wed, 8 Nov 2023 23:55:38 +0000 Subject: [PATCH 17/42] renamed vars --- schema.graphql | 10 +++++----- src/fetch/account.ts | 18 +++++++++--------- src/fetch/erc721.ts | 10 +++++----- src/utils/helpers/diamond.ts | 10 +++++----- tests/handleTransfer.test.ts | 26 +++++++++++++------------- 5 files changed, 37 insertions(+), 37 deletions(-) diff --git a/schema.graphql b/schema.graphql index ea8dc34..742d47a 100644 --- a/schema.graphql +++ b/schema.graphql @@ -161,12 +161,12 @@ type User @entity { fakeGotchis: String! # from array amountFakeGotchis: Int! - currentUniquePiecesOwned: Int! - totalUniquePiecesOwned: Int! + currentUniqueFakeGotchisOwned: Int! + totalUniqueFakeGotchisOwned: Int! - currentUniquePiecesOwnedArray: String! # from array - totalUniquePiecesOwnedArray: String! # from array - totalPiecesOwnedArray: String! # from array + currentUniqueFakeGotchisOwnedArray: String! # from array + totalUniqueFakeGotchisOwnedArray: String! # from array + totalFakeGotchisOwnedArray: String! # from array } type ERC721Listing @entity { diff --git a/src/fetch/account.ts b/src/fetch/account.ts index 9331675..2d0e88e 100644 --- a/src/fetch/account.ts +++ b/src/fetch/account.ts @@ -14,7 +14,7 @@ export function updateAccountStatsFrom( metadataId: string ): User { const parsedJsonCurrent = json.fromString( - account.currentUniquePiecesOwnedArray + account.currentUniqueFakeGotchisOwnedArray ); const jsonObjCurrent = parsedJsonCurrent.toObject(); @@ -26,7 +26,7 @@ export function updateAccountStatsFrom( newAmount = entryCurrent.toBigInt().minus(BIGINT_ONE); } if (newAmount.equals(BIGINT_ZERO)) { - account.currentUniquePiecesOwned = account.currentUniquePiecesOwned - 1; + account.currentUniqueFakeGotchisOwned = account.currentUniqueFakeGotchisOwned - 1; } // received on token of that series, therefore +1 @@ -34,7 +34,7 @@ export function updateAccountStatsFrom( let newString = createJsonFromJSONObject(jsonObjCurrent); - account.currentUniquePiecesOwnedArray = newString; + account.currentUniqueFakeGotchisOwnedArray = newString; return account; } @@ -44,12 +44,12 @@ export function updateAccountStatsTo( metadataId: string ): User { const parsedJsonTotal = json.fromString( - account.totalUniquePiecesOwnedArray + account.totalUniqueFakeGotchisOwnedArray ); const jsonObjTotal = parsedJsonTotal.toObject(); const parsedJsonCurrent = json.fromString( - account.currentUniquePiecesOwnedArray + account.currentUniqueFakeGotchisOwnedArray ); const jsonObjCurrent = parsedJsonCurrent.toObject(); @@ -67,14 +67,14 @@ export function updateAccountStatsTo( } if (!entryTotal) { - account.totalUniquePiecesOwned = account.totalUniquePiecesOwned + 1; + account.totalUniqueFakeGotchisOwned = account.totalUniqueFakeGotchisOwned + 1; jsonObjTotal.set(metadataId, json.fromString(newAmount.toString())); } // update currentPiecesOwned if (newAmount.equals(BIGINT_ONE)) { // new piece - account.currentUniquePiecesOwned = account.currentUniquePiecesOwned + 1; + account.currentUniqueFakeGotchisOwned = account.currentUniqueFakeGotchisOwned + 1; } // received on token of that series, therefore +1 @@ -83,11 +83,11 @@ export function updateAccountStatsTo( // create new json object string let newString = createJsonFromJSONObject(jsonObjTotal); - account.totalUniquePiecesOwnedArray = newString; + account.totalUniqueFakeGotchisOwnedArray = newString; newString = createJsonFromJSONObject(jsonObjCurrent); - account.currentUniquePiecesOwnedArray = newString; + account.currentUniqueFakeGotchisOwnedArray = newString; return account; } diff --git a/src/fetch/erc721.ts b/src/fetch/erc721.ts index 09a39f1..ece312c 100644 --- a/src/fetch/erc721.ts +++ b/src/fetch/erc721.ts @@ -48,12 +48,12 @@ export function fetchERC721(address: Address): FakeGotchiNFTContract | null { detectionAccount.amountFakeGotchis = 0; - detectionAccount.currentUniquePiecesOwned = 0; - detectionAccount.currentUniquePiecesOwnedArray = "{}"; - detectionAccount.totalUniquePiecesOwned = 0; - detectionAccount.totalUniquePiecesOwnedArray = "{}"; + detectionAccount.currentUniqueFakeGotchisOwned = 0; + detectionAccount.currentUniqueFakeGotchisOwnedArray = "{}"; + detectionAccount.totalUniqueFakeGotchisOwned = 0; + detectionAccount.totalUniqueFakeGotchisOwnedArray = "{}"; - detectionAccount.totalPiecesOwnedArray = "{}"; + detectionAccount.totalFakeGotchisOwnedArray = "{}"; detectionAccount.save(); } diff --git a/src/utils/helpers/diamond.ts b/src/utils/helpers/diamond.ts index 4269e9c..5c5bccf 100644 --- a/src/utils/helpers/diamond.ts +++ b/src/utils/helpers/diamond.ts @@ -101,12 +101,12 @@ export function getOrCreateUser( user.fakeGotchis = "{}"; user.amountFakeGotchis = 0; - user.currentUniquePiecesOwned = 0; - user.currentUniquePiecesOwnedArray = "{}"; - user.totalUniquePiecesOwned = 0; - user.totalUniquePiecesOwnedArray = "{}"; + user.currentUniqueFakeGotchisOwned = 0; + user.currentUniqueFakeGotchisOwnedArray = "{}"; + user.totalUniqueFakeGotchisOwned = 0; + user.totalUniqueFakeGotchisOwnedArray = "{}"; - user.totalPiecesOwnedArray = "{}"; + user.totalFakeGotchisOwnedArray = "{}"; } return user as User; diff --git a/tests/handleTransfer.test.ts b/tests/handleTransfer.test.ts index f9d6c39..26cf6d6 100644 --- a/tests/handleTransfer.test.ts +++ b/tests/handleTransfer.test.ts @@ -94,11 +94,11 @@ describe("handleTransfer", () => { token.editions = 0; const senderAccount = new User(sender); - senderAccount.totalPiecesOwnedArray = "{}"; - senderAccount.totalUniquePiecesOwnedArray = "{}"; - senderAccount.totalUniquePiecesOwned = 0; - senderAccount.currentUniquePiecesOwned = 0; - senderAccount.currentUniquePiecesOwnedArray = "{}"; + senderAccount.totalFakeGotchisOwnedArray = "{}"; + senderAccount.totalUniqueFakeGotchisOwnedArray = "{}"; + senderAccount.totalUniqueFakeGotchisOwned = 0; + senderAccount.currentUniqueFakeGotchisOwned = 0; + senderAccount.currentUniqueFakeGotchisOwnedArray = "{}"; senderAccount.fakeGotchis = "{}"; senderAccount.amountFakeGotchis = 0; senderAccount.gotchisLentOut = new Array(); @@ -186,11 +186,11 @@ describe("handleTransfer", () => { assert.fieldEquals("NFTHolder", idSender, "nftStats", "1"); // account stats - assert.fieldEquals("User", receiver, "totalUniquePiecesOwned", "1"); + assert.fieldEquals("User", receiver, "totalUniqueFakeGotchisOwned", "1"); assert.fieldEquals( "User", receiver, - "currentUniquePiecesOwned", + "currentUniqueFakeGotchisOwned", "1" ); }); @@ -230,16 +230,16 @@ describe("handleTransfer", () => { assert.fieldEquals("NFTHolder", idReceiver, "nftStats", "1"); // User - assert.fieldEquals("User", receiver, "totalUniquePiecesOwned", "1"); + assert.fieldEquals("User", receiver, "totalUniqueFakeGotchisOwned", "1"); assert.fieldEquals( "User", receiver, - "currentUniquePiecesOwned", + "currentUniqueFakeGotchisOwned", "0" ); - assert.fieldEquals("User", sender, "totalUniquePiecesOwned", "1"); - assert.fieldEquals("User", sender, "currentUniquePiecesOwned", "1"); + assert.fieldEquals("User", sender, "totalUniqueFakeGotchisOwned", "1"); + assert.fieldEquals("User", sender, "currentUniqueFakeGotchisOwned", "1"); }); test("it should update total, nft and holder stats if tx is burn", () => { @@ -276,7 +276,7 @@ describe("handleTransfer", () => { assert.fieldEquals("NFTHolder", idSender, "nftStats", "1"); // User - assert.fieldEquals("User", sender, "totalUniquePiecesOwned", "1"); - assert.fieldEquals("User", sender, "currentUniquePiecesOwned", "0"); + assert.fieldEquals("User", sender, "totalUniqueFakeGotchisOwned", "1"); + assert.fieldEquals("User", sender, "currentUniqueFakeGotchisOwned", "0"); }); }); From 60864d13985e74255e07996f58189777bc677bf2 Mon Sep 17 00:00:00 2001 From: narayanprusty Date: Wed, 8 Nov 2023 23:58:28 +0000 Subject: [PATCH 18/42] removed unused fields --- schema.graphql | 6 ------ src/mappings/fakeGotchisNFT.ts | 1 - src/utils/helpers/diamond.ts | 5 ----- 3 files changed, 12 deletions(-) diff --git a/schema.graphql b/schema.graphql index 742d47a..dda0912 100644 --- a/schema.graphql +++ b/schema.graphql @@ -218,18 +218,13 @@ type ERC721Listing @entity { whitelist: Whitelist priceUpdatedAt: BigInt - fileHash: String name: String publisher: User publisherName: String - externalLink: String description: String artist: User artistName: String editions: Int - fileType: String - thumbnailHash: String - thumbnailType: String } type ERC1155Listing @entity { @@ -522,7 +517,6 @@ type FakeGotchiNFTToken @entity { artist: User artistName: String editions: Int - fileType: String thumbnailHash: String thumbnailType: String } diff --git a/src/mappings/fakeGotchisNFT.ts b/src/mappings/fakeGotchisNFT.ts index 1a9867d..76bb7dd 100644 --- a/src/mappings/fakeGotchisNFT.ts +++ b/src/mappings/fakeGotchisNFT.ts @@ -201,7 +201,6 @@ export function handleMetadataActionLog(event: MetadataActionLogEvent): void { token.publisher = event.params.metaData.publisher.toHexString(); token.publisherName = event.params.metaData.publisherName; token.editions = event.params.metaData.editions; - token.fileType = event.params.metaData.fileType; token.thumbnailHash = event.params.metaData.thumbnailHash; token.thumbnailType = event.params.metaData.thumbnailType; token.save(); diff --git a/src/utils/helpers/diamond.ts b/src/utils/helpers/diamond.ts index 5c5bccf..20fe402 100644 --- a/src/utils/helpers/diamond.ts +++ b/src/utils/helpers/diamond.ts @@ -226,17 +226,12 @@ export function updateERC721ListingInfo( listingInfo.erc721TokenId ); - listing.fileHash = erc721Token.fileHash; listing.name = erc721Token.name; listing.publisher = erc721Token.publisher; - listing.externalLink = erc721Token.externalLink; listing.description = erc721Token.description; listing.artist = erc721Token.artist; listing.artistName = erc721Token.artistName; listing.editions = erc721Token.editions; - listing.fileType = erc721Token.fileType; - listing.thumbnailHash = erc721Token.thumbnailHash; - listing.thumbnailType = erc721Token.thumbnailType; } if (listing.category.toI32() <= 2) { From 210110489aa345dde3bc9ae93afef63fffdf0f4f Mon Sep 17 00:00:00 2001 From: narayanprusty Date: Thu, 9 Nov 2023 00:02:02 +0000 Subject: [PATCH 19/42] remove txn and events --- schema.graphql | 18 ------------------ src/mappings/fakeGotchisNFT.ts | 5 ----- tests/handleTransfer.test.ts | 3 --- 3 files changed, 26 deletions(-) diff --git a/schema.graphql b/schema.graphql index dda0912..5b374db 100644 --- a/schema.graphql +++ b/schema.graphql @@ -452,19 +452,6 @@ type ERC721BuyOrder @entity { canceled: Boolean } -interface Event { - id: ID! - transaction: Transaction! - emitter: User! - timestamp: BigInt! -} -type Transaction @entity(immutable: true) { - id: ID! - timestamp: BigInt! - blockNumber: BigInt! - events: [Event!]! @derivedFrom(field: "transaction") -} - # Cards type FakeGotchiCardContract @entity(immutable: true) { id: Bytes! @@ -524,7 +511,6 @@ type FakeGotchiNFTToken @entity { type MetadataActionLog implements Event @entity { id: ID! emitter: User! - transaction: Transaction! timestamp: BigInt! sender: User minted: Boolean @@ -552,7 +538,6 @@ type MetadataActionLog implements Event @entity { type MetadataFlag implements Event @entity(immutable: true) { id: ID! emitter: User! - transaction: Transaction! timestamp: BigInt! token: FakeGotchiNFTToken sender: User @@ -564,7 +549,6 @@ type MetadataFlag implements Event @entity(immutable: true) { type MetadataLike implements Event @entity(immutable: true) { id: ID! emitter: User! - transaction: Transaction! timestamp: BigInt! token: FakeGotchiNFTToken sender: User @@ -576,7 +560,6 @@ type MetadataLike implements Event @entity(immutable: true) { type MetadataDecline implements Event @entity(immutable: true) { id: ID! emitter: User! - transaction: Transaction! timestamp: BigInt! token: FakeGotchiNFTToken sender: User @@ -588,7 +571,6 @@ type MetadataDecline implements Event @entity(immutable: true) { type ReviewPass implements Event @entity(immutable: true) { id: ID! emitter: User! - transaction: Transaction! timestamp: BigInt! token: FakeGotchiNFTToken sender: User diff --git a/src/mappings/fakeGotchisNFT.ts b/src/mappings/fakeGotchisNFT.ts index 76bb7dd..27e0a38 100644 --- a/src/mappings/fakeGotchisNFT.ts +++ b/src/mappings/fakeGotchisNFT.ts @@ -157,7 +157,6 @@ export function handleMetadataActionLog(event: MetadataActionLogEvent): void { let publisher = getOrCreateUser(event.params.metaData.publisher.toHexString()); ev.emitter = contract.id.toHexString(); - ev.transaction = transactions.log(event).id; ev.timestamp = event.block.timestamp; ev.minted = event.params.metaData.minted; ev.artist = artist.id; @@ -225,7 +224,6 @@ export function handleMetadataFlag(event: MetadataFlagEvent): void { let contract = fetchERC721(event.address)!; let token = fetchFakeGotchiNFTToken(contract, event.params._id); metadataflaggedEv.emitter = contract.id.toHexString(); - metadataflaggedEv.transaction = transactions.log(event).id; metadataflaggedEv.timestamp = event.block.timestamp; metadataflaggedEv.token = token.id; @@ -246,7 +244,6 @@ export function handleMetadataLike(event: MetadataLikeEvent): void { let contract = fetchERC721(event.address)!; let token = fetchFakeGotchiNFTToken(contract, event.params._id); metadatalikedEv.emitter = contract.id.toHexString(); - metadatalikedEv.transaction = transactions.log(event).id; metadatalikedEv.timestamp = event.block.timestamp; metadatalikedEv.token = token.id; @@ -267,7 +264,6 @@ export function handleMetadataDecline(event: MetadataDeclineEvent): void { let contract = fetchERC721(event.address)!; let token = fetchFakeGotchiNFTToken(contract, event.params._id); metadatalikedEv.emitter = contract.id.toHexString(); - metadatalikedEv.transaction = transactions.log(event).id; metadatalikedEv.timestamp = event.block.timestamp; metadatalikedEv.token = token.id; @@ -288,7 +284,6 @@ export function handleReviewPass(event: ReviewPassEvent): void { let contract = fetchERC721(event.address)!; let token = fetchFakeGotchiNFTToken(contract, event.params._id); reviewPassed.emitter = contract.id.toHexString(); - reviewPassed.transaction = transactions.log(event).id; reviewPassed.timestamp = event.block.timestamp; reviewPassed.token = token.id; reviewPassed.reviewer = reviewer.id; diff --git a/tests/handleTransfer.test.ts b/tests/handleTransfer.test.ts index 26cf6d6..ff0eecc 100644 --- a/tests/handleTransfer.test.ts +++ b/tests/handleTransfer.test.ts @@ -19,7 +19,6 @@ import { MetadataActionLog, NFTHolder, NFTStatistic, - Transaction, User, } from "../generated/schema"; import { @@ -74,10 +73,8 @@ const event = createTransferEvent(sender, receiver, tokenId); describe("handleTransfer", () => { beforeAll(() => { - const transaction = new Transaction("abc"); const log = new MetadataActionLog("1"); log.emitter = sender; - log.transaction = transaction.id; log.timestamp = BIGINT_ZERO; log.editions = 1; From 176a37c166276f76a931ba4225ee3ade83eb69c5 Mon Sep 17 00:00:00 2001 From: narayanprusty Date: Thu, 9 Nov 2023 19:27:04 +0000 Subject: [PATCH 20/42] rename entities --- schema.graphql | 8 ++++---- src/fetch/account.ts | 1 - src/helper/entities.ts | 20 ++++++++++---------- src/mappings/fakeGotchisNFT.ts | 10 +++++----- 4 files changed, 19 insertions(+), 20 deletions(-) diff --git a/schema.graphql b/schema.graphql index 5b374db..1d3438b 100644 --- a/schema.graphql +++ b/schema.graphql @@ -585,19 +585,19 @@ type Generation @entity { amount: Int } -type NFTStatistic @entity { +type FakeGotchiStatistic @entity { id: ID! metadata: MetadataActionLog - holders: [NFTHolder!]! @derivedFrom(field: "nftStats") + holders: [FakeGotchiHolder!]! @derivedFrom(field: "fakeGotchiStats") burned: Int amountHolder: Int totalSupply: Int tokenIds: [BigInt!]! } -type NFTHolder @entity { +type FakeGotchiHolder @entity { id: ID! - nftStats: NFTStatistic + fakeGotchiStats: FakeGotchiStatistic holder: User amount: Int } diff --git a/src/fetch/account.ts b/src/fetch/account.ts index 2d0e88e..0031533 100644 --- a/src/fetch/account.ts +++ b/src/fetch/account.ts @@ -3,7 +3,6 @@ import { Address, BigInt, Bytes, json, log } from "@graphprotocol/graph-ts"; import { User, MetadataActionLog, - NFTStatistic, Statistic, } from "../../generated/schema"; import { BIGINT_ONE, BIGINT_ZERO } from "../utils/constants"; diff --git a/src/helper/entities.ts b/src/helper/entities.ts index aae2c71..fd1513a 100644 --- a/src/helper/entities.ts +++ b/src/helper/entities.ts @@ -1,8 +1,8 @@ import { Address, BigInt, Bytes, ethereum } from "@graphprotocol/graph-ts"; import { Transfer } from "../../generated/FAKEGotchisNFTDiamond/IERC721"; import { - NFTHolder, - NFTStatistic, + FakeGotchiHolder, + FakeGotchiStatistic, Statistic } from "../../generated/schema"; import { ADDRESS_BURN, ADDRESS_DEAD, ADDRESS_ZERO, BIGINT_ZERO } from "../utils/constants"; @@ -45,10 +45,10 @@ export function getOrCreateStats(): Statistic { return stat; } -export function getOrCreateNFTStatistic(metadataId: string): NFTStatistic { - let stat = NFTStatistic.load(metadataId); +export function getOrCreateFakeGotchiStatistic(metadataId: string): FakeGotchiStatistic { + let stat = FakeGotchiStatistic.load(metadataId); if (!stat) { - stat = new NFTStatistic(metadataId); + stat = new FakeGotchiStatistic(metadataId); stat.burned = 0; stat.metadata = metadataId; stat.amountHolder = 0; @@ -59,17 +59,17 @@ export function getOrCreateNFTStatistic(metadataId: string): NFTStatistic { return stat; } -export function getNFTHolder( +export function getFakeGotchiHolder( holderAddress: Address, metadataId: string -): NFTHolder { +): FakeGotchiHolder { let id = holderAddress.toHexString() + "-" + metadataId; - let holder = NFTHolder.load(id); + let holder = FakeGotchiHolder.load(id); if (!holder) { - holder = new NFTHolder(id); + holder = new FakeGotchiHolder(id); holder.amount = 0; holder.holder = holderAddress.toHexString(); - holder.nftStats = metadataId; + holder.fakeGotchiStats = metadataId; } return holder; diff --git a/src/mappings/fakeGotchisNFT.ts b/src/mappings/fakeGotchisNFT.ts index 27e0a38..ad3ff87 100644 --- a/src/mappings/fakeGotchisNFT.ts +++ b/src/mappings/fakeGotchisNFT.ts @@ -41,8 +41,8 @@ import { } from "../fetch/erc721"; import { BigInt } from "@graphprotocol/graph-ts"; import { - getNFTHolder, - getOrCreateNFTStatistic, + getFakeGotchiHolder, + getOrCreateFakeGotchiStatistic, getOrCreateStats, isBurn, isMint, @@ -73,7 +73,7 @@ export function handleTransfer(event: TransferEvent): void { // fetch metadata let metadata = MetadataActionLog.load(token.metadata!)!; - let nftStats = getOrCreateNFTStatistic(metadata.id); + let nftStats = getOrCreateFakeGotchiStatistic(metadata.id); let stats = getOrCreateStats(); // update account entity @@ -81,7 +81,7 @@ export function handleTransfer(event: TransferEvent): void { to = updateAccountStatsTo(to, metadata.id); to.amountFakeGotchis = to.amountFakeGotchis + 1; - let receiver = getNFTHolder(event.params._to, metadata.id); + let receiver = getFakeGotchiHolder(event.params._to, metadata.id); receiver.amount = receiver.amount + 1; receiver.save(); @@ -97,7 +97,7 @@ export function handleTransfer(event: TransferEvent): void { from = updateAccountStatsFrom(from, metadata.id); from.amountFakeGotchis = from.amountFakeGotchis - 1; - let sender = getNFTHolder(event.params._from, metadata.id); + let sender = getFakeGotchiHolder(event.params._from, metadata.id); sender.amount = sender.amount - 1; sender.save(); From 7900e02c3ba5207bfbdda29ae5e744a6f4a8234e Mon Sep 17 00:00:00 2001 From: narayanprusty Date: Thu, 9 Nov 2023 19:34:04 +0000 Subject: [PATCH 21/42] removed ReviewPass --- schema.graphql | 11 ------ src/mappings/fakeGotchisNFT.ts | 20 ----------- subgraph.mumbai.yaml | 2 -- subgraph.yaml | 2 -- tests/handleTransfer.test.ts | 66 +++++++++++++++++----------------- 5 files changed, 32 insertions(+), 69 deletions(-) diff --git a/schema.graphql b/schema.graphql index 1d3438b..931ad6c 100644 --- a/schema.graphql +++ b/schema.graphql @@ -568,17 +568,6 @@ type MetadataDecline implements Event @entity(immutable: true) { metadata: MetadataActionLog } -type ReviewPass implements Event @entity(immutable: true) { - id: ID! - emitter: User! - timestamp: BigInt! - token: FakeGotchiNFTToken - sender: User - - reviewer: User - metadata: MetadataActionLog -} - type Generation @entity { "a generation is a series" id: ID! diff --git a/src/mappings/fakeGotchisNFT.ts b/src/mappings/fakeGotchisNFT.ts index ad3ff87..6706bee 100644 --- a/src/mappings/fakeGotchisNFT.ts +++ b/src/mappings/fakeGotchisNFT.ts @@ -3,7 +3,6 @@ import { MetadataDecline, MetadataFlag, MetadataLike, - ReviewPass } from "../../generated/schema"; import { @@ -271,22 +270,3 @@ export function handleMetadataDecline(event: MetadataDeclineEvent): void { metadatalikedEv.metadata = metadata.id; metadatalikedEv.save(); } - -export function handleReviewPass(event: ReviewPassEvent): void { - let metadata = MetadataActionLog.load(event.params._id.toString())!; - metadata.status = METADATA_STATUS_PENDING; - metadata.save(); - - let reviewer = getOrCreateUser(event.params._reviewer.toHexString()); - reviewer.save(); - - let reviewPassed = new ReviewPass(events.id(event)); - let contract = fetchERC721(event.address)!; - let token = fetchFakeGotchiNFTToken(contract, event.params._id); - reviewPassed.emitter = contract.id.toHexString(); - reviewPassed.timestamp = event.block.timestamp; - reviewPassed.token = token.id; - reviewPassed.reviewer = reviewer.id; - reviewPassed.metadata = metadata.id; - reviewPassed.save(); -} diff --git a/subgraph.mumbai.yaml b/subgraph.mumbai.yaml index d1ebc55..0297ae4 100644 --- a/subgraph.mumbai.yaml +++ b/subgraph.mumbai.yaml @@ -298,8 +298,6 @@ dataSources: handler: handleMetadataFlag - event: MetadataLike(indexed uint256,address) handler: handleMetadataLike - - event: ReviewPass(indexed uint256,address) - handler: handleReviewPass - event: MetadataDecline(indexed uint256,address) handler: handleMetadataDecline file: ./src/mappings/fakeGotchisNFT.ts \ No newline at end of file diff --git a/subgraph.yaml b/subgraph.yaml index 0fe1b1a..4f57399 100644 --- a/subgraph.yaml +++ b/subgraph.yaml @@ -298,8 +298,6 @@ dataSources: handler: handleMetadataFlag - event: MetadataLike(indexed uint256,address) handler: handleMetadataLike - - event: ReviewPass(indexed uint256,address) - handler: handleReviewPass - event: MetadataDecline(indexed uint256,address) handler: handleMetadataDecline file: ./src/mappings/fakeGotchisNFT.ts diff --git a/tests/handleTransfer.test.ts b/tests/handleTransfer.test.ts index ff0eecc..2663368 100644 --- a/tests/handleTransfer.test.ts +++ b/tests/handleTransfer.test.ts @@ -1,7 +1,6 @@ import { Address, BigInt, - Bytes, ethereum, store, } from "@graphprotocol/graph-ts"; @@ -17,8 +16,7 @@ import { Transfer } from "../generated/FAKEGotchisNFTDiamond/IERC721"; import { FakeGotchiNFTToken, MetadataActionLog, - NFTHolder, - NFTStatistic, + FakeGotchiHolder, User, } from "../generated/schema"; import { @@ -101,19 +99,19 @@ describe("handleTransfer", () => { senderAccount.gotchisLentOut = new Array(); senderAccount.gotchisBorrowed = new Array(); - const holder = new NFTHolder( + const holder = new FakeGotchiHolder( "0x46a3a41bd932244dd08186e4c19f1a7e48cbcdf4-1" ); holder.amount = 0; holder.holder = receiver; - holder.nftStats = "1"; + holder.fakeGotchiStats = "1"; store.set("MetadataActionLog", "1", log); store.set("FakeGotchiNFTToken", tokenEntityId, token); store.set("User", sender, senderAccount); - // store.set("NFTStatistic", "1", nftStats); + // store.set("FakeGotchiStatistic", "1", fakeGotchiStats); store.set( - "NFTHolder", + "FakeGotchiHolder", "0x46a3a41bd932244dd08186e4c19f1a7e48cbcdf4-1", holder ); @@ -170,17 +168,17 @@ describe("handleTransfer", () => { assert.fieldEquals("Statistic", "0", "totalOwners", "1"); // nft stats - assert.fieldEquals("NFTStatistic", "1", "burned", "0"); - assert.fieldEquals("NFTStatistic", "1", "amountHolder", "1"); - assert.fieldEquals("NFTStatistic", "1", "totalSupply", "1"); - assert.fieldEquals("NFTStatistic", "1", "metadata", "1"); - assert.fieldEquals("NFTStatistic", "1", "tokenIds", "[1]"); + assert.fieldEquals("FakeGotchiStatistic", "1", "burned", "0"); + assert.fieldEquals("FakeGotchiStatistic", "1", "amountHolder", "1"); + assert.fieldEquals("FakeGotchiStatistic", "1", "totalSupply", "1"); + assert.fieldEquals("FakeGotchiStatistic", "1", "metadata", "1"); + assert.fieldEquals("FakeGotchiStatistic", "1", "tokenIds", "[1]"); // NFT Holder Stats let idSender = receiver + "-1"; - assert.fieldEquals("NFTHolder", idSender, "holder", receiver); - assert.fieldEquals("NFTHolder", idSender, "amount", "1"); - assert.fieldEquals("NFTHolder", idSender, "nftStats", "1"); + assert.fieldEquals("FakeGotchiHolder", idSender, "holder", receiver); + assert.fieldEquals("FakeGotchiHolder", idSender, "amount", "1"); + assert.fieldEquals("FakeGotchiHolder", idSender, "fakeGotchiStats", "1"); // account stats assert.fieldEquals("User", receiver, "totalUniqueFakeGotchisOwned", "1"); @@ -209,22 +207,22 @@ describe("handleTransfer", () => { assert.fieldEquals("Statistic", "0", "totalOwners", "1"); // NFT Stats - assert.fieldEquals("NFTStatistic", "1", "burned", "0"); - assert.fieldEquals("NFTStatistic", "1", "amountHolder", "1"); - assert.fieldEquals("NFTStatistic", "1", "totalSupply", "1"); - assert.fieldEquals("NFTStatistic", "1", "metadata", "1"); - assert.fieldEquals("NFTStatistic", "1", "tokenIds", "[1]"); + assert.fieldEquals("FakeGotchiStatistic", "1", "burned", "0"); + assert.fieldEquals("FakeGotchiStatistic", "1", "amountHolder", "1"); + assert.fieldEquals("FakeGotchiStatistic", "1", "totalSupply", "1"); + assert.fieldEquals("FakeGotchiStatistic", "1", "metadata", "1"); + assert.fieldEquals("FakeGotchiStatistic", "1", "tokenIds", "[1]"); // NFT Holder Stats let idSender = receiver + "-1"; - assert.fieldEquals("NFTHolder", idSender, "holder", receiver); - assert.fieldEquals("NFTHolder", idSender, "amount", "0"); - assert.fieldEquals("NFTHolder", idSender, "nftStats", "1"); + assert.fieldEquals("FakeGotchiHolder", idSender, "holder", receiver); + assert.fieldEquals("FakeGotchiHolder", idSender, "amount", "0"); + assert.fieldEquals("FakeGotchiHolder", idSender, "fakeGotchiStats", "1"); let idReceiver = sender + "-1"; - assert.fieldEquals("NFTHolder", idReceiver, "holder", sender); - assert.fieldEquals("NFTHolder", idReceiver, "amount", "1"); - assert.fieldEquals("NFTHolder", idReceiver, "nftStats", "1"); + assert.fieldEquals("FakeGotchiHolder", idReceiver, "holder", sender); + assert.fieldEquals("FakeGotchiHolder", idReceiver, "amount", "1"); + assert.fieldEquals("FakeGotchiHolder", idReceiver, "fakeGotchiStats", "1"); // User assert.fieldEquals("User", receiver, "totalUniqueFakeGotchisOwned", "1"); @@ -260,17 +258,17 @@ describe("handleTransfer", () => { assert.fieldEquals("Statistic", "0", "totalOwners", "0"); // NFT Stats - assert.fieldEquals("NFTStatistic", "1", "burned", "1"); - assert.fieldEquals("NFTStatistic", "1", "amountHolder", "0"); - assert.fieldEquals("NFTStatistic", "1", "totalSupply", "0"); - assert.fieldEquals("NFTStatistic", "1", "metadata", "1"); - assert.fieldEquals("NFTStatistic", "1", "tokenIds", "[]"); + assert.fieldEquals("FakeGotchiStatistic", "1", "burned", "1"); + assert.fieldEquals("FakeGotchiStatistic", "1", "amountHolder", "0"); + assert.fieldEquals("FakeGotchiStatistic", "1", "totalSupply", "0"); + assert.fieldEquals("FakeGotchiStatistic", "1", "metadata", "1"); + assert.fieldEquals("FakeGotchiStatistic", "1", "tokenIds", "[]"); // NFT Holder Stats let idSender = sender + "-1"; - assert.fieldEquals("NFTHolder", idSender, "holder", sender); - assert.fieldEquals("NFTHolder", idSender, "amount", "0"); - assert.fieldEquals("NFTHolder", idSender, "nftStats", "1"); + assert.fieldEquals("FakeGotchiHolder", idSender, "holder", sender); + assert.fieldEquals("FakeGotchiHolder", idSender, "amount", "0"); + assert.fieldEquals("FakeGotchiHolder", idSender, "fakeGotchiStats", "1"); // User assert.fieldEquals("User", sender, "totalUniqueFakeGotchisOwned", "1"); From e650413f0064d67cc092a74e2e1c0dcc9760e7d0 Mon Sep 17 00:00:00 2001 From: narayanprusty Date: Thu, 9 Nov 2023 19:36:49 +0000 Subject: [PATCH 22/42] removed MetadataDecline --- schema.graphql | 11 ----------- src/mappings/fakeGotchisNFT.ts | 24 +----------------------- subgraph.mumbai.yaml | 2 -- subgraph.yaml | 2 -- 4 files changed, 1 insertion(+), 38 deletions(-) diff --git a/schema.graphql b/schema.graphql index 931ad6c..6f00dc3 100644 --- a/schema.graphql +++ b/schema.graphql @@ -557,17 +557,6 @@ type MetadataLike implements Event @entity(immutable: true) { metadata: MetadataActionLog } -type MetadataDecline implements Event @entity(immutable: true) { - id: ID! - emitter: User! - timestamp: BigInt! - token: FakeGotchiNFTToken - sender: User - - declinedBy: User - metadata: MetadataActionLog -} - type Generation @entity { "a generation is a series" id: ID! diff --git a/src/mappings/fakeGotchisNFT.ts b/src/mappings/fakeGotchisNFT.ts index 6706bee..2d42dc4 100644 --- a/src/mappings/fakeGotchisNFT.ts +++ b/src/mappings/fakeGotchisNFT.ts @@ -1,6 +1,5 @@ import { MetadataActionLog, - MetadataDecline, MetadataFlag, MetadataLike, } from "../../generated/schema"; @@ -8,7 +7,6 @@ import { import { MetadataActionLog as MetadataActionLogEvent, MetadataLike as MetadataLikeEvent, - MetadataDecline as MetadataDeclineEvent, ReviewPass as ReviewPassEvent, Approval as ApprovalEvent, ApprovalForAll as ApprovalForAllEvent, @@ -249,24 +247,4 @@ export function handleMetadataLike(event: MetadataLikeEvent): void { metadatalikedEv.likedBy = liker.id; metadatalikedEv.metadata = metadata.id; metadatalikedEv.save(); -} - -export function handleMetadataDecline(event: MetadataDeclineEvent): void { - let metadata = MetadataActionLog.load(event.params._id.toString())!; - metadata.status = METADATA_STATUS_DECLINED; - metadata.save(); - - let decliner = getOrCreateUser(event.params._declinedBy.toHexString()); - decliner.save(); - - let metadatalikedEv = new MetadataDecline(events.id(event)); - let contract = fetchERC721(event.address)!; - let token = fetchFakeGotchiNFTToken(contract, event.params._id); - metadatalikedEv.emitter = contract.id.toHexString(); - metadatalikedEv.timestamp = event.block.timestamp; - metadatalikedEv.token = token.id; - - metadatalikedEv.declinedBy = decliner.id; - metadatalikedEv.metadata = metadata.id; - metadatalikedEv.save(); -} +} \ No newline at end of file diff --git a/subgraph.mumbai.yaml b/subgraph.mumbai.yaml index 0297ae4..2bc7b81 100644 --- a/subgraph.mumbai.yaml +++ b/subgraph.mumbai.yaml @@ -298,6 +298,4 @@ dataSources: handler: handleMetadataFlag - event: MetadataLike(indexed uint256,address) handler: handleMetadataLike - - event: MetadataDecline(indexed uint256,address) - handler: handleMetadataDecline file: ./src/mappings/fakeGotchisNFT.ts \ No newline at end of file diff --git a/subgraph.yaml b/subgraph.yaml index 4f57399..8693fea 100644 --- a/subgraph.yaml +++ b/subgraph.yaml @@ -298,6 +298,4 @@ dataSources: handler: handleMetadataFlag - event: MetadataLike(indexed uint256,address) handler: handleMetadataLike - - event: MetadataDecline(indexed uint256,address) - handler: handleMetadataDecline file: ./src/mappings/fakeGotchisNFT.ts From d846afd038ac4077ba06fefba0fdf94930910283 Mon Sep 17 00:00:00 2001 From: narayanprusty Date: Thu, 9 Nov 2023 19:46:37 +0000 Subject: [PATCH 23/42] removed MetadataFlag and MetadataLike --- schema.graphql | 24 ------------------------ src/mappings/fakeGotchisNFT.ts | 14 -------------- 2 files changed, 38 deletions(-) diff --git a/schema.graphql b/schema.graphql index 6f00dc3..30e3869 100644 --- a/schema.graphql +++ b/schema.graphql @@ -529,34 +529,10 @@ type MetadataActionLog implements Event @entity { thumbnailHash: String thumbnailType: String flagCount: Int - flags: [MetadataFlag!]! @derivedFrom(field: "metadata") likeCount: Int - likes: [MetadataLike!]! @derivedFrom(field: "metadata") status: Int } -type MetadataFlag implements Event @entity(immutable: true) { - id: ID! - emitter: User! - timestamp: BigInt! - token: FakeGotchiNFTToken - sender: User - - flaggedBy: User - metadata: MetadataActionLog -} - -type MetadataLike implements Event @entity(immutable: true) { - id: ID! - emitter: User! - timestamp: BigInt! - token: FakeGotchiNFTToken - sender: User - - likedBy: User - metadata: MetadataActionLog -} - type Generation @entity { "a generation is a series" id: ID! diff --git a/src/mappings/fakeGotchisNFT.ts b/src/mappings/fakeGotchisNFT.ts index 2d42dc4..ebdc72b 100644 --- a/src/mappings/fakeGotchisNFT.ts +++ b/src/mappings/fakeGotchisNFT.ts @@ -1,15 +1,11 @@ import { MetadataActionLog, MetadataFlag, - MetadataLike, } from "../../generated/schema"; import { MetadataActionLog as MetadataActionLogEvent, MetadataLike as MetadataLikeEvent, - ReviewPass as ReviewPassEvent, - Approval as ApprovalEvent, - ApprovalForAll as ApprovalForAllEvent, Transfer as TransferEvent, MetadataFlag as MetadataFlagEvent } from "../../generated/FAKEGotchisNFTDiamond/IERC721"; @@ -237,14 +233,4 @@ export function handleMetadataLike(event: MetadataLikeEvent): void { let liker = getOrCreateUser(event.params._likedBy.toHexString()); liker.save(); - let metadatalikedEv = new MetadataLike(events.id(event)); - let contract = fetchERC721(event.address)!; - let token = fetchFakeGotchiNFTToken(contract, event.params._id); - metadatalikedEv.emitter = contract.id.toHexString(); - metadatalikedEv.timestamp = event.block.timestamp; - metadatalikedEv.token = token.id; - - metadatalikedEv.likedBy = liker.id; - metadatalikedEv.metadata = metadata.id; - metadatalikedEv.save(); } \ No newline at end of file From 0d23d6b1ec1919312c777c6b0f6d16030e1bf619 Mon Sep 17 00:00:00 2001 From: narayanprusty Date: Thu, 9 Nov 2023 19:58:50 +0000 Subject: [PATCH 24/42] removed FakeGotchiCardContract --- schema.graphql | 13 +++---------- src/fetch/erc1155.ts | 24 ++++-------------------- src/mappings/fakeGotchisCard.ts | 15 +++++---------- src/mappings/fakeGotchisNFT.ts | 12 ------------ 4 files changed, 12 insertions(+), 52 deletions(-) diff --git a/schema.graphql b/schema.graphql index 30e3869..28dad43 100644 --- a/schema.graphql +++ b/schema.graphql @@ -152,10 +152,9 @@ type User @entity { # borrowedGotchis: [GotchiLending!]! @derivedFrom(field: "borrower") # lendGotchis: [GotchiLending!]! @derivedFrom(field: "originalOwner") - asERC1155: FakeGotchiCardContract fakeGotchiCardBalances: [FakeGotchiCardBalance!]! @derivedFrom(field: "account") - asERC721: FakeGotchiNFTContract + asERC721: FakeGotchiNFTContract fakeGotchiNFTTokens: [FakeGotchiNFTToken!]! @derivedFrom(field: "owner") fakeGotchis: String! # from array @@ -453,15 +452,9 @@ type ERC721BuyOrder @entity { } # Cards -type FakeGotchiCardContract @entity(immutable: true) { - id: Bytes! - asAccount: User! - tokens: [FakeGotchiCardToken!]! @derivedFrom(field: "contract") - balances: [FakeGotchiCardBalance!]! @derivedFrom(field: "contract") -} type FakeGotchiCardToken @entity { id: ID! - contract: FakeGotchiCardContract! + contract: Bytes! identifier: BigInt! uri: String totalSupply: FakeGotchiCardBalance! @@ -470,7 +463,7 @@ type FakeGotchiCardToken @entity { } type FakeGotchiCardBalance @entity { id: ID! - contract: FakeGotchiCardContract! + contract: Bytes! token: FakeGotchiCardToken! account: User value: BigDecimal! diff --git a/src/fetch/erc1155.ts b/src/fetch/erc1155.ts index be70664..87a275c 100644 --- a/src/fetch/erc1155.ts +++ b/src/fetch/erc1155.ts @@ -2,7 +2,6 @@ import { Address, BigInt } from "@graphprotocol/graph-ts"; import { User, - FakeGotchiCardContract, FakeGotchiCardToken, FakeGotchiCardBalance, } from "../../generated/schema"; @@ -22,36 +21,21 @@ export function replaceURI(uri: string, identifier: BigInt): string { ); } -export function fetchERC1155(address: Address): FakeGotchiCardContract { - let contract = FakeGotchiCardContract.load(address); - if (!contract) { - contract = new FakeGotchiCardContract(address); - contract.asAccount = address.toHex(); - contract.save(); - - let account = getOrCreateUser(address.toHex()); - account.asERC1155 = address; - account.save(); - } - - return contract; -} - export function fetchFakeGotchiCardToken( - contract: FakeGotchiCardContract, + contract: Address, identifier: BigInt ): FakeGotchiCardToken { - let id = contract.id + let id = contract .toHex() .concat("/") .concat(identifier.toHex()); let token = FakeGotchiCardToken.load(id); if (token == null) { - let erc1155 = IERC1155.bind(Address.fromBytes(contract.id)); + let erc1155 = IERC1155.bind(contract); let try_uri = erc1155.try_uri(identifier); token = new FakeGotchiCardToken(id); - token.contract = contract.id; + token.contract = contract; token.identifier = identifier; token.totalSupply = fetchFakeGotchiCardBalance(token as FakeGotchiCardToken, null).id; token.uri = try_uri.reverted diff --git a/src/mappings/fakeGotchisCard.ts b/src/mappings/fakeGotchisCard.ts index 3a14330..f05bfee 100644 --- a/src/mappings/fakeGotchisCard.ts +++ b/src/mappings/fakeGotchisCard.ts @@ -1,8 +1,7 @@ -import { ethereum, BigInt } from "@graphprotocol/graph-ts"; +import { ethereum, BigInt, Address } from "@graphprotocol/graph-ts"; import { User, - FakeGotchiCardContract, Generation, } from "../../generated/schema"; @@ -23,7 +22,6 @@ import { } from "@amxx/graphprotocol-utils"; import { - fetchERC1155, fetchFakeGotchiCardToken, fetchFakeGotchiCardBalance, replaceURI, @@ -33,7 +31,7 @@ import { getOrCreateUser } from "../utils/helpers/diamond"; function registerTransfer( event: ethereum.Event, suffix: string, - contract: FakeGotchiCardContract, + contract: Address, from: User, to: User, id: BigInt, @@ -70,14 +68,13 @@ function registerTransfer( } export function handleTransferSingle(event: TransferSingleEvent): void { - let contract = fetchERC1155(event.address); let from = getOrCreateUser(event.params._from.toHex()); let to = getOrCreateUser(event.params._to.toHex()); registerTransfer( event, "", - contract, + event.address, from, to, event.params._id, @@ -86,7 +83,6 @@ export function handleTransferSingle(event: TransferSingleEvent): void { } export function handleTransferBatch(event: TransferBatchEvent): void { - let contract = fetchERC1155(event.address); let from = getOrCreateUser(event.params._from.toHex()); let to = getOrCreateUser(event.params._to.toHex()); @@ -101,7 +97,7 @@ export function handleTransferBatch(event: TransferBatchEvent): void { registerTransfer( event, "/".concat(i.toString()), - contract, + event.address, from, to, ids[i], @@ -112,8 +108,7 @@ export function handleTransferBatch(event: TransferBatchEvent): void { } export function handleURI(event: URIEvent): void { - let contract = fetchERC1155(event.address); - let token = fetchFakeGotchiCardToken(contract, event.params._id); + let token = fetchFakeGotchiCardToken(event.address, event.params._id); token.uri = replaceURI(event.params._value, event.params._id); token.save(); } diff --git a/src/mappings/fakeGotchisNFT.ts b/src/mappings/fakeGotchisNFT.ts index ebdc72b..c288239 100644 --- a/src/mappings/fakeGotchisNFT.ts +++ b/src/mappings/fakeGotchisNFT.ts @@ -1,6 +1,5 @@ import { MetadataActionLog, - MetadataFlag, } from "../../generated/schema"; import { @@ -212,17 +211,6 @@ export function handleMetadataFlag(event: MetadataFlagEvent): void { let flagger = getOrCreateUser(event.params._flaggedBy.toHexString()); flagger.save(); - - let metadataflaggedEv = new MetadataFlag(events.id(event)); - let contract = fetchERC721(event.address)!; - let token = fetchFakeGotchiNFTToken(contract, event.params._id); - metadataflaggedEv.emitter = contract.id.toHexString(); - metadataflaggedEv.timestamp = event.block.timestamp; - metadataflaggedEv.token = token.id; - - metadataflaggedEv.flaggedBy = flagger.id; - metadataflaggedEv.metadata = metadata.id; - metadataflaggedEv.save(); } export function handleMetadataLike(event: MetadataLikeEvent): void { From 877f16dfdea20b1552d1a290a01064d384363f7f Mon Sep 17 00:00:00 2001 From: narayanprusty Date: Thu, 9 Nov 2023 22:54:37 +0000 Subject: [PATCH 25/42] removed FakeGotchiNFTContract --- schema.graphql | 12 +- src/fetch/erc721.ts | 91 ++++------------ src/mappings/fakeGotchisNFT.ts | 127 ++++++++++------------ src/utils/helpers/diamond.ts | 17 ++- tests/handleERC721ExecutedListing.test.ts | 24 +--- tests/handleERC721ListingAdded.test.ts | 6 +- 6 files changed, 92 insertions(+), 185 deletions(-) diff --git a/schema.graphql b/schema.graphql index 28dad43..8e75358 100644 --- a/schema.graphql +++ b/schema.graphql @@ -153,8 +153,6 @@ type User @entity { # lendGotchis: [GotchiLending!]! @derivedFrom(field: "originalOwner") fakeGotchiCardBalances: [FakeGotchiCardBalance!]! @derivedFrom(field: "account") - - asERC721: FakeGotchiNFTContract fakeGotchiNFTTokens: [FakeGotchiNFTToken!]! @derivedFrom(field: "owner") fakeGotchis: String! # from array @@ -471,17 +469,9 @@ type FakeGotchiCardBalance @entity { } # NFT 721 -type FakeGotchiNFTContract @entity(immutable: true) { - id: Bytes! - asAccount: User! - supportsMetadata: Boolean - name: String - symbol: String - tokens: [FakeGotchiNFTToken!]! @derivedFrom(field: "contract") -} type FakeGotchiNFTToken @entity { id: ID! - contract: FakeGotchiNFTContract! + contract: Bytes! identifier: BigInt! owner: User! approval: User! diff --git a/src/fetch/erc721.ts b/src/fetch/erc721.ts index ece312c..2764ab1 100644 --- a/src/fetch/erc721.ts +++ b/src/fetch/erc721.ts @@ -3,12 +3,12 @@ import { BigInt, Bytes, JSONValue, - TypedMap + TypedMap, + log } from "@graphprotocol/graph-ts"; import { User, - FakeGotchiNFTContract, FakeGotchiNFTToken, } from "../../generated/schema"; @@ -17,71 +17,11 @@ import { constants } from "@amxx/graphprotocol-utils"; import { IERC721 } from "../../generated/FAKEGotchisNFTDiamond/IERC721"; import { getOrCreateUser } from "../utils/helpers/diamond"; -export function fetchERC721(address: Address): FakeGotchiNFTContract | null { - let erc721 = IERC721.bind(address); - - // Try load entry - let contract = FakeGotchiNFTContract.load(address); - if (contract != null) { - return contract; - } - - // Detect using ERC165 - let detectionId = address.concat(Bytes.fromHexString("80ac58cd")); // Address + ERC721 - let detectionAccount = User.load(detectionId.toHex()); - - // On missing cache - if (detectionAccount == null) { - detectionAccount = new User(detectionId.toHex()); - detectionAccount.gotchisLentOut = new Array(); - detectionAccount.gotchisBorrowed = new Array(); - - detectionAccount.fakeGotchis = "{}"; - let introspection_01ffc9a7 = true; - let introspection_80ac58cd = true; - let introspection_00000000 = true; - let isERC721 = - introspection_01ffc9a7 && - introspection_80ac58cd && - introspection_00000000; - detectionAccount.asERC721 = isERC721 ? address : null; - - detectionAccount.amountFakeGotchis = 0; - - detectionAccount.currentUniqueFakeGotchisOwned = 0; - detectionAccount.currentUniqueFakeGotchisOwnedArray = "{}"; - detectionAccount.totalUniqueFakeGotchisOwned = 0; - detectionAccount.totalUniqueFakeGotchisOwnedArray = "{}"; - - detectionAccount.totalFakeGotchisOwnedArray = "{}"; - - detectionAccount.save(); - } - - // If an ERC721, build entry - if (detectionAccount.asERC721) { - contract = new FakeGotchiNFTContract(address); - let try_name = erc721.try_name(); - let try_symbol = erc721.try_symbol(); - contract.name = try_name.reverted ? "" : try_name.value; - contract.symbol = try_symbol.reverted ? "" : try_symbol.value; - contract.supportsMetadata = true; - contract.asAccount = address.toHex(); - contract.save(); - - let account = getOrCreateUser(address.toHex()); - account.asERC721 = address; - account.save(); - } - - return contract; -} - export function fetchFakeGotchiNFTToken( - contract: FakeGotchiNFTContract, + contract: Address, identifier: BigInt ): FakeGotchiNFTToken { - let id = contract.id + let id = contract .toHex() .concat("/") .concat(identifier.toHex()); @@ -89,16 +29,27 @@ export function fetchFakeGotchiNFTToken( if (token == null) { token = new FakeGotchiNFTToken(id); - token.contract = contract.id; + token.contract = contract; token.identifier = identifier; token.approval = getOrCreateUser(constants.ADDRESS_ZERO.toHex()).id; - if (contract.supportsMetadata) { - let erc721 = IERC721.bind(Address.fromBytes(contract.id)); - let try_tokenURI = erc721.try_tokenURI(identifier); - token.uri = try_tokenURI.reverted ? "" : try_tokenURI.value; - } + let erc721 = IERC721.bind(Address.fromBytes(contract)); + let try_tokenURI = erc721.try_tokenURI(identifier); + token.uri = try_tokenURI.reverted ? "" : try_tokenURI.value; } + return token as FakeGotchiNFTToken; +} + +export function getFakeGotchiNFTToken( + contract: Address, + identifier: BigInt +): FakeGotchiNFTToken | null { + let id = contract + .toHex() + .concat("/") + .concat(identifier.toHex()); + let token = FakeGotchiNFTToken.load(id); + return token; } \ No newline at end of file diff --git a/src/mappings/fakeGotchisNFT.ts b/src/mappings/fakeGotchisNFT.ts index c288239..5bdc1e8 100644 --- a/src/mappings/fakeGotchisNFT.ts +++ b/src/mappings/fakeGotchisNFT.ts @@ -28,7 +28,6 @@ import { } from "../utils/constants"; import { - fetchERC721, fetchFakeGotchiNFTToken, } from "../fetch/erc721"; import { BigInt } from "@graphprotocol/graph-ts"; @@ -47,19 +46,12 @@ export function handleTransfer(event: TransferEvent): void { const isBurnFlag = isBurn(event); const isTransferFlag = isTransfer(event); - // fetch contract - const contract = fetchERC721(event.address); - if (contract == null) { - return; - } - contract.save(); - // fetch sender and receiver let from = getOrCreateUser(event.params._from.toHexString()); let to = getOrCreateUser(event.params._to.toHexString()); // update token owner - let token = fetchFakeGotchiNFTToken(contract, event.params._tokenId); + let token = fetchFakeGotchiNFTToken(event.address, event.params._tokenId); token.owner = to.id; token.save(); @@ -137,67 +129,64 @@ export function handleTransfer(event: TransferEvent): void { } export function handleMetadataActionLog(event: MetadataActionLogEvent): void { - let contract = fetchERC721(event.address); - if (contract != null) { - let ev = MetadataActionLog.load(event.params.id.toString()); - if (!ev) { - ev = new MetadataActionLog(event.params.id.toString()); - ev.flagCount = 0; - ev.likeCount = 0; - } - let artist = getOrCreateUser(event.params.metaData.artist.toHexString()); - let publisher = getOrCreateUser(event.params.metaData.publisher.toHexString()); - - ev.emitter = contract.id.toHexString(); - ev.timestamp = event.block.timestamp; - ev.minted = event.params.metaData.minted; - ev.artist = artist.id; - ev.artistName = event.params.metaData.artistName; - ev.createdAt = event.params.metaData.createdAt; - ev.description = event.params.metaData.description; - ev.externalLink = event.params.metaData.externalLink; - ev.fileHash = event.params.metaData.fileHash; - ev.name = event.params.metaData.name; - ev.publisher = publisher.id; - ev.publisherName = event.params.metaData.publisherName; - ev.royalty = event.params.metaData.royalty; - ev.status = event.params.metaData.status; - ev.editions = event.params.metaData.editions; - ev.fileType = event.params.metaData.fileType; - ev.thumbnailHash = event.params.metaData.thumbnailHash; - ev.thumbnailType = event.params.metaData.thumbnailType; - - ev.save(); - - if (ev.status == METADATA_STATUS_APPROVED) { - // Update Global Stats - let stats = getOrCreateStats(); - stats.totalFakeGotchiPieces = stats.totalFakeGotchiPieces + 1; - - // create tokens tokens and attach metadata - let startId = stats.tokenIdCounter; - stats.tokenIdCounter = stats.tokenIdCounter + ev.editions; - for (let i = 0; i < ev.editions; i++) { - let id = startId + i; - let token = fetchFakeGotchiNFTToken(contract, BigInt.fromI32(id)); - token.metadata = ev.id; - token.owner = ev.publisher!; - token.contract = event.address; - token.artist = event.params.metaData.artist.toHexString(); - token.artistName = event.params.metaData.artistName; - token.description = event.params.metaData.description; - token.externalLink = event.params.metaData.externalLink; - token.fileHash = event.params.metaData.fileHash; - token.name = event.params.metaData.name; - token.publisher = event.params.metaData.publisher.toHexString(); - token.publisherName = event.params.metaData.publisherName; - token.editions = event.params.metaData.editions; - token.thumbnailHash = event.params.metaData.thumbnailHash; - token.thumbnailType = event.params.metaData.thumbnailType; - token.save(); - } - stats.save(); + let ev = MetadataActionLog.load(event.params.id.toString()); + if (!ev) { + ev = new MetadataActionLog(event.params.id.toString()); + ev.flagCount = 0; + ev.likeCount = 0; + } + let artist = getOrCreateUser(event.params.metaData.artist.toHexString()); + let publisher = getOrCreateUser(event.params.metaData.publisher.toHexString()); + + ev.emitter = event.address.toHexString(); + ev.timestamp = event.block.timestamp; + ev.minted = event.params.metaData.minted; + ev.artist = artist.id; + ev.artistName = event.params.metaData.artistName; + ev.createdAt = event.params.metaData.createdAt; + ev.description = event.params.metaData.description; + ev.externalLink = event.params.metaData.externalLink; + ev.fileHash = event.params.metaData.fileHash; + ev.name = event.params.metaData.name; + ev.publisher = publisher.id; + ev.publisherName = event.params.metaData.publisherName; + ev.royalty = event.params.metaData.royalty; + ev.status = event.params.metaData.status; + ev.editions = event.params.metaData.editions; + ev.fileType = event.params.metaData.fileType; + ev.thumbnailHash = event.params.metaData.thumbnailHash; + ev.thumbnailType = event.params.metaData.thumbnailType; + + ev.save(); + + if (ev.status == METADATA_STATUS_APPROVED) { + // Update Global Stats + let stats = getOrCreateStats(); + stats.totalFakeGotchiPieces = stats.totalFakeGotchiPieces + 1; + + // create tokens tokens and attach metadata + let startId = stats.tokenIdCounter; + stats.tokenIdCounter = stats.tokenIdCounter + ev.editions; + for (let i = 0; i < ev.editions; i++) { + let id = startId + i; + let token = fetchFakeGotchiNFTToken(event.address, BigInt.fromI32(id)); + token.metadata = ev.id; + token.owner = ev.publisher!; + token.contract = event.address; + token.artist = event.params.metaData.artist.toHexString(); + token.artistName = event.params.metaData.artistName; + token.description = event.params.metaData.description; + token.externalLink = event.params.metaData.externalLink; + token.fileHash = event.params.metaData.fileHash; + token.name = event.params.metaData.name; + token.publisher = event.params.metaData.publisher.toHexString(); + token.publisherName = event.params.metaData.publisherName; + token.editions = event.params.metaData.editions; + token.thumbnailHash = event.params.metaData.thumbnailHash; + token.thumbnailType = event.params.metaData.thumbnailType; + token.save(); } + stats.save(); } } diff --git a/src/utils/helpers/diamond.ts b/src/utils/helpers/diamond.ts index 20fe402..58b573d 100644 --- a/src/utils/helpers/diamond.ts +++ b/src/utils/helpers/diamond.ts @@ -21,9 +21,8 @@ import { Whitelist, ClaimedToken, ERC721BuyOrder, - FakeGotchiNFTContract, } from "../../../generated/schema"; -import { fetchERC721, fetchFakeGotchiNFTToken } from "../../fetch/erc721"; +import { fetchFakeGotchiNFTToken, getFakeGotchiNFTToken } from "../../fetch/erc721"; import { BIGINT_ZERO, STATUS_AAVEGOTCHI, ZERO_ADDRESS } from "../constants"; import { Address, @@ -218,14 +217,12 @@ export function updateERC721ListingInfo( listing.blockCreated = event.block.number; } - let FakeGotchiNFTContract = fetchERC721(listingInfo.erc721TokenAddress); - - if (FakeGotchiNFTContract != null) { - let erc721Token = fetchFakeGotchiNFTToken( - FakeGotchiNFTContract, - listingInfo.erc721TokenId - ); - + let erc721Token = getFakeGotchiNFTToken( + listingInfo.erc721TokenAddress, + listingInfo.erc721TokenId + ); + + if (erc721Token != null) { listing.name = erc721Token.name; listing.publisher = erc721Token.publisher; listing.description = erc721Token.description; diff --git a/tests/handleERC721ExecutedListing.test.ts b/tests/handleERC721ExecutedListing.test.ts index bc38989..fd89735 100644 --- a/tests/handleERC721ExecutedListing.test.ts +++ b/tests/handleERC721ExecutedListing.test.ts @@ -18,7 +18,7 @@ import { getERC721ListingMock, } from "./mocks"; import { getOrCreatePortal } from "../src/utils/helpers/diamond"; -import { Aavegotchi, FakeGotchiNFTContract, ERC721Listing, ItemType } from "../generated/schema"; +import { Aavegotchi, ERC721Listing, ItemType } from "../generated/schema"; test("handleERC721Listing - should add price to historicalPrices of aavegotchi if listing is aavegotchi", () => { // prepare event @@ -73,7 +73,7 @@ test("handleERC721Listing - should add price to historicalPrices of aavegotchi i listing.cancelled = false; listing.nameLowerCase = "TEST123"; listing.category = BIGINT_ZERO; - listing.erc721TokenAddress = Address.fromString(ZERO_ADDRESS); + listing.erc721TokenAddress = event.params.erc721TokenAddress listing.tokenId = BIGINT_ZERO; listing.seller = Address.fromString(ZERO_ADDRESS); listing.timeCreated = BIGINT_ZERO; @@ -83,10 +83,6 @@ test("handleERC721Listing - should add price to historicalPrices of aavegotchi i listing.blockCreated = BIGINT_ZERO; listing.save(); - let FakeGotchiNFTContract = new FakeGotchiNFTContract(event.params.erc721TokenAddress); - FakeGotchiNFTContract.asAccount = ZERO_ADDRESS; - FakeGotchiNFTContract.save(); - //try_getERC721Listing createMockedFunction( event.address, @@ -118,10 +114,6 @@ test("handleERC721Listing - should add price to historicalPrices of portal if li portal.save(); - let FakeGotchiNFTContract = new FakeGotchiNFTContract(event.params.erc721TokenAddress); - FakeGotchiNFTContract.asAccount = ZERO_ADDRESS; - FakeGotchiNFTContract.save(); - createMockedFunction( event.address, "getERC721Listing", @@ -177,7 +169,7 @@ test("handleERC721Listing - should set blockCreated to block number when listing listing.cancelled = false; listing.nameLowerCase = "TEST123"; listing.category = BIGINT_ZERO; - listing.erc721TokenAddress = Address.fromString(ZERO_ADDRESS); + listing.erc721TokenAddress = event.params.erc721TokenAddress listing.tokenId = BIGINT_ZERO; listing.seller = Address.fromString(ZERO_ADDRESS); listing.timeCreated = BIGINT_ZERO; @@ -187,10 +179,6 @@ test("handleERC721Listing - should set blockCreated to block number when listing listing.blockCreated = BIGINT_ZERO; listing.save(); - let FakeGotchiNFTContract = new FakeGotchiNFTContract(event.params.erc721TokenAddress); - FakeGotchiNFTContract.asAccount = ZERO_ADDRESS; - FakeGotchiNFTContract.save(); - //try_getERC721Listing createMockedFunction( event.address, @@ -243,7 +231,7 @@ test("handleERC721Listing - reorg: should set block created if cancel events hap listing.cancelled = false; listing.nameLowerCase = "TEST123"; listing.category = BIGINT_ZERO; - listing.erc721TokenAddress = Address.fromString(ZERO_ADDRESS); + listing.erc721TokenAddress = Address.fromString("0x86935F11C86623deC8a25696E1C19a8659CbF95d"); listing.tokenId = BIGINT_ZERO; listing.seller = Address.fromString(ZERO_ADDRESS); listing.timeCreated = BIGINT_ZERO; @@ -253,10 +241,6 @@ test("handleERC721Listing - reorg: should set block created if cancel events hap listing.blockCreated = BIGINT_ZERO; listing.save(); - let FakeGotchiNFTContract = new FakeGotchiNFTContract(Address.fromString("0x86935F11C86623deC8a25696E1C19a8659CbF95d")); - FakeGotchiNFTContract.asAccount = ZERO_ADDRESS; - FakeGotchiNFTContract.save(); - //try_getERC721Listing createMockedFunction( event.address, diff --git a/tests/handleERC721ListingAdded.test.ts b/tests/handleERC721ListingAdded.test.ts index a8c2e9b..df225ca 100644 --- a/tests/handleERC721ListingAdded.test.ts +++ b/tests/handleERC721ListingAdded.test.ts @@ -18,7 +18,7 @@ import { getERC721ListingMock, } from "./mocks"; import { getOrCreatePortal } from "../src/utils/helpers/diamond"; -import { Aavegotchi, FakeGotchiNFTContract } from "../generated/schema"; +import { Aavegotchi } from "../generated/schema"; test("should add gotchi name lower case if token is an aavegtochi", () => { // prepare event @@ -54,10 +54,6 @@ test("should add gotchi name lower case if token is an aavegtochi", () => { gotchi.timesTraded = BIGINT_ONE; gotchi.save(); - let FakeGotchiNFTContract = new FakeGotchiNFTContract(event.params.erc721TokenAddress); - FakeGotchiNFTContract.asAccount = ZERO_ADDRESS; - FakeGotchiNFTContract.save(); - //try_getERC721Listing createMockedFunction( event.address, From fdf2b8d4ec74d99b9b7da27788a857781ec2605f Mon Sep 17 00:00:00 2001 From: narayanprusty Date: Thu, 9 Nov 2023 23:01:34 +0000 Subject: [PATCH 26/42] renamed totalOwners --- schema.graphql | 4 ++-- src/fetch/account.ts | 12 ++++++------ src/helper/entities.ts | 4 ++-- src/utils/helpers/diamond.ts | 4 ++-- tests/handleTransfer.test.ts | 6 +++--- 5 files changed, 15 insertions(+), 15 deletions(-) diff --git a/schema.graphql b/schema.graphql index 8e75358..09b8e3a 100644 --- a/schema.graphql +++ b/schema.graphql @@ -296,8 +296,8 @@ type Statistic @entity { totalConsumablesVolume: BigInt! totalTicketsVolume: BigInt! - totalOwners: Int - totalOwnersArray: [Bytes!]! + totalFakeGotchiOwners: Int + totalFakeGotchiOwnersArray: [Bytes!]! totalFakeGotchiPieces: Int totalNFTs: Int diff --git a/src/fetch/account.ts b/src/fetch/account.ts index 0031533..ff2c87e 100644 --- a/src/fetch/account.ts +++ b/src/fetch/account.ts @@ -152,11 +152,11 @@ export function addToOwnersIfNotExists( totalStats: Statistic, owner: Bytes ): Statistic { - let ownersArray = totalStats.totalOwnersArray; + let ownersArray = totalStats.totalFakeGotchiOwnersArray; if (ownersArray.indexOf(owner) == -1) { ownersArray.push(owner); - totalStats.totalOwnersArray = ownersArray; - totalStats.totalOwners = ownersArray.length; + totalStats.totalFakeGotchiOwnersArray = ownersArray; + totalStats.totalFakeGotchiOwners = ownersArray.length; } return totalStats; @@ -171,12 +171,12 @@ export function removeFromOwnersIfExistsAndBalanceNotZero( return totalStats; } - let ownersArray = totalStats.totalOwnersArray; + let ownersArray = totalStats.totalFakeGotchiOwnersArray; let index = ownersArray.indexOf(owner); if (index != -1) { ownersArray.splice(index, 1); - totalStats.totalOwnersArray = ownersArray; - totalStats.totalOwners = ownersArray.length; + totalStats.totalFakeGotchiOwnersArray = ownersArray; + totalStats.totalFakeGotchiOwners = ownersArray.length; } return totalStats; diff --git a/src/helper/entities.ts b/src/helper/entities.ts index fd1513a..df10b5c 100644 --- a/src/helper/entities.ts +++ b/src/helper/entities.ts @@ -16,10 +16,10 @@ export function getOrCreateStats(): Statistic { stat.burnedCards = 0; stat.burnedNFTs = 0; stat.totalNFTs = 0; - stat.totalOwners = 0; + stat.totalFakeGotchiOwners = 0; stat.totalFakeGotchiPieces = 0; stat.totalNFTsArray = "{}"; - stat.totalOwnersArray = new Array(); + stat.totalFakeGotchiOwnersArray = new Array(); stat.tokenIdCounter = 0; stat.totalEditionsCirculating = 0; stat.totalEditionsMinted = 0; diff --git a/src/utils/helpers/diamond.ts b/src/utils/helpers/diamond.ts index 58b573d..0096554 100644 --- a/src/utils/helpers/diamond.ts +++ b/src/utils/helpers/diamond.ts @@ -576,10 +576,10 @@ export function getStatisticEntity(): Statistic { stats.burnedCards = 0; stats.burnedNFTs = 0; stats.totalNFTs = 0; - stats.totalOwners = 0; + stats.totalFakeGotchiOwners = 0; stats.totalFakeGotchiPieces = 0; stats.totalNFTsArray = "{}"; - stats.totalOwnersArray = new Array(); + stats.totalFakeGotchiOwnersArray = new Array(); stats.tokenIdCounter = 0; stats.totalEditionsCirculating = 0; stats.totalEditionsMinted = 0; diff --git a/tests/handleTransfer.test.ts b/tests/handleTransfer.test.ts index 2663368..033ab7c 100644 --- a/tests/handleTransfer.test.ts +++ b/tests/handleTransfer.test.ts @@ -165,7 +165,7 @@ describe("handleTransfer", () => { assert.fieldEquals("Statistic", "0", "totalEditionsMinted", "1"); assert.fieldEquals("Statistic", "0", "totalNFTs", "1"); assert.fieldEquals("Statistic", "0", "burnedNFTs", "0"); - assert.fieldEquals("Statistic", "0", "totalOwners", "1"); + assert.fieldEquals("Statistic", "0", "totalFakeGotchiOwners", "1"); // nft stats assert.fieldEquals("FakeGotchiStatistic", "1", "burned", "0"); @@ -204,7 +204,7 @@ describe("handleTransfer", () => { assert.fieldEquals("Statistic", "0", "totalEditionsMinted", "1"); assert.fieldEquals("Statistic", "0", "totalNFTs", "1"); assert.fieldEquals("Statistic", "0", "burnedNFTs", "0"); - assert.fieldEquals("Statistic", "0", "totalOwners", "1"); + assert.fieldEquals("Statistic", "0", "totalFakeGotchiOwners", "1"); // NFT Stats assert.fieldEquals("FakeGotchiStatistic", "1", "burned", "0"); @@ -255,7 +255,7 @@ describe("handleTransfer", () => { assert.fieldEquals("Statistic", "0", "totalEditionsMinted", "1"); assert.fieldEquals("Statistic", "0", "totalNFTs", "0"); assert.fieldEquals("Statistic", "0", "burnedNFTs", "1"); - assert.fieldEquals("Statistic", "0", "totalOwners", "0"); + assert.fieldEquals("Statistic", "0", "totalFakeGotchiOwners", "0"); // NFT Stats assert.fieldEquals("FakeGotchiStatistic", "1", "burned", "1"); From 461f087fe6b545688cb72d5b2313863b0ea968f2 Mon Sep 17 00:00:00 2001 From: narayanprusty Date: Thu, 9 Nov 2023 23:14:26 +0000 Subject: [PATCH 27/42] removed FakeGotchiCardToken --- schema.graphql | 11 +-------- src/fetch/erc1155.ts | 41 +++++---------------------------- src/mappings/fakeGotchisCard.ts | 19 ++++----------- subgraph.mumbai.yaml | 2 -- subgraph.yaml | 2 -- 5 files changed, 11 insertions(+), 64 deletions(-) diff --git a/schema.graphql b/schema.graphql index 09b8e3a..ee892cb 100644 --- a/schema.graphql +++ b/schema.graphql @@ -450,19 +450,10 @@ type ERC721BuyOrder @entity { } # Cards -type FakeGotchiCardToken @entity { - id: ID! - contract: Bytes! - identifier: BigInt! - uri: String - totalSupply: FakeGotchiCardBalance! - balances: [FakeGotchiCardBalance!]! @derivedFrom(field: "token") - metadata: MetadataActionLog -} type FakeGotchiCardBalance @entity { id: ID! contract: Bytes! - token: FakeGotchiCardToken! + token: BigInt! account: User value: BigDecimal! valueExact: BigInt! diff --git a/src/fetch/erc1155.ts b/src/fetch/erc1155.ts index 87a275c..bcbe730 100644 --- a/src/fetch/erc1155.ts +++ b/src/fetch/erc1155.ts @@ -2,14 +2,10 @@ import { Address, BigInt } from "@graphprotocol/graph-ts"; import { User, - FakeGotchiCardToken, FakeGotchiCardBalance, } from "../../generated/schema"; -import { IERC1155 } from "../../generated/FAKEGotchisCardDiamond/IERC1155"; - import { constants } from "@amxx/graphprotocol-utils"; -import { getOrCreateUser } from "../utils/helpers/diamond"; export function replaceURI(uri: string, identifier: BigInt): string { return uri.replaceAll( @@ -21,45 +17,20 @@ export function replaceURI(uri: string, identifier: BigInt): string { ); } -export function fetchFakeGotchiCardToken( - contract: Address, - identifier: BigInt -): FakeGotchiCardToken { - let id = contract - .toHex() - .concat("/") - .concat(identifier.toHex()); - let token = FakeGotchiCardToken.load(id); - - if (token == null) { - let erc1155 = IERC1155.bind(contract); - let try_uri = erc1155.try_uri(identifier); - token = new FakeGotchiCardToken(id); - token.contract = contract; - token.identifier = identifier; - token.totalSupply = fetchFakeGotchiCardBalance(token as FakeGotchiCardToken, null).id; - token.uri = try_uri.reverted - ? null - : replaceURI(try_uri.value, identifier); - token.save(); - } - - return token as FakeGotchiCardToken; -} - export function fetchFakeGotchiCardBalance( - token: FakeGotchiCardToken, - account: User | null + token: BigInt, + account: User | null, + contract: Address ): FakeGotchiCardBalance { - let id = token.id + let id = token.toString() .concat("/") .concat(account ? account.id.toString() : "totalSupply"); let balance = FakeGotchiCardBalance.load(id); if (balance == null) { balance = new FakeGotchiCardBalance(id); - balance.contract = token.contract; - balance.token = token.id; + balance.contract = contract; + balance.token = token; balance.account = account ? account.id : null; balance.value = constants.BIGDECIMAL_ZERO; balance.valueExact = constants.BIGINT_ZERO; diff --git a/src/mappings/fakeGotchisCard.ts b/src/mappings/fakeGotchisCard.ts index f05bfee..894f0d6 100644 --- a/src/mappings/fakeGotchisCard.ts +++ b/src/mappings/fakeGotchisCard.ts @@ -22,7 +22,6 @@ import { } from "@amxx/graphprotocol-utils"; import { - fetchFakeGotchiCardToken, fetchFakeGotchiCardBalance, replaceURI, } from "../fetch/erc1155"; @@ -37,34 +36,30 @@ function registerTransfer( id: BigInt, value: BigInt ): void { - let token = fetchFakeGotchiCardToken(contract, id); - if (from.id == constants.ADDRESS_ZERO.toHexString()) { - let totalSupply = fetchFakeGotchiCardBalance(token, null); + let totalSupply = fetchFakeGotchiCardBalance(id, null, contract); totalSupply.valueExact = totalSupply.valueExact.plus(value); totalSupply.value = decimals.toDecimals(totalSupply.valueExact); totalSupply.save(); } else { - let balance = fetchFakeGotchiCardBalance(token, from); + let balance = fetchFakeGotchiCardBalance(id, from, contract); balance.valueExact = balance.valueExact.minus(value); balance.value = decimals.toDecimals(balance.valueExact); balance.save(); } if (to.id == constants.ADDRESS_ZERO.toHexString()) { - let totalSupply = fetchFakeGotchiCardBalance(token, null); + let totalSupply = fetchFakeGotchiCardBalance(id, null, contract); totalSupply.valueExact = totalSupply.valueExact.minus(value); totalSupply.value = decimals.toDecimals(totalSupply.valueExact); totalSupply.save(); } else { - let balance = fetchFakeGotchiCardBalance(token, to); + let balance = fetchFakeGotchiCardBalance(id, to, contract); balance.valueExact = balance.valueExact.plus(value); balance.value = decimals.toDecimals(balance.valueExact); balance.save(); } - - token.save(); } export function handleTransferSingle(event: TransferSingleEvent): void { @@ -107,12 +102,6 @@ export function handleTransferBatch(event: TransferBatchEvent): void { } } -export function handleURI(event: URIEvent): void { - let token = fetchFakeGotchiCardToken(event.address, event.params._id); - token.uri = replaceURI(event.params._value, event.params._id); - token.save(); -} - export function handleNewSeriesStarted(event: NewSeriesStarted): void { let series = new Generation(event.params.id.toString()); series.amount = event.params.amount.toI32(); diff --git a/subgraph.mumbai.yaml b/subgraph.mumbai.yaml index 2bc7b81..1a40b74 100644 --- a/subgraph.mumbai.yaml +++ b/subgraph.mumbai.yaml @@ -268,8 +268,6 @@ dataSources: handler: handleTransferSingle - event: TransferBatch(indexed address,indexed address,indexed address,uint256[],uint256[]) handler: handleTransferBatch - - event: URI(string,indexed uint256) - handler: handleURI file: ./src/mappings/fakeGotchisCard.ts - kind: ethereum/contract name: FAKEGotchisNFTDiamond diff --git a/subgraph.yaml b/subgraph.yaml index 8693fea..1f7bb4b 100644 --- a/subgraph.yaml +++ b/subgraph.yaml @@ -268,8 +268,6 @@ dataSources: handler: handleTransferSingle - event: TransferBatch(indexed address,indexed address,indexed address,uint256[],uint256[]) handler: handleTransferBatch - - event: URI(string,indexed uint256) - handler: handleURI file: ./src/mappings/fakeGotchisCard.ts - kind: ethereum/contract name: FAKEGotchisNFTDiamond From f284daab1e2c4833e906cab3f81aa410d27d5f23 Mon Sep 17 00:00:00 2001 From: narayanprusty Date: Tue, 14 Nov 2023 22:15:35 +0000 Subject: [PATCH 28/42] updated readme --- README.md | 47 ----------------------------------------------- 1 file changed, 47 deletions(-) diff --git a/README.md b/README.md index 9e24bcd..911069e 100644 --- a/README.md +++ b/README.md @@ -70,41 +70,6 @@ test("handleMintPortals - should update portal status and stats entity", () => { In this section we provide some example queries which should help you to get first ideas of what to fetch from the graph and how to do it. You can insert all events on the Playground and get the results. If you need help on how to integrate those queries in your app please take a look into the [General Section](https://docs.aavegotchi.com/subgraphs/general). Events -## Events on chain - -You can query the subgraph for almost every event happened on chain. -``` -{ - erc1155Transfers { - from { - id - } - to { - id - } - valueExact - } - - metadataFlags { - flaggedBy { - id - } - metadata { - id - } - } - - metadataLikes { - likedBy { - id - } - metadata { - id - } - } -} -``` - ## Account owned NFTs You can fetch the NFTs of one Account with the following query: @@ -126,18 +91,6 @@ account(id:"0x01c28a969a7d0ba03419c8c80be59928c4732cd9") { ``` -## Account balances of Cards -Its also possible to fetch the Accounts with Cards. -``` -{ - erc1155Balances(orderBy: valueExact orderDirection: desc where: {account_not:null valueExact_gt: 0}) { - account { - id - } - valueExact - } -} -``` ## New NFT proposals Further its also possible to fetch upcoming NFTs. ``` From cd892f831a3213e6990d5a7f7a0f157925ea0a22 Mon Sep 17 00:00:00 2001 From: narayanprusty Date: Tue, 14 Nov 2023 22:22:10 +0000 Subject: [PATCH 29/42] remove ownership transfer event --- src/mappings/ownable.ts | 27 --------------------------- tests/.latest.json | 2 +- 2 files changed, 1 insertion(+), 28 deletions(-) delete mode 100644 src/mappings/ownable.ts diff --git a/src/mappings/ownable.ts b/src/mappings/ownable.ts deleted file mode 100644 index a5f3814..0000000 --- a/src/mappings/ownable.ts +++ /dev/null @@ -1,27 +0,0 @@ -import { OwnershipTransferred } from "@openzeppelin/subgraphs/generated/schema"; - -import { OwnershipTransferred as OwnershipTransferredEvent } from "@openzeppelin/subgraphs/generated/ownable/Ownable"; - -import { events, transactions } from "@amxx/graphprotocol-utils"; - -import { fetchOwnable } from "@openzeppelin/subgraphs/src/fetch/ownable"; -import { getOrCreateUser } from "../utils/helpers/diamond"; -import { Bytes } from "@graphprotocol/graph-ts"; - -export function handleOwnershipTransferred( - event: OwnershipTransferredEvent -): void { - let contract = fetchOwnable(event.address); - let owner = getOrCreateUser(event.params.newOwner.toHex()); - - contract.owner = Bytes.fromHexString(owner.id); - contract.save(); - - let ev = new OwnershipTransferred(events.id(event)); - ev.emitter = contract.id; - ev.transaction = transactions.log(event).id; - ev.timestamp = event.block.timestamp; - ev.contract = contract.id; - ev.owner = Bytes.fromHexString(owner.id); - ev.save(); -} diff --git a/tests/.latest.json b/tests/.latest.json index 7e8b20f..70fd8d5 100644 --- a/tests/.latest.json +++ b/tests/.latest.json @@ -1,4 +1,4 @@ { "version": "0.6.0", - "timestamp": 1699487185248 + "timestamp": 1700000201311 } \ No newline at end of file From 924a8239b995a6706e21f88fa2b317f7a7a44405 Mon Sep 17 00:00:00 2001 From: narayanprusty Date: Wed, 15 Nov 2023 12:00:16 +0000 Subject: [PATCH 30/42] enable grafting --- subgraph.mumbai.yaml | 10 +++++----- subgraph.yaml | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/subgraph.mumbai.yaml b/subgraph.mumbai.yaml index 1a40b74..149ed4e 100644 --- a/subgraph.mumbai.yaml +++ b/subgraph.mumbai.yaml @@ -1,9 +1,9 @@ specVersion: 0.0.4 -# features: -# - grafting -# graft: -# base: QmV3LtUtUCiD774HXR3D9SJBNgw2VNcXZM9McyMGTfotBQ # Subgraph ID of base subgraph -# block: 39550000 # Block number +features: + - grafting +graft: + base: QmV3LtUtUCiD774HXR3D9SJBNgw2VNcXZM9McyMGTfotBQ # Subgraph ID of base subgraph + block: 28127642 # Block number description: Aavegotchi Core Mumbai repository: schema: diff --git a/subgraph.yaml b/subgraph.yaml index 1f7bb4b..6fa67d1 100644 --- a/subgraph.yaml +++ b/subgraph.yaml @@ -1,9 +1,9 @@ specVersion: 0.0.4 -# features: -# - grafting -# graft: -# base: QmY6zf3YHfzuYTHFtLkDDMLimkK1fr9pCQbtCppkg24ZW9 # Subgraph ID of base subgraph -# block: 48000000 # Block number +features: + - grafting +graft: + base: QmY6zf3YHfzuYTHFtLkDDMLimkK1fr9pCQbtCppkg24ZW9 # Subgraph ID of base subgraph + block: 34520145 # Block number description: Aavegotchi Core Matic repository: schema: From c1a57590774d0160c408f4439b401a851f0250db Mon Sep 17 00:00:00 2001 From: narayanprusty Date: Wed, 15 Nov 2023 12:19:39 +0000 Subject: [PATCH 31/42] updated node version --- .github/workflows/deploy-satsuma.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/deploy-satsuma.yml b/.github/workflows/deploy-satsuma.yml index 746f960..896c3b4 100644 --- a/.github/workflows/deploy-satsuma.yml +++ b/.github/workflows/deploy-satsuma.yml @@ -13,7 +13,7 @@ jobs: - name: Install node uses: actions/setup-node@v1 with: - node-version: 14 + node-version: 16 - name: Install Yarn run: npm i -g yarn - name: Install Libs From b5b9c1b9b9be80aa9d0017e1ad779c8826b8ce13 Mon Sep 17 00:00:00 2001 From: narayanprusty Date: Wed, 15 Nov 2023 12:22:46 +0000 Subject: [PATCH 32/42] updated node version --- .github/workflows/graph.yml | 2 +- .github/workflows/run-e2e.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/graph.yml b/.github/workflows/graph.yml index 4e2559c..54cc3f4 100644 --- a/.github/workflows/graph.yml +++ b/.github/workflows/graph.yml @@ -13,7 +13,7 @@ jobs: - name: Install node uses: actions/setup-node@v1 with: - node-version: 14 + node-version: 16 - name: Install Yarn run: npm i -g yarn - name: Install Libs diff --git a/.github/workflows/run-e2e.yml b/.github/workflows/run-e2e.yml index ec86840..9d0328a 100644 --- a/.github/workflows/run-e2e.yml +++ b/.github/workflows/run-e2e.yml @@ -13,7 +13,7 @@ jobs: - name: Install node uses: actions/setup-node@v1 with: - node-version: 14 + node-version: 16 - name: Install Yarn run: npm i -g yarn - name: Install Libs From bbe124b762b9019ae1e9ca7ccfaec1c4274e06bf Mon Sep 17 00:00:00 2001 From: narayanprusty Date: Fri, 17 Nov 2023 22:30:42 +0000 Subject: [PATCH 33/42] remove event --- schema.graphql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/schema.graphql b/schema.graphql index ee892cb..90f4a94 100644 --- a/schema.graphql +++ b/schema.graphql @@ -482,7 +482,7 @@ type FakeGotchiNFTToken @entity { thumbnailType: String } -type MetadataActionLog implements Event @entity { +type MetadataActionLog @entity { id: ID! emitter: User! timestamp: BigInt! From ea2f79d22b59bb6af46a13aee9024d0cf3dae0c5 Mon Sep 17 00:00:00 2001 From: narayanprusty Date: Fri, 17 Nov 2023 22:33:28 +0000 Subject: [PATCH 34/42] updated ipfs hash --- subgraph.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/subgraph.yaml b/subgraph.yaml index 6fa67d1..6078356 100644 --- a/subgraph.yaml +++ b/subgraph.yaml @@ -2,7 +2,7 @@ specVersion: 0.0.4 features: - grafting graft: - base: QmY6zf3YHfzuYTHFtLkDDMLimkK1fr9pCQbtCppkg24ZW9 # Subgraph ID of base subgraph + base: QmP2tR7PzfqCmxK9GmPvmAJnpTaATn6YFbRX77UGw68yHe # Subgraph ID of base subgraph block: 34520145 # Block number description: Aavegotchi Core Matic repository: From 4d46c05efa4a20887d608929d7d127e11227eb54 Mon Sep 17 00:00:00 2001 From: Narayan Prusty Date: Sat, 18 Nov 2023 19:35:06 +0000 Subject: [PATCH 35/42] disable grafting --- subgraph.mumbai.yaml | 10 +++++----- subgraph.yaml | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/subgraph.mumbai.yaml b/subgraph.mumbai.yaml index 149ed4e..6ac7a48 100644 --- a/subgraph.mumbai.yaml +++ b/subgraph.mumbai.yaml @@ -1,9 +1,9 @@ specVersion: 0.0.4 -features: - - grafting -graft: - base: QmV3LtUtUCiD774HXR3D9SJBNgw2VNcXZM9McyMGTfotBQ # Subgraph ID of base subgraph - block: 28127642 # Block number +# features: +# - grafting +# graft: +# base: QmV3LtUtUCiD774HXR3D9SJBNgw2VNcXZM9McyMGTfotBQ # Subgraph ID of base subgraph +# block: 28127642 # Block number description: Aavegotchi Core Mumbai repository: schema: diff --git a/subgraph.yaml b/subgraph.yaml index 6078356..c3ce391 100644 --- a/subgraph.yaml +++ b/subgraph.yaml @@ -1,9 +1,9 @@ specVersion: 0.0.4 -features: - - grafting -graft: - base: QmP2tR7PzfqCmxK9GmPvmAJnpTaATn6YFbRX77UGw68yHe # Subgraph ID of base subgraph - block: 34520145 # Block number +# features: +# - grafting +# graft: +# base: QmP2tR7PzfqCmxK9GmPvmAJnpTaATn6YFbRX77UGw68yHe # Subgraph ID of base subgraph +# block: 34520145 # Block number description: Aavegotchi Core Matic repository: schema: From 171b8bcb030cdf2fecd13dbfed0f31db93856c4e Mon Sep 17 00:00:00 2001 From: Narayan Prusty Date: Wed, 22 Nov 2023 18:57:34 +0000 Subject: [PATCH 36/42] save FakeGotchi NFT transfers --- schema.graphql | 15 +++++++++++++++ src/mappings/fakeGotchisNFT.ts | 10 ++++++++++ 2 files changed, 25 insertions(+) diff --git a/schema.graphql b/schema.graphql index 90f4a94..de218f6 100644 --- a/schema.graphql +++ b/schema.graphql @@ -529,3 +529,18 @@ type FakeGotchiHolder @entity { holder: User amount: Int } + +type Transaction @entity(immutable: true) { + id: ID! + timestamp: BigInt! + blockNumber: BigInt! +} + +type FakeGotchiNFTTransfer @entity { + id: ID! + transaction: Transaction! + timestamp: BigInt! + token: FakeGotchiNFTToken! + from: User! + to: User! +} \ No newline at end of file diff --git a/src/mappings/fakeGotchisNFT.ts b/src/mappings/fakeGotchisNFT.ts index 5bdc1e8..d2072b4 100644 --- a/src/mappings/fakeGotchisNFT.ts +++ b/src/mappings/fakeGotchisNFT.ts @@ -1,4 +1,5 @@ import { + FakeGotchiNFTTransfer, MetadataActionLog, } from "../../generated/schema"; @@ -55,6 +56,15 @@ export function handleTransfer(event: TransferEvent): void { token.owner = to.id; token.save(); + // create event entity + let ev = new FakeGotchiNFTTransfer(events.id(event)); + ev.transaction = transactions.log(event).id; + ev.timestamp = event.block.timestamp; + ev.token = token.id; + ev.from = from.id; + ev.to = to.id; + ev.save(); + // fetch metadata let metadata = MetadataActionLog.load(token.metadata!)!; let nftStats = getOrCreateFakeGotchiStatistic(metadata.id); From 7b3e702b81bea0f6b7e9f30e4a00bb60a8b535b7 Mon Sep 17 00:00:00 2001 From: Narayan Prusty Date: Wed, 22 Nov 2023 19:18:01 +0000 Subject: [PATCH 37/42] make transaction as bytes --- schema.graphql | 8 +------- src/mappings/fakeGotchisNFT.ts | 2 +- tests/.latest.json | 2 +- 3 files changed, 3 insertions(+), 9 deletions(-) diff --git a/schema.graphql b/schema.graphql index de218f6..0e5b6c9 100644 --- a/schema.graphql +++ b/schema.graphql @@ -530,15 +530,9 @@ type FakeGotchiHolder @entity { amount: Int } -type Transaction @entity(immutable: true) { - id: ID! - timestamp: BigInt! - blockNumber: BigInt! -} - type FakeGotchiNFTTransfer @entity { id: ID! - transaction: Transaction! + transaction: Bytes! timestamp: BigInt! token: FakeGotchiNFTToken! from: User! diff --git a/src/mappings/fakeGotchisNFT.ts b/src/mappings/fakeGotchisNFT.ts index d2072b4..0ac53f0 100644 --- a/src/mappings/fakeGotchisNFT.ts +++ b/src/mappings/fakeGotchisNFT.ts @@ -58,7 +58,7 @@ export function handleTransfer(event: TransferEvent): void { // create event entity let ev = new FakeGotchiNFTTransfer(events.id(event)); - ev.transaction = transactions.log(event).id; + ev.transaction = event.transaction.hash; ev.timestamp = event.block.timestamp; ev.token = token.id; ev.from = from.id; diff --git a/tests/.latest.json b/tests/.latest.json index 70fd8d5..af3688e 100644 --- a/tests/.latest.json +++ b/tests/.latest.json @@ -1,4 +1,4 @@ { "version": "0.6.0", - "timestamp": 1700000201311 + "timestamp": 1700679567767 } \ No newline at end of file From dd708db85f5ab12b38de069f69b10bc449259944 Mon Sep 17 00:00:00 2001 From: narayanprusty Date: Sun, 26 Nov 2023 14:15:20 +0000 Subject: [PATCH 38/42] added fg prefix --- schema.graphql | 14 +++++++------- src/utils/helpers/diamond.ts | 12 ++++++------ tests/.latest.json | 2 +- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/schema.graphql b/schema.graphql index 90f4a94..7d28538 100644 --- a/schema.graphql +++ b/schema.graphql @@ -215,13 +215,13 @@ type ERC721Listing @entity { whitelist: Whitelist priceUpdatedAt: BigInt - name: String - publisher: User - publisherName: String - description: String - artist: User - artistName: String - editions: Int + fg_name: String + fg_publisher: User + fg_publisherName: String + fg_description: String + fg_artist: User + fg_artistName: String + fg_editions: Int } type ERC1155Listing @entity { diff --git a/src/utils/helpers/diamond.ts b/src/utils/helpers/diamond.ts index 0096554..e104fd9 100644 --- a/src/utils/helpers/diamond.ts +++ b/src/utils/helpers/diamond.ts @@ -223,12 +223,12 @@ export function updateERC721ListingInfo( ); if (erc721Token != null) { - listing.name = erc721Token.name; - listing.publisher = erc721Token.publisher; - listing.description = erc721Token.description; - listing.artist = erc721Token.artist; - listing.artistName = erc721Token.artistName; - listing.editions = erc721Token.editions; + listing.fg_name = erc721Token.name; + listing.fg_publisher = erc721Token.publisher; + listing.fg_description = erc721Token.description; + listing.fg_artist = erc721Token.artist; + listing.fg_artistName = erc721Token.artistName; + listing.fg_editions = erc721Token.editions; } if (listing.category.toI32() <= 2) { diff --git a/tests/.latest.json b/tests/.latest.json index 70fd8d5..46879d3 100644 --- a/tests/.latest.json +++ b/tests/.latest.json @@ -1,4 +1,4 @@ { "version": "0.6.0", - "timestamp": 1700000201311 + "timestamp": 1701008037781 } \ No newline at end of file From 3fddde1bf5f3870f436876c56bb60098ca00521a Mon Sep 17 00:00:00 2001 From: narayanprusty Date: Sun, 26 Nov 2023 14:45:24 +0000 Subject: [PATCH 39/42] changed prefix --- schema.graphql | 14 +++++++------- src/utils/helpers/diamond.ts | 12 ++++++------ 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/schema.graphql b/schema.graphql index 5a9308f..eabfcdf 100644 --- a/schema.graphql +++ b/schema.graphql @@ -215,13 +215,13 @@ type ERC721Listing @entity { whitelist: Whitelist priceUpdatedAt: BigInt - fg_name: String - fg_publisher: User - fg_publisherName: String - fg_description: String - fg_artist: User - fg_artistName: String - fg_editions: Int + fakeGotchi_name: String + fakeGotchi_publisher: User + fakeGotchi_publisherName: String + fakeGotchi_description: String + fakeGotchi_artist: User + fakeGotchi_artistName: String + fakeGotchi_editions: Int } type ERC1155Listing @entity { diff --git a/src/utils/helpers/diamond.ts b/src/utils/helpers/diamond.ts index e104fd9..3c2a2ee 100644 --- a/src/utils/helpers/diamond.ts +++ b/src/utils/helpers/diamond.ts @@ -223,12 +223,12 @@ export function updateERC721ListingInfo( ); if (erc721Token != null) { - listing.fg_name = erc721Token.name; - listing.fg_publisher = erc721Token.publisher; - listing.fg_description = erc721Token.description; - listing.fg_artist = erc721Token.artist; - listing.fg_artistName = erc721Token.artistName; - listing.fg_editions = erc721Token.editions; + listing.fakeGotchi_name = erc721Token.name; + listing.fakeGotchi_publisher = erc721Token.publisher; + listing.fakeGotchi_description = erc721Token.description; + listing.fakeGotchi_artist = erc721Token.artist; + listing.fakeGotchi_artistName = erc721Token.artistName; + listing.fakeGotchi_editions = erc721Token.editions; } if (listing.category.toI32() <= 2) { From ace43ce7fe91d45d870f1b32cf8efe16d3be1708 Mon Sep 17 00:00:00 2001 From: Coderdan Date: Thu, 30 Nov 2023 12:52:32 +0800 Subject: [PATCH 40/42] chore: handle gotchi locking --- src/mappings/diamond.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/mappings/diamond.ts b/src/mappings/diamond.ts index 004a514..d4533fb 100644 --- a/src/mappings/diamond.ts +++ b/src/mappings/diamond.ts @@ -484,6 +484,7 @@ export function handleERC721ListingAdd(event: ERC721ListingAdd): void { event.params.erc721TokenId.toString(), event )!; + gotchi.locked = true; listing.collateral = gotchi.collateral; gotchi.activeListing = event.params.listingId; gotchi.save(); @@ -584,6 +585,7 @@ export function handleERC721ExecutedListing( historicalPrices.push(event.params.priceInWei); gotchi.historicalPrices = historicalPrices; gotchi.activeListing = null; + gotchi.locked = false; gotchi.save(); } else if (event.params.category == BigInt.fromI32(4)) { let listing = getOrCreateERC721Listing( @@ -643,6 +645,7 @@ export function handleERC721ListingCancelled( } else if (listing.category.equals(BigInt.fromI32(3))) { let gotchi = getOrCreateAavegotchi(listing.tokenId.toString(), event)!; gotchi.activeListing = null; + gotchi.locked = false; gotchi.save(); } else if (listing.category.equals(BigInt.fromI32(4))) { let parcel = getOrCreateParcel( @@ -675,6 +678,7 @@ export function handleERC721ListingRemoved(event: ERC721ListingRemoved): void { } else if (listing.category.equals(BigInt.fromI32(3))) { let gotchi = getOrCreateAavegotchi(listing.tokenId.toString(), event)!; gotchi.activeListing = null; + gotchi.locked = false; gotchi.save(); } else if (listing.category.equals(BigInt.fromI32(4))) { let parcel = getOrCreateParcel( From 8554e06a636a7cd901bc9e9ee69a212b482f20f0 Mon Sep 17 00:00:00 2001 From: narayanprusty Date: Mon, 4 Dec 2023 18:07:41 +0530 Subject: [PATCH 41/42] added missing publisherName --- src/utils/helpers/diamond.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/utils/helpers/diamond.ts b/src/utils/helpers/diamond.ts index 3c2a2ee..878fab6 100644 --- a/src/utils/helpers/diamond.ts +++ b/src/utils/helpers/diamond.ts @@ -229,6 +229,7 @@ export function updateERC721ListingInfo( listing.fakeGotchi_artist = erc721Token.artist; listing.fakeGotchi_artistName = erc721Token.artistName; listing.fakeGotchi_editions = erc721Token.editions; + listing.fakeGotchi_publisherName = erc721Token.publisherName; } if (listing.category.toI32() <= 2) { From ebc54c8a0a342aaeff639edf3496de4ac1a6e429 Mon Sep 17 00:00:00 2001 From: narayanprusty Date: Wed, 20 Dec 2023 23:08:44 +0530 Subject: [PATCH 42/42] fixed saving of user --- src/mappings/fakeGotchisNFT.ts | 3 +++ tests/.latest.json | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/mappings/fakeGotchisNFT.ts b/src/mappings/fakeGotchisNFT.ts index 0ac53f0..7680a98 100644 --- a/src/mappings/fakeGotchisNFT.ts +++ b/src/mappings/fakeGotchisNFT.ts @@ -198,6 +198,9 @@ export function handleMetadataActionLog(event: MetadataActionLogEvent): void { } stats.save(); } + + artist.save(); + publisher.save(); } export function handleMetadataFlag(event: MetadataFlagEvent): void { diff --git a/tests/.latest.json b/tests/.latest.json index 46879d3..85c2dc8 100644 --- a/tests/.latest.json +++ b/tests/.latest.json @@ -1,4 +1,4 @@ { "version": "0.6.0", - "timestamp": 1701008037781 + "timestamp": 1702375664971 } \ No newline at end of file