Contract constructor deploy visible

Contract constructor now visible after compile, but the deploy button is not operational yet.

Modified the compilation for returning all errors that still allows for a fatal compilation error to be passed through.

Empty fiddle profile now treated as undefined.
This commit is contained in:
emizzle 2018-09-04 22:34:52 +10:00
parent 7899a03fac
commit bd3ac7c8ec
3 changed files with 12 additions and 9 deletions

View File

@ -222,6 +222,7 @@ export const fiddleProfile = {
timestamp = lastFiddle.timestamp;
compilationResult = lastFiddle.compilationResult;
}
if(fiddleProfile === '') fiddleProfile = undefined;
return action(FIDDLE_PROFILE[SUCCESS], {fiddleProfiles: [{fiddleProfile, timestamp, compilationResult}]});
},
failure: (error) => action(FIDDLE_PROFILE[FAILURE], {error})

View File

@ -223,7 +223,7 @@ class FiddleContainer extends Component {
fatalFiddleDeployCard={this._renderFatalCard("Failed to deploy", fiddleDeployError)}
compiledContractsCard={compiledFiddle && compiledFiddle.compilationResult && this._renderSuccessCard("Contract(s) compiled!",
profiledFiddle && <ContractFunctions contractProfile={profiledFiddle}
contractFunctions={deployedFiddle}
contractFunctions={[]}
onlyConstructor
postContractFunction={this._onDeployClick}/>
)}

View File

@ -28,14 +28,16 @@ class Solidity {
return res.status(422).send({error: 'Body parameter \'codeToCompile\' must be a string'});
}
const input = {'fiddle': {content: sourceCode.replace(/\r\n/g, '\n')}};
this.compile_solidity_code(input, {}, true, (errors, compilationResult) => {
this.compile_solidity_code(input, {}, true, (error, compilationResult, errors) => {
if (error) res.status(500).send({error: error.message});
// write code to filesystem so we can view the source after page refresh
const className = !compilationResult ? 'temp' : Object.keys(compilationResult).join('_');
this._writeFiddleToFile(sourceCode, className, Boolean(compilationResult), (err) => {
if (err) this.logger.trace('Error writing fiddle to filesystem: ', err);
}); // async, do not need to wait
const responseData = {errors: errors, compilationResult: compilationResult};
const responseData = {errors, compilationResult};
this.logger.trace(`POST response /embark-api/contract/compile:\n ${JSON.stringify(responseData)}`);
res.send(responseData);
});
@ -71,16 +73,13 @@ class Solidity {
if (err) {
return callback(err);
}
if (output.errors && returnAllErrors) {
return callback(output.errors);
}
if (output.errors) {
for (let i = 0; i < output.errors.length; i++) {
if (output.errors[i].type === 'Warning') {
self.logger.warn(output.errors[i].formattedMessage);
}
if (output.errors[i].type === 'Error' || output.errors[i].severity === 'error') {
if ((output.errors[i].type === 'Error' || output.errors[i].severity === 'error') && !returnAllErrors) {
return callback(new Error("Solidity errors: " + output.errors[i].formattedMessage).message);
}
}
@ -175,9 +174,12 @@ class Solidity {
}
}
callback(null, compiled_object);
callback(null, compiled_object, output.errors);
}
], function (err, result, errors) {
if (returnAllErrors) {
return cb(err, result, errors);
}
], function (err, result) {
cb(err, result);
});
}