Skip to content

Commit

Permalink
update isValidium method
Browse files Browse the repository at this point in the history
  • Loading branch information
toni-calvin committed Feb 1, 2024
1 parent b428c3d commit 02d17ce
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions core/tests/ts-integration/src/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,21 +111,20 @@ export async function scaledGasPrice(wallet: ethers.Wallet | zksync.Wallet): Pro
*
* @returns Boolean that indicates whether it is Validium mode.
*/
export async function getIsValidium(): Promise<Boolean> {
export async function getIsValidium(): Promise<boolean> {
const filePath = `${process.env.ZKSYNC_HOME}/etc/env/dev.env`;
let isValidium: Boolean = false;

try {
const fileContent = await fs.promises.readFile(filePath, 'utf-8');
const keyValuePairs = fileContent.split('\n').map((line) => line.trim().split('='));
const configObject: { [key: string]: string } = {};
keyValuePairs.forEach((pair) => {
if (pair.length === 2) {
configObject[pair[0]] = pair[1];
}
});
isValidium = configObject.VALIDIUM_MODE === 'true';

const isValidiumMode = fileContent
.split('\n')
.map((line) => line.trim().split('='))
.find((pair) => pair[0] === 'VALIDIUM_MODE');

return isValidiumMode ? isValidiumMode[1] === 'true' : false;
} catch (error) {
console.error(`Error reading or parsing the config file ${filePath}:`, error);
return false; // Return a default value or handle the error as needed
}
return isValidium;
}
}

0 comments on commit 02d17ce

Please sign in to comment.