diff --git a/blockExplorerApi/handler.go b/blockExplorerApi/handler.go index abdc9acd31..2b5c3692c3 100644 --- a/blockExplorerApi/handler.go +++ b/blockExplorerApi/handler.go @@ -16,7 +16,6 @@ import ( func GetTransaction(w http.ResponseWriter, r *http.Request) { vars := mux.Vars(r) txHash := vars["txHash"] - fmt.Println(txHash) connStr := "user=postgres dbname=shyftdb sslmode=disable" blockExplorerDb, err := sql.Open("postgres", connStr) if err != nil { @@ -24,7 +23,6 @@ func GetTransaction(w http.ResponseWriter, r *http.Request) { } getTxResponse := shyftdb.GetTransaction(blockExplorerDb, txHash) - fmt.Println(getTxResponse) if err != nil { http.Error(w, err.Error(), 500) diff --git a/shyftBlockExplorerUI/src/components/table/blocks/blockRows.js b/shyftBlockExplorerUI/src/components/table/blocks/blockRows.js index 1258db7b55..900f3cf1d5 100644 --- a/shyftBlockExplorerUI/src/components/table/blocks/blockRows.js +++ b/shyftBlockExplorerUI/src/components/table/blocks/blockRows.js @@ -24,7 +24,7 @@ class BlocksTable extends Component { render() { const table = this.state.data.map((data, i) => { return { return ( - + props.detailBlockHandler(props.Number)}> {props.Number} diff --git a/shyftBlockExplorerUI/src/components/table/blocks/blocksDetailsRow.js b/shyftBlockExplorerUI/src/components/table/blocks/blocksDetailsRow.js index 74c45681a1..dc881a5b9c 100644 --- a/shyftBlockExplorerUI/src/components/table/blocks/blocksDetailsRow.js +++ b/shyftBlockExplorerUI/src/components/table/blocks/blocksDetailsRow.js @@ -8,6 +8,7 @@ class DetailBlockTable extends Component { let combinedClasses = ['responsive-table', classes.table]; return ( + @@ -68,6 +69,7 @@ class DetailBlockTable extends Component { +
Height: {data.Number}Reward: TBD
); } diff --git a/shyftBlockExplorerUI/src/components/table/blocks/table.css b/shyftBlockExplorerUI/src/components/table/blocks/table.css index 38f3d87fed..8aa8995a54 100644 --- a/shyftBlockExplorerUI/src/components/table/blocks/table.css +++ b/shyftBlockExplorerUI/src/components/table/blocks/table.css @@ -13,6 +13,11 @@ th { padding-right: 10px; } +td { + padding-left: 5px; + font-size: .5rem; +} + .addressTag { display: inline-block; vertical-align: bottom; diff --git a/shyftBlockExplorerUI/src/components/table/transactions/transactionDetailsRow.js b/shyftBlockExplorerUI/src/components/table/transactions/transactionDetailsRow.js index a4d51fccb0..1ce7db2ac8 100644 --- a/shyftBlockExplorerUI/src/components/table/transactions/transactionDetailsRow.js +++ b/shyftBlockExplorerUI/src/components/table/transactions/transactionDetailsRow.js @@ -5,69 +5,64 @@ class DetailTransactionTable extends Component { render() { let data = this.props.data + console.log(data) let combinedClasses = ['responsive-table', classes.table]; return ( + - + + + + + + + + + - - + + - - + + - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + - - + + +
TxHash: {data.TxHash}
Age:TxReceipt Status:{data.Status}
Block Height:{data.BlockNumber}
TimeStamp: {data.Age}
Txn:{data.TxCount} transactionsFrom:{data.From}
Block Hash:{data.Hash}To:{ `${data.IsContract}` ? `${data.To} (Contract)` : `${data.To}` }
Parent Hash:{data.ParentHash}Value:{data.Amount}
Uncle Hash:{data.UncleHash}
Uncle Count:{data.UncleCount}
Coinbase:{data.Coinbase}
Difficulty:{data.Difficulty}
GasUsed:{data.GasUsed}
Size:{data.Size}ytes
GasUsed:{data.GasUsed}
GasLimit:Gas Limit: {data.GasLimit}
Gas Used By Txn:{data.Gas}
Gas Price:{data.GasPrice}
Actual Tx Cost/Fee:{data.Cost}
Nonce: {data.Nonce}
Reward:TBDInput Data:{data.Data}
); } diff --git a/shyftBlockExplorerUI/src/components/table/transactions/transactionRow.js b/shyftBlockExplorerUI/src/components/table/transactions/transactionRow.js index abde6e9bef..76bd341d5c 100644 --- a/shyftBlockExplorerUI/src/components/table/transactions/transactionRow.js +++ b/shyftBlockExplorerUI/src/components/table/transactions/transactionRow.js @@ -26,25 +26,28 @@ class TransactionTable extends Component { const table = this.state.data.map((data, i) => { return }) let combinedClasses = ['responsive-table', classes.table]; return ( - +
+ diff --git a/shyftBlockExplorerUI/src/components/table/transactions/transactionTable.js b/shyftBlockExplorerUI/src/components/table/transactions/transactionTable.js index f8fb0d1713..2d3210b60c 100644 --- a/shyftBlockExplorerUI/src/components/table/transactions/transactionTable.js +++ b/shyftBlockExplorerUI/src/components/table/transactions/transactionTable.js @@ -4,6 +4,7 @@ import arrow from '../../assets/arrow_right.png'; import { Link } from 'react-router-dom' const TransactionTable = (props) => { + console.log(props) return ( @@ -12,10 +13,10 @@ const TransactionTable = (props) => { {props.txHash} - + - - + + diff --git a/shyftBlockExplorerUI/src/containers/App.js b/shyftBlockExplorerUI/src/containers/App.js index 6029f37e68..b794f9283f 100644 --- a/shyftBlockExplorerUI/src/containers/App.js +++ b/shyftBlockExplorerUI/src/containers/App.js @@ -32,8 +32,10 @@ class App extends Component { } detailTransactionHandler = async(txHash) => { + console.log("THIS RAN") try { const response = await axios.get(`http://localhost:8080/api/get_transaction/${txHash}`) + console.log("THIS IS RESPONSE", response) await this.setState({ transactionDetailData: response.data }) } catch(error) { diff --git a/shyftDb/postgres_setup/create_tables.psql b/shyftDb/postgres_setup/create_tables.psql index 2e3a75d6c3..4135e5e41e 100644 --- a/shyftDb/postgres_setup/create_tables.psql +++ b/shyftDb/postgres_setup/create_tables.psql @@ -23,10 +23,12 @@ CREATE TABLE IF NOT EXISTS txs ( amount numeric, gasprice numeric, gas numeric, + gasLimit numeric, txFee numeric, nonce numeric, txStatus text, isContract bool, + age timestamp, data bytea ); diff --git a/shyftdb/shyft_database_util.go b/shyftdb/shyft_database_util.go index d27502618e..20d1e6355f 100644 --- a/shyftdb/shyft_database_util.go +++ b/shyftdb/shyft_database_util.go @@ -78,10 +78,12 @@ type ShyftTxEntryPretty struct { Amount uint64 GasPrice uint64 Gas uint64 + GasLimit uint64 Cost uint64 Nonce uint64 Status string IsContract bool + Age time.Time Data []byte } @@ -100,13 +102,7 @@ type SendAndReceive struct { } //WriteBlock writes to block info to sql db - func WriteBlock(sqldb *sql.DB, block *types.Block, receipts []*types.Receipt) error { - //Need to create field in postgres db isContract : True || False - //Need to fix nonce numeric issue (attempt to reproduce and record) - //Need to update tx To Field where null with Contract Address - //Need to update account table with that Contract Address - //Need to update AccountNonce and Balance of Tx To field || Contract Address - +func WriteBlock(sqldb *sql.DB, block *types.Block, receipts []*types.Receipt) error { coinbase := block.Header().Coinbase.String() number := block.Header().Number.String() gasUsed := block.Header().GasUsed @@ -134,7 +130,7 @@ type SendAndReceive struct { if block.Transactions().Len() > 0 { for _, tx := range block.Transactions() { //WriteMinerRewards(sqldb, block) - WriteTransactions(sqldb, tx, block.Header().Hash(), block.Header().Number.String(), receipts) + WriteTransactions(sqldb, tx, block.Header().Hash(), block.Header().Number.String(), receipts, age, gasLimit) if block.Transactions()[0].To() != nil { WriteFromBalance(sqldb, tx) } @@ -148,7 +144,7 @@ type SendAndReceive struct { } //WriteTransactions writes to sqldb -func WriteTransactions(sqldb *sql.DB, tx *types.Transaction, blockHash common.Hash, blockNumber string, receipts []*types.Receipt) error { +func WriteTransactions(sqldb *sql.DB, tx *types.Transaction, blockHash common.Hash, blockNumber string, receipts []*types.Receipt, age time.Time, gasLimit uint64) error { txData := ShyftTxEntry{ TxHash: tx.Hash(), From: tx.From(), @@ -161,7 +157,8 @@ func WriteTransactions(sqldb *sql.DB, tx *types.Transaction, blockHash common.Ha Nonce: tx.Nonce(), Data: tx.Data(), } - + fmt.Println("THIS IS AGE", age) + fmt.Println("THIS IS GAS LIMIT", gasLimit) txHash := txData.TxHash.Hex() from := txData.From.Hex() blockHasher := txData.BlockHash @@ -190,8 +187,8 @@ func WriteTransactions(sqldb *sql.DB, tx *types.Transaction, blockHash common.Ha var retNonce string isContract = true - sqlStatement := `INSERT INTO txs(txhash, from_addr, to_addr, blockhash, blockNumber, amount, gasprice, gas, txfee, nonce, isContract, txStatus, data) VALUES(($1), ($2), ($3), ($4), ($5), ($6), ($7), ($8), ($9), ($10), ($11), ($12), ($13)) RETURNING nonce` - qerr := sqldb.QueryRow(sqlStatement, txHash, from, contractAddressFromReciept, blockHasher, blockNumber, amount, gasPrice, gas, txFee, nonce, isContract, statusFromReciept, data).Scan(&retNonce) + sqlStatement := `INSERT INTO txs(txhash, from_addr, to_addr, blockhash, blockNumber, amount, gasprice, gas, gasLimit,txfee, nonce, isContract, txStatus, age, data) VALUES(($1), ($2), ($3), ($4), ($5), ($6), ($7), ($8), ($9), ($10), ($11), ($12), ($13), ($14), ($15)) RETURNING nonce` + qerr := sqldb.QueryRow(sqlStatement, txHash, from, contractAddressFromReciept, blockHasher, blockNumber, amount, gasPrice, gas, gasLimit, txFee, nonce, isContract, statusFromReciept, age,data).Scan(&retNonce) if qerr != nil { panic(qerr) @@ -209,8 +206,8 @@ func WriteTransactions(sqldb *sql.DB, tx *types.Transaction, blockHash common.Ha } } - sqlStatement := `INSERT INTO txs(txhash, from_addr, to_addr, blockhash, blockNumber, amount, gasprice, gas, txfee, nonce, isContract, txStatus, data) VALUES(($1), ($2), ($3), ($4), ($5), ($6), ($7), ($8), ($9), ($10), ($11), ($12), ($13)) RETURNING nonce` - qerr := sqldb.QueryRow(sqlStatement, txHash, from, to.Hex(), blockHasher, blockNumber, amount, gasPrice, gas, txFee, nonce, isContract, statusFromReciept, data).Scan(&retNonce) + sqlStatement := `INSERT INTO txs(txhash, from_addr, to_addr, blockhash, blockNumber, amount, gasprice, gas, gasLimit, txfee, nonce, isContract, txStatus, age, data) VALUES(($1), ($2), ($3), ($4), ($5), ($6), ($7), ($8), ($9), ($10), ($11), ($12), ($13), ($14), ($15)) RETURNING nonce` + qerr := sqldb.QueryRow(sqlStatement, txHash, from, to.Hex(), blockHasher, blockNumber, amount, gasPrice, gas, gasLimit, txFee, nonce, isContract, statusFromReciept, age,data).Scan(&retNonce) if qerr != nil { panic(qerr) @@ -612,10 +609,12 @@ func GetAllTransactions(sqldb *sql.DB) string { var amount uint64 var gasprice uint64 var gas uint64 + var gasLimit uint64 var txfee uint64 var nonce uint64 var status string var isContract bool + var age time.Time var data []byte err = rows.Scan( &txhash, @@ -626,10 +625,12 @@ func GetAllTransactions(sqldb *sql.DB) string { &amount, &gasprice, &gas, + &gasLimit, &txfee, &nonce, &status, &isContract, + &age, &data, ) @@ -642,10 +643,12 @@ func GetAllTransactions(sqldb *sql.DB) string { Amount: amount, GasPrice: gasprice, Gas: gas, + GasLimit: gasLimit, Cost: txfee, Nonce: nonce, Status: status, IsContract: isContract, + Age: age, Data: data, }) @@ -660,32 +663,39 @@ func GetAllTransactions(sqldb *sql.DB) string { func GetTransaction(sqldb *sql.DB, txHash string) string { sqlStatement := `SELECT * FROM txs WHERE txhash=$1;` row := sqldb.QueryRow(sqlStatement, txHash) - var txhash string - var to_addr string - var from_addr string - var blockhash string - var blocknumber string - var amount uint64 - var gasprice uint64 - var gas uint64 - var txfee uint64 - var nonce uint64 - var status string - var isContract bool - var data []byte + var txhash string + var to_addr string + var from_addr string + var blockhash string + var blocknumber string + var amount uint64 + var gasprice uint64 + var gas uint64 + var gasLimit uint64 + var txfee uint64 + var nonce uint64 + var status string + var isContract bool + var age time.Time + var data []byte + row.Scan( &txhash, &to_addr, &from_addr, &blockhash, + &blocknumber, &amount, &gasprice, &gas, + &gasLimit, &txfee, &nonce, &status, &isContract, + &age, &data) + tx := ShyftTxEntryPretty{ TxHash: txhash, To: to_addr, @@ -695,10 +705,12 @@ func GetTransaction(sqldb *sql.DB, txHash string) string { Amount: amount, GasPrice: gasprice, Gas: gas, + GasLimit: gasLimit, Cost: txfee, Nonce: nonce, Status: status, IsContract: isContract, + Age: age, Data: data, } json, _ := json.Marshal(tx)
TxHash Block Age From To Value TxFee
{props.blockNumber}30 secs ago{props.age} {props.from}{props.to}{props.to} {props.value} {props.cost}