Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/static/openapi.yml

Large diffs are not rendered by default.

37 changes: 25 additions & 12 deletions proto/cardchain/cardchain/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,16 @@ service Msg {
rpc EncounterEdit (MsgEncounterEdit) returns (MsgEncounterEditResponse);
rpc EncounterDo (MsgEncounterDo) returns (MsgEncounterDoResponse);
rpc EncounterClose (MsgEncounterClose) returns (MsgEncounterCloseResponse);
rpc EncounterDelete (MsgEncounterDelete) returns (MsgEncounterDeleteResponse);
rpc EarlyAccessDisinvite (MsgEarlyAccessDisinvite) returns (MsgEarlyAccessDisinviteResponse);
rpc CardBan (MsgCardBan) returns (MsgCardBanResponse);
rpc EarlyAccessGrant (MsgEarlyAccessGrant) returns (MsgEarlyAccessGrantResponse);
rpc SetActivate (MsgSetActivate) returns (MsgSetActivateResponse);
rpc CardCopyrightClaim (MsgCardCopyrightClaim) returns (MsgCardCopyrightClaimResponse);

// EncounterEdit defines the EncounterEdit RPC.

// EncounterDelete defines the EncounterDelete RPC.
}
// MsgUpdateParams is the Msg/UpdateParams request type.
message MsgUpdateParams {
Expand Down Expand Up @@ -119,12 +122,12 @@ message MsgCardSchemeBuyResponse {

message MsgCardSaveContent {
option (cosmos.msg.v1.signer) = "creator";
string creator = 1;
uint64 cardId = 2;
bytes content = 3;
string notes = 4;
string artist = 5;
bool balanceAnchor = 6;
string creator = 1;
uint64 cardId = 2;
bytes content = 3;
string notes = 4;
string artist = 5;
bool balanceAnchor = 6;
repeated Parameter parameters = 7;
}

Expand Down Expand Up @@ -507,18 +510,17 @@ message MsgEncounterCreateResponse {}
// MsgEncounterEdit defines the MsgEncounterEdit message.
message MsgEncounterEdit {
option (cosmos.msg.v1.signer) = "creator";
string creator = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
uint64 id = 2;
string name = 3;
repeated uint64 drawlist = 4;
string creator = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
uint64 id = 2;
string name = 3;
repeated uint64 drawlist = 4;
repeated Parameter parameters = 5;
bytes image = 6;
bytes image = 6;
}

// MsgEncounterEditResponse defines the MsgEncounterEditResponse message.
message MsgEncounterEditResponse {}


message MsgEncounterDo {
option (cosmos.msg.v1.signer) = "creator";
string creator = 1;
Expand Down Expand Up @@ -577,3 +579,14 @@ message MsgCardCopyrightClaim {
}

message MsgCardCopyrightClaimResponse {}

// MsgEncounterDelete defines the MsgEncounterDelete message.
message MsgEncounterDelete {
option (cosmos.msg.v1.signer) = "creator";
string creator = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
uint64 id = 2;
}

// MsgEncounterDeleteResponse defines the MsgEncounterDeleteResponse message.
message MsgEncounterDeleteResponse {}

30 changes: 30 additions & 0 deletions x/cardchain/keeper/msg_server_encounter_delete.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package keeper

import (
"context"

errorsmod "cosmossdk.io/errors"
"github.com/DecentralCardGame/cardchain/x/cardchain/types"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/errors"
)

func (k msgServer) EncounterDelete(goCtx context.Context, msg *types.MsgEncounterDelete) (*types.MsgEncounterDeleteResponse, error) {
ctx := sdk.UnwrapSDKContext(goCtx)

if _, err := k.addressCodec.StringToBytes(msg.Creator); err != nil {
return nil, errorsmod.Wrap(err, "invalid authority address")
}

encounter := k.Encounterk.Get(ctx, msg.Id)

if encounter.Owner != msg.Creator {
return nil, errorsmod.Wrap(errors.ErrUnauthorized, "incorrect owner")

}

k.Images.Set(ctx, encounter.ImageId, nil)
k.Encounterk.Set(ctx, msg.Id, nil)

return &types.MsgEncounterDeleteResponse{}, nil
}
8 changes: 7 additions & 1 deletion x/cardchain/module/autocli.go
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,13 @@ func (am AppModule) AutoCLIOptions() *autocliv1.ModuleOptions {
PositionalArgs: []*autocliv1.PositionalArgDescriptor{{ProtoField: "cardId"}},
},

// this line is used by ignite scaffolding # autocli/tx
{
RpcMethod: "EncounterDelete",
Use: "encounter-delete [id]",
Short: "Send a EncounterDelete tx",
PositionalArgs: []*autocliv1.PositionalArgDescriptor{{ProtoField: "id"}},
},
// this line is used by ignite scaffolding # autocli/tx
},
},
}
Expand Down
15 changes: 15 additions & 0 deletions x/cardchain/module/simulation.go
Original file line number Diff line number Diff line change
Expand Up @@ -825,6 +825,21 @@ func (am AppModule) WeightedOperations(simState module.SimulationState) []simtyp
weightMsgEncounterEdit,
cardchainsimulation.SimulateMsgEncounterEdit(am.accountKeeper, am.bankKeeper, am.keeper),
))
const (
opWeightMsgEncounterDelete = "op_weight_msg_cardchain"
defaultWeightMsgEncounterDelete int = 100
)

var weightMsgEncounterDelete int
simState.AppParams.GetOrGenerate(opWeightMsgEncounterDelete, &weightMsgEncounterDelete, nil,
func(_ *rand.Rand) {
weightMsgEncounterDelete = defaultWeightMsgEncounterDelete
},
)
operations = append(operations, simulation.NewWeightedOperation(
weightMsgEncounterDelete,
cardchainsimulation.SimulateMsgEncounterDelete(am.accountKeeper, am.bankKeeper, am.keeper),
))

// this line is used by starport scaffolding # simapp/module/operation

Expand Down
30 changes: 30 additions & 0 deletions x/cardchain/simulation/encounter_delete.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package simulation

import (
"math/rand"

"github.com/cosmos/cosmos-sdk/baseapp"
sdk "github.com/cosmos/cosmos-sdk/types"
simtypes "github.com/cosmos/cosmos-sdk/types/simulation"

"github.com/DecentralCardGame/cardchain/x/cardchain/keeper"
"github.com/DecentralCardGame/cardchain/x/cardchain/types"
)

func SimulateMsgEncounterDelete(
ak types.AccountKeeper,
bk types.BankKeeper,
k keeper.Keeper,
) simtypes.Operation {
return func(r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simtypes.Account, chainID string,
) (simtypes.OperationMsg, []simtypes.FutureOperation, error) {
simAccount, _ := simtypes.RandomAcc(r, accs)
msg := &types.MsgEncounterDelete{
Creator: simAccount.Address.String(),
}

// TODO: Handle the EncounterDelete simulation

return simtypes.NoOpMsg(types.ModuleName, sdk.MsgTypeURL(msg), "EncounterDelete simulation not implemented"), nil, nil
}
}
6 changes: 5 additions & 1 deletion x/cardchain/types/codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ import (
)

func RegisterInterfaces(registrar cdctypes.InterfaceRegistry) {
registrar.RegisterImplementations((*sdk.Msg)(nil),
&MsgEncounterDelete{},
)

registrar.RegisterImplementations((*sdk.Msg)(nil),
&MsgEncounterEdit{},
)
Expand Down Expand Up @@ -170,4 +174,4 @@ func RegisterInterfaces(registrar cdctypes.InterfaceRegistry) {
&MsgUpdateParams{},
)
msgservice.RegisterMsgServiceDesc(registrar, &_Msg_serviceDesc)
}
}
Loading