Skip to content

Commit

Permalink
fix: fix export and incentive migrator
Browse files Browse the repository at this point in the history
  • Loading branch information
cosmic-vagabond committed Dec 12, 2023
1 parent 933661a commit fe6a71d
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 18 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@ scripts/testing/variables.sh
scripts/csv/dist
scripts/csv/node_modules
scripts/csv/.env
price-feeder
price-feeder
*-skip
2 changes: 1 addition & 1 deletion cmd/elysd/cmd/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"github.com/elys-network/elys/app"
)

func initSDKConfig() {
func InitSDKConfig() {
// Set prefixes
accountPubKeyPrefix := app.AccountAddressPrefix + "pub"
validatorAddressPrefix := app.AccountAddressPrefix + "valoper"
Expand Down
2 changes: 1 addition & 1 deletion cmd/elysd/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ func initRootCmd(
encodingConfig appparams.EncodingConfig,
) {
// Set config
initSDKConfig()
InitSDKConfig()

gentxModule := app.ModuleBasics[genutiltypes.ModuleName].(genutil.AppModuleBasic)
rootCmd.AddCommand(
Expand Down
1 change: 1 addition & 0 deletions x/commitment/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ func ExportGenesis(ctx sdk.Context, k keeper.Keeper) *types.GenesisState {
genesis := types.DefaultGenesis()
genesis.Params = k.GetParams(ctx)

genesis.Commitments = k.GetAllCommitments(ctx)
// this line is used by starport scaffolding # genesis/module/export

return genesis
Expand Down
16 changes: 16 additions & 0 deletions x/commitment/keeper/commitments.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,22 @@ func (k Keeper) SetCommitments(ctx sdk.Context, commitments types.Commitments) {
store.Set(types.CommitmentsKey(commitments.Creator), b)
}

// GetAllCommitments returns all commitments
func (k Keeper) GetAllCommitments(ctx sdk.Context) (list []*types.Commitments) {
store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.CommitmentsKeyPrefix))
iterator := sdk.KVStorePrefixIterator(store, []byte{})

defer iterator.Close()

for ; iterator.Valid(); iterator.Next() {
var val types.Commitments
k.cdc.MustUnmarshal(iterator.Value(), &val)
list = append(list, &val)
}

return
}

// GetCommitments returns a commitments from its index
func (k Keeper) GetCommitments(ctx sdk.Context, creator string) types.Commitments {
store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.CommitmentsKeyPrefix))
Expand Down
4 changes: 2 additions & 2 deletions x/commitment/types/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ func validateVestingInfo(info *VestingInfo) error {
return fmt.Errorf("num_epochs must be greater than zero")
}

if info.NumMaxVestings <= 0 {
return fmt.Errorf("num_max_vestings must be greater than zero")
if info.NumMaxVestings < 0 {
return fmt.Errorf("num_max_vestings cannot be negative")
}

return nil
Expand Down
11 changes: 0 additions & 11 deletions x/incentive/migrations/v9_migration.go

This file was deleted.

4 changes: 2 additions & 2 deletions x/incentive/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ func (am AppModule) RegisterServices(cfg module.Configurator) {
types.RegisterMsgServer(cfg.MsgServer(), keeper.NewMsgServerImpl(am.keeper))
types.RegisterQueryServer(cfg.QueryServer(), am.keeper)
m := migrations.NewMigrator(am.keeper)
err := cfg.RegisterMigration(types.ModuleName, 8, m.V9Migration)
err := cfg.RegisterMigration(types.ModuleName, 7, m.V8Migration)
if err != nil {
panic(err)
}
Expand All @@ -137,7 +137,7 @@ func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.Raw
}

// ConsensusVersion is a sequence number for state-breaking change of the module. It should be incremented on each consensus-breaking change introduced by the module. To avoid wrong/empty versions, the initial version should be set to 1
func (AppModule) ConsensusVersion() uint64 { return 9 }
func (AppModule) ConsensusVersion() uint64 { return 8 }

// BeginBlock contains the logic that is automatically triggered at the beginning of each block
func (am AppModule) BeginBlock(_ sdk.Context, _ abci.RequestBeginBlock) {}
Expand Down

0 comments on commit fe6a71d

Please sign in to comment.