Fix issues in Contract Development view (#5555)

* Better errors in contract dev

* Use RAW Git instead of Github Raw URLs (better CORS support)

* Network first for Solc list

* Don't use importScript n Worker // update rawgit to use CDN
This commit is contained in:
Nicolas Gotchac
2017-05-05 10:00:16 +02:00
committed by Jaco Greeff
parent 951dc757f8
commit eb316fcb9c
5 changed files with 59 additions and 49 deletions

View File

@@ -271,24 +271,6 @@ class WriteContract extends Component {
renderParameters () {
const { compiling, contract, selectedBuild, loading, workerError } = this.store;
if (workerError) {
return (
<div className={ styles.panel }>
<div className={ styles.centeredMessage }>
<p>
<FormattedMessage
id='writeContract.error.params'
defaultMessage='An error occurred with the following description'
/>
</p>
<div className={ styles.error }>
{ workerError.toString() }
</div>
</div>
</div>
);
}
if (selectedBuild < 0) {
return (
<div className={ `${styles.panel} ${styles.centeredMessage}` }>
@@ -306,10 +288,28 @@ class WriteContract extends Component {
);
}
if (loading) {
let content;
if (workerError) {
content = (
<div className={ styles.panel }>
<div className={ styles.centeredMessage }>
<p>
<FormattedMessage
id='writeContract.error.params'
defaultMessage='An error occurred with the following description'
/>
</p>
<div className={ styles.error }>
{ workerError.toString() }
</div>
</div>
</div>
);
} else if (loading) {
const { longVersion } = this.store.builds[selectedBuild];
return (
content = (
<div className={ styles.panel }>
<div className={ styles.centeredMessage }>
<CircularProgress
@@ -328,6 +328,8 @@ class WriteContract extends Component {
</div>
</div>
);
} else {
content = this.renderCompilation();
}
return (
@@ -392,7 +394,7 @@ class WriteContract extends Component {
</div>
</div>
{ this.renderSolidityVersions() }
{ this.renderCompilation() }
{ content }
</div>
);
}

View File

@@ -23,7 +23,7 @@ import store from 'store';
import { sha3 } from '~/api/util/sha3';
import SolidityUtils from '~/util/solidity';
const SOLIDITY_LIST_URL = 'https://raw.githubusercontent.com/ethereum/solc-bin/gh-pages/bin/list.json';
const SOLIDITY_LIST_URL = 'https://rawgit.com/ethereum/solc-bin/gh-pages/bin/list.json';
const WRITE_CONTRACT_STORE_KEY = '_parity::writeContractStore';
const SNIPPETS = {
@@ -197,6 +197,7 @@ export default class WriteContractStore {
})
.catch((error) => {
this.setWorkerError(error);
throw error;
});
}
@@ -318,6 +319,7 @@ export default class WriteContractStore {
transaction(() => {
this.compiled = false;
this.compiling = true;
this.setWorkerError(null);
});
const build = this.builds[this.selectedBuild];
@@ -365,12 +367,16 @@ export default class WriteContractStore {
annotations, contracts, errors
} = data.result;
this.contract = contract;
this.contractIndex = contractIndex;
if (!contract && errors && errors.length > 0) {
this.setWorkerError(errors[0]);
} else {
this.contract = contract;
this.contractIndex = contractIndex;
this.annotations = annotations;
this.contracts = contracts;
this.errors = errors;
this.annotations = annotations;
this.contracts = contracts;
this.errors = errors;
}
}
this.compiled = true;