Skip to content

Commit

Permalink
refactor: improvements (#26)
Browse files Browse the repository at this point in the history
* M-01

* L-01

* G-01

* M-02 add clarrification note
  • Loading branch information
Reecepbcups authored Dec 16, 2024
1 parent 59eb848 commit bf594b9
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 11 deletions.
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 @@ const (
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 @@ const (

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

for _, v := range enabledCapabilities {
Expand Down

0 comments on commit bf594b9

Please sign in to comment.