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.
Merge PR cosmos#6869: Backport 0.39.1: Launchpad Migration cosmos#6829
- Loading branch information
1 parent
b0ab544
commit e82246e
Showing
9 changed files
with
661 additions
and
18 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package v039 | ||
|
||
import ( | ||
"fmt" | ||
|
||
v038auth "github.com/cosmos/cosmos-sdk/x/auth/legacy/v0_38" | ||
) | ||
|
||
// Migrate accepts exported genesis state from v0.38 and migrates it to v0.39 | ||
// genesis state. | ||
func Migrate(oldAuthGenState v038auth.GenesisState) GenesisState { | ||
accounts := make(v038auth.GenesisAccounts, len(oldAuthGenState.Accounts)) | ||
|
||
for i, acc := range oldAuthGenState.Accounts { | ||
switch t := acc.(type) { | ||
case *v038auth.BaseAccount: | ||
accounts[i] = NewBaseAccount(t.Address, t.Coins, t.PubKey, t.AccountNumber, t.Sequence) | ||
|
||
case *v038auth.BaseVestingAccount: | ||
accounts[i] = NewBaseVestingAccount( | ||
NewBaseAccount(t.Address, t.Coins, t.PubKey, t.AccountNumber, t.Sequence), | ||
t.OriginalVesting, t.DelegatedFree, t.DelegatedVesting, t.EndTime, | ||
) | ||
|
||
case *v038auth.ContinuousVestingAccount: | ||
accounts[i] = NewContinuousVestingAccountRaw( | ||
NewBaseVestingAccount( | ||
NewBaseAccount(t.Address, t.Coins, t.PubKey, t.AccountNumber, t.Sequence), | ||
t.OriginalVesting, t.DelegatedFree, t.DelegatedVesting, t.EndTime, | ||
), | ||
t.StartTime, | ||
) | ||
|
||
case *v038auth.DelayedVestingAccount: | ||
accounts[i] = NewDelayedVestingAccountRaw( | ||
NewBaseVestingAccount( | ||
NewBaseAccount(t.Address, t.Coins, t.PubKey, t.AccountNumber, t.Sequence), | ||
t.OriginalVesting, t.DelegatedFree, t.DelegatedVesting, t.EndTime, | ||
), | ||
) | ||
|
||
case *v038auth.ModuleAccount: | ||
accounts[i] = NewModuleAccount( | ||
NewBaseAccount(t.Address, t.Coins, t.PubKey, t.AccountNumber, t.Sequence), | ||
t.Name, t.Permissions..., | ||
) | ||
|
||
default: | ||
panic(fmt.Sprintf("unexpected account type: %T", acc)) | ||
} | ||
} | ||
|
||
accounts = v038auth.SanitizeGenesisAccounts(accounts) | ||
|
||
if err := v038auth.ValidateGenAccounts(accounts); err != nil { | ||
panic(err) | ||
} | ||
|
||
return NewGenesisState(oldAuthGenState.Params, accounts) | ||
} |
Oops, something went wrong.