Use NewContractMaker for messenger
This commit is contained in:
parent
6f4f57b7a8
commit
4fba5647d1
|
@ -23,6 +23,13 @@ type ContractMaker struct {
|
|||
RPCClient *rpc.Client
|
||||
}
|
||||
|
||||
func NewContractMaker(client *rpc.Client) (*ContractMaker, error) {
|
||||
if client == nil {
|
||||
return nil, errors.New("could not initialize ContractMaker with an rpc client")
|
||||
}
|
||||
return &ContractMaker{RPCClient: client}, nil
|
||||
}
|
||||
|
||||
func (c *ContractMaker) NewRegistryWithAddress(chainID uint64, address common.Address) (*resolver.ENSRegistryWithFallback, error) {
|
||||
backend, err := c.RPCClient.EthClient(chainID)
|
||||
if err != nil {
|
||||
|
|
|
@ -518,9 +518,6 @@ func NewMessenger(
|
|||
}{wait: make(chan struct{})},
|
||||
browserDatabase: c.browserDatabase,
|
||||
httpServer: c.httpServer,
|
||||
contractMaker: &contracts.ContractMaker{
|
||||
RPCClient: c.rpcClient,
|
||||
},
|
||||
shutdownTasks: []func() error{
|
||||
ensVerifier.Stop,
|
||||
pushNotificationClient.Stop,
|
||||
|
@ -547,6 +544,15 @@ func NewMessenger(
|
|||
logger: logger,
|
||||
savedAddressesManager: savedAddressesManager,
|
||||
}
|
||||
|
||||
if c.rpcClient != nil {
|
||||
contractMaker, err := contracts.NewContractMaker(c.rpcClient)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
messenger.contractMaker = contractMaker
|
||||
}
|
||||
|
||||
messenger.mentionsManager = NewMentionManager(messenger)
|
||||
|
||||
if c.walletService != nil {
|
||||
|
|
|
@ -505,6 +505,11 @@ func (m *Messenger) startCuratedCommunitiesUpdateLoop() {
|
|||
}
|
||||
|
||||
func (m *Messenger) CuratedCommunities() (*communities.KnownCommunitiesResponse, error) {
|
||||
if m.contractMaker == nil {
|
||||
m.logger.Warn("contract maker not initialized")
|
||||
return nil, errors.New("contract maker not initialized")
|
||||
}
|
||||
|
||||
// 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
|
||||
|
|
|
@ -373,7 +373,10 @@ func (r *Router) requireApproval(ctx context.Context, bridge bridge.Bridge, acco
|
|||
if token.IsNative() {
|
||||
return false, nil, 0, nil, nil
|
||||
}
|
||||
contractMaker := &contracts.ContractMaker{RPCClient: r.rpcClient}
|
||||
contractMaker, err := contracts.NewContractMaker(r.rpcClient)
|
||||
if err != nil {
|
||||
return false, nil, 0, nil, err
|
||||
}
|
||||
|
||||
bridgeAddress := bridge.GetContractAddress(network, token)
|
||||
if bridgeAddress == nil {
|
||||
|
|
|
@ -568,7 +568,10 @@ func (tm *Manager) GetBalances(parent context.Context, clients map[uint64]*chain
|
|||
response[account][token] = &sumHex
|
||||
mu.Unlock()
|
||||
}
|
||||
contractMaker := contracts.ContractMaker{RPCClient: tm.RPCClient}
|
||||
contractMaker, err := contracts.NewContractMaker(tm.RPCClient)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
for clientIdx := range clients {
|
||||
client := clients[clientIdx]
|
||||
|
||||
|
@ -703,7 +706,10 @@ func (tm *Manager) GetBalancesByChain(parent context.Context, clients map[uint64
|
|||
mu.Unlock()
|
||||
}
|
||||
|
||||
contractMaker := contracts.ContractMaker{RPCClient: tm.RPCClient}
|
||||
contractMaker, err := contracts.NewContractMaker(tm.RPCClient)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
for clientIdx := range clients {
|
||||
client := clients[clientIdx]
|
||||
ethScanContract, err := contractMaker.NewEthScan(client.ChainID)
|
||||
|
|
Loading…
Reference in New Issue