feat: returns tokens even when error
This commit is contained in:
parent
540001e137
commit
0c8ce79941
|
@ -1593,7 +1593,7 @@ func (m *Manager) getOwnedERC721Tokens(walletAddresses []gethcommon.Address, tok
|
||||||
ownedERC721Tokens := make(map[uint64]map[string][]opensea.Asset)
|
ownedERC721Tokens := make(map[uint64]map[string][]opensea.Asset)
|
||||||
|
|
||||||
for chainID, erc721Tokens := range tokenRequirements {
|
for chainID, erc721Tokens := range tokenRequirements {
|
||||||
client, err := opensea.NewOpenseaClient(chainID, m.walletConfig.OpenseaAPIKey)
|
client, err := opensea.NewOpenseaClient(chainID, m.walletConfig.OpenseaAPIKey, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,10 +4,7 @@ import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"math/big"
|
"math/big"
|
||||||
<<<<<<< HEAD
|
|
||||||
"strings"
|
"strings"
|
||||||
=======
|
|
||||||
>>>>>>> 6fcba6e30 (feat: add buffer for status event)
|
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
@ -175,13 +172,10 @@ func (c *ClientWithFallback) makeCallNoReturn(main func() error, fallback func()
|
||||||
|
|
||||||
err = fallback()
|
err = fallback()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
<<<<<<< HEAD
|
|
||||||
if isVMError(err) {
|
if isVMError(err) {
|
||||||
resultChan <- CommandResult{vmError: err}
|
resultChan <- CommandResult{vmError: err}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
=======
|
|
||||||
>>>>>>> fdaa1ce1b (fix: set is connected for chain without fallback)
|
|
||||||
c.setIsConnected(false)
|
c.setIsConnected(false)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -218,7 +212,9 @@ func (c *ClientWithFallback) makeCallSingleReturn(main func() (any, error), fall
|
||||||
return nil
|
return nil
|
||||||
}, func(err error) error {
|
}, func(err error) error {
|
||||||
if c.fallback == nil {
|
if c.fallback == nil {
|
||||||
c.setIsConnected(false)
|
if toggleIsConnected {
|
||||||
|
c.setIsConnected(false)
|
||||||
|
}
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -204,6 +204,7 @@ func (r *Reader) GetWalletToken(ctx context.Context, addresses []common.Address)
|
||||||
group.Add(func(parent context.Context) error {
|
group.Add(func(parent context.Context) error {
|
||||||
balances, err = r.tokenManager.GetBalancesByChain(ctx, clients, addresses, tokenAddresses)
|
balances, err = r.tokenManager.GetBalancesByChain(ctx, clients, addresses, tokenAddresses)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
log.Info("tokenManager.GetBalancesByChain err", err)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
@ -215,10 +216,6 @@ func (r *Reader) GetWalletToken(ctx context.Context, addresses []common.Address)
|
||||||
return nil, ctx.Err()
|
return nil, ctx.Err()
|
||||||
}
|
}
|
||||||
err = group.Error()
|
err = group.Error()
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
result := make(map[common.Address][]Token)
|
result := make(map[common.Address][]Token)
|
||||||
for _, address := range addresses {
|
for _, address := range addresses {
|
||||||
for symbol, tokens := range getTokenBySymbols(allTokens) {
|
for symbol, tokens := range getTokenBySymbols(allTokens) {
|
||||||
|
@ -235,7 +232,7 @@ func (r *Reader) GetWalletToken(ctx context.Context, addresses []common.Address)
|
||||||
}
|
}
|
||||||
hasError := false
|
hasError := false
|
||||||
if client, ok := clients[token.ChainID]; ok {
|
if client, ok := clients[token.ChainID]; ok {
|
||||||
hasError = !client.IsConnected
|
hasError = err != nil || !client.IsConnected
|
||||||
}
|
}
|
||||||
balancesPerChain[token.ChainID] = ChainBalance{
|
balancesPerChain[token.ChainID] = ChainBalance{
|
||||||
Balance: balance,
|
Balance: balance,
|
||||||
|
|
|
@ -245,11 +245,6 @@ func NewOpenseaClient(chainID uint64, apiKey string, feed *event.Feed) (*Client,
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if client, ok := OpenseaClientInstances[chainID]; ok {
|
|
||||||
if client.apiKey == tmpAPIKey {
|
|
||||||
return client, nil
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
openseaClient := &Client{
|
openseaClient := &Client{
|
||||||
client: OpenseaHTTPClient,
|
client: OpenseaHTTPClient,
|
||||||
|
@ -272,12 +267,14 @@ func (o *Client) setIsConnected(value bool) {
|
||||||
if value {
|
if value {
|
||||||
message = "up"
|
message = "up"
|
||||||
}
|
}
|
||||||
o.feed.Send(walletevent.Event{
|
if o.feed != nil {
|
||||||
Type: EventCollectibleStatusChanged,
|
o.feed.Send(walletevent.Event{
|
||||||
Accounts: []common.Address{},
|
Type: EventCollectibleStatusChanged,
|
||||||
Message: message,
|
Accounts: []common.Address{},
|
||||||
At: time.Now().Unix(),
|
Message: message,
|
||||||
})
|
At: time.Now().Unix(),
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
o.IsConnected = value
|
o.IsConnected = value
|
||||||
}
|
}
|
||||||
|
|
|
@ -677,7 +677,6 @@ func (tm *Manager) GetBalancesByChain(parent context.Context, clients map[uint64
|
||||||
Context: ctx,
|
Context: ctx,
|
||||||
}, accounts)
|
}, accounts)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
||||||
log.Error("can't fetch chain balance", err)
|
log.Error("can't fetch chain balance", err)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -702,7 +701,6 @@ func (tm *Manager) GetBalancesByChain(parent context.Context, clients map[uint64
|
||||||
Context: ctx,
|
Context: ctx,
|
||||||
}, account, chunk)
|
}, account, chunk)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
||||||
log.Error("can't fetch erc20 token balance", "account", account, "error", err)
|
log.Error("can't fetch erc20 token balance", "account", account, "error", err)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue