From 6e19868a9b72efebc601023740bb1d2d8d2139b1 Mon Sep 17 00:00:00 2001 From: Reece Williams Date: Fri, 26 Apr 2024 21:32:08 -0500 Subject: [PATCH] EnableCommunityPoolFeeFunding --- app/app.go | 1 + x/tokenfactory/keeper/createdenom.go | 16 ++++++++++++++-- x/tokenfactory/types/capabilities.go | 3 +++ 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/app/app.go b/app/app.go index 8719075..967934b 100644 --- a/app/app.go +++ b/app/app.go @@ -152,6 +152,7 @@ var ( tokenfactorytypes.EnableForceTransfer, tokenfactorytypes.EnableSetMetadata, tokenfactorytypes.EnableSudoMint, + tokenfactorytypes.EnableCommunityPoolFeeFunding, } ) diff --git a/x/tokenfactory/keeper/createdenom.go b/x/tokenfactory/keeper/createdenom.go index 58c8a4a..0ee45a5 100644 --- a/x/tokenfactory/keeper/createdenom.go +++ b/x/tokenfactory/keeper/createdenom.go @@ -84,8 +84,20 @@ func (k Keeper) chargeForCreateDenom(ctx sdk.Context, creatorAddr string, _ stri return err } - if err := k.communityPoolKeeper.FundCommunityPool(ctx, params.DenomCreationFee, accAddr); err != nil { - return err + if types.IsCapabilityEnabled(k.enabledCapabilities, types.EnableCommunityPoolFeeFunding) { + if err := k.communityPoolKeeper.FundCommunityPool(ctx, params.DenomCreationFee, accAddr); err != nil { + return err + } + } else { + err = k.bankKeeper.SendCoinsFromAccountToModule(ctx, accAddr, types.ModuleName, params.DenomCreationFee) + if err != nil { + return err + } + + err = k.bankKeeper.BurnCoins(ctx, types.ModuleName, params.DenomCreationFee) + if err != nil { + return err + } } } diff --git a/x/tokenfactory/types/capabilities.go b/x/tokenfactory/types/capabilities.go index f879cdf..2bff522 100644 --- a/x/tokenfactory/types/capabilities.go +++ b/x/tokenfactory/types/capabilities.go @@ -7,6 +7,9 @@ const ( // Allows addresses of your choosing to mint tokens based on specific conditions. // via the IsSudoAdminFunc 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). + EnableCommunityPoolFeeFunding = "enable_community_pool_fee_funding" ) func IsCapabilityEnabled(enabledCapabilities []string, capability string) bool {