diff --git a/const.js b/const.js index 48ae886..0fb4bca 100644 --- a/const.js +++ b/const.js @@ -3,7 +3,10 @@ const PROTOCOL_CATEGORIES = ['money market', 'yield strategy', 'liquid locker', const DESCRIPTION_MAXIMUM_CHARACTERS = 120; +const SUBTITLE_MAXIMUM_CHARACTERS = 12; + module.exports = { PROTOCOL_CATEGORIES, DESCRIPTION_MAXIMUM_CHARACTERS, + SUBTITLE_MAXIMUM_CHARACTERS, } \ No newline at end of file diff --git a/merge-config.js b/merge-config.js index d2cfb23..7d458c0 100644 --- a/merge-config.js +++ b/merge-config.js @@ -70,12 +70,13 @@ function formatProtocolConfig(config) { function formatMetadataAssets(assets) { const result = []; for (const asset of (assets ?? [])) { - const {chainId, address, integrationUrl, description} = asset; + const {chainId, address, integrationUrl, description, subtitle} = asset; result.push({ chainId, address: address.toLowerCase(), integrationUrl, description, + subtitle, }) } diff --git a/validate-config.js b/validate-config.js index f95e7bf..f1c2678 100644 --- a/validate-config.js +++ b/validate-config.js @@ -1,7 +1,7 @@ const fs = require('fs'); const path = require('path'); const yaml = require('js-yaml'); -const {PROTOCOL_CATEGORIES, DESCRIPTION_MAXIMUM_CHARACTERS} = require("./const"); +const {PROTOCOL_CATEGORIES, DESCRIPTION_MAXIMUM_CHARACTERS, SUBTITLE_MAXIMUM_CHARACTERS} = require("./const"); const LIMIT_ICON_KB_SIZE = 20; const BUFFER_LIMIT_ICON_KB_SIZE = LIMIT_ICON_KB_SIZE + 1; @@ -34,6 +34,22 @@ function validateDescription(info) { } } +function validateSubtitle(info) { + const {protocol, field, index, subtitle} = info; + + if (subtitle === undefined) { + return; + } + + if (!mustBeNonEmptyString(subtitle)) { + throw new Error(`protocol ${protocol}: metadata ${field} 'subtitle' is not an non-empty string`); + } + + if (subtitle.length > SUBTITLE_MAXIMUM_CHARACTERS) { + throw new Error(`protocol ${protocol}: metadata ${field} 'subtitle' too long at index ${index}`); + } +} + async function main() { const CHANGED_PROTOCOLS = process.env.CHANGED_PROTOCOLS; const GET_ASSET_LIST_URL = process.env.GET_ASSET_LIST_URL; @@ -155,7 +171,7 @@ function checkMetadataField(data, protocol, field, assetMap) { for (let index = 0; index < data.length; index ++) { const item = data[index]; - const {chainId, address, description, integrationUrl} = item; + const {chainId, address, description, integrationUrl, subtitle} = item; if (typeof chainId !== 'number') { throw new Error(`protocol ${protocol}: metadata ${field} invalid 'chainId' field at index ${index}`); @@ -171,6 +187,8 @@ function checkMetadataField(data, protocol, field, assetMap) { validateDescription({protocol, field, index, description}); + validateSubtitle({protocol, field, index, subtitle}); + if (!mustBeNonEmptyString(integrationUrl)) { throw new Error(`protocol ${protocol}: metadata ${field} invalid 'integrationUrl' field at index ${index}`); }