Load contract APIs from hardhat artifacts

This commit is contained in:
bumi 2022-05-19 18:06:56 +02:00
parent 9d87636fb0
commit ba52e61d50
5 changed files with 14 additions and 20 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,24 +1,18 @@
const fs = require('fs');
const path = require('path');
const fs = require("fs");
const path = require("path");
const contractsPath = path.join(__dirname, '..', 'build', 'contracts');
const libPath = path.join(__dirname, '..', 'lib');
const abisPath = path.join(libPath, 'abis');
const contractsPath = path.join(__dirname, "..", "artifacts", "contracts");
const libPath = path.join(__dirname, "..", "lib");
const abisPath = path.join(libPath, "abis");
const files = [
'Contributor',
'Contribution',
'Kernel',
'Proposal',
'Token',
'Reimbursement',
'ACL'
];
const files = ["Contributor", "Contribution", "Token", "Reimbursement"];
files.forEach((fileName) => {
let file = require(`${contractsPath}/${fileName}.json`);
let file = require(`${contractsPath}/${fileName}.sol/${fileName}.json`);
let abiFile = path.join(abisPath, `${fileName}.json`);
fs.writeFileSync(abiFile, JSON.stringify(file.abi));
});
console.log("Don't forget to reaload the JSON files from your application; i.e. restart kredits-web");
console.log(
"Don't forget to reaload the JSON files from your application; i.e. restart kredits-web"
);