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'}>
|
||||
{contractProfile.methods
|
||||
.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}
|
||||
method={method}
|
||||
|
|
|
@ -1,29 +1,38 @@
|
|||
import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { NavLink } from 'react-router-dom';
|
||||
import {Card, Icon, Button} from 'tabler-react';
|
||||
import {Card, Icon} from 'tabler-react';
|
||||
import ContractFunctions from '../components/ContractFunctions';
|
||||
|
||||
const TextEditorContractDeploy = (props) => (
|
||||
<Card statusColor="success"
|
||||
statusSide
|
||||
className="success-card">
|
||||
<Card.Header>
|
||||
<Card.Title color="success">
|
||||
<Icon name="check" className="mr-1" />
|
||||
Deploy Contract
|
||||
</Card.Title>
|
||||
</Card.Header>
|
||||
<Card.Body>
|
||||
<Button to={`/embark/contracts/${Object.keys(props.result)[0]}/deployment`}
|
||||
RootComponent={NavLink}>
|
||||
Deploy my contract(s)
|
||||
</Button>
|
||||
</Card.Body>
|
||||
</Card>
|
||||
);
|
||||
const TextEditorContractDeploy = (props) => {
|
||||
const name = Object.keys(props.result)[0];
|
||||
const profile = {
|
||||
name,
|
||||
methods: props.result[name].abiDefinition
|
||||
};
|
||||
return (
|
||||
<Card statusColor="success"
|
||||
statusSide
|
||||
className="success-card">
|
||||
<Card.Header>
|
||||
<Card.Title color="success">
|
||||
<Icon name="check" className="mr-1" />
|
||||
Deploy Contract
|
||||
</Card.Title>
|
||||
</Card.Header>
|
||||
<Card.Body>
|
||||
<ContractFunctions contractProfile={profile}
|
||||
contractFunctions={props.contractDeploys}
|
||||
onlyConstructor
|
||||
postContractFunction={props.postContractDeploy}/>
|
||||
</Card.Body>
|
||||
</Card>
|
||||
);
|
||||
};
|
||||
|
||||
TextEditorContractDeploy.propTypes = {
|
||||
result: PropTypes.object
|
||||
result: PropTypes.object,
|
||||
postContractDeploy: PropTypes.func,
|
||||
contractDeploys: PropTypes.array
|
||||
};
|
||||
|
||||
export default TextEditorContractDeploy;
|
||||
|
|
|
@ -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(<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>;
|
||||
}
|
||||
|
@ -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);
|
||||
|
|
|
@ -33,6 +33,7 @@ class Profiler {
|
|||
|
||||
profileObj.methods.push({
|
||||
name: methodName,
|
||||
type: abiMethod.type,
|
||||
payable: abiMethod.payable,
|
||||
mutability: abiMethod.stateMutability,
|
||||
inputs: abiMethod.inputs || [],
|
||||
|
|
Loading…
Reference in New Issue