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

Token Factory module #584

Closed
wants to merge 27 commits into from
Closed
Show file tree
Hide file tree
Changes from 20 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
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
247 changes: 247 additions & 0 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,9 @@ import (
poolincentivesclient "github.com/osmosis-labs/osmosis/x/pool-incentives/client"
poolincentiveskeeper "github.com/osmosis-labs/osmosis/x/pool-incentives/keeper"
poolincentivestypes "github.com/osmosis-labs/osmosis/x/pool-incentives/types"
"github.com/osmosis-labs/osmosis/x/tokenfactory"
tokenfactorykeeper "github.com/osmosis-labs/osmosis/x/tokenfactory/keeper"
tokenfactorytypes "github.com/osmosis-labs/osmosis/x/tokenfactory/types"
"github.com/osmosis-labs/osmosis/x/txfees"
txfeeskeeper "github.com/osmosis-labs/osmosis/x/txfees/keeper"
txfeestypes "github.com/osmosis-labs/osmosis/x/txfees/types"
Expand Down Expand Up @@ -162,6 +165,7 @@ var (
epochs.AppModuleBasic{},
claim.AppModuleBasic{},
bech32ibc.AppModuleBasic{},
tokenfactory.AppModuleBasic{},
)

// module account permissions
Expand All @@ -180,6 +184,7 @@ var (
lockuptypes.ModuleName: {authtypes.Minter, authtypes.Burner},
poolincentivestypes.ModuleName: nil,
txfeestypes.ModuleName: nil,
tokenfactorytypes.ModuleName: {authtypes.Minter, authtypes.Burner},
}

// module accounts that are allowed to receive tokens
Expand All @@ -206,12 +211,42 @@ type OsmosisApp struct {
tkeys map[string]*sdk.TransientStoreKey
memKeys map[string]*sdk.MemoryStoreKey

<<<<<<< HEAD
// keepers
AccountKeeper authkeeper.AccountKeeper
BankKeeper bankkeeper.Keeper
CapabilityKeeper *capabilitykeeper.Keeper
StakingKeeper stakingkeeper.Keeper
SlashingKeeper slashingkeeper.Keeper
MintKeeper mintkeeper.Keeper
DistrKeeper distrkeeper.Keeper
GovKeeper govkeeper.Keeper
CrisisKeeper crisiskeeper.Keeper
UpgradeKeeper upgradekeeper.Keeper
ParamsKeeper paramskeeper.Keeper
IBCKeeper *ibckeeper.Keeper // IBC Keeper must be a pointer in the app, so we can SetRouter on it correctly
EvidenceKeeper evidencekeeper.Keeper
TransferKeeper ibctransferkeeper.Keeper
AuthzKeeper authzkeeper.Keeper
ClaimKeeper *claimkeeper.Keeper
GAMMKeeper gammkeeper.Keeper
IncentivesKeeper incentiveskeeper.Keeper
LockupKeeper lockupkeeper.Keeper
EpochsKeeper epochskeeper.Keeper
PoolIncentivesKeeper poolincentiveskeeper.Keeper
TxFeesKeeper txfeeskeeper.Keeper
TokenFactoryKeeper tokenfactorykeeper.Keeper

Bech32IBCKeeper bech32ibckeeper.Keeper
Bech32ICS20Keeper bech32ics20keeper.Keeper
=======
// keepers, by order of initialization
// "Special" keepers
ParamsKeeper *paramskeeper.Keeper
CapabilityKeeper *capabilitykeeper.Keeper
CrisisKeeper *crisiskeeper.Keeper
UpgradeKeeper *upgradekeeper.Keeper
>>>>>>> main

// make scoped keepers public for test purposes
ScopedIBCKeeper capabilitykeeper.ScopedKeeper
Expand Down Expand Up @@ -282,6 +317,7 @@ func NewOsmosisApp(
gammtypes.StoreKey, lockuptypes.StoreKey, claimtypes.StoreKey, incentivestypes.StoreKey,
epochstypes.StoreKey, poolincentivestypes.StoreKey, authzkeeper.StoreKey, txfeestypes.StoreKey,
bech32ibctypes.StoreKey,
tokenfactorytypes.StoreKey,
sunnya97 marked this conversation as resolved.
Show resolved Hide resolved
)
tkeys := sdk.NewTransientStoreKeys(paramstypes.TStoreKey)
memKeys := sdk.NewMemoryStoreKeys(capabilitytypes.MemStoreKey)
Expand All @@ -297,11 +333,201 @@ func NewOsmosisApp(
memKeys: memKeys,
}

<<<<<<< HEAD
app.ParamsKeeper = initParamsKeeper(appCodec, cdc, keys[paramstypes.StoreKey], tkeys[paramstypes.TStoreKey])

// set the BaseApp's parameter store
bApp.SetParamStore(app.ParamsKeeper.Subspace(baseapp.Paramspace).WithKeyTable(paramskeeper.ConsensusParamsKeyTable()))

// add capability keeper and ScopeToModule for ibc module
app.CapabilityKeeper = capabilitykeeper.NewKeeper(appCodec, keys[capabilitytypes.StoreKey], memKeys[capabilitytypes.MemStoreKey])
scopedIBCKeeper := app.CapabilityKeeper.ScopeToModule(ibchost.ModuleName)
scopedTransferKeeper := app.CapabilityKeeper.ScopeToModule(ibctransfertypes.ModuleName)
app.CapabilityKeeper.Seal()

// add keepers
app.AccountKeeper = authkeeper.NewAccountKeeper(
appCodec, keys[authtypes.StoreKey], app.GetSubspace(authtypes.ModuleName), authtypes.ProtoBaseAccount, maccPerms,
)
app.BankKeeper = bankkeeper.NewBaseKeeper(
appCodec,
keys[banktypes.StoreKey],
app.AccountKeeper,
app.GetSubspace(banktypes.ModuleName),
app.BlockedAddrs(),
)
app.AuthzKeeper = authzkeeper.NewKeeper(
keys[authzkeeper.StoreKey],
appCodec,
app.BaseApp.MsgServiceRouter(),
)
stakingKeeper := stakingkeeper.NewKeeper(
appCodec, keys[stakingtypes.StoreKey], app.AccountKeeper, app.BankKeeper, app.GetSubspace(stakingtypes.ModuleName),
)

app.DistrKeeper = distrkeeper.NewKeeper(
appCodec, keys[distrtypes.StoreKey], app.GetSubspace(distrtypes.ModuleName), app.AccountKeeper, app.BankKeeper,
&stakingKeeper, authtypes.FeeCollectorName, app.ModuleAccountAddrs(),
)
app.SlashingKeeper = slashingkeeper.NewKeeper(
appCodec, keys[slashingtypes.StoreKey], &stakingKeeper, app.GetSubspace(slashingtypes.ModuleName),
)
app.CrisisKeeper = crisiskeeper.NewKeeper(
app.GetSubspace(crisistypes.ModuleName), invCheckPeriod, app.BankKeeper, authtypes.FeeCollectorName,
)
app.UpgradeKeeper = upgradekeeper.NewKeeper(
skipUpgradeHeights,
keys[upgradetypes.StoreKey],
appCodec,
homePath,
app.BaseApp,
)

// Create IBC Keeper
app.IBCKeeper = ibckeeper.NewKeeper(
appCodec,
keys[ibchost.StoreKey],
app.GetSubspace(ibchost.ModuleName),
&stakingKeeper,
app.UpgradeKeeper,
scopedIBCKeeper)

// Create Transfer Keepers
app.TransferKeeper = ibctransferkeeper.NewKeeper(
appCodec, keys[ibctransfertypes.StoreKey], app.GetSubspace(ibctransfertypes.ModuleName),
app.IBCKeeper.ChannelKeeper, &app.IBCKeeper.PortKeeper,
app.AccountKeeper, app.BankKeeper, scopedTransferKeeper,
)
transferModule := transfer.NewAppModule(app.TransferKeeper)

// Create static IBC router, add transfer route, then set and seal it
ibcRouter := porttypes.NewRouter()
ibcRouter.AddRoute(ibctransfertypes.ModuleName, transferModule)
app.IBCKeeper.SetRouter(ibcRouter)

app.Bech32IBCKeeper = *bech32ibckeeper.NewKeeper(
app.IBCKeeper.ChannelKeeper, appCodec, keys[bech32ibctypes.StoreKey],
app.TransferKeeper,
)

app.Bech32ICS20Keeper = *bech32ics20keeper.NewKeeper(
app.IBCKeeper.ChannelKeeper,
app.BankKeeper, app.TransferKeeper,
app.Bech32IBCKeeper,
app.TransferKeeper,
appCodec,
)

// create evidence keeper with router
evidenceKeeper := evidencekeeper.NewKeeper(
appCodec, keys[evidencetypes.StoreKey], &stakingKeeper, app.SlashingKeeper,
)
// If evidence needs to be handled for the app, set routes in router here and seal
app.EvidenceKeeper = *evidenceKeeper

app.ClaimKeeper = claimkeeper.NewKeeper(appCodec, keys[claimtypes.StoreKey], app.AccountKeeper, app.BankKeeper, stakingKeeper, app.DistrKeeper)

app.setupUpgrades()

// register the staking hooks
// NOTE: stakingKeeper above is passed by reference, so that it will contain these hooks
app.StakingKeeper = *stakingKeeper.SetHooks(
stakingtypes.NewMultiStakingHooks(app.DistrKeeper.Hooks(), app.SlashingKeeper.Hooks(), app.ClaimKeeper.Hooks()),
)
gammKeeper := gammkeeper.NewKeeper(appCodec, keys[gammtypes.StoreKey], app.GetSubspace(gammtypes.ModuleName), app.AccountKeeper, app.BankKeeper, app.DistrKeeper)
lockupKeeper := lockupkeeper.NewKeeper(appCodec, keys[lockuptypes.StoreKey], app.AccountKeeper, app.BankKeeper)
epochsKeeper := epochskeeper.NewKeeper(appCodec, keys[epochstypes.StoreKey])
incentivesKeeper := incentiveskeeper.NewKeeper(appCodec, keys[incentivestypes.StoreKey], app.GetSubspace(incentivestypes.ModuleName), app.AccountKeeper, app.BankKeeper, *lockupKeeper, epochsKeeper)
mintKeeper := mintkeeper.NewKeeper(
appCodec, keys[minttypes.StoreKey], app.GetSubspace(minttypes.ModuleName),
app.AccountKeeper, app.BankKeeper, app.DistrKeeper, app.EpochsKeeper,
authtypes.FeeCollectorName,
)

app.PoolIncentivesKeeper = poolincentiveskeeper.NewKeeper(
appCodec,
keys[poolincentivestypes.StoreKey],
app.GetSubspace(poolincentivestypes.ModuleName),
app.AccountKeeper,
app.BankKeeper,
incentivesKeeper,
app.DistrKeeper,
distrtypes.ModuleName,
authtypes.FeeCollectorName,
)
poolIncentivesHooks := app.PoolIncentivesKeeper.Hooks()

app.TokenFactoryKeeper = *tokenfactorykeeper.NewKeeper(appCodec, keys[tokenfactorytypes.StoreKey], app.AccountKeeper, app.BankKeeper)

// register the proposal types
govRouter := govtypes.NewRouter()
govRouter.AddRoute(govtypes.RouterKey, govtypes.ProposalHandler).
AddRoute(paramproposal.RouterKey, params.NewParamChangeProposalHandler(app.ParamsKeeper)).
AddRoute(distrtypes.RouterKey, distr.NewCommunityPoolSpendProposalHandler(app.DistrKeeper)).
AddRoute(ibcclienttypes.RouterKey, ibcclient.NewClientProposalHandler(app.IBCKeeper.ClientKeeper)).
AddRoute(upgradetypes.RouterKey, upgrade.NewSoftwareUpgradeProposalHandler(app.UpgradeKeeper)).
AddRoute(ibchost.RouterKey, ibcclient.NewClientProposalHandler(app.IBCKeeper.ClientKeeper)).
AddRoute(poolincentivestypes.RouterKey, poolincentives.NewPoolIncentivesProposalHandler(app.PoolIncentivesKeeper)).
AddRoute(bech32ibctypes.RouterKey, bech32ibc.NewBech32IBCProposalHandler(app.Bech32IBCKeeper))

govKeeper := govkeeper.NewKeeper(
appCodec, keys[govtypes.StoreKey], app.GetSubspace(govtypes.ModuleName), app.AccountKeeper, app.BankKeeper,
&stakingKeeper, govRouter)

app.GAMMKeeper = *gammKeeper.SetHooks(
gammtypes.NewMultiGammHooks(
// insert gamm hooks receivers here
poolIncentivesHooks,
app.ClaimKeeper.Hooks(),
),
)

app.TxFeesKeeper = txfeeskeeper.NewKeeper(
appCodec,
keys[txfeestypes.StoreKey],
app.GAMMKeeper,
)

app.LockupKeeper = *lockupKeeper.SetHooks(
lockuptypes.NewMultiLockupHooks(
// insert lockup hooks receivers here
),
)

app.IncentivesKeeper = *incentivesKeeper.SetHooks(
incentivestypes.NewMultiIncentiveHooks(
// insert incentive hooks receivers here
),
)

app.MintKeeper = *mintKeeper.SetHooks(
minttypes.NewMultiMintHooks(
// insert mint hooks receivers here
poolIncentivesHooks,
),
)

app.EpochsKeeper = *epochsKeeper.SetHooks(
epochstypes.NewMultiEpochHooks(
// insert epoch hooks receivers here
app.IncentivesKeeper.Hooks(),
app.MintKeeper.Hooks(),
),
)

app.GovKeeper = *govKeeper.SetHooks(
govtypes.NewMultiGovHooks(
// insert governance hooks receivers here
app.ClaimKeeper.Hooks(),
),
)
=======
app.InitSpecialKeepers(skipUpgradeHeights, homePath, invCheckPeriod)
app.setupUpgradeStoreLoaders()
app.InitNormalKeepers()
app.SetupHooks()
app.setupUpgradeHandlers()
>>>>>>> main

/**** Module Options ****/

Expand Down Expand Up @@ -340,13 +566,24 @@ func NewOsmosisApp(
params.NewAppModule(*app.ParamsKeeper),
app.transferModule,
claim.NewAppModule(appCodec, *app.ClaimKeeper),
<<<<<<< HEAD
gamm.NewAppModule(appCodec, app.GAMMKeeper, app.AccountKeeper, app.BankKeeper),
txfees.NewAppModule(appCodec, app.TxFeesKeeper),
incentives.NewAppModule(appCodec, app.IncentivesKeeper, app.AccountKeeper, app.BankKeeper, app.EpochsKeeper),
lockup.NewAppModule(appCodec, app.LockupKeeper, app.AccountKeeper, app.BankKeeper),
poolincentives.NewAppModule(appCodec, app.PoolIncentivesKeeper),
epochs.NewAppModule(appCodec, app.EpochsKeeper),
bech32ibc.NewAppModule(appCodec, app.Bech32IBCKeeper),
tokenfactory.NewAppModule(appCodec, app.TokenFactoryKeeper),
=======
gamm.NewAppModule(appCodec, *app.GAMMKeeper, app.AccountKeeper, app.BankKeeper),
txfees.NewAppModule(appCodec, *app.TxFeesKeeper),
incentives.NewAppModule(appCodec, *app.IncentivesKeeper, app.AccountKeeper, app.BankKeeper, app.EpochsKeeper),
lockup.NewAppModule(appCodec, *app.LockupKeeper, app.AccountKeeper, app.BankKeeper),
poolincentives.NewAppModule(appCodec, *app.PoolIncentivesKeeper),
epochs.NewAppModule(appCodec, *app.EpochsKeeper),
bech32ibc.NewAppModule(appCodec, *app.Bech32IBCKeeper),
>>>>>>> main
)

// During begin block slashing happens after distr.BeginBlocker so that
Expand Down Expand Up @@ -388,6 +625,7 @@ func NewOsmosisApp(
epochstypes.ModuleName,
lockuptypes.ModuleName,
authz.ModuleName,
tokenfactorytypes.ModuleName,
)

app.mm.RegisterInvariants(app.CrisisKeeper)
Expand All @@ -414,11 +652,20 @@ func NewOsmosisApp(
params.NewAppModule(*app.ParamsKeeper),
evidence.NewAppModule(*app.EvidenceKeeper),
ibc.NewAppModule(app.IBCKeeper),
<<<<<<< HEAD
incentives.NewAppModule(appCodec, app.IncentivesKeeper, app.AccountKeeper, app.BankKeeper, app.EpochsKeeper),
lockup.NewAppModule(appCodec, app.LockupKeeper, app.AccountKeeper, app.BankKeeper),
poolincentives.NewAppModule(appCodec, app.PoolIncentivesKeeper),
epochs.NewAppModule(appCodec, app.EpochsKeeper),
transferModule,
tokenfactory.NewAppModule(appCodec, app.TokenFactoryKeeper),
=======
incentives.NewAppModule(appCodec, *app.IncentivesKeeper, app.AccountKeeper, app.BankKeeper, app.EpochsKeeper),
lockup.NewAppModule(appCodec, *app.LockupKeeper, app.AccountKeeper, app.BankKeeper),
poolincentives.NewAppModule(appCodec, *app.PoolIncentivesKeeper),
epochs.NewAppModule(appCodec, *app.EpochsKeeper),
app.transferModule,
>>>>>>> main
)

app.sm.RegisterStoreDecoders()
Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ require (
github.com/gogo/gateway v1.1.0 // indirect
github.com/golang/snappy v0.0.3 // indirect
github.com/google/btree v1.0.0 // indirect
github.com/google/go-cmp v0.5.6 // indirect
github.com/google/orderedcode v0.0.1 // indirect
github.com/gorilla/handlers v1.5.1 // indirect
github.com/gorilla/websocket v1.4.2 // indirect
Expand Down
14 changes: 14 additions & 0 deletions proto/osmosis/tokenfactory/v1beta1/authorityMetadata.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
syntax = "proto3";
package osmosis.tokenfactory.v1beta1;

import "gogoproto/gogo.proto";
import "cosmos/base/v1beta1/coin.proto";

option go_package = "github.com/osmosis-labs/osmosis/x/tokenfactory/types";

message DenomAuthorityMetadata {
option (gogoproto.equal) = true;

// Can be empty for no admin, or a valid osmosis address
string Admin = 1 [ (gogoproto.moretags) = "yaml:\"admin\"" ];
sunnya97 marked this conversation as resolved.
Show resolved Hide resolved
}
27 changes: 27 additions & 0 deletions proto/osmosis/tokenfactory/v1beta1/genesis.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
syntax = "proto3";
package osmosis.tokenfactory.v1beta1;

import "gogoproto/gogo.proto";
import "osmosis/tokenfactory/v1beta1/authorityMetadata.proto";

option go_package = "github.com/osmosis-labs/osmosis/x/tokenfactory/types";

// GenesisState defines the tokenfactory module's genesis state.
message GenesisState {
option (gogoproto.equal) = true;

repeated GenesisDenom factory_denoms = 1 [
(gogoproto.moretags) = "yaml:\"factory_denoms\"",
(gogoproto.nullable) = false
];
}

message GenesisDenom {
ValarDragon marked this conversation as resolved.
Show resolved Hide resolved
option (gogoproto.equal) = true;

string denom = 1 [ (gogoproto.moretags) = "yaml:\"denom\"" ];
ValarDragon marked this conversation as resolved.
Show resolved Hide resolved
DenomAuthorityMetadata authority_metadata = 2 [
(gogoproto.moretags) = "yaml:\"authority_metadata\"",
(gogoproto.nullable) = false
];
}
Loading