Skip to content

Commit

Permalink
Fixed wrong error message when lastCodeID value is incorrect (cosmos#644
Browse files Browse the repository at this point in the history
)

* Fixed wrong error message when lastCodeID value is incorrect

* Updated changelog

* removed unused import

* fixed typeo
  • Loading branch information
fkneeland-figure authored Oct 26, 2021
1 parent c18bc4b commit 9186d81
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
- Remove unused flags from command prompt for storing contract [\#647](https://github.com/CosmWasm/wasmd/issues/647)
- Ran `make format` [\#649](https://github.com/CosmWasm/wasmd/issues/649)
- Add golangci lint check to circleci jobs [\620](https://github.com/CosmWasm/wasmd/issues/620)
- Updated error log statements in initGenesis for easier debugging: [\#643](https://github.com/CosmWasm/wasmd/issues/643)

[Full Changelog](https://github.com/CosmWasm/wasmd/compare/v0.20.0...HEAD)

Expand Down
10 changes: 6 additions & 4 deletions x/wasm/keeper/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,13 @@ func InitGenesis(ctx sdk.Context, keeper *Keeper, data types.GenesisState, staki
}

// sanity check seq values
if keeper.peekAutoIncrementID(ctx, types.KeyLastCodeID) <= maxCodeID {
return nil, sdkerrors.Wrapf(types.ErrInvalid, "seq %s must be greater %d ", string(types.KeyLastCodeID), maxCodeID)
seqVal := keeper.peekAutoIncrementID(ctx, types.KeyLastCodeID)
if seqVal <= maxCodeID {
return nil, sdkerrors.Wrapf(types.ErrInvalid, "seq %s with value: %d must be greater than: %d ", string(types.KeyLastCodeID), seqVal, maxCodeID)
}
if keeper.peekAutoIncrementID(ctx, types.KeyLastInstanceID) <= uint64(maxContractID) {
return nil, sdkerrors.Wrapf(types.ErrInvalid, "seq %s must be greater %d ", string(types.KeyLastInstanceID), maxContractID)
seqVal = keeper.peekAutoIncrementID(ctx, types.KeyLastInstanceID)
if seqVal <= uint64(maxContractID) {
return nil, sdkerrors.Wrapf(types.ErrInvalid, "seq %s with value: %d must be greater than: %d ", string(types.KeyLastInstanceID), seqVal, maxContractID)
}

if len(data.GenMsgs) == 0 {
Expand Down

0 comments on commit 9186d81

Please sign in to comment.