Delay contract deploiement if share bytecode
This commit is contained in:
parent
13ab52125a
commit
527dbcca8b
|
@ -20,6 +20,7 @@ class BlockchainConnector {
|
||||||
this.isDev = options.isDev;
|
this.isDev = options.isDev;
|
||||||
this.web3Endpoint = '';
|
this.web3Endpoint = '';
|
||||||
this.isWeb3Ready = false;
|
this.isWeb3Ready = false;
|
||||||
|
this.deployers = {};
|
||||||
|
|
||||||
self.events.setCommandHandler("blockchain:web3:isReady", (cb) => {
|
self.events.setCommandHandler("blockchain:web3:isReady", (cb) => {
|
||||||
cb(self.isWeb3Ready);
|
cb(self.isWeb3Ready);
|
||||||
|
@ -232,9 +233,29 @@ class BlockchainConnector {
|
||||||
}
|
}
|
||||||
|
|
||||||
deployContractFromObject(deployContractObject, params, cb) {
|
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, {
|
embarkJsUtils.secureSend(this.web3, deployContractObject, {
|
||||||
from: params.from, gas: params.gas, gasPrice: params.gasPrice
|
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) {
|
determineDefaultAccount(cb) {
|
||||||
|
|
Loading…
Reference in New Issue