diff --git a/cmd/explorer/main.go b/cmd/explorer/main.go index 2b895442e3..3d3751a0de 100644 --- a/cmd/explorer/main.go +++ b/cmd/explorer/main.go @@ -410,6 +410,7 @@ func main() { router.HandleFunc("/block/{block}", handlers.Eth1Block).Methods("GET") router.HandleFunc("/block/{block}/transactions", handlers.BlockTransactionsData).Methods("GET") router.HandleFunc("/tx/{hash}", handlers.Eth1TransactionTx).Methods("GET") + router.HandleFunc("/tx/{hash}/data", handlers.Eth1TransactionTxData).Methods("GET") router.HandleFunc("/mempool", handlers.MempoolView).Methods("GET") router.HandleFunc("/burn", handlers.Burn).Methods("GET") router.HandleFunc("/burn/data", handlers.BurnPageData).Methods("GET") diff --git a/handlers/eth1tx.go b/handlers/eth1tx.go index 431d72c84a..74fc0707e5 100644 --- a/handlers/eth1tx.go +++ b/handlers/eth1tx.go @@ -124,3 +124,44 @@ func Eth1TransactionTx(w http.ResponseWriter, r *http.Request) { return // an error has occurred and was processed } } + +func Eth1TransactionTxData(w http.ResponseWriter, r *http.Request) { + w.Header().Set("Content-Type", "application/json") + + vars := mux.Vars(r) + txHashString := vars["hash"] + err := json.NewEncoder(w).Encode(getEth1TransactionTxData(txHashString)) + 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 { + 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)) + its := txData.InternalTxns + if err != nil { + fmt.Println("hello") + } else { + for _, i := range its { + tableData = append(tableData, []interface{}{ + i.TracePath, + i.From, + i.To, + i.Amount, + i.Gas.Limit, + }) + } + } + } + + return &types.DataTableResponse{ + Data: tableData, + } +} diff --git a/static/css/layout/toggle.css b/static/css/layout/toggle.css index c20128ec51..f111c4199b 100644 --- a/static/css/layout/toggle.css +++ b/static/css/layout/toggle.css @@ -5,6 +5,17 @@ height: 19.2px; } +.advanced-itx-switch { + position: relative; + display: inline-flex; + width: 38.4px; + height: 19.2px; +} + +.advanced-itx-switch input { + display: none; +} + .theme-switch { height: calc(var(--font-size, 1rem) * 1.2); position: absolute; diff --git a/templates/eth1tx.html b/templates/eth1tx.html index bf6ec3c3cf..2551b3b73f 100644 --- a/templates/eth1tx.html +++ b/templates/eth1tx.html @@ -1,4 +1,7 @@ {{ define "js" }} + + + {{ end }} @@ -47,6 +102,15 @@