Skip to content

Commit

Permalink
remove token factory config
Browse files Browse the repository at this point in the history
  • Loading branch information
dssei committed Dec 3, 2024
1 parent d125382 commit 0e7984a
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 68 deletions.
6 changes: 0 additions & 6 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -534,19 +534,13 @@ func New(
).SetHooks(epochmoduletypes.NewMultiEpochHooks(
app.MintKeeper.Hooks()))

tokenFactoryConfig, err := tokenfactorykeeper.ReadConfig(appOpts)
if err != nil {
panic(fmt.Sprintf("error reading token factory config due to %s", err))
}

app.TokenFactoryKeeper = tokenfactorykeeper.NewKeeper(
appCodec,
app.keys[tokenfactorytypes.StoreKey],
app.GetSubspace(tokenfactorytypes.ModuleName),
app.AccountKeeper,
app.BankKeeper.(bankkeeper.BaseKeeper).WithMintCoinsRestriction(tokenfactorytypes.NewTokenFactoryDenomMintCoinsRestriction()),
app.DistrKeeper,
tokenFactoryConfig,
)

// The last arguments can contain custom message handlers, and custom query handlers,
Expand Down
4 changes: 0 additions & 4 deletions app/test_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import (
slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types"
"github.com/cosmos/cosmos-sdk/x/staking/teststaking"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
tokenfactorykeeper "github.com/sei-protocol/sei-chain/x/tokenfactory/keeper"
"github.com/stretchr/testify/suite"
abci "github.com/tendermint/tendermint/abci/types"
"github.com/tendermint/tendermint/config"
Expand Down Expand Up @@ -56,9 +55,6 @@ func (t TestAppOpts) Get(s string) interface{} {
if s == FlagSCEnable {
return t.useSc
}
if s == tokenfactorykeeper.FlagDenomAllowListMaxSize {
return 3
}
return nil
}

Expand Down
29 changes: 0 additions & 29 deletions x/tokenfactory/keeper/config.go

This file was deleted.

2 changes: 1 addition & 1 deletion x/tokenfactory/keeper/createdenom.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ func (k Keeper) validateAllowListSize(allowList *banktypes.AllowList) error {
return types.ErrAllowListUndefined
}

if len(allowList.Addresses) > k.config.DenomAllowListMaxSize {
if len(allowList.Addresses) > DenomAllowListMaxSize {
return types.ErrAllowListTooLarge
}
return nil
Expand Down
37 changes: 16 additions & 21 deletions x/tokenfactory/keeper/createdenom_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ func (suite *KeeperTestSuite) TestMsgCreateDenom() {
}

func (suite *KeeperTestSuite) TestCreateDenom() {
largeAllowList := make([]string, 2001)
for i := 0; i < 2001; i++ {
largeAllowList[i] = suite.TestAccs[i%len(suite.TestAccs)].String()
}
for _, tc := range []struct {
desc string
setup func()
Expand Down Expand Up @@ -99,16 +103,10 @@ func (suite *KeeperTestSuite) TestCreateDenom() {
valid: false,
},
{
desc: "list is too large",
subdenom: "test",
allowList: &banktypes.AllowList{
Addresses: []string{
suite.TestAccs[0].String(),
suite.TestAccs[1].String(),
suite.TestAccs[2].String(),
suite.TestAccs[2].String()},
},
valid: false,
desc: "list is too large",
subdenom: "test",
allowList: &banktypes.AllowList{Addresses: largeAllowList},
valid: false,
},
} {
suite.Run(fmt.Sprintf("Case %s", tc.desc), func() {
Expand Down Expand Up @@ -158,6 +156,10 @@ func (suite *KeeperTestSuite) TestCreateDenom() {
}

func (suite *KeeperTestSuite) TestUpdateDenom() {
largeAllowList := make([]string, 2001)
for i := 0; i < 2001; i++ {
largeAllowList[i] = suite.TestAccs[0].String()
}
for _, tc := range []struct {
desc string
setup func()
Expand Down Expand Up @@ -222,17 +224,10 @@ func (suite *KeeperTestSuite) TestUpdateDenom() {
types.NewMsgCreateDenom(suite.TestAccs[0].String(), "TLRG"))
suite.Require().NoError(err)
},
denom: fmt.Sprintf("factory/%s/TLRG", suite.TestAccs[0].String()),
allowList: &banktypes.AllowList{
Addresses: []string{
suite.TestAccs[0].String(),
suite.TestAccs[1].String(),
suite.TestAccs[2].String(),
suite.TestAccs[2].String(),
},
},
valid: false,
errMsg: "allowlist too large",
denom: fmt.Sprintf("factory/%s/TLRG", suite.TestAccs[0].String()),
allowList: &banktypes.AllowList{Addresses: largeAllowList},
valid: false,
errMsg: "allowlist too large",
},
{
desc: "denom having invalid characters",
Expand Down
7 changes: 2 additions & 5 deletions x/tokenfactory/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import (
paramtypes "github.com/cosmos/cosmos-sdk/x/params/types"
)

const DenomAllowListMaxSize = 2000

type (
Keeper struct {
storeKey sdk.StoreKey
Expand All @@ -24,8 +26,6 @@ type (
accountKeeper types.AccountKeeper
bankKeeper types.BankKeeper
distrKeeper types.DistrKeeper

config Config
}
)

Expand All @@ -37,7 +37,6 @@ func NewKeeper(
accountKeeper types.AccountKeeper,
bankKeeper types.BankKeeper,
distrKeeper types.DistrKeeper,
config Config,
) Keeper {
if !paramSpace.HasKeyTable() {
paramSpace = paramSpace.WithKeyTable(types.ParamKeyTable())
Expand All @@ -50,8 +49,6 @@ func NewKeeper(
accountKeeper: accountKeeper,
bankKeeper: bankKeeper,
distrKeeper: distrKeeper,

config: config,
}
}

Expand Down
4 changes: 2 additions & 2 deletions x/tokenfactory/keeper/migrations_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func TestMigrate2to3(t *testing.T) {
store.Set(oldCreatorSpecificPrefix, []byte("garbage value whitelist creator"))
require.True(t, store.Has(oldCreateDenomFeeWhitelistPrefix))
require.True(t, store.Has(oldCreatorSpecificPrefix))
newKeeper := NewKeeper(cdc, storeKey, paramsSubspace, nil, bankkeeper.NewBaseKeeper(cdc, bankstorekey, nil, paramsSubspace, nil), nil, Config{DenomAllowListMaxSize: 100})
newKeeper := NewKeeper(cdc, storeKey, paramsSubspace, nil, bankkeeper.NewBaseKeeper(cdc, bankstorekey, nil, paramsSubspace, nil), nil)
m := NewMigrator(newKeeper)
err := m.Migrate2to3(ctx)
require.Nil(t, err)
Expand All @@ -80,7 +80,7 @@ func TestMigrate2to3(t *testing.T) {
func TestMigrate3To4(t *testing.T) {
// Test migration with all metadata denom
metadata := banktypes.Metadata{Description: sdk.DefaultBondDenom, Base: sdk.DefaultBondDenom, Display: sdk.DefaultBondDenom, Name: sdk.DefaultBondDenom, Symbol: sdk.DefaultBondDenom}
keeper := NewKeeper(nil, nil, typesparams.Subspace{}, nil, nil, nil, Config{DenomAllowListMaxSize: 100})
keeper := NewKeeper(nil, nil, typesparams.Subspace{}, nil, nil, nil)
m := NewMigrator(keeper)
m.SetMetadata(&metadata)
require.Equal(t, sdk.DefaultBondDenom, metadata.Display)
Expand Down

0 comments on commit 0e7984a

Please sign in to comment.