Skip to content

Commit

Permalink
chore: update run validation script
Browse files Browse the repository at this point in the history
  • Loading branch information
SGiaccobasso committed Sep 24, 2024
1 parent c25040c commit 79ced73
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 13 deletions.
33 changes: 21 additions & 12 deletions scripts/run-validation.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { readFile } from "fs/promises";
import { execSync, spawnSync } from "child_process";
import { execSync, spawn } from "child_process";
import path from "path";

const tokenListPath = "registry/mainnet/interchain/squid.tokenlist.json";
Expand All @@ -26,21 +26,30 @@ async function main() {
.reduce((obj, [id, token]) => ({ ...obj, [id]: token }), {});

// Run validation script with new tokens as parameter
const result = spawnSync(
const validationProcess = spawn(
"bun",
["run", "scripts/validate-token-configs.ts"],
{
input: JSON.stringify(newTokens),
encoding: "utf-8",
stdio: ["pipe", "inherit", "inherit"],
}
{ stdio: ["pipe", "inherit", "inherit"] }
);

if (result.status !== 0) {
throw new Error(`Validation script exited with status ${result.status}`);
}

console.log("All new token configurations are valid.");
validationProcess.stdin.setDefaultEncoding("utf-8");
validationProcess.stdin.write(JSON.stringify(newTokens));
validationProcess.stdin.end();

await new Promise((resolve, reject) => {
validationProcess.on("close", (code) => {
if (code === 0) {
console.log("All new token configurations are valid.");
resolve(null);
} else {
reject(new Error(`Validation script exited with status ${code}`));
}
});

validationProcess.on("error", (error) => {
reject(new Error(`Validation process error: ${error.message}`));
});
});
} catch (error) {
console.error("Validation failed:", (error as Error).message);
process.exit(1);
Expand Down
3 changes: 2 additions & 1 deletion scripts/validate-token-configs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ const tokenManagerABI = [
* =============================
*/

// Get the tokens to be validated
async function getInputTokens() {
const chunks: any[] = [];
for await (const chunk of process.stdin) chunks.push(chunk);
Expand All @@ -128,7 +129,7 @@ async function getProvider(axelarChainId: string) {
for (let attempt = 0; attempt < rpcUrls.length; attempt++) {
try {
const rpcURL = rpcUrls[attempt];
provider = await new ethers.JsonRpcProvider(rpcURL);
provider = new ethers.JsonRpcProvider(rpcURL);

// Test the provider with a simple call
await provider.getNetwork();
Expand Down

0 comments on commit 79ced73

Please sign in to comment.