-
Notifications
You must be signed in to change notification settings - Fork 217
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
47 changed files
with
8,322 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
syntax = "proto3"; | ||
package neutron.cron; | ||
|
||
import "gogoproto/gogo.proto"; | ||
import "neutron/cron/params.proto"; | ||
import "neutron/cron/schedule.proto"; | ||
// this line is used by starport scaffolding # genesis/proto/import | ||
|
||
option go_package = "github.com/neutron-org/neutron/v5/x/cron/types"; | ||
|
||
// Defines the cron module's genesis state. | ||
message GenesisState { | ||
repeated Schedule scheduleList = 2 [(gogoproto.nullable) = false]; | ||
Params params = 1 [(gogoproto.nullable) = false]; | ||
// this line is used by starport scaffolding # genesis/proto/state | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
syntax = "proto3"; | ||
package neutron.cron; | ||
|
||
import "gogoproto/gogo.proto"; | ||
|
||
option go_package = "github.com/neutron-org/neutron/v5/x/cron/types"; | ||
|
||
// Defines the parameters for the module. | ||
message Params { | ||
option (gogoproto.goproto_stringer) = false; | ||
// Security address that can remove schedules | ||
string security_address = 1; | ||
// Limit of schedules executed in one block | ||
uint64 limit = 2; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
syntax = "proto3"; | ||
package neutron.cron; | ||
|
||
import "cosmos/base/query/v1beta1/pagination.proto"; | ||
import "gogoproto/gogo.proto"; | ||
import "google/api/annotations.proto"; | ||
import "neutron/cron/params.proto"; | ||
import "neutron/cron/schedule.proto"; | ||
// this line is used by starport scaffolding # 1 | ||
|
||
option go_package = "github.com/neutron-org/neutron/v5/x/cron/types"; | ||
|
||
// Defines the gRPC querier service. | ||
service Query { | ||
// Queries the parameters of the module. | ||
rpc Params(QueryParamsRequest) returns (QueryParamsResponse) { | ||
option (google.api.http).get = "/neutron/cron/params"; | ||
} | ||
|
||
// Queries a Schedule by name. | ||
rpc Schedule(QueryGetScheduleRequest) returns (QueryGetScheduleResponse) { | ||
option (google.api.http).get = "/neutron/cron/schedule/{name}"; | ||
} | ||
|
||
// Queries a list of Schedule items. | ||
rpc Schedules(QuerySchedulesRequest) returns (QuerySchedulesResponse) { | ||
option (google.api.http).get = "/neutron/cron/schedule"; | ||
} | ||
|
||
// this line is used by starport scaffolding # 2 | ||
} | ||
|
||
// The request type for the Query/Params RPC method. | ||
message QueryParamsRequest {} | ||
|
||
// The response type for the Query/Params RPC method. | ||
message QueryParamsResponse { | ||
// params holds all the parameters of this module. | ||
Params params = 1 [(gogoproto.nullable) = false]; | ||
} | ||
|
||
// The request type for the Query/Schedule RPC method. | ||
message QueryGetScheduleRequest { | ||
string name = 1; | ||
} | ||
|
||
// The response type for the Query/Params RPC method. | ||
message QueryGetScheduleResponse { | ||
Schedule schedule = 1 [(gogoproto.nullable) = false]; | ||
} | ||
|
||
// The request type for the Query/Schedules RPC method. | ||
message QuerySchedulesRequest { | ||
cosmos.base.query.v1beta1.PageRequest pagination = 1; | ||
} | ||
|
||
// The response type for the Query/Params RPC method. | ||
message QuerySchedulesResponse { | ||
repeated Schedule schedules = 1 [(gogoproto.nullable) = false]; | ||
cosmos.base.query.v1beta1.PageResponse pagination = 2; | ||
} | ||
|
||
// this line is used by starport scaffolding # 3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
syntax = "proto3"; | ||
package neutron.cron; | ||
|
||
import "gogoproto/gogo.proto"; | ||
|
||
option go_package = "github.com/neutron-org/neutron/v5/x/cron/types"; | ||
|
||
// Defines when messages will be executed in the block | ||
enum ExecutionStage { | ||
// Execution at the end of the block | ||
EXECUTION_STAGE_END_BLOCKER = 0; | ||
// Execution at the beginning of the block | ||
EXECUTION_STAGE_BEGIN_BLOCKER = 1; | ||
} | ||
|
||
// Defines the schedule for execution | ||
message Schedule { | ||
// Name of schedule | ||
string name = 1; | ||
// Period in blocks | ||
uint64 period = 2; | ||
// Msgs that will be executed every certain number of blocks, specified in the `period` field | ||
repeated MsgExecuteContract msgs = 3 [(gogoproto.nullable) = false]; | ||
// Last execution's block height | ||
uint64 last_execute_height = 4; | ||
// Stage when messages will be executed | ||
ExecutionStage execution_stage = 5; | ||
} | ||
|
||
// Defines the contract and the message to pass | ||
message MsgExecuteContract { | ||
// The address of the smart contract | ||
string contract = 1; | ||
// JSON encoded message to be passed to the contract | ||
string msg = 2; | ||
} | ||
|
||
// Defines the number of current schedules | ||
message ScheduleCount { | ||
// The number of current schedules | ||
int32 count = 1; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
syntax = "proto3"; | ||
package neutron.cron; | ||
|
||
import "amino/amino.proto"; | ||
import "cosmos/msg/v1/msg.proto"; | ||
import "cosmos_proto/cosmos.proto"; | ||
import "gogoproto/gogo.proto"; | ||
import "neutron/cron/params.proto"; | ||
import "neutron/cron/schedule.proto"; | ||
|
||
// this line is used by starport scaffolding # proto/tx/import | ||
|
||
option go_package = "github.com/neutron-org/neutron/v5/x/cron/types"; | ||
|
||
// Defines the Msg service. | ||
service Msg { | ||
option (cosmos.msg.v1.service) = true; | ||
|
||
// Adds new schedule. | ||
rpc AddSchedule(MsgAddSchedule) returns (MsgAddScheduleResponse); | ||
// Removes schedule. | ||
rpc RemoveSchedule(MsgRemoveSchedule) returns (MsgRemoveScheduleResponse); | ||
// Updates the module parameters. | ||
rpc UpdateParams(MsgUpdateParams) returns (MsgUpdateParamsResponse); | ||
// this line is used by starport scaffolding # proto/tx/rpc | ||
} | ||
|
||
// The MsgAddSchedule request type. | ||
message MsgAddSchedule { | ||
option (amino.name) = "cron/MsgAddSchedule"; | ||
option (cosmos.msg.v1.signer) = "authority"; | ||
|
||
// The address of the governance account. | ||
string authority = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; | ||
// Name of the schedule | ||
string name = 2; | ||
// Period in blocks | ||
uint64 period = 3; | ||
// Msgs that will be executed every certain number of blocks, specified in the `period` field | ||
repeated MsgExecuteContract msgs = 4 [(gogoproto.nullable) = false]; | ||
// Stage when messages will be executed | ||
ExecutionStage execution_stage = 5; | ||
} | ||
|
||
// Defines the response structure for executing a MsgAddSchedule message. | ||
message MsgAddScheduleResponse {} | ||
|
||
// The MsgRemoveSchedule request type. | ||
message MsgRemoveSchedule { | ||
option (amino.name) = "cron/MsgRemoveSchedule"; | ||
option (cosmos.msg.v1.signer) = "authority"; | ||
|
||
// The address of the governance account. | ||
string authority = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; | ||
// Name of the schedule | ||
string name = 2; | ||
} | ||
|
||
// Defines the response structure for executing a MsgRemoveSchedule message. | ||
message MsgRemoveScheduleResponse {} | ||
|
||
// this line is used by starport scaffolding # proto/tx/message | ||
|
||
// The MsgUpdateParams request type. | ||
// | ||
// Since: 0.47 | ||
message MsgUpdateParams { | ||
option (amino.name) = "cron/MsgUpdateParams"; | ||
option (cosmos.msg.v1.signer) = "authority"; | ||
|
||
// The address of the governance account. | ||
string authority = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; | ||
|
||
// Defines the x/cron parameters to update. | ||
// | ||
// NOTE: All parameters must be supplied. | ||
Params params = 2 [ | ||
(gogoproto.nullable) = false, | ||
(amino.dont_omitempty) = true | ||
]; | ||
} | ||
|
||
// Defines the response structure for executing a MsgUpdateParams message. | ||
// | ||
// Since: 0.47 | ||
message MsgUpdateParamsResponse {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
syntax = "proto3"; | ||
package neutron.cron.v1; | ||
|
||
import "gogoproto/gogo.proto"; | ||
|
||
option go_package = "github.com/neutron-org/neutron/v5/x/cron/types/v1"; | ||
|
||
// Defines the schedule for execution | ||
message Schedule { | ||
// Name of schedule | ||
string name = 1; | ||
// Period in blocks | ||
uint64 period = 2; | ||
// Msgs that will be executed every certain number of blocks, specified in the `period` field | ||
repeated MsgExecuteContract msgs = 3 [(gogoproto.nullable) = false]; | ||
// Last execution's block height | ||
uint64 last_execute_height = 4; | ||
} | ||
|
||
// Defines the contract and the message to pass | ||
message MsgExecuteContract { | ||
// The address of the smart contract | ||
string contract = 1; | ||
// JSON encoded message to be passed to the contract | ||
string msg = 2; | ||
} | ||
|
||
// Defines the number of current schedules | ||
message ScheduleCount { | ||
// The number of current schedules | ||
int32 count = 1; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package cli | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/spf13/cobra" | ||
|
||
"github.com/cosmos/cosmos-sdk/client" | ||
|
||
"github.com/neutron-org/neutron/v5/x/cron/types" | ||
) | ||
|
||
// GetQueryCmd returns the cli query commands for this module | ||
func GetQueryCmd(_ string) *cobra.Command { | ||
// Group cron queries under a subcommand | ||
cmd := &cobra.Command{ | ||
Use: types.ModuleName, | ||
Short: fmt.Sprintf("Querying commands for the %s module", types.ModuleName), | ||
DisableFlagParsing: true, | ||
SuggestionsMinimumDistance: 2, | ||
RunE: client.ValidateCmd, | ||
} | ||
|
||
cmd.AddCommand(CmdQueryParams()) | ||
cmd.AddCommand(CmdListSchedule()) | ||
cmd.AddCommand(CmdShowSchedule()) | ||
|
||
return cmd | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package cli | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/cosmos/cosmos-sdk/client" | ||
"github.com/cosmos/cosmos-sdk/client/flags" | ||
"github.com/spf13/cobra" | ||
|
||
"github.com/neutron-org/neutron/v5/x/cron/types" | ||
) | ||
|
||
func CmdQueryParams() *cobra.Command { | ||
cmd := &cobra.Command{ | ||
Use: "params", | ||
Short: "shows the parameters of the module", | ||
Args: cobra.NoArgs, | ||
RunE: func(cmd *cobra.Command, _ []string) error { | ||
clientCtx := client.GetClientContextFromCmd(cmd) | ||
|
||
queryClient := types.NewQueryClient(clientCtx) | ||
|
||
res, err := queryClient.Params(context.Background(), &types.QueryParamsRequest{}) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
return clientCtx.PrintProto(res) | ||
}, | ||
} | ||
|
||
flags.AddQueryFlagsToCmd(cmd) | ||
|
||
return cmd | ||
} |
Oops, something went wrong.