[#4640] Temporary fetch l2 block number for Arbitrum networks separately from BalanceChecker (#4644)

This commit is contained in:
Roman Volosovskyi 2024-01-30 10:09:44 +01:00 committed by GitHub
parent 0808b780f7
commit dad2ec3f66
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 15 additions and 1 deletions

View File

@ -1 +1 @@
0.172.8 0.172.9

View File

@ -20,6 +20,7 @@ import (
"github.com/status-im/status-go/services/wallet/async" "github.com/status-im/status-go/services/wallet/async"
"github.com/status-im/status-go/services/wallet/balance" "github.com/status-im/status-go/services/wallet/balance"
"github.com/status-im/status-go/services/wallet/blockchainstate" "github.com/status-im/status-go/services/wallet/blockchainstate"
walletcommon "github.com/status-im/status-go/services/wallet/common"
"github.com/status-im/status-go/services/wallet/token" "github.com/status-im/status-go/services/wallet/token"
"github.com/status-im/status-go/services/wallet/walletevent" "github.com/status-im/status-go/services/wallet/walletevent"
"github.com/status-im/status-go/transactions" "github.com/status-im/status-go/transactions"
@ -71,6 +72,19 @@ func (c *findNewBlocksCommand) detectTransfers(parent context.Context, accounts
return nil, nil, err return nil, nil, err
} }
networkID := c.chainClient.NetworkID()
// TODO(rasom): remove this as soon as BalanceChecker contract for
// Arbitrum networks will return l2 block number instead of l1
if networkID == walletcommon.ArbitrumMainnet || networkID == walletcommon.ArbitrumGoerli || networkID == walletcommon.ArbitrumSepolia {
header, err := c.chainClient.HeaderByNumber(context.Background(), nil)
if err != nil {
log.Error("findNewBlocksCommand error getting header", "error", err, "chain", c.chainClient.NetworkID())
return nil, nil, err
}
blockNum = header.Number
}
addressesToCheck := []common.Address{} addressesToCheck := []common.Address{}
for idx, account := range accounts { for idx, account := range accounts {
blockRange, err := c.blockRangeDAO.getBlockRange(c.chainClient.NetworkID(), account) blockRange, err := c.blockRangeDAO.getBlockRange(c.chainClient.NetworkID(), account)