From 34f9237275cdc219ca32cde369983fb8ec8f9e3b Mon Sep 17 00:00:00 2001 From: thib-wien Date: Mon, 22 Jan 2024 15:56:41 +0100 Subject: [PATCH] (BIDS-2841) fixes bug on premerge blocks for Ethereum + sets xDAI by default on Gnosis --- handlers/common.go | 8 +++++++- price/price.go | 20 ++++++-------------- static/img/{DAI.svg => xDAI.svg} | 0 templates/eth1tx.html | 16 ++++++++++------ templates/slot/execTransactions.html | 6 +++--- 5 files changed, 26 insertions(+), 24 deletions(-) rename static/img/{DAI.svg => xDAI.svg} (100%) diff --git a/handlers/common.go b/handlers/common.go index 6e0ae2ca0e..b0e30cfc05 100644 --- a/handlers/common.go +++ b/handlers/common.go @@ -494,7 +494,13 @@ func GetCurrency(r *http.Request) string { return cookie.Value } } - return utils.Config.Frontend.MainCurrency + // here, the user did not select a currency to visualize the amounts, so we choose one by default + if utils.Config.Frontend.MainCurrency != "GNO" { + return utils.Config.Frontend.MainCurrency + } else { + // if the network is Gnosis, we show amounts in xDAI by default + return utils.Config.Frontend.ElCurrency + } } func GetCurrencySymbol(r *http.Request) string { diff --git a/price/price.go b/price/price.go index 74250ce569..d2bd1a9961 100644 --- a/price/price.go +++ b/price/price.go @@ -73,14 +73,12 @@ func Init(chainId uint64, eth1Endpoint, clCurrencyParam, elCurrencyParam string) clCurrency = clCurrencyParam elCurrency = elCurrencyParam - if elCurrency == "xDAI" { - elCurrency = "DAI" - } + calcPairs[elCurrency] = true calcPairs[clCurrency] = true - setPrice("DAI", "GNO", 1.0/200.0) - setPrice("GNO", "DAI", 200.0) + setPrice("xDAI", "GNO", 1.0/200.0) + setPrice("GNO", "xDAI", 200.0) setPrice("GNO", "USD", 200.0) setPrice("GNO", "ETH", 200.0/2000.0) setPrice("mGNO", "GNO", float64(1)/float64(32)) @@ -90,7 +88,7 @@ func Init(chainId uint64, eth1Endpoint, clCurrencyParam, elCurrencyParam string) calcPairs["GNO"] = true - availableCurrencies = []string{"GNO", "mGNO", "DAI", "ETH", "USD"} + availableCurrencies = []string{"GNO", "mGNO", "xDAI", "ETH", "USD"} return eClient, err := ethclient.Dial(eth1Endpoint) @@ -137,7 +135,7 @@ func Init(chainId uint64, eth1Endpoint, clCurrencyParam, elCurrencyParam string) case 100: // see: https://docs.chain.link/data-feeds/price-feeds/addresses/?network=gnosis-chain feedAddrs["GNO/USD"] = "0x22441d81416430A54336aB28765abd31a792Ad37" - feedAddrs["DAI/USD"] = "0x678df3415fc31947dA4324eC63212874be5a82f8" + feedAddrs["xDAI/USD"] = "0x678df3415fc31947dA4324eC63212874be5a82f8" feedAddrs["EUR/USD"] = "0xab70BCB260073d036d1660201e9d5405F5829b7a" feedAddrs["JPY/USD"] = "0x2AfB993C670C01e9dA1550c58e8039C1D8b8A317" // feedAddrs["CHFUSD"] = "0xFb00261Af80ADb1629D3869E377ae1EEC7bE659F" @@ -150,7 +148,7 @@ func Init(chainId uint64, eth1Endpoint, clCurrencyParam, elCurrencyParam string) calcPairs["GNO"] = true - availableCurrencies = []string{"GNO", "mGNO", "DAI", "ETH", "USD", "EUR", "JPY"} + availableCurrencies = []string{"GNO", "mGNO", "xDAI", "ETH", "USD", "EUR", "JPY"} default: logger.Fatalf("unsupported chainId %v", chainId) } @@ -240,12 +238,6 @@ func GetPrice(a, b string) float64 { runOnceWg.Wait() pricesMu.Lock() defer pricesMu.Unlock() - if a == "xDAI" { - a = "DAI" - } - if b == "xDAI" { - b = "DAI" - } price, exists := prices[a+"/"+b] if !exists { logrus.WithFields(logrus.Fields{"pair": a + "/" + b}).Warnf("price pair not found") diff --git a/static/img/DAI.svg b/static/img/xDAI.svg similarity index 100% rename from static/img/DAI.svg rename to static/img/xDAI.svg diff --git a/templates/eth1tx.html b/templates/eth1tx.html index a233b14ae8..bb52accc1f 100644 --- a/templates/eth1tx.html +++ b/templates/eth1tx.html @@ -225,18 +225,22 @@

Value:
{{ formatBytesAmount .Value config.Frontend.ElCurrency 8 }} - - {{ formatElCurrency .Value $.Rates.SelectedCurrency 2 true false false false }} - + {{ if ne $.Rates.SelectedCurrency config.Frontend.ElCurrency }} + + {{ formatElCurrency .Value $.Rates.SelectedCurrency 2 true false false false }} + + {{ end }}
Transaction Fee:
{{ formatBytesAmount .Gas.TxFee config.Frontend.ElCurrency 8 }} - - {{ formatElCurrency .Gas.TxFee $.Rates.SelectedCurrency 2 true false false false }} - + {{ if ne $.Rates.SelectedCurrency config.Frontend.ElCurrency }} + + {{ formatElCurrency .Gas.TxFee $.Rates.SelectedCurrency 2 true false false false }} + + {{ end }}
diff --git a/templates/slot/execTransactions.html b/templates/slot/execTransactions.html index d3719df75e..92dd90cfcf 100644 --- a/templates/slot/execTransactions.html +++ b/templates/slot/execTransactions.html @@ -1,7 +1,7 @@ {{ define "execution_transactions" }} - {{ $data := .Data }} - {{ if $data.ExecutionData }} - {{ $data = $data.ExecutionData}} + {{ $data := .Data}} + {{ if eq $.Active "blockchain" }} + {{ $data = .Data.ExecutionData}} {{ end }} {{ with $data }}