0g-chain/x/community/migrations/v2/store.go
drklee3 8186367c8b
feat(community): consolidate community funds (#1729)
* Add consolidate methods

* Update distr feepool balance with dust, add tests

* Set params for proposal handler to not influence module balances

* Add StakingRewardsPerSecond param for proposal test

* Update changelog

* Update test to check emitted events

* Log dust amounts for x/distribution

* Modify feepool communitypool field instead of entire replacement

* Update tests to include cases with empty balances

* Move EventsContains to app

* Remove extra copied ModuleName

* Add Require() to incentive claims in tests to reduce errors

* Move consolidate tests to testutil

* Only transfer non-ukava coins

* Add DefaultStakingRewardsState to proposal handler test

* Move event emit before consolidate

* add golangci specific timeout

---------

Co-authored-by: Nick DeLuca <nickdeluca08@gmail.com>
2023-10-20 09:18:37 -07:00

36 lines
728 B
Go

package v2
import (
"time"
storetypes "github.com/cosmos/cosmos-sdk/store/types"
sdkmath "cosmossdk.io/math"
"github.com/cosmos/cosmos-sdk/codec"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/kava-labs/kava/x/community/types"
)
// Migrate migrates the x/community module state from the consensus version 1 to
// version 2. Specifically, sets new parameters in the module state.
func Migrate(
ctx sdk.Context,
store storetypes.KVStore,
cdc codec.BinaryCodec,
) error {
params := types.NewParams(
time.Time{},
sdkmath.LegacyNewDec(0),
sdkmath.LegacyNewDec(0),
)
if err := params.Validate(); err != nil {
return err
}
bz := cdc.MustMarshal(&params)
store.Set(types.ParamsKey, bz)
return nil
}