WIP
This commit is contained in:
parent
1576db38d5
commit
4332480b86
|
@ -114,6 +114,10 @@ function writeJson() {
|
||||||
return restrictPath(fs.writeJson, fs.writeJson, 1, arguments);
|
return restrictPath(fs.writeJson, fs.writeJson, 1, arguments);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function ensureFileSync() {
|
||||||
|
return restrictPath(fs.ensureFileSync, fs.ensureFileSync, 1, arguments);
|
||||||
|
}
|
||||||
|
|
||||||
function existsSync() {
|
function existsSync() {
|
||||||
return restrictPath(fs.existsSync, fs.existsSync, 1, arguments);
|
return restrictPath(fs.existsSync, fs.existsSync, 1, arguments);
|
||||||
}
|
}
|
||||||
|
@ -208,5 +212,6 @@ module.exports = {
|
||||||
dappPath,
|
dappPath,
|
||||||
pkgPath,
|
pkgPath,
|
||||||
outputFileSync,
|
outputFileSync,
|
||||||
|
ensureFileSync,
|
||||||
writeJson
|
writeJson
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
const utils = require('../../utils/utils.js');
|
const utils = require('../../utils/utils.js');
|
||||||
|
const fs = require('../../core/fs');
|
||||||
|
|
||||||
class ConsoleListener {
|
class ConsoleListener {
|
||||||
constructor(embark, options) {
|
constructor(embark, options) {
|
||||||
|
@ -16,6 +17,8 @@ class ConsoleListener {
|
||||||
this.outputDone = true;
|
this.outputDone = true;
|
||||||
});
|
});
|
||||||
this._registerAPI();
|
this._registerAPI();
|
||||||
|
this.transactionPath = fs.dappPath('.embark', 'transactions.json');
|
||||||
|
fs.ensureFileSync(this.transactionPath);
|
||||||
|
|
||||||
this.events.on("contractsDeployed", () => {
|
this.events.on("contractsDeployed", () => {
|
||||||
this.contractsDeployed = true;
|
this.contractsDeployed = true;
|
||||||
|
@ -97,7 +100,15 @@ class ConsoleListener {
|
||||||
gasUsed = utils.hexToNumber(gasUsed);
|
gasUsed = utils.hexToNumber(gasUsed);
|
||||||
blockNumber = utils.hexToNumber(blockNumber);
|
blockNumber = utils.hexToNumber(blockNumber);
|
||||||
|
|
||||||
this.logs.push(Object.assign({}, request, {name, functionName, paramString, gasUsed, blockNumber}));
|
let transactions;
|
||||||
|
try {
|
||||||
|
transactions = JSON.parse(fs.readFileSync(this.transactionPath, 'utf-8'));
|
||||||
|
} catch {
|
||||||
|
transactions = {};
|
||||||
|
}
|
||||||
|
const transaction = Object.assign({}, request, {name, functionName, paramString, gasUsed, blockNumber});
|
||||||
|
transactions[transactionHash] = transaction;
|
||||||
|
fs.writeFileSync(this.transactionPath, JSON.stringify(transactions));
|
||||||
this.events.emit('contracts:log', this.logs[this.logs.length - 1]);
|
this.events.emit('contracts:log', this.logs[this.logs.length - 1]);
|
||||||
|
|
||||||
this.logger.info(`Blockchain>`.underline + ` ${name}.${functionName}(${paramString})`.bold + ` | ${transactionHash} | gas:${gasUsed} | blk:${blockNumber} | status:${status}`);
|
this.logger.info(`Blockchain>`.underline + ` ${name}.${functionName}(${paramString})`.bold + ` | ${transactionHash} | gas:${gasUsed} | blk:${blockNumber} | status:${status}`);
|
||||||
|
|
Loading…
Reference in New Issue