mirror of https://github.com/embarklabs/embark.git
Deploy contract
This commit is contained in:
parent
a08690ef43
commit
592ce4773c
|
@ -109,7 +109,7 @@ const ContractFunctions = (props) => {
|
||||||
<Page.Content title={contractProfile.name + ' Functions'}>
|
<Page.Content title={contractProfile.name + ' Functions'}>
|
||||||
{contractProfile.methods
|
{contractProfile.methods
|
||||||
.filter((method) => {
|
.filter((method) => {
|
||||||
return props.onlyConstructor ? method.name === 'constructor' : method.name !== 'constructor';
|
return props.onlyConstructor ? method.type === 'constructor' : method.type !== 'constructor';
|
||||||
})
|
})
|
||||||
.map(method => <ContractFunction key={method.name}
|
.map(method => <ContractFunction key={method.name}
|
||||||
method={method}
|
method={method}
|
||||||
|
|
|
@ -1,29 +1,38 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import { NavLink } from 'react-router-dom';
|
import {Card, Icon} from 'tabler-react';
|
||||||
import {Card, Icon, Button} from 'tabler-react';
|
import ContractFunctions from '../components/ContractFunctions';
|
||||||
|
|
||||||
const TextEditorContractDeploy = (props) => (
|
const TextEditorContractDeploy = (props) => {
|
||||||
<Card statusColor="success"
|
const name = Object.keys(props.result)[0];
|
||||||
statusSide
|
const profile = {
|
||||||
className="success-card">
|
name,
|
||||||
<Card.Header>
|
methods: props.result[name].abiDefinition
|
||||||
<Card.Title color="success">
|
};
|
||||||
<Icon name="check" className="mr-1" />
|
return (
|
||||||
Deploy Contract
|
<Card statusColor="success"
|
||||||
</Card.Title>
|
statusSide
|
||||||
</Card.Header>
|
className="success-card">
|
||||||
<Card.Body>
|
<Card.Header>
|
||||||
<Button to={`/embark/contracts/${Object.keys(props.result)[0]}/deployment`}
|
<Card.Title color="success">
|
||||||
RootComponent={NavLink}>
|
<Icon name="check" className="mr-1" />
|
||||||
Deploy my contract(s)
|
Deploy Contract
|
||||||
</Button>
|
</Card.Title>
|
||||||
</Card.Body>
|
</Card.Header>
|
||||||
</Card>
|
<Card.Body>
|
||||||
);
|
<ContractFunctions contractProfile={profile}
|
||||||
|
contractFunctions={props.contractDeploys}
|
||||||
|
onlyConstructor
|
||||||
|
postContractFunction={props.postContractDeploy}/>
|
||||||
|
</Card.Body>
|
||||||
|
</Card>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
TextEditorContractDeploy.propTypes = {
|
TextEditorContractDeploy.propTypes = {
|
||||||
result: PropTypes.object
|
result: PropTypes.object,
|
||||||
|
postContractDeploy: PropTypes.func,
|
||||||
|
contractDeploys: PropTypes.array
|
||||||
};
|
};
|
||||||
|
|
||||||
export default TextEditorContractDeploy;
|
export default TextEditorContractDeploy;
|
||||||
|
|
|
@ -16,9 +16,9 @@ import {
|
||||||
saveFile as saveFileAction,
|
saveFile as saveFileAction,
|
||||||
removeFile as removeFileAction,
|
removeFile as removeFileAction,
|
||||||
contractCompile as contractCompileAction,
|
contractCompile as contractCompileAction,
|
||||||
contractDeploy as contractDeployAction
|
contractDeploy as postContractDeploy
|
||||||
} from '../actions';
|
} from '../actions';
|
||||||
import {getCurrentFile, getContractCompile} from '../reducers/selectors';
|
import {getCurrentFile, getContractCompile, getContractDeploys} from '../reducers/selectors';
|
||||||
|
|
||||||
const DEFAULT_FILE = {name: 'newContract.sol', content: ''};
|
const DEFAULT_FILE = {name: 'newContract.sol', content: ''};
|
||||||
|
|
||||||
|
@ -79,7 +79,10 @@ class TextEditorContainer extends Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (result) {
|
if (result) {
|
||||||
components.push(<TextEditorContractDeploy key={3} result={result}/>);
|
components.push(<TextEditorContractDeploy key={3}
|
||||||
|
result={result}
|
||||||
|
postContractDeploy={this.props.postContractDeploy}
|
||||||
|
contractDeploys={this.props.contractDeploys}/>);
|
||||||
}
|
}
|
||||||
return <React.Fragment>{components}</React.Fragment>;
|
return <React.Fragment>{components}</React.Fragment>;
|
||||||
}
|
}
|
||||||
|
@ -116,10 +119,13 @@ class TextEditorContainer extends Component {
|
||||||
function mapStateToProps(state) {
|
function mapStateToProps(state) {
|
||||||
const currentFile = getCurrentFile(state) || DEFAULT_FILE;
|
const currentFile = getCurrentFile(state) || DEFAULT_FILE;
|
||||||
const contractCompile = getContractCompile(state, currentFile) || {};
|
const contractCompile = getContractCompile(state, currentFile) || {};
|
||||||
|
const contractName = contractCompile.result && Object.keys(contractCompile.result)[0];
|
||||||
|
const contractDeploys = getContractDeploys(state, contractName);
|
||||||
return {
|
return {
|
||||||
currentFile,
|
currentFile,
|
||||||
contractCompile,
|
contractCompile,
|
||||||
compilingContract: state.compilingContract,
|
compilingContract: state.compilingContract,
|
||||||
|
contractDeploys,
|
||||||
loading: state.loading,
|
loading: state.loading,
|
||||||
error: state.errorMessage
|
error: state.errorMessage
|
||||||
};
|
};
|
||||||
|
@ -132,9 +138,10 @@ TextEditorContainer.propTypes = {
|
||||||
fetchCurrentFile: PropTypes.func,
|
fetchCurrentFile: PropTypes.func,
|
||||||
saveFile: PropTypes.func,
|
saveFile: PropTypes.func,
|
||||||
removeFile: PropTypes.func,
|
removeFile: PropTypes.func,
|
||||||
deployContract: PropTypes.func,
|
postContractDeploy: PropTypes.func,
|
||||||
compileContract: PropTypes.func,
|
compileContract: PropTypes.func,
|
||||||
compilingContract: PropTypes.bool,
|
compilingContract: PropTypes.bool,
|
||||||
|
contractDeploys: PropTypes.array,
|
||||||
loading: PropTypes.bool,
|
loading: PropTypes.bool,
|
||||||
error: PropTypes.string
|
error: PropTypes.string
|
||||||
};
|
};
|
||||||
|
@ -146,7 +153,7 @@ export default connect(
|
||||||
saveCurrentFile: saveCurrentFileAction.request,
|
saveCurrentFile: saveCurrentFileAction.request,
|
||||||
saveFile: saveFileAction.request,
|
saveFile: saveFileAction.request,
|
||||||
removeFile: removeFileAction.request,
|
removeFile: removeFileAction.request,
|
||||||
deployContract: contractDeployAction.post,
|
postContractDeploy: postContractDeploy.post,
|
||||||
compileContract: contractCompileAction.post
|
compileContract: contractCompileAction.post
|
||||||
},
|
},
|
||||||
)(TextEditorContainer);
|
)(TextEditorContainer);
|
||||||
|
|
|
@ -33,6 +33,7 @@ class Profiler {
|
||||||
|
|
||||||
profileObj.methods.push({
|
profileObj.methods.push({
|
||||||
name: methodName,
|
name: methodName,
|
||||||
|
type: abiMethod.type,
|
||||||
payable: abiMethod.payable,
|
payable: abiMethod.payable,
|
||||||
mutability: abiMethod.stateMutability,
|
mutability: abiMethod.stateMutability,
|
||||||
inputs: abiMethod.inputs || [],
|
inputs: abiMethod.inputs || [],
|
||||||
|
|
Loading…
Reference in New Issue