diff --git a/go.mod b/go.mod index 3d0060f..d8cd0bb 100644 --- a/go.mod +++ b/go.mod @@ -9,7 +9,6 @@ require ( github.com/CosmWasm/wasmd v0.33.0 github.com/bcdevtools/block-explorer-rpc-cosmos v1.2.3 github.com/bcdevtools/wasm-block-explorer-rpc-cosmos v1.1.1 - github.com/cosmos/cosmos-proto v1.0.0-beta.3 github.com/cosmos/cosmos-sdk v0.46.16 github.com/cosmos/gogoproto v1.4.11 github.com/cosmos/ibc-go/v6 v6.3.0 @@ -87,6 +86,7 @@ require ( github.com/containerd/cgroups v1.1.0 // indirect github.com/coreos/go-systemd/v22 v22.5.0 // indirect github.com/cosmos/btcutil v1.0.5 // indirect + github.com/cosmos/cosmos-proto v1.0.0-beta.3 // indirect github.com/cosmos/go-bip39 v1.0.0 // indirect github.com/cosmos/gorocksdb v1.2.0 // indirect github.com/cosmos/iavl v0.19.6 // indirect diff --git a/proto/wasmrollapp/cron/v1beta1/cron.proto b/proto/wasmrollapp/cron/v1beta1/cron.proto index 9307987..6cabf05 100644 --- a/proto/wasmrollapp/cron/v1beta1/cron.proto +++ b/proto/wasmrollapp/cron/v1beta1/cron.proto @@ -1,15 +1,19 @@ syntax = "proto3"; package wasmrollapp.cron.v1beta1; -import "gogoproto/gogo.proto"; - option go_package = "github.com/dymensionxyz/rollapp-wasm/x/cron/types"; message WhitelistedContract { + // game_id is the unique identifier for the game uint64 game_id = 1; + // security_address is the address of the security contract string security_address = 2; + // contract_admin is the address of the contract admin string contract_admin = 3; + // game_name is the name of the game string game_name = 4; + // contract_address is the address of the contract string contract_address = 5; + // game_type is the type of the game, single player or multiplayer or both uint64 game_type = 6; } diff --git a/proto/wasmrollapp/cron/v1beta1/query.proto b/proto/wasmrollapp/cron/v1beta1/query.proto index 38ff317..c279b76 100644 --- a/proto/wasmrollapp/cron/v1beta1/query.proto +++ b/proto/wasmrollapp/cron/v1beta1/query.proto @@ -15,6 +15,7 @@ service Query { rpc Params(QueryParamsRequest) returns (QueryParamsResponse) { option (google.api.http).get = "/wasmrollapp/cron/v1beta1/params"; } + // WhitelistedContracts queries the whitelisted contracts of the module. rpc QueryWhitelistedContracts(QueryWhitelistedContractsRequest) returns (QueryWhitelistedContractsResponse) { option (google.api.http).get = "/wasmrollapp/cron/v1beta1/whitelisted_contracts"; } @@ -29,11 +30,13 @@ message QueryParamsResponse { Params params = 1 [(gogoproto.nullable) = false]; } +// QueryWhitelistedContractsRequest is request type for the Query/WhitelistedContracts RPC method. message QueryWhitelistedContractsRequest{ cosmos.base.query.v1beta1.PageRequest pagination = 1 [(gogoproto.moretags) = "yaml:\"pagination\""]; } +// QueryWhitelistedContractsResponse is response type for the Query/WhitelistedContracts RPC method. message QueryWhitelistedContractsResponse { repeated WhitelistedContract whilisted_contracts = 1 [(gogoproto.nullable) = false]; cosmos.base.query.v1beta1.PageResponse pagination = 2 diff --git a/proto/wasmrollapp/cron/v1beta1/tx.proto b/proto/wasmrollapp/cron/v1beta1/tx.proto index e5046c2..2a914ee 100644 --- a/proto/wasmrollapp/cron/v1beta1/tx.proto +++ b/proto/wasmrollapp/cron/v1beta1/tx.proto @@ -1,32 +1,34 @@ syntax = "proto3"; package wasmrollapp.cron.v1beta1; -import "gogoproto/gogo.proto"; - -import "cosmos/msg/v1/msg.proto"; -import "cosmos_proto/cosmos.proto"; -import "wasmrollapp/cron/v1beta1/params.proto"; - option go_package = "github.com/dymensionxyz/rollapp-wasm/x/cron/types"; // Msg defines the Msg service. service Msg { rpc RegisterContract(MsgRegisterContract) returns(MsgRegisterContractResponse); - rpc DeRegisterContract(MsgDeRegisterContract) returns(MsgDeRegisterContractResponse); + rpc DeregisterContract(MsgDeregisterContract) returns(MsgDeregisterContractResponse); } +// MsgRegisterContract defines the Msg/RegisterContract request type. message MsgRegisterContract { + // security_address is the address of the security module string security_address = 1; + // game_name is the name of the game string game_name = 2; + // contract_address is the address of the contract string contract_address = 3; - uint64 game_type = 4; // 1 -> single, 2 -> multi, 3 -> both + // game_type is the type of the game 1 -> single, 2 -> multi, 3 -> both + uint64 game_type = 4; } +// MsgRegisterContractResponse defines the Msg/RegisterContract response type. message MsgRegisterContractResponse {} -message MsgDeRegisterContract { +// MsgDeregisterContract defines the Msg/DeregisterContract request type. +message MsgDeregisterContract { string security_address = 1; uint64 game_id = 2; } -message MsgDeRegisterContractResponse {} \ No newline at end of file +// MsgDeregisterContractResponse defines the Msg/DeregisterContract response type. +message MsgDeregisterContractResponse {} \ No newline at end of file diff --git a/x/cron/abci.go b/x/cron/abci.go index 8fd321b..a6964ba 100644 --- a/x/cron/abci.go +++ b/x/cron/abci.go @@ -1,9 +1,9 @@ package cron import ( + sdk "github.com/cosmos/cosmos-sdk/types" "github.com/dymensionxyz/rollapp-wasm/x/cron/keeper" cronTypes "github.com/dymensionxyz/rollapp-wasm/x/cron/types" - sdk "github.com/cosmos/cosmos-sdk/types" ) func BeginBlocker(ctx sdk.Context, k keeper.Keeper) { diff --git a/x/cron/client/cli/query.go b/x/cron/client/cli/query.go index 17ef53d..38d8c32 100644 --- a/x/cron/client/cli/query.go +++ b/x/cron/client/cli/query.go @@ -2,14 +2,12 @@ package cli import ( "fmt" - // "strings" "github.com/spf13/cobra" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" - // sdk "github.com/cosmos/cosmos-sdk/types" "github.com/dymensionxyz/rollapp-wasm/x/cron/types" ) diff --git a/x/cron/client/cli/query_params.go b/x/cron/client/cli/query_params.go index 6e332eb..2a59a9b 100644 --- a/x/cron/client/cli/query_params.go +++ b/x/cron/client/cli/query_params.go @@ -3,9 +3,9 @@ package cli import ( "context" - "github.com/dymensionxyz/rollapp-wasm/x/cron/types" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/dymensionxyz/rollapp-wasm/x/cron/types" "github.com/spf13/cobra" ) diff --git a/x/cron/client/cli/tx.go b/x/cron/client/cli/tx.go index 1e09a64..cea1e43 100644 --- a/x/cron/client/cli/tx.go +++ b/x/cron/client/cli/tx.go @@ -80,7 +80,7 @@ func CmdDeRegisterContract() *cobra.Command { return fmt.Errorf("game-id '%s' not a valid uint", args[0]) } - msg := types.NewMsgDeRegisterContract( + msg := types.NewMsgDeregisterContract( clientCtx.GetFromAddress().String(), gameID, ) diff --git a/x/cron/genesis.go b/x/cron/genesis.go index 21d0d69..ae7d2b5 100644 --- a/x/cron/genesis.go +++ b/x/cron/genesis.go @@ -1,9 +1,9 @@ package cron import ( + sdk "github.com/cosmos/cosmos-sdk/types" "github.com/dymensionxyz/rollapp-wasm/x/cron/keeper" "github.com/dymensionxyz/rollapp-wasm/x/cron/types" - sdk "github.com/cosmos/cosmos-sdk/types" ) // InitGenesis initializes the capability module's state from a provided genesis diff --git a/x/cron/handler.go b/x/cron/handler.go index 861807b..89b5770 100644 --- a/x/cron/handler.go +++ b/x/cron/handler.go @@ -1,12 +1,13 @@ package cron import ( + errorsmod "cosmossdk.io/errors" "fmt" - "github.com/dymensionxyz/rollapp-wasm/x/cron/keeper" - "github.com/dymensionxyz/rollapp-wasm/x/cron/types" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + "github.com/dymensionxyz/rollapp-wasm/x/cron/keeper" + "github.com/dymensionxyz/rollapp-wasm/x/cron/types" ) // NewHandler ... @@ -22,13 +23,13 @@ func NewHandler(k keeper.Keeper) sdk.Handler { case *types.MsgRegisterContract: res, err := server.RegisterContract(sdk.WrapSDKContext(ctx), msg) return sdk.WrapServiceResult(ctx, res, err) - case *types.MsgDeRegisterContract: - res, err := server.DeRegisterContract(sdk.WrapSDKContext(ctx), msg) + case *types.MsgDeregisterContract: + res, err := server.DeregisterContract(sdk.WrapSDKContext(ctx), msg) return sdk.WrapServiceResult(ctx, res, err) // this line is used by starport scaffolding # 1 default: errMsg := fmt.Sprintf("unrecognized %s message type: %T", types.ModuleName, msg) - return nil, sdkerrors.Wrap(sdkerrors.ErrUnknownRequest, errMsg) + return nil, errorsmod.Wrap(sdkerrors.ErrUnknownRequest, errMsg) } } } diff --git a/x/cron/keeper/genesis.go b/x/cron/keeper/genesis.go index 099b77b..863d135 100644 --- a/x/cron/keeper/genesis.go +++ b/x/cron/keeper/genesis.go @@ -13,16 +13,15 @@ func (k Keeper) InitGenesis(ctx sdk.Context, genState types.GenesisState) { panic(err) } var ( - GameID uint64 + gameID uint64 ) // this line is used by starport scaffolding # genesis/module/init for _, item := range genState.WhitelistedContracts { - if item.GameId > GameID { - GameID = item.GameId - } k.SetContract(ctx, item) + // Set the gameID to the gameID in the whitelisted contract + gameID = item.GameId } - k.SetGameID(ctx, GameID) + k.SetGameID(ctx, gameID) k.SetParams(ctx, genState.Params) } diff --git a/x/cron/keeper/keeper.go b/x/cron/keeper/keeper.go index ef5ce43..4d09d92 100644 --- a/x/cron/keeper/keeper.go +++ b/x/cron/keeper/keeper.go @@ -11,7 +11,6 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" - // "github.com/dymensionxyz/dymension-rdk/utils/logger" "github.com/dymensionxyz/rollapp-wasm/x/cron/expected" "github.com/dymensionxyz/rollapp-wasm/x/cron/types" ) @@ -76,8 +75,8 @@ func (k Keeper) Store(ctx sdk.Context) sdk.KVStore { return ctx.KVStore(k.storeKey) } -func (k Keeper) SinglePlayer(ctx sdk.Context, contractAddress string, ResolveSinglePlayer []byte, gameName string) { - err := k.SudoContractCall(ctx, contractAddress, ResolveSinglePlayer) +func (k Keeper) SinglePlayer(ctx sdk.Context, contractAddress string, resolveSinglePlayer []byte, gameName string) { + err := k.SudoContractCall(ctx, contractAddress, resolveSinglePlayer) if err != nil { ctx.Logger().Error("Game %s contract call error for single-player", gameName) } else { @@ -85,15 +84,15 @@ func (k Keeper) SinglePlayer(ctx sdk.Context, contractAddress string, ResolveSin } } -func (k Keeper) MultiPlayer(ctx sdk.Context, contractAddress string, SetupMultiPlayer []byte, ResolveMultiPlayer []byte, gameName string) { - err := k.SudoContractCall(ctx, contractAddress, SetupMultiPlayer) +func (k Keeper) MultiPlayer(ctx sdk.Context, contractAddress string, setupMultiPlayer []byte, resolveMultiPlayer []byte, gameName string) { + err := k.SudoContractCall(ctx, contractAddress, setupMultiPlayer) if err != nil { ctx.Logger().Error("Game %s contract call error for setup multi-player", gameName) } else { ctx.Logger().Info("Game %s contract call for setup multi-player success", gameName) } - err = k.SudoContractCall(ctx, contractAddress, ResolveMultiPlayer) + err = k.SudoContractCall(ctx, contractAddress, resolveMultiPlayer) if err != nil { ctx.Logger().Error("Game %s contract call error for resolve multi-player", gameName) } else { diff --git a/x/cron/keeper/msg_server.go b/x/cron/keeper/msg_server.go index 7a241e8..42dde89 100644 --- a/x/cron/keeper/msg_server.go +++ b/x/cron/keeper/msg_server.go @@ -2,11 +2,12 @@ package keeper import ( "context" + errorsmod "cosmossdk.io/errors" "fmt" - "github.com/dymensionxyz/rollapp-wasm/x/cron/types" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + "github.com/dymensionxyz/rollapp-wasm/x/cron/types" ) type msgServer struct { @@ -26,7 +27,7 @@ func (k msgServer) RegisterContract(goCtx context.Context, msg *types.MsgRegiste // check if the cron is globally enabled params := k.GetParams(ctx) if !params.EnableCron { - return &types.MsgRegisterContractResponse{}, sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, "Cron is disabled") + return &types.MsgRegisterContractResponse{}, errorsmod.Wrapf(sdkerrors.ErrInvalidRequest, "Cron is disabled") } if err := msg.ValidateBasic(); err != nil { @@ -51,7 +52,7 @@ func (k msgServer) RegisterContract(goCtx context.Context, msg *types.MsgRegiste for _, data := range allContracts { if data.ContractAddress == msg.ContractAddress { - return &types.MsgRegisterContractResponse{}, sdkerrors.Wrapf(sdkerrors.ErrNotFound, "contract already registered") + return &types.MsgRegisterContractResponse{}, errorsmod.Wrapf(sdkerrors.ErrNotFound, "contract already registered") } } gameID := k.GetGameID(ctx) @@ -70,38 +71,38 @@ func (k msgServer) RegisterContract(goCtx context.Context, msg *types.MsgRegiste return &types.MsgRegisterContractResponse{}, nil } -func (k msgServer) DeRegisterContract(goCtx context.Context, msg *types.MsgDeRegisterContract) (*types.MsgDeRegisterContractResponse, error) { +func (k msgServer) DeregisterContract(goCtx context.Context, msg *types.MsgDeregisterContract) (*types.MsgDeregisterContractResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) params := k.GetParams(ctx) if !params.EnableCron { - return &types.MsgDeRegisterContractResponse{}, sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, "Cron is disabled") + return &types.MsgDeregisterContractResponse{}, errorsmod.Wrapf(sdkerrors.ErrInvalidRequest, "Cron is disabled") } if err := msg.ValidateBasic(); err != nil { ctx.Logger().Error(fmt.Sprintf("request invalid: %s", err)) - return &types.MsgDeRegisterContractResponse{}, err + return &types.MsgDeregisterContractResponse{}, err } // Get Game info from Game Id gameInfo, found := k.GetWhitelistedContract(ctx, msg.GameId) if !found { - return &types.MsgDeRegisterContractResponse{}, sdkerrors.Wrapf(sdkerrors.ErrNotFound, "no contract found for this game ID") + return &types.MsgDeregisterContractResponse{}, errorsmod.Wrapf(sdkerrors.ErrNotFound, "no contract found for this game ID") } // Validation such that only the user who instantiated the contract can register contract contractAddr, err := sdk.AccAddressFromBech32(gameInfo.ContractAddress) if err != nil { - return &types.MsgDeRegisterContractResponse{}, sdkerrors.ErrInvalidAddress + return &types.MsgDeregisterContractResponse{}, sdkerrors.ErrInvalidAddress } contractInfo := k.conOps.GetContractInfo(ctx, contractAddr) // check if sender is authorized exists := k.CheckSecurityAddress(ctx, msg.SecurityAddress) if !exists && contractInfo.Admin != msg.SecurityAddress { - return &types.MsgDeRegisterContractResponse{}, sdkerrors.ErrUnauthorized + return &types.MsgDeregisterContractResponse{}, sdkerrors.ErrUnauthorized } k.DeleteContract(ctx, msg.GameId) - return &types.MsgDeRegisterContractResponse{}, nil + return &types.MsgDeregisterContractResponse{}, nil } diff --git a/x/cron/keeper/params.go b/x/cron/keeper/params.go index 81f0779..b654b97 100644 --- a/x/cron/keeper/params.go +++ b/x/cron/keeper/params.go @@ -1,8 +1,8 @@ package keeper import ( - "github.com/dymensionxyz/rollapp-wasm/x/cron/types" sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/dymensionxyz/rollapp-wasm/x/cron/types" ) // GetParams returns the current x/cron module parameters. diff --git a/x/cron/keeper/params_test.go b/x/cron/keeper/params_test.go index 3d550ff..a2dbea0 100644 --- a/x/cron/keeper/params_test.go +++ b/x/cron/keeper/params_test.go @@ -14,8 +14,8 @@ func TestGetParams(t *testing.T) { appd := app.Setup(t, false) ctx := appd.BaseApp.NewContext(false, tmproto.Header{}) - DefaultSecurityAddress := []string{"cosmos1xkxed7rdzvmyvgdshpe445ddqwn47fru24fnlp"} - params := cronTypes.Params{SecurityAddress: DefaultSecurityAddress, EnableCron: true} + defaultSecurityAddress := []string{"cosmos1xkxed7rdzvmyvgdshpe445ddqwn47fru24fnlp"} + params := cronTypes.Params{SecurityAddress: defaultSecurityAddress, EnableCron: true} appd.CronKeeper.SetParams(ctx, params) diff --git a/x/cron/module.go b/x/cron/module.go index 44a0a3d..c4e121d 100644 --- a/x/cron/module.go +++ b/x/cron/module.go @@ -71,7 +71,7 @@ func (AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, _ client.TxEncodingCo } // RegisterRESTRoutes registers the capability module's REST service handlers. -func (AppModuleBasic) RegisterRESTRoutes(clientCtx client.Context, rtr *mux.Router) { +func (AppModuleBasic) RegisterRESTRoutes(_ client.Context, _ *mux.Router) { } // RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the module. @@ -165,7 +165,7 @@ func (am AppModule) EndBlock(_ sdk.Context, _ abci.RequestEndBlock) []abci.Valid } // LegacyQuerierHandler returns the capability module's Querier. -func (am AppModule) LegacyQuerierHandler(legacyQuerierCdc *codec.LegacyAmino) sdk.Querier { +func (am AppModule) LegacyQuerierHandler(_ *codec.LegacyAmino) sdk.Querier { return nil } diff --git a/x/cron/spec/02_state.md b/x/cron/spec/02_state.md index b0ca7e1..4999b3b 100644 --- a/x/cron/spec/02_state.md +++ b/x/cron/spec/02_state.md @@ -32,7 +32,7 @@ message WhitelistedContract { ## Genesis & Params -The `x/cron` module's `GenesisState` defines the state necessary for initializing the chain from a previously exported height. It contains the module Parameters and Whitelisted Contract. The params are used to control the Contract GasLimit and Security Address which is responsible to whitelist contract. This value can be modified with a governance proposal. +The `x/cron` module's `GenesisState` defines the state necessary for initializing the chain from a previously exported height. It contains the module Parameters and Whitelisted Contract. The params are used to control the Security Address which is responsible to whitelist contract. This value can be modified with a governance proposal. ```go // GenesisState defines the cron module's genesis state. @@ -57,10 +57,8 @@ message Params { (gogoproto.moretags) = "yaml:\"security_address\"" ]; - uint64 contract_gas_limit = 2 [ - (gogoproto.jsontag) = "contract_gas_limit,omitempty", - (gogoproto.moretags) = "yaml:\"contract_gas_limit\"" - ]; + // set module enabled or not + bool enable_cron = 2; } ``` @@ -69,4 +67,4 @@ message Params { The following state transitions are possible: - Register the contract for cronjob -- DeRegister the contract from cronjob +- Deregister the contract from cronjob diff --git a/x/cron/spec/03_clients.md b/x/cron/spec/03_clients.md index 2e860ba..6ca6e1e 100644 --- a/x/cron/spec/03_clients.md +++ b/x/cron/spec/03_clients.md @@ -17,7 +17,7 @@ The CLI has been updated with new queries and transactions for the `x/cron` modu ### Transactions -| Command | Subcommand | Arguments | Description | -| :--------------------- | :--------------------- | :----------------------------------------- | :------------------------------------- | -| `wasmrollappd tx cron` | `register-contract` | [game-name] [contract-address] [game-type] | Register the contract for cron job | -| `wasmrollappd tx cron` | `de-register-contract` | [game-id] | De-Register the contract from cron job | +| Command | Subcommand | Arguments | Description | +| :--------------------- | :--------------------- | :----------------------------------------- | :------------------------------------ | +| `wasmrollappd tx cron` | `register-contract` | [game-name] [contract-address] [game-type] | Register the contract for cron job | +| `wasmrollappd tx cron` | `de-register-contract` | [game-id] | Deregister the contract from cron job | diff --git a/x/cron/spec/README.md b/x/cron/spec/README.md index 42eddbb..b2a891d 100644 --- a/x/cron/spec/README.md +++ b/x/cron/spec/README.md @@ -20,3 +20,11 @@ The `x/cron` module provides functionality for scheduling and executing tasks, i 1. **[Concepts](01_concepts.md)** 2. **[State](02_state.md)** 3. **[Clients](03_clients.md)** + +## Flow + +### Step 1: Upload the contract + #### ex: `wasmrollappd tx wasm store "$DIR/../../x/wasm/keeper/testdata/coinflip.wasm` +### Step 2: Register the contract according to the game type + #### ex: `wasmrollappd tx cron register-contract coin-flip rol14hj2tavq8f.... 1` +### result : cronjob for the specific contract is activated \ No newline at end of file diff --git a/x/cron/types/codec.go b/x/cron/types/codec.go index 58b97ca..598e7c7 100644 --- a/x/cron/types/codec.go +++ b/x/cron/types/codec.go @@ -14,7 +14,7 @@ import ( func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { // this line is used by starport scaffolding # 2 cdc.RegisterConcrete(&MsgRegisterContract{}, "wasmrollapp/cron/MsgRegisterContract", nil) - cdc.RegisterConcrete(&MsgDeRegisterContract{}, "wasmrollapp/cron/MsgDeRegisterContract", nil) + cdc.RegisterConcrete(&MsgDeregisterContract{}, "wasmrollapp/cron/MsgDeregisterContract", nil) } @@ -23,7 +23,7 @@ func RegisterInterfaces(registry cdctypes.InterfaceRegistry) { registry.RegisterImplementations( (*sdk.Msg)(nil), &MsgRegisterContract{}, - &MsgDeRegisterContract{}, + &MsgDeregisterContract{}, ) msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) diff --git a/x/cron/types/cron.pb.go b/x/cron/types/cron.pb.go index 53aaeb2..5768477 100644 --- a/x/cron/types/cron.pb.go +++ b/x/cron/types/cron.pb.go @@ -5,7 +5,6 @@ package types import ( fmt "fmt" - _ "github.com/cosmos/gogoproto/gogoproto" proto "github.com/gogo/protobuf/proto" io "io" math "math" @@ -24,12 +23,18 @@ var _ = math.Inf const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type WhitelistedContract struct { - GameId uint64 `protobuf:"varint,1,opt,name=game_id,json=gameId,proto3" json:"game_id,omitempty"` + // game_id is the unique identifier for the game + GameId uint64 `protobuf:"varint,1,opt,name=game_id,json=gameId,proto3" json:"game_id,omitempty"` + // security_address is the address of the security contract SecurityAddress string `protobuf:"bytes,2,opt,name=security_address,json=securityAddress,proto3" json:"security_address,omitempty"` - ContractAdmin string `protobuf:"bytes,3,opt,name=contract_admin,json=contractAdmin,proto3" json:"contract_admin,omitempty"` - GameName string `protobuf:"bytes,4,opt,name=game_name,json=gameName,proto3" json:"game_name,omitempty"` + // contract_admin is the address of the contract admin + ContractAdmin string `protobuf:"bytes,3,opt,name=contract_admin,json=contractAdmin,proto3" json:"contract_admin,omitempty"` + // game_name is the name of the game + GameName string `protobuf:"bytes,4,opt,name=game_name,json=gameName,proto3" json:"game_name,omitempty"` + // contract_address is the address of the contract ContractAddress string `protobuf:"bytes,5,opt,name=contract_address,json=contractAddress,proto3" json:"contract_address,omitempty"` - GameType uint64 `protobuf:"varint,6,opt,name=game_type,json=gameType,proto3" json:"game_type,omitempty"` + // game_type is the type of the game, single player or multiplayer or both + GameType uint64 `protobuf:"varint,6,opt,name=game_type,json=gameType,proto3" json:"game_type,omitempty"` } func (m *WhitelistedContract) Reset() { *m = WhitelistedContract{} } @@ -116,26 +121,25 @@ func init() { } var fileDescriptor_ad6aacd87fd409ed = []byte{ - // 298 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x4c, 0x90, 0x4f, 0x4a, 0x03, 0x31, - 0x1c, 0x85, 0x1b, 0xad, 0xd5, 0x06, 0xfc, 0xc3, 0x28, 0x18, 0x14, 0x42, 0x51, 0x84, 0xba, 0xb0, - 0xa1, 0x78, 0x82, 0xea, 0x4a, 0x04, 0x17, 0x45, 0x10, 0xdc, 0x94, 0x74, 0x12, 0xa6, 0x81, 0x49, - 0x32, 0x24, 0xa9, 0x76, 0x3c, 0x85, 0xc7, 0x72, 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7e, 0x2a, 0x0c, - 0x3e, 0x6b, 0xdc, 0x59, 0xd7, 0xb8, 0xf3, 0x5d, 0xe3, 0xce, 0xeb, 0x38, 0x13, 0x6e, 0xb1, 0x9c, - 0x8f, 0x52, 0x2d, 0x09, 0x2b, 0x25, 0x57, 0x56, 0x68, 0xb5, 0x2a, 0x3f, 0x48, 0xb3, 0xe2, 0x8d, - 0x5f, 0x94, 0xac, 0xe2, 0xe2, 0xde, 0x6d, 0xe7, 0xbd, 0xb0, 0xdd, 0xed, 0x5f, 0x00, 0x00, 0x00, - 0xff, 0xff, 0xaf, 0x32, 0x5d, 0x0b, 0x92, 0x01, 0x00, 0x00, + // 287 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x4c, 0x90, 0x4f, 0x4b, 0xc3, 0x30, + 0x18, 0xc6, 0x1b, 0x9d, 0xd5, 0x05, 0xfc, 0x43, 0x3d, 0x18, 0x10, 0xc2, 0x50, 0x84, 0x79, 0xb0, + 0xa5, 0xf8, 0x09, 0xa6, 0x27, 0x11, 0x3c, 0x0c, 0x41, 0xf0, 0x52, 0xd2, 0x26, 0x6c, 0x81, 0x26, + 0x29, 0x49, 0xa6, 0xab, 0x9f, 0xc2, 0x8f, 0xe5, 0x71, 0x47, 0x8f, 0xd2, 0xe2, 0xf7, 0x90, 0xa4, + 0x2d, 0xee, 0xf8, 0xfe, 0x78, 0xf8, 0x3d, 0x2f, 0x0f, 0xbc, 0x7c, 0x27, 0x46, 0x68, 0x55, 0x96, + 0xa4, 0xaa, 0x92, 0x42, 0x2b, 0x99, 0xbc, 0xa5, 0x39, 0xb3, 0x24, 0xf5, 0x47, 0x5c, 0x69, 0x65, + 0x55, 0x84, 0xb6, 0x42, 0xb1, 0xe7, 0x7d, 0xe8, 0xe2, 0x17, 0xc0, 0xd3, 0x97, 0x25, 0xb7, 0xac, + 0xe4, 0xc6, 0x32, 0x7a, 0xaf, 0xa4, 0xd5, 0xa4, 0xb0, 0xd1, 0x19, 0xdc, 0x5f, 0x10, 0xc1, 0x32, + 0x4e, 0x11, 0x98, 0x80, 0xe9, 0x68, 0x1e, 0xba, 0xf3, 0x81, 0x46, 0xd7, 0xf0, 0xc4, 0xb0, 0x62, + 0xa5, 0xb9, 0xad, 0x33, 0x42, 0xa9, 0x66, 0xc6, 0xa0, 0x9d, 0x09, 0x98, 0x8e, 0xe7, 0xc7, 0x03, + 0x9f, 0x75, 0x38, 0xba, 0x82, 0x47, 0x45, 0xef, 0xcb, 0x08, 0x15, 0x5c, 0xa2, 0x5d, 0x1f, 0x3c, + 0x1c, 0xe8, 0xcc, 0xc1, 0xe8, 0x1c, 0x8e, 0x7d, 0x95, 0x24, 0x82, 0xa1, 0x91, 0x4f, 0x1c, 0x38, + 0xf0, 0x44, 0x04, 0x73, 0x75, 0x5b, 0x8e, 0xae, 0x6e, 0xaf, 0xab, 0xfb, 0xb7, 0x74, 0x75, 0x83, + 0xc7, 0xd6, 0x15, 0x43, 0xa1, 0x7f, 0xda, 0x7b, 0x9e, 0xeb, 0x8a, 0xdd, 0x3d, 0x7e, 0x35, 0x18, + 0x6c, 0x1a, 0x0c, 0x7e, 0x1a, 0x0c, 0x3e, 0x5b, 0x1c, 0x6c, 0x5a, 0x1c, 0x7c, 0xb7, 0x38, 0x78, + 0x4d, 0x17, 0xdc, 0x2e, 0x57, 0x79, 0x5c, 0x28, 0x91, 0xd0, 0x5a, 0x30, 0x69, 0xb8, 0x92, 0xeb, + 0xfa, 0x23, 0xe9, 0xf7, 0xba, 0x71, 0xdb, 0x25, 0xeb, 0x6e, 0x5b, 0xe7, 0x36, 0x79, 0xe8, 0x57, + 0xbd, 0xfd, 0x0b, 0x00, 0x00, 0xff, 0xff, 0x82, 0x7d, 0x13, 0xbc, 0x7c, 0x01, 0x00, 0x00, } func (m *WhitelistedContract) Marshal() (dAtA []byte, err error) { diff --git a/x/cron/types/events.go b/x/cron/types/events.go index c6905a3..79b031b 100644 --- a/x/cron/types/events.go +++ b/x/cron/types/events.go @@ -1,8 +1,6 @@ package types const ( - CronModuleEventType = "cron" - EventTypeContractSudoMsg = "sudo_msg" AttributeKeyResultDataHex = "result" ) diff --git a/x/cron/types/message_de_register_contract.go b/x/cron/types/message_de_register_contract.go index acb3055..c73bf5a 100644 --- a/x/cron/types/message_de_register_contract.go +++ b/x/cron/types/message_de_register_contract.go @@ -1,33 +1,34 @@ package types import ( + errorsmod "cosmossdk.io/errors" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" ) -const TypeMsgDeRegisterContract = "de_register_contract" +const TypeMsgDeregisterContract = "de_register_contract" -var _ sdk.Msg = &MsgDeRegisterContract{} +var _ sdk.Msg = &MsgDeregisterContract{} -func NewMsgDeRegisterContract( +func NewMsgDeregisterContract( securityAddress string, gameID uint64, -) *MsgDeRegisterContract { - return &MsgDeRegisterContract{ +) *MsgDeregisterContract { + return &MsgDeregisterContract{ SecurityAddress: securityAddress, - GameId: gameID, + GameId: gameID, } } -func (msg *MsgDeRegisterContract) Route() string { +func (msg *MsgDeregisterContract) Route() string { return RouterKey } -func (msg *MsgDeRegisterContract) Type() string { - return TypeMsgDeRegisterContract +func (msg *MsgDeregisterContract) Type() string { + return TypeMsgDeregisterContract } -func (msg *MsgDeRegisterContract) GetSigners() []sdk.AccAddress { +func (msg *MsgDeregisterContract) GetSigners() []sdk.AccAddress { creator, err := sdk.AccAddressFromBech32(msg.SecurityAddress) if err != nil { panic(err) @@ -35,15 +36,15 @@ func (msg *MsgDeRegisterContract) GetSigners() []sdk.AccAddress { return []sdk.AccAddress{creator} } -func (msg *MsgDeRegisterContract) GetSignBytes() []byte { +func (msg *MsgDeregisterContract) GetSignBytes() []byte { bz := moduleCdc.MustMarshalJSON(msg) return sdk.MustSortJSON(bz) } -func (msg *MsgDeRegisterContract) ValidateBasic() error { +func (msg *MsgDeregisterContract) ValidateBasic() error { _, err := sdk.AccAddressFromBech32(msg.SecurityAddress) if err != nil { - return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid creator address (%s)", err) + return errorsmod.Wrapf(sdkerrors.ErrInvalidAddress, "invalid security address (%s)", err) } return nil diff --git a/x/cron/types/message_register_contract.go b/x/cron/types/message_register_contract.go index fe8aa22..806269a 100644 --- a/x/cron/types/message_register_contract.go +++ b/x/cron/types/message_register_contract.go @@ -1,9 +1,10 @@ package types import ( - "slices" + errorsmod "cosmossdk.io/errors" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + "slices" ) const TypeMsgRegisterContract = "register_contract" @@ -48,16 +49,16 @@ func (msg *MsgRegisterContract) GetSignBytes() []byte { func (msg *MsgRegisterContract) ValidateBasic() error { _, err := sdk.AccAddressFromBech32(msg.SecurityAddress) if err != nil { - return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid creator address (%s)", err) + return errorsmod.Wrapf(sdkerrors.ErrInvalidAddress, "invalid creator address (%s)", err) } _, err = sdk.AccAddressFromBech32(msg.ContractAddress) if err != nil { - return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid contract address (%s)", err) + return errorsmod.Wrapf(sdkerrors.ErrInvalidAddress, "invalid contract address (%s)", err) } gameType := []uint64{1, 2, 3} if !slices.Contains(gameType, msg.GameType) { - return sdkerrors.Wrap(sdkerrors.ErrInvalidType, "invalid game type, should be 1,2 or 3") + return errorsmod.Wrap(sdkerrors.ErrInvalidType, "invalid game type, should be 1,2 or 3") } return nil diff --git a/x/cron/types/params.go b/x/cron/types/params.go index 17117a4..aa92d9c 100644 --- a/x/cron/types/params.go +++ b/x/cron/types/params.go @@ -9,7 +9,7 @@ import ( var _ paramtypes.ParamSet = (*Params)(nil) var ( - DefaultSecurityAddress = []string{} + DefaultSecurityAddress []string // KeySecurityAddress is store's key for SecurityAddress Params KeySecurityAddress = []byte("SecurityAddress") KeyEnableCron = []byte("EnableCron") @@ -23,11 +23,11 @@ func ParamKeyTable() paramtypes.KeyTable { func NewParams(securityAddress []string, enableCron bool) Params { return Params{ SecurityAddress: securityAddress, - EnableCron: enableCron, + EnableCron: enableCron, } } -// default minting module parameters +// DefaultParams default minting module parameters func DefaultParams() Params { return NewParams(DefaultSecurityAddress, true) } @@ -40,7 +40,7 @@ func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs { } } -// validateSecurityAddress validates that the security addressess are valid +// validateSecurityAddress validates that the security addresses are valid func validateSecurityAddress(i interface{}) error { v, ok := i.([]string) if !ok { diff --git a/x/cron/types/query.pb.go b/x/cron/types/query.pb.go index 0990ae7..c343836 100644 --- a/x/cron/types/query.pb.go +++ b/x/cron/types/query.pb.go @@ -113,6 +113,7 @@ func (m *QueryParamsResponse) GetParams() Params { return Params{} } +// QueryWhitelistedContractsRequest is request type for the Query/WhitelistedContracts RPC method. type QueryWhitelistedContractsRequest struct { Pagination *query.PageRequest `protobuf:"bytes,1,opt,name=pagination,proto3" json:"pagination,omitempty" yaml:"pagination"` } @@ -157,6 +158,7 @@ func (m *QueryWhitelistedContractsRequest) GetPagination() *query.PageRequest { return nil } +// QueryWhitelistedContractsResponse is response type for the Query/WhitelistedContracts RPC method. type QueryWhitelistedContractsResponse struct { WhilistedContracts []WhitelistedContract `protobuf:"bytes,1,rep,name=whilisted_contracts,json=whilistedContracts,proto3" json:"whilisted_contracts"` Pagination *query.PageResponse `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty" yaml:"pagination"` @@ -268,6 +270,7 @@ const _ = grpc.SupportPackageIsVersion4 type QueryClient interface { // Parameters queries the parameters of the module. Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) + // WhitelistedContracts queries the whitelisted contracts of the module. QueryWhitelistedContracts(ctx context.Context, in *QueryWhitelistedContractsRequest, opts ...grpc.CallOption) (*QueryWhitelistedContractsResponse, error) } @@ -301,6 +304,7 @@ func (c *queryClient) QueryWhitelistedContracts(ctx context.Context, in *QueryWh type QueryServer interface { // Parameters queries the parameters of the module. Params(context.Context, *QueryParamsRequest) (*QueryParamsResponse, error) + // WhitelistedContracts queries the whitelisted contracts of the module. QueryWhitelistedContracts(context.Context, *QueryWhitelistedContractsRequest) (*QueryWhitelistedContractsResponse, error) } diff --git a/x/cron/types/tx.pb.go b/x/cron/types/tx.pb.go index 4eac9e1..2632ed7 100644 --- a/x/cron/types/tx.pb.go +++ b/x/cron/types/tx.pb.go @@ -6,9 +6,6 @@ package types import ( context "context" fmt "fmt" - _ "github.com/cosmos/cosmos-proto" - _ "github.com/cosmos/cosmos-sdk/types/msgservice" - _ "github.com/cosmos/gogoproto/gogoproto" grpc1 "github.com/gogo/protobuf/grpc" proto "github.com/gogo/protobuf/proto" grpc "google.golang.org/grpc" @@ -30,11 +27,16 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package +// MsgRegisterContract defines the Msg/RegisterContract request type. type MsgRegisterContract struct { + // security_address is the address of the security module SecurityAddress string `protobuf:"bytes,1,opt,name=security_address,json=securityAddress,proto3" json:"security_address,omitempty"` - GameName string `protobuf:"bytes,2,opt,name=game_name,json=gameName,proto3" json:"game_name,omitempty"` + // game_name is the name of the game + GameName string `protobuf:"bytes,2,opt,name=game_name,json=gameName,proto3" json:"game_name,omitempty"` + // contract_address is the address of the contract ContractAddress string `protobuf:"bytes,3,opt,name=contract_address,json=contractAddress,proto3" json:"contract_address,omitempty"` - GameType uint64 `protobuf:"varint,4,opt,name=game_type,json=gameType,proto3" json:"game_type,omitempty"` + // game_type is the type of the game 1 -> single, 2 -> multi, 3 -> both + GameType uint64 `protobuf:"varint,4,opt,name=game_type,json=gameType,proto3" json:"game_type,omitempty"` } func (m *MsgRegisterContract) Reset() { *m = MsgRegisterContract{} } @@ -98,6 +100,7 @@ func (m *MsgRegisterContract) GetGameType() uint64 { return 0 } +// MsgRegisterContractResponse defines the Msg/RegisterContract response type. type MsgRegisterContractResponse struct { } @@ -134,23 +137,24 @@ func (m *MsgRegisterContractResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgRegisterContractResponse proto.InternalMessageInfo -type MsgDeRegisterContract struct { +// MsgDeregisterContract defines the Msg/DeregisterContract request type. +type MsgDeregisterContract struct { SecurityAddress string `protobuf:"bytes,1,opt,name=security_address,json=securityAddress,proto3" json:"security_address,omitempty"` GameId uint64 `protobuf:"varint,2,opt,name=game_id,json=gameId,proto3" json:"game_id,omitempty"` } -func (m *MsgDeRegisterContract) Reset() { *m = MsgDeRegisterContract{} } -func (m *MsgDeRegisterContract) String() string { return proto.CompactTextString(m) } -func (*MsgDeRegisterContract) ProtoMessage() {} -func (*MsgDeRegisterContract) Descriptor() ([]byte, []int) { +func (m *MsgDeregisterContract) Reset() { *m = MsgDeregisterContract{} } +func (m *MsgDeregisterContract) String() string { return proto.CompactTextString(m) } +func (*MsgDeregisterContract) ProtoMessage() {} +func (*MsgDeregisterContract) Descriptor() ([]byte, []int) { return fileDescriptor_7921049427efd58c, []int{2} } -func (m *MsgDeRegisterContract) XXX_Unmarshal(b []byte) error { +func (m *MsgDeregisterContract) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *MsgDeRegisterContract) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *MsgDeregisterContract) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_MsgDeRegisterContract.Marshal(b, m, deterministic) + return xxx_messageInfo_MsgDeregisterContract.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -160,47 +164,48 @@ func (m *MsgDeRegisterContract) XXX_Marshal(b []byte, deterministic bool) ([]byt return b[:n], nil } } -func (m *MsgDeRegisterContract) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgDeRegisterContract.Merge(m, src) +func (m *MsgDeregisterContract) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgDeregisterContract.Merge(m, src) } -func (m *MsgDeRegisterContract) XXX_Size() int { +func (m *MsgDeregisterContract) XXX_Size() int { return m.Size() } -func (m *MsgDeRegisterContract) XXX_DiscardUnknown() { - xxx_messageInfo_MsgDeRegisterContract.DiscardUnknown(m) +func (m *MsgDeregisterContract) XXX_DiscardUnknown() { + xxx_messageInfo_MsgDeregisterContract.DiscardUnknown(m) } -var xxx_messageInfo_MsgDeRegisterContract proto.InternalMessageInfo +var xxx_messageInfo_MsgDeregisterContract proto.InternalMessageInfo -func (m *MsgDeRegisterContract) GetSecurityAddress() string { +func (m *MsgDeregisterContract) GetSecurityAddress() string { if m != nil { return m.SecurityAddress } return "" } -func (m *MsgDeRegisterContract) GetGameId() uint64 { +func (m *MsgDeregisterContract) GetGameId() uint64 { if m != nil { return m.GameId } return 0 } -type MsgDeRegisterContractResponse struct { +// MsgDeregisterContractResponse defines the Msg/DeregisterContract response type. +type MsgDeregisterContractResponse struct { } -func (m *MsgDeRegisterContractResponse) Reset() { *m = MsgDeRegisterContractResponse{} } -func (m *MsgDeRegisterContractResponse) String() string { return proto.CompactTextString(m) } -func (*MsgDeRegisterContractResponse) ProtoMessage() {} -func (*MsgDeRegisterContractResponse) Descriptor() ([]byte, []int) { +func (m *MsgDeregisterContractResponse) Reset() { *m = MsgDeregisterContractResponse{} } +func (m *MsgDeregisterContractResponse) String() string { return proto.CompactTextString(m) } +func (*MsgDeregisterContractResponse) ProtoMessage() {} +func (*MsgDeregisterContractResponse) Descriptor() ([]byte, []int) { return fileDescriptor_7921049427efd58c, []int{3} } -func (m *MsgDeRegisterContractResponse) XXX_Unmarshal(b []byte) error { +func (m *MsgDeregisterContractResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *MsgDeRegisterContractResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *MsgDeregisterContractResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_MsgDeRegisterContractResponse.Marshal(b, m, deterministic) + return xxx_messageInfo_MsgDeregisterContractResponse.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -210,54 +215,51 @@ func (m *MsgDeRegisterContractResponse) XXX_Marshal(b []byte, deterministic bool return b[:n], nil } } -func (m *MsgDeRegisterContractResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgDeRegisterContractResponse.Merge(m, src) +func (m *MsgDeregisterContractResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgDeregisterContractResponse.Merge(m, src) } -func (m *MsgDeRegisterContractResponse) XXX_Size() int { +func (m *MsgDeregisterContractResponse) XXX_Size() int { return m.Size() } -func (m *MsgDeRegisterContractResponse) XXX_DiscardUnknown() { - xxx_messageInfo_MsgDeRegisterContractResponse.DiscardUnknown(m) +func (m *MsgDeregisterContractResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgDeregisterContractResponse.DiscardUnknown(m) } -var xxx_messageInfo_MsgDeRegisterContractResponse proto.InternalMessageInfo +var xxx_messageInfo_MsgDeregisterContractResponse proto.InternalMessageInfo func init() { proto.RegisterType((*MsgRegisterContract)(nil), "wasmrollapp.cron.v1beta1.MsgRegisterContract") proto.RegisterType((*MsgRegisterContractResponse)(nil), "wasmrollapp.cron.v1beta1.MsgRegisterContractResponse") - proto.RegisterType((*MsgDeRegisterContract)(nil), "wasmrollapp.cron.v1beta1.MsgDeRegisterContract") - proto.RegisterType((*MsgDeRegisterContractResponse)(nil), "wasmrollapp.cron.v1beta1.MsgDeRegisterContractResponse") + proto.RegisterType((*MsgDeregisterContract)(nil), "wasmrollapp.cron.v1beta1.MsgDeregisterContract") + proto.RegisterType((*MsgDeregisterContractResponse)(nil), "wasmrollapp.cron.v1beta1.MsgDeregisterContractResponse") } func init() { proto.RegisterFile("wasmrollapp/cron/v1beta1/tx.proto", fileDescriptor_7921049427efd58c) } var fileDescriptor_7921049427efd58c = []byte{ - // 398 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08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, 0x97, 0xa9, 0x76, 0x44, 0xb9, 0x79, 0xa2, 0xfa, 0xea, 0xe5, 0xa2, 0x5b, 0x3e, 0xcd, 0x8f, - 0x37, 0x01, 0x00, 0x00, 0xff, 0xff, 0x67, 0x13, 0xe3, 0x2d, 0x4a, 0x03, 0x00, 0x00, + // 350 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x92, 0xcd, 0x4a, 0xc3, 0x40, + 0x14, 0x85, 0x3b, 0xb6, 0x54, 0x3b, 0x1b, 0x4b, 0x44, 0x0c, 0x2d, 0x8d, 0x35, 0xab, 0xba, 0x68, + 0x86, 0x2a, 0xe2, 0xda, 0x9f, 0x8d, 0x48, 0x5d, 0x04, 0x57, 0xba, 0x28, 0xd3, 0xe4, 0x12, 0x03, + 0x4d, 0x26, 0xcc, 0x4c, 0x35, 0x71, 0xe1, 0x33, 0xf8, 0x12, 0xbe, 0x8b, 0xcb, 0x2e, 0x5d, 0x4a, + 0xfb, 0x20, 0xca, 0xe4, 0x47, 0xc4, 0x46, 0xa1, 0xb8, 0xcc, 0xe1, 0xcc, 0x77, 0xee, 0xb9, 0xb9, + 0x78, 0xef, 0x81, 0x8a, 0x80, 0xb3, 0xc9, 0x84, 0x46, 0x11, 0x71, 0x38, 0x0b, 0xc9, 0xfd, 0x60, + 0x0c, 0x92, 0x0e, 0x88, 0x8c, 0xad, 0x88, 0x33, 0xc9, 0x34, 0xfd, 0x9b, 0xc5, 0x52, 0x16, 0x2b, + 0xb7, 0x98, 0x2f, 0x08, 0x6f, 0x0d, 0x85, 0x67, 0x83, 0xe7, 0x0b, 0x09, 0xfc, 0x8c, 0x85, 0x92, + 0x53, 0x47, 0x6a, 0xfb, 0xb8, 0x29, 0xc0, 0x99, 0x72, 0x5f, 0x26, 0x23, 0xea, 0xba, 0x1c, 0x84, + 0xd0, 0x51, 0x17, 0xf5, 0x1a, 0xf6, 0x66, 0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xf5, 0xf4, 0x68, 0x0f, + 0x3f, 0x03, 0x00, 0x00, 0xff, 0xff, 0xde, 0xfe, 0x28, 0xbc, 0xd9, 0x02, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -273,7 +275,7 @@ const _ = grpc.SupportPackageIsVersion4 // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. type MsgClient interface { RegisterContract(ctx context.Context, in *MsgRegisterContract, opts ...grpc.CallOption) (*MsgRegisterContractResponse, error) - DeRegisterContract(ctx context.Context, in *MsgDeRegisterContract, opts ...grpc.CallOption) (*MsgDeRegisterContractResponse, error) + DeregisterContract(ctx context.Context, in *MsgDeregisterContract, opts ...grpc.CallOption) (*MsgDeregisterContractResponse, error) } type msgClient struct { @@ -293,9 +295,9 @@ func (c *msgClient) RegisterContract(ctx context.Context, in *MsgRegisterContrac return out, nil } -func (c *msgClient) DeRegisterContract(ctx context.Context, in *MsgDeRegisterContract, opts ...grpc.CallOption) (*MsgDeRegisterContractResponse, error) { - out := new(MsgDeRegisterContractResponse) - err := c.cc.Invoke(ctx, "/wasmrollapp.cron.v1beta1.Msg/DeRegisterContract", in, out, opts...) +func (c *msgClient) DeregisterContract(ctx context.Context, in *MsgDeregisterContract, opts ...grpc.CallOption) (*MsgDeregisterContractResponse, error) { + out := new(MsgDeregisterContractResponse) + err := c.cc.Invoke(ctx, "/wasmrollapp.cron.v1beta1.Msg/DeregisterContract", in, out, opts...) if err != nil { return nil, err } @@ -305,7 +307,7 @@ func (c *msgClient) DeRegisterContract(ctx context.Context, in *MsgDeRegisterCon // MsgServer is the server API for Msg service. type MsgServer interface { RegisterContract(context.Context, *MsgRegisterContract) (*MsgRegisterContractResponse, error) - DeRegisterContract(context.Context, *MsgDeRegisterContract) (*MsgDeRegisterContractResponse, error) + DeregisterContract(context.Context, *MsgDeregisterContract) (*MsgDeregisterContractResponse, error) } // UnimplementedMsgServer can be embedded to have forward compatible implementations. @@ -315,8 +317,8 @@ type UnimplementedMsgServer struct { func (*UnimplementedMsgServer) RegisterContract(ctx context.Context, req *MsgRegisterContract) (*MsgRegisterContractResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method RegisterContract not implemented") } -func (*UnimplementedMsgServer) DeRegisterContract(ctx context.Context, req *MsgDeRegisterContract) (*MsgDeRegisterContractResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method DeRegisterContract not implemented") +func (*UnimplementedMsgServer) DeregisterContract(ctx context.Context, req *MsgDeregisterContract) (*MsgDeregisterContractResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method DeregisterContract not implemented") } func RegisterMsgServer(s grpc1.Server, srv MsgServer) { @@ -341,20 +343,20 @@ func _Msg_RegisterContract_Handler(srv interface{}, ctx context.Context, dec fun return interceptor(ctx, in, info, handler) } -func _Msg_DeRegisterContract_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(MsgDeRegisterContract) +func _Msg_DeregisterContract_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgDeregisterContract) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(MsgServer).DeRegisterContract(ctx, in) + return srv.(MsgServer).DeregisterContract(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/wasmrollapp.cron.v1beta1.Msg/DeRegisterContract", + FullMethod: "/wasmrollapp.cron.v1beta1.Msg/DeregisterContract", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MsgServer).DeRegisterContract(ctx, req.(*MsgDeRegisterContract)) + return srv.(MsgServer).DeregisterContract(ctx, req.(*MsgDeregisterContract)) } return interceptor(ctx, in, info, handler) } @@ -368,8 +370,8 @@ var _Msg_serviceDesc = grpc.ServiceDesc{ Handler: _Msg_RegisterContract_Handler, }, { - MethodName: "DeRegisterContract", - Handler: _Msg_DeRegisterContract_Handler, + MethodName: "DeregisterContract", + Handler: _Msg_DeregisterContract_Handler, }, }, Streams: []grpc.StreamDesc{}, @@ -448,7 +450,7 @@ func (m *MsgRegisterContractResponse) MarshalToSizedBuffer(dAtA []byte) (int, er return len(dAtA) - i, nil } -func (m *MsgDeRegisterContract) Marshal() (dAtA []byte, err error) { +func (m *MsgDeregisterContract) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -458,12 +460,12 @@ func (m *MsgDeRegisterContract) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *MsgDeRegisterContract) MarshalTo(dAtA []byte) (int, error) { +func (m *MsgDeregisterContract) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *MsgDeRegisterContract) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *MsgDeregisterContract) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -483,7 +485,7 @@ func (m *MsgDeRegisterContract) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *MsgDeRegisterContractResponse) Marshal() (dAtA []byte, err error) { +func (m *MsgDeregisterContractResponse) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -493,12 +495,12 @@ func (m *MsgDeRegisterContractResponse) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *MsgDeRegisterContractResponse) MarshalTo(dAtA []byte) (int, error) { +func (m *MsgDeregisterContractResponse) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *MsgDeRegisterContractResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *MsgDeregisterContractResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -550,7 +552,7 @@ func (m *MsgRegisterContractResponse) Size() (n int) { return n } -func (m *MsgDeRegisterContract) Size() (n int) { +func (m *MsgDeregisterContract) Size() (n int) { if m == nil { return 0 } @@ -566,7 +568,7 @@ func (m *MsgDeRegisterContract) Size() (n int) { return n } -func (m *MsgDeRegisterContractResponse) Size() (n int) { +func (m *MsgDeregisterContractResponse) Size() (n int) { if m == nil { return 0 } @@ -796,7 +798,7 @@ func (m *MsgRegisterContractResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *MsgDeRegisterContract) Unmarshal(dAtA []byte) error { +func (m *MsgDeregisterContract) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -819,10 +821,10 @@ func (m *MsgDeRegisterContract) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MsgDeRegisterContract: wiretype end group for non-group") + return fmt.Errorf("proto: MsgDeregisterContract: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MsgDeRegisterContract: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgDeregisterContract: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -897,7 +899,7 @@ func (m *MsgDeRegisterContract) Unmarshal(dAtA []byte) error { } return nil } -func (m *MsgDeRegisterContractResponse) Unmarshal(dAtA []byte) error { +func (m *MsgDeregisterContractResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -920,10 +922,10 @@ func (m *MsgDeRegisterContractResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MsgDeRegisterContractResponse: wiretype end group for non-group") + return fmt.Errorf("proto: MsgDeregisterContractResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MsgDeRegisterContractResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgDeregisterContractResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { default: diff --git a/x/cron/types/types.go b/x/cron/types/types.go index 9777d3a..1d31121 100644 --- a/x/cron/types/types.go +++ b/x/cron/types/types.go @@ -1,8 +1,9 @@ package types import ( - "fmt" + errorsmod "cosmossdk.io/errors" sdk "github.com/cosmos/cosmos-sdk/types" + errors "github.com/cosmos/cosmos-sdk/types/errors" "golang.org/x/exp/slices" ) @@ -25,26 +26,26 @@ func NewWhitelistContract(gameId uint64, securityAddress, contractAdmin sdk.AccA func (m WhitelistedContract) Validate() error { if m.GameId == 0 { - return fmt.Errorf("invalid GameId: %d", m.GameId) + return errorsmod.Wrap(errors.ErrInvalidRequest, "game id must not be 0") } // check if the security address is valid if _, err := sdk.AccAddressFromBech32(m.SecurityAddress); err != nil { - return fmt.Errorf("invalid SecurityAddress: %s", m.SecurityAddress) + return errorsmod.Wrapf(errors.ErrInvalidAddress, "invalid security address: %v", err) } // check if the contract admin is valid if _, err := sdk.AccAddressFromBech32(m.ContractAdmin); err != nil { - return fmt.Errorf("invalid ContractAdmin: %s", m.ContractAdmin) + return errorsmod.Wrapf(errors.ErrInvalidAddress, "invalid contract admin: %v", err) } if m.GameName == "" { - return fmt.Errorf("invalid GameName: %s", m.GameName) + return errorsmod.Wrap(errors.ErrInvalidRequest, "game name must not be empty") } // check if the contract address is valid if _, err := sdk.AccAddressFromBech32(m.ContractAddress); err != nil { - return fmt.Errorf("invalid ContractAddress: %s", m.ContractAddress) + return errorsmod.Wrapf(errors.ErrInvalidAddress, "invalid ContractAddress: %v", err) } - // check if game type does not contain 1,2,3 + // check if game type does not contain 1,2,3 if !slices.Contains([]uint64{1, 2, 3}, m.GameType) { - return fmt.Errorf("invalid GameType: %d", m.GameType) + return errorsmod.Wrapf(errors.ErrInvalidRequest, "invalid game type, should be 1, 2 or 3") } return nil