feat: returns tokens even when error

This commit is contained in:
Anthony Laibe 2023-03-30 14:54:55 +02:00 committed by Anthony Laibe
parent 540001e137
commit 0c8ce79941
5 changed files with 14 additions and 26 deletions

View File

@ -1593,7 +1593,7 @@ func (m *Manager) getOwnedERC721Tokens(walletAddresses []gethcommon.Address, tok
ownedERC721Tokens := make(map[uint64]map[string][]opensea.Asset)
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 {
return nil, err
}

View File

@ -4,10 +4,7 @@ import (
"context"
"fmt"
"math/big"
<<<<<<< HEAD
"strings"
=======
>>>>>>> 6fcba6e30 (feat: add buffer for status event)
"sync"
"time"
@ -175,13 +172,10 @@ func (c *ClientWithFallback) makeCallNoReturn(main func() error, fallback func()
err = fallback()
if err != nil {
<<<<<<< HEAD
if isVMError(err) {
resultChan <- CommandResult{vmError: err}
return nil
}
=======
>>>>>>> fdaa1ce1b (fix: set is connected for chain without fallback)
c.setIsConnected(false)
return err
}
@ -218,7 +212,9 @@ func (c *ClientWithFallback) makeCallSingleReturn(main func() (any, error), fall
return nil
}, func(err error) error {
if c.fallback == nil {
if toggleIsConnected {
c.setIsConnected(false)
}
return err
}

View File

@ -204,6 +204,7 @@ func (r *Reader) GetWalletToken(ctx context.Context, addresses []common.Address)
group.Add(func(parent context.Context) error {
balances, err = r.tokenManager.GetBalancesByChain(ctx, clients, addresses, tokenAddresses)
if err != nil {
log.Info("tokenManager.GetBalancesByChain err", err)
return err
}
return nil
@ -215,10 +216,6 @@ func (r *Reader) GetWalletToken(ctx context.Context, addresses []common.Address)
return nil, ctx.Err()
}
err = group.Error()
if err != nil {
return nil, err
}
result := make(map[common.Address][]Token)
for _, address := range addresses {
for symbol, tokens := range getTokenBySymbols(allTokens) {
@ -235,7 +232,7 @@ func (r *Reader) GetWalletToken(ctx context.Context, addresses []common.Address)
}
hasError := false
if client, ok := clients[token.ChainID]; ok {
hasError = !client.IsConnected
hasError = err != nil || !client.IsConnected
}
balancesPerChain[token.ChainID] = ChainBalance{
Balance: balance,

View File

@ -245,11 +245,6 @@ func NewOpenseaClient(chainID uint64, apiKey string, feed *event.Feed) (*Client,
if err != nil {
return nil, err
}
if client, ok := OpenseaClientInstances[chainID]; ok {
if client.apiKey == tmpAPIKey {
return client, nil
}
}
openseaClient := &Client{
client: OpenseaHTTPClient,
@ -272,6 +267,7 @@ func (o *Client) setIsConnected(value bool) {
if value {
message = "up"
}
if o.feed != nil {
o.feed.Send(walletevent.Event{
Type: EventCollectibleStatusChanged,
Accounts: []common.Address{},
@ -279,6 +275,7 @@ func (o *Client) setIsConnected(value bool) {
At: time.Now().Unix(),
})
}
}
o.IsConnected = value
}
func (o *Client) FetchAllCollectionsByOwner(owner common.Address) ([]OwnedCollection, error) {

View File

@ -677,7 +677,6 @@ func (tm *Manager) GetBalancesByChain(parent context.Context, clients map[uint64
Context: ctx,
}, accounts)
if err != nil {
log.Error("can't fetch chain balance", err)
return nil
}
@ -702,7 +701,6 @@ func (tm *Manager) GetBalancesByChain(parent context.Context, clients map[uint64
Context: ctx,
}, account, chunk)
if err != nil {
log.Error("can't fetch erc20 token balance", "account", account, "error", err)
return nil
}