Skip to content
Open
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
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ test:
COV_ROOT="/tmp/tokenfactory-coverage"
COV_UNIT_E2E="${COV_ROOT}/unit-e2e"
COV_SIMULATION="${COV_ROOT}/simulation"
COV_PKG="github.com/strangelove-ventures/tokenfactory/..."
COV_PKG="github.com/MissingNO57/tokenfactory/..."
COV_SIM_CMD=${COV_SIMULATION}/simulation.test
COV_SIM_COMMON=-Enabled=True -NumBlocks=100 -Commit=true -Period=5 -Verbose=false -test.v -test.gocoverdir=${COV_SIMULATION}

Expand Down
4 changes: 2 additions & 2 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,7 @@ func NewApp(

app.GovKeeper = *govKeeper.SetHooks(
govtypes.NewMultiGovHooks(
// register the governance hooks
// register the governance hooks
),
)

Expand Down Expand Up @@ -551,7 +551,7 @@ func NewApp(
app.BankKeeper,
app.DistrKeeper,
tokenFactoryCapabilities,
tokenfactorykeeper.DefaultIsSudoAdminFunc,
nil,
govModAddress,
)
wasmOpts = append(wasmOpts, bindings.RegisterCustomPlugins(app.BankKeeper, &app.TokenFactoryKeeper)...)
Expand Down
1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,6 @@ require (
github.com/cloudwego/base64x v0.1.5 // indirect
github.com/cncf/xds/go v0.0.0-20250121191232-2f005788dc42 // indirect
github.com/cockroachdb/fifo v0.0.0-20240616162244-4768e80dfb9a // indirect
github.com/cosmos/ibc-go/v10 v10.3.0 // indirect
github.com/dgraph-io/badger/v4 v4.2.0 // indirect
github.com/envoyproxy/go-control-plane/envoy v1.32.4 // indirect
github.com/envoyproxy/protoc-gen-validate v1.2.1 // indirect
Expand Down
6 changes: 2 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -835,12 +835,10 @@ github.com/cosmos/gogoproto v1.7.0 h1:79USr0oyXAbxg3rspGh/m4SWNyoz/GLaAh0QlCe2fr
github.com/cosmos/gogoproto v1.7.0/go.mod h1:yWChEv5IUEYURQasfyBW5ffkMHR/90hiHgbNgrtp4j0=
github.com/cosmos/iavl v1.2.4 h1:IHUrG8dkyueKEY72y92jajrizbkZKPZbMmG14QzsEkw=
github.com/cosmos/iavl v1.2.4/go.mod h1:GiM43q0pB+uG53mLxLDzimxM9l/5N9UuSY3/D0huuVw=
github.com/cosmos/ibc-go/modules/capability v1.0.0 h1:r/l++byFtn7jHYa09zlAdSeevo8ci1mVZNO9+V0xsLE=
github.com/cosmos/ibc-go/modules/capability v1.0.0/go.mod h1:D81ZxzjZAe0ZO5ambnvn1qedsFQ8lOwtqicG6liLBco=
github.com/cosmos/ibc-go/modules/capability v1.0.1 h1:ibwhrpJ3SftEEZRxCRkH0fQZ9svjthrX2+oXdZvzgGI=
github.com/cosmos/ibc-go/modules/capability v1.0.1/go.mod h1:rquyOV262nGJplkumH+/LeYs04P3eV8oB7ZM4Ygqk4E=
github.com/cosmos/ibc-go/v10 v10.3.0 h1:w5DkHih8qn15deAeFoTk778WJU+xC1krJ5kDnicfUBc=
github.com/cosmos/ibc-go/v10 v10.3.0/go.mod h1:CthaR7n4d23PJJ7wZHegmNgbVcLXCQql7EwHrAXnMtw=
github.com/cosmos/ibc-go/v10 v8.2.0 h1:7oCzyy1sZCcgpeQLnHxC56brsSz3KWwQGKXalXwXFzE=
github.com/cosmos/ibc-go/v10 v8.2.0/go.mod h1:wj3qx75iC/XNnsMqbPDCIGs0G6Y3E/lo3bdqCyoCy+8=
github.com/cosmos/ics23/go v0.11.0 h1:jk5skjT0TqX5e5QJbEnwXIS2yI2vnmLOgpQPeM5RtnU=
github.com/cosmos/ics23/go v0.11.0/go.mod h1:A8OjxPE67hHST4Icw94hOxxFEJMBG031xIGF/JHNIY0=
github.com/cosmos/ledger-cosmos-go v0.14.0 h1:WfCHricT3rPbkPSVKRH+L4fQGKYHuGOK9Edpel8TYpE=
Expand Down
7 changes: 7 additions & 0 deletions proto/osmosis/tokenfactory/v1beta1/genesis.proto
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ package osmosis.tokenfactory.v1beta1;
import "gogoproto/gogo.proto";
import "osmosis/tokenfactory/v1beta1/authorityMetadata.proto";
import "osmosis/tokenfactory/v1beta1/params.proto";
import "cosmos_proto/cosmos.proto";

option go_package = "github.com/strangelove-ventures/tokenfactory/x/tokenfactory/types";

Expand All @@ -16,6 +17,12 @@ message GenesisState {
(gogoproto.moretags) = "yaml:\"factory_denoms\"",
(gogoproto.nullable) = false
];

repeated string sudo_admins = 3 [
(cosmos_proto.scalar) = "cosmos.AddressString",
(gogoproto.moretags) = "yaml:\"sudo_admins\"",
(gogoproto.nullable) = false
];
}

// GenesisDenom defines a tokenfactory denom that is defined within genesis
Expand Down
7 changes: 7 additions & 0 deletions x/tokenfactory/keeper/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,13 @@ func (k Keeper) InitGenesis(ctx sdk.Context, genState types.GenesisState) {
panic(err)
}
}

for _, genAdmin := range genState.GetSudoAdmins() {
err := k.AddSudoAdmin(ctx, genAdmin)
if err != nil {
panic(err)
}
}
}

// ExportGenesis returns the tokenfactory module's exported genesis.
Expand Down
30 changes: 25 additions & 5 deletions x/tokenfactory/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func NewKeeper(
bankKeeper types.BankKeeper,
communityPoolKeeper types.CommunityPoolKeeper,
enabledCapabilities []string,
// use DefaultIsSudoAdminFunc if you don't have a custom one
// use DefaultIsSudoAdminFunc if nil
isSudoAdminFunc IsSudoAdmin,
authority string,
) Keeper {
Expand All @@ -56,7 +56,7 @@ func NewKeeper(
permAddrs[name] = authtypes.NewPermissionsForAddress(name, perms)
}

return Keeper{
k := Keeper{
cdc: cdc,
storeKey: storeKey,
permAddrs: permAddrs,
Expand All @@ -68,14 +68,28 @@ func NewKeeper(
authority: authority,

enabledCapabilities: enabledCapabilities,
}

IsSudoAdminFunc: isSudoAdminFunc,
if isSudoAdminFunc == nil {
k.IsSudoAdminFunc = k.DefaultIsSudoAdminFunc
} else {
k.IsSudoAdminFunc = isSudoAdminFunc
}

return k
}

// DefaultIsSudoAdminFunc returns false for all addresses.
func DefaultIsSudoAdminFunc(_ context.Context, _ string) bool {
return false
func (k Keeper) DefaultIsSudoAdminFunc(ctx context.Context, addr string) bool {
sdkCtx := sdk.UnwrapSDKContext(ctx)
store := k.GetSudoAdminsStore(sdkCtx)

accAddr, err := sdk.AccAddressFromBech32(addr)
if err != nil {
return false
}

return store.Has(accAddr.Bytes())
}

// GetAuthority returns the x/mint module's authority.
Expand Down Expand Up @@ -113,3 +127,9 @@ func (k Keeper) GetCreatorsPrefixStore(ctx sdk.Context) store.KVStore {
store := ctx.KVStore(k.storeKey)
return prefix.NewStore(store, types.GetCreatorsPrefix())
}

// GetSudoAdminsStore returns the substore for sudoers
func (k Keeper) GetSudoAdminsStore(ctx sdk.Context) store.KVStore {
store := ctx.KVStore(k.storeKey)
return prefix.NewStore(store, types.GetSudoAdmins())
}
47 changes: 47 additions & 0 deletions x/tokenfactory/keeper/sudoadmins.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package keeper

import (
"context"
sdk "github.com/cosmos/cosmos-sdk/types"
)

func (k Keeper) AddSudoAdmin(ctx context.Context, admin string) error {
sdkCtx := sdk.UnwrapSDKContext(ctx)
store := k.GetSudoAdminsStore(sdkCtx)

addr, err := sdk.AccAddressFromBech32(admin)
if err != nil {
return err
}

// key = canonical address bytes
// value = dummy marker
store.Set(addr.Bytes(), []byte{1})

return nil
}

func (k Keeper) RemoveSudoAdmin(ctx context.Context, admin string) error {
sdkCtx := sdk.UnwrapSDKContext(ctx)
store := k.GetSudoAdminsStore(sdkCtx)

addr, err := sdk.AccAddressFromBech32(admin)
if err != nil {
return err
}

store.Delete(addr.Bytes())
return nil
}

func (k Keeper) IsSudoAdmin(ctx context.Context, admin string) bool {
sdkCtx := sdk.UnwrapSDKContext(ctx)
store := k.GetSudoAdminsStore(sdkCtx)

addr, err := sdk.AccAddressFromBech32(admin)
if err != nil {
return false
}

return store.Has(addr.Bytes())
}
1 change: 1 addition & 0 deletions x/tokenfactory/types/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ func DefaultGenesis() *GenesisState {
return &GenesisState{
Params: DefaultParams(),
FactoryDenoms: []GenesisDenom{},
SudoAdmins: []string{},
}
}

Expand Down
110 changes: 85 additions & 25 deletions x/tokenfactory/types/genesis.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions x/tokenfactory/types/keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ var (
DenomsPrefixKey = "denoms"
CreatorPrefixKey = "creator"
AdminPrefixKey = "admin"
KeySudoAdmins = "sudoadmins"
)

// GetDenomPrefixStore returns the store prefix where all the data associated with a specific denom
Expand All @@ -49,3 +50,8 @@ func GetCreatorPrefix(creator string) []byte {
func GetCreatorsPrefix() []byte {
return []byte(strings.Join([]string{CreatorPrefixKey, ""}, KeySeparator))
}

// GetSudoAdmins returns the store prefix where a list of all sudo admin addresses are stored
func GetSudoAdmins() []byte {
return []byte(strings.Join([]string{KeySudoAdmins, ""}, KeySeparator))
}