From 43056094932b9b15cce5827a19dafc27cf8160a6 Mon Sep 17 00:00:00 2001 From: Mohsen Date: Thu, 14 Nov 2024 16:58:58 +0300 Subject: [PATCH] fix_: hide mercuryo provider --- params/config.go | 15 +++++++++------ protocol/common/feature_flags.go | 3 +++ services/wallet/service.go | 20 ++++++++++++++------ 3 files changed, 26 insertions(+), 12 deletions(-) diff --git a/params/config.go b/params/config.go index 2f256e443..eeca6dacc 100644 --- a/params/config.go +++ b/params/config.go @@ -558,19 +558,22 @@ type WalletConfig struct { StatusProxyEnabled bool `json:"StatusProxyEnabled"` StatusProxyStageName string `json:"StatusProxyStageName"` EnableCelerBridge bool `json:"EnableCelerBridge"` + EnableMercuryoProvider bool `json:"EnableMercuryoProvider"` } // MarshalJSON custom marshalling to avoid exposing sensitive data in log, // there's a function called `startNode` will log NodeConfig which include WalletConfig func (wc WalletConfig) MarshalJSON() ([]byte, error) { return json.Marshal(struct { - Enabled bool `json:"Enabled"` - StatusProxyEnabled bool `json:"StatusProxyEnabled"` - EnableCelerBridge bool `json:"EnableCelerBridge"` + Enabled bool `json:"Enabled"` + StatusProxyEnabled bool `json:"StatusProxyEnabled"` + EnableCelerBridge bool `json:"EnableCelerBridge"` + EnableMercuryoProvider bool `json:"EnableMercuryoProvider"` }{ - Enabled: wc.Enabled, - StatusProxyEnabled: wc.StatusProxyEnabled, - EnableCelerBridge: wc.EnableCelerBridge, + Enabled: wc.Enabled, + StatusProxyEnabled: wc.StatusProxyEnabled, + EnableCelerBridge: wc.EnableCelerBridge, + EnableMercuryoProvider: wc.EnableMercuryoProvider, }) } diff --git a/protocol/common/feature_flags.go b/protocol/common/feature_flags.go index ca787556f..cae98577f 100644 --- a/protocol/common/feature_flags.go +++ b/protocol/common/feature_flags.go @@ -29,4 +29,7 @@ type FeatureFlags struct { // EnableCelerBridge indicates whether we should enable the Celer bridge in the Router EnableCelerBridge bool + + // EnableMercuryoProvider indicates whether we should enable the Mercuryo provider in the Wallet + EnableMercuryoProvider bool } diff --git a/services/wallet/service.go b/services/wallet/service.go index 18582ac78..938b2379b 100644 --- a/services/wallet/service.go +++ b/services/wallet/service.go @@ -106,10 +106,23 @@ func NewService( tokenManager.Start() cryptoOnRampProviders := []onramp.Provider{ - onramp.NewMercuryoProvider(tokenManager), onramp.NewRampProvider(), onramp.NewMoonPayProvider(), } + + featureFlags := &protocolCommon.FeatureFlags{} + if config.WalletConfig.EnableCelerBridge { + featureFlags.EnableCelerBridge = true + } + + if config.WalletConfig.EnableMercuryoProvider { + featureFlags.EnableMercuryoProvider = true + } + + if featureFlags.EnableMercuryoProvider { + cryptoOnRampProviders = append(cryptoOnRampProviders, onramp.NewMercuryoProvider(tokenManager)) + } + cryptoOnRampManager := onramp.NewManager(cryptoOnRampProviders) savedAddressesManager := &SavedAddressesManager{db: db} @@ -184,11 +197,6 @@ func NewService( activity := activity.NewService(db, accountsDB, tokenManager, collectiblesManager, feed, pendingTxManager) - featureFlags := &protocolCommon.FeatureFlags{} - if config.WalletConfig.EnableCelerBridge { - featureFlags.EnableCelerBridge = true - } - router := router.NewRouter(rpcClient, transactor, tokenManager, marketManager, collectibles, collectiblesManager, ens) pathProcessors := buildPathProcessors(rpcClient, transactor, tokenManager, ens, featureFlags)