Skip to content

Commit

Permalink
chore: local validation
Browse files Browse the repository at this point in the history
  • Loading branch information
SGiaccobasso committed Sep 24, 2024
1 parent bb77c7a commit ed5d2ee
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 116 deletions.
10 changes: 0 additions & 10 deletions .github/workflows/validate-tokens.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,3 @@ jobs:
EOF
bun run scripts/validate-token-configs.ts
- name: Check validation results
run: |
if [ -f validation_errors.txt ]; then
echo "Validation errors found:"
cat validation_errors.txt
exit 1
else
echo "All new token configurations are valid."
fi
82 changes: 0 additions & 82 deletions new_tokens.json

This file was deleted.

35 changes: 13 additions & 22 deletions scripts/run-validation.ts
Original file line number Diff line number Diff line change
@@ -1,26 +1,23 @@
import { readFile, writeFile } from "fs/promises";
import { readFile, writeFile, unlink } from "fs/promises";
import { execSync } from "child_process";
import path from "path";

const tokenListPath = "registry/mainnet/interchain/squid.tokenlist.json";
const tempFile = "new_tokens.json";

async function getFileContent(
filePath: string,
ref: string = "HEAD"
): Promise<string> {
async function cleanup() {
try {
return execSync(`git show ${ref}:${filePath}`, { encoding: "utf-8" });
} catch (error) {
console.error(`Error reading file from git: ${error}`);
return "";
}
await unlink(tempFile);
} catch {}
}

async function main() {
try {
// Fetching latest changes from main branch
execSync("git fetch origin main", { stdio: "inherit" });
const mainContent = await getFileContent(tokenListPath, "origin/main");
const mainContent = execSync(`git show "origin/main":${tokenListPath}`, {
encoding: "utf-8",
});
const mainTokens = JSON.parse(mainContent).tokens;

// Read local version
Expand All @@ -38,21 +35,15 @@ async function main() {
await writeFile("new_tokens.json", JSON.stringify(newTokens, null, 2));
} catch (error) {
console.error("An error occurred:", error);
cleanup();
}
// Run validation script
try {
execSync("bun run scripts/validate-token-configs.js", { stdio: "inherit" });
} catch {}

// Check for validation errors
// Run validation script
try {
await readFile("validation_errors.txt", "utf8");
console.error(
"Validation errors found. Check validation_errors.txt for details."
);
process.exit(1);
execSync("bun run scripts/validate-token-configs.ts", { stdio: "inherit" });
} catch {
console.log("All new token configurations are valid.");
} finally {
cleanup();
}
}

Expand Down
1 change: 0 additions & 1 deletion scripts/validate-token-configs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,6 @@ async function getRpcUrls(axelarChainId: string): Promise<string[]> {

function exitWithError(errorMessage: string) {
console.error(errorMessage);
fs.writeFileSync("validation_errors.txt", errorMessage);
process.exit(1);
}

Expand Down
1 change: 0 additions & 1 deletion validation_errors.txt

This file was deleted.

0 comments on commit ed5d2ee

Please sign in to comment.