github.com/NpoolPlatform/chain-middleware@v0.0.0-20240228100535-eb1bcf896eb9/api/tx/update.go (about) 1 //nolint:nolintlint,dupl 2 package tran 3 4 import ( 5 "context" 6 7 tx1 "github.com/NpoolPlatform/chain-middleware/pkg/mw/tx" 8 "github.com/NpoolPlatform/go-service-framework/pkg/logger" 9 npool "github.com/NpoolPlatform/message/npool/chain/mw/v1/tx" 10 11 "google.golang.org/grpc/codes" 12 "google.golang.org/grpc/status" 13 ) 14 15 func (s *Server) UpdateTx(ctx context.Context, in *npool.UpdateTxRequest) (*npool.UpdateTxResponse, error) { 16 req := in.GetInfo() 17 handler, err := tx1.NewHandler( 18 ctx, 19 tx1.WithID(req.ID, true), 20 tx1.WithChainTxID(req.ChainTxID, false), 21 tx1.WithState(req.State, false), 22 tx1.WithExtra(req.Extra, false), 23 ) 24 if err != nil { 25 logger.Sugar().Errorw( 26 "UpdateTx", 27 "In", in, 28 "Error", err, 29 ) 30 return &npool.UpdateTxResponse{}, status.Error(codes.InvalidArgument, err.Error()) 31 } 32 33 info, err := handler.UpdateTx(ctx) 34 if err != nil { 35 logger.Sugar().Errorw( 36 "UpdateTx", 37 "In", in, 38 "Error", err, 39 ) 40 return &npool.UpdateTxResponse{}, status.Error(codes.Internal, err.Error()) 41 } 42 43 return &npool.UpdateTxResponse{ 44 Info: info, 45 }, nil 46 }