From 7570419f1d2487b0c091d9d8f079bfc7a5e7b9d8 Mon Sep 17 00:00:00 2001 From: Julien Robert Date: Wed, 20 Jul 2022 08:56:35 +0200 Subject: [PATCH] updates --- x/bank/keeper/migrations.go | 10 ++++++---- x/bank/keeper/send.go | 7 +------ x/bank/spec/02_keepers.md | 2 +- x/bank/spec/03_messages.md | 10 ++++++++++ x/bank/types/msgs.go | 6 ------ 5 files changed, 18 insertions(+), 17 deletions(-) diff --git a/x/bank/keeper/migrations.go b/x/bank/keeper/migrations.go index a4d12b5d2ef7c..c7065f77af63d 100644 --- a/x/bank/keeper/migrations.go +++ b/x/bank/keeper/migrations.go @@ -1,8 +1,6 @@ package keeper import ( - "fmt" - sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/bank/exported" v2 "github.com/cosmos/cosmos-sdk/x/bank/migrations/v2" @@ -34,11 +32,15 @@ func (m Migrator) Migrate2to3(ctx sdk.Context) error { // Migrate3to4 migrates x/bank storage from version 3 to 4. func (m Migrator) Migrate3to4(ctx sdk.Context) error { + if err := v4.MigrateStore(ctx, m.keeper.storeKey, m.legacySubspace, m.keeper.cdc); err != nil { + return err + } + oldParams := m.keeper.GetParams(ctx) m.keeper.SetAllSendEnabled(ctx, oldParams.GetSendEnabled()) if err := m.keeper.SetParams(ctx, banktypes.NewParams(oldParams.DefaultSendEnabled)); err != nil { - return fmt.Errorf("failed to set params: %w", err) + return err } - return v4.MigrateStore(ctx, m.keeper.storeKey, m.legacySubspace, m.keeper.cdc) + return nil } diff --git a/x/bank/keeper/send.go b/x/bank/keeper/send.go index e89b2f9afca89..03ec6a1ce3499 100644 --- a/x/bank/keeper/send.go +++ b/x/bank/keeper/send.go @@ -104,13 +104,8 @@ func (k BaseSendKeeper) SetParams(ctx sdk.Context, params types.Params) error { return err } - if len(params.SendEnabled) > 0 { - k.SetAllSendEnabled(ctx, params.SendEnabled) - } - - p := types.NewParams(params.DefaultSendEnabled) store := ctx.KVStore(k.storeKey) - bz, err := k.cdc.Marshal(&p) + bz, err := k.cdc.Marshal(¶ms) if err != nil { return err } diff --git a/x/bank/spec/02_keepers.md b/x/bank/spec/02_keepers.md index 56048fc0297af..e7d99f85ea2db 100644 --- a/x/bank/spec/02_keepers.md +++ b/x/bank/spec/02_keepers.md @@ -86,7 +86,7 @@ type Keeper interface { DelegateCoins(ctx sdk.Context, delegatorAddr, moduleAccAddr sdk.AccAddress, amt sdk.Coins) error UndelegateCoins(ctx sdk.Context, moduleAccAddr, delegatorAddr sdk.AccAddress, amt sdk.Coins) error - // GetAuthority Gets the address capable of executing governance proposal messages. Usually the gov module account. + // GetAuthority gets the address capable of executing governance proposal messages. Usually the gov module account. GetAuthority() string types.QueryServer diff --git a/x/bank/spec/03_messages.md b/x/bank/spec/03_messages.md index a6d2379458cff..5b3ec664bd96a 100644 --- a/x/bank/spec/03_messages.md +++ b/x/bank/spec/03_messages.md @@ -26,3 +26,13 @@ The message will fail under the following conditions: * Any of the `to` addresses are restricted * Any of the coins are locked * The inputs and outputs do not correctly correspond to one another + +## MsgUpdateParams + +The `bank` module params can be updated through `MsgUpdateParams`, which can be done using governance proposal. The signer will always be the `gov` module account address. + ++++ https://github.com/cosmos/cosmos-sdk/blob/e167855c9b99c4e58c1455533c6f88af5ff78ae1/proto/cosmos/bank/v1beta1/tx.proto#L56-L69 + +The message handling can fail if: + +* signer is not the gov module account address. diff --git a/x/bank/types/msgs.go b/x/bank/types/msgs.go index d8b5db283202a..dedcf151392fd 100644 --- a/x/bank/types/msgs.go +++ b/x/bank/types/msgs.go @@ -180,12 +180,6 @@ func ValidateInputsOutputs(input Input, outputs []Output) error { return nil } -// Route returns the MsgUpdateParams message route. -func (msg MsgUpdateParams) Route() string { return ModuleName } - -// Type returns the MsgUpdateParams message type. -func (msg MsgUpdateParams) Type() string { return TypeMsgUpdateParams } - // GetSigners returns the signer addresses that are expected to sign the result // of GetSignBytes. func (msg MsgUpdateParams) GetSigners() []sdk.AccAddress {