Skip to content

Commit

Permalink
wait for artifacts to build
Browse files Browse the repository at this point in the history
  • Loading branch information
gretzke committed Nov 25, 2023
1 parent 2230b5b commit b20ef6c
Showing 1 changed file with 9 additions and 22 deletions.
31 changes: 9 additions & 22 deletions script/util/extractor.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
const fs = require("fs");
const path = require("path");
const { exec } = require("child_process");
const Util = require("util");
const asyncExec = Util.promisify(exec);

// ========== ABOUT ==========

Expand All @@ -22,6 +24,8 @@ const scriptName = process.argv[2]; // Replace with the appropriate index for sc
const chainId = process.argv[3]; // Replace with the appropriate index for chainId

async function main() {
console.log("Extracting...");

// ========== APPEND TO HISTORY ==========

// Used for getVersion() helper
Expand Down Expand Up @@ -58,8 +62,7 @@ async function main() {
}
}

//TODO: Uncomment (see function definition).
//prepareArtifacts();
await prepareArtifacts();

// Filter transactions with "transactionType" as "CREATE"
const createTransactions = jsonData.transactions.filter((transaction) => transaction.transactionType === "CREATE");
Expand Down Expand Up @@ -191,14 +194,11 @@ async function main() {

// Write the updated object back to the record.json file
fs.writeFileSync(recordFilePath, JSON.stringify(recordData, null, 2), "utf8");
console.log(`Extraction complete.`);
}

console.log("Extracting...");

main();

console.log(`Extraction complete.`);

// ========== HELPERS ==========

// IN: contract address and RPC URL
Expand Down Expand Up @@ -281,24 +281,11 @@ function getABI(contractName) {
}

// Note: Makes sure contract artifacts are up-to-date.
function prepareArtifacts() {
//TODO: Make JS wait for these commands to finish before continuing.

async function prepareArtifacts() {
console.log(`Preparing artifacts...`);

exec("forge clean", (error) => {
if (error) {
console.error(`Failed to forge clean.`);
return;
}
});

exec("forge build", (error) => {
if (error) {
console.error(`Failed to forge build.`);
return;
}
});
await asyncExec("forge clean");
await asyncExec("forge build");

console.log(`Artifacts ready. Continuing...`);
}

0 comments on commit b20ef6c

Please sign in to comment.