Adding filter
This commit is contained in:
parent
96c3575e75
commit
2a9262c4b9
|
@ -7,13 +7,12 @@ import {
|
||||||
Form
|
Form
|
||||||
} from "tabler-react";
|
} from "tabler-react";
|
||||||
|
|
||||||
const ANY_STATE = 'Any';
|
const TX_STATES = {Success: '0x1', Fail: '0x0', Any: ''};
|
||||||
const TX_STATES = ['Success', 'Fail', ANY_STATE];
|
|
||||||
|
|
||||||
class ContractLogger extends React.Component {
|
class ContractLogger extends React.Component {
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props);
|
super(props);
|
||||||
this.state = {method: '', event: '', status: ANY_STATE};
|
this.state = {method: '', event: '', status: TX_STATES['Any']};
|
||||||
}
|
}
|
||||||
|
|
||||||
getMethods() {
|
getMethods() {
|
||||||
|
@ -45,9 +44,12 @@ class ContractLogger extends React.Component {
|
||||||
contractLog.events = events;
|
contractLog.events = events;
|
||||||
return contractLog;
|
return contractLog;
|
||||||
}).filter(contractLog => {
|
}).filter(contractLog => {
|
||||||
if (this.state.method || this.state.event || this.state.status !== ANY_STATE) {
|
if (this.state.status && contractLog.status !== this.state.status) {
|
||||||
return contractLog.status === '0x1' && this.state.status === 'Success' &&
|
return false;
|
||||||
(this.state.method === contractLog.functionName || contractLog.events.includes(this.state.event));
|
}
|
||||||
|
|
||||||
|
if (this.state.method || this.state.event) {
|
||||||
|
return this.state.method === contractLog.functionName || contractLog.events.includes(this.state.event);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -77,14 +79,14 @@ class ContractLogger extends React.Component {
|
||||||
</Grid.Col>
|
</Grid.Col>
|
||||||
<Grid.Col>
|
<Grid.Col>
|
||||||
<Form.Group label="Tx Status">
|
<Form.Group label="Tx Status">
|
||||||
{TX_STATES.map(state => (
|
{Object.keys(TX_STATES).map(key => (
|
||||||
<Form.Radio
|
<Form.Radio
|
||||||
key={state}
|
key={key}
|
||||||
isInline
|
isInline
|
||||||
label={state}
|
label={key}
|
||||||
value={state}
|
value={TX_STATES[key]}
|
||||||
onChange={(event) => this.updateState('status', event.target.value)}
|
onChange={(event) => this.updateState('status', event.target.value)}
|
||||||
checked={state === this.state.status}
|
checked={TX_STATES[key] === this.state.status}
|
||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
</Form.Group>
|
</Form.Group>
|
||||||
|
@ -114,7 +116,7 @@ class ContractLogger extends React.Component {
|
||||||
return (
|
return (
|
||||||
<Table.Row key={'log-' + index}>
|
<Table.Row key={'log-' + index}>
|
||||||
<Table.Col>{`${log.name}.${log.functionName}(${log.paramString})`}</Table.Col>
|
<Table.Col>{`${log.name}.${log.functionName}(${log.paramString})`}</Table.Col>
|
||||||
<Table.Col>{log.events.join(' ')}</Table.Col>
|
<Table.Col>{log.events.join(', ')}</Table.Col>
|
||||||
<Table.Col>{log.gasUsed}</Table.Col>
|
<Table.Col>{log.gasUsed}</Table.Col>
|
||||||
<Table.Col>{log.blockNumber}</Table.Col>
|
<Table.Col>{log.blockNumber}</Table.Col>
|
||||||
<Table.Col>{log.status}</Table.Col>
|
<Table.Col>{log.status}</Table.Col>
|
||||||
|
|
Loading…
Reference in New Issue