-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9 from smartcontractkit/170048196-170048219-add-g…
…as-price Add gas price information
- Loading branch information
Showing
15 changed files
with
240 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
95 changes: 95 additions & 0 deletions
95
feeds-ui/src/components/oracleTable/OracleTable.component.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
import React, { useEffect, useState } from 'react' | ||
import { humanizeUnixTimestamp } from 'utils' | ||
import _ from 'lodash' | ||
import { Table, Icon } from 'antd' | ||
|
||
const OracleTable = ({ | ||
networkGraphState, | ||
networkGraphNodes, | ||
fetchEthGasPrice, | ||
ethGasPrice, | ||
}) => { | ||
const [data, setData] = useState() | ||
const [gasPrice, setGasPrice] = useState() | ||
|
||
useEffect(() => { | ||
fetchEthGasPrice() | ||
}, [fetchEthGasPrice]) | ||
|
||
useEffect(() => { | ||
if (ethGasPrice) { | ||
setGasPrice(ethGasPrice.fast / 10) | ||
} | ||
}, [ethGasPrice]) | ||
|
||
useEffect(() => { | ||
const mergedData = networkGraphNodes | ||
.filter(node => node.type === 'oracle') | ||
.map(oracle => { | ||
const state = _.find(networkGraphState, { sender: oracle.address }) | ||
return { | ||
oracle: oracle, | ||
state, | ||
key: oracle.id, | ||
} | ||
}) | ||
setData(mergedData) | ||
}, [networkGraphState, networkGraphNodes]) | ||
|
||
const columns = [ | ||
{ | ||
title: 'Oracle', | ||
dataIndex: 'oracle.name', | ||
key: 'name', | ||
sorter: (a, b) => | ||
a.oracle.name.localeCompare(b && b.oracle && b.oracle.name), | ||
}, | ||
{ | ||
title: 'Answer', | ||
dataIndex: 'state.responseFormatted', | ||
key: 'answer', | ||
sorter: (a, b) => { | ||
if (!a.state || !b.state) return | ||
|
||
return a.state.responseFormatted - b.state.responseFormatted | ||
}, | ||
}, | ||
{ | ||
title: 'Gas Price (Gwei)', | ||
dataIndex: 'state.meta.gasPrice', | ||
key: 'gas', | ||
sorter: (a, b) => { | ||
if (!a.state || !b.state) return | ||
return a.state.meta.gasPrice - b.state.meta.gasPrice | ||
}, | ||
defaultSortOrder: 'descend', | ||
}, | ||
{ | ||
title: 'Date', | ||
dataIndex: 'state.meta.timestamp', | ||
key: 'timestamp', | ||
render: timestamp => humanizeUnixTimestamp(timestamp), | ||
}, | ||
] | ||
|
||
return ( | ||
<div className="oracle-table"> | ||
<h2 className="oracle-table-header">Oracles data</h2> | ||
<div className="gas-price-info"> | ||
<h4> | ||
<Icon type="check-circle" /> Recommended gas price:{' '} | ||
<b>{gasPrice} Gwei</b> | ||
</h4> | ||
</div> | ||
<Table | ||
dataSource={data} | ||
columns={columns} | ||
pagination={false} | ||
size={'middle'} | ||
locale={{ emptyText: <Icon type="loading" /> }} | ||
/> | ||
</div> | ||
) | ||
} | ||
|
||
export default OracleTable |
19 changes: 19 additions & 0 deletions
19
feeds-ui/src/components/oracleTable/OracleTable.enhanced.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import OracleTable from './OracleTable.component' | ||
import { connect } from 'react-redux' | ||
|
||
import { | ||
aggregationSelectors, | ||
aggregationOperations, | ||
} from 'state/ducks/aggregation' | ||
|
||
const mapStateToProps = state => ({ | ||
networkGraphNodes: aggregationSelectors.networkGraphNodes(state), | ||
networkGraphState: aggregationSelectors.networkGraphState(state), | ||
ethGasPrice: state.aggregation.ethGasPrice, | ||
}) | ||
|
||
const mapDispatchToProps = { | ||
fetchEthGasPrice: aggregationOperations.fetchEthGasPrice, | ||
} | ||
|
||
export default connect(mapStateToProps, mapDispatchToProps)(OracleTable) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default as OracleTable } from './OracleTable.enhanced' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.