Some checks are pending
Build SimApp / build (amd64) (push) Waiting to run
Build SimApp / build (arm64) (push) Waiting to run
CodeQL / Analyze (push) Waiting to run
Build & Push / build (push) Waiting to run
Run Gosec / Gosec (push) Waiting to run
Lint / golangci-lint (push) Waiting to run
Checks dependencies and mocks generation / Check go mod tidy (push) Waiting to run
Checks dependencies and mocks generation / Check up to date mocks (push) Waiting to run
System Tests / setup (push) Waiting to run
System Tests / test-system (push) Blocked by required conditions
System Tests / test-system-legacy (push) Blocked by required conditions
Tests / Code Coverage / split-test-files (push) Waiting to run
Tests / Code Coverage / tests (00) (push) Blocked by required conditions
Tests / Code Coverage / tests (01) (push) Blocked by required conditions
Tests / Code Coverage / tests (02) (push) Blocked by required conditions
Tests / Code Coverage / tests (03) (push) Blocked by required conditions
Tests / Code Coverage / test-integration (push) Waiting to run
Tests / Code Coverage / test-e2e (push) Waiting to run
Tests / Code Coverage / repo-analysis (push) Blocked by required conditions
Tests / Code Coverage / test-sim-nondeterminism (push) Waiting to run
Tests / Code Coverage / test-clientv2 (push) Waiting to run
Tests / Code Coverage / test-core (push) Waiting to run
Tests / Code Coverage / test-depinject (push) Waiting to run
Tests / Code Coverage / test-errors (push) Waiting to run
Tests / Code Coverage / test-math (push) Waiting to run
Tests / Code Coverage / test-schema (push) Waiting to run
Tests / Code Coverage / test-collections (push) Waiting to run
Tests / Code Coverage / test-cosmovisor (push) Waiting to run
Tests / Code Coverage / test-confix (push) Waiting to run
Tests / Code Coverage / test-store (push) Waiting to run
Tests / Code Coverage / test-log (push) Waiting to run
Tests / Code Coverage / test-x-tx (push) Waiting to run
Tests / Code Coverage / test-x-nft (push) Waiting to run
Tests / Code Coverage / test-x-circuit (push) Waiting to run
Tests / Code Coverage / test-x-feegrant (push) Waiting to run
Tests / Code Coverage / test-x-evidence (push) Waiting to run
Tests / Code Coverage / test-x-upgrade (push) Waiting to run
Tests / Code Coverage / test-tools-benchmark (push) Waiting to run
63 lines
1.8 KiB
Go
63 lines
1.8 KiB
Go
package v5
|
|
|
|
import (
|
|
"cosmossdk.io/collections"
|
|
corestoretypes "cosmossdk.io/core/store"
|
|
|
|
"git.cw.tr/mukan-network/mukan-sdk/codec"
|
|
sdk "git.cw.tr/mukan-network/mukan-sdk/types"
|
|
v4 "git.cw.tr/mukan-network/mukan-sdk/x/gov/migrations/v4"
|
|
govv1 "git.cw.tr/mukan-network/mukan-sdk/x/gov/types/v1"
|
|
)
|
|
|
|
var (
|
|
// ParamsKey is the key of x/gov params
|
|
ParamsKey = []byte{0x30}
|
|
// ConstitutionKey is the key of x/gov constitution
|
|
ConstitutionKey = collections.NewPrefix(49)
|
|
)
|
|
|
|
// MigrateStore performs in-place store migrations from v4 (v0.47) to v5 (v0.50). The
|
|
// migration includes:
|
|
//
|
|
// Addition of the new proposal expedited parameters that are set to 0 by default.
|
|
// Set of default chain constitution.
|
|
func MigrateStore(ctx sdk.Context, storeService corestoretypes.KVStoreService, cdc codec.BinaryCodec, constitutionCollection collections.Item[string]) error {
|
|
store := storeService.OpenKVStore(ctx)
|
|
paramsBz, err := store.Get(v4.ParamsKey)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
var params govv1.Params
|
|
err = cdc.Unmarshal(paramsBz, ¶ms)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
defaultParams := govv1.DefaultParams()
|
|
params.ExpeditedMinDeposit = defaultParams.ExpeditedMinDeposit
|
|
params.ExpeditedVotingPeriod = defaultParams.ExpeditedVotingPeriod
|
|
params.ExpeditedThreshold = defaultParams.ExpeditedThreshold
|
|
params.ProposalCancelRatio = defaultParams.ProposalCancelRatio
|
|
params.ProposalCancelDest = defaultParams.ProposalCancelDest
|
|
params.MinDepositRatio = defaultParams.MinDepositRatio
|
|
|
|
bz, err := cdc.Marshal(¶ms)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
if err := store.Set(ParamsKey, bz); err != nil {
|
|
return err
|
|
}
|
|
|
|
// Set the default consisitution if it is not set
|
|
if ok, err := constitutionCollection.Has(ctx); !ok || err != nil {
|
|
if err := constitutionCollection.Set(ctx, "This chain has no constitution."); err != nil {
|
|
return err
|
|
}
|
|
}
|
|
|
|
return nil
|
|
}
|