Skip to content

Commit

Permalink
fix: fix cyclic dependency between virtual group and storage module
Browse files Browse the repository at this point in the history
  • Loading branch information
alexgao001 committed Nov 7, 2023
1 parent 1c8ce9f commit 06b6b2e
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
5 changes: 3 additions & 2 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -472,9 +472,7 @@ func New(
app.AccountKeeper,
app.BankKeeper,
app.PaymentKeeper,
app.StorageKeeper,
)
virtualgroupModule := virtualgroupmodule.NewAppModule(appCodec, app.VirtualgroupKeeper, app.SpKeeper)

app.PermissionmoduleKeeper = *permissionmodulekeeper.NewKeeper(
appCodec,
Expand All @@ -498,6 +496,9 @@ func New(
)
storageModule := storagemodule.NewAppModule(appCodec, app.StorageKeeper, app.AccountKeeper, app.BankKeeper, app.SpKeeper)

app.VirtualgroupKeeper.SetStorageKeeper(&app.StorageKeeper)
virtualgroupModule := virtualgroupmodule.NewAppModule(appCodec, app.VirtualgroupKeeper, app.SpKeeper)

app.ChallengeKeeper = *challengemodulekeeper.NewKeeper(
appCodec,
keys[challengemoduletypes.StoreKey],
Expand Down
6 changes: 4 additions & 2 deletions x/virtualgroup/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ func NewKeeper(
accountKeeper types.AccountKeeper,
bankKeeper types.BankKeeper,
paymentKeeper types.PaymentKeeper,
storageKeeper types.StorageKeeper,
) *Keeper {

k := Keeper{
Expand All @@ -57,7 +56,6 @@ func NewKeeper(
accountKeeper: accountKeeper,
bankKeeper: bankKeeper,
paymentKeeper: paymentKeeper,
storageKeeper: storageKeeper,
}

k.gvgSequence = sequence.NewSequence[uint32](types.GVGSequencePrefix)
Expand All @@ -66,6 +64,10 @@ func NewKeeper(
return &k
}

func (k *Keeper) SetStorageKeeper(storageKeeper types.StorageKeeper) {
k.storageKeeper = storageKeeper
}

func (k Keeper) GetAuthority() string {
return k.authority
}
Expand Down
2 changes: 0 additions & 2 deletions x/virtualgroup/keeper/payment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ func (s *TestSuite) SetupTest() {
accountKeeper := types.NewMockAccountKeeper(ctrl)
spKeeper := types.NewMockSpKeeper(ctrl)
paymentKeeper := types.NewMockPaymentKeeper(ctrl)
storageKeeper := types.NewMockStorageKeeper(ctrl)

s.ctx = testCtx.Ctx
s.virtualgroupKeeper = keeper.NewKeeper(
Expand All @@ -60,7 +59,6 @@ func (s *TestSuite) SetupTest() {
accountKeeper,
bankKeeper,
paymentKeeper,
storageKeeper,
)

s.cdc = encCfg.Codec
Expand Down

0 comments on commit 06b6b2e

Please sign in to comment.