mirror of
https://github.com/status-im/embark-area-51.git
synced 2025-02-02 02:15:58 +00:00
Event function filt
This commit is contained in:
parent
a118fc1017
commit
5fa118ae2e
@ -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}) => (
|
||||
<Page.Content title={contractName + ' Logger'}>
|
||||
<Grid.Row>
|
||||
<Grid.Col>
|
||||
<Table
|
||||
responsive
|
||||
cards
|
||||
verticalAlign="center"
|
||||
className="text-nowrap">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>call</th>
|
||||
<th>Transaction hash</th>
|
||||
<th>Gas Used</th>
|
||||
<th>Block number</th>
|
||||
<th>Status</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{
|
||||
contractLogs.map((log, index) => {
|
||||
return (
|
||||
<tr key={'log-' + index}>
|
||||
<td>{`${log.name}.${log.functionName}(${log.paramString})`}</td>
|
||||
<td>{log.transactionHash}</td>
|
||||
<td>{log.gasUsed}</td>
|
||||
<td>{log.blockNumber}</td>
|
||||
<td>{log.status}</td>
|
||||
</tr>
|
||||
);
|
||||
})
|
||||
}
|
||||
</tbody>
|
||||
</Table>
|
||||
</Grid.Col>
|
||||
</Grid.Row>
|
||||
</Page.Content>
|
||||
);
|
||||
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 (
|
||||
<Page.Content title={this.props.contractName + ' Logger'}>
|
||||
<Form>
|
||||
<Grid.Row>
|
||||
<Grid.Col md={6}>
|
||||
<Form.Group label="Functions">
|
||||
<Form.Select>
|
||||
{this.getMethods().map((method, index) => <option key={index}>{method.name}</option>)}
|
||||
</Form.Select>
|
||||
</Form.Group>
|
||||
</Grid.Col>
|
||||
<Grid.Col md={6}>
|
||||
<Form.Group label="Events">
|
||||
<Form.Select>
|
||||
{this.getEvents().map((event, index) => <option key={index}>{event.name}</option>)}
|
||||
</Form.Select>
|
||||
</Form.Group>
|
||||
</Grid.Col>
|
||||
<Grid.Col>
|
||||
<Form.Group label="Tx Status">
|
||||
<Form.Radio
|
||||
isInline
|
||||
label="Failed"
|
||||
name="example-inline-radios"
|
||||
value="option1"
|
||||
/>
|
||||
<Form.Radio
|
||||
isInline
|
||||
label="Success"
|
||||
name="example-inline-radios"
|
||||
value="option2"
|
||||
/>
|
||||
<Form.Radio
|
||||
isInline
|
||||
label="Any"
|
||||
name="example-inline-radios"
|
||||
value="option3"
|
||||
/>
|
||||
</Form.Group>
|
||||
</Grid.Col>
|
||||
</Grid.Row>
|
||||
</Form>
|
||||
<Grid.Row>
|
||||
<Grid.Col>
|
||||
<Table
|
||||
responsive
|
||||
cards
|
||||
verticalAlign="center"
|
||||
className="text-nowrap">
|
||||
<Table.Header>
|
||||
<Table.Row>
|
||||
<Table.ColHeader>call</Table.ColHeader>
|
||||
<Table.ColHeader>Transaction hash</Table.ColHeader>
|
||||
<Table.ColHeader>Gas Used</Table.ColHeader>
|
||||
<Table.ColHeader>Block number</Table.ColHeader>
|
||||
<Table.ColHeader>Status</Table.ColHeader>
|
||||
</Table.Row>
|
||||
</Table.Header>
|
||||
<Table.Body>
|
||||
{
|
||||
this.props.contractLogs.map((log, index) => {
|
||||
return (
|
||||
<Table.Row key={'log-' + index}>
|
||||
<Table.Col>{`${log.name}.${log.functionName}(${log.paramString})`}</Table.Col>
|
||||
<Table.Col>{log.transactionHash}</Table.Col>
|
||||
<Table.Col>{log.gasUsed}</Table.Col>
|
||||
<Table.Col>{log.blockNumber}</Table.Col>
|
||||
<Table.Col>{log.status}</Table.Col>
|
||||
</Table.Row>
|
||||
);
|
||||
})
|
||||
}
|
||||
</Table.Body>
|
||||
</Table>
|
||||
</Grid.Col>
|
||||
</Grid.Row>
|
||||
</Page.Content>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
ContractLogger.propTypes = {
|
||||
contractName: PropTypes.string.isRequired,
|
||||
contractLogs: PropTypes.array.isRequired
|
||||
contractLogs: PropTypes.array.isRequired.Header,
|
||||
contract: PropTypes.object.isRequired
|
||||
};
|
||||
|
||||
export default ContractLogger;
|
||||
|
@ -31,6 +31,7 @@ function mapStateToProps(state, props) {
|
||||
}
|
||||
|
||||
ContractLoggerContainer.propTypes = {
|
||||
contract: PropTypes.object,
|
||||
contractLogs: PropTypes.array,
|
||||
fetchContractLogs: PropTypes.func,
|
||||
listenToContractLogs: PropTypes.func,
|
||||
|
@ -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};
|
||||
|
@ -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) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user