Skip to content

Commit

Permalink
migrate UpdateConversionFeeDenom for msgfees
Browse files Browse the repository at this point in the history
  • Loading branch information
nullpointer0x00 committed Apr 25, 2024
1 parent b998684 commit fc8ab3c
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 28 deletions.
2 changes: 0 additions & 2 deletions x/msgfees/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ func NewProposalHandler(k keeper.Keeper, registry cdctypes.InterfaceRegistry) go
return keeper.HandleRemoveMsgFeeProposal(ctx, k, c, registry)
case *types.UpdateNhashPerUsdMilProposal:
return keeper.HandleUpdateNhashPerUsdMilProposal(ctx, k, c)
case *types.UpdateConversionFeeDenomProposal:
return keeper.HandleUpdateConversionFeeDenomProposal(ctx, k, c)
default:
return sdkerrors.ErrUnknownRequest.Wrapf("unrecognized marker proposal content type: %T", c)
}
Expand Down
7 changes: 7 additions & 0 deletions x/msgfees/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -242,3 +242,10 @@ func sortedKeys[K constraints.Ordered, V any](m map[K]V) []K {
})
return keys
}

// UpdateConversionFeeDenomProposal updates the conversion fee denom
func (k Keeper) UpdateConversionFeeDenomProposal(ctx sdk.Context, conversionFeeDenom string) {
params := k.GetParams(ctx)
params.ConversionFeeDenom = conversionFeeDenom
k.SetParams(ctx, params)
}
11 changes: 1 addition & 10 deletions x/msgfees/keeper/msg_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,16 +142,7 @@ func (m msgServer) UpdateConversionFeeDenomProposal(goCtx context.Context, req *

ctx := sdk.UnwrapSDKContext(goCtx)

prop := types.UpdateConversionFeeDenomProposal{
Title: "UpdateConversionFeeDenomProposal",
Description: "UpdateConversionFeeDenomProposal",
ConversionFeeDenom: req.ConversionFeeDenom,
}

err := HandleUpdateConversionFeeDenomProposal(ctx, m.Keeper, &prop)
if err != nil {
return nil, err
}
m.Keeper.UpdateConversionFeeDenomProposal(ctx, req.ConversionFeeDenom)

return &types.MsgUpdateConversionFeeDenomProposalResponse{}, nil
}
6 changes: 3 additions & 3 deletions x/msgfees/keeper/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,19 @@ import (
// GetParams returns the total set of distribution parameters.
func (k Keeper) GetParams(ctx sdk.Context) (params types.Params) {
store := ctx.KVStore(k.storeKey)
params = types.DefaultParams() // Initialize with defaults
params = types.DefaultParams()

bz := store.Get(types.MsgFeesParamStoreKey)
if bz != nil {
k.cdc.MustUnmarshal(bz, &params) // Deserialize parameters
k.cdc.MustUnmarshal(bz, &params)
}
return params
}

// SetParams sets the account parameters to the store.
func (k Keeper) SetParams(ctx sdk.Context, params types.Params) {
store := ctx.KVStore(k.storeKey)
bz := k.cdc.MustMarshal(&params) // Serialize parameters
bz := k.cdc.MustMarshal(&params)
store.Set(types.MsgFeesParamStoreKey, bz)
}

Expand Down
11 changes: 0 additions & 11 deletions x/msgfees/keeper/proposal_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,14 +111,3 @@ func HandleUpdateNhashPerUsdMilProposal(ctx sdk.Context, k Keeper, proposal *typ
k.SetParams(ctx, params)
return nil
}

// HandleUpdateConversionFeeDenomProposal handles update of conversion fee denom
func HandleUpdateConversionFeeDenomProposal(ctx sdk.Context, k Keeper, proposal *types.UpdateConversionFeeDenomProposal) error {
if err := proposal.ValidateBasic(); err != nil {
return err
}
params := k.GetParams(ctx)
params.ConversionFeeDenom = proposal.ConversionFeeDenom
k.SetParams(ctx, params)
return nil
}
2 changes: 0 additions & 2 deletions x/msgfees/keeper/proposal_handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,6 @@ func (s *IntegrationTestSuite) TestMsgFeeProposals() {
err = msgfeeskeeper.HandleRemoveMsgFeeProposal(s.ctx, s.k, c, s.app.InterfaceRegistry())
case *msgfeestypes.UpdateNhashPerUsdMilProposal:
err = msgfeeskeeper.HandleUpdateNhashPerUsdMilProposal(s.ctx, s.k, c)
case *msgfeestypes.UpdateConversionFeeDenomProposal:
err = msgfeeskeeper.HandleUpdateConversionFeeDenomProposal(s.ctx, s.k, c)
default:
panic("invalid proposal type")
}
Expand Down

0 comments on commit fc8ab3c

Please sign in to comment.