diff --git a/params/config.go b/params/config.go index 9bfdc3ab4..74f4cf9ba 100644 --- a/params/config.go +++ b/params/config.go @@ -543,6 +543,7 @@ type WalletConfig struct { AlchemyAPIKeys map[uint64]string `json:"AlchemyAPIKeys"` InfuraAPIKey string `json:"InfuraAPIKey"` InfuraAPIKeySecret string `json:"InfuraAPIKeySecret"` + EnableCelerBridge bool `json:"EnableCelerBridge"` } // LocalNotificationsConfig extra configuration for localnotifications.Service. diff --git a/protocol/common/feature_flags.go b/protocol/common/feature_flags.go index daf4960a8..ca787556f 100644 --- a/protocol/common/feature_flags.go +++ b/protocol/common/feature_flags.go @@ -26,4 +26,7 @@ type FeatureFlags struct { // Peersyncing indicates whether we should advertise and sync messages with other peers Peersyncing bool + + // EnableCelerBridge indicates whether we should enable the Celer bridge in the Router + EnableCelerBridge bool } diff --git a/services/wallet/api.go b/services/wallet/api.go index 907238105..8ba2c3fdf 100644 --- a/services/wallet/api.go +++ b/services/wallet/api.go @@ -37,7 +37,7 @@ import ( func NewAPI(s *Service) *API { router := router.NewRouter(s.GetRPCClient(), s.GetTransactor(), s.GetTokenManager(), s.GetMarketManager(), s.GetCollectiblesService(), - s.GetCollectiblesManager(), s.GetEnsService(), s.GetStickersService()) + s.GetCollectiblesManager(), s.GetEnsService(), s.GetStickersService(), s.FeatureFlags()) return &API{s, s.reader, router} } diff --git a/services/wallet/router/router.go b/services/wallet/router/router.go index b8eddb229..95fb03194 100644 --- a/services/wallet/router/router.go +++ b/services/wallet/router/router.go @@ -18,6 +18,7 @@ import ( gaspriceoracle "github.com/status-im/status-go/contracts/gas-price-oracle" "github.com/status-im/status-go/contracts/ierc20" "github.com/status-im/status-go/params" + protocolCommon "github.com/status-im/status-go/protocol/common" "github.com/status-im/status-go/rpc" "github.com/status-im/status-go/services/ens" "github.com/status-im/status-go/services/stickers" @@ -275,12 +276,12 @@ func newSuggestedRoutes( } func NewRouter(rpcClient *rpc.Client, transactor *transactions.Transactor, tokenManager *token.Manager, marketManager *market.Manager, - collectibles *collectibles.Service, collectiblesManager *collectibles.Manager, ensService *ens.Service, stickersService *stickers.Service) *Router { + collectibles *collectibles.Service, collectiblesManager *collectibles.Manager, ensService *ens.Service, stickersService *stickers.Service, + featureFlags *protocolCommon.FeatureFlags) *Router { processors := make(map[string]pathprocessor.PathProcessor) transfer := pathprocessor.NewTransferProcessor(rpcClient, transactor) erc721Transfer := pathprocessor.NewERC721Processor(rpcClient, transactor) erc1155Transfer := pathprocessor.NewERC1155Processor(rpcClient, transactor) - cbridge := pathprocessor.NewCelerBridgeProcessor(rpcClient, transactor, tokenManager) hop := pathprocessor.NewHopBridgeProcessor(rpcClient, transactor, tokenManager) paraswap := pathprocessor.NewSwapParaswapProcessor(rpcClient, transactor, tokenManager) ensRegister := pathprocessor.NewENSRegisterProcessor(rpcClient, transactor, ensService) @@ -291,7 +292,6 @@ func NewRouter(rpcClient *rpc.Client, transactor *transactions.Transactor, token processors[transfer.Name()] = transfer processors[erc721Transfer.Name()] = erc721Transfer processors[hop.Name()] = hop - processors[cbridge.Name()] = cbridge processors[erc1155Transfer.Name()] = erc1155Transfer processors[paraswap.Name()] = paraswap processors[ensRegister.Name()] = ensRegister @@ -299,6 +299,12 @@ func NewRouter(rpcClient *rpc.Client, transactor *transactions.Transactor, token processors[ensPublicKey.Name()] = ensPublicKey processors[buyStickers.Name()] = buyStickers + if featureFlags.EnableCelerBridge { + // TODO: Celar Bridge is out of scope for 2.30, check it thoroughly once we decide to include it again + cbridge := pathprocessor.NewCelerBridgeProcessor(rpcClient, transactor, tokenManager) + processors[cbridge.Name()] = cbridge + } + return &Router{ rpcClient: rpcClient, tokenManager: tokenManager, @@ -309,6 +315,7 @@ func NewRouter(rpcClient *rpc.Client, transactor *transactions.Transactor, token stickersService: stickersService, feesManager: &FeeManager{rpcClient}, pathProcessors: processors, + featureFlags: featureFlags, } } @@ -340,6 +347,7 @@ type Router struct { stickersService *stickers.Service feesManager *FeeManager pathProcessors map[string]pathprocessor.PathProcessor + featureFlags *protocolCommon.FeatureFlags } func (r *Router) requireApproval(ctx context.Context, sendType SendType, approvalContractAddress *common.Address, account common.Address, network *params.Network, token *token.Token, amountIn *big.Int) ( diff --git a/services/wallet/service.go b/services/wallet/service.go index 196f35526..180d0de6d 100644 --- a/services/wallet/service.go +++ b/services/wallet/service.go @@ -15,6 +15,7 @@ import ( "github.com/status-im/status-go/account" "github.com/status-im/status-go/multiaccounts/accounts" "github.com/status-im/status-go/params" + protocolCommon "github.com/status-im/status-go/protocol/common" "github.com/status-im/status-go/rpc" "github.com/status-im/status-go/server" "github.com/status-im/status-go/services/ens" @@ -170,6 +171,11 @@ func NewService( activity := activity.NewService(db, accountsDB, tokenManager, collectiblesManager, feed, pendingTxManager) + featureFlags := &protocolCommon.FeatureFlags{} + if config.WalletConfig.EnableCelerBridge { + featureFlags.EnableCelerBridge = true + } + return &Service{ db: db, accountsDB: accountsDB, @@ -198,6 +204,7 @@ func NewService( blockChainState: blockChainState, keycardPairings: NewKeycardPairings(), config: config, + featureFlags: featureFlags, } } @@ -231,6 +238,7 @@ type Service struct { blockChainState *blockchainstate.BlockChainState keycardPairings *KeycardPairings config *params.NodeConfig + featureFlags *protocolCommon.FeatureFlags } // Start signals transmitter. @@ -294,6 +302,10 @@ func (s *Service) Config() *params.NodeConfig { return s.config } +func (s *Service) FeatureFlags() *protocolCommon.FeatureFlags { + return s.featureFlags +} + func (s *Service) GetRPCClient() *rpc.Client { return s.rpcClient }