Skip to content

Commit

Permalink
add logo size limit on validataion workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
Manh Cao authored and Manh Cao committed Oct 1, 2024
1 parent e75db43 commit fc71a97
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions validate-config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
const fs = require('fs');
const path = require('path');

const LIMIT_ICON_KB_SIZE = 20;

function isValidEthereumAddress(address) {
const ethereumAddressPattern = /^0x[a-fA-F0-9]{40}$/;
return ethereumAddressPattern.test(address);
Expand Down Expand Up @@ -95,6 +97,16 @@ function validateConfig(protocol, assetMap) {
throw new Error(`protocol ${protocol}: icon path not found for protocol ${icon}`);
}

const iconStats = fs.statSync(iconPath);
if (iconStats.isDirectory()) {
throw new Error(`protocol ${protocol}: icon must be a png file`);
}

if (iconStats.size > LIMIT_ICON_KB_SIZE * 1024) {
throw new Error(`protocol ${protocol}: icon size must be less than ${LIMIT_ICON_KB_SIZE}KB file`);
}


const {pt, yt, lp} = metadata;
checkMetadataField(pt, protocol, 'pt', ptMap);
checkMetadataField(yt, protocol, 'yt', ytMap);
Expand Down

0 comments on commit fc71a97

Please sign in to comment.