Skip to content

Commit

Permalink
chore: validate logoURI path (#497)
Browse files Browse the repository at this point in the history
### Description

<!--
Summary of change.
Example: Add sepolia chain
-->
fixes #496 

Now validates that the path in logoURI for warp deployments actually
exists, if it doesn't it will throw an error in the CI

### Backward compatibility

<!--
Are these changes backward compatible? Note that additions are backwards
compatible.

Yes/No
-->
Yes
### Testing

<!--
Have any new metadata configs and deployment addresses been used with
any Hyperlane tooling, such as the CLI?
-->
Manual

![image](https://github.com/user-attachments/assets/e926cb98-7dc5-476d-a874-128e611f4a17)
  • Loading branch information
Xaroz authored Jan 16, 2025
1 parent 89bbb56 commit f86f9ae
Showing 1 changed file with 31 additions and 1 deletion.
32 changes: 31 additions & 1 deletion scripts/validate-file-data.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const noLogoFileError = [];
// warp route warnings / errors
const noConfigFileWarning = [];
const unorderedChainNamesError = [];
const invalidLogoURIPathError = [];

function validateChains() {
if (!fs.existsSync(chainsDir)) {
Expand Down Expand Up @@ -71,6 +72,27 @@ function validateConfigFiles(entryPath) {
noConfigFileWarning.push(entryPath);
return;
}

configFiles.forEach((configFile) => {
const configFilePath = path.join(entryPath, configFile);
const configData = readYaml(configFilePath);

if (Object.keys(configData).includes('tokens')) {
const tokens = configData.tokens;
tokens.forEach((token) => {
if (Object.keys(token).includes('logoURI')) {
const logoURI = token.logoURI;
const filePath = path.join('./', logoURI);
if (!fs.existsSync(filePath)) {
invalidLogoURIPathError.push({
chain: token.chainName,
path: configFilePath,
});
}
}
});
}
});
}

function validateWarpRoutes() {
Expand Down Expand Up @@ -105,7 +127,8 @@ function validateErrors() {
const errorCount =
missingDeployerField.length +
noLogoFileError.length +
unorderedChainNamesError.length;
unorderedChainNamesError.length +
invalidLogoURIPathError.length;

if (errorCount === 0) return;

Expand All @@ -125,6 +148,13 @@ function validateErrors() {
unorderedChainNamesError,
);

if (invalidLogoURIPathError.length > 0) {
console.error(
'Error: Invalid logoURI paths, verify that files exist:',
invalidLogoURIPathError,
);
}

process.exit(1);
}

Expand Down

0 comments on commit f86f9ae

Please sign in to comment.