forked from cosmos/cosmos-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add 0.43 CLI JSON
migrate
command (cosmos#8880)
* Add aadr-037 json migration * Add 0.43 to CLI migraet command * Add comment * Don't cover .pb.go * Bez says (2) * Reviews Co-authored-by: Alessio Treglia <[email protected]>
- Loading branch information
1 parent
7b1d80e
commit 3f52d5a
Showing
12 changed files
with
837 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package v043 | ||
|
||
import ( | ||
"github.com/cosmos/cosmos-sdk/client" | ||
"github.com/cosmos/cosmos-sdk/x/genutil/types" | ||
v040gov "github.com/cosmos/cosmos-sdk/x/gov/legacy/v040" | ||
v043gov "github.com/cosmos/cosmos-sdk/x/gov/legacy/v043" | ||
) | ||
|
||
// Migrate migrates exported state from v0.40 to a v0.43 genesis state. | ||
func Migrate(appState types.AppMap, clientCtx client.Context) types.AppMap { | ||
// Migrate x/gov. | ||
if appState[v040gov.ModuleName] != nil { | ||
// unmarshal relative source genesis application state | ||
var oldGovState v040gov.GenesisState | ||
clientCtx.JSONMarshaler.MustUnmarshalJSON(appState[v040gov.ModuleName], &oldGovState) | ||
|
||
// delete deprecated x/gov genesis state | ||
delete(appState, v040gov.ModuleName) | ||
|
||
// Migrate relative source genesis application state and marshal it into | ||
// the respective key. | ||
appState[v043gov.ModuleName] = clientCtx.JSONMarshaler.MustMarshalJSON(v043gov.MigrateJSON(&oldGovState)) | ||
} | ||
|
||
return appState | ||
} |
Oops, something went wrong.