Skip to content

Commit

Permalink
Move all permissions address from denommetadata, hubgenesis to sequen…
Browse files Browse the repository at this point in the history
…cers
  • Loading branch information
trinitys7 committed Apr 25, 2024
1 parent f6997e0 commit 6312884
Show file tree
Hide file tree
Showing 51 changed files with 2,072 additions and 2,376 deletions.
8 changes: 1 addition & 7 deletions proto/denommetadata/genesis.proto
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
syntax = "proto3";
package rollapp.denommetadata.types;

import "gogoproto/gogo.proto";
import "denommetadata/params.proto";

option go_package = "github.com/dymensionxyz/dymension-rdk/x/denommetadata/types";

// GenesisState defines the test module's genesis state.
message GenesisState {
// params are all parameters for the module
Params params = 1 [ (gogoproto.nullable) = false ];
}
message GenesisState {}
13 changes: 0 additions & 13 deletions proto/denommetadata/params.proto

This file was deleted.

16 changes: 0 additions & 16 deletions proto/denommetadata/query.proto
Original file line number Diff line number Diff line change
@@ -1,19 +1,12 @@
syntax = "proto3";
package rollapp.denommetadata.types;

import "gogoproto/gogo.proto";
import "google/api/annotations.proto";
import "denommetadata/params.proto";

option go_package = "github.com/dymensionxyz/dymension-rdk/x/denommetadata/types";

// Query defines the gRPC querier service.
service Query {
// Parameters retrieves the denom metadata module params
rpc Params(QueryParamsRequest) returns (QueryParamsResponse) {
option (google.api.http).get =
"/dymensionxyz/dymension-rdk/denommetadata/params";
}
// Queries an IBC denom base on denom trace
rpc IBCDenomByDenomTrace(QueryGetIBCDenomByDenomTraceRequest)
returns (QueryIBCDenomByDenomTraceResponse) {
Expand All @@ -22,15 +15,6 @@ service Query {
}
}

// QueryParamsRequest is request type for the Query/Params RPC method.
message QueryParamsRequest {}

// QueryParamsResponse is response type for the Query/Params RPC method.
message QueryParamsResponse {
// params holds all the parameters of this module.
Params params = 1 [ (gogoproto.nullable) = false ];
}

// QueryGetIBCDenomByDenomTraceRequest is the request type for the
// Query/IBCDenomByDenomTrace RPC method.
message QueryGetIBCDenomByDenomTraceRequest {
Expand Down
7 changes: 1 addition & 6 deletions proto/hub-genesis/genesis.proto
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,9 @@ syntax = "proto3";
package rollapp.hub_genesis;

import "gogoproto/gogo.proto";
import "hub-genesis/params.proto";
import "hub-genesis/state.proto";

option go_package = "github.com/dymensionxyz/dymension-rdk/x/hub-genesis/types";

// GenesisState defines the hub-genesis module's genesis state.
message GenesisState {
// params defines all the parameters of the module.
Params params = 1 [ (gogoproto.nullable) = false ];
State state = 2 [(gogoproto.nullable) = false];
}
message GenesisState { State state = 2 [ (gogoproto.nullable) = false ]; }
25 changes: 0 additions & 25 deletions proto/hub-genesis/params.proto

This file was deleted.

22 changes: 3 additions & 19 deletions proto/hub-genesis/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -3,40 +3,24 @@ package rollapp.hub_genesis;

import "gogoproto/gogo.proto";
import "google/api/annotations.proto";
import "hub-genesis/params.proto";
import "hub-genesis/state.proto";

option go_package = "github.com/dymensionxyz/dymension-rdk/x/hub-genesis/types";

// Query provides defines the gRPC querier service.
service Query {
// Params returns the total set of hub-genesis parameters.
rpc Params(QueryParamsRequest) returns (QueryParamsResponse) {
option (google.api.http).get =
"/dymensionxyz/dymension-rdk/hub-genesis/params";
}

// State returns the state of the genesis event.
rpc State(QueryStateRequest) returns (QueryStateResponse) {
// State returns the state of the genesis event.
rpc State(QueryStateRequest) returns (QueryStateResponse) {
option (google.api.http).get =
"/dymensionxyz/dymension-rdk/hub-genesis/state";
}
}

// QueryParamsRequest is the request type for the Query/Params RPC method.
message QueryParamsRequest {}

// QueryParamsResponse is the response type for the Query/Params RPC method.
message QueryParamsResponse {
// params defines the parameters of the module.
Params params = 1 [ (gogoproto.nullable) = false ];
}

// QueryStateRequest is the request type for the Query/State RPC method.
message QueryStateRequest {}

// QueryStateResponse is the response type for the Query/State RPC method.
message QueryStateResponse {
// state holds the state of the genesis event
State state = 1 [(gogoproto.nullable) = false];
State state = 1 [ (gogoproto.nullable) = false ];
}
16 changes: 8 additions & 8 deletions proto/hub-genesis/state.proto
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ option go_package = "github.com/dymensionxyz/dymension-rdk/x/hub-genesis/types";

// State holds the state of the genesis event
message State {
// is_locked is a boolean that indicates if the genesis event has occured
bool is_locked = 1;

// genesis_tokens is the list of tokens that are expected to be locked on genesis event
repeated cosmos.base.v1beta1.Coin genesis_tokens = 2 [
(gogoproto.nullable) = false,
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"
];
// is_locked is a boolean that indicates if the genesis event has occured
bool is_locked = 1;

// genesis_tokens is the list of tokens that are expected to be locked on
// genesis event
repeated cosmos.base.v1beta1.Coin genesis_tokens = 2 [
(gogoproto.nullable) = false,
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"
];
}
12 changes: 10 additions & 2 deletions proto/sequencers/genesis.proto
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package rollapp.sequencers.types;

import "gogoproto/gogo.proto";
import "sequencers/params.proto";
import "sequencers/permission.proto";

// this line is used by starport scaffolding # genesis/proto/import

Expand All @@ -12,7 +13,14 @@ option go_package = "github.com/dymensionxyz/dymension-rdk/x/sequencers/types";
message GenesisState {
Params params = 1 [ (gogoproto.nullable) = false ];

// the address and its permissions to trigger some special actions
// on the rollapp
repeated AddressPermissions address_permissions = 2 [
(gogoproto.moretags) = "yaml:\"address_permissions\"",
(gogoproto.nullable) = false
];

// genesis_operator_address defines the genesis operator address of the
// sequencer.
string genesis_operator_address = 2;
}
string genesis_operator_address = 3;
}
29 changes: 29 additions & 0 deletions proto/sequencers/gov_permission.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
syntax = "proto3";
package rollapp.sequencers.types;

import "gogoproto/gogo.proto";
import "sequencers/permission.proto";

option go_package = "github.com/dymensionxyz/dymension-rdk/x/sequencers/types";

message GrantPermissionsProposal {
option (gogoproto.equal) = true;
option (gogoproto.goproto_getters) = false;
option (gogoproto.goproto_stringer) = false;

string title = 1;
string description = 2;

AddressPermissions address_permissions = 3 [ (gogoproto.nullable) = false ];
}

message RevokePermissionsProposal {
option (gogoproto.equal) = true;
option (gogoproto.goproto_getters) = false;
option (gogoproto.goproto_stringer) = false;

string title = 1;
string description = 2;

AddressPermissions address_permissions = 3 [ (gogoproto.nullable) = false ];
}
26 changes: 26 additions & 0 deletions proto/sequencers/permission.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
syntax = "proto3";
package rollapp.sequencers.types;

import "gogoproto/gogo.proto";

// this line is used by starport scaffolding # genesis/proto/import

option go_package = "github.com/dymensionxyz/dymension-rdk/x/sequencers/types";

message AddressPermissions {
option (gogoproto.equal) = true;

string address = 1 [ (gogoproto.moretags) = "yaml:\"address\"" ];
// list of the module name that addresses have permission to execute msg
Permissions permissions = 2 [
(gogoproto.moretags) = "yaml:\"permissions\"",
(gogoproto.nullable) = false
];
}

message Permissions {
option (gogoproto.equal) = true;

repeated string permissions = 1
[ (gogoproto.moretags) = "yaml:\"permissions\"" ];
}
11 changes: 4 additions & 7 deletions testutil/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ import (
"github.com/cosmos/cosmos-sdk/x/auth/posthandler"
authsims "github.com/cosmos/cosmos-sdk/x/auth/simulation"
"github.com/cosmos/cosmos-sdk/x/auth/tx"
authtx "github.com/cosmos/cosmos-sdk/x/auth/tx"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
"github.com/cosmos/cosmos-sdk/x/auth/vesting"
vestingtypes "github.com/cosmos/cosmos-sdk/x/auth/vesting/types"
Expand Down Expand Up @@ -414,10 +413,10 @@ func NewRollapp(
app.DenommetadataKeeper = denommetadatakeeper.NewKeeper(
appCodec,
keys[denommetadatatypes.StoreKey],
app.SequencersKeeper,
app.BankKeeper,
app.TransferKeeper,
nil,
app.GetSubspace(denommetadatatypes.ModuleName),
)
// set hook for denom metadata keeper later
app.DenommetadataKeeper.SetHooks(
Expand All @@ -429,8 +428,8 @@ func NewRollapp(
app.HubGenesisKeeper = hubgenkeeper.NewKeeper(
appCodec,
keys[hubgentypes.StoreKey],
app.GetSubspace(hubgentypes.ModuleName),
app.IBCKeeper.ChannelKeeper,
app.SequencersKeeper,
app.BankKeeper,
app.AccountKeeper,
)
Expand Down Expand Up @@ -746,7 +745,7 @@ func (app *App) SimulationManager() *module.SimulationManager {
func (app *App) RegisterAPIRoutes(apiSvr *api.Server, apiConfig config.APIConfig) {
clientCtx := apiSvr.ClientCtx
// Register new tx routes from grpc-gateway.
authtx.RegisterGRPCGatewayRoutes(clientCtx, apiSvr.GRPCGatewayRouter)
tx.RegisterGRPCGatewayRoutes(clientCtx, apiSvr.GRPCGatewayRouter)
// Register new tendermint queries routes from grpc-gateway.
tmservice.RegisterGRPCGatewayRoutes(clientCtx, apiSvr.GRPCGatewayRouter)

Expand All @@ -764,7 +763,7 @@ func (app *App) RegisterAPIRoutes(apiSvr *api.Server, apiConfig config.APIConfig

// RegisterTxService implements the Application.RegisterTxService method.
func (app *App) RegisterTxService(clientCtx client.Context) {
authtx.RegisterTxService(app.BaseApp.GRPCQueryRouter(), clientCtx, app.BaseApp.Simulate, app.interfaceRegistry)
tx.RegisterTxService(app.BaseApp.GRPCQueryRouter(), clientCtx, app.BaseApp.Simulate, app.interfaceRegistry)
}

// RegisterTendermintService implements the Application.RegisterTendermintService method.
Expand Down Expand Up @@ -843,13 +842,11 @@ func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino
paramsKeeper.Subspace(stakingtypes.ModuleName)
paramsKeeper.Subspace(seqtypes.ModuleName)
paramsKeeper.Subspace(minttypes.ModuleName)
paramsKeeper.Subspace(denommetadatatypes.ModuleName)
paramsKeeper.Subspace(epochstypes.ModuleName)
paramsKeeper.Subspace(distrtypes.ModuleName)
paramsKeeper.Subspace(govtypes.ModuleName).WithKeyTable(govv1.ParamKeyTable())
paramsKeeper.Subspace(ibctransfertypes.ModuleName)
paramsKeeper.Subspace(ibchost.ModuleName)
paramsKeeper.Subspace(hubgentypes.ModuleName)

return paramsKeeper
}
Expand Down
30 changes: 0 additions & 30 deletions x/denommetadata/client/cli/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,42 +23,12 @@ func GetQueryCmd() *cobra.Command {
}

denommetadataQueryCmd.AddCommand(
GetCmdQueryParams(),
GetCmdIBCDenomBaseOnDenomTrace(),
)

return denommetadataQueryCmd
}

// GetCmdQueryParams implements a command to return the current parameters.
func GetCmdQueryParams() *cobra.Command {
cmd := &cobra.Command{
Use: "params",
Short: "Query the current denom metadata module parameters",
Args: cobra.NoArgs,
RunE: func(cmd *cobra.Command, _ []string) error {
clientCtx, err := client.GetClientQueryContext(cmd)
if err != nil {
return err
}
queryClient := types.NewQueryClient(clientCtx)

params := &types.QueryParamsRequest{}

res, err := queryClient.Params(context.Background(), params)
if err != nil {
return err
}

return clientCtx.PrintProto(&res.Params)
},
}

flags.AddQueryFlagsToCmd(cmd)

return cmd
}

// GetCmdIBCDenomBaseOnDenomTrace implements a command to return the IBC denom base on a denom trace.
func GetCmdIBCDenomBaseOnDenomTrace() *cobra.Command {
cmd := &cobra.Command{
Expand Down
21 changes: 2 additions & 19 deletions x/denommetadata/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,27 +9,10 @@ import (

// DefaultGenesis returns the default Capability genesis state
func DefaultGenesis() *types.GenesisState {
return &types.GenesisState{
Params: types.DefaultParams(),
}
}

// InitGenesis import module genesis
func InitGenesis(
ctx sdk.Context,
k keeper.Keeper,
data types.GenesisState,
) {
k.SetParams(ctx, data.Params)
return &types.GenesisState{}
}

// ExportGenesis export module state
func ExportGenesis(ctx sdk.Context, k keeper.Keeper) *types.GenesisState {
return &types.GenesisState{
Params: k.GetParams(ctx),
}
}

func ValidateGenesis(gs types.GenesisState) error {
return gs.Params.Validate()
return &types.GenesisState{}
}
Loading

0 comments on commit 6312884

Please sign in to comment.