From 9543c8e82b6ecd0146b4bc3dbd0f3c6f1df3f1f0 Mon Sep 17 00:00:00 2001 From: Hugo Arregui <969314+hugoArregui@users.noreply.github.com> Date: Fri, 16 Feb 2024 16:45:39 -0300 Subject: [PATCH] feat: support for base emotes (#258) * support for base emotes * Save Fri Feb 16 12:31:42 PM -03 2024 --- .github/workflows/build-and-publish.yml | 1 + package.json | 7 +++++++ src/platform/item/base-item.ts | 9 +++++++++ src/platform/item/emote/emote.ts | 15 +++++++++++++-- 4 files changed, 30 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-and-publish.yml b/.github/workflows/build-and-publish.yml index 73331697..344bf8c4 100644 --- a/.github/workflows/build-and-publish.yml +++ b/.github/workflows/build-and-publish.yml @@ -34,6 +34,7 @@ jobs: ## publish every package to s3 s3-bucket: ${{ secrets.SDK_TEAM_S3_BUCKET }} s3-bucket-key-prefix: '@dcl/${{ github.event.repository.name }}/branch/${{ github.head_ref }}' + s3-bucket-region: ${{ secrets.SDK_TEAM_AWS_REGION }} ## inform gitlab after publishing to proceed with CDN propagation gitlab-token: ${{ secrets.GITLAB_TOKEN }} diff --git a/package.json b/package.json index 1cef2891..2c136eac 100644 --- a/package.json +++ b/package.json @@ -16,6 +16,13 @@ "type": "git", "url": "git+https://github.com/decentraland/schemas.git" }, + "prettier": { + "printWidth": 120, + "semi": false, + "singleQuote": true, + "trailingComma": "none", + "tabWidth": 2 + }, "devDependencies": { "@dcl/eslint-config": "^1.1.1", "@microsoft/api-extractor": "^7.34.8", diff --git a/src/platform/item/base-item.ts b/src/platform/item/base-item.ts index 715800e9..bc9649e7 100644 --- a/src/platform/item/base-item.ts +++ b/src/platform/item/base-item.ts @@ -62,3 +62,12 @@ export function isBaseAvatar(item: BaseItem): boolean { return urnParts.length === 5 && isDecentralandAvatar && isBaseAvatar } + +export function isBaseEmote(item: BaseItem): boolean { + if (!item || !item.id) { + return false + } + + const urnParts = item.id.split(':') + return urnParts.length === 5 && urnParts[1] === 'decentraland' && urnParts[3] === 'base-emotes' +} diff --git a/src/platform/item/emote/emote.ts b/src/platform/item/emote/emote.ts index 1ff6ddaf..aee13ad7 100644 --- a/src/platform/item/emote/emote.ts +++ b/src/platform/item/emote/emote.ts @@ -1,6 +1,6 @@ import { isThirdParty } from '..' import { generateLazyValidator, JSONSchema } from '../../../validation' -import { BaseItem, baseItemProperties, requiredBaseItemProps } from '../base-item' +import { BaseItem, baseItemProperties, isBaseEmote, requiredBaseItemProps } from '../base-item' import { standardProperties, StandardProps } from '../standard-props' import { thirdPartyProps, ThirdPartyProps } from '../third-party-props' import { EmoteDataADR74 } from './adr74/emote-data-adr74' @@ -27,6 +27,11 @@ export namespace Emote { required: ['emoteDataADR74'], // Emotes of ADR74 must be standard XOR thirdparty oneOf: [ + { + required: ['id', 'i18n'], + prohibited: ['merkleProof', 'content', 'collectionAddress', 'rarity'], + _isBaseEmote: true + }, { required: ['collectionAddress', 'rarity'], prohibited: ['merkleProof', 'content'], @@ -66,5 +71,11 @@ export namespace Emote { errors: false } - export const validate = generateLazyValidator(schema, [_isThirdPartyKeywordDef]) + const _isBaseEmoteKeywordDef = { + keyword: '_isBaseEmote', + validate: (schema: boolean, data: any) => !schema || isBaseEmote(data), + errors: false + } + + export const validate = generateLazyValidator(schema, [_isThirdPartyKeywordDef, _isBaseEmoteKeywordDef]) }