Rename fiatValue to secondaryValue in Address related endpoints
This commit is contained in:
parent
250a788d20
commit
147ceabd6e
12
api/types.go
12
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
|
||||
|
||||
@ -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),
|
||||
|
||||
@ -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),
|
||||
}
|
||||
|
||||
@ -5,13 +5,13 @@
|
||||
<h5 class="col-12 d-flex h-data pb-2"><span class="ellipsis copyable">{{$addr.AddrStr}}</span></h5>
|
||||
<h4 class="row">
|
||||
<div class="col-lg-6">{{formattedAmountSpan $addr.BalanceSat 0 $data.CoinShortcut $data "copyable"}}</div>
|
||||
{{if $addr.FiatValue}}<div class="col-lg-6">{{summaryValuesSpan 0 $addr.FiatValue $data}}</div>{{end}}
|
||||
{{if $addr.SecondaryValue}}<div class="col-lg-6">{{summaryValuesSpan 0 $addr.SecondaryValue $data}}</div>{{end}}
|
||||
</h4>
|
||||
{{if gt $addr.TotalFiatValue $addr.FiatValue}}
|
||||
{{if gt $addr.TotalSecondaryValue $addr.SecondaryValue}}
|
||||
<div class="row g-0 small text-muted">Including Tokens</div>
|
||||
<h4 class="row">
|
||||
<div class="col-lg-6">{{summaryValuesSpan $addr.TotalBaseValue 0 $data}}</div>
|
||||
<div class="col-lg-6">{{summaryValuesSpan 0 $addr.TotalFiatValue $data}}</div>
|
||||
<div class="col-lg-6">{{summaryValuesSpan 0 $addr.TotalSecondaryValue $data}}</div>
|
||||
</h4>
|
||||
{{end}}
|
||||
</div>
|
||||
@ -116,7 +116,7 @@
|
||||
<button class="accordion-button collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#erc20Body" aria-expanded="false" aria-controls="erc20Body">
|
||||
<div class="row g-0 w-100">
|
||||
<h5 class="col-md-4 mb-md-0">ERC20 Tokens <span class="badge bg-secondary">{{tokenCount $addr.Tokens "ERC20"}}</span></h5>
|
||||
<h5 class="col-md-8 mb-md-0"><span tt="Total value of tokens">{{summaryValuesSpan $addr.TokensBaseValue $addr.TokensFiatValue $data}}</span></h5>
|
||||
<h5 class="col-md-8 mb-md-0"><span tt="Total value of tokens">{{summaryValuesSpan $addr.TokensBaseValue $addr.TokensSecondaryValue $data}}</span></h5>
|
||||
</div>
|
||||
</button>
|
||||
</div>
|
||||
@ -135,7 +135,7 @@
|
||||
<tr>
|
||||
<td class="ellipsis"><a href="/address/{{$t.Contract}}">{{if $t.Name}}<span class="copyable" cc="{{$t.Contract}}" alias-type="Contract">{{$t.Name}}</span>{{else}}<span class="copyable">{{$t.Contract}}</span>{{end}}</a></td>
|
||||
<td>{{formattedAmountSpan $t.BalanceSat $t.Decimals $t.Symbol $data "copyable"}}</td>
|
||||
<td>{{summaryValuesSpan $t.BaseValue $t.FiatValue $data}}</span></td>
|
||||
<td>{{summaryValuesSpan $t.BaseValue $t.SecondaryValue $data}}</span></td>
|
||||
<td class="text-end">{{formatInt $t.Transfers}}</td>
|
||||
</tr>
|
||||
{{end}}
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
<h5 class="col-12 d-flex h-data pb-2"><span class="ellipsis copyable">{{$addr.AddrStr}}</span></h5>
|
||||
<h4 class="row">
|
||||
<div class="col-lg-6">{{formattedAmountSpan $addr.BalanceSat 0 $data.CoinShortcut $data "copyable"}}</div>
|
||||
{{if $addr.FiatValue}}<div class="col-lg-6">{{summaryValuesSpan 0 $addr.FiatValue $data}}</div>{{end}}
|
||||
{{if $addr.SecondaryValue}}<div class="col-lg-6">{{summaryValuesSpan 0 $addr.SecondaryValue $data}}</div>{{end}}
|
||||
</h4>
|
||||
</div>
|
||||
<div class="col-md-2 order-1 order-md-2 d-flex justify-content-center justify-content-md-end mb-3 mb-md-0">
|
||||
|
||||
Loading…
Reference in New Issue
Block a user