Fix contract call for communities
This commit is contained in:
parent
b3a93fff12
commit
8c41678520
|
@ -5,7 +5,6 @@ import (
|
|||
"errors"
|
||||
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
"github.com/ethereum/go-ethereum/ethclient"
|
||||
"github.com/status-im/status-go/contracts/directory"
|
||||
"github.com/status-im/status-go/contracts/ethscan"
|
||||
"github.com/status-im/status-go/contracts/hop"
|
||||
|
@ -159,18 +158,6 @@ func (c *ContractMaker) NewDirectory(chainID uint64) (*directory.Directory, erro
|
|||
)
|
||||
}
|
||||
|
||||
func (c *ContractMaker) NewDirectoryWithBackend(chainID uint64, backend *ethclient.Client) (*directory.Directory, error) {
|
||||
contractAddr, err := directory.ContractAddress(chainID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return directory.NewDirectory(
|
||||
contractAddr,
|
||||
backend,
|
||||
)
|
||||
}
|
||||
|
||||
func (c *ContractMaker) NewEthScan(chainID uint64) (*ethscan.BalanceScanner, error) {
|
||||
contractAddr, err := ethscan.ContractAddress(chainID)
|
||||
if err != nil {
|
||||
|
|
|
@ -1276,6 +1276,8 @@ func (db *Database) GetPath(address types.Address) (path string, err error) {
|
|||
return path, err
|
||||
}
|
||||
|
||||
// NOTE: This should not be used to retrieve `Networks`.
|
||||
// NetworkManager should be used instead, otherwise RPCURL will be empty
|
||||
func (db *Database) GetNodeConfig() (*params.NodeConfig, error) {
|
||||
return nodecfg.GetNodeConfigFromDB(db.db)
|
||||
}
|
||||
|
|
|
@ -18,7 +18,6 @@ import (
|
|||
|
||||
gethcommon "github.com/ethereum/go-ethereum/common"
|
||||
"github.com/ethereum/go-ethereum/common/hexutil"
|
||||
"github.com/ethereum/go-ethereum/ethclient"
|
||||
|
||||
"go.uber.org/zap"
|
||||
|
||||
|
@ -509,30 +508,8 @@ func (m *Messenger) CuratedCommunities() (*communities.KnownCommunitiesResponse,
|
|||
// Revert code to https://github.com/status-im/status-go/blob/e6a3f63ec7f2fa691878ed35f921413dc8acfc66/protocol/messenger_communities.go#L211-L226 once the curated communities contract is deployed to mainnet
|
||||
|
||||
chainID := uint64(420) // Optimism Goerli
|
||||
sDB, err := accounts.NewDB(m.database)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
nodeConfig, err := sDB.GetNodeConfig()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var ethClient *ethclient.Client
|
||||
for _, n := range nodeConfig.Networks {
|
||||
if n.ChainID == chainID {
|
||||
e, err := ethclient.Dial(n.RPCURL)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
ethClient = e
|
||||
}
|
||||
}
|
||||
|
||||
if ethClient == nil {
|
||||
return nil, errors.New("failed to initialize backend before requesting curated communities")
|
||||
}
|
||||
|
||||
directory, err := m.contractMaker.NewDirectoryWithBackend(chainID, ethClient)
|
||||
directory, err := m.contractMaker.NewDirectory(chainID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue