Created
September 18, 2018 19:43
-
-
Save pkieltyka/1646a6f26e4c589e8f050e715e760e4b to your computer and use it in GitHub Desktop.
Revisions
-
pkieltyka created this gist
Sep 18, 2018 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,31 @@ 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) }) })