diff --git a/js/src/api/contract/contract.js b/js/src/api/contract/contract.js
index 68c0371a116..eacb21fd1e1 100644
--- a/js/src/api/contract/contract.js
+++ b/js/src/api/contract/contract.js
@@ -89,9 +89,15 @@ export default class Contract {
return this;
}
- deploy (options, values, statecb) {
- let gas;
+ deployEstimateGas (options, values) {
+ return this._api.eth
+ .estimateGas(this._encodeOptions(this.constructors[0], options, values))
+ .then((gasEst) => {
+ return [gasEst, gasEst.mul(1.2)];
+ });
+ }
+ deploy (options, values, statecb) {
const setState = (state) => {
if (!statecb) {
return;
@@ -102,31 +108,32 @@ export default class Contract {
setState({ state: 'estimateGas' });
- return this._api.eth
- .estimateGas(this._encodeOptions(this.constructors[0], options, values))
- .then((_gas) => {
- gas = _gas.mul(1.2);
+ return this
+ .deployEstimateGas(options, values)
+ .then(([gasEst, gas]) => {
options.gas = gas.toFixed(0);
setState({ state: 'postTransaction', gas });
- return this._api.parity.postTransaction(this._encodeOptions(this.constructors[0], options, values));
- })
- .then((requestId) => {
- setState({ state: 'checkRequest', requestId });
- return this._pollCheckRequest(requestId);
- })
- .then((txhash) => {
- setState({ state: 'getTransactionReceipt', txhash });
- return this._pollTransactionReceipt(txhash, gas);
- })
- .then((receipt) => {
- if (receipt.gasUsed.eq(gas)) {
- throw new Error(`Contract not deployed, gasUsed == ${gas.toFixed(0)}`);
- }
- setState({ state: 'hasReceipt', receipt });
- this._address = receipt.contractAddress;
- return this._address;
+ return this._api.parity
+ .postTransaction(this._encodeOptions(this.constructors[0], options, values))
+ .then((requestId) => {
+ setState({ state: 'checkRequest', requestId });
+ return this._pollCheckRequest(requestId);
+ })
+ .then((txhash) => {
+ setState({ state: 'getTransactionReceipt', txhash });
+ return this._pollTransactionReceipt(txhash, gas);
+ })
+ .then((receipt) => {
+ if (receipt.gasUsed.eq(gas)) {
+ throw new Error(`Contract not deployed, gasUsed == ${gas.toFixed(0)}`);
+ }
+
+ setState({ state: 'hasReceipt', receipt });
+ this._address = receipt.contractAddress;
+ return this._address;
+ });
})
.then((address) => {
setState({ state: 'getCode' });
diff --git a/js/src/modals/DeployContract/DetailsStep/detailsStep.js b/js/src/modals/DeployContract/DetailsStep/detailsStep.js
index d2fa869a7a8..cfb8aa40f52 100644
--- a/js/src/modals/DeployContract/DetailsStep/detailsStep.js
+++ b/js/src/modals/DeployContract/DetailsStep/detailsStep.js
@@ -15,6 +15,7 @@
// along with Parity. If not, see