Merge pull request #905 from embark-framework/bugfix/infura-simultaneous-tx

Bugfix/infura simultaneous tx
This commit is contained in:
Iuri Matias 2018-09-26 14:21:30 -04:00 committed by GitHub
commit 8d13cd8e9d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 2 deletions

View File

@ -20,6 +20,7 @@ class BlockchainConnector {
this.isDev = options.isDev;
this.web3Endpoint = '';
this.isWeb3Ready = false;
this.deployers = {};
self.events.setCommandHandler("blockchain:web3:isReady", (cb) => {
cb(self.isWeb3Ready);
@ -232,9 +233,29 @@ class BlockchainConnector {
}
deployContractFromObject(deployContractObject, params, cb) {
let deployer = this.deployers[deployContractObject._deployData];
if (!deployer) {
deployer = {running: false, requested: []};
this.deployers[deployContractObject._deployData] = deployer;
}
if (deployer.running) {
deployer.requested.push({deployContractObject, params, cb});
return;
}
deployer.running = true;
embarkJsUtils.secureSend(this.web3, deployContractObject, {
from: params.from, gas: params.gas, gasPrice: params.gasPrice
}, true, cb);
}, true, (error, receipt) => {
deployer.running = false;
if (deployer.requested.length > 0) {
let request = deployer.requested.shift();
this.deployContractFromObject(request.deployContractObject, request.params, request.cb);
}
cb(error, receipt);
});
}
determineDefaultAccount(cb) {

View File

@ -275,7 +275,7 @@ class ContractDeployer {
if (error) {
contract.error = error.message;
self.events.emit("deploy:contract:error", contract);
if (error.message && error.message.indexOf('replacement transaction underpriced')) {
if (error.message && error.message.indexOf('replacement transaction underpriced') !== -1) {
self.logger.warn("replacement transaction underpriced: This warning typically means a transaction exactly like this one is still pending on the blockchain");
}
return next(new Error("error deploying =" + contract.className + "= due to error: " + error.message));