diff --git a/shyftBlockExplorerUI/src/components/table/accounts/accountRows.js b/shyftBlockExplorerUI/src/components/table/accounts/accountRows.js index fdd78a2766..da0b7aa3c9 100644 --- a/shyftBlockExplorerUI/src/components/table/accounts/accountRows.js +++ b/shyftBlockExplorerUI/src/components/table/accounts/accountRows.js @@ -26,9 +26,9 @@ class AccountTable extends Component { const sorted = [...this.state.data]; sorted.sort((a, b) => a.Balance > b.Balance); const table = sorted.reverse().map((data, i) => { - const conversion = data.Balance / 1000000000000000000; + const conversion = data.Balance / 10000000000000000000; const total = sorted - .map(num => num.Balance / 1000000000000000000) + .map(num => num.Balance / 10000000000000000000) .reduce((acc, cur) => acc + cur ,0); const percentage = ( (conversion / total) *100); return { + const conversion = data.Rewards / 10000000000000000000; return }); diff --git a/shyftBlockExplorerUI/src/components/table/blocks/blockTable.js b/shyftBlockExplorerUI/src/components/table/blocks/blockTable.js index 81aabfeaad..52ccdebd28 100644 --- a/shyftBlockExplorerUI/src/components/table/blocks/blockTable.js +++ b/shyftBlockExplorerUI/src/components/table/blocks/blockTable.js @@ -17,7 +17,7 @@ const BlockTable = (props) => { {props.GasUsed} {props.GasLimit} TBD - TBD + {props.Reward} ) diff --git a/shyftBlockExplorerUI/src/components/table/blocks/blocksDetailsRow.js b/shyftBlockExplorerUI/src/components/table/blocks/blocksDetailsRow.js index dc881a5b9c..12d06bc0b6 100644 --- a/shyftBlockExplorerUI/src/components/table/blocks/blocksDetailsRow.js +++ b/shyftBlockExplorerUI/src/components/table/blocks/blocksDetailsRow.js @@ -1,10 +1,11 @@ import React, { Component } from 'react'; import classes from './table.css'; +import { Link } from 'react-router-dom' class DetailBlockTable extends Component { render() { - let data = this.props.data + let data = this.props.data; let combinedClasses = ['responsive-table', classes.table]; return ( @@ -19,7 +20,7 @@ class DetailBlockTable extends Component { - + @@ -67,7 +68,7 @@ class DetailBlockTable extends Component { - +
Txn:{data.TxCount} transactions this.props.getBlockTransactions(data.Number)}>{data.TxCount} transactions
Block Hash:
Reward:TBD{data.Rewards}
diff --git a/shyftBlockExplorerUI/src/components/table/transactions/blockTx.js b/shyftBlockExplorerUI/src/components/table/transactions/blockTx.js new file mode 100644 index 0000000000..afdfd709b7 --- /dev/null +++ b/shyftBlockExplorerUI/src/components/table/transactions/blockTx.js @@ -0,0 +1,51 @@ +import React, { Component } from 'react'; +import TransactionsTable from './transactionTable'; +import classes from './table.css'; + +class BlockTransactionTable extends Component { + constructor(props) { + super(props); + this.state = { + data: [] + }; + } + + render() { + const table = this.props.data.map((data, i) => { + const conversion = data.Cost / 10000000000000000000; + return + }) + + let combinedClasses = ['responsive-table', classes.table]; + return ( + + + + + + + + + + + + + + {table} +
TxHashBlockAgeFromToValueTxFee
+ ); + } +} +export default BlockTransactionTable; diff --git a/shyftBlockExplorerUI/src/components/table/transactions/transactionDetailsRow.js b/shyftBlockExplorerUI/src/components/table/transactions/transactionDetailsRow.js index 889bb3e33f..e130feb577 100644 --- a/shyftBlockExplorerUI/src/components/table/transactions/transactionDetailsRow.js +++ b/shyftBlockExplorerUI/src/components/table/transactions/transactionDetailsRow.js @@ -6,6 +6,7 @@ class DetailTransactionTable extends Component { render() { let data = this.props.data let combinedClasses = ['responsive-table', classes.table]; + const conversion = data.Cost / 10000000000000000000; return ( @@ -51,7 +52,7 @@ class DetailTransactionTable extends Component { - + diff --git a/shyftBlockExplorerUI/src/components/table/transactions/transactionRow.js b/shyftBlockExplorerUI/src/components/table/transactions/transactionRow.js index 0806cf78c9..af3f4f0b94 100644 --- a/shyftBlockExplorerUI/src/components/table/transactions/transactionRow.js +++ b/shyftBlockExplorerUI/src/components/table/transactions/transactionRow.js @@ -25,6 +25,7 @@ class TransactionTable extends Component { render() { const table = this.state.data.map((data, i) => { + const conversion = data.Cost / 10000000000000000000; return diff --git a/shyftBlockExplorerUI/src/components/table/transactions/transactionTable.js b/shyftBlockExplorerUI/src/components/table/transactions/transactionTable.js index ae32a137e9..71ea807e01 100644 --- a/shyftBlockExplorerUI/src/components/table/transactions/transactionTable.js +++ b/shyftBlockExplorerUI/src/components/table/transactions/transactionTable.js @@ -18,7 +18,7 @@ const TransactionTable = (props) => { props.detailTransactionHandler(props.txHash)}> {props.txHash} - + diff --git a/shyftBlockExplorerUI/src/containers/App.js b/shyftBlockExplorerUI/src/containers/App.js index 3301e296c0..a4fb1a571f 100644 --- a/shyftBlockExplorerUI/src/containers/App.js +++ b/shyftBlockExplorerUI/src/containers/App.js @@ -11,6 +11,8 @@ import TransactionRow from '../components/table/transactions/transactionRow'; import TransactionHeader from "../components/nav/transactionHeader/transactionHeader"; import TransactionDetailHeader from "../components/nav/transactionHeader/transactionDetailHeader"; import DetailTransactionTable from "../components/table/transactions/transactionDetailsRow"; +import BlockTxs from "../components/table/transactions/blockTx"; + ///**BLOCKS**/// import BlocksRow from '../components/table/blocks/blockRows'; import DetailBlockTable from '../components/table/blocks/blocksDetailsRow'; @@ -31,6 +33,7 @@ class App extends Component { blockDetailData: [], transactionDetailData: [], accountDetailData: [], + blockTransactions: [], reqAccount: '' }; } @@ -65,6 +68,16 @@ class App extends Component { } }; + getBlockTransactions = async(blockNumber) => { + try { + const response = await axios.get(`http://localhost:8080/api/get_all_transactions_from_block/${blockNumber}`) + await this.setState({ blockTransactions: response.data }) + } + catch(error) { + console.log(error) + } + }; + render() { return ( @@ -79,6 +92,7 @@ class App extends Component {
} @@ -87,7 +101,9 @@ class App extends Component {
- +
} /> @@ -112,10 +128,24 @@ class App extends Component { } /> + +
+ {/**/} + + +
} + /> +
0 { for _, tx := range block.Transactions() { - //WriteMinerRewards(sqldb, block) WriteTransactions(sqldb, tx, block.Header().Hash(), block.Header().Number.String(), receipts, age, gasLimit) if block.Transactions()[0].To() != nil { WriteFromBalance(sqldb, tx) @@ -411,7 +406,7 @@ func WriteBalanceHelper(sqldb *sql.DB, tx *types.Transaction) (SendAndReceive, s // uncle blocks, account balance updates based on reorgs, diverges that get dropped. // Reason for this is because the accounts are not deterministic like the block and tx hashes. // @TODO: Calculate reorg -func WriteMinerRewards(sqldb *sql.DB, block *types.Block) { +func WriteMinerRewards(sqldb *sql.DB, block *types.Block) string { minerAddr := block.Coinbase().String() shyftConduitAddress := Rewards.ShyftNetworkConduitAddress.String() // Calculate the total gas used in the block @@ -443,9 +438,18 @@ func WriteMinerRewards(sqldb *sql.DB, block *types.Block) { StoreReward(sqldb, minerAddr, totalMinerReward) StoreReward(sqldb, shyftConduitAddress, Rewards.ShyftNetworkBlockReward) + var uncRewards = new(big.Int) for i := 0; i < len(uncleAddrs); i++ { + uncRewards := uncleRewards[i] + fmt.Println(uncRewards) StoreReward(sqldb, uncleAddrs[i], uncleRewards[i]) } + + fullRewardValue := new(big.Int) + fullRewardValue.Add(totalMinerReward, Rewards.ShyftNetworkBlockReward) + fullRewardValue.Add(fullRewardValue, uncRewards) + + return fullRewardValue.String() } func StoreReward(sqldb *sql.DB, address string, reward *big.Int) { @@ -497,16 +501,7 @@ func GetAllBlocks(sqldb *sql.DB) string { var arr blockRes var blockArr string rows, err := sqldb.Query(` - SELECT - hash, - coinbase, - gasused, - gaslimit, - txcount, - unclecount, - age, - number - FROM blocks`) + SELECT * FROM blocks`) if err != nil { fmt.Println("err") } @@ -520,6 +515,12 @@ func GetAllBlocks(sqldb *sql.DB) string { var txCount string var uncleCount string var age string + var parentHash string + var uncleHash string + var difficulty string + var size string + var nonce string + var rewards string var num string err = rows.Scan( @@ -530,8 +531,13 @@ func GetAllBlocks(sqldb *sql.DB) string { &txCount, &uncleCount, &age, - &num, - ) + &parentHash, + &uncleHash, + &difficulty, + &size, + &nonce, + &rewards, + &num,) arr.Blocks = append(arr.Blocks, SBlock{ Hash: hash, @@ -541,6 +547,12 @@ func GetAllBlocks(sqldb *sql.DB) string { TxCount: txCount, UncleCount: uncleCount, Age: age, + ParentHash:parentHash, + UncleHash:uncleHash, + Difficulty:difficulty, + Size: size, + Nonce:nonce, + Rewards: rewards, Number: num, }) @@ -568,6 +580,7 @@ func GetBlock(sqldb *sql.DB, blockNumber string) string { var difficulty string var size string var nonce string + var rewards string var num string row.Scan( &hash, @@ -582,6 +595,7 @@ func GetBlock(sqldb *sql.DB, blockNumber string) string { &difficulty, &size, &nonce, + &rewards, &num,) block := SBlock{ @@ -597,6 +611,7 @@ func GetBlock(sqldb *sql.DB, blockNumber string) string { Difficulty:difficulty, Size: size, Nonce:nonce, + Rewards: rewards, Number: num, } json, _ := json.Marshal(block) @@ -618,6 +633,7 @@ func GetRecentBlock(sqldb *sql.DB) string { var difficulty string var size string var nonce string + var rewards string var num string row.Scan( &hash, @@ -632,6 +648,7 @@ func GetRecentBlock(sqldb *sql.DB) string { &difficulty, &size, &nonce, + &rewards, &num,) block := SBlock{ @@ -647,6 +664,7 @@ func GetRecentBlock(sqldb *sql.DB) string { Difficulty:difficulty, Size: size, Nonce:nonce, + Rewards: rewards, Number: num, } json, _ := json.Marshal(block) @@ -656,7 +674,7 @@ func GetRecentBlock(sqldb *sql.DB) string { func GetAllTransactionsFromBlock(sqldb *sql.DB, blockNumber string) string { var arr txRes var txx string - sqlStatement := `SELECT * FROM txs WHERE blockNumber=$1` + sqlStatement := `SELECT * FROM txs WHERE blocknumber=$1` rows, err := sqldb.Query(sqlStatement, blockNumber) if err != nil { fmt.Println("err")
Actual Tx Cost/Fee:{data.Cost}{conversion}
Nonce:{props.blockNumber} props.getBlockTransactions(props.blockNumber)}>{props.blockNumber} {props.age} props.detailAccountHandler(props.from)}>{props.from} arrow