Skip to content

Commit

Permalink
Made set artwork mandatory
Browse files Browse the repository at this point in the history
  • Loading branch information
lxgr-linux committed Oct 6, 2023
1 parent f61cb36 commit bcdf2e2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
9 changes: 7 additions & 2 deletions x/cardchain/keeper/msg_server_finalize_set.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package keeper

import (
"context"
"fmt"

sdkerrors "cosmossdk.io/errors"
"github.com/DecentralCardGame/Cardchain/x/cardchain/types"
Expand All @@ -21,6 +20,12 @@ func (k msgServer) FinalizeSet(goCtx context.Context, msg *types.MsgFinalizeSet)
return nil, err
}

image := k.Images.Get(ctx, set.ArtworkId)

if len(image.Image) == 0 {
return nil, sdkerrors.Wrapf(types.ErrFinalizeSet, "Set artwork is needed")
}

err = k.CollectSetCreationFee(ctx, msg.Creator)
if err != nil {
return nil, sdkerrors.Wrap(errors.ErrInsufficientFunds, err.Error())
Expand All @@ -32,7 +37,7 @@ func (k msgServer) FinalizeSet(goCtx context.Context, msg *types.MsgFinalizeSet)
}

if dist[0] != dist[1] {
return nil, fmt.Errorf("sets should contain [(common,unique,exceptional), uncommon, rare] %d, %d, %d but contains %d, %d, %d", dist[1][0], dist[1][1], dist[1][2], dist[0][0], dist[0][1], dist[0][2])
return nil, sdkerrors.Wrapf(types.ErrFinalizeSet, "Sets should contain [(common,unique,exceptional), uncommon, rare] %d, %d, %d but contains %d, %d, %d", dist[1][0], dist[1][1], dist[1][2], dist[0][0], dist[0][1], dist[0][2])
}

set.Status = types.CStatus_finalized
Expand Down
1 change: 1 addition & 0 deletions x/cardchain/types/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,5 @@ var (
ErrUserAlreadyExists = sdkerrors.Register(ModuleName, 22, "User already exists")
ErrWaitingForPlayers = sdkerrors.Register(ModuleName, 23, "Waiting for players")
ErrUninitializedType = sdkerrors.Register(ModuleName, 24, "Type not yet initialized")
ErrFinalizeSet = sdkerrors.Register(ModuleName, 24, "Set can't be finalized")
)

0 comments on commit bcdf2e2

Please sign in to comment.