diff --git a/api/types.go b/api/types.go index 10d595f4..c0ef1383 100644 --- a/api/types.go +++ b/api/types.go @@ -166,8 +166,8 @@ type Token struct { Symbol string `json:"symbol,omitempty"` Decimals int `json:"decimals,omitempty"` BalanceSat *Amount `json:"balance,omitempty"` - BaseValue float64 `json:"baseValue,omitempty"` - FiatValue float64 `json:"fiatValue,omitempty"` + BaseValue float64 `json:"baseValue,omitempty"` // value in the base currency (ETH for Ethereum) + SecondaryValue float64 `json:"secondaryValue,omitempty"` // value in secondary (fiat) currency, if specified Ids []Amount `json:"ids,omitempty"` // multiple ERC721 tokens MultiTokenValues []MultiTokenValue `json:"multiTokenValues,omitempty"` // multiple ERC1155 tokens TotalReceivedSat *Amount `json:"totalReceived,omitempty"` @@ -333,11 +333,11 @@ type Address struct { Nonce string `json:"nonce,omitempty"` UsedTokens int `json:"usedTokens,omitempty"` Tokens Tokens `json:"tokens,omitempty"` - FiatValue float64 `json:"fiatValue,omitempty"` + SecondaryValue float64 `json:"secondaryValue,omitempty"` // address value in secondary currency TokensBaseValue float64 `json:"tokensBaseValue,omitempty"` - TokensFiatValue float64 `json:"tokensFiatValue,omitempty"` - TotalBaseValue float64 `json:"totalBaseValue,omitempty"` - TotalFiatValue float64 `json:"totalFiatValue,omitempty"` + TokensSecondaryValue float64 `json:"tokensSecondaryValue,omitempty"` + TotalBaseValue float64 `json:"totalBaseValue,omitempty"` // value including tokens in base currency + TotalSecondaryValue float64 `json:"totalSecondaryValue,omitempty"` // value including tokens in secondary currency ContractInfo *bchain.ContractInfo `json:"contractInfo,omitempty"` AddressAliases AddressAliasesMap `json:"addressAliases,omitempty"` // helpers for explorer diff --git a/api/worker.go b/api/worker.go index 1f78db72..e263f513 100644 --- a/api/worker.go +++ b/api/worker.go @@ -913,7 +913,7 @@ func (w *Worker) getEthereumContractBalance(addrDesc bchain.AddressDescriptor, i if ticker != nil { secondaryRate, found := ticker.Rates[secondaryCoin] if found { - t.FiatValue = t.BaseValue * float64(secondaryRate) + t.SecondaryValue = t.BaseValue * float64(secondaryRate) } } } @@ -995,14 +995,14 @@ func (w *Worker) GetContractBaseRate(ticker *common.CurrencyRatesTicker, contrac } type ethereumTypeAddressData struct { - tokens Tokens - contractInfo *bchain.ContractInfo - nonce string - nonContractTxs int - internalTxs int - totalResults int - tokensBaseValue float64 - tokensFiatValue float64 + tokens Tokens + contractInfo *bchain.ContractInfo + nonce string + nonContractTxs int + internalTxs int + totalResults int + tokensBaseValue float64 + tokensSecondaryValue float64 } func (w *Worker) getEthereumTypeAddressBalances(addrDesc bchain.AddressDescriptor, details AccountDetails, filter *AddressFilter, secondaryCoin string) (*db.AddrBalance, *ethereumTypeAddressData, error) { @@ -1055,7 +1055,7 @@ func (w *Worker) getEthereumTypeAddressBalances(addrDesc bchain.AddressDescripto } d.tokens[j] = *t d.tokensBaseValue += t.BaseValue - d.tokensFiatValue += t.FiatValue + d.tokensSecondaryValue += t.SecondaryValue j++ } d.tokens = d.tokens[:j] @@ -1306,7 +1306,7 @@ func (w *Worker) GetAddress(address string, page int, txsOnPage int, option Acco totalReceived = ba.ReceivedSat() totalSent = &ba.SentSat } - var secondaryRate, totalFiatValue, totalBaseValue, fiatValue float64 + var secondaryRate, totalSecondaryValue, totalBaseValue, secondaryValue float64 if secondaryCoin != "" { ticker := w.is.GetCurrentTicker("", "") balance, err := strconv.ParseFloat((*Amount)(&ba.BalanceSat).DecimalString(w.chainParser.AmountDecimals()), 64) @@ -1316,10 +1316,10 @@ func (w *Worker) GetAddress(address string, page int, txsOnPage int, option Acco secondaryRate = float64(r) } } - fiatValue = secondaryRate * balance + secondaryValue = secondaryRate * balance if w.chainType == bchain.ChainEthereumType { totalBaseValue += balance + ed.tokensBaseValue - totalFiatValue = secondaryRate * totalBaseValue + totalSecondaryValue = secondaryRate * totalBaseValue } } r := &Address{ @@ -1336,11 +1336,11 @@ func (w *Worker) GetAddress(address string, page int, txsOnPage int, option Acco Transactions: txs, Txids: txids, Tokens: ed.tokens, - FiatValue: fiatValue, + SecondaryValue: secondaryValue, TokensBaseValue: ed.tokensBaseValue, - TokensFiatValue: ed.tokensFiatValue, + TokensSecondaryValue: ed.tokensSecondaryValue, TotalBaseValue: totalBaseValue, - TotalFiatValue: totalFiatValue, + TotalSecondaryValue: totalSecondaryValue, ContractInfo: ed.contractInfo, Nonce: ed.nonce, AddressAliases: w.getAddressAliases(addresses), diff --git a/api/xpub.go b/api/xpub.go index 3a1b4cc2..da245258 100644 --- a/api/xpub.go +++ b/api/xpub.go @@ -569,7 +569,7 @@ func (w *Worker) GetXpubAddress(xpub string, page int, txsOnPage int, option Acc var totalReceived big.Int totalReceived.Add(&data.balanceSat, &data.sentSat) - var fiatValue float64 + var secondaryValue float64 if secondaryCoin != "" { ticker := w.is.GetCurrentTicker("", "") balance, err := strconv.ParseFloat((*Amount)(&data.balanceSat).DecimalString(w.chainParser.AmountDecimals()), 64) @@ -577,7 +577,7 @@ func (w *Worker) GetXpubAddress(xpub string, page int, txsOnPage int, option Acc r, found := ticker.Rates[secondaryCoin] if found { secondaryRate := float64(r) - fiatValue = secondaryRate * balance + secondaryValue = secondaryRate * balance } } } @@ -595,7 +595,7 @@ func (w *Worker) GetXpubAddress(xpub string, page int, txsOnPage int, option Acc Txids: txids, UsedTokens: usedTokens, Tokens: tokens, - FiatValue: fiatValue, + SecondaryValue: secondaryValue, XPubAddresses: xpubAddresses, AddressAliases: w.getAddressAliases(addresses), } diff --git a/static/templates/address.html b/static/templates/address.html index 9c6f4c3a..2ae5bb30 100644 --- a/static/templates/address.html +++ b/static/templates/address.html @@ -5,13 +5,13 @@