From 633c8d1ed5b5bca965e5d96f8e6a285323d4c2e3 Mon Sep 17 00:00:00 2001 From: Dario Gabriel Lipicar Date: Tue, 18 Apr 2023 11:04:12 -0300 Subject: [PATCH] chore: clean up passing api keys to the wallet service --- node/status_node_services.go | 12 +++--------- services/wallet/service.go | 10 +++------- 2 files changed, 6 insertions(+), 16 deletions(-) diff --git a/node/status_node_services.go b/node/status_node_services.go index a10cdcb4c..01ca67a30 100644 --- a/node/status_node_services.go +++ b/node/status_node_services.go @@ -56,8 +56,6 @@ var ( // ErrRPCClientUnavailable is returned if an RPC client can't be retrieved. // This is a normal situation when a node is stopped. ErrRPCClientUnavailable = errors.New("JSON-RPC client is unavailable") - // OpenseaKeyFromEnv passed from on env var during build time - OpenseaKeyFromEnv string ) func (b *StatusNode) initServices(config *params.NodeConfig, mediaServer *server.MediaServer) error { @@ -132,11 +130,7 @@ func (b *StatusNode) initServices(config *params.NodeConfig, mediaServer *server } if config.WalletConfig.Enabled { - openseaKey := config.WalletConfig.OpenseaAPIKey - if len(openseaKey) == 0 { - openseaKey = OpenseaKeyFromEnv - } - walletService := b.walletService(accDB, accountsFeed, openseaKey, config.WalletConfig.AlchemyAPIKeys, config.WalletConfig.InfuraAPIKey, config.WalletConfig.InfuraAPIKeySecret) + walletService := b.walletService(accDB, accountsFeed) services = append(services, walletService) } @@ -471,7 +465,7 @@ func (b *StatusNode) appmetricsService() common.StatusService { return b.appMetricsSrvc } -func (b *StatusNode) walletService(accountsDB *accounts.Database, accountsFeed *event.Feed, openseaAPIKey string, alchemyAPIKeys map[uint64]string, infuraAPIKey string, infuraAPIKeySecret string) common.StatusService { +func (b *StatusNode) walletService(accountsDB *accounts.Database, accountsFeed *event.Feed) common.StatusService { if b.walletSrvc == nil { var extService *ext.Service if b.WakuV2ExtService() != nil { @@ -480,7 +474,7 @@ func (b *StatusNode) walletService(accountsDB *accounts.Database, accountsFeed * extService = b.WakuExtService().Service } b.walletSrvc = wallet.NewService( - b.appDB, accountsDB, b.rpcClient, accountsFeed, openseaAPIKey, alchemyAPIKeys, infuraAPIKey, infuraAPIKeySecret, b.gethAccountManager, b.transactor, b.config, + b.appDB, accountsDB, b.rpcClient, accountsFeed, b.gethAccountManager, b.transactor, b.config, b.ensService(), b.stickersService(accountsDB), extService, diff --git a/services/wallet/service.go b/services/wallet/service.go index 9a5afe7d3..44d55a746 100644 --- a/services/wallet/service.go +++ b/services/wallet/service.go @@ -42,10 +42,6 @@ func NewService( accountsDB *accounts.Database, rpcClient *rpc.Client, accountFeed *event.Feed, - openseaAPIKey string, - alchemyAPIKeys map[uint64]string, - infuraAPIKey string, - infuraAPIKeySecret string, gethManager *account.GethManager, transactor *transactions.Transactor, config *params.NodeConfig, @@ -98,9 +94,9 @@ func NewService( history := history.NewService(db, walletFeed, rpcClient, tokenManager, marketManager) currency := currency.NewService(db, walletFeed, tokenManager, marketManager) - alchemyClient := alchemy.NewClient(alchemyAPIKeys) - infuraClient := infura.NewClient(infuraAPIKey, infuraAPIKeySecret) - collectiblesManager := collectibles.NewManager(rpcClient, alchemyClient, infuraClient, nftMetadataProvider, openseaAPIKey, walletFeed) + alchemyClient := alchemy.NewClient(config.WalletConfig.AlchemyAPIKeys) + infuraClient := infura.NewClient(config.WalletConfig.InfuraAPIKey, config.WalletConfig.InfuraAPIKeySecret) + collectiblesManager := collectibles.NewManager(rpcClient, alchemyClient, infuraClient, nftMetadataProvider, config.WalletConfig.OpenseaAPIKey, walletFeed) return &Service{ db: db, accountsDB: accountsDB,