Skip to content

Commit

Permalink
auction module now compiles
Browse files Browse the repository at this point in the history
  • Loading branch information
denalimarsh committed Jun 6, 2020
1 parent 9492fc8 commit 162057f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
9 changes: 5 additions & 4 deletions x/auction/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
)

// InitGenesis initializes the store state from a genesis state.
func InitGenesis(ctx sdk.Context, keeper Keeper, gs GenesisState) {
func InitGenesis(ctx sdk.Context, ak types.AccountKeeper, bk types.BankKeeper, keeper Keeper, gs GenesisState) {
if err := gs.Validate(); err != nil {
panic(fmt.Sprintf("failed to validate %s genesis state: %s", ModuleName, err))
}
Expand All @@ -26,14 +26,15 @@ func InitGenesis(ctx sdk.Context, keeper Keeper, gs GenesisState) {
}

// check if the module account exists
moduleAcc := keeper.AccountKeeper.GetModuleAccount(ctx, ModuleName)
moduleAcc := ak.GetModuleAccount(ctx, ModuleName)
if moduleAcc == nil {
panic(fmt.Sprintf("%s module account has not been set", ModuleName))
}
// check module coins match auction coins
// Note: Other sdk modules do not check this, instead just using the existing module account coins, or if zero, setting them.
if !moduleAcc.GetCoins().IsEqual(totalAuctionCoins) {
panic(fmt.Sprintf("total auction coins (%s) do not equal (%s) module account (%s) ", moduleAcc.GetCoins(), ModuleName, totalAuctionCoins))
maccCoins := bk.GetAllBalances(ctx, moduleAcc.GetAddress())
if !maccCoins.IsEqual(totalAuctionCoins) {
panic(fmt.Sprintf("total auction coins (%s) do not equal (%s) module account (%s) ", maccCoins, ModuleName, totalAuctionCoins))
}
}

Expand Down
2 changes: 1 addition & 1 deletion x/auction/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ func (am AppModule) NewQuerierHandler() sdk.Querier {
func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONMarshaler, data json.RawMessage) []abci.ValidatorUpdate {
var genesisState GenesisState
ModuleCdc.MustUnmarshalJSON(data, &genesisState)
InitGenesis(ctx, am.keeper, genesisState) // TODO: am.bankKeeper
InitGenesis(ctx, am.accountKeeper, am.bankKeeper, am.keeper, genesisState)
return []abci.ValidatorUpdate{}
}

Expand Down

0 comments on commit 162057f

Please sign in to comment.