Skip to content

Commit

Permalink
chore(unification): rename KeeperBuilder to Builder (#2471)
Browse files Browse the repository at this point in the history
  • Loading branch information
robert-zaremba authored Mar 25, 2024
1 parent f8e7d34 commit 764a5c4
Show file tree
Hide file tree
Showing 18 changed files with 37 additions and 37 deletions.
8 changes: 4 additions & 4 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ type UmeeApp struct {
LeverageKeeper leveragekeeper.Keeper
IncentiveKeeper incentivekeeper.Keeper
OracleKeeper oraclekeeper.Keeper
UIbcQuotaKeeperB uibcquota.KeeperBuilder
UIbcQuotaKeeperB uibcquota.Builder
UGovKeeperB ugovkeeper.Builder
MetokenKeeperB metokenkeeper.Builder

Expand Down Expand Up @@ -461,7 +461,7 @@ func New(

app.NFTKeeper = nftkeeper.NewKeeper(keys[nftkeeper.StoreKey], appCodec, app.AccountKeeper, app.BankKeeper)

app.UGovKeeperB = ugovkeeper.NewKeeperBuilder(appCodec, keys[ugov.ModuleName])
app.UGovKeeperB = ugovkeeper.NewBuilder(appCodec, keys[ugov.ModuleName])

app.OracleKeeper = oraclekeeper.NewKeeper(
appCodec,
Expand Down Expand Up @@ -494,7 +494,7 @@ func New(
)
app.LeverageKeeper.SetBondHooks(app.IncentiveKeeper.BondHooks())

app.MetokenKeeperB = metokenkeeper.NewKeeperBuilder(
app.MetokenKeeperB = metokenkeeper.NewBuilder(
appCodec,
keys[metoken.StoreKey],
app.BankKeeper,
Expand Down Expand Up @@ -538,7 +538,7 @@ func New(
)

// UIbcQuotaKeeper implements ibcporttypes.ICS4Wrapper
app.UIbcQuotaKeeperB = uibcquota.NewKeeperBuilder(
app.UIbcQuotaKeeperB = uibcquota.NewBuilder(
appCodec, keys[uibc.StoreKey],
app.LeverageKeeper, uibcoracle.FromUmeeAvgPriceOracle(app.OracleKeeper), app.UGovKeeperB.EmergencyGroup,
)
Expand Down
2 changes: 1 addition & 1 deletion x/metoken/keeper/intest/keeper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func initTestSuite(t *testing.T, registry []metoken.Index, balances []metoken.In
AnyTimes()
oracleMock.EXPECT().SetExchangeRate(gomock.Any(), gomock.Any(), gomock.Any()).AnyTimes()

kb := keeper.NewKeeperBuilder(
kb := keeper.NewBuilder(
app.AppCodec(),
app.GetKey(metoken.ModuleName),
app.BankKeeper,
Expand Down
8 changes: 4 additions & 4 deletions x/metoken/keeper/intest/msg_server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -607,7 +607,7 @@ func TestMsgServer_Swap_Depegging(t *testing.T) {
Return(initialPrices).
AnyTimes()

kb := keeper.NewKeeperBuilder(
kb := keeper.NewBuilder(
app.AppCodec(),
app.GetKey(metoken.ModuleName),
app.BankKeeper,
Expand Down Expand Up @@ -704,7 +704,7 @@ func TestMsgServer_Swap_Depegging(t *testing.T) {
Return(mocks.ValidPrices()).
AnyTimes()

kb = keeper.NewKeeperBuilder(
kb = keeper.NewBuilder(
app.AppCodec(),
app.GetKey(metoken.ModuleName),
app.BankKeeper,
Expand Down Expand Up @@ -1348,7 +1348,7 @@ func TestMsgServer_Redeem_Depegging(t *testing.T) {
Return(initialPrices).
AnyTimes()

kb := keeper.NewKeeperBuilder(
kb := keeper.NewBuilder(
app.AppCodec(),
app.GetKey(metoken.ModuleName),
app.BankKeeper,
Expand Down Expand Up @@ -1445,7 +1445,7 @@ func TestMsgServer_Redeem_Depegging(t *testing.T) {
Return(mocks.ValidPrices()).
AnyTimes()

kb = keeper.NewKeeperBuilder(
kb = keeper.NewBuilder(
app.AppCodec(),
app.GetKey(metoken.ModuleName),
app.BankKeeper,
Expand Down
4 changes: 2 additions & 2 deletions x/metoken/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ type Builder struct {
ugov ugov.EmergencyGroupBuilder
}

// NewKeeperBuilder returns Builder object.
func NewKeeperBuilder(
// NewBuilder returns Builder object.
func NewBuilder(
cdc codec.Codec,
storeKey storetypes.StoreKey,
bankKeeper metoken.BankKeeper,
Expand Down
2 changes: 1 addition & 1 deletion x/metoken/keeper/unit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func initSimpleKeeper(t *testing.T) Keeper {
interfaceRegistry := types.NewInterfaceRegistry()
cdc := codec.NewProtoCodec(interfaceRegistry)
storeKey := storetypes.NewMemoryStoreKey("metoken")
kb := NewKeeperBuilder(cdc, storeKey, nil, nil, nil, nil)
kb := NewBuilder(cdc, storeKey, nil, nil, nil, nil)
ctx, _ := tsdk.NewCtxOneStore(t, storeKey)

return kb.Keeper(&ctx)
Expand Down
2 changes: 1 addition & 1 deletion x/ugov/keeper/intest/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func MkKeeper(t *testing.T) (*sdk.Context, ugov.Keeper) {
ugov.RegisterInterfaces(ir)
cdc := codec.NewProtoCodec(ir)
storeKey := storetypes.NewMemoryStoreKey(ugov.StoreKey)
kb := keeper.NewKeeperBuilder(cdc, storeKey)
kb := keeper.NewBuilder(cdc, storeKey)
ctx, _ := tsdk.NewCtxOneStore(t, storeKey)
return &ctx, kb.Keeper(&ctx)
}
2 changes: 1 addition & 1 deletion x/ugov/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ type Builder struct {
Cdc codec.BinaryCodec
}

func NewKeeperBuilder(
func NewBuilder(
cdc codec.BinaryCodec, key storetypes.StoreKey,
) Builder {
return Builder{
Expand Down
4 changes: 2 additions & 2 deletions x/uibc/module/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,10 @@ func (AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, _ client.TxEncodingCo
// AppModule represents the AppModule for this module
type AppModule struct {
AppModuleBasic
kb quota.KeeperBuilder
kb quota.Builder
}

func NewAppModule(cdc codec.Codec, kb quota.KeeperBuilder) AppModule {
func NewAppModule(cdc codec.Codec, kb quota.Builder) AppModule {
return AppModule{
AppModuleBasic: NewAppModuleBasic(cdc),
kb: kb,
Expand Down
4 changes: 2 additions & 2 deletions x/uibc/quota/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (

// InitGenesis initializes the x/uibc module's state from a provided genesis
// state.
func (kb KeeperBuilder) InitGenesis(ctx sdk.Context, genState uibc.GenesisState) {
func (kb Builder) InitGenesis(ctx sdk.Context, genState uibc.GenesisState) {
k := kb.Keeper(&ctx)
err := k.SetParams(genState.Params)
util.Panic(err)
Expand All @@ -23,7 +23,7 @@ func (kb KeeperBuilder) InitGenesis(ctx sdk.Context, genState uibc.GenesisState)
}

// ExportGenesis returns the x/uibc module's exported genesis state.
func (kb KeeperBuilder) ExportGenesis(ctx sdk.Context) *uibc.GenesisState {
func (kb Builder) ExportGenesis(ctx sdk.Context) *uibc.GenesisState {
k := kb.Keeper(&ctx)
outflows, err := k.GetAllOutflows()
util.Panic(err)
Expand Down
6 changes: 3 additions & 3 deletions x/uibc/quota/grpc_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ var _ uibc.QueryServer = Querier{}

// Querier implements a QueryServer for the x/uibc module.
type Querier struct {
KeeperBuilder
Builder
}

func NewQuerier(kb KeeperBuilder) Querier {
return Querier{KeeperBuilder: kb}
func NewQuerier(kb Builder) Querier {
return Querier{Builder: kb}
}

// Params returns params of the x/uibc module.
Expand Down
2 changes: 1 addition & 1 deletion x/uibc/quota/intest/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,6 @@ func initKeeper(
storeKey := storetypes.NewMemoryStoreKey("quota")
ctx, _ := tsdk.NewCtxOneStore(t, storeKey)
eg := ugovmocks.NewSimpleEmergencyGroupBuilder()
kb := quota.NewKeeperBuilder(cdc, storeKey, leverage, oracle, eg)
kb := quota.NewBuilder(cdc, storeKey, leverage, oracle, eg)
return ctx, kb.Keeper(&ctx)
}
12 changes: 6 additions & 6 deletions x/uibc/quota/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,20 @@ import (
"github.com/umee-network/umee/v6/x/uibc"
)

// KeeperBuilder constructs Keeper by perparing all related dependencies (notably the store).
type KeeperBuilder struct {
// Builder constructs Keeper by perparing all related dependencies (notably the store).
type Builder struct {
storeKey storetypes.StoreKey
cdc codec.BinaryCodec
leverage uibc.Leverage
oracle uibc.Oracle
ugov ugov.EmergencyGroupBuilder
}

func NewKeeperBuilder(
func NewBuilder(
cdc codec.BinaryCodec, key storetypes.StoreKey,
leverage uibc.Leverage, oracle uibc.Oracle, ugov ugov.EmergencyGroupBuilder,
) KeeperBuilder {
return KeeperBuilder{
) Builder {
return Builder{
cdc: cdc,
storeKey: key,
leverage: leverage,
Expand All @@ -35,7 +35,7 @@ func NewKeeperBuilder(
}
}

func (kb KeeperBuilder) Keeper(ctx *sdk.Context) Keeper {
func (kb Builder) Keeper(ctx *sdk.Context) Keeper {
return Keeper{
store: ctx.KVStore(kb.storeKey),
leverage: kb.leverage,
Expand Down
4 changes: 2 additions & 2 deletions x/uibc/quota/msg_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ import (
var _ uibc.MsgServer = msgServer{}

type msgServer struct {
kb KeeperBuilder
kb Builder
}

// NewMsgServerImpl returns an implementation of uibc.MsgServer
func NewMsgServerImpl(kb KeeperBuilder) uibc.MsgServer {
func NewMsgServerImpl(kb Builder) uibc.MsgServer {
return &msgServer{kb: kb}
}

Expand Down
2 changes: 1 addition & 1 deletion x/uibc/quota/unit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func initKeeper(t *testing.T, l uibc.Leverage, o uibc.Oracle) TestKeeper {
ir := cdctypes.NewInterfaceRegistry()
cdc := codec.NewProtoCodec(ir)
storeKey := storetypes.NewMemoryStoreKey("quota")
kb := NewKeeperBuilder(cdc, storeKey, l, o, eg)
kb := NewBuilder(cdc, storeKey, l, o, eg)
ctx, _ := tsdk.NewCtxOneStore(t, storeKey)
return TestKeeper{kb.Keeper(&ctx), t, &ctx}
}
Expand Down
4 changes: 2 additions & 2 deletions x/uibc/uics20/ibc_module.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@ var _ porttypes.IBCModule = ICS20Module{}
// quota update on acknowledgement error or timeout.
type ICS20Module struct {
porttypes.IBCModule
kb quota.KeeperBuilder
kb quota.Builder
leverage ltypes.MsgServer
cdc codec.JSONCodec
}

// NewICS20Module is an IBCMiddlware constructor.
// `app` must be an ICS20 app.
func NewICS20Module(app porttypes.IBCModule, cdc codec.JSONCodec, k quota.KeeperBuilder, l ltypes.MsgServer,
func NewICS20Module(app porttypes.IBCModule, cdc codec.JSONCodec, k quota.Builder, l ltypes.MsgServer,
) ICS20Module {
return ICS20Module{
IBCModule: app,
Expand Down
2 changes: 1 addition & 1 deletion x/uibc/uics20/ibc_module_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func TestIBCOnRecvPacket(t *testing.T) {
storeKey := storetypes.NewMemoryStoreKey("quota")
ctx, _ := tsdk.NewCtxOneStore(t, storeKey)
eg := ugovmocks.NewSimpleEmergencyGroupBuilder()
kb := quota.NewKeeperBuilder(cdc, storeKey, leverageMock, oracleMock, eg)
kb := quota.NewBuilder(cdc, storeKey, leverageMock, oracleMock, eg)
ics20Module := NewICS20Module(mockIBCModule, cdc, kb, mockLeverageMsgServer)

validMemoMsgs := func(noOfMsgs int, fallbackAddr string) string {
Expand Down
4 changes: 2 additions & 2 deletions x/uibc/uics20/ics4_wrapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ import (
type ICS4 struct {
porttypes.ICS4Wrapper

quotaKB quota.KeeperBuilder
quotaKB quota.Builder
}

func NewICS4(parent porttypes.ICS4Wrapper, kb quota.KeeperBuilder) ICS4 {
func NewICS4(parent porttypes.ICS4Wrapper, kb quota.Builder) ICS4 {
return ICS4{parent, kb}
}

Expand Down
2 changes: 1 addition & 1 deletion x/uibc/uics20/ics4_wrapper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func TestSendPacket(t *testing.T) {

storeKey := storetypes.NewMemoryStoreKey("quota")
ctx, _ := tsdk.NewCtxOneStore(t, storeKey)
kb := quota.NewKeeperBuilder(codec.NewProtoCodec(nil), storeKey, leverageMock, oracleMock, eg)
kb := quota.NewBuilder(codec.NewProtoCodec(nil), storeKey, leverageMock, oracleMock, eg)
dp := uibc.DefaultParams()
keeper := kb.Keeper(&ctx)
keeper.SetParams(dp)
Expand Down

0 comments on commit 764a5c4

Please sign in to comment.