From 64683d676de3256b0019149742a4c465d75be72f Mon Sep 17 00:00:00 2001 From: Melisa Anabella Rossi Date: Mon, 25 Sep 2023 10:45:16 -0300 Subject: [PATCH] feat: add sound and geometry property to emotes (#102) --- README.md | 22 ++++++------ schema.graphql | 4 +++ src/entities/schema.ts | 52 +++++++++++++++++++++++++++++ src/modules/metadata/emote/index.ts | 7 ++-- 4 files changed, 72 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 00350b0..e9d2844 100644 --- a/README.md +++ b/README.md @@ -2,17 +2,17 @@ | Network | Provider | URL | Current | Previous | | ---------- | --------------- | --------------------------------------------------------------------------------------- | ---------------------------------------------- | ---------------------------------------------- | -| Mainnet | Satsuma | https://subgraph.satsuma-prod.com/decentraland/collections-ethereum-mainnet/playground | QmcyYqqmE3egvtZReHk1aVxmZawxRSECuj1PcZLgMVzHSp | QmbzvX1C9aBbb1Z2nJc99JcmgmWmURQ9mPvjZV6Zb4gcx2 | -| Mainnet | Hosted Services | https://thegraph.com/explorer/subgraph/decentraland/collections-ethereum-mainnet | QmP2EQebbD9W8AaphRTzNUL7NLdMH8FdqNNWtqUiNg2VkB | QmPjcwU1HSxWAf9sMyAag6NGSYxP2Y2U2PAx4sPg15mmJZ | -| Sepolia | Satsuma | https://subgraph.satsuma-prod.com/decentraland/collections-ethereum-sepolia/playground | QmWQZiMSV5AnUPN34NFmAYtxGntxewMUUwuS9r5vBpc5Ys | - | -| Sepolia | Graph Studio | https://api.studio.thegraph.com/query/49472/collections-ethereum-sepolia/version/latest | QmWQZiMSV5AnUPN34NFmAYtxGntxewMUUwuS9r5vBpc5Ys | - | -| Goerli | Satsuma | https://subgraph.satsuma-prod.com/decentraland/collections-ethereum-goerli/playground | QmUvtxgRKdFf1zcZZLrJ5nZ6HyoUYKPtByGQigP4rHxwSj | QmSSzDJBxX7Kj4EqszCUw3AHiznkt5W1fJEpLhiTsVdaqN | -| Goerli | Hosted Services | https://thegraph.com/explorer/subgraph/decentraland/collections-ethereum-goerli | QmUvtxgRKdFf1zcZZLrJ5nZ6HyoUYKPtByGQigP4rHxwSj | QmTNQHzovP1WLp1zBmJvU72uRpHhmzeHe1wb1hwysaXx6F | -| Matic | Satsuma | https://subgraph.satsuma-prod.com/decentraland/collections-matic-mainnet/playground | QmdavX3eGWLYCjjzYAZv924hyoLv8f9Rg6FxHD7kAJ4fXn | Qmf1ouGZcxBegEWodVy5fjFYFgQaB7wzw7j5rHwLcKeSXB | -| Matic | Hosted Services | https://thegraph.com/explorer/subgraph/decentraland/collections-matic-mainnet | QmXEwSeNTT5xHRQPcTUDQJayjjfhcbaxYf2o7ycuYf8YF7 | Qmf3igvJs24gozdwCwnDyPNz9DEBQMPQRFmEhUzEvgxZSq | -| Matic Temp | Hosted Services | https://thegraph.com/explorer/subgraph/decentraland/collections-matic-mainnet-temp | Qmf3igvJs24gozdwCwnDyPNz9DEBQMPQRFmEhUzEvgxZSq | QmXyrt3tNkrnDRopnMdY7Na9y8jbKi1645gbR4cJTURbk5 | -| Mumbai | Satsuma | https://subgraph.satsuma-prod.com/decentraland/collections-matic-mumbai/playground | QmRpCReFLwhB4tATJhur1MEjsPY1Rgo2yVrd5oinnjCrAy | QmY4hQRkXCtKRGP3aCYn4ES8kv1MmeHfov5gSK4EvTbzwz | -| Mumbai | Hosted Service | https://thegraph.com/explorer/subgraph/decentraland/collections-matic-mumbai | QmegTREYw1Li3DYMAcCVJDcoBuquoCFKDUCzxrxyGhWwUW | QmdwRWh1FeGi3bJFYkD1Hu8w2uHvAHzJqbdCtszymfoqDS | +| Mainnet | Satsuma | https://subgraph.satsuma-prod.com/decentraland/collections-ethereum-mainnet/playground | Qmf4SMTepdDoFh1ozcaAUMieGF83tnNa2G2Jr4KkH5jPRA |QmcyYqqmE3egvtZReHk1aVxmZawxRSECuj1PcZLgMVzHSp | +| Mainnet | Hosted Services | https://thegraph.com/explorer/subgraph/decentraland/collections-ethereum-mainnet | Qmf4SMTepdDoFh1ozcaAUMieGF83tnNa2G2Jr4KkH5jPRA |QmP2EQebbD9W8AaphRTzNUL7NLdMH8FdqNNWtqUiNg2VkB | +| Sepolia | Satsuma | https://subgraph.satsuma-prod.com/decentraland/collections-ethereum-sepolia/playground | QmSYyRTthY69mSHxkAY6ym3beCWQr97NwecWdpxjiHypKh | QmWQZiMSV5AnUPN34NFmAYtxGntxewMUUwuS9r5vBpc5Ys | +| Sepolia | Graph Studio | https://api.studio.thegraph.com/query/49472/collections-ethereum-sepolia/version/latest | QmSYyRTthY69mSHxkAY6ym3beCWQr97NwecWdpxjiHypKh | QmWQZiMSV5AnUPN34NFmAYtxGntxewMUUwuS9r5vBpc5Ys | +| Goerli | Satsuma | https://subgraph.satsuma-prod.com/decentraland/collections-ethereum-goerli/playground | QmZXxk89ZunJvXNsckSioadZNQW7VBydrGfXTqS2ivzHqU | QmUvtxgRKdFf1zcZZLrJ5nZ6HyoUYKPtByGQigP4rHxwSj | +| Goerli | Hosted Services | https://thegraph.com/explorer/subgraph/decentraland/collections-ethereum-goerli | QmZXxk89ZunJvXNsckSioadZNQW7VBydrGfXTqS2ivzHqU | QmUvtxgRKdFf1zcZZLrJ5nZ6HyoUYKPtByGQigP4rHxwSj | +| Matic | Satsuma | https://subgraph.satsuma-prod.com/decentraland/collections-matic-mainnet/playground | QmPAV5PzFgu7iaiSYYmRTPGFR4ADGfeKSTPqTPt5eKVAVv | QmdavX3eGWLYCjjzYAZv924hyoLv8f9Rg6FxHD7kAJ4fXn | +| Matic | Hosted Services | https://thegraph.com/explorer/subgraph/decentraland/collections-matic-mainnet | QmPAV5PzFgu7iaiSYYmRTPGFR4ADGfeKSTPqTPt5eKVAVv |QmXEwSeNTT5xHRQPcTUDQJayjjfhcbaxYf2o7ycuYf8YF7 | +| Matic Temp | Hosted Services | https://thegraph.com/explorer/subgraph/decentraland/collections-matic-mainnet-temp | QmTKztw187jUHZ33S2pndtyo68K462XwewcvMVAVH7mwZR |Qmf3igvJs24gozdwCwnDyPNz9DEBQMPQRFmEhUzEvgxZSq | +| Mumbai | Satsuma | https://subgraph.satsuma-prod.com/decentraland/collections-matic-mumbai/playground | QmYVGaMGvqkcBMrJ4F5XrkzwCzhB3FfJvHRBERbtgovCai | QmRpCReFLwhB4tATJhur1MEjsPY1Rgo2yVrd5oinnjCrAy | +| Mumbai | Hosted Service | https://thegraph.com/explorer/subgraph/decentraland/collections-matic-mumbai | QmYVGaMGvqkcBMrJ4F5XrkzwCzhB3FfJvHRBERbtgovCai | QmegTREYw1Li3DYMAcCVJDcoBuquoCFKDUCzxrxyGhWwUW | Using [The Graph](https://thegraph.com) and [Satsuma](https://www.satsuma.xyz/) diff --git a/schema.graphql b/schema.graphql index 7b26736..8524e50 100644 --- a/schema.graphql +++ b/schema.graphql @@ -77,6 +77,8 @@ type Item @entity { searchEmoteLoop: Boolean searchEmoteRarity: String # We're using String instead of WearableRarity here so we can later query this field via ()_in searchEmoteBodyShapes: [WearableBodyShape!] + searchEmoteHasSound: Boolean + searchEmoteHasGeometry: Boolean ## Unique collectors uniqueCollectors: [String!]! @@ -171,6 +173,8 @@ type Emote @entity { loop: Boolean! rarity: WearableRarity! bodyShapes: [WearableBodyShape!] + hasSound: Boolean + hasGeometry: Boolean } enum WearableCategory @entity { diff --git a/src/entities/schema.ts b/src/entities/schema.ts index 5119ef2..fa8948a 100644 --- a/src/entities/schema.ts +++ b/src/entities/schema.ts @@ -888,6 +888,32 @@ export class Item extends Entity { } } + get searchEmoteHasSound(): boolean { + let value = this.get("searchEmoteHasSound"); + if (!value || value.kind == ValueKind.NULL) { + return false; + } else { + return value.toBoolean(); + } + } + + set searchEmoteHasSound(value: boolean) { + this.set("searchEmoteHasSound", Value.fromBoolean(value)); + } + + get searchEmoteHasGeometry(): boolean { + let value = this.get("searchEmoteHasGeometry"); + if (!value || value.kind == ValueKind.NULL) { + return false; + } else { + return value.toBoolean(); + } + } + + set searchEmoteHasGeometry(value: boolean) { + this.set("searchEmoteHasGeometry", Value.fromBoolean(value)); + } + get uniqueCollectors(): Array { let value = this.get("uniqueCollectors"); if (!value || value.kind == ValueKind.NULL) { @@ -1846,6 +1872,32 @@ export class Emote extends Entity { this.set("bodyShapes", Value.fromStringArray(>value)); } } + + get hasSound(): boolean { + let value = this.get("hasSound"); + if (!value || value.kind == ValueKind.NULL) { + return false; + } else { + return value.toBoolean(); + } + } + + set hasSound(value: boolean) { + this.set("hasSound", Value.fromBoolean(value)); + } + + get hasGeometry(): boolean { + let value = this.get("hasGeometry"); + if (!value || value.kind == ValueKind.NULL) { + return false; + } else { + return value.toBoolean(); + } + } + + set hasGeometry(value: boolean) { + this.set("hasGeometry", Value.fromBoolean(value)); + } } export class Rarity extends Entity { diff --git a/src/modules/metadata/emote/index.ts b/src/modules/metadata/emote/index.ts index 06b46f3..1fafb25 100644 --- a/src/modules/metadata/emote/index.ts +++ b/src/modules/metadata/emote/index.ts @@ -3,7 +3,6 @@ import { isValidBodyShape } from '..' import { Emote, Item, Metadata, NFT } from '../../../entities/schema' import { toLowerCase } from '../../../utils' import { DANCE, FUN, GREETINGS, HORROR, MISCELLANEOUS, POSES, REACTIONS, STUNT } from './categories' -import { LOOP, SIMPLE } from './playModes' /** * @dev The item's rawMetadata for emotes should follow: version:item_type:name:description:category:bodyshapes:play_mode @@ -26,7 +25,9 @@ export function buildEmoteItem(item: Item): Emote | null { emote.rarity = item.rarity emote.category = isValidEmoteCategory(data[4]) ? data[4] : DANCE // We're using DANCE as fallback to support the emotes that were created with the old categories. emote.bodyShapes = data[5].split(',') // Could be more than one - emote.loop = data.length == 7 && isValidLoopValue(data[6]) && data[6] == '1' ? true : false // Fallback old emotes as not loopable + emote.loop = data.length >= 7 && isValidLoopValue(data[6]) && data[6] == '1' ? true : false // Fallback old emotes as not loopable + emote.hasGeometry = data.length >= 8 && data[7].includes('g') + emote.hasSound = data.length >= 8 && data[7].includes('s') emote.save() return emote @@ -77,6 +78,8 @@ export function setItemEmoteSearchFields(item: Item): Item { item.searchEmoteLoop = emote.loop item.searchEmoteBodyShapes = emote.bodyShapes item.searchEmoteRarity = emote.rarity + item.searchEmoteHasSound = emote.hasSound + item.searchEmoteHasGeometry = emote.hasGeometry } item.searchItemType = item.itemType }