Display compilation result
This commit is contained in:
parent
1d13c71d83
commit
52cec0a29e
|
@ -4,7 +4,7 @@ import 'brace/mode/javascript';
|
|||
import 'brace/theme/tomorrow_night_blue';
|
||||
import 'ace-mode-solidity/build/remix-ide/mode-solidity';
|
||||
|
||||
const Fiddle = ({onCodeChange}) => {
|
||||
const Fiddle = ({onCodeChange, value}) => {
|
||||
|
||||
return (
|
||||
<React.Fragment>
|
||||
|
@ -16,7 +16,8 @@ const Fiddle = ({onCodeChange}) => {
|
|||
name="blah1"
|
||||
height="60em"
|
||||
width="100%"
|
||||
onChange={(e) => onCodeChange(e)}
|
||||
onChange={onCodeChange}
|
||||
value={value}
|
||||
/>
|
||||
</React.Fragment>
|
||||
);
|
||||
|
|
|
@ -5,44 +5,37 @@ import {fetchCodeCompilation} from '../actions';
|
|||
import Fiddle from '../components/Fiddle';
|
||||
|
||||
class FiddleContainer extends Component {
|
||||
componentWillMount() {
|
||||
|
||||
|
||||
constructor(props){
|
||||
super(props)
|
||||
this.state = { value: ''};
|
||||
}
|
||||
|
||||
onCodeChange(newValue) {
|
||||
this.setState({value: newValue});
|
||||
this.props.fetchCodeCompilation(newValue);
|
||||
}
|
||||
|
||||
render() {
|
||||
const { compilationResult } = this.props;
|
||||
|
||||
const code = 'hello world';
|
||||
console.log('rendering fiddle, compilation result = ' + compilationResult);
|
||||
const { fiddles } = this.props;
|
||||
|
||||
return (
|
||||
<React.Fragment>
|
||||
<Fiddle onCodeChange={this.props.fetchCodeCompilation} />
|
||||
<Fiddle value={this.state.value} onCodeChange={(n) => this.onCodeChange(n)} />
|
||||
<h2>Result</h2>
|
||||
{
|
||||
!compilationResult
|
||||
?
|
||||
'No compilation results yet'
|
||||
:
|
||||
compilationResult.error
|
||||
?
|
||||
<i>Error API...</i>
|
||||
:
|
||||
compilationResult
|
||||
}
|
||||
<p>{ fiddles.data ? JSON.stringify(fiddles.data) : 'No compilation results yet'}</p>
|
||||
</React.Fragment>
|
||||
);
|
||||
}
|
||||
}
|
||||
function mapStateToProps(state) {
|
||||
return {
|
||||
compilationResult: state.compilationResult
|
||||
fiddles: state.fiddles
|
||||
};
|
||||
}
|
||||
|
||||
FiddleContainer.propTypes = {
|
||||
compilationResult: PropTypes.object,
|
||||
fiddles: PropTypes.object,
|
||||
fetchCodeCompilation: PropTypes.func
|
||||
};
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import {combineReducers} from 'redux';
|
||||
import {REQUEST} from "../actions";
|
||||
import fiddleRecuder from './fiddleReducer';
|
||||
|
||||
const BN_FACTOR = 10000;
|
||||
|
||||
|
@ -86,7 +87,6 @@ function entities(state = entitiesDefaultState, action) {
|
|||
}
|
||||
|
||||
function errorMessage(state = null, action) {
|
||||
return action.error || state;
|
||||
}
|
||||
|
||||
function loading(_state = false, action) {
|
||||
|
@ -96,7 +96,8 @@ function loading(_state = false, action) {
|
|||
const rootReducer = combineReducers({
|
||||
entities,
|
||||
loading,
|
||||
errorMessage
|
||||
errorMessage,
|
||||
fiddles: fiddleRecuder
|
||||
});
|
||||
|
||||
export default rootReducer;
|
||||
|
|
|
@ -26,9 +26,9 @@ class Solidity {
|
|||
'/embark-api/contract/compile',
|
||||
(req, res) => {
|
||||
console.log('=====> POST contract/compile, req = ' + JSON.stringify(req.body));
|
||||
this.events.request("contract:compile", req.body.code, (compilationResult) => {
|
||||
this.events.request("contract:compile", req.body.code, (error, compilationResult) => {
|
||||
console.log('=====> POST contract/compile, result = ' + JSON.stringify(compilationResult));
|
||||
res.send(JSON.stringify({compilationResult: compilationResult}));
|
||||
res.send(JSON.stringify({compilationResult}));
|
||||
});
|
||||
}
|
||||
);
|
||||
|
|
Loading…
Reference in New Issue