Skip to content

Commit

Permalink
Merge branch 'master' into cosmos_upgrade_0.47
Browse files Browse the repository at this point in the history
  • Loading branch information
lxgr-linux committed Oct 7, 2023
2 parents 08483b3 + 467e685 commit f32d118
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 16 deletions.
4 changes: 2 additions & 2 deletions scripts/migrate_with_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@


# delete all sets # TODO REMOVE THIS PART ONCE EVERYTHING IS FINE
print(old_dict["app_state"]["cardchain"]["sets"])
old_dict["app_state"]["cardchain"]["sets"] = []
#print(old_dict["app_state"]["cardchain"]["sets"])
#old_dict["app_state"]["cardchain"]["sets"] = []


params = new_dict["app_state"]["cardchain"]["params"]
Expand Down
2 changes: 1 addition & 1 deletion x/cardchain/client/cli/tx_buy_set.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ var _ = strconv.Itoa(0)

func CmdBuyBoosterPack() *cobra.Command {
cmd := &cobra.Command{
Use: "buy-set [set-id]",
Use: "buy-booster-pack [set-id]",
Short: "Broadcast message BuyBoosterPack",
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) (err error) {
Expand Down
2 changes: 1 addition & 1 deletion x/cardchain/client/cli/tx_msg_open_match.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ var _ = strconv.Itoa(0)

func CmdMsgOpenMatch() *cobra.Command {
cmd := &cobra.Command{
Use: "msg-open-match",
Use: "open-match",
Short: "Broadcast message OpenMatch",
Args: cobra.ExactArgs(0),
RunE: func(cmd *cobra.Command, args []string) (err error) {
Expand Down
16 changes: 6 additions & 10 deletions x/cardchain/client/cli/tx_set_card_rarity.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package cli

import (
"github.com/DecentralCardGame/cardobject/cardobject"
"fmt"
"strconv"

"github.com/DecentralCardGame/Cardchain/x/cardchain/types"
Expand All @@ -10,6 +10,7 @@ import (
"github.com/cosmos/cosmos-sdk/client/tx"
"github.com/spf13/cast"
"github.com/spf13/cobra"
"golang.org/x/exp/maps"
)

var _ = strconv.Itoa(0)
Expand All @@ -28,17 +29,12 @@ func CmdSetCardRarity() *cobra.Command {
if err != nil {
return err
}
rar, err := strconv.Atoi(args[2])
if err != nil {
return err
rar, found := types.CardRarity_value[args[2]]
if (!found) {
return fmt.Errorf("Rarity has to be in %s", maps.Keys(types.CardRarity_value))
}
argRarity := types.CardRarity(rar)

rarity := cardobject.Rarity(argRarity)
err = rarity.ValidateType(cardobject.Card{})
if err != nil {
return err
}
argRarity := types.CardRarity(rar)

clientCtx, err := client.GetClientTxContext(cmd)
if err != nil {
Expand Down
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 f32d118

Please sign in to comment.