github.com/cosmos/cosmos-sdk@v0.50.10/x/gov/migrations/v2/json.go (about)

     1  package v2
     2  
     3  import (
     4  	"github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
     5  )
     6  
     7  // migrateJSONWeightedVotes migrates the ADR-037 weighted votes.
     8  func migrateJSONWeightedVotes(oldVotes v1beta1.Votes) v1beta1.Votes {
     9  	newVotes := make(v1beta1.Votes, len(oldVotes))
    10  	for i, oldVote := range oldVotes {
    11  		newVotes[i] = migrateVote(oldVote)
    12  	}
    13  
    14  	return newVotes
    15  }
    16  
    17  // MigrateJSON accepts exported v1 (v0.40) x/gov genesis state and migrates it to
    18  // v2 (v0.43) x/gov genesis state. The migration includes:
    19  //
    20  // - Gov weighted votes.
    21  func MigrateJSON(oldState *v1beta1.GenesisState) *v1beta1.GenesisState {
    22  	return &v1beta1.GenesisState{
    23  		StartingProposalId: oldState.StartingProposalId,
    24  		Deposits:           oldState.Deposits,
    25  		Votes:              migrateJSONWeightedVotes(oldState.Votes),
    26  		Proposals:          oldState.Proposals,
    27  		DepositParams:      oldState.DepositParams,
    28  		VotingParams:       oldState.VotingParams,
    29  		TallyParams:        oldState.TallyParams,
    30  	}
    31  }