2020-05-13 11:23:17 +00:00
|
|
|
const fs = require('fs');
|
2020-06-23 15:34:03 +00:00
|
|
|
const path = require('path');
|
2020-05-13 11:23:17 +00:00
|
|
|
|
2020-06-23 15:34:03 +00:00
|
|
|
const CONTRACTS_PATH="./contracts";
|
|
|
|
|
|
|
|
module.exports.loadContractFile = (fileName) => {
|
|
|
|
let content = fs.readFileSync(path.join(__dirname, CONTRACTS_PATH, fileName), "utf-8");
|
|
|
|
return content;
|
2020-05-13 14:39:52 +00:00
|
|
|
};
|
2020-05-13 11:23:17 +00:00
|
|
|
|
2020-06-23 15:34:03 +00:00
|
|
|
module.exports.loadContractCode = (contractName) => {
|
2020-06-29 15:41:28 +00:00
|
|
|
return this.loadContractFile(`${contractName}.bin`);
|
2020-05-13 14:39:52 +00:00
|
|
|
};
|
|
|
|
|
2020-06-23 15:34:03 +00:00
|
|
|
module.exports.loadContract = (web3, contractName) => {
|
|
|
|
let content = this.loadContractFile(`${contractName}.abi`);
|
|
|
|
let abi = JSON.parse(content);
|
|
|
|
return new web3.eth.Contract(abi);
|
|
|
|
};
|