diff --git a/embark-ui/src/actions/index.js b/embark-ui/src/actions/index.js
index c839e103..9bab56fc 100644
--- a/embark-ui/src/actions/index.js
+++ b/embark-ui/src/actions/index.js
@@ -175,6 +175,13 @@ export const fiddle = {
failure: (error) => action(FIDDLE[FAILURE], {error})
};
+export const FIDDLE_DEPLOY = createRequestTypes('FIDDLE_DEPLOY');
+export const fiddleDeploy = {
+ request: (compiledCode) => action(FIDDLE_DEPLOY[REQUEST], {compiledCode}),
+ success: () => action(FIDDLE_DEPLOY[SUCCESS]),
+ failure: (error) => action(FIDDLE_DEPLOY[FAILURE], {error})
+};
+
// Web Socket
export const WATCH_NEW_PROCESS_LOGS = 'WATCH_NEW_PROCESS_LOGS';
export const WATCH_NEW_CONTRACT_LOGS = 'WATCH_NEW_CONTRACT_LOGS';
diff --git a/embark-ui/src/api/index.js b/embark-ui/src/api/index.js
index 3718d061..653fff8f 100644
--- a/embark-ui/src/api/index.js
+++ b/embark-ui/src/api/index.js
@@ -124,6 +124,10 @@ export function webSocketBlockHeader() {
return new WebSocket(`${constants.wsEndpoint}/blockchain/blockHeader`);
}
-export function fetchFiddle(payload) {
+export function postFiddle(payload) {
return post('/contract/compile', {code: payload.codeToCompile});
}
+
+export function postFiddleDeploy(payload) {
+ return post('/contract/deploy', {compiledContract: payload.compiledCode.compilationResult});
+}
diff --git a/embark-ui/src/components/FiddleDeployButton.js b/embark-ui/src/components/FiddleDeployButton.js
new file mode 100644
index 00000000..7805b95e
--- /dev/null
+++ b/embark-ui/src/components/FiddleDeployButton.js
@@ -0,0 +1,47 @@
+import React, {Component} from 'react';
+import PropTypes from 'prop-types';
+import {Button} from 'tabler-react';
+import {fiddleDeploy as fiddleDeployAction} from '../actions';
+import {connect} from 'react-redux';
+import {getFiddle} from '../reducers/selectors';
+
+class FiddleDeployButton extends Component{
+
+ handleClick(){
+ this.props.postFiddleDeploy(this.props.fiddle);
+ }
+ render (){
+
+ return (
+
+ );
+ }
+}
+
+function mapStateToProps(state) {
+ return {
+ fiddle: getFiddle(state),
+ error: state.errorMessage,
+ loading: state.loading,
+ compiledContract: state.compiledContract
+ };
+}
+
+FiddleDeployButton.propTypes = {
+ fiddle: PropTypes.object,
+ postFiddleDeploy: PropTypes.func,
+ loading: PropTypes.bool,
+ compiledContract: PropTypes.object,
+ error: PropTypes.string
+};
+
+export default connect(
+ mapStateToProps,
+ {
+ postFiddleDeploy: fiddleDeployAction.request
+ },
+)(FiddleDeployButton);
diff --git a/embark-ui/src/components/FiddleResultsSummary.js b/embark-ui/src/components/FiddleResultsSummary.js
index 4a977421..88b4cfa9 100644
--- a/embark-ui/src/components/FiddleResultsSummary.js
+++ b/embark-ui/src/components/FiddleResultsSummary.js
@@ -1,6 +1,7 @@
import React, {Component} from 'react';
import {Badge, Icon} from 'tabler-react';
import PropTypes from 'prop-types';
+import FiddleDeployButton from './FiddleDeployButton';
class FiddleResultsSummary extends Component{
@@ -21,7 +22,12 @@ class FiddleResultsSummary extends Component{
}
else {
if(hasResult && !errors.length){
- renderings.push(Compiled);
+ renderings.push(
+
+ Compiled
+
+
+ );
}
if(errors.length) renderings.push(
diff --git a/embark-ui/src/containers/FiddleContainer.js b/embark-ui/src/containers/FiddleContainer.js
index d43ce130..f57cb054 100644
--- a/embark-ui/src/containers/FiddleContainer.js
+++ b/embark-ui/src/containers/FiddleContainer.js
@@ -27,7 +27,7 @@ class FiddleContainer extends Component {
this.setState({value: newValue});
if (this.compileTimeout) clearTimeout(this.compileTimeout);
this.compileTimeout = setTimeout(() => {
- this.props.fetchFiddle(newValue);
+ this.props.postFiddle(newValue);
}, 1000);
}
@@ -136,14 +136,13 @@ function mapStateToProps(state) {
FiddleContainer.propTypes = {
fiddle: PropTypes.object,
error: PropTypes.string,
- fetchFiddle: PropTypes.func,
+ postFiddle: PropTypes.func,
loading: PropTypes.bool
};
export default connect(
mapStateToProps,
{
- fetchFiddle: fiddleAction.request
- //fetchBlock: blockAction.request
+ postFiddle: fiddleAction.request
},
)(FiddleContainer);
diff --git a/embark-ui/src/sagas/index.js b/embark-ui/src/sagas/index.js
index 668767a1..34d74a23 100644
--- a/embark-ui/src/sagas/index.js
+++ b/embark-ui/src/sagas/index.js
@@ -5,7 +5,7 @@ import {all, call, fork, put, takeEvery, take} from 'redux-saga/effects';
const {account, accounts, block, blocks, transaction, transactions, processes, commands, processLogs,
contracts, contract, contractProfile, messageSend, versions, plugins, messageListen, fiddle,
- ensRecord, ensRecords, contractLogs, contractFile, contractFunction, contractDeploy} = actions;
+ fiddleDeploy, ensRecord, ensRecords, contractLogs, contractFile, contractFunction, contractDeploy} = actions;
function *doRequest(entity, apiFn, payload) {
const {response, error} = yield call(apiFn, payload);
@@ -34,7 +34,8 @@ export const fetchContractProfile = doRequest.bind(null, contractProfile, api.fe
export const fetchContractFile = doRequest.bind(null, contractFile, api.fetchContractFile);
export const postContractFunction = doRequest.bind(null, contractFunction, api.postContractFunction);
export const postContractDeploy = doRequest.bind(null, contractDeploy, api.postContractDeploy);
-export const fetchFiddle = doRequest.bind(null, fiddle, api.fetchFiddle);
+export const postFiddle = doRequest.bind(null, fiddle, api.postFiddle);
+export const postFiddleDeploy = doRequest.bind(null, fiddleDeploy, api.postFiddleDeploy);
export const sendMessage = doRequest.bind(null, messageSend, api.sendMessage);
export const fetchEnsRecord = doRequest.bind(null, ensRecord, api.fetchEnsRecord);
export const postEnsRecord = doRequest.bind(null, ensRecords, api.postEnsRecord);
@@ -127,8 +128,12 @@ export function *watchListenToMessages() {
yield takeEvery(actions.MESSAGE_LISTEN[actions.REQUEST], listenToMessages);
}
-export function *watchFetchFiddle() {
- yield takeEvery(actions.FIDDLE[actions.REQUEST], fetchFiddle);
+export function *watchPostFiddle() {
+ yield takeEvery(actions.FIDDLE[actions.REQUEST], postFiddle);
+}
+
+export function *watchPostFiddleDeploy() {
+ yield takeEvery(actions.FIDDLE_DEPLOY[actions.REQUEST], postFiddleDeploy);
}
function createChannel(socket) {
@@ -216,7 +221,8 @@ export default function *root() {
fork(watchSendMessage),
fork(watchFetchContract),
fork(watchFetchTransaction),
- fork(watchFetchFiddle),
+ fork(watchPostFiddle),
+ fork(watchPostFiddleDeploy),
fork(watchFetchEnsRecord),
fork(watchPostEnsRecords)
]);
diff --git a/lib/contracts/contract.js b/lib/contracts/contract.js
deleted file mode 100644
index df2aa677..00000000
--- a/lib/contracts/contract.js
+++ /dev/null
@@ -1,22 +0,0 @@
-class Contract {
- constructor(className, compiledContract, gas, gasPrice, type = 'file') {
- this.className = className;
- this.gas = gas;
- this.gasPrice = gasPrice;
- this.type = type;
- this.compiledContract = compiledContract;
- }
-
- set compiledContract(compiledContract) {
- this.code = compiledContract.code;
- this.runtimeBytecode = compiledContract.runtimeBytecode;
- this.realRuntimeBytecode = (contract.realRuntimeBytecode || contract.runtimeBytecode);
- this.swarmHash = compiledContract.swarmHash;
- this.gasEstimates = compiledContract.gasEstimates;
- this.functionHashes = compiledContract.functionHashes;
- this.abiDefinition = compiledContract.abiDefinition;
- this.filename = compiledContract.filename;
- this.originalFilename = compiledContract.originalFilename || ("contracts/" + contract.filename);
- }
-
-}
\ No newline at end of file
diff --git a/lib/modules/contracts_manager/index.js b/lib/modules/contracts_manager/index.js
index de2f339d..c7710f42 100644
--- a/lib/modules/contracts_manager/index.js
+++ b/lib/modules/contracts_manager/index.js
@@ -164,9 +164,22 @@ class ContractsManager {
self.events.request('contracts:all', null, res.send.bind(res));
}
);
+
+ plugin.registerAPICall(
+ 'post',
+ '/embark-api/contract/deploy',
+ (req, res) => {
+ self.compiledContracts = req.body.compiledContract;
+ self.build((err, _mgr) => {
+ const responseData = {errors: err, success: !err};
+ this.logger.trace(`POST response /embark-api/contract/deploy:\n ${JSON.stringify(responseData)}`);
+ res.send(responseData);
+ }, false);
+ }
+ );
}
- build(done) {
+ build(done, useContractFiles = true) {
let self = this;
self.contracts = {};