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