fix: remove deputy cold wallet coins (#683)

This commit is contained in:
Kevin Davis 2020-10-06 16:11:56 -04:00 committed by GitHub
parent 14df6ad410
commit dbb385ecd8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -465,17 +465,22 @@ func MigrateCommittee(oldGenState v0_9committee.GenesisState) v0_11committee.Gen
// MigrateAuth migrates from a v0.38.5 auth genesis state to a v0.39.1 auth genesis state
func MigrateAuth(oldGenState v38_5auth.GenesisState) v39_1auth.GenesisState {
var newAccounts v39_1authexported.GenesisAccounts
deputyBnbBalance = sdk.NewCoin("bnb", sdk.ZeroInt())
deputyAddr, err := sdk.AccAddressFromBech32("kava1r4v2zdhdalfj2ydazallqvrus9fkphmglhn6u6")
if err != nil {
panic(err)
}
deputyColdAddr, err := sdk.AccAddressFromBech32("kava1qm2u6nyv7kg6awdm46caccgzn5h7mdkde0sue6")
if err != nil {
panic(err)
}
for _, account := range oldGenState.Accounts {
switch acc := account.(type) {
case *v38_5auth.BaseAccount:
a := v39_1auth.BaseAccount(*acc)
// Remove deputy bnb
if a.GetAddress().Equals(deputyAddr) {
deputyBnbBalance = sdk.NewCoin("bnb", a.GetCoins().AmountOf("bnb"))
if a.GetAddress().Equals(deputyAddr) || a.GetAddress().Equals(deputyColdAddr) {
deputyBnbBalance = deputyBnbBalance.Add(sdk.NewCoin("bnb", a.GetCoins().AmountOf("bnb")))
err := a.SetCoins(a.GetCoins().Sub(sdk.NewCoins(sdk.NewCoin("bnb", a.GetCoins().AmountOf("bnb")))))
if err != nil {
panic(err)