Skip to content

Commit

Permalink
feat: support for base emotes (#258)
Browse files Browse the repository at this point in the history
* support for base emotes

* Save Fri Feb 16 12:31:42 PM -03 2024
  • Loading branch information
hugoArregui authored Feb 16, 2024
1 parent b45ed6c commit 9543c8e
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 2 deletions.
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])
}

0 comments on commit 9543c8e

Please sign in to comment.