Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add init logic of module accounts just in case #1277

Merged
merged 8 commits into from
Mar 17, 2024
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
* (x/auth, x/slashing) [\#1179](https://github.com/Finschia/finschia-sdk/pull/1179) modify missing changes of converting to tendermint
* (x/auth) [#1274](https://github.com/Finschia/finschia-sdk/pull/1274) `ModuleAccount.Validate` now reports a nil `.BaseAccount` instead of panicking.
* (x/collection) [\#1276](https://github.com/Finschia/finschia-sdk/pull/1276) eliminates potential risk for Insufficient Sanity Check of tokenID in Genesis
* (x/foundation) [\#1277](https://github.com/Finschia/finschia-sdk/pull/1277) add init logic of foundation module accounts to InitGenesis in order to eliminate potential panic

### Removed

Expand Down
2 changes: 1 addition & 1 deletion baseapp/block_gas_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ func TestBaseApp_BlockGas(t *testing.T) {
txBuilder.SetFeeAmount(feeAmount)
txBuilder.SetGasLimit(txtypes.MaxGasWanted) // tx validation checks that gasLimit can't be bigger than this

privs, accNums, accSeqs := []cryptotypes.PrivKey{priv1}, []uint64{6}, []uint64{0}
privs, accNums, accSeqs := []cryptotypes.PrivKey{priv1}, []uint64{8}, []uint64{0}
_, txBytes, err := createTestTx(encCfg.TxConfig, txBuilder, privs, accNums, accSeqs, ctx.ChainID())
require.NoError(t, err)

Expand Down
9 changes: 9 additions & 0 deletions x/foundation/keeper/internal/genesis.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package internal

import (
"fmt"

sdk "github.com/Finschia/finschia-sdk/types"
"github.com/Finschia/finschia-sdk/x/foundation"
)
Expand Down Expand Up @@ -48,6 +50,13 @@

k.SetPool(ctx, data.Pool)

// init module accounts just in case
if acc := k.authKeeper.GetModuleAccount(ctx, foundation.ModuleName); acc == nil {
panic(fmt.Sprintf("failed to create module account=%s", foundation.ModuleName))

Check warning on line 55 in x/foundation/keeper/internal/genesis.go

View check run for this annotation

Codecov / codecov/patch

x/foundation/keeper/internal/genesis.go#L55

Added line #L55 was not covered by tests
}
if acc := k.authKeeper.GetModuleAccount(ctx, foundation.TreasuryName); acc == nil {
panic(fmt.Sprintf("failed to create module account=%s", foundation.TreasuryName))

Check warning on line 58 in x/foundation/keeper/internal/genesis.go

View check run for this annotation

Codecov / codecov/patch

x/foundation/keeper/internal/genesis.go#L58

Added line #L58 was not covered by tests
}
return nil
}

Expand Down
Loading