forked from cosmos/cosmos-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
json.go
39 lines (35 loc) · 1.27 KB
/
json.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package v3
import (
v1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1"
"github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
)
// MigrateJSON accepts exported v0.43 x/gov genesis state and migrates it to
// v0.46 x/gov genesis state. The migration includes:
//
// - Updating everything to v1.
// - Migrating proposals to be Msg-based.
func MigrateJSON(oldState *v1beta1.GenesisState) (*v1.GenesisState, error) {
newProps, err := convertToNewProposals(oldState.Proposals)
if err != nil {
return nil, err
}
newVotes, err := convertToNewVotes(oldState.Votes)
if err != nil {
return nil, err
}
depParams, votingParms, tallyParams := convertToNewDepParams(oldState.DepositParams), convertToNewVotingParams(oldState.VotingParams), convertToNewTallyParams(oldState.TallyParams)
return &v1.GenesisState{
StartingProposalId: oldState.StartingProposalId,
Deposits: convertToNewDeposits(oldState.Deposits),
Votes: newVotes,
Proposals: newProps,
Params: &v1.Params{
MinDeposit: depParams.MinDeposit,
MaxDepositPeriod: depParams.MaxDepositPeriod,
VotingPeriod: votingParms.VotingPeriod,
Quorum: tallyParams.Quorum,
Threshold: tallyParams.Threshold,
VetoThreshold: tallyParams.VetoThreshold,
},
}, nil
}