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

refactor: improvements #26

Merged
merged 4 commits into from
Dec 16, 2024
Merged
Show file tree
Hide file tree
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
7 changes: 1 addition & 6 deletions x/tokenfactory/keeper/admins.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,7 @@ func (k Keeper) setAuthorityMetadata(ctx context.Context, denom string, metadata
return nil
}

func (k Keeper) setAdmin(ctx context.Context, denom string, admin string) error {
metadata, err := k.GetAuthorityMetadata(sdk.UnwrapSDKContext(ctx), denom)
if err != nil {
return err
}

func (k Keeper) setAdmin(ctx context.Context, metadata types.DenomAuthorityMetadata, denom string, admin string) error {
metadata.Admin = admin

return k.setAuthorityMetadata(ctx, denom, metadata)
Expand Down
6 changes: 3 additions & 3 deletions x/tokenfactory/keeper/msg_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ func (server msgServer) Mint(goCtx context.Context, msg *types.MsgMint) (*types.
ctx.EventManager().EmitEvents(sdk.Events{
sdk.NewEvent(
types.TypeMsgMint,
sdk.NewAttribute(types.AttributeMintToAddress, msg.Sender),
sdk.NewAttribute(types.AttributeMintToAddress, msg.MintToAddress),
sdk.NewAttribute(types.AttributeAmount, msg.Amount.String()),
),
})
Expand Down Expand Up @@ -119,7 +119,7 @@ func (server msgServer) Burn(goCtx context.Context, msg *types.MsgBurn) (*types.
ctx.EventManager().EmitEvents(sdk.Events{
sdk.NewEvent(
types.TypeMsgBurn,
sdk.NewAttribute(types.AttributeBurnFromAddress, msg.Sender),
sdk.NewAttribute(types.AttributeBurnFromAddress, msg.BurnFromAddress),
sdk.NewAttribute(types.AttributeAmount, msg.Amount.String()),
),
})
Expand Down Expand Up @@ -172,7 +172,7 @@ func (server msgServer) ChangeAdmin(goCtx context.Context, msg *types.MsgChangeA
return nil, types.ErrUnauthorized
}

err = server.Keeper.setAdmin(ctx, msg.Denom, msg.NewAdmin)
err = server.Keeper.setAdmin(ctx, authorityMetadata, msg.Denom, msg.NewAdmin)
if err != nil {
return nil, err
}
Expand Down
7 changes: 5 additions & 2 deletions x/tokenfactory/types/capabilities.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@
EnableForceTransfer = "enable_force_transfer"
EnableBurnFrom = "enable_burn_from"
// Allows addresses of your choosing to mint tokens based on specific conditions.
// via the IsSudoAdminFunc
// via the IsSudoAdminFunc.
// NOTE: with SudoMint enabled, the sudo admin can mint `any` token, not just tokenfactory tokens.
// This is intended behavior as requested by other teams, rather than having its own module with very minor logic.
// If you do not wish for this behavior, write your own and do not use this capability.
EnableSudoMint = "enable_admin_sudo_mint"
// EnableCommunityPoolFeeFunding sends tokens to the community pool when a new fee is charged (if one is set in params).
// This is useful for ICS chains, or networks who wish to just have the fee tokens burned (not gas fees, just the extra on top).
Expand All @@ -14,7 +17,7 @@

func IsCapabilityEnabled(enabledCapabilities []string, capability string) bool {
if len(enabledCapabilities) == 0 {
return true
return false

Check warning on line 20 in x/tokenfactory/types/capabilities.go

View check run for this annotation

Codecov / codecov/patch

x/tokenfactory/types/capabilities.go#L20

Added line #L20 was not covered by tests
}

for _, v := range enabledCapabilities {
Expand Down
Loading