-
Notifications
You must be signed in to change notification settings - Fork 607
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
fix: fix the account number of x/tokenfactory
module account
#5534
fix: fix the account number of x/tokenfactory
module account
#5534
Conversation
x/tokenfactory
module account
@@ -83,6 +82,5 @@ func (k *Keeper) SetContractKeeper(contractKeeper types.ContractKeeper) { | |||
// it purely mints and burns them on behalf of the admin of respective denoms, | |||
// and sends to the relevant address. | |||
func (k Keeper) CreateModuleAccount(ctx sdk.Context) { | |||
moduleAcc := authtypes.NewEmptyModuleAccount(types.ModuleName, authtypes.Minter, authtypes.Burner) | |||
k.accountKeeper.SetModuleAccount(ctx, moduleAcc) | |||
k.accountKeeper.GetModuleAccount(ctx, types.ModuleName) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, it should be created at the genesis phase, see x/gov
calls GetModuleAccount
to create the module account as follows:
https://github.com/cosmos/cosmos-sdk/blob/release/v0.45.x/x/gov/genesis.go#L19
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the change makes sense, tests seem to be failing can you take a look into the tests please 🙏
let's also add a changelog for this please |
@mattverse Added changelog entry. The last test failing seems not related to this change if I am not wrong, and also test is passed by manually and the latest test checking action. |
@mattverse Rebased |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
What is the purpose of the change
This pull request fixes the account number of
x/tokenfactory
is wrongly set by genesis sinceCreateModuleAccount
only stores the module account with default account number 0, and it it also missing an update toglobal_account_number
insidex/auth
.To solve it,
CreateModuleAccount
should callAccountKeeper.GetModuleAccount
instead ofAccountKeeper.SetModuleAccount
, or it lost to set account number properly, see:https://github.com/cosmos/cosmos-sdk/blob/main/x/auth/keeper/keeper.go#L252
Testing and Verifying
This change added tests and can be verified as follows:
x/tokenfactory
module account is correctly setDocumentation and Release Note
Unreleased
section ofCHANGELOG.md
?Where is the change documented?
x/{module}/README.md
)