diff --git a/embark-ui/src/components/ContractsDeployment.js b/embark-ui/src/components/ContractsDeployment.js new file mode 100644 index 000000000..71f4d0788 --- /dev/null +++ b/embark-ui/src/components/ContractsDeployment.js @@ -0,0 +1,64 @@ +import PropTypes from "prop-types"; +import React from 'react'; +import { + Row, + Col +} from 'reactstrap'; +import classNames from 'classnames'; + +const orderClassName = (address) => { + return classNames({ + badge: true, + 'badge-success': address, + 'badge-secondary': !address + }); +} + +const Contract = ({contract}) => ( + + +

{contract.index + 1}

+ + + {contract.address && + +
{contract.className} deployed at {contract.address}
+

Arguments: {contract.args}

+
+ } + {!contract.address && +
{contract.className} not deployed
+ } + {contract.transactionHash && + +

Transaction Hash: {contract.transactionHash}

+

{contract.gas} gas at {contract.gasPrice} Wei, estimated cost: {contract.gas * contract.gasPrice} Wei

+
+ } + {contract.address && !contract.transactionHash && +

Contract already deployed

+ } + +
+); + +const Contracts = ({contracts}) => ( + + + + Order + + + Contract + + + {contracts.sort((a, b) => a.index - b.index).map(contract => )} + +); + +Contracts.propTypes = { + contracts: PropTypes.array, +}; + +export default Contracts; + diff --git a/embark-ui/src/components/Layout.js b/embark-ui/src/components/Layout.js index 9c33977a3..50038bc3e 100644 --- a/embark-ui/src/components/Layout.js +++ b/embark-ui/src/components/Layout.js @@ -21,6 +21,7 @@ import logo from '../images/logo.png'; const sidebarNavItems = {items: [ {name: "Dashboard", url: "/embark", icon: 'fa fa-tachometer'}, + {name: "Deployment", url: "/embark/deployment", icon: "fa fa-arrow-up"}, {name: "Contracts", url: "/embark/contracts", icon: "fa fa-file-text"}, {name: "Explorer", url: "/embark/explorer/accounts", icon: "fa fa-signal", children: [ {url: "/embark/explorer/accounts", icon: "fa fa-users", name: "Accounts"}, diff --git a/embark-ui/src/containers/DeploymentContainer.js b/embark-ui/src/containers/DeploymentContainer.js new file mode 100644 index 000000000..6ed8e210c --- /dev/null +++ b/embark-ui/src/containers/DeploymentContainer.js @@ -0,0 +1,40 @@ +import React, {Component} from 'react'; +import {connect} from 'react-redux'; +import PropTypes from 'prop-types'; +import {contracts as contractsAction} from "../actions"; + +import ContractsDeployment from '../components/ContractsDeployment'; +import DataWrapper from "../components/DataWrapper"; +import {getContracts} from "../reducers/selectors"; + +class DeploymentContainer extends Component { + componentDidMount() { + this.props.fetchContracts(); + } + + render() { + return ( + 0} {...this.props} render={({contracts}) => ( + + )} /> + ); + } +} + +function mapStateToProps(state) { + return { + contracts: getContracts(state), + error: state.errorMessage, + loading: state.loading}; +} + +DeploymentContainer.propTypes = { + contracts: PropTypes.array, + fetchContracts: PropTypes.func +}; + +export default connect( + mapStateToProps,{ + fetchContracts: contractsAction.request + } +)(DeploymentContainer); diff --git a/embark-ui/src/routes.js b/embark-ui/src/routes.js index a2b60ba77..1b5cd3bd1 100644 --- a/embark-ui/src/routes.js +++ b/embark-ui/src/routes.js @@ -3,7 +3,8 @@ import {Route, Switch} from 'react-router-dom'; import HomeContainer from './containers/HomeContainer'; import ContractsContainer from './containers/ContractsContainer'; -import ContractContainer from './containers/ContractLayoutContainer'; +import ContractLayoutContainer from './containers/ContractLayoutContainer'; +import DeploymentContainer from './containers/DeploymentContainer'; import NoMatch from './components/NoMatch'; import ExplorerLayout from './components/ExplorerLayout'; import FiddleLayout from './components/FiddleLayout'; @@ -14,7 +15,8 @@ const routes = ( - + + diff --git a/lib/modules/contracts_manager/index.js b/lib/modules/contracts_manager/index.js index f08a25212..ea8a2682a 100644 --- a/lib/modules/contracts_manager/index.js +++ b/lib/modules/contracts_manager/index.js @@ -65,23 +65,21 @@ class ContractsManager { }); self.events.setCommandHandler("contracts:all", (contractName, cb) => { - let contracts = self.listContracts(); - let results = []; - let i = 0; - for (let className in contracts) { - let contract = contracts[className]; - - results.push({ - index: i, + const contracts = self.listContracts().map((contract, index) => ( + { className: contract.className, deploy: contract.deploy, error: contract.error, address: contract.deployedAddress, - isFiddle: Boolean(contract.isFiddle) - }); - i += 1; - } - cb(results); + isFiddle: Boolean(contract.isFiddle), + args: contract.args, + transactionHash: contract.transactionHash, + gas: contract.gas, + gasPrice: contract.gasPrice, + index + } + )); + cb(contracts); }); embark.registerAPICall(