Skip to content

Commit

Permalink
fix: migrated genesis & migrated account with existing balance (#157)
Browse files Browse the repository at this point in the history
* fix: add missing capability module initial state on stargate-migrate command
* fix: invalid account balance update when account already exists in genesis
  • Loading branch information
daeMOn63 authored Aug 26, 2021
1 parent 5e2a6f9 commit dc3c40c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion cmd/fetchd/cmd/gendelegations.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ and the full amount is stored on the account balance.`,
bankState.Balances[i].Coins = bankState.Balances[i].Coins.Add(delegatedCoin)
successUpdatingBondedPool = true
case addr.String():
bankState.Balances[i].GetCoins().Add(accountCoin)
bankState.Balances[i].Coins = bankState.Balances[i].Coins.Add(accountCoin)
updatedUserBank = true
}
}
Expand Down
4 changes: 4 additions & 0 deletions cmd/fetchd/cmd/stargatemigrate.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
"github.com/cosmos/cosmos-sdk/types/errors"
airdrop "github.com/cosmos/cosmos-sdk/x/airdrop/types"
v038auth "github.com/cosmos/cosmos-sdk/x/auth/legacy/v038"
capability "github.com/cosmos/cosmos-sdk/x/capability/types"
v039 "github.com/cosmos/cosmos-sdk/x/genutil/legacy/v039"
v040 "github.com/cosmos/cosmos-sdk/x/genutil/legacy/v040"
"github.com/cosmos/cosmos-sdk/x/genutil/types"
Expand Down Expand Up @@ -133,6 +134,9 @@ and then migrate the given genesis to version v0.39, and then v0.40 of the cosmo
// Add airdrop defaults
v040GenState[airdrop.ModuleName] = cdc.MustMarshalJSON(airdrop.DefaultGenesisState())

// Add capability defaults
v040GenState[capability.ModuleName] = cdc.MustMarshalJSON(capability.DefaultGenesis())

// Update genesis with migrated state
genDoc.AppState, err = json.Marshal(v040GenState)
if err != nil {
Expand Down

0 comments on commit dc3c40c

Please sign in to comment.