keycard-redeem/scripts/utils.js

16 lines
415 B
JavaScript
Raw Normal View History

2020-05-13 11:23:17 +00:00
const fs = require('fs');
2020-05-13 14:39:52 +00:00
module.exports.loadJSON = (path) => {
2020-05-13 11:23:17 +00:00
let file = fs.readFileSync(path, "utf-8");
let loadedAsset = JSON.parse(file);
return loadedAsset;
2020-05-13 14:39:52 +00:00
};
2020-05-13 11:23:17 +00:00
2020-05-13 14:39:52 +00:00
module.exports.json2Contract = (web3, config) => {
2020-05-13 11:23:17 +00:00
return new web3.eth.Contract(config["abiDefinition"]);
2020-05-13 14:39:52 +00:00
};
module.exports.loadContract = (web3, path) => {
let config = this.loadJSON(path);
return this.json2Contract(web3, config);
};