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: support for base emotes #258

Merged
merged 2 commits into from
Feb 16, 2024
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
1 change: 1 addition & 0 deletions .github/workflows/build-and-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
7 changes: 7 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
9 changes: 9 additions & 0 deletions src/platform/item/base-item.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
}
15 changes: 13 additions & 2 deletions src/platform/item/emote/emote.ts
Original file line number Diff line number Diff line change
@@ -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'
Expand All @@ -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'],
Expand Down Expand Up @@ -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])
}
Loading