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

Rustninja/ibctransfer custom ibc transfer module added to store params for eth fees #448

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
7 changes: 7 additions & 0 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ import (
custombankmodule "github.com/notional-labs/composable/v6/custom/bank"

"github.com/notional-labs/composable/v6/app/ante"
"github.com/notional-labs/composable/v6/x/ibctransfermiddleware"
"github.com/notional-labs/composable/v6/x/stakingmiddleware"
transfermiddleware "github.com/notional-labs/composable/v6/x/transfermiddleware"
transfermiddlewaretypes "github.com/notional-labs/composable/v6/x/transfermiddleware/types"
Expand All @@ -127,6 +128,7 @@ import (
wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types"

upgrades "github.com/notional-labs/composable/v6/app/upgrades"
ibctransfermiddlewaretypes "github.com/notional-labs/composable/v6/x/ibctransfermiddleware/types"
stakingmiddlewaretypes "github.com/notional-labs/composable/v6/x/stakingmiddleware/types"
)

Expand Down Expand Up @@ -227,6 +229,7 @@ var (
consensus.AppModuleBasic{},
alliancemodule.AppModuleBasic{},
stakingmiddleware.AppModuleBasic{},
ibctransfermiddleware.AppModuleBasic{},
// this line is used by starport scaffolding # stargate/app/moduleBasic
)

Expand Down Expand Up @@ -371,6 +374,7 @@ func NewComposableApp(
distr.NewAppModule(appCodec, app.DistrKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper, app.GetSubspace(distrtypes.ModuleName)),
customstaking.NewAppModule(appCodec, *app.StakingKeeper, app.AccountKeeper, app.BankKeeper, app.GetSubspace(stakingtypes.ModuleName)),
stakingmiddleware.NewAppModule(appCodec, app.StakingMiddlewareKeeper),
ibctransfermiddleware.NewAppModule(appCodec, app.IbcTransferMiddlewareKeeper),
authzmodule.NewAppModule(appCodec, app.AuthzKeeper, app.AccountKeeper, app.BankKeeper, app.interfaceRegistry),
upgrade.NewAppModule(app.UpgradeKeeper),
evidence.NewAppModule(app.EvidenceKeeper),
Expand Down Expand Up @@ -427,6 +431,7 @@ func NewComposableApp(
wasm.ModuleName,
alliancemoduletypes.ModuleName,
stakingmiddlewaretypes.ModuleName,
ibctransfermiddlewaretypes.ModuleName,
// this line is used by starport scaffolding # stargate/app/beginBlockers
)

Expand Down Expand Up @@ -462,6 +467,7 @@ func NewComposableApp(
wasm.ModuleName,
alliancemoduletypes.ModuleName,
stakingmiddlewaretypes.ModuleName,
ibctransfermiddlewaretypes.ModuleName,
)

// NOTE: The genutils module must occur after staking so that pools are
Expand Down Expand Up @@ -501,6 +507,7 @@ func NewComposableApp(
wasm.ModuleName,
alliancemoduletypes.ModuleName,
stakingmiddlewaretypes.ModuleName,
ibctransfermiddlewaretypes.ModuleName,
// this line is used by starport scaffolding # stargate/app/initGenesis
)

Expand Down
20 changes: 13 additions & 7 deletions app/keepers/keepers.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,9 @@ import (
ibchookstypes "github.com/notional-labs/composable/v6/x/ibc-hooks/types"
stakingmiddleware "github.com/notional-labs/composable/v6/x/stakingmiddleware/keeper"
stakingmiddlewaretypes "github.com/notional-labs/composable/v6/x/stakingmiddleware/types"

ibctransfermiddleware "github.com/notional-labs/composable/v6/x/ibctransfermiddleware/keeper"
ibctransfermiddlewaretypes "github.com/notional-labs/composable/v6/x/ibctransfermiddleware/types"
)

const (
Expand Down Expand Up @@ -156,12 +159,13 @@ type AppKeepers struct {
ScopedRateLimitKeeper capabilitykeeper.ScopedKeeper
ConsensusParamsKeeper consensusparamkeeper.Keeper
// this line is used by starport scaffolding # stargate/app/keeperDeclaration
TransferMiddlewareKeeper transfermiddlewarekeeper.Keeper
TxBoundaryKeepper txBoundaryKeeper.Keeper
RouterKeeper *routerkeeper.Keeper
RatelimitKeeper ratelimitmodulekeeper.Keeper
AllianceKeeper alliancemodulekeeper.Keeper
StakingMiddlewareKeeper stakingmiddleware.Keeper
TransferMiddlewareKeeper transfermiddlewarekeeper.Keeper
TxBoundaryKeepper txBoundaryKeeper.Keeper
RouterKeeper *routerkeeper.Keeper
RatelimitKeeper ratelimitmodulekeeper.Keeper
AllianceKeeper alliancemodulekeeper.Keeper
StakingMiddlewareKeeper stakingmiddleware.Keeper
IbcTransferMiddlewareKeeper ibctransfermiddleware.Keeper
}

// InitNormalKeepers initializes all 'normal' keepers.
Expand Down Expand Up @@ -194,6 +198,7 @@ func (appKeepers *AppKeepers) InitNormalKeepers(
)

appKeepers.StakingMiddlewareKeeper = stakingmiddleware.NewKeeper(appCodec, appKeepers.keys[stakingmiddlewaretypes.StoreKey], authtypes.NewModuleAddress(govtypes.ModuleName).String())
appKeepers.IbcTransferMiddlewareKeeper = ibctransfermiddleware.NewKeeper(appCodec, appKeepers.keys[ibctransfermiddlewaretypes.StoreKey], authtypes.NewModuleAddress(govtypes.ModuleName).String())

appKeepers.StakingKeeper = customstaking.NewKeeper(
appCodec, appKeepers.keys[stakingtypes.StoreKey], appKeepers.AccountKeeper, appKeepers.BankKeeper, authtypes.NewModuleAddress(govtypes.ModuleName).String(), &appKeepers.StakingMiddlewareKeeper,
Expand Down Expand Up @@ -394,7 +399,7 @@ func (appKeepers *AppKeepers) InitNormalKeepers(
appKeepers.IBCKeeper.ChannelKeeper,
&appKeepers.IBCKeeper.PortKeeper,
appKeepers.ScopedWasmKeeper,
appKeepers.TransferKeeper,
appKeepers.TransferKeeper.Keeper,
bApp.MsgServiceRouter(),
bApp.GRPCQueryRouter(),
wasmDir,
Expand Down Expand Up @@ -492,6 +497,7 @@ func (appKeepers *AppKeepers) initParamsKeeper(appCodec codec.BinaryCodec, legac
paramsKeeper.Subspace(wasm.ModuleName)
paramsKeeper.Subspace(transfermiddlewaretypes.ModuleName)
paramsKeeper.Subspace(stakingmiddlewaretypes.ModuleName)
paramsKeeper.Subspace(ibctransfermiddlewaretypes.ModuleName)

return paramsKeeper
}
Expand Down
4 changes: 3 additions & 1 deletion app/keepers/keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ import (

// customstakingtypes "github.com/notional-labs/composable/v6/custom/staking/types"
stakingmiddleware "github.com/notional-labs/composable/v6/x/stakingmiddleware/types"

ibctransfermiddleware "github.com/notional-labs/composable/v6/x/ibctransfermiddleware/types"
)

// GenerateKeys generates new keys (KV Store, Transient store, and memory store).
Expand All @@ -55,7 +57,7 @@ func (appKeepers *AppKeepers) GenerateKeys() {
authtypes.StoreKey, banktypes.StoreKey, stakingtypes.StoreKey, distrtypes.StoreKey, slashingtypes.StoreKey,
govtypes.StoreKey, paramstypes.StoreKey, ibchost.StoreKey, upgradetypes.StoreKey, feegrant.StoreKey,
evidencetypes.StoreKey, ibctransfertypes.StoreKey, icqtypes.StoreKey, capabilitytypes.StoreKey, consensusparamtypes.StoreKey, wasm08types.StoreKey,
authzkeeper.StoreKey, stakingmiddleware.StoreKey,
authzkeeper.StoreKey, stakingmiddleware.StoreKey, ibctransfermiddleware.StoreKey,
crisistypes.StoreKey, routertypes.StoreKey, transfermiddlewaretypes.StoreKey, group.StoreKey, minttypes.StoreKey, alliancemoduletypes.StoreKey, wasm.StoreKey, ibchookstypes.StoreKey, icahosttypes.StoreKey, ratelimitmoduletypes.StoreKey, txBoundaryTypes.StoreKey,
)

Expand Down
14 changes: 14 additions & 0 deletions proto/composable/ibctransfermiddleware/v1beta1/genesis.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
syntax = "proto3";
package composable.ibctransfermiddleware.v1beta1;

import "gogoproto/gogo.proto";
import "composable/ibctransfermiddleware/v1beta1/ibctransfermiddleware.proto";
import "amino/amino.proto";


option go_package = "x/ibctransfermiddleware/types";

// GenesisState defines the ibctransfermiddleware module's genesis state.
message GenesisState {
Params params = 1 [ (gogoproto.nullable) = false ];
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
syntax = "proto3";
package composable.ibctransfermiddleware.v1beta1;

option go_package = "x/ibctransfermiddleware/types";

import "gogoproto/gogo.proto";
import "cosmos_proto/cosmos.proto";
import "cosmos/base/v1beta1/coin.proto";

import "amino/amino.proto";
import "cosmos/msg/v1/msg.proto";


// MsgDelegate defines a SDK message for performing a delegation of coins
// from a delegator to a validator.
message Delegation {
option (cosmos.msg.v1.signer) = "delegator_address";
option (amino.name) = "cosmos-sdk/MsgDelegate";

option (gogoproto.equal) = false;
option (gogoproto.goproto_getters) = false;

string delegator_address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
string validator_address = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"];
cosmos.base.v1beta1.Coin amount = 3 [(gogoproto.nullable) = false, (amino.dont_omitempty) = true];
}

// BeginRedelegate defines a SDK message for performing a begin redelegation of coins
// from a delegator to a validator.
message BeginRedelegate{
option (cosmos.msg.v1.signer) = "delegator_address";
option (amino.name) = "cosmos-sdk/MsgBeginRedelegate";

option (gogoproto.equal) = false;
option (gogoproto.goproto_getters) = false;

string delegator_address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
string validator_src_address = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"];
string validator_dst_address = 3 [(cosmos_proto.scalar) = "cosmos.AddressString"];
cosmos.base.v1beta1.Coin amount = 4 [(gogoproto.nullable) = false, (amino.dont_omitempty) = true];
}

// MsgDelegate defines a SDK message for performing a delegation of coins
// from a delegator to a validator.
message Undelegate {
option (cosmos.msg.v1.signer) = "delegator_address";
option (amino.name) = "cosmos-sdk/MsgUndelegate";

option (gogoproto.equal) = false;
option (gogoproto.goproto_getters) = false;

string delegator_address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
string validator_address = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"];
cosmos.base.v1beta1.Coin amount = 3 [(gogoproto.nullable) = false, (amino.dont_omitempty) = true];
}

// MsgDelegate defines a SDK message for performing a delegation of coins
// from a delegator to a validator.
message CancelUnbondingDelegation {
option (cosmos.msg.v1.signer) = "delegator_address";
option (amino.name) = "cosmos-sdk/MsgCancelUnbondingDelegation";

option (gogoproto.equal) = false;
option (gogoproto.goproto_getters) = false;

string delegator_address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
string validator_address = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"];
cosmos.base.v1beta1.Coin amount = 3 [(gogoproto.nullable) = false, (amino.dont_omitempty) = true];
int64 creation_height = 4;
}



// Params holds parameters for the ibctransfermiddleware module.
message Params {
// expected blocks per year
uint64 blocks_per_epoch = 1;
// max block allowed before validator set update
uint64 allow_unbond_after_epoch_progress_block_number = 2;
}

25 changes: 25 additions & 0 deletions proto/composable/ibctransfermiddleware/v1beta1/query.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
syntax = "proto3";
package composable.ibctransfermiddleware.v1beta1;

import "gogoproto/gogo.proto";
import "google/api/annotations.proto";
import "composable/ibctransfermiddleware/v1beta1/ibctransfermiddleware.proto";

option go_package = "x/ibctransfermiddleware/types";

// Query provides defines the gRPC querier service.
service Query {
// Params returns the total set of minting parameters.
rpc Params(QueryParamsRequest) returns (QueryParamsResponse) {
option (google.api.http).get = "/composable/ibctransfermiddleware/params";
}
}

// 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 ];
}
41 changes: 41 additions & 0 deletions proto/composable/ibctransfermiddleware/v1beta1/tx.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
syntax = "proto3";
package composable.ibctransfermiddleware.v1beta1;

import "cosmos/msg/v1/msg.proto";
import "amino/amino.proto";
import "gogoproto/gogo.proto";
import "cosmos_proto/cosmos.proto";
import "composable/ibctransfermiddleware/v1beta1/ibctransfermiddleware.proto";

option go_package = "x/ibctransfermiddleware/types";

// Msg defines the x/ibctransfermiddleware Msg service.
service Msg {
option (cosmos.msg.v1.service) = true;

rpc UpdateEpochParams(MsgUpdateCustomIbcParams) returns (MsgUpdateParamsCustomIbcResponse);
}

// MsgUpdateParams is the Msg/UpdateParams request type.
//
// Since: cosmos-sdk 0.47
message MsgUpdateCustomIbcParams {
option (cosmos.msg.v1.signer) = "authority";
option (amino.name) = "composable/x/ibctransfermiddleware/MsgUpdateParams";

// authority is the address that controls the module (defaults to x/gov unless
// overwritten).
string authority = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ];

// params defines the x/ibctransfermiddleware parameters to update.
//
// NOTE: All parameters must be supplied.
Params params = 2
[ (gogoproto.nullable) = false, (amino.dont_omitempty) = true ];
}

// MsgUpdateParamsResponse defines the response structure for executing a
// MsgUpdateParams message.
//
// Since: cosmos-sdk 0.47
message MsgUpdateParamsCustomIbcResponse {}
55 changes: 55 additions & 0 deletions x/ibctransfermiddleware/client/cli/query.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
package cli

import (
"github.com/spf13/cobra"

"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/flags"
"github.com/notional-labs/composable/v6/x/ibctransfermiddleware/types"
)

// GetQueryCmd returns the cli query commands for the staking middleware module.
func GetQueryCmd() *cobra.Command {
ibctransfermiddlewareParamsQueryCmd := &cobra.Command{
Use: types.ModuleName,
Short: "Querying commands for the staking middleware module",
DisableFlagParsing: true,
SuggestionsMinimumDistance: 2,
RunE: client.ValidateCmd,
}

ibctransfermiddlewareParamsQueryCmd.AddCommand(
GetCmdQueryParams(),
)

return ibctransfermiddlewareParamsQueryCmd
}

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

params := &types.QueryParamsRequest{}
res, err := queryClient.Params(cmd.Context(), params)
if err != nil {
return err
}

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

flags.AddQueryFlagsToCmd(cmd)

return cmd
}
22 changes: 22 additions & 0 deletions x/ibctransfermiddleware/client/cli/tx.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package cli

import (
"github.com/cosmos/cosmos-sdk/client"
"github.com/notional-labs/composable/v6/x/ibctransfermiddleware/types"
"github.com/spf13/cobra"
)

// GetTxCmd returns the tx commands for staking middleware module.
func GetTxCmd() *cobra.Command {
txCmd := &cobra.Command{
Use: types.ModuleName,
Short: "Exp transaction subcommands",
DisableFlagParsing: true,
SuggestionsMinimumDistance: 2,
RunE: client.ValidateCmd,
}

txCmd.AddCommand()

return txCmd
}
19 changes: 19 additions & 0 deletions x/ibctransfermiddleware/keeper/genesis.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package keeper

import (
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/notional-labs/composable/v6/x/ibctransfermiddleware/types"
)

// InitGenesis new stake middleware genesis
func (keeper Keeper) InitGenesis(ctx sdk.Context, data *types.GenesisState) {
if err := keeper.SetParams(ctx, data.Params); err != nil {
panic(err)
}
}

// ExportGenesis returns a GenesisState for a given context and keeper.
func (keeper Keeper) ExportGenesis(ctx sdk.Context) *types.GenesisState {
params := keeper.GetParams(ctx)
return types.NewGenesisState(params)
}
Loading
Loading