Skip to content

Commit

Permalink
fix bug for create tokens
Browse files Browse the repository at this point in the history
  • Loading branch information
Geapefurit committed Nov 30, 2023
1 parent 900b76e commit fb7eb9b
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions api/v1/tokeninfo.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@ import (
func (s *Server) CreateTokenInfo(ctx context.Context, in *npool.CreateTokenInfoRequest) (*npool.CreateTokenInfoResponse, error) {
var err error
var info *npool.TokenInfo

if in == nil || in.Info == nil {
errMsg := "create tokeninfos failed, please give the input"
logger.Sugar().Errorf(errMsg)
return &npool.CreateTokenInfoResponse{Msg: errMsg}, status.Error(codes.Internal, errMsg)
}
conds := &npool.Conds{
OfficialContract: &v1.StringVal{Op: cruder.EQ, Value: *in.Info.OfficialContract},
}
Expand All @@ -32,6 +36,7 @@ func (s *Server) CreateTokenInfo(ctx context.Context, in *npool.CreateTokenInfoR
handler.WithOfficialContract(in.Info.OfficialContract, true),
handler.WithRemark(in.Info.Remark, false),
handler.WithData(in.Info.Data, true),
handler.WithLimit(1),
)
if err != nil {
logger.Sugar().Errorf("create tokeninfos failed, %v", err)
Expand All @@ -41,7 +46,7 @@ func (s *Server) CreateTokenInfo(ctx context.Context, in *npool.CreateTokenInfoR
_infos, _, _ := h.GetTokenInfos(ctx)
name := *in.Info.Name
if len(_infos) > 0 && !in.Force {
logger.Sugar().Infof("create tokeninfo,it is exist, %v")
logger.Sugar().Infof("create tokeninfo,it is exist")
return &npool.CreateTokenInfoResponse{Info: _infos[0], Success: true, Msg: "it`s exist"}, nil
}

Expand Down

0 comments on commit fb7eb9b

Please sign in to comment.