github.com/NpoolPlatform/chain-middleware@v0.0.0-20240228100535-eb1bcf896eb9/api/app/coin/update.go (about) 1 package appcoin 2 3 import ( 4 "context" 5 6 appcoin1 "github.com/NpoolPlatform/chain-middleware/pkg/mw/app/coin" 7 npool "github.com/NpoolPlatform/message/npool/chain/mw/v1/app/coin" 8 9 "github.com/NpoolPlatform/go-service-framework/pkg/logger" 10 11 "google.golang.org/grpc/codes" 12 "google.golang.org/grpc/status" 13 ) 14 15 func (s *Server) UpdateCoin(ctx context.Context, in *npool.UpdateCoinRequest) (*npool.UpdateCoinResponse, error) { 16 req := in.GetInfo() 17 handler, err := appcoin1.NewHandler( 18 ctx, 19 appcoin1.WithID(req.ID, true), 20 appcoin1.WithName(req.Name, false), 21 appcoin1.WithDisplayNames(req.DisplayNames, false), 22 appcoin1.WithLogo(req.Logo, false), 23 appcoin1.WithForPay(req.ForPay, false), 24 appcoin1.WithProductPage(req.ProductPage, false), 25 appcoin1.WithWithdrawAutoReviewAmount(req.WithdrawAutoReviewAmount, false), 26 appcoin1.WithDailyRewardAmount(req.DailyRewardAmount, false), 27 appcoin1.WithDisabled(req.Disabled, false), 28 appcoin1.WithDisplay(req.Display, false), 29 appcoin1.WithDisplayIndex(req.DisplayIndex, false), 30 appcoin1.WithMaxAmountPerWithdraw(req.MaxAmountPerWithdraw, false), 31 appcoin1.WithMarketValue(req.MarketValue, false), 32 appcoin1.WithSettlePercent(req.SettlePercent, false), 33 appcoin1.WithSettleTips(req.SettleTips, false), 34 appcoin1.WithSetter(req.Setter, false), 35 ) 36 if err != nil { 37 logger.Sugar().Errorw( 38 "UpdateCoin", 39 "In", in, 40 "Error", err, 41 ) 42 return &npool.UpdateCoinResponse{}, status.Error(codes.InvalidArgument, err.Error()) 43 } 44 45 info, err := handler.UpdateCoin(ctx) 46 if err != nil { 47 logger.Sugar().Errorw( 48 "UpdateCoin", 49 "In", in, 50 "Error", err, 51 ) 52 return &npool.UpdateCoinResponse{}, status.Error(codes.Internal, err.Error()) 53 } 54 55 return &npool.UpdateCoinResponse{ 56 Info: info, 57 }, nil 58 }