Skip to content

Commit

Permalink
Merge pull request #120 from onomyprotocol/dzmitryhil/dao-genesis-imp…
Browse files Browse the repository at this point in the history
…ort-minting-ptotection

Add initial DAO height check to prevent double minting of the initial balance
  • Loading branch information
cgdusek authored Nov 17, 2022
2 parents af55eeb + bc9d867 commit 8e843a1
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions x/dao/keeper/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,15 @@ import (
func (k Keeper) InitGenesis(ctx sdk.Context, genState types.GenesisState) error {
k.SetParams(ctx, genState.Params)

balance := genState.TreasuryBalance
return k.bankKeeper.MintCoins(ctx, types.ModuleName, balance)
// if the height is 1 or 0 the chain is in the initial state
if ctx.BlockHeight() <= 1 {
balance := genState.TreasuryBalance
if err := k.bankKeeper.MintCoins(ctx, types.ModuleName, balance); err != nil {
return err
}
}

return nil
}

// ExportGenesis returns a GenesisState for a given context and keeper.
Expand Down

0 comments on commit 8e843a1

Please sign in to comment.