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

add subtitle #74

Merged
merged 1 commit into from
Dec 9, 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
3 changes: 3 additions & 0 deletions const.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
3 changes: 2 additions & 1 deletion merge-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
})
}

Expand Down
22 changes: 20 additions & 2 deletions validate-config.js
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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}`);
Expand All @@ -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}`);
}
Expand Down
Loading