Created
September 18, 2018 19:43
-
-
Save pkieltyka/1646a6f26e4c589e8f050e715e760e4b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const path = require('path') | |
const fs = require('fs') | |
const contractBuildDir = path.join(path.dirname(require.main.filename), '../build/contracts') | |
const abiDir = path.join(path.dirname(require.main.filename), '../abi') | |
fs.readdir(contractBuildDir, (err, files) => { | |
if (err) { | |
console.error('whoops', err) | |
process.exit() | |
} | |
files.forEach(filename => { | |
const abiFilePath = path.join(abiDir, filename) | |
console.log('creating ', abiFilePath, '...') | |
const contents = fs.readFileSync(path.join(contractBuildDir, filename), 'utf8') | |
const data = JSON.parse(contents) | |
const abi = { | |
'contractName': data['contractName'], | |
'abi': data['abi'], | |
'networks': data['networks'], | |
'updatedAt': data['updatedAt'] | |
} | |
const abiFileData = JSON.stringify(abi) | |
fs.writeFileSync(abiFilePath, abiFileData) | |
}) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment