diff --git a/embark-ui/src/components/ContractLogger.js b/embark-ui/src/components/ContractLogger.js index c1b91c62..fb0677bb 100644 --- a/embark-ui/src/components/ContractLogger.js +++ b/embark-ui/src/components/ContractLogger.js @@ -2,51 +2,116 @@ import PropTypes from "prop-types"; import React from 'react'; import { Page, - Grid, Table + Grid, + Table, + Form } from "tabler-react"; -const ContractLogger = ({contractName, contractLogs}) => ( - - - - - - - call - Transaction hash - Gas Used - Block number - Status - - - - { - contractLogs.map((log, index) => { - return ( - - {`${log.name}.${log.functionName}(${log.paramString})`} - {log.transactionHash} - {log.gasUsed} - {log.blockNumber} - {log.status} - - ); - }) - } - - - - - -); +class ContractLogger extends React.Component { + + getMethods() { + if (!this.props.contract.abiDefinition) { + return []; + } + + return this.props.contract.abiDefinition.filter(method => ( + method.name !== 'constructor' && method.mutability !== 'view' && method.mutability !== 'pure' && method.constant !== true && method.type === 'function' + )); + } + + getEvents() { + if (!this.props.contract.abiDefinition) { + return []; + } + return this.props.contract.abiDefinition.filter(method => method.type === 'event'); + } + + render() { + return ( + + + + + + + {this.getMethods().map((method, index) => {method.name})} + + + + + + + {this.getEvents().map((event, index) => {event.name})} + + + + + + + + + + + + + + + + + + call + Transaction hash + Gas Used + Block number + Status + + + + { + this.props.contractLogs.map((log, index) => { + return ( + + {`${log.name}.${log.functionName}(${log.paramString})`} + {log.transactionHash} + {log.gasUsed} + {log.blockNumber} + {log.status} + + ); + }) + } + + + + + + ); + } +} ContractLogger.propTypes = { contractName: PropTypes.string.isRequired, - contractLogs: PropTypes.array.isRequired + contractLogs: PropTypes.array.isRequired.Header, + contract: PropTypes.object.isRequired }; export default ContractLogger; diff --git a/embark-ui/src/containers/ContractLoggerContainer.js b/embark-ui/src/containers/ContractLoggerContainer.js index 7f444eda..d6266644 100644 --- a/embark-ui/src/containers/ContractLoggerContainer.js +++ b/embark-ui/src/containers/ContractLoggerContainer.js @@ -31,6 +31,7 @@ function mapStateToProps(state, props) { } ContractLoggerContainer.propTypes = { + contract: PropTypes.object, contractLogs: PropTypes.array, fetchContractLogs: PropTypes.func, listenToContractLogs: PropTypes.func, diff --git a/lib/modules/blockchain_process/proxy.js b/lib/modules/blockchain_process/proxy.js index afdfbc1e..33ffbcc6 100644 --- a/lib/modules/blockchain_process/proxy.js +++ b/lib/modules/blockchain_process/proxy.js @@ -16,6 +16,7 @@ const parseRequest = function (reqBody) { } catch (e) { return; // Request is not a json. Do nothing } + console.error("Request ", jsonO) if (jsonO.method === "eth_sendTransaction") { commList[jsonO.id] = { type: 'contract-log', @@ -37,6 +38,7 @@ const parseResponse = function (ipc, resBody) { } catch (e) { return; // Response is not a json. Do nothing } + console.error("Response", jsonO) if (commList[jsonO.id]) { commList[jsonO.id].transactionHash = jsonO.result; transactions[jsonO.result] = {commListId: jsonO.id}; diff --git a/templates/demo/contracts/simple_storage.sol b/templates/demo/contracts/simple_storage.sol index d2ab0073..7810f582 100644 --- a/templates/demo/contracts/simple_storage.sol +++ b/templates/demo/contracts/simple_storage.sol @@ -1,6 +1,7 @@ pragma solidity ^0.4.25; contract SimpleStorage { + event SetCalled(uint x); uint public storedData; constructor(uint initialValue) public { @@ -9,6 +10,7 @@ contract SimpleStorage { function set(uint x) public { storedData = x; + emit SetCalled(x); } function get() public view returns (uint retVal) {