mirror of
https://github.com/status-im/embark-area-51.git
synced 2025-02-18 18:26:50 +00:00
Merge pull request #528 from embark-framework/cached_gas_issue
fix cached gas issue
This commit is contained in:
commit
502788c7e0
@ -27,8 +27,6 @@ class TemplateGenerator {
|
|||||||
console.log('-------------------'.yellow);
|
console.log('-------------------'.yellow);
|
||||||
console.log(__('Next steps:').green);
|
console.log(__('Next steps:').green);
|
||||||
console.log(('-> ' + ('cd ' + fspath).bold.cyan).green);
|
console.log(('-> ' + ('cd ' + fspath).bold.cyan).green);
|
||||||
console.log('-> '.green + 'embark blockchain'.bold.cyan + ' or '.green + 'embark simulator'.bold.cyan);
|
|
||||||
console.log(__('open another console in the same directory and run').green);
|
|
||||||
console.log('-> '.green + 'embark run'.bold.cyan);
|
console.log('-> '.green + 'embark run'.bold.cyan);
|
||||||
console.log(__('For more info go to http://embark.status.im').green);
|
console.log(__('For more info go to http://embark.status.im').green);
|
||||||
}
|
}
|
||||||
|
@ -216,10 +216,13 @@ class ContractDeployer {
|
|||||||
},
|
},
|
||||||
function estimateCorrectGas(next) {
|
function estimateCorrectGas(next) {
|
||||||
if (contract.gas === 'auto') {
|
if (contract.gas === 'auto') {
|
||||||
return deployObject.estimateGas().then((gasValue) => {
|
return self.blockchain.estimateDeployContractGas(deployObject, (err, gasValue) => {
|
||||||
|
if (err) {
|
||||||
|
return next(err);
|
||||||
|
}
|
||||||
contract.gas = gasValue;
|
contract.gas = gasValue;
|
||||||
next();
|
next();
|
||||||
}).catch(next);
|
});
|
||||||
}
|
}
|
||||||
next();
|
next();
|
||||||
},
|
},
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
let toposort = require('toposort');
|
let toposort = require('toposort');
|
||||||
let async = require('async');
|
let async = require('async');
|
||||||
|
const cloneDeep = require('clone-deep');
|
||||||
|
|
||||||
let utils = require('../utils/utils.js');
|
let utils = require('../utils/utils.js');
|
||||||
const constants = require('../constants');
|
|
||||||
|
|
||||||
// TODO: create a contract object
|
// TODO: create a contract object
|
||||||
|
|
||||||
@ -10,7 +10,7 @@ class ContractsManager {
|
|||||||
constructor(options) {
|
constructor(options) {
|
||||||
const self = this;
|
const self = this;
|
||||||
this.contractFiles = options.contractFiles;
|
this.contractFiles = options.contractFiles;
|
||||||
this.contractsConfig = options.contractsConfig;
|
this.contractsConfig = cloneDeep(options.contractsConfig || {});
|
||||||
this.contracts = {};
|
this.contracts = {};
|
||||||
this.logger = options.logger;
|
this.logger = options.logger;
|
||||||
this.plugins = options.plugins;
|
this.plugins = options.plugins;
|
||||||
@ -20,13 +20,6 @@ class ContractsManager {
|
|||||||
this.events = options.events;
|
this.events = options.events;
|
||||||
this.compileError = false;
|
this.compileError = false;
|
||||||
|
|
||||||
self.events.on(constants.events.contractFilesChanged, (newContractFiles) => {
|
|
||||||
self.contractFiles = newContractFiles;
|
|
||||||
});
|
|
||||||
self.events.on(constants.events.contractConfigChanged, (newContracts) => {
|
|
||||||
self.contractsConfig = newContracts;
|
|
||||||
});
|
|
||||||
|
|
||||||
self.events.setCommandHandler('contracts:list', (cb) => {
|
self.events.setCommandHandler('contracts:list', (cb) => {
|
||||||
cb(self.compileError, self.listContracts());
|
cb(self.compileError, self.listContracts());
|
||||||
});
|
});
|
||||||
@ -58,7 +51,20 @@ class ContractsManager {
|
|||||||
|
|
||||||
build(done) {
|
build(done) {
|
||||||
let self = this;
|
let self = this;
|
||||||
|
self.contracts = {};
|
||||||
async.waterfall([
|
async.waterfall([
|
||||||
|
function loadContractFiles(callback) {
|
||||||
|
self.events.request("config:contractsFiles", (contractsFiles) => {
|
||||||
|
self.contractsFiles = contractsFiles;
|
||||||
|
callback();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
function loadContractConfigs(callback) {
|
||||||
|
self.events.request("config:contractsConfig", (contractsConfig) => {
|
||||||
|
self.contractsConfig = cloneDeep(contractsConfig);
|
||||||
|
callback();
|
||||||
|
});
|
||||||
|
},
|
||||||
function compileContracts(callback) {
|
function compileContracts(callback) {
|
||||||
self.events.emit("status", __("Compiling..."));
|
self.events.emit("status", __("Compiling..."));
|
||||||
if (process.env.isTest && self.compiledContracts && Object.keys(self.compiledContracts).length) {
|
if (process.env.isTest && self.compiledContracts && Object.keys(self.compiledContracts).length) {
|
||||||
|
@ -7,6 +7,7 @@ const deepEqual = require('deep-equal');
|
|||||||
const constants = require('../constants');
|
const constants = require('../constants');
|
||||||
|
|
||||||
var Config = function(options) {
|
var Config = function(options) {
|
||||||
|
const self = this;
|
||||||
this.env = options.env;
|
this.env = options.env;
|
||||||
this.blockchainConfig = {};
|
this.blockchainConfig = {};
|
||||||
this.contractsConfig = {};
|
this.contractsConfig = {};
|
||||||
@ -22,6 +23,14 @@ var Config = function(options) {
|
|||||||
this.events = options.events;
|
this.events = options.events;
|
||||||
this.embarkConfig = {};
|
this.embarkConfig = {};
|
||||||
this.context = options.context || [constants.contexts.any];
|
this.context = options.context || [constants.contexts.any];
|
||||||
|
|
||||||
|
self.events.setCommandHandler("config:contractsConfig", (cb) => {
|
||||||
|
cb(self.contractsConfig);
|
||||||
|
});
|
||||||
|
|
||||||
|
self.events.setCommandHandler("config:contractsFiles", (cb) => {
|
||||||
|
cb(self.contractsFiles);
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
Config.prototype.loadConfigFiles = function(options) {
|
Config.prototype.loadConfigFiles = function(options) {
|
||||||
|
@ -43,14 +43,15 @@ describe('embark.Contracts', function() {
|
|||||||
compiler.compile_contracts(contractFiles, cb);
|
compiler.compile_contracts(contractFiles, cb);
|
||||||
});
|
});
|
||||||
|
|
||||||
let contractsManager = new ContractsManager({
|
events.setCommandHandler("config:contractsConfig", function(cb) {
|
||||||
plugins: plugins,
|
cb(contractsConfig);
|
||||||
contractFiles: [
|
});
|
||||||
readFile('test/contracts/simple_storage.sol'),
|
|
||||||
readFile('test/contracts/token.sol')
|
events.setCommandHandler("config:contractsFiles", (cb) => {
|
||||||
],
|
cb([]);
|
||||||
contractDirectories: ['app/contracts'],
|
});
|
||||||
contractsConfig: {
|
|
||||||
|
let contractsConfig = {
|
||||||
"versions": {
|
"versions": {
|
||||||
"web3.js": "1.0.0-beta",
|
"web3.js": "1.0.0-beta",
|
||||||
"solc": "0.4.17"
|
"solc": "0.4.17"
|
||||||
@ -77,7 +78,16 @@ describe('embark.Contracts', function() {
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
};
|
||||||
|
|
||||||
|
let contractsManager = new ContractsManager({
|
||||||
|
plugins: plugins,
|
||||||
|
contractFiles: [
|
||||||
|
readFile('test/contracts/simple_storage.sol'),
|
||||||
|
readFile('test/contracts/token.sol')
|
||||||
|
],
|
||||||
|
contractDirectories: ['app/contracts'],
|
||||||
|
contractsConfig: contractsConfig,
|
||||||
logger: new Logger({}),
|
logger: new Logger({}),
|
||||||
events: events
|
events: events
|
||||||
});
|
});
|
||||||
@ -138,14 +148,15 @@ describe('embark.Contracts', function() {
|
|||||||
compiler.compile_contracts(contractFiles, cb);
|
compiler.compile_contracts(contractFiles, cb);
|
||||||
});
|
});
|
||||||
|
|
||||||
let contractsManager = new ContractsManager({
|
events.setCommandHandler("config:contractsConfig", function(cb) {
|
||||||
plugins: plugins,
|
cb(contractsConfig);
|
||||||
contractFiles: [
|
});
|
||||||
readFile('test/contracts/simple_storage.sol'),
|
|
||||||
readFile('test/contracts/token_storage.sol')
|
events.setCommandHandler("config:contractsFiles", (cb) => {
|
||||||
],
|
cb([]);
|
||||||
contractDirectories: ['app/contracts'],
|
});
|
||||||
contractsConfig: {
|
|
||||||
|
let contractsConfig = {
|
||||||
"versions": {
|
"versions": {
|
||||||
"web3.js": "1.0.0-beta",
|
"web3.js": "1.0.0-beta",
|
||||||
"solc": "0.4.17"
|
"solc": "0.4.17"
|
||||||
@ -182,7 +193,16 @@ describe('embark.Contracts', function() {
|
|||||||
"instanceOf": "SimpleStorage"
|
"instanceOf": "SimpleStorage"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
|
|
||||||
|
let contractsManager = new ContractsManager({
|
||||||
|
plugins: plugins,
|
||||||
|
contractFiles: [
|
||||||
|
readFile('test/contracts/simple_storage.sol'),
|
||||||
|
readFile('test/contracts/token_storage.sol')
|
||||||
|
],
|
||||||
|
contractDirectories: ['app/contracts'],
|
||||||
|
contractsConfig: contractsConfig,
|
||||||
logger: new Logger({}),
|
logger: new Logger({}),
|
||||||
events: events
|
events: events
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user