Skip to content

Commit 9c8840a

Browse files
committed
feat(#244): Scaffolded UpgradePicksReport message
1 parent 5b139d1 commit 9c8840a

8 files changed

Lines changed: 876 additions & 347 deletions

File tree

docs/static/openapi.yml

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

proto/cardchain/cardchain/tx.proto

Lines changed: 167 additions & 153 deletions
Large diffs are not rendered by default.
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package keeper
2+
3+
import (
4+
"context"
5+
6+
errorsmod "cosmossdk.io/errors"
7+
"github.com/DecentralCardGame/cardchain/x/cardchain/types"
8+
)
9+
10+
func (k msgServer) UpgradePicksReport(goCtx context.Context, msg *types.MsgUpgradePicksReport) (*types.MsgUpgradePicksReportResponse, error) {
11+
if _, err := k.addressCodec.StringToBytes(msg.Creator); err != nil {
12+
return nil, errorsmod.Wrap(err, "invalid authority address")
13+
}
14+
15+
// TODO: Handle the message
16+
17+
return &types.MsgUpgradePicksReportResponse{}, nil
18+
}

x/cardchain/module/autocli.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -503,6 +503,12 @@ func (am AppModule) AutoCLIOptions() *autocliv1.ModuleOptions {
503503
Short: "Send a EncounterDelete tx",
504504
PositionalArgs: []*autocliv1.PositionalArgDescriptor{{ProtoField: "id"}},
505505
},
506+
{
507+
RpcMethod: "UpgradePicksReport",
508+
Use: "upgrade-picks-report [picked] [dismissed]",
509+
Short: "Send a UpgradePicksReport tx",
510+
PositionalArgs: []*autocliv1.PositionalArgDescriptor{{ProtoField: "picked"}, {ProtoField: "dismissed", Varargs: true}},
511+
},
506512
// this line is used by ignite scaffolding # autocli/tx
507513
},
508514
},

x/cardchain/module/simulation.go

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
package cardchain
22

33
import (
4-
"math/rand"
5-
64
sdk "github.com/cosmos/cosmos-sdk/types"
75
"github.com/cosmos/cosmos-sdk/types/module"
86
simtypes "github.com/cosmos/cosmos-sdk/types/simulation"
97
"github.com/cosmos/cosmos-sdk/x/simulation"
8+
"math/rand"
109

1110
"github.com/DecentralCardGame/cardchain/testutil/sample"
1211
cardchainsimulation "github.com/DecentralCardGame/cardchain/x/cardchain/simulation"
@@ -840,6 +839,21 @@ func (am AppModule) WeightedOperations(simState module.SimulationState) []simtyp
840839
weightMsgEncounterDelete,
841840
cardchainsimulation.SimulateMsgEncounterDelete(am.accountKeeper, am.bankKeeper, am.keeper),
842841
))
842+
const (
843+
opWeightMsgUpgradePicksReport = "op_weight_msg_cardchain"
844+
defaultWeightMsgUpgradePicksReport int = 100
845+
)
846+
847+
var weightMsgUpgradePicksReport int
848+
simState.AppParams.GetOrGenerate(opWeightMsgUpgradePicksReport, &weightMsgUpgradePicksReport, nil,
849+
func(_ *rand.Rand) {
850+
weightMsgUpgradePicksReport = defaultWeightMsgUpgradePicksReport
851+
},
852+
)
853+
operations = append(operations, simulation.NewWeightedOperation(
854+
weightMsgUpgradePicksReport,
855+
cardchainsimulation.SimulateMsgUpgradePicksReport(am.accountKeeper, am.bankKeeper, am.keeper),
856+
))
843857

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

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package simulation
2+
3+
import (
4+
"math/rand"
5+
6+
"github.com/cosmos/cosmos-sdk/baseapp"
7+
sdk "github.com/cosmos/cosmos-sdk/types"
8+
simtypes "github.com/cosmos/cosmos-sdk/types/simulation"
9+
10+
"github.com/DecentralCardGame/cardchain/x/cardchain/keeper"
11+
"github.com/DecentralCardGame/cardchain/x/cardchain/types"
12+
)
13+
14+
func SimulateMsgUpgradePicksReport(
15+
ak types.AccountKeeper,
16+
bk types.BankKeeper,
17+
k keeper.Keeper,
18+
) simtypes.Operation {
19+
return func(r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simtypes.Account, chainID string,
20+
) (simtypes.OperationMsg, []simtypes.FutureOperation, error) {
21+
simAccount, _ := simtypes.RandomAcc(r, accs)
22+
msg := &types.MsgUpgradePicksReport{
23+
Creator: simAccount.Address.String(),
24+
}
25+
26+
// TODO: Handle the UpgradePicksReport simulation
27+
28+
return simtypes.NoOpMsg(types.ModuleName, sdk.MsgTypeURL(msg), "UpgradePicksReport simulation not implemented"), nil, nil
29+
}
30+
}

x/cardchain/types/codec.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ import (
88
)
99

1010
func RegisterInterfaces(registrar cdctypes.InterfaceRegistry) {
11+
registrar.RegisterImplementations((*sdk.Msg)(nil),
12+
&MsgUpgradePicksReport{},
13+
)
14+
1115
registrar.RegisterImplementations((*sdk.Msg)(nil),
1216
&MsgEncounterDelete{},
1317
)

x/cardchain/types/tx.pb.go

Lines changed: 634 additions & 191 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)