mirror of https://github.com/embarklabs/embark.git
create separate function for secure send
This commit is contained in:
parent
a7b0cea09b
commit
083c936351
|
@ -230,7 +230,7 @@ class BlockchainConnector {
|
|||
}).catch(cb);
|
||||
}
|
||||
|
||||
deployContractFromObject(deployContractObject, params, cb) {
|
||||
secureSend(toSend, params, cb) {
|
||||
const self = this;
|
||||
let hash;
|
||||
let calledBacked = false;
|
||||
|
@ -263,9 +263,11 @@ class BlockchainConnector {
|
|||
});
|
||||
}, 500);
|
||||
|
||||
deployContractObject.send({
|
||||
from: params.from, gas: params.gas, gasPrice: params.gasPrice
|
||||
}, function (err, transactionHash) {
|
||||
toSend.estimateGas()
|
||||
.then(gasEstimated => {
|
||||
params.gas = gasEstimated + 1000;
|
||||
params.from = params.from || self.defaultAccount();
|
||||
return toSend.send(params, function(err, transactionHash) {
|
||||
if (err) {
|
||||
return callback(err);
|
||||
}
|
||||
|
@ -280,6 +282,13 @@ class BlockchainConnector {
|
|||
}
|
||||
self.web3.eth.getTransactionReceipt(hash, callback);
|
||||
}).catch(callback);
|
||||
});
|
||||
}
|
||||
|
||||
deployContractFromObject(deployContractObject, params, cb) {
|
||||
this.secureSend(deployContractObject, {
|
||||
from: params.from, gas: params.gas, gasPrice: params.gasPrice
|
||||
}, cb);
|
||||
}
|
||||
|
||||
determineDefaultAccount(cb) {
|
||||
|
|
Loading…
Reference in New Issue