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"`
|
Symbol string `json:"symbol,omitempty"`
|
||||||
Decimals int `json:"decimals,omitempty"`
|
Decimals int `json:"decimals,omitempty"`
|
||||||
BalanceSat *Amount `json:"balance,omitempty"`
|
BalanceSat *Amount `json:"balance,omitempty"`
|
||||||
BaseValue float64 `json:"baseValue,omitempty"`
|
BaseValue float64 `json:"baseValue,omitempty"` // value in the base currency (ETH for Ethereum)
|
||||||
FiatValue float64 `json:"fiatValue,omitempty"`
|
SecondaryValue float64 `json:"secondaryValue,omitempty"` // value in secondary (fiat) currency, if specified
|
||||||
Ids []Amount `json:"ids,omitempty"` // multiple ERC721 tokens
|
Ids []Amount `json:"ids,omitempty"` // multiple ERC721 tokens
|
||||||
MultiTokenValues []MultiTokenValue `json:"multiTokenValues,omitempty"` // multiple ERC1155 tokens
|
MultiTokenValues []MultiTokenValue `json:"multiTokenValues,omitempty"` // multiple ERC1155 tokens
|
||||||
TotalReceivedSat *Amount `json:"totalReceived,omitempty"`
|
TotalReceivedSat *Amount `json:"totalReceived,omitempty"`
|
||||||
@ -333,11 +333,11 @@ type Address struct {
|
|||||||
Nonce string `json:"nonce,omitempty"`
|
Nonce string `json:"nonce,omitempty"`
|
||||||
UsedTokens int `json:"usedTokens,omitempty"`
|
UsedTokens int `json:"usedTokens,omitempty"`
|
||||||
Tokens Tokens `json:"tokens,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"`
|
TokensBaseValue float64 `json:"tokensBaseValue,omitempty"`
|
||||||
TokensFiatValue float64 `json:"tokensFiatValue,omitempty"`
|
TokensSecondaryValue float64 `json:"tokensSecondaryValue,omitempty"`
|
||||||
TotalBaseValue float64 `json:"totalBaseValue,omitempty"`
|
TotalBaseValue float64 `json:"totalBaseValue,omitempty"` // value including tokens in base currency
|
||||||
TotalFiatValue float64 `json:"totalFiatValue,omitempty"`
|
TotalSecondaryValue float64 `json:"totalSecondaryValue,omitempty"` // value including tokens in secondary currency
|
||||||
ContractInfo *bchain.ContractInfo `json:"contractInfo,omitempty"`
|
ContractInfo *bchain.ContractInfo `json:"contractInfo,omitempty"`
|
||||||
AddressAliases AddressAliasesMap `json:"addressAliases,omitempty"`
|
AddressAliases AddressAliasesMap `json:"addressAliases,omitempty"`
|
||||||
// helpers for explorer
|
// helpers for explorer
|
||||||
|
|||||||
@ -913,7 +913,7 @@ func (w *Worker) getEthereumContractBalance(addrDesc bchain.AddressDescriptor, i
|
|||||||
if ticker != nil {
|
if ticker != nil {
|
||||||
secondaryRate, found := ticker.Rates[secondaryCoin]
|
secondaryRate, found := ticker.Rates[secondaryCoin]
|
||||||
if found {
|
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 {
|
type ethereumTypeAddressData struct {
|
||||||
tokens Tokens
|
tokens Tokens
|
||||||
contractInfo *bchain.ContractInfo
|
contractInfo *bchain.ContractInfo
|
||||||
nonce string
|
nonce string
|
||||||
nonContractTxs int
|
nonContractTxs int
|
||||||
internalTxs int
|
internalTxs int
|
||||||
totalResults int
|
totalResults int
|
||||||
tokensBaseValue float64
|
tokensBaseValue float64
|
||||||
tokensFiatValue float64
|
tokensSecondaryValue float64
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *Worker) getEthereumTypeAddressBalances(addrDesc bchain.AddressDescriptor, details AccountDetails, filter *AddressFilter, secondaryCoin string) (*db.AddrBalance, *ethereumTypeAddressData, error) {
|
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.tokens[j] = *t
|
||||||
d.tokensBaseValue += t.BaseValue
|
d.tokensBaseValue += t.BaseValue
|
||||||
d.tokensFiatValue += t.FiatValue
|
d.tokensSecondaryValue += t.SecondaryValue
|
||||||
j++
|
j++
|
||||||
}
|
}
|
||||||
d.tokens = d.tokens[: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()
|
totalReceived = ba.ReceivedSat()
|
||||||
totalSent = &ba.SentSat
|
totalSent = &ba.SentSat
|
||||||
}
|
}
|
||||||
var secondaryRate, totalFiatValue, totalBaseValue, fiatValue float64
|
var secondaryRate, totalSecondaryValue, totalBaseValue, secondaryValue float64
|
||||||
if secondaryCoin != "" {
|
if secondaryCoin != "" {
|
||||||
ticker := w.is.GetCurrentTicker("", "")
|
ticker := w.is.GetCurrentTicker("", "")
|
||||||
balance, err := strconv.ParseFloat((*Amount)(&ba.BalanceSat).DecimalString(w.chainParser.AmountDecimals()), 64)
|
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)
|
secondaryRate = float64(r)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fiatValue = secondaryRate * balance
|
secondaryValue = secondaryRate * balance
|
||||||
if w.chainType == bchain.ChainEthereumType {
|
if w.chainType == bchain.ChainEthereumType {
|
||||||
totalBaseValue += balance + ed.tokensBaseValue
|
totalBaseValue += balance + ed.tokensBaseValue
|
||||||
totalFiatValue = secondaryRate * totalBaseValue
|
totalSecondaryValue = secondaryRate * totalBaseValue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
r := &Address{
|
r := &Address{
|
||||||
@ -1336,11 +1336,11 @@ func (w *Worker) GetAddress(address string, page int, txsOnPage int, option Acco
|
|||||||
Transactions: txs,
|
Transactions: txs,
|
||||||
Txids: txids,
|
Txids: txids,
|
||||||
Tokens: ed.tokens,
|
Tokens: ed.tokens,
|
||||||
FiatValue: fiatValue,
|
SecondaryValue: secondaryValue,
|
||||||
TokensBaseValue: ed.tokensBaseValue,
|
TokensBaseValue: ed.tokensBaseValue,
|
||||||
TokensFiatValue: ed.tokensFiatValue,
|
TokensSecondaryValue: ed.tokensSecondaryValue,
|
||||||
TotalBaseValue: totalBaseValue,
|
TotalBaseValue: totalBaseValue,
|
||||||
TotalFiatValue: totalFiatValue,
|
TotalSecondaryValue: totalSecondaryValue,
|
||||||
ContractInfo: ed.contractInfo,
|
ContractInfo: ed.contractInfo,
|
||||||
Nonce: ed.nonce,
|
Nonce: ed.nonce,
|
||||||
AddressAliases: w.getAddressAliases(addresses),
|
AddressAliases: w.getAddressAliases(addresses),
|
||||||
|
|||||||
@ -569,7 +569,7 @@ func (w *Worker) GetXpubAddress(xpub string, page int, txsOnPage int, option Acc
|
|||||||
var totalReceived big.Int
|
var totalReceived big.Int
|
||||||
totalReceived.Add(&data.balanceSat, &data.sentSat)
|
totalReceived.Add(&data.balanceSat, &data.sentSat)
|
||||||
|
|
||||||
var fiatValue float64
|
var secondaryValue float64
|
||||||
if secondaryCoin != "" {
|
if secondaryCoin != "" {
|
||||||
ticker := w.is.GetCurrentTicker("", "")
|
ticker := w.is.GetCurrentTicker("", "")
|
||||||
balance, err := strconv.ParseFloat((*Amount)(&data.balanceSat).DecimalString(w.chainParser.AmountDecimals()), 64)
|
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]
|
r, found := ticker.Rates[secondaryCoin]
|
||||||
if found {
|
if found {
|
||||||
secondaryRate := float64(r)
|
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,
|
Txids: txids,
|
||||||
UsedTokens: usedTokens,
|
UsedTokens: usedTokens,
|
||||||
Tokens: tokens,
|
Tokens: tokens,
|
||||||
FiatValue: fiatValue,
|
SecondaryValue: secondaryValue,
|
||||||
XPubAddresses: xpubAddresses,
|
XPubAddresses: xpubAddresses,
|
||||||
AddressAliases: w.getAddressAliases(addresses),
|
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>
|
<h5 class="col-12 d-flex h-data pb-2"><span class="ellipsis copyable">{{$addr.AddrStr}}</span></h5>
|
||||||
<h4 class="row">
|
<h4 class="row">
|
||||||
<div class="col-lg-6">{{formattedAmountSpan $addr.BalanceSat 0 $data.CoinShortcut $data "copyable"}}</div>
|
<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>
|
</h4>
|
||||||
{{if gt $addr.TotalFiatValue $addr.FiatValue}}
|
{{if gt $addr.TotalSecondaryValue $addr.SecondaryValue}}
|
||||||
<div class="row g-0 small text-muted">Including Tokens</div>
|
<div class="row g-0 small text-muted">Including Tokens</div>
|
||||||
<h4 class="row">
|
<h4 class="row">
|
||||||
<div class="col-lg-6">{{summaryValuesSpan $addr.TotalBaseValue 0 $data}}</div>
|
<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>
|
</h4>
|
||||||
{{end}}
|
{{end}}
|
||||||
</div>
|
</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">
|
<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">
|
<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-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>
|
</div>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
@ -135,7 +135,7 @@
|
|||||||
<tr>
|
<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 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>{{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>
|
<td class="text-end">{{formatInt $t.Transfers}}</td>
|
||||||
</tr>
|
</tr>
|
||||||
{{end}}
|
{{end}}
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
<h5 class="col-12 d-flex h-data pb-2"><span class="ellipsis copyable">{{$addr.AddrStr}}</span></h5>
|
<h5 class="col-12 d-flex h-data pb-2"><span class="ellipsis copyable">{{$addr.AddrStr}}</span></h5>
|
||||||
<h4 class="row">
|
<h4 class="row">
|
||||||
<div class="col-lg-6">{{formattedAmountSpan $addr.BalanceSat 0 $data.CoinShortcut $data "copyable"}}</div>
|
<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>
|
</h4>
|
||||||
</div>
|
</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">
|
<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