From 592ce4773c325849af6523f65b48e3b60aefcaa8 Mon Sep 17 00:00:00 2001 From: Anthony Laibe Date: Tue, 4 Sep 2018 15:47:15 +0100 Subject: [PATCH] Deploy contract --- embark-ui/src/components/ContractFunctions.js | 2 +- .../components/TextEditorContractDeploy.js | 51 +++++++++++-------- .../src/containers/TextEditorContainer.js | 17 +++++-- lib/modules/profiler/index.js | 1 + 4 files changed, 44 insertions(+), 27 deletions(-) diff --git a/embark-ui/src/components/ContractFunctions.js b/embark-ui/src/components/ContractFunctions.js index 5c3a9c26c..9444df971 100644 --- a/embark-ui/src/components/ContractFunctions.js +++ b/embark-ui/src/components/ContractFunctions.js @@ -109,7 +109,7 @@ const ContractFunctions = (props) => { {contractProfile.methods .filter((method) => { - return props.onlyConstructor ? method.name === 'constructor' : method.name !== 'constructor'; + return props.onlyConstructor ? method.type === 'constructor' : method.type !== 'constructor'; }) .map(method => ( - - - - - Deploy Contract - - - - - - -); +const TextEditorContractDeploy = (props) => { + const name = Object.keys(props.result)[0]; + const profile = { + name, + methods: props.result[name].abiDefinition + }; + return ( + + + + + Deploy Contract + + + + + + + ); +}; TextEditorContractDeploy.propTypes = { - result: PropTypes.object + result: PropTypes.object, + postContractDeploy: PropTypes.func, + contractDeploys: PropTypes.array }; export default TextEditorContractDeploy; diff --git a/embark-ui/src/containers/TextEditorContainer.js b/embark-ui/src/containers/TextEditorContainer.js index 8c040a779..f2af1e1fa 100644 --- a/embark-ui/src/containers/TextEditorContainer.js +++ b/embark-ui/src/containers/TextEditorContainer.js @@ -16,9 +16,9 @@ import { saveFile as saveFileAction, removeFile as removeFileAction, contractCompile as contractCompileAction, - contractDeploy as contractDeployAction + contractDeploy as postContractDeploy } from '../actions'; -import {getCurrentFile, getContractCompile} from '../reducers/selectors'; +import {getCurrentFile, getContractCompile, getContractDeploys} from '../reducers/selectors'; const DEFAULT_FILE = {name: 'newContract.sol', content: ''}; @@ -79,7 +79,10 @@ class TextEditorContainer extends Component { } if (result) { - components.push(); + components.push(); } return {components}; } @@ -116,10 +119,13 @@ class TextEditorContainer extends Component { function mapStateToProps(state) { const currentFile = getCurrentFile(state) || DEFAULT_FILE; const contractCompile = getContractCompile(state, currentFile) || {}; + const contractName = contractCompile.result && Object.keys(contractCompile.result)[0]; + const contractDeploys = getContractDeploys(state, contractName); return { currentFile, contractCompile, compilingContract: state.compilingContract, + contractDeploys, loading: state.loading, error: state.errorMessage }; @@ -132,9 +138,10 @@ TextEditorContainer.propTypes = { fetchCurrentFile: PropTypes.func, saveFile: PropTypes.func, removeFile: PropTypes.func, - deployContract: PropTypes.func, + postContractDeploy: PropTypes.func, compileContract: PropTypes.func, compilingContract: PropTypes.bool, + contractDeploys: PropTypes.array, loading: PropTypes.bool, error: PropTypes.string }; @@ -146,7 +153,7 @@ export default connect( saveCurrentFile: saveCurrentFileAction.request, saveFile: saveFileAction.request, removeFile: removeFileAction.request, - deployContract: contractDeployAction.post, + postContractDeploy: postContractDeploy.post, compileContract: contractCompileAction.post }, )(TextEditorContainer); diff --git a/lib/modules/profiler/index.js b/lib/modules/profiler/index.js index ba622b650..7f1a64375 100644 --- a/lib/modules/profiler/index.js +++ b/lib/modules/profiler/index.js @@ -33,6 +33,7 @@ class Profiler { profileObj.methods.push({ name: methodName, + type: abiMethod.type, payable: abiMethod.payable, mutability: abiMethod.stateMutability, inputs: abiMethod.inputs || [],