From bf54fdea43721bb2720d175753383ceab9155647 Mon Sep 17 00:00:00 2001 From: tamjidahmed Date: Fri, 3 May 2024 01:09:18 +0600 Subject: [PATCH] refactor: remove unused functions GetParams and SetParams can be easily replaced with the underlying collection's Get and Set methods --- x/wasm-storage/keeper/keeper.go | 28 +----------------------- x/wasm-storage/keeper/msg_server.go | 3 ++- x/wasm-storage/keeper/msg_server_test.go | 2 +- 3 files changed, 4 insertions(+), 29 deletions(-) diff --git a/x/wasm-storage/keeper/keeper.go b/x/wasm-storage/keeper/keeper.go index 901fbc12..d02bebdf 100644 --- a/x/wasm-storage/keeper/keeper.go +++ b/x/wasm-storage/keeper/keeper.go @@ -3,7 +3,6 @@ package keeper import ( "encoding/hex" "fmt" - "time" "cosmossdk.io/collections" storetypes "cosmossdk.io/core/store" @@ -22,15 +21,7 @@ var ( // OverlayPrefix defines prefix to store Overlay Wasm binaries. OverlayPrefix = collections.NewPrefix(1) - // DataRequestQueuePrefix defines prefix to store the queue that contains - // the hashes of Data Request Wasm binaries. - DataRequestQueuePrefix = collections.NewPrefix(2) - - // ProxyContractRegistryPrefix defines prefix to store address of - // Proxy Contract. - ProxyContractRegistryPrefix = collections.NewPrefix(3) - - ParamsPrefix = collections.NewPrefix(4) + ParamsPrefix = collections.NewPrefix(2) ) func GetDataRequestWasmKeyPrefixFull(hash []byte) []byte { @@ -41,13 +32,6 @@ func GetOverlayWasmKeyPrefixFull(hash []byte) []byte { return append(OverlayPrefix, hash...) } -// GetDataRequestTimeKeyPrefixFull gets the key for an item in Data Request Queue. This key -// is the timestamp of when the Data Request Wasm was stored. -func GetDataRequestTimeKeyPrefixFull(timestamp time.Time) []byte { - bz := sdk.FormatTimeBytes(timestamp) - return append(DataRequestQueuePrefix, bz...) -} - type Keeper struct { authority string wasmKeeper wasmtypes.ContractOpsKeeper @@ -219,13 +203,3 @@ func (k Keeper) GetAllWasms(ctx sdk.Context) []types.Wasm { func (k Keeper) Logger(ctx sdk.Context) log.Logger { return ctx.Logger().With("module", fmt.Sprintf("x/%s", types.ModuleName)) } - -// GetParams returns all the parameters for the module. -func (k Keeper) GetParams(ctx sdk.Context) (types.Params, error) { - return k.Params.Get(ctx) -} - -// SetParams sets the parameters in the store. -func (k Keeper) SetParams(ctx sdk.Context, params types.Params) error { - return k.Params.Set(ctx, params) -} diff --git a/x/wasm-storage/keeper/msg_server.go b/x/wasm-storage/keeper/msg_server.go index 3264d723..3ca569f6 100644 --- a/x/wasm-storage/keeper/msg_server.go +++ b/x/wasm-storage/keeper/msg_server.go @@ -201,7 +201,8 @@ func (m msgServer) UpdateParams(goCtx context.Context, req *types.MsgUpdateParam } ctx := sdk.UnwrapSDKContext(goCtx) - if err := m.SetParams(ctx, req.Params); err != nil { + + if err := m.Params.Set(ctx, req.Params); err != nil { return nil, err } diff --git a/x/wasm-storage/keeper/msg_server_test.go b/x/wasm-storage/keeper/msg_server_test.go index 42d19448..033701d7 100644 --- a/x/wasm-storage/keeper/msg_server_test.go +++ b/x/wasm-storage/keeper/msg_server_test.go @@ -313,7 +313,7 @@ func (s *KeeperTestSuite) TestUpdateParams() { s.Require().NoError(err) // Check that the Params were correctly set - params, _ := s.wasmStorageKeeper.GetParams(s.ctx) + params, _ := s.wasmStorageKeeper.Params.Get(s.ctx) s.Require().Equal(tc.input.Params, params) } })