fix: token override when scanning (#2910)

This commit is contained in:
Anthony Laibe 2022-10-24 08:45:14 +02:00 committed by GitHub
parent bef211b5d6
commit 37c9eb1a9d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 1 deletions

View File

@ -1,6 +1,9 @@
package contracts
import (
"context"
"errors"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/ethclient"
"github.com/status-im/status-go/contracts/directory"
@ -159,6 +162,15 @@ func (c *ContractMaker) NewEthScan(chainID uint64) (*ethscan.BalanceScanner, err
return nil, err
}
bytecode, err := backend.CodeAt(context.Background(), contractAddr, nil)
if err != nil {
return nil, err
}
if len(bytecode) == 0 {
return nil, errors.New("is not a contract")
}
return ethscan.NewBalanceScanner(
contractAddr,
backend,

View File

@ -47,13 +47,13 @@ func NewTokenManager(
networkManager *network.Manager,
) *TokenManager {
tokenManager := &TokenManager{db, RPCClient, networkManager}
// Check the networks' custom tokens to see if we must update the tokenStore
networks := networkManager.GetConfiguredNetworks()
for _, network := range networks {
if len(network.TokenOverrides) == 0 {
continue
}
for _, overrideToken := range network.TokenOverrides {
tokensMap, ok := tokenStore[network.ChainID]
if !ok {