Skip to content

Commit

Permalink
(BIDS-2841) fixes bug on premerge blocks for Ethereum + sets xDAI by …
Browse files Browse the repository at this point in the history
…default on Gnosis
  • Loading branch information
thib-wien committed Jan 22, 2024
1 parent 068e969 commit 34f9237
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 24 deletions.
8 changes: 7 additions & 1 deletion handlers/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
20 changes: 6 additions & 14 deletions price/price.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand All @@ -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)

Check failure on line 94 in price/price.go

View workflow job for this annotation

GitHub Actions / Run CI (ubuntu-latest, 1.20.x)

unreachable code
Expand Down Expand Up @@ -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"
Expand All @@ -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)
}
Expand Down Expand Up @@ -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")
Expand Down
File renamed without changes
16 changes: 10 additions & 6 deletions templates/eth1tx.html
Original file line number Diff line number Diff line change
Expand Up @@ -225,18 +225,22 @@ <h1 class="h4 mb-1 mb-md-0">
<div class="col-md-3">Value:</div>
<div class="col-md-9">
{{ formatBytesAmount .Value config.Frontend.ElCurrency 8 }}
<span id="valuePriceButton" class="badge badge-pill align-middle bg-dark text-white" data-html="true" data-toggle="tooltip" data-placement="bottom" data-original-title="Current Value" {{ if .HistoricalEtherPrice }}onclick="togglePriceContent('{{ .CurrentEtherPrice }}','{{ .HistoricalEtherPrice }}')" style="cursor: pointer;"{{ end }}>
{{ formatElCurrency .Value $.Rates.SelectedCurrency 2 true false false false }}
</span>
{{ if ne $.Rates.SelectedCurrency config.Frontend.ElCurrency }}
<span id="valuePriceButton" class="badge badge-pill align-middle bg-dark text-white" data-html="true" data-toggle="tooltip" data-placement="bottom" data-original-title="Current Value" {{ if .HistoricalEtherPrice }}onclick="togglePriceContent('{{ .CurrentEtherPrice }}','{{ .HistoricalEtherPrice }}')" style="cursor: pointer;"{{ end }}>
{{ formatElCurrency .Value $.Rates.SelectedCurrency 2 true false false false }}
</span>
{{ end }}
</div>
</div>
<div class="row border-bottom p-3 mx-0" style="border-width:4px !important;">
<div class="col-md-3">Transaction Fee:</div>
<div class="col-md-9">
{{ formatBytesAmount .Gas.TxFee config.Frontend.ElCurrency 8 }}
<span id="valuePriceButton" class="badge badge-pill align-middle bg-dark text-white" data-html="true" data-toggle="tooltip" data-placement="bottom" data-original-title="Current Value">
{{ formatElCurrency .Gas.TxFee $.Rates.SelectedCurrency 2 true false false false }}
</span>
{{ if ne $.Rates.SelectedCurrency config.Frontend.ElCurrency }}
<span id="valuePriceButton" class="badge badge-pill align-middle bg-dark text-white" data-html="true" data-toggle="tooltip" data-placement="bottom" data-original-title="Current Value">
{{ formatElCurrency .Gas.TxFee $.Rates.SelectedCurrency 2 true false false false }}
</span>
{{ end }}
</div>
</div>
<div class="row border-bottom p-3 mx-0">
Expand Down
6 changes: 3 additions & 3 deletions templates/slot/execTransactions.html
Original file line number Diff line number Diff line change
@@ -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 }}
<style>
Expand Down

0 comments on commit 34f9237

Please sign in to comment.