github.com/Finschia/finschia-sdk@v0.48.1/x/gov/legacy/v043/json.go (about)

     1  package v043
     2  
     3  import (
     4  	"github.com/Finschia/finschia-sdk/x/gov/types"
     5  )
     6  
     7  // migrateWeightedVotes migrates the ADR-037 weighted votes.
     8  func migrateJSONWeightedVotes(oldVotes types.Votes) types.Votes {
     9  	newVotes := make(types.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 v0.40 x/gov genesis state and migrates it to
    18  // v0.43 x/gov genesis state. The migration includes:
    19  //
    20  // - Gov weighted votes.
    21  func MigrateJSON(oldState *types.GenesisState) *types.GenesisState {
    22  	return &types.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  }