diff --git a/db/bigtable_eth1.go b/db/bigtable_eth1.go index 56bf92ecb9..57eb7e0ef5 100644 --- a/db/bigtable_eth1.go +++ b/db/bigtable_eth1.go @@ -2472,7 +2472,7 @@ func (bigtable *Bigtable) GetAddressInternalTableData(address []byte, pageToken return data, nil } -func (bigtable *Bigtable) GetInternalTransfersForTransaction(transaction []byte, from []byte, parityTrace []*rpc.ParityTraceResult) ([]types.ITransaction, error) { +func (bigtable *Bigtable) GetInternalTransfersForTransaction(transaction []byte, from []byte, parityTrace []*rpc.ParityTraceResult, currency string) ([]types.ITransaction, error) { getTraceInfo := func(trace *rpc.ParityTraceResult) ([]byte, []byte, []byte, string) { var from, to, value []byte tx_type := trace.Type @@ -2511,9 +2511,6 @@ func (bigtable *Bigtable) GetInternalTransfersForTransaction(transaction []byte, data := make([]types.ITransaction, 0, len(parityTrace)-1) for i := 1; i < len(parityTrace); i++ { from, to, value, tx_type := getTraceInfo(parityTrace[i]) - if string(value) == "\x00" { - continue - } if tx_type == "suicide" { // erigon's "suicide" might be misleading for users tx_type = "selfdestruct" @@ -2530,7 +2527,7 @@ func (bigtable *Bigtable) GetInternalTransfersForTransaction(transaction []byte, itx := types.ITransaction{ From: utils.FormatAddress(from, nil, fromName, false, false, true), To: utils.FormatAddress(to, nil, toName, false, false, true), - Amount: utils.FormatBytesAmount(value, utils.Config.Frontend.ElCurrency, 8), + Amount: utils.FormatElCurrency(value, currency, 8, true, false, false, true), TracePath: utils.FormatTracePath(tx_type, parityTrace[i].TraceAddress, parityTrace[i].Error == "", bigtable.GetMethodLabel(input, true)), Advanced: tx_type == "delegatecall" || string(value) == "\x00", } diff --git a/eth1data/eth1data.go b/eth1data/eth1data.go index 64069d366d..1ca646b695 100644 --- a/eth1data/eth1data.go +++ b/eth1data/eth1data.go @@ -27,7 +27,7 @@ import ( var logger = logrus.New().WithField("module", "eth1data") var ErrTxIsPending = errors.New("error retrieving data for tx: tx is still pending") -func GetEth1Transaction(hash common.Hash) (*types.Eth1TxData, error) { +func GetEth1Transaction(hash common.Hash, currency string) (*types.Eth1TxData, error) { ctx, cancel := context.WithTimeout(context.Background(), time.Second*10) defer cancel() @@ -150,7 +150,7 @@ func GetEth1Transaction(hash common.Hash) (*types.Eth1TxData, error) { return nil, fmt.Errorf("error loading token transfers from tx: %w", err) } } - txPageData.InternalTxns, err = db.BigtableClient.GetInternalTransfersForTransaction(tx.Hash().Bytes(), msg.From.Bytes(), data) + txPageData.InternalTxns, err = db.BigtableClient.GetInternalTransfersForTransaction(tx.Hash().Bytes(), msg.From.Bytes(), data, currency) if err != nil { return nil, fmt.Errorf("error loading internal transfers from tx: %w", err) } diff --git a/handlers/eth1tx.go b/handlers/eth1tx.go index 74fc0707e5..028e968205 100644 --- a/handlers/eth1tx.go +++ b/handlers/eth1tx.go @@ -50,7 +50,7 @@ func Eth1TransactionTx(w http.ResponseWriter, r *http.Request) { data = InitPageData(w, r, "blockchain", path, title, txNotFoundTemplateFiles) txTemplate = txNotFoundTemplate } else { - txData, err := eth1data.GetEth1Transaction(common.BytesToHash(txHash)) + txData, err := eth1data.GetEth1Transaction(common.BytesToHash(txHash), "ETH") if err != nil { mempool := services.LatestMempoolTransactions() mempoolTx := mempool.FindTxByHash(txHashString) @@ -130,21 +130,21 @@ func Eth1TransactionTxData(w http.ResponseWriter, r *http.Request) { vars := mux.Vars(r) txHashString := vars["hash"] - err := json.NewEncoder(w).Encode(getEth1TransactionTxData(txHashString)) + currency := GetCurrency(r) + err := json.NewEncoder(w).Encode(getEth1TransactionTxData(txHashString, currency)) if err != nil { logger.Errorf("error enconding json response for %v route: %v", r.URL.String(), err) http.Error(w, "Internal server error", http.StatusInternalServerError) } } -func getEth1TransactionTxData(txhash string) *types.DataTableResponse { +func getEth1TransactionTxData(txhash, currency string) *types.DataTableResponse { tableData := make([][]interface{}, 0, minimumTransactionsPerUpdate) - txHash, err := hex.DecodeString(strings.ReplaceAll(txhash, "0x", "")) if err != nil { logger.Warnf("error parsing tx hash %v: %v", txhash, err) } else { - txData, err := eth1data.GetEth1Transaction(common.BytesToHash(txHash)) + txData, err := eth1data.GetEth1Transaction(common.BytesToHash(txHash), currency) its := txData.InternalTxns if err != nil { fmt.Println("hello") diff --git a/templates/eth1tx.html b/templates/eth1tx.html index 2551b3b73f..8ae8d67183 100644 --- a/templates/eth1tx.html +++ b/templates/eth1tx.html @@ -42,16 +42,24 @@ function filterItransactions(show) { if (show) { $('#itransactions').DataTable() + .column(0) + .search("") .column(3) .search("") .draw() } else { - regExSearch = '^(?!' + `0 ETH` + '$).*$'; + // all but exact match would be: + //regExSearch = '^(?!' + `0 ETH` + '$).*$' + noZeroValue = '^(?!' + '0 ' + ')' + noDelegateCall = '^(?!' + 'delegatecall' + ')' $('#itransactions').DataTable() + .column(0) + .search(noDelegateCall, true, false) .column(3) - .search(regExSearch, true, false) + .search(noZeroValue, true, false) .draw() } + $('#itxCountLabel').text($('#itransactions').DataTable().rows( {search:'applied'} ).count()); } $("#advanced-itx-toggle").on("click", async () => { @@ -66,10 +74,12 @@ ordering: false, searching: true, ajax: dataTableLoader('/tx/' + hash + '/data'), - dom: 'lrtip' + dom: 'lrtip', + initComplete: function(settings, json) { + filterItransactions(false) + } } $('#itransactions').DataTable(tblOpts) - filterItransactions(false) }) {{ end }} @@ -118,7 +128,7 @@