Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bugfix] treasury module burn permission #493

Merged
merged 1 commit into from
Jun 3, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion custom/auth/legacy/v040/migrate.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
v40mint "github.com/cosmos/cosmos-sdk/x/mint/types"

v039authcustom "github.com/terra-money/core/custom/auth/legacy/v039"
v40treasury "github.com/terra-money/core/x/treasury/types"
v040vesting "github.com/terra-money/core/x/vesting/types"
)

Expand Down Expand Up @@ -54,6 +55,7 @@ func convertBaseVestingAccount(old *v039auth.BaseVestingAccount) *v040authvestin
// - Re-encode in v0.40 GenesisState.
func Migrate(authGenState v039auth.GenesisState) *v040auth.GenesisState {
mintModuleAddress := v040auth.NewModuleAddress(v40mint.ModuleName)
treasuryModuleAddress := v040auth.NewModuleAddress(v40treasury.ModuleName)

// Convert v0.39 accounts to v0.40 ones.
var v040Accounts = make([]v040auth.GenesisAccount, len(authGenState.Accounts))
Expand All @@ -75,10 +77,16 @@ func Migrate(authGenState v039auth.GenesisState) *v040auth.GenesisState {
}
case *v039auth.ModuleAccount:
{
// burn permission must be added to treasury module
permissions := v039Account.Permissions
if v039Account.GetAddress().Equals(treasuryModuleAddress) {
permissions = append(permissions, v040auth.Burner)
}

v040Accounts[i] = &v040auth.ModuleAccount{
BaseAccount: convertBaseAccount(v039Account.BaseAccount),
Name: v039Account.Name,
Permissions: v039Account.Permissions,
Permissions: permissions,
}
}
case *v039auth.BaseVestingAccount:
Expand Down