Skip to content

Commit

Permalink
Add some more scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
gamalielhere committed Sep 20, 2018
1 parent 04dcd3e commit 7638551
Show file tree
Hide file tree
Showing 7 changed files with 119 additions and 313 deletions.
4 changes: 2 additions & 2 deletions checkContract.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const constraints = {
}
};

function run() {
function checkContract() {
fs.readdirSync(contractsDirectory).forEach(folder => {
fs.readdirSync(`${contractsDirectory}/${folder}`).forEach(file => {
if (
Expand Down Expand Up @@ -55,4 +55,4 @@ function run() {
process.exit(0);
}

run();
module.exports = checkContract;
4 changes: 2 additions & 2 deletions checkToken.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ const constraints = {
}
};

function run() {
function checkToken() {
fs.readdirSync(tokensDirectory).forEach(folder => {
fs.readdirSync(`${tokensDirectory}/${folder}`).forEach(file => {
if (
Expand Down Expand Up @@ -135,4 +135,4 @@ function run() {
process.exit(0);
}

run();
module.exports = checkToken;
13 changes: 13 additions & 0 deletions compile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
const recreateFiles = require('./recreateFiles');
const createFiles = require('./createFiles');
const checkContract = require('./checkContract');
const checkToken = require('./checkToken');

function compile() {
recreateFiles();
createFiles();
checkToken();
checkContract();
}

compile();
4 changes: 2 additions & 2 deletions createFiles.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@ function createTokenFiles() {
});
}

function run() {
function createFiles() {
createContractFiles();
createTokenFiles();
}

run();
module.exports = createFiles;
4 changes: 2 additions & 2 deletions recreateFiles.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const fs = require('fs');
const directory = './src/contracts';
// const directory = './src/tokens';
function run() {
function recreateFiles() {
fs.readdirSync(directory).forEach(tokenFolder => {
fs.readdirSync(`${directory}/${tokenFolder}`).forEach(file => {
const newFile = JSON.parse(
Expand All @@ -17,4 +17,4 @@ function run() {
});
}

run();
module.exports = recreateFiles;
42 changes: 42 additions & 0 deletions renameToChecksum.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
const fs = require('fs');
const web3 = require('web3');
const utiles = web3.utils;
const contractsDirectory = './src/contracts';
const tokensDirectory = './src/tokens';

function renameTokens() {
fs.readdirSync(tokensDirectory).forEach(folder => {
fs.readdirSync(`${tokensDirectory}/${folder}`).forEach(file => {
if (!utils.checkAddressChecksum(file.replace('.json', ''))) {
fs.renameSync(
`${tokensDirectory}/${folder}/${file}`,
`${tokensDirectory}/${folder}/${utils.toChecksumAddress(
file.replace('.json', '')
)}.json`
);
}
});
});
}

function renameContracts() {
fs.readdirSync(contractsDirectory).forEach(folder => {
fs.readdirSync(`${contractsDirectory}/${folder}`).forEach(file => {
if (!utils.checkAddressChecksum(file.replace('.json', ''))) {
fs.renameSync(
`${contractsDirectory}/${folder}/${file}`,
`${contractsDirectory}/${folder}/${utils.toChecksumAddress(
file.replace('.json', '')
)}.json`
);
}
});
});
}

function renameToChecksum() {
renameTokens();
renameContracts();
}

module.exports = renameToChecksum;
Loading

0 comments on commit 7638551

Please sign in to comment.