Fix backward compatibility with v0.3.6
This commit is contained in:
parent
026899edf1
commit
8e28ebe8dc
@ -339,6 +339,7 @@ type Address struct {
|
|||||||
TotalBaseValue float64 `json:"totalBaseValue,omitempty"` // value including tokens in base currency
|
TotalBaseValue float64 `json:"totalBaseValue,omitempty"` // value including tokens in base currency
|
||||||
TotalSecondaryValue float64 `json:"totalSecondaryValue,omitempty"` // value including tokens in secondary currency
|
TotalSecondaryValue float64 `json:"totalSecondaryValue,omitempty"` // value including tokens in secondary currency
|
||||||
ContractInfo *bchain.ContractInfo `json:"contractInfo,omitempty"`
|
ContractInfo *bchain.ContractInfo `json:"contractInfo,omitempty"`
|
||||||
|
Erc20Contract *bchain.ContractInfo `json:"erc20Contract,omitempty"` // deprecated
|
||||||
AddressAliases AddressAliasesMap `json:"addressAliases,omitempty"`
|
AddressAliases AddressAliasesMap `json:"addressAliases,omitempty"`
|
||||||
// helpers for explorer
|
// helpers for explorer
|
||||||
Filter string `json:"-"`
|
Filter string `json:"-"`
|
||||||
|
|||||||
@ -1007,6 +1007,7 @@ type ethereumTypeAddressData struct {
|
|||||||
|
|
||||||
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) {
|
||||||
var ba *db.AddrBalance
|
var ba *db.AddrBalance
|
||||||
|
var n uint64
|
||||||
// unknown number of results for paging initially
|
// unknown number of results for paging initially
|
||||||
d := ethereumTypeAddressData{totalResults: -1}
|
d := ethereumTypeAddressData{totalResults: -1}
|
||||||
ca, err := w.db.GetAddrDescContracts(addrDesc)
|
ca, err := w.db.GetAddrDescContracts(addrDesc)
|
||||||
@ -1031,11 +1032,10 @@ func (w *Worker) getEthereumTypeAddressBalances(addrDesc bchain.AddressDescripto
|
|||||||
if b != nil {
|
if b != nil {
|
||||||
ba.BalanceSat = *b
|
ba.BalanceSat = *b
|
||||||
}
|
}
|
||||||
n, err := w.chain.EthereumTypeGetNonce(addrDesc)
|
n, err = w.chain.EthereumTypeGetNonce(addrDesc)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, errors.Annotatef(err, "EthereumTypeGetNonce %v", addrDesc)
|
return nil, nil, errors.Annotatef(err, "EthereumTypeGetNonce %v", addrDesc)
|
||||||
}
|
}
|
||||||
d.nonce = strconv.Itoa(int(n))
|
|
||||||
ticker := w.is.GetCurrentTicker("", "")
|
ticker := w.is.GetCurrentTicker("", "")
|
||||||
if details > AccountDetailsBasic {
|
if details > AccountDetailsBasic {
|
||||||
d.tokens = make([]Token, len(ca.Contracts))
|
d.tokens = make([]Token, len(ca.Contracts))
|
||||||
@ -1089,6 +1089,8 @@ func (w *Worker) getEthereumTypeAddressBalances(addrDesc bchain.AddressDescripto
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// returns 0 for unknown address
|
||||||
|
d.nonce = strconv.Itoa(int(n))
|
||||||
// special handling if filtering for a contract, return the contract details even though the address had no transactions with it
|
// special handling if filtering for a contract, return the contract details even though the address had no transactions with it
|
||||||
if len(d.tokens) == 0 && len(filterDesc) > 0 && details >= AccountDetailsTokens {
|
if len(d.tokens) == 0 && len(filterDesc) > 0 && details >= AccountDetailsTokens {
|
||||||
t, err := w.getEthereumContractBalanceFromBlockchain(addrDesc, filterDesc, details)
|
t, err := w.getEthereumContractBalanceFromBlockchain(addrDesc, filterDesc, details)
|
||||||
@ -1345,6 +1347,10 @@ func (w *Worker) GetAddress(address string, page int, txsOnPage int, option Acco
|
|||||||
Nonce: ed.nonce,
|
Nonce: ed.nonce,
|
||||||
AddressAliases: w.getAddressAliases(addresses),
|
AddressAliases: w.getAddressAliases(addresses),
|
||||||
}
|
}
|
||||||
|
// keep address backward compatible, set deprecated Erc20Contract value if ERC20 token
|
||||||
|
if ed.contractInfo != nil && ed.contractInfo.Type == bchain.ERC20TokenType {
|
||||||
|
r.Erc20Contract = ed.contractInfo
|
||||||
|
}
|
||||||
glog.Info("GetAddress ", address, ", ", time.Since(start))
|
glog.Info("GetAddress ", address, ", ", time.Since(start))
|
||||||
return r, nil
|
return r, nil
|
||||||
}
|
}
|
||||||
|
|||||||
@ -55,7 +55,7 @@ type EthereumInternalData struct {
|
|||||||
Error string
|
Error string
|
||||||
}
|
}
|
||||||
|
|
||||||
// ContractInfo contains info about ERC20 contract
|
// ContractInfo contains info about a contract
|
||||||
type ContractInfo struct {
|
type ContractInfo struct {
|
||||||
Type TokenTypeName `json:"type"`
|
Type TokenTypeName `json:"type"`
|
||||||
Contract string `json:"contract"`
|
Contract string `json:"contract"`
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user