From 47c699e61b526683af8aeeb30b2666973b7ef9d6 Mon Sep 17 00:00:00 2001 From: istae <14264581+istae@users.noreply.github.com> Date: Tue, 24 Dec 2024 17:44:37 +0300 Subject: [PATCH] Reverts "get wallet endpoint available if swap not enabled" (#4938) --- pkg/api/router.go | 1 + pkg/api/router_test.go | 2 +- pkg/node/node.go | 20 ++++++++++---------- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/pkg/api/router.go b/pkg/api/router.go index 8cffd8ac32e..d2f8fdb0c68 100644 --- a/pkg/api/router.go +++ b/pkg/api/router.go @@ -532,6 +532,7 @@ func (s *Service) mountBusinessDebug() { handle("/wallet", web.ChainHandlers( s.checkChequebookAvailability, + s.checkSwapAvailability, web.FinalHandler(jsonhttp.MethodHandler{ "GET": http.HandlerFunc(s.walletHandler), }), diff --git a/pkg/api/router_test.go b/pkg/api/router_test.go index 99382427c22..71d3c8b56ce 100644 --- a/pkg/api/router_test.go +++ b/pkg/api/router_test.go @@ -289,7 +289,7 @@ func TestEndpointOptions(t *testing.T) { {"/chequebook/address", []string{"GET"}, http.StatusNoContent}, {"/chequebook/deposit", []string{"POST"}, http.StatusNoContent}, {"/chequebook/withdraw", []string{"POST"}, http.StatusNoContent}, - {"/wallet", []string{"GET"}, http.StatusNoContent}, + {"/wallet", nil, http.StatusNotImplemented}, {"/wallet/withdraw/{coin}", nil, http.StatusNotImplemented}, {"/stamps", []string{"GET"}, http.StatusNoContent}, {"/stamps/{batch_id}", []string{"GET"}, http.StatusNoContent}, diff --git a/pkg/node/node.go b/pkg/node/node.go index 2cda81da54f..a9cbcf10580 100644 --- a/pkg/node/node.go +++ b/pkg/node/node.go @@ -492,19 +492,19 @@ func NewBee( } } - chequebookFactory, err = InitChequebookFactory(logger, chainBackend, chainID, transactionService, o.SwapFactoryAddress) - if err != nil { - return nil, err - } + if o.SwapEnable { + chequebookFactory, err = InitChequebookFactory(logger, chainBackend, chainID, transactionService, o.SwapFactoryAddress) + if err != nil { + return nil, err + } - erc20Address, err := chequebookFactory.ERC20Address(ctx) - if err != nil { - return nil, fmt.Errorf("factory fail: %w", err) - } + erc20Address, err := chequebookFactory.ERC20Address(ctx) + if err != nil { + return nil, fmt.Errorf("factory fail: %w", err) + } - erc20Service = erc20.New(transactionService, erc20Address) + erc20Service = erc20.New(transactionService, erc20Address) - if o.SwapEnable { if o.ChequebookEnable && chainEnabled { chequebookService, err = InitChequebookService( ctx,