Skip to content

Commit

Permalink
Merge pull request #56 from pendle-finance/add-logo-size-limit-valida…
Browse files Browse the repository at this point in the history
…tion

add logo size limit on validataion workflow
  • Loading branch information
gentyana authored Oct 4, 2024
2 parents 6ea950c + 6412736 commit 526115a
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 526115a

Please sign in to comment.