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