-
Notifications
You must be signed in to change notification settings - Fork 287
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #384 from terra-project/feature/mint-module
feat(mint): use uluna as default mint denom
- Loading branch information
Showing
6 changed files
with
218 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// nolint | ||
package mint | ||
|
||
import ( | ||
"github.com/cosmos/cosmos-sdk/x/mint" | ||
) | ||
|
||
const ( | ||
ModuleName = mint.ModuleName | ||
StoreKey = mint.StoreKey | ||
QuerierRoute = mint.QuerierRoute | ||
QueryParameters = mint.QueryParameters | ||
DefaultParamspace = mint.DefaultParamspace | ||
) | ||
|
||
var ( | ||
// functions aliases | ||
NewGenesisState = mint.NewGenesisState | ||
DefaultGenesisState = mint.DefaultGenesisState | ||
ValidateGenesis = mint.ValidateGenesis | ||
ParamKeyTable = mint.ParamKeyTable | ||
NewParams = mint.NewParams | ||
DefaultParams = mint.DefaultParams | ||
NewCosmosAppModule = mint.NewAppModule | ||
NewKeeper = mint.NewKeeper | ||
|
||
// variable aliases | ||
CosmosModuleCdc = mint.ModuleCdc | ||
) | ||
|
||
type ( | ||
GenesisState = mint.GenesisState | ||
Params = mint.Params | ||
Keeper = mint.Keeper | ||
CosmosAppModule = mint.AppModule | ||
CosmosAppModuleBasic = mint.AppModuleBasic | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,160 @@ | ||
package mint | ||
|
||
import ( | ||
"encoding/json" | ||
"math/rand" | ||
|
||
"github.com/gorilla/mux" | ||
"github.com/spf13/cobra" | ||
|
||
abci "github.com/tendermint/tendermint/abci/types" | ||
|
||
"github.com/cosmos/cosmos-sdk/client/context" | ||
"github.com/cosmos/cosmos-sdk/codec" | ||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
"github.com/cosmos/cosmos-sdk/types/module" | ||
sim "github.com/cosmos/cosmos-sdk/x/simulation" | ||
|
||
core "github.com/terra-project/core/types" | ||
) | ||
|
||
var ( | ||
_ module.AppModule = AppModule{} | ||
_ module.AppModuleBasic = AppModuleBasic{} | ||
_ module.AppModuleSimulation = AppModule{} | ||
) | ||
|
||
// AppModuleBasic defines the basic application module used by the slashing module. | ||
type AppModuleBasic struct{} | ||
|
||
// Name returns the slashing module's name | ||
func (AppModuleBasic) Name() string { | ||
return CosmosAppModuleBasic{}.Name() | ||
} | ||
|
||
// RegisterCodec registers the slashing module's types for the given codec. | ||
func (AppModuleBasic) RegisterCodec(cdc *codec.Codec) { | ||
CosmosAppModuleBasic{}.RegisterCodec(cdc) | ||
} | ||
|
||
// DefaultGenesis returns default genesis state as raw bytes for the slashing | ||
// module. | ||
func (AppModuleBasic) DefaultGenesis() json.RawMessage { | ||
// customize to set default genesis state bond denom to uluna | ||
defaultGenesisState := DefaultGenesisState() | ||
defaultGenesisState.Params.MintDenom = core.MicroLunaDenom | ||
|
||
return CosmosModuleCdc.MustMarshalJSON(defaultGenesisState) | ||
} | ||
|
||
// ValidateGenesis performs genesis state validation for the slashing module. | ||
func (AppModuleBasic) ValidateGenesis(bz json.RawMessage) error { | ||
return CosmosAppModuleBasic{}.ValidateGenesis(bz) | ||
} | ||
|
||
// RegisterRESTRoutes registers the REST routes for the slashing module. | ||
func (AppModuleBasic) RegisterRESTRoutes(cliCtx context.CLIContext, route *mux.Router) { | ||
CosmosAppModuleBasic{}.RegisterRESTRoutes(cliCtx, route) | ||
} | ||
|
||
// GetTxCmd returns the root tx command for the slashing module. | ||
func (AppModuleBasic) GetTxCmd(cdc *codec.Codec) *cobra.Command { | ||
return CosmosAppModuleBasic{}.GetTxCmd(cdc) | ||
} | ||
|
||
// GetQueryCmd returns the root query command for the slashing module. | ||
func (AppModuleBasic) GetQueryCmd(cdc *codec.Codec) *cobra.Command { | ||
return CosmosAppModuleBasic{}.GetQueryCmd(cdc) | ||
} | ||
|
||
//___________________________ | ||
|
||
// AppModule implements an application module for the slashing module. | ||
type AppModule struct { | ||
AppModuleBasic | ||
cosmosAppModule CosmosAppModule | ||
} | ||
|
||
// NewAppModule creates a new AppModule object | ||
func NewAppModule(keeper Keeper) AppModule { | ||
return AppModule{ | ||
AppModuleBasic: AppModuleBasic{}, | ||
cosmosAppModule: NewCosmosAppModule(keeper), | ||
} | ||
} | ||
|
||
// Name returns the slashing module's name. | ||
func (am AppModule) Name() string { | ||
return am.cosmosAppModule.Name() | ||
} | ||
|
||
// RegisterInvariants registers the slashing module invariants. | ||
func (am AppModule) RegisterInvariants(ir sdk.InvariantRegistry) { | ||
am.cosmosAppModule.RegisterInvariants(ir) | ||
} | ||
|
||
// Route returns the message routing key for the slashing module. | ||
func (am AppModule) Route() string { | ||
return am.cosmosAppModule.Route() | ||
} | ||
|
||
// NewHandler returns an sdk.Handler for the slashing module. | ||
func (am AppModule) NewHandler() sdk.Handler { | ||
return am.cosmosAppModule.NewHandler() | ||
} | ||
|
||
// QuerierRoute returns the slashing module's querier route name. | ||
func (am AppModule) QuerierRoute() string { return am.cosmosAppModule.QuerierRoute() } | ||
|
||
// NewQuerierHandler returns the slashing module sdk.Querier. | ||
func (am AppModule) NewQuerierHandler() sdk.Querier { return am.cosmosAppModule.NewQuerierHandler() } | ||
|
||
// InitGenesis performs genesis initialization for the slashing module. | ||
func (am AppModule) InitGenesis(ctx sdk.Context, data json.RawMessage) []abci.ValidatorUpdate { | ||
return am.cosmosAppModule.InitGenesis(ctx, data) | ||
} | ||
|
||
// ExportGenesis returns the exported genesis state as raw bytes for the slashing | ||
// module. | ||
func (am AppModule) ExportGenesis(ctx sdk.Context) json.RawMessage { | ||
return am.cosmosAppModule.ExportGenesis(ctx) | ||
} | ||
|
||
// BeginBlock returns the begin blocker for the slashing module. | ||
func (am AppModule) BeginBlock(ctx sdk.Context, rbb abci.RequestBeginBlock) { | ||
am.cosmosAppModule.BeginBlock(ctx, rbb) | ||
} | ||
|
||
// EndBlock returns the end blocker for the slashing module. | ||
func (am AppModule) EndBlock(ctx sdk.Context, rbb abci.RequestEndBlock) []abci.ValidatorUpdate { | ||
return am.cosmosAppModule.EndBlock(ctx, rbb) | ||
} | ||
|
||
//____________________________________________________________________________ | ||
|
||
// AppModuleSimulation functions | ||
|
||
// GenerateGenesisState creates a randomized GenState of the auth module | ||
func (am AppModule) GenerateGenesisState(simState *module.SimulationState) { | ||
am.cosmosAppModule.GenerateGenesisState(simState) | ||
} | ||
|
||
// ProposalContents doesn't return any content functions for governance proposals. | ||
func (am AppModule) ProposalContents(simState module.SimulationState) []sim.WeightedProposalContent { | ||
return am.cosmosAppModule.ProposalContents(simState) | ||
} | ||
|
||
// RandomizedParams creates randomized auth param changes for the simulator. | ||
func (am AppModule) RandomizedParams(r *rand.Rand) []sim.ParamChange { | ||
return am.cosmosAppModule.RandomizedParams(r) | ||
} | ||
|
||
// RegisterStoreDecoder registers a decoder for auth module's types | ||
func (am AppModule) RegisterStoreDecoder(sdr sdk.StoreDecoderRegistry) { | ||
am.cosmosAppModule.RegisterStoreDecoder(sdr) | ||
} | ||
|
||
// WeightedOperations doesn't return any auth module operation. | ||
func (am AppModule) WeightedOperations(simState module.SimulationState) []sim.WeightedOperation { | ||
return am.cosmosAppModule.WeightedOperations(simState) | ||
} |