Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: emotes #41

Merged
merged 6 commits into from
Mar 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# Decentraland collections graph

- Mainnet: https://thegraph.com/explorer/subgraph/decentraland/collections-ethereum-mainnet (QmSRex2cvskLzaMpjeeZounbtFcMwirN7vaCf5LMo6FFna)
- Mainnet: https://thegraph.com/explorer/subgraph/decentraland/collections-ethereum-mainnet (QmdWuDd5S8TfhEV9SAXTpGi2pfPQGu8kJfs6mVB787fy4A)
- Ropsten: https://thegraph.com/explorer/subgraph/decentraland/collections-ethereum-ropsten (QmZTJrrSmAjKm1Vq8HRRkUu7FxvAbPXdum8vYmmR3pEF6w)
- Matic: https://thegraph.com/explorer/subgraph/decentraland/collections-matic-mainnet (QmcvFsuwJMC4o2B3Xp7kejU4YSDjFDNE89JwvgpgyGjmK8)
- Mumbai: https://thegraph.com/explorer/subgraph/decentraland/collections-matic-mumbai (QmSgPsD7sPmYNXysuFtjtXnENMRsHhAn5bZFaTfpVKDUAt)
- Matic: https://thegraph.com/explorer/subgraph/decentraland/collections-matic-mainnet (QmeajVAfQe1coz6H6SnR9pGhBo1Ntg1pMUAR7o5bxALjHK)
- Mumbai: https://thegraph.com/explorer/subgraph/decentraland/collections-matic-mumbai (QmSXYRaYd6Tmufanyw7URhLST3x7VAJ9rPaCHx2Lmgvb4f)

### Install

Expand Down
27 changes: 27 additions & 0 deletions schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,11 @@ type Item @entity {
searchWearableCategory: WearableCategory
searchWearableRarity: String # We're using String instead of WearableRarity here so we can later query this field via ()_in
searchWearableBodyShapes: [WearableBodyShape!]

## Emote search fields
searchEmoteCategory: EmoteCategory
searchEmoteRarity: String # We're using String instead of WearableRarity here so we can later query this field via ()_in
searchEmoteBodyShapes: [WearableBodyShape!]
}

type NFT @entity {
Expand Down Expand Up @@ -109,6 +114,11 @@ type NFT @entity {
searchWearableRarity: String # We're using String instead of WearableRarity here so we can later query this field via ()_in
searchWearableBodyShapes: [WearableBodyShape!]

## Emote search fields
searchEmoteCategory: EmoteCategory
searchEmoteRarity: String # We're using String instead of WearableRarity here so we can later query this field via ()_in
searchEmoteBodyShapes: [WearableBodyShape!]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

searchEmoteRarity and searchEmoteBodyShapes may be combined into a single searchRarity and searchBodyShapes and then get rid of the current searchWearableRarity and searchWearableBodyShapes. The thing is if we wanted to change those it would be a breaking change, so we would need to still support the old ones until migration the nft-server and potentially breaking other integrations. Also, even tho those things are repeated between wearables and emotes, they might not exist on other future type of assets (like 3D assets for the Builder) so it might be OK to let them exist only on the item types that actually use them./

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you want to create an issue with this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 #42


## Order search fields
searchOrderStatus: OrderStatus
searchOrderPrice: BigInt
Expand All @@ -120,13 +130,15 @@ type Metadata @entity {
id: ID!
itemType: ItemType!
wearable: Wearable
emote: Emote
}

enum ItemType @entity {
undefined
wearable_v1
wearable_v2
smart_wearable_v1
emote_v1
}

type Wearable @entity {
Expand All @@ -139,6 +151,16 @@ type Wearable @entity {
bodyShapes: [WearableBodyShape!]
}

type Emote @entity {
id: ID!
name: String!
description: String!
collection: String!
category: EmoteCategory!
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The difference between the Wearable and Emote entities is the latter uses EmoteCategory instead of WearableCategory

rarity: WearableRarity!
bodyShapes: [WearableBodyShape!]
}

enum WearableCategory @entity {
eyebrows
eyes
Expand All @@ -158,6 +180,11 @@ enum WearableCategory @entity {
skin
}

enum EmoteCategory @entity {
simple
loop
}

enum WearableRarity @entity {
common
uncommon
Expand Down
218 changes: 218 additions & 0 deletions src/entities/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -663,6 +663,60 @@ export class Item extends Entity {
);
}
}

get searchEmoteCategory(): string | null {
let value = this.get("searchEmoteCategory");
if (value === null || value.kind == ValueKind.NULL) {
return null;
} else {
return value.toString();
}
}

set searchEmoteCategory(value: string | null) {
if (value === null) {
this.unset("searchEmoteCategory");
} else {
this.set("searchEmoteCategory", Value.fromString(value as string));
}
}

get searchEmoteRarity(): string | null {
let value = this.get("searchEmoteRarity");
if (value === null || value.kind == ValueKind.NULL) {
return null;
} else {
return value.toString();
}
}

set searchEmoteRarity(value: string | null) {
if (value === null) {
this.unset("searchEmoteRarity");
} else {
this.set("searchEmoteRarity", Value.fromString(value as string));
}
}

get searchEmoteBodyShapes(): Array<string> | null {
let value = this.get("searchEmoteBodyShapes");
if (value === null || value.kind == ValueKind.NULL) {
return null;
} else {
return value.toStringArray();
}
}

set searchEmoteBodyShapes(value: Array<string> | null) {
if (value === null) {
this.unset("searchEmoteBodyShapes");
} else {
this.set(
"searchEmoteBodyShapes",
Value.fromStringArray(value as Array<string>)
);
}
}
}

export class NFT extends Entity {
Expand Down Expand Up @@ -1061,6 +1115,60 @@ export class NFT extends Entity {
}
}

get searchEmoteCategory(): string | null {
let value = this.get("searchEmoteCategory");
if (value === null || value.kind == ValueKind.NULL) {
return null;
} else {
return value.toString();
}
}

set searchEmoteCategory(value: string | null) {
if (value === null) {
this.unset("searchEmoteCategory");
} else {
this.set("searchEmoteCategory", Value.fromString(value as string));
}
}

get searchEmoteRarity(): string | null {
let value = this.get("searchEmoteRarity");
if (value === null || value.kind == ValueKind.NULL) {
return null;
} else {
return value.toString();
}
}

set searchEmoteRarity(value: string | null) {
if (value === null) {
this.unset("searchEmoteRarity");
} else {
this.set("searchEmoteRarity", Value.fromString(value as string));
}
}

get searchEmoteBodyShapes(): Array<string> | null {
let value = this.get("searchEmoteBodyShapes");
if (value === null || value.kind == ValueKind.NULL) {
return null;
} else {
return value.toStringArray();
}
}

set searchEmoteBodyShapes(value: Array<string> | null) {
if (value === null) {
this.unset("searchEmoteBodyShapes");
} else {
this.set(
"searchEmoteBodyShapes",
Value.fromStringArray(value as Array<string>)
);
}
}

get searchOrderStatus(): string | null {
let value = this.get("searchOrderStatus");
if (value === null || value.kind == ValueKind.NULL) {
Expand Down Expand Up @@ -1185,6 +1293,23 @@ export class Metadata extends Entity {
this.set("wearable", Value.fromString(value as string));
}
}

get emote(): string | null {
let value = this.get("emote");
if (value === null || value.kind == ValueKind.NULL) {
return null;
} else {
return value.toString();
}
}

set emote(value: string | null) {
if (value === null) {
this.unset("emote");
} else {
this.set("emote", Value.fromString(value as string));
}
}
}

export class Wearable extends Entity {
Expand Down Expand Up @@ -1280,6 +1405,99 @@ export class Wearable extends Entity {
}
}

export class Emote extends Entity {
constructor(id: string) {
super();
this.set("id", Value.fromString(id));
}

save(): void {
let id = this.get("id");
assert(id !== null, "Cannot save Emote entity without an ID");
assert(
id.kind == ValueKind.STRING,
"Cannot save Emote entity with non-string ID. " +
'Considering using .toHex() to convert the "id" to a string.'
);
store.set("Emote", id.toString(), this);
}

static load(id: string): Emote | null {
return store.get("Emote", id) as Emote | null;
}

get id(): string {
let value = this.get("id");
return value.toString();
}

set id(value: string) {
this.set("id", Value.fromString(value));
}

get name(): string {
let value = this.get("name");
return value.toString();
}

set name(value: string) {
this.set("name", Value.fromString(value));
}

get description(): string {
let value = this.get("description");
return value.toString();
}

set description(value: string) {
this.set("description", Value.fromString(value));
}

get collection(): string {
let value = this.get("collection");
return value.toString();
}

set collection(value: string) {
this.set("collection", Value.fromString(value));
}

get category(): string {
let value = this.get("category");
return value.toString();
}

set category(value: string) {
this.set("category", Value.fromString(value));
}

get rarity(): string {
let value = this.get("rarity");
return value.toString();
}

set rarity(value: string) {
this.set("rarity", Value.fromString(value));
}

get bodyShapes(): Array<string> | null {
let value = this.get("bodyShapes");
if (value === null || value.kind == ValueKind.NULL) {
return null;
} else {
return value.toStringArray();
}
}

set bodyShapes(value: Array<string> | null) {
if (value === null) {
this.unset("bodyShapes");
} else {
this.set("bodyShapes", Value.fromStringArray(value as Array<string>));
}
}
}

export class Rarity extends Entity {
constructor(id: string) {
super();
Expand Down
3 changes: 3 additions & 0 deletions src/modules/metadata/emote/categories.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// Emote categories
export const SIMPLE = 'simple'
export const LOOP = 'loop'
Loading