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

chore: replace keeper methods #NTRN-268 #485

Merged
merged 9 commits into from
May 8, 2024
1 change: 1 addition & 0 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -748,6 +748,7 @@ func New(
memKeys[interchaintxstypes.MemStoreKey],
app.IBCKeeper.ChannelKeeper,
app.ICAControllerKeeper,
icacontrollerkeeper.NewMsgServerImpl(&app.ICAControllerKeeper),
contractmanager.NewSudoLimitWrapper(app.ContractManagerKeeper, &app.WasmKeeper),
app.FeeKeeper,
app.BankKeeper,
Expand Down
2 changes: 1 addition & 1 deletion app/upgrades/v4.0.0/upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func CreateUpgradeHandler(
_ upgrades.StoreKeys,
_ codec.Codec,
) upgradetypes.UpgradeHandler {
return func(c context.Context, plan upgradetypes.Plan, vm module.VersionMap) (module.VersionMap, error) {
return func(c context.Context, _ upgradetypes.Plan, vm module.VersionMap) (module.VersionMap, error) {
ctx := sdk.UnwrapSDKContext(c)

ctx.Logger().Info("Starting module migrations...")
Expand Down
7 changes: 6 additions & 1 deletion proto/neutron/interchaintxs/v1/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,12 @@ message MsgRegisterInterchainAccount {

// MsgRegisterInterchainAccountResponse is the response type for
// MsgRegisterInterchainAccount.
message MsgRegisterInterchainAccountResponse {}
message MsgRegisterInterchainAccountResponse {
option (gogoproto.goproto_getters) = false;

string channel_id = 1;
string port_id = 2;
}

// MsgSubmitTx defines the payload for Msg/SubmitTx
message MsgSubmitTx {
Expand Down
2 changes: 2 additions & 0 deletions testutil/interchaintxs/keeper/interchaintxs.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ func InterchainTxsKeeper(
managerKeeper types.WasmKeeper,
refunderKeeper types.FeeRefunderKeeper,
icaControllerKeeper types.ICAControllerKeeper,
icaControllerMsgServer types.ICAControllerMsgServer,
channelKeeper types.ChannelKeeper,
bankKeeper types.BankKeeper,
getFeeCollectorAddr types.GetFeeCollectorAddr,
Expand All @@ -48,6 +49,7 @@ func InterchainTxsKeeper(
memStoreKey,
channelKeeper,
icaControllerKeeper,
icaControllerMsgServer,
managerKeeper,
refunderKeeper,
bankKeeper,
Expand Down
4 changes: 2 additions & 2 deletions testutil/mocks/interchainqueries/keeper/verify.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion testutil/mocks/interchainqueries/types/expected_keepers.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

77 changes: 63 additions & 14 deletions testutil/mocks/interchaintxs/types/expected_keepers.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion wasmbinding/bindings/msg.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,10 @@ type RegisterInterchainAccount struct {
}

// RegisterInterchainAccountResponse holds response for RegisterInterchainAccount.
type RegisterInterchainAccountResponse struct{}
type RegisterInterchainAccountResponse struct {
ChannelId string `json:"channel_id"`
PortId string `json:"port_id"`
}

// RegisterInterchainQuery creates a query for remote chain.
type RegisterInterchainQuery struct {
Expand Down
2 changes: 1 addition & 1 deletion x/globalfee/client/cli/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func GetCmdShowGlobalFeeParams() *cobra.Command {
Short: "Show globalfee params",
Long: "Show globalfee requirement: minimum_gas_prices, bypass_min_fee_msg_types, max_total_bypass_minFee_msg_gas_usage",
Args: cobra.ExactArgs(0),
RunE: func(cmd *cobra.Command, args []string) error {
RunE: func(cmd *cobra.Command, _ []string) error {
clientCtx, err := client.GetClientQueryContext(cmd)
if err != nil {
return err
Expand Down
2 changes: 1 addition & 1 deletion x/interchainqueries/types/genesis.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion x/interchaintxs/genesis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ func TestGenesis(t *testing.T) {
Params: types.DefaultParams(),
}

k, ctx := keepertest.InterchainTxsKeeper(t, nil, nil, nil, nil, nil, nil)
k, ctx := keepertest.InterchainTxsKeeper(t, nil, nil, nil, nil, nil, nil, nil)
interchaintxs.InitGenesis(ctx, *k, genesisState)
got := interchaintxs.ExportGenesis(ctx, *k)
require.NotNil(t, got)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func TestKeeper_InterchainAccountAddress(t *testing.T) {
ctrl := gomock.NewController(t)
defer ctrl.Finish()
icaKeeper := mock_types.NewMockICAControllerKeeper(ctrl)
keeper, ctx := testkeeper.InterchainTxsKeeper(t, nil, nil, icaKeeper, nil, nil, nil)
keeper, ctx := testkeeper.InterchainTxsKeeper(t, nil, nil, icaKeeper, nil, nil, nil, nil)

resp, err := keeper.InterchainAccountAddress(ctx, nil)
require.ErrorIs(t, err, sdkerrors.ErrInvalidRequest)
Expand Down
2 changes: 1 addition & 1 deletion x/interchaintxs/keeper/grpc_query_params_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
)

func TestParamsQuery(t *testing.T) {
keeper, ctx := testkeeper.InterchainTxsKeeper(t, nil, nil, nil, nil, nil, nil)
keeper, ctx := testkeeper.InterchainTxsKeeper(t, nil, nil, nil, nil, nil, nil, nil)
params := types.DefaultParams()
err := keeper.SetParams(ctx, params)
require.NoError(t, err)
Expand Down
10 changes: 4 additions & 6 deletions x/interchaintxs/keeper/ibc_handlers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,10 @@ const ICAId = ".ica0"
func TestHandleAcknowledgement(t *testing.T) {
ctrl := gomock.NewController(t)
defer ctrl.Finish()
icaKeeper := mock_types.NewMockICAControllerKeeper(ctrl)
wmKeeper := mock_types.NewMockWasmKeeper(ctrl)
feeKeeper := mock_types.NewMockFeeRefunderKeeper(ctrl)
bankKeeper := mock_types.NewMockBankKeeper(ctrl)
icak, infCtx := testkeeper.InterchainTxsKeeper(t, wmKeeper, feeKeeper, icaKeeper, nil, bankKeeper, func(_ sdk.Context) string {
icak, infCtx := testkeeper.InterchainTxsKeeper(t, wmKeeper, feeKeeper, nil, nil, nil, bankKeeper, func(_ sdk.Context) string {
return TestFeeCollectorAddr
})
ctx := infCtx.WithGasMeter(types2.NewGasMeter(1_000_000_000_000))
Expand Down Expand Up @@ -76,11 +75,10 @@ func TestHandleAcknowledgement(t *testing.T) {
func TestHandleTimeout(t *testing.T) {
ctrl := gomock.NewController(t)
defer ctrl.Finish()
icaKeeper := mock_types.NewMockICAControllerKeeper(ctrl)
wmKeeper := mock_types.NewMockWasmKeeper(ctrl)
feeKeeper := mock_types.NewMockFeeRefunderKeeper(ctrl)
bankKeeper := mock_types.NewMockBankKeeper(ctrl)
icak, infCtx := testkeeper.InterchainTxsKeeper(t, wmKeeper, feeKeeper, icaKeeper, nil, bankKeeper, func(_ sdk.Context) string {
icak, infCtx := testkeeper.InterchainTxsKeeper(t, wmKeeper, feeKeeper, nil, nil, nil, bankKeeper, func(_ sdk.Context) string {
return TestFeeCollectorAddr
})
ctx := infCtx.WithGasMeter(types2.NewGasMeter(1_000_000_000_000))
Expand Down Expand Up @@ -119,12 +117,12 @@ func TestHandleChanOpenAck(t *testing.T) {
defer ctrl.Finish()
wmKeeper := mock_types.NewMockWasmKeeper(ctrl)
bankKeeper := mock_types.NewMockBankKeeper(ctrl)
icak, ctx := testkeeper.InterchainTxsKeeper(t, wmKeeper, nil, nil, nil, bankKeeper, func(_ sdk.Context) string {
icak, ctx := testkeeper.InterchainTxsKeeper(t, wmKeeper, nil, nil, nil, nil, bankKeeper, func(_ sdk.Context) string {
return TestFeeCollectorAddr
})
portID := icatypes.ControllerPortPrefix + testutil.TestOwnerAddress + ICAId
contractAddress := sdk.MustAccAddressFromBech32(testutil.TestOwnerAddress)
channelID := "channel-0"
const channelID = "channel-0"
counterpartyChannelID := "channel-1"

err := icak.HandleChanOpenAck(ctx, "", channelID, counterpartyChannelID, "1")
Expand Down
43 changes: 23 additions & 20 deletions x/interchaintxs/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,17 @@ const (

type (
Keeper struct {
Codec codec.BinaryCodec
storeKey storetypes.StoreKey
memKey storetypes.StoreKey
channelKeeper types.ChannelKeeper
feeKeeper types.FeeRefunderKeeper
icaControllerKeeper types.ICAControllerKeeper
sudoKeeper types.WasmKeeper
bankKeeper types.BankKeeper
getFeeCollectorAddr types.GetFeeCollectorAddr
authority string
Codec codec.BinaryCodec
storeKey storetypes.StoreKey
memKey storetypes.StoreKey
channelKeeper types.ChannelKeeper
feeKeeper types.FeeRefunderKeeper
icaControllerKeeper types.ICAControllerKeeper
icaControllerMsgServer types.ICAControllerMsgServer
sudoKeeper types.WasmKeeper
bankKeeper types.BankKeeper
getFeeCollectorAddr types.GetFeeCollectorAddr
authority string
}
)

Expand All @@ -44,23 +45,25 @@ func NewKeeper(
memKey storetypes.StoreKey,
channelKeeper types.ChannelKeeper,
icaControllerKeeper types.ICAControllerKeeper,
icaControllerMsgServer types.ICAControllerMsgServer,
sudoKeeper types.WasmKeeper,
feeKeeper types.FeeRefunderKeeper,
bankKeeper types.BankKeeper,
getFeeCollectorAddr types.GetFeeCollectorAddr,
authority string,
) *Keeper {
return &Keeper{
Codec: cdc,
storeKey: storeKey,
memKey: memKey,
channelKeeper: channelKeeper,
icaControllerKeeper: icaControllerKeeper,
sudoKeeper: sudoKeeper,
feeKeeper: feeKeeper,
bankKeeper: bankKeeper,
getFeeCollectorAddr: getFeeCollectorAddr,
authority: authority,
Codec: cdc,
storeKey: storeKey,
memKey: memKey,
channelKeeper: channelKeeper,
icaControllerKeeper: icaControllerKeeper,
icaControllerMsgServer: icaControllerMsgServer,
sudoKeeper: sudoKeeper,
feeKeeper: feeKeeper,
bankKeeper: bankKeeper,
getFeeCollectorAddr: getFeeCollectorAddr,
authority: authority,
}
}

Expand Down
Loading
Loading