fix_: Fix timestamo integer cast (#5092)
This commit is contained in:
parent
90b18d4f88
commit
eb1ed696f6
|
@ -222,7 +222,10 @@ func (r *Reader) startWalletEventsWatcher() {
|
||||||
|
|
||||||
for _, address := range event.Accounts {
|
for _, address := range event.Accounts {
|
||||||
timestamp, ok := r.lastWalletTokenUpdateTimestamp.Load(address)
|
timestamp, ok := r.lastWalletTokenUpdateTimestamp.Load(address)
|
||||||
timecheck := timestamp.(int64) - activityReloadMarginSeconds
|
timecheck := int64(0)
|
||||||
|
if ok {
|
||||||
|
timecheck = timestamp.(int64) - activityReloadMarginSeconds
|
||||||
|
}
|
||||||
|
|
||||||
if !ok || event.At > timecheck {
|
if !ok || event.At > timecheck {
|
||||||
r.triggerDelayedWalletReload()
|
r.triggerDelayedWalletReload()
|
||||||
|
|
|
@ -14,45 +14,52 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
var coinGeckoMapping = map[string]string{
|
var coinGeckoMapping = map[string]string{
|
||||||
"STT": "status",
|
"STT": "status",
|
||||||
"SNT": "status",
|
"SNT": "status",
|
||||||
"ETH": "ethereum",
|
"ETH": "ethereum",
|
||||||
"AST": "airswap",
|
"AST": "airswap",
|
||||||
"AMB": "",
|
"AMB": "",
|
||||||
"ABT": "arcblock",
|
"ABT": "arcblock",
|
||||||
"ATM": "",
|
"ATM": "",
|
||||||
"BNB": "binancecoin",
|
"BNB": "binancecoin",
|
||||||
"BLT": "bloom",
|
"BLT": "bloom",
|
||||||
"CDT": "",
|
"CDT": "",
|
||||||
"COMP": "compound-coin",
|
"COMP": "compound-coin",
|
||||||
"EDG": "edgeless",
|
"EDG": "edgeless",
|
||||||
"ELF": "",
|
"ELF": "",
|
||||||
"ENG": "enigma",
|
"ENG": "enigma",
|
||||||
"EOS": "eos",
|
"EOS": "eos",
|
||||||
"GEN": "daostack",
|
"GEN": "daostack",
|
||||||
"MANA": "decentraland-wormhole",
|
"MANA": "decentraland-wormhole",
|
||||||
"LEND": "ethlend",
|
"LEND": "ethlend",
|
||||||
"LRC": "loopring",
|
"LRC": "loopring",
|
||||||
"MET": "metronome",
|
"MET": "metronome",
|
||||||
"POLY": "polymath",
|
"POLY": "polymath",
|
||||||
"PPT": "populous",
|
"PPT": "populous",
|
||||||
"SAN": "santiment-network-token",
|
"SAN": "santiment-network-token",
|
||||||
"DNT": "district0x",
|
"DNT": "district0x",
|
||||||
"SPN": "sapien",
|
"SPN": "sapien",
|
||||||
"USDS": "stableusd",
|
"USDS": "stableusd",
|
||||||
"STX": "stox",
|
"STX": "stox",
|
||||||
"SUB": "substratum",
|
"SUB": "substratum",
|
||||||
"PAY": "tenx",
|
"PAY": "tenx",
|
||||||
"GRT": "the-graph",
|
"GRT": "the-graph",
|
||||||
"TNT": "tierion",
|
"TNT": "tierion",
|
||||||
"TRX": "tron",
|
"TRX": "tron",
|
||||||
"TGT": "",
|
"TGT": "",
|
||||||
"RARE": "superrare",
|
"RARE": "superrare",
|
||||||
"UNI": "uniswap",
|
"UNI": "uniswap",
|
||||||
"USDC": "usd-coin",
|
"USDC": "usd-coin",
|
||||||
"USDP": "paxos-standard",
|
"USDP": "paxos-standard",
|
||||||
"VRS": "",
|
"VRS": "",
|
||||||
"TIME": "",
|
"TIME": "",
|
||||||
|
"USDT": "tether",
|
||||||
|
"SHIB": "shiba-inu",
|
||||||
|
"LINK": "chainlink",
|
||||||
|
"MATIC": "matic-network",
|
||||||
|
"DAI": "dai",
|
||||||
|
"ARB": "arbitrum",
|
||||||
|
"OP": "optimism",
|
||||||
}
|
}
|
||||||
|
|
||||||
const baseURL = "https://api.coingecko.com/api/v3/"
|
const baseURL = "https://api.coingecko.com/api/v3/"
|
||||||
|
@ -150,6 +157,7 @@ func (c *Client) mapSymbolsToIds(symbols []string) ([]string, error) {
|
||||||
ids = append(ids, token.ID)
|
ids = append(ids, token.ID)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
ids = utils.RemoveDuplicates(ids)
|
||||||
return ids, nil
|
return ids, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -182,7 +190,7 @@ func (c *Client) FetchPrices(symbols []string, currencies []string) (map[string]
|
||||||
prices := make(map[string]map[string]float64)
|
prices := make(map[string]map[string]float64)
|
||||||
err = json.Unmarshal(body, &prices)
|
err = json.Unmarshal(body, &prices)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, fmt.Errorf("%s - %s", err, string(body))
|
||||||
}
|
}
|
||||||
|
|
||||||
result := make(map[string]map[string]float64)
|
result := make(map[string]map[string]float64)
|
||||||
|
@ -240,7 +248,7 @@ func (c *Client) FetchTokenMarketValues(symbols []string, currency string) (map[
|
||||||
var marketValues []GeckoMarketValues
|
var marketValues []GeckoMarketValues
|
||||||
err = json.Unmarshal(body, &marketValues)
|
err = json.Unmarshal(body, &marketValues)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, fmt.Errorf("%s - %s", err, string(body))
|
||||||
}
|
}
|
||||||
|
|
||||||
result := make(map[string]thirdparty.TokenMarketValues)
|
result := make(map[string]thirdparty.TokenMarketValues)
|
||||||
|
|
|
@ -71,7 +71,7 @@ func (c *Client) FetchPrices(symbols []string, currencies []string) (map[string]
|
||||||
prices := make(map[string]map[string]float64)
|
prices := make(map[string]map[string]float64)
|
||||||
err = json.Unmarshal(body, &prices)
|
err = json.Unmarshal(body, &prices)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, fmt.Errorf("%s - %s", err, string(body))
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, symbol := range smbls {
|
for _, symbol := range smbls {
|
||||||
|
@ -132,8 +132,12 @@ func (c *Client) FetchTokenMarketValues(symbols []string, currency string) (map[
|
||||||
|
|
||||||
container := MarketValuesContainer{}
|
container := MarketValuesContainer{}
|
||||||
err = json.Unmarshal(body, &container)
|
err = json.Unmarshal(body, &container)
|
||||||
|
|
||||||
|
if len(container.Raw) == 0 {
|
||||||
|
return nil, fmt.Errorf("no data found - %s", string(body))
|
||||||
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return item, err
|
return nil, fmt.Errorf("%s - %s", err, string(body))
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, symbol := range smbls {
|
for _, symbol := range smbls {
|
||||||
|
|
|
@ -13,6 +13,18 @@ func RenameSymbols(symbols []string) (renames []string) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func RemoveDuplicates(strings []string) []string {
|
||||||
|
uniqueStrings := make(map[string]bool)
|
||||||
|
var uniqueSlice []string
|
||||||
|
for _, str := range strings {
|
||||||
|
if !uniqueStrings[str] {
|
||||||
|
uniqueStrings[str] = true
|
||||||
|
uniqueSlice = append(uniqueSlice, str)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return uniqueSlice
|
||||||
|
}
|
||||||
|
|
||||||
func GetRealSymbol(symbol string) string {
|
func GetRealSymbol(symbol string) string {
|
||||||
if val, ok := renameMapping[strings.ToUpper(symbol)]; ok {
|
if val, ok := renameMapping[strings.ToUpper(symbol)]; ok {
|
||||||
return val
|
return val
|
||||||
|
|
Loading…
Reference in New Issue