Skip to content

Commit

Permalink
refactor: remove unused functions
Browse files Browse the repository at this point in the history
GetParams and
SetParams can be easily replaced with the underlying collection's Get and Set methods
  • Loading branch information
DeshErBojhaa committed May 2, 2024
1 parent fd9eaee commit e1aaee3
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 29 deletions.
28 changes: 1 addition & 27 deletions x/wasm-storage/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package keeper
import (
"encoding/hex"
"fmt"
"time"

"cosmossdk.io/collections"
storetypes "cosmossdk.io/core/store"
Expand All @@ -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 {
Expand All @@ -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
Expand Down Expand Up @@ -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)
}
3 changes: 2 additions & 1 deletion x/wasm-storage/keeper/msg_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,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
}

Expand Down
2 changes: 1 addition & 1 deletion x/wasm-storage/keeper/msg_server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
})
Expand Down

0 comments on commit e1aaee3

Please sign in to comment.