Skip to content

Commit

Permalink
fix(auction): use correct account linking for x/metoken
Browse files Browse the repository at this point in the history
  • Loading branch information
robert-zaremba committed May 6, 2024
1 parent c5caa92 commit f9a8aaf
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 8 deletions.
2 changes: 1 addition & 1 deletion app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -514,7 +514,7 @@ func New(
app.LeverageKeeper,
app.OracleKeeper,
app.UGovKeeperB.EmergencyGroup,
// rewardsAuctionAccs.RewardsCollect,
rewardsAuctionAccs.RewardsCollect,
)

// register the staking hooks
Expand Down
7 changes: 4 additions & 3 deletions x/auction/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ type Builder struct {
storeKey storetypes.StoreKey
bank auction.BankKeeper
ugov ugov.EmergencyGroupBuilder
accs SubAccounts

Accs SubAccounts
}

func NewBuilder(cdc codec.BinaryCodec,
Expand All @@ -28,15 +29,15 @@ func NewBuilder(cdc codec.BinaryCodec,
b auction.BankKeeper,
ugov ugov.EmergencyGroupBuilder) Builder {

return Builder{cdc: cdc, storeKey: key, accs: accs,
return Builder{cdc: cdc, storeKey: key, Accs: accs,
bank: b, ugov: ugov}
}

func (kb Builder) Keeper(ctx *sdk.Context) Keeper {
return Keeper{
store: ctx.KVStore(kb.storeKey),
cdc: kb.cdc,
accs: kb.accs,
accs: kb.Accs,
bank: kb.bank,
ugov: kb.ugov(ctx),

Expand Down
6 changes: 3 additions & 3 deletions x/metoken/keeper/intest/keeper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,20 +54,20 @@ func initTestSuite(t *testing.T, registry []metoken.Index, balances []metoken.In
AnyTimes()
oracleMock.EXPECT().SetExchangeRate(gomock.Any(), gomock.Any(), gomock.Any()).AnyTimes()

kb := keeper.NewBuilder(
app.MetokenKeeperB = keeper.NewBuilder(
app.AppCodec(),
app.GetKey(metoken.ModuleName),
app.BankKeeper,
app.LeverageKeeper,
oracleMock,
app.UGovKeeperB.EmergencyGroup,
app.AuctionKeeperB.Accs.RewardsCollect,
)
app.MetokenKeeperB = kb

genState := metoken.DefaultGenesisState()
genState.Registry = registry
genState.Balances = balances
kb.Keeper(&ctx).InitGenesis(*genState)
app.MetokenKeeperB.Keeper(&ctx).InitGenesis(*genState)

queryHelper := baseapp.NewQueryServerTestHelper(ctx, app.InterfaceRegistry())
metoken.RegisterQueryServer(queryHelper, keeper.NewQuerier(app.MetokenKeeperB))
Expand Down
4 changes: 4 additions & 0 deletions x/metoken/keeper/intest/msg_server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -616,6 +616,7 @@ func TestMsgServer_Swap_Depegging(t *testing.T) {
app.LeverageKeeper,
oracleMock,
app.UGovKeeperB.EmergencyGroup,
app.AuctionKeeperB.Accs.RewardsCollect,
)
app.MetokenKeeperB = kb
msgServer = keeper.NewMsgServerImpl(app.MetokenKeeperB)
Expand Down Expand Up @@ -714,6 +715,7 @@ func TestMsgServer_Swap_Depegging(t *testing.T) {
app.LeverageKeeper,
oracleMock,
app.UGovKeeperB.EmergencyGroup,
app.AuctionKeeperB.Accs.RewardsCollect,
)
app.MetokenKeeperB = kb
msgServer = keeper.NewMsgServerImpl(app.MetokenKeeperB)
Expand Down Expand Up @@ -1357,6 +1359,7 @@ func TestMsgServer_Redeem_Depegging(t *testing.T) {
app.LeverageKeeper,
oracleMock,
app.UGovKeeperB.EmergencyGroup,
app.AuctionKeeperB.Accs.RewardsCollect,
)
app.MetokenKeeperB = kb
msgServer = keeper.NewMsgServerImpl(app.MetokenKeeperB)
Expand Down Expand Up @@ -1456,6 +1459,7 @@ func TestMsgServer_Redeem_Depegging(t *testing.T) {
app.LeverageKeeper,
oracleMock,
app.UGovKeeperB.EmergencyGroup,
app.AuctionKeeperB.Accs.RewardsCollect,
)
app.MetokenKeeperB = kb
msgServer = keeper.NewMsgServerImpl(app.MetokenKeeperB)
Expand Down
5 changes: 5 additions & 0 deletions x/metoken/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ type Builder struct {
leverageKeeper metoken.LeverageKeeper
oracleKeeper metoken.OracleKeeper
ugov ugov.EmergencyGroupBuilder
rewardsAuction sdk.AccAddress
}

// NewBuilder returns Builder object.
Expand All @@ -28,6 +29,7 @@ func NewBuilder(
leverageKeeper metoken.LeverageKeeper,
oracleKeeper metoken.OracleKeeper,
ugov ugov.EmergencyGroupBuilder,
rewardsAuction sdk.AccAddress,
) Builder {
return Builder{
cdc: cdc,
Expand All @@ -36,6 +38,7 @@ func NewBuilder(
leverageKeeper: leverageKeeper,
oracleKeeper: oracleKeeper,
ugov: ugov,
rewardsAuction: rewardsAuction,
}
}

Expand All @@ -46,6 +49,7 @@ type Keeper struct {
leverageKeeper metoken.LeverageKeeper
oracleKeeper metoken.OracleKeeper
ugov ugov.EmergencyGroupBuilder
rewardsAuction sdk.AccAddress

// TODO: ctx should be removed when we migrate leverageKeeper and oracleKeeper
ctx *sdk.Context
Expand All @@ -60,6 +64,7 @@ func (b Builder) Keeper(ctx *sdk.Context) Keeper {
leverageKeeper: b.leverageKeeper,
oracleKeeper: b.oracleKeeper,
ugov: b.ugov,
rewardsAuction: b.rewardsAuction,
ctx: ctx,
}
}
Expand Down
3 changes: 2 additions & 1 deletion x/metoken/keeper/unit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
storetypes "github.com/cosmos/cosmos-sdk/store/types"
"github.com/stretchr/testify/require"

"github.com/umee-network/umee/v6/tests/accs"
"github.com/umee-network/umee/v6/tests/tsdk"
"github.com/umee-network/umee/v6/x/metoken"
"github.com/umee-network/umee/v6/x/metoken/mocks"
Expand All @@ -19,7 +20,7 @@ func initSimpleKeeper(t *testing.T) Keeper {
interfaceRegistry := types.NewInterfaceRegistry()
cdc := codec.NewProtoCodec(interfaceRegistry)
storeKey := storetypes.NewMemoryStoreKey("metoken")
kb := NewBuilder(cdc, storeKey, nil, nil, nil, nil)
kb := NewBuilder(cdc, storeKey, nil, nil, nil, nil, accs.GenerateAddr("auction.Rewards"))
ctx, _ := tsdk.NewCtxOneStore(t, storeKey)

k := kb.Keeper(&ctx)
Expand Down

0 comments on commit f9a8aaf

Please sign in to comment.