2020-05-13 14:23:17 +03:00
|
|
|
const fs = require('fs');
|
2020-06-23 17:34:03 +02:00
|
|
|
const path = require('path');
|
2020-05-13 14:23:17 +03:00
|
|
|
|
2020-06-23 17:34:03 +02: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 17:39:52 +03:00
|
|
|
};
|
2020-05-13 14:23:17 +03:00
|
|
|
|
2020-06-23 17:34:03 +02:00
|
|
|
module.exports.loadContractCode = (contractName) => {
|
2020-06-29 17:41:28 +02:00
|
|
|
return this.loadContractFile(`${contractName}.bin`);
|
2020-05-13 17:39:52 +03:00
|
|
|
};
|
|
|
|
|
2020-06-23 17:34:03 +02:00
|
|
|
module.exports.loadContract = (web3, contractName) => {
|
|
|
|
let content = this.loadContractFile(`${contractName}.abi`);
|
|
|
|
let abi = JSON.parse(content);
|
|
|
|
return new web3.eth.Contract(abi);
|
|
|
|
};
|