Can't deploy without compiling Contract (#5593)

This commit is contained in:
Nicolas Gotchac 2017-05-10 15:24:24 +02:00 committed by Jaco Greeff
parent c58c253cbf
commit 0a16c350d1
2 changed files with 17 additions and 6 deletions

View File

@ -345,12 +345,13 @@ class WriteContract extends Component {
}
onClick={ this.store.handleCompile }
primary={ false }
disabled={ compiling }
disabled={ compiling || this.store.isPristine }
/>
{
contract
? (
<Button
disabled={ compiling || !this.store.isPristine }
icon={ <SendIcon /> }
label={
<FormattedMessage

View File

@ -15,7 +15,7 @@
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
import { debounce } from 'lodash';
import { action, observable, transaction } from 'mobx';
import { action, computed, observable, transaction } from 'mobx';
import React from 'react';
import { FormattedMessage } from 'react-intl';
import store from 'store';
@ -140,7 +140,7 @@ export default class WriteContractStore {
this.worker = worker;
return Promise.all([
this.fetchSolidityVersions(),
this.fetchSolidityVersions().then(() => this.handleCompile()),
this.reloadContracts(undefined, undefined, false)
]);
}
@ -316,6 +316,18 @@ export default class WriteContractStore {
});
}
@computed get isPristine () {
return this.getHash() === this.lastCompilation.hash;
}
getHash () {
const build = this.builds[this.selectedBuild];
const version = build.longVersion;
const sourcecode = this.sourcecode.replace(/\s+/g, ' ');
return sha3(JSON.stringify({ version, sourcecode, optimize: this.optimize }));
}
@action handleCompile = () => {
transaction(() => {
this.compiled = false;
@ -324,9 +336,7 @@ export default class WriteContractStore {
});
const build = this.builds[this.selectedBuild];
const version = build.longVersion;
const sourcecode = this.sourcecode.replace(/\s+/g, ' ');
const hash = sha3(JSON.stringify({ version, sourcecode, optimize: this.optimize }));
const hash = this.getHash();
let promise = Promise.resolve(null);