From c040cc753e387739ba687deb8e7cb15975178e3c Mon Sep 17 00:00:00 2001 From: saledjenic <86303051+saledjenic@users.noreply.github.com> Date: Thu, 31 Oct 2024 12:53:28 +0100 Subject: [PATCH] chore(wallet)_: router tx improvements (#6020) * chore(wallet)_: stickers service removed from the router, not needed after recent changes * chore(wallet)_: missed check for error added to few processors --- node/status_node_services.go | 1 - services/wallet/api_test.go | 2 +- services/wallet/keycard_pairings_test.go | 2 +- .../pathprocessor/processor_bridge_celar.go | 3 +++ .../pathprocessor/processor_bridge_hop.go | 3 +++ .../pathprocessor/processor_stickers_buy.go | 11 ++++------- services/wallet/router/router.go | 5 +---- services/wallet/router/router_test.go | 4 ++-- services/wallet/service.go | 19 ++++++++----------- 9 files changed, 23 insertions(+), 27 deletions(-) diff --git a/node/status_node_services.go b/node/status_node_services.go index 48406c055..ee76a8354 100644 --- a/node/status_node_services.go +++ b/node/status_node_services.go @@ -594,7 +594,6 @@ func (b *StatusNode) walletService(accountsDB *accounts.Database, appDB *sql.DB, b.walletSrvc = wallet.NewService( b.walletDB, accountsDB, appDB, b.rpcClient, accountsFeed, settingsFeed, b.gethAccountManager, b.transactor, b.config, b.ensService(b.timeSourceNow()), - b.stickersService(accountsDB), b.pendingTracker, walletFeed, b.httpServer, diff --git a/services/wallet/api_test.go b/services/wallet/api_test.go index bea442534..dd41ce9a5 100644 --- a/services/wallet/api_test.go +++ b/services/wallet/api_test.go @@ -159,7 +159,7 @@ func TestAPI_GetAddressDetails(t *testing.T) { chainClient.SetWalletNotifier(func(chainID uint64, message string) {}) c.SetWalletNotifier(func(chainID uint64, message string) {}) - service := NewService(db, accountsDb, appDB, c, accountFeed, nil, nil, nil, ¶ms.NodeConfig{}, nil, nil, nil, nil, nil, "") + service := NewService(db, accountsDb, appDB, c, accountFeed, nil, nil, nil, ¶ms.NodeConfig{}, nil, nil, nil, nil, "") api := &API{ s: service, diff --git a/services/wallet/keycard_pairings_test.go b/services/wallet/keycard_pairings_test.go index df1b200ff..44466e4cc 100644 --- a/services/wallet/keycard_pairings_test.go +++ b/services/wallet/keycard_pairings_test.go @@ -29,7 +29,7 @@ func TestKeycardPairingsFile(t *testing.T) { accountFeed := &event.Feed{} - service := NewService(db, accountsDb, appDB, &rpc.Client{NetworkManager: network.NewManager(db)}, accountFeed, nil, nil, nil, ¶ms.NodeConfig{}, nil, nil, nil, nil, nil, "") + service := NewService(db, accountsDb, appDB, &rpc.Client{NetworkManager: network.NewManager(db)}, accountFeed, nil, nil, nil, ¶ms.NodeConfig{}, nil, nil, nil, nil, "") data, err := service.KeycardPairings().GetPairingsJSONFileContent() require.NoError(t, err) diff --git a/services/wallet/router/pathprocessor/processor_bridge_celar.go b/services/wallet/router/pathprocessor/processor_bridge_celar.go index 5811c26e5..a4941a8aa 100644 --- a/services/wallet/router/pathprocessor/processor_bridge_celar.go +++ b/services/wallet/router/pathprocessor/processor_bridge_celar.go @@ -443,6 +443,9 @@ func (s *CelerBridgeProcessor) BuildTransaction(sendArgs *MultipathProcessorTxAr func (s *CelerBridgeProcessor) BuildTransactionV2(sendArgs *transactions.SendTxArgs, lastUsedNonce int64) (*ethTypes.Transaction, uint64, error) { tx, err := s.sendOrBuildV2(sendArgs, nil, lastUsedNonce) + if err != nil { + return nil, 0, createBridgeCellerErrorResponse(err) + } return tx, tx.Nonce(), err } diff --git a/services/wallet/router/pathprocessor/processor_bridge_hop.go b/services/wallet/router/pathprocessor/processor_bridge_hop.go index eee493579..22e1eab78 100644 --- a/services/wallet/router/pathprocessor/processor_bridge_hop.go +++ b/services/wallet/router/pathprocessor/processor_bridge_hop.go @@ -432,6 +432,9 @@ func (h *HopBridgeProcessor) BuildTransaction(sendArgs *MultipathProcessorTxArgs func (h *HopBridgeProcessor) BuildTransactionV2(sendArgs *transactions.SendTxArgs, lastUsedNonce int64) (*ethTypes.Transaction, uint64, error) { tx, err := h.sendOrBuildV2(sendArgs, nil, lastUsedNonce) + if err != nil { + return nil, 0, createBridgeHopErrorResponse(err) + } return tx, tx.Nonce(), createBridgeHopErrorResponse(err) } diff --git a/services/wallet/router/pathprocessor/processor_stickers_buy.go b/services/wallet/router/pathprocessor/processor_stickers_buy.go index d723e33b2..40c717ded 100644 --- a/services/wallet/router/pathprocessor/processor_stickers_buy.go +++ b/services/wallet/router/pathprocessor/processor_stickers_buy.go @@ -16,24 +16,21 @@ import ( stickersContracts "github.com/status-im/status-go/contracts/stickers" "github.com/status-im/status-go/eth-node/types" "github.com/status-im/status-go/rpc" - "github.com/status-im/status-go/services/stickers" walletCommon "github.com/status-im/status-go/services/wallet/common" "github.com/status-im/status-go/transactions" ) type StickersBuyProcessor struct { - contractMaker *contracts.ContractMaker - transactor transactions.TransactorIface - stickersService *stickers.Service + contractMaker *contracts.ContractMaker + transactor transactions.TransactorIface } -func NewStickersBuyProcessor(rpcClient *rpc.Client, transactor transactions.TransactorIface, stickersService *stickers.Service) *StickersBuyProcessor { +func NewStickersBuyProcessor(rpcClient *rpc.Client, transactor transactions.TransactorIface) *StickersBuyProcessor { return &StickersBuyProcessor{ contractMaker: &contracts.ContractMaker{ RPCClient: rpcClient, }, - transactor: transactor, - stickersService: stickersService, + transactor: transactor, } } diff --git a/services/wallet/router/router.go b/services/wallet/router/router.go index 1dd4993fb..2d462a27e 100644 --- a/services/wallet/router/router.go +++ b/services/wallet/router/router.go @@ -17,7 +17,6 @@ import ( "github.com/status-im/status-go/params" "github.com/status-im/status-go/rpc" "github.com/status-im/status-go/services/ens" - "github.com/status-im/status-go/services/stickers" "github.com/status-im/status-go/services/wallet/async" "github.com/status-im/status-go/services/wallet/collectibles" walletCommon "github.com/status-im/status-go/services/wallet/common" @@ -70,7 +69,6 @@ type Router struct { collectiblesService *collectibles.Service collectiblesManager *collectibles.Manager ensService *ens.Service - stickersService *stickers.Service feesManager *fees.FeeManager pathProcessors map[string]pathprocessor.PathProcessor scheduler *async.Scheduler @@ -90,7 +88,7 @@ type Router struct { } 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) *Router { processors := make(map[string]pathprocessor.PathProcessor) return &Router{ @@ -100,7 +98,6 @@ func NewRouter(rpcClient *rpc.Client, transactor *transactions.Transactor, token collectiblesService: collectibles, collectiblesManager: collectiblesManager, ensService: ensService, - stickersService: stickersService, feesManager: &fees.FeeManager{ RPCClient: rpcClient, }, diff --git a/services/wallet/router/router_test.go b/services/wallet/router/router_test.go index ac36ede5e..8dd1b5b70 100644 --- a/services/wallet/router/router_test.go +++ b/services/wallet/router/router_test.go @@ -101,7 +101,7 @@ func setupRouter(t *testing.T) (*Router, func()) { } client, _ := rpc.NewClient(config) - router := NewRouter(client, nil, nil, nil, nil, nil, nil, nil) + router := NewRouter(client, nil, nil, nil, nil, nil, nil) transfer := pathprocessor.NewTransferProcessor(nil, nil) router.AddPathProcessor(transfer) @@ -127,7 +127,7 @@ func setupRouter(t *testing.T) (*Router, func()) { ensPublicKey := pathprocessor.NewENSPublicKeyProcessor(nil, nil, nil) router.AddPathProcessor(ensPublicKey) - buyStickers := pathprocessor.NewStickersBuyProcessor(nil, nil, nil) + buyStickers := pathprocessor.NewStickersBuyProcessor(nil, nil) router.AddPathProcessor(buyStickers) return router, cleanTmpDb diff --git a/services/wallet/service.go b/services/wallet/service.go index fb5e37a0f..0148a04f5 100644 --- a/services/wallet/service.go +++ b/services/wallet/service.go @@ -20,7 +20,6 @@ import ( "github.com/status-im/status-go/rpc" "github.com/status-im/status-go/server" "github.com/status-im/status-go/services/ens" - "github.com/status-im/status-go/services/stickers" "github.com/status-im/status-go/services/wallet/activity" "github.com/status-im/status-go/services/wallet/balance" "github.com/status-im/status-go/services/wallet/blockchainstate" @@ -61,7 +60,6 @@ func NewService( transactor *transactions.Transactor, config *params.NodeConfig, ens *ens.Service, - stickers *stickers.Service, pendingTxManager *transactions.PendingTxTracker, feed *event.Feed, mediaServer *server.MediaServer, @@ -192,8 +190,8 @@ func NewService( } router := router.NewRouter(rpcClient, transactor, tokenManager, marketManager, collectibles, - collectiblesManager, ens, stickers) - pathProcessors := buildPathProcessors(rpcClient, transactor, tokenManager, ens, stickers, featureFlags) + collectiblesManager, ens) + pathProcessors := buildPathProcessors(rpcClient, transactor, tokenManager, ens, featureFlags) for _, processor := range pathProcessors { router.AddPathProcessor(processor) } @@ -217,7 +215,6 @@ func NewService( marketManager: marketManager, transactor: transactor, ens: ens, - stickers: stickers, feed: feed, signals: signals, reader: reader, @@ -239,7 +236,6 @@ func buildPathProcessors( transactor *transactions.Transactor, tokenManager *token.Manager, ens *ens.Service, - stickers *stickers.Service, featureFlags *protocolCommon.FeatureFlags, ) []pathprocessor.PathProcessor { ret := make([]pathprocessor.PathProcessor, 0) @@ -271,6 +267,12 @@ func buildPathProcessors( ensRelease := pathprocessor.NewENSReleaseProcessor(rpcClient, transactor, ens) ret = append(ret, ensRelease) + ensPublicKey := pathprocessor.NewENSPublicKeyProcessor(rpcClient, transactor, ens) + ret = append(ret, ensPublicKey) + + buyStickers := pathprocessor.NewStickersBuyProcessor(rpcClient, transactor) + ret = append(ret, buyStickers) + return ret } @@ -293,7 +295,6 @@ type Service struct { gethManager *account.GethManager transactor *transactions.Transactor ens *ens.Service - stickers *stickers.Service feed *event.Feed signals *walletevent.SignalsTransmitter reader *Reader @@ -402,7 +403,3 @@ func (s *Service) GetCollectiblesManager() *collectibles.Manager { func (s *Service) GetEnsService() *ens.Service { return s.ens } - -func (s *Service) GetStickersService() *stickers.Service { - return s.stickers -}