Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: refactor whitelisted_addresses #392

Merged
merged 4 commits into from
Apr 25, 2024
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
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 {}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if this is empty, why do we need it at all?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should keep it as it's the cosmos-sdk standard, and in case we need to store some states in the future

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 = 1 [ (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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// is_locked is a boolean that indicates if the genesis event has occured
// is_locked is a boolean that indicates if the genesis event has occurred

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;
}
31 changes: 31 additions & 0 deletions proto/sequencers/gov_permission.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
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;

repeated 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;

repeated 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
PermissionList permission_list = 2 [
(gogoproto.moretags) = "yaml:\"permission_list\"",
(gogoproto.nullable) = false
];
}

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

repeated string permissions = 1
[ (gogoproto.moretags) = "yaml:\"permissions\"" ];
}
20 changes: 20 additions & 0 deletions proto/sequencers/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ service Query {
"/dymensionxyz/dymension-rdk/sequencers/historical_info/{height}";
}

// Permissions queries the permissions for given address.
rpc Permissions(QueryPermissionsRequest) returns (QueryPermissionsResponse) {
option (google.api.http).get =
"/dymensionxyz/dymension-rdk/sequencers/permissions/{address}";
}

// Parameters queries the staking parameters.
rpc Params(QueryParamsRequest) returns (QueryParamsResponse) {
option (google.api.http).get = "/cosmos/staking/v1beta1/params";
Expand Down Expand Up @@ -84,6 +90,20 @@ message QueryHistoricalInfoResponse {
cosmos.staking.v1beta1.HistoricalInfo hist = 1;
}

// QueryPermissionsRequest is request type for the Query/Permissions RPC
// method.
message QueryPermissionsRequest {
// address defines the address to query for.
string address = 1;
}

// QueryPermissionsResponse is response type for the Query/Permissions RPC
// method.
message QueryPermissionsResponse {
// permissions defines the permissions for the given address.
string permissions = 1;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not repeated string permissions = 1; ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to store it in KVStore, and the repeated string, which will be convert to []string can not be Marshal to bytes in codec. This's the reason I make a wrapper struct for that

}

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

Expand Down
10 changes: 4 additions & 6 deletions testutil/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ import (
authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper"
"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"
Expand Down Expand Up @@ -379,6 +378,7 @@ func NewRollapp(
AddRoute(paramproposal.RouterKey, params.NewParamChangeProposalHandler(app.ParamsKeeper)).
AddRoute(distrtypes.RouterKey, distr.NewCommunityPoolSpendProposalHandler(app.DistrKeeper)).
AddRoute(upgradetypes.RouterKey, upgrade.NewSoftwareUpgradeProposalHandler(app.UpgradeKeeper)).
AddRoute(seqtypes.RouterKey, sequencers.NewUpdatePermissionProposalHandler(&app.SequencersKeeper)).
AddRoute(ibcclienttypes.RouterKey, ibcclient.NewClientProposalHandler(app.IBCKeeper.ClientKeeper))

govConfig := govtypes.DefaultConfig()
Expand Down Expand Up @@ -414,10 +414,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 +429,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 @@ -843,13 +843,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 All @@ -866,7 +864,7 @@ func MakeEncodingConfig() EncodingConfig {
amino := codec.NewLegacyAmino()
interfaceRegistry := types.NewInterfaceRegistry()
codec := codec.NewProtoCodec(interfaceRegistry)
txCfg := tx.NewTxConfig(codec, tx.DefaultSignModes)
txCfg := authtx.NewTxConfig(codec, authtx.DefaultSignModes)

encodingConfig := EncodingConfig{
InterfaceRegistry: interfaceRegistry,
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
Loading
Loading