Documentation ¶
Index ¶
- Constants
- Variables
- func ErrAddressNotAuthorised() sdk.Error
- func ErrCommunityNotFound(id string) sdk.Error
- func ErrInvalidCommunityMsg(message string) sdk.Error
- func ErrJSONParse(err error) sdk.Error
- func InitGenesis(ctx sdk.Context, keeper Keeper, data GenesisState)
- func NewHandler(k Keeper) sdk.Handler
- func NewQuerier(k Keeper) sdk.Querier
- func ParamKeyTable() params.KeyTable
- func RegisterCodec(c *codec.Codec)
- func ValidateGenesis(data GenesisState) error
- type AppModule
- func (am AppModule) BeginBlock(_ sdk.Context, _ abci.RequestBeginBlock)
- func (AppModule) EndBlock(_ sdk.Context, _ abci.RequestEndBlock) []abci.ValidatorUpdate
- func (am AppModule) ExportGenesis(ctx sdk.Context) json.RawMessage
- func (am AppModule) InitGenesis(ctx sdk.Context, data json.RawMessage) []abci.ValidatorUpdate
- func (am AppModule) NewHandler() sdk.Handler
- func (am AppModule) NewQuerierHandler() sdk.Querier
- func (AppModule) QuerierRoute() string
- func (am AppModule) RegisterInvariants(ir sdk.InvariantRegistry)
- func (AppModule) Route() string
- type AppModuleBasic
- func (AppModuleBasic) DefaultGenesis() json.RawMessage
- func (AppModuleBasic) GetQueryCmd(cdc *codec.Codec) *cobra.Command
- func (AppModuleBasic) GetTxCmd(_ *codec.Codec) *cobra.Command
- func (AppModuleBasic) Name() string
- func (AppModuleBasic) RegisterCodec(cdc *codec.Codec)
- func (AppModuleBasic) RegisterRESTRoutes(ctx context.CLIContext, rtr *mux.Router)
- func (AppModuleBasic) ValidateGenesis(bz json.RawMessage) error
- type Communities
- type Community
- type GenesisState
- type Keeper
- func (k Keeper) AddAdmin(ctx sdk.Context, admin, creator sdk.AccAddress) (err sdk.Error)
- func (k Keeper) Communities(ctx sdk.Context) (communities []Community)
- func (k Keeper) Community(ctx sdk.Context, id string) (community Community, err sdk.Error)
- func (k Keeper) GetParams(ctx sdk.Context) Params
- func (k Keeper) NewCommunity(ctx sdk.Context, id string, name string, description string, ...) (community Community, err sdk.Error)
- func (k Keeper) RemoveAdmin(ctx sdk.Context, admin, remover sdk.AccAddress) (err sdk.Error)
- func (k Keeper) SetParams(ctx sdk.Context, params Params)
- func (k Keeper) UpdateParams(ctx sdk.Context, updater sdk.AccAddress, updates Params, ...) sdk.Error
- type MsgAddAdmin
- type MsgNewCommunity
- type MsgRemoveAdmin
- type MsgUpdateParams
- type Params
- type QueryCommunityParams
Constants ¶
const ( DefaultCodespace sdk.CodespaceType = ModuleName ErrorCodeCommunityNotFound sdk.CodeType = 801 ErrorCodeInvalidCommunityMsg sdk.CodeType = 802 ErrorCodeAddressNotAuthorised sdk.CodeType = 803 ErrorCodeJSONParsing sdk.CodeType = 804 )
Community errors reserve 800 ~ 899.
const ( // TypeMsgNewCommunity represents the type of the message for creating new community TypeMsgNewCommunity = "new_community" // TypeMsgAddAdmin represents the type of message for adding a new admin TypeMsgAddAdmin = "add_admin" // TypeMsgRemoveAdmin represents the type of message for removeing an admin TypeMsgRemoveAdmin = "remove_admin" // TypeMsgUpdateParams represents the type of TypeMsgUpdateParams = "update_params" )
const ( QueryCommunity = "community" QueryCommunities = "communities" QueryParams = "params" )
query endpoints supported by the truchain Querier
const ( RouterKey = ModuleName QuerierRoute = ModuleName StoreKey = ModuleName )
Defines module constants
const ModuleName = "community"
ModuleName is the name of this module
Variables ¶
var ( KeyMinIDLength = []byte("minIDLength") KeyMaxIDLength = []byte("maxIDLength") KeyMinNameLength = []byte("minNameLength") KeyMaxNameLength = []byte("maxNameLength") KeyMaxDescriptionLength = []byte("maxDescriptionLength") KeyCommunityAdmins = []byte("communityAdmins") )
Keys for params
var (
CommunityKeyPrefix = []byte{0x00}
)
Keys for community store Items are stored with the following key: values
- 0x00<communityID_Bytes>: Community{} bytes
var ModuleCodec *codec.Codec
ModuleCodec encodes module codec
Functions ¶
func ErrAddressNotAuthorised ¶
ErrAddressNotAuthorised throws an error when the address is not admin
func ErrCommunityNotFound ¶
ErrCommunityNotFound throws an error when the searched category is not found
func ErrInvalidCommunityMsg ¶
ErrInvalidCommunityMsg throws an error when the searched category is not found
func ErrJSONParse ¶
ErrJSONParse throws an error on failed JSON parsing
func InitGenesis ¶
func InitGenesis(ctx sdk.Context, keeper Keeper, data GenesisState)
InitGenesis initializes community state from genesis file
func NewHandler ¶
NewHandler creates a new handler for all community messages
func NewQuerier ¶
NewQuerier returns a function that handles queries on the KVStore
func RegisterCodec ¶
RegisterCodec registers messages into the codec
func ValidateGenesis ¶
func ValidateGenesis(data GenesisState) error
ValidateGenesis validates the genesis state data
Types ¶
type AppModule ¶
type AppModule struct { AppModuleBasic // contains filtered or unexported fields }
AppModule defines external data for the module ----------------------------------------------------------------------------
func NewAppModule ¶
NewAppModule creates a NewAppModule object
func (AppModule) BeginBlock ¶
func (am AppModule) BeginBlock(_ sdk.Context, _ abci.RequestBeginBlock)
BeginBlock returns the begin blocker for the supply module.
func (AppModule) EndBlock ¶
func (AppModule) EndBlock(_ sdk.Context, _ abci.RequestEndBlock) []abci.ValidatorUpdate
EndBlock returns the end blocker for the supply module. It returns no validator updates.
func (AppModule) ExportGenesis ¶
func (am AppModule) ExportGenesis(ctx sdk.Context) json.RawMessage
ExportGenesis enforces exporting this module's data to a genesis file
func (AppModule) InitGenesis ¶
func (am AppModule) InitGenesis(ctx sdk.Context, data json.RawMessage) []abci.ValidatorUpdate
InitGenesis enforces the creation of the genesis state for this module
func (AppModule) NewHandler ¶
NewHandler creates the handler for the module
func (AppModule) NewQuerierHandler ¶
NewQuerierHandler creates a new querier handler
func (AppModule) QuerierRoute ¶
QuerierRoute defines the querier route
func (AppModule) RegisterInvariants ¶
func (am AppModule) RegisterInvariants(ir sdk.InvariantRegistry)
RegisterInvariants enforces registering of invariants
type AppModuleBasic ¶
type AppModuleBasic struct{}
AppModuleBasic defines the internal data for the module ----------------------------------------------------------------------------
func (AppModuleBasic) DefaultGenesis ¶
func (AppModuleBasic) DefaultGenesis() json.RawMessage
DefaultGenesis creates the default genesis state for testing
func (AppModuleBasic) GetQueryCmd ¶
func (AppModuleBasic) GetQueryCmd(cdc *codec.Codec) *cobra.Command
GetQueryCmd returns no root query command for the community module.
func (AppModuleBasic) GetTxCmd ¶
func (AppModuleBasic) GetTxCmd(_ *codec.Codec) *cobra.Command
GetTxCmd returns the root tx command for the community module.
func (AppModuleBasic) RegisterCodec ¶
func (AppModuleBasic) RegisterCodec(cdc *codec.Codec)
RegisterCodec registers the types needed for amino encoding/decoding
func (AppModuleBasic) RegisterRESTRoutes ¶
func (AppModuleBasic) RegisterRESTRoutes(ctx context.CLIContext, rtr *mux.Router)
RegisterRESTRoutes registers the REST routes for the community module.
func (AppModuleBasic) ValidateGenesis ¶
func (AppModuleBasic) ValidateGenesis(bz json.RawMessage) error
ValidateGenesis validates the genesis state
type Community ¶
type Community struct { ID string `json:"id"` Name string `json:"name"` Description string `json:"description,omitempty"` CreatedTime time.Time `json:"created_time,omitempty"` }
Community represents the state of a community on TruStory
func NewCommunity ¶
NewCommunity creates a new Community
type GenesisState ¶
type GenesisState struct { Communities []Community `json:"communities"` Params Params `json:"params"` }
GenesisState defines genesis data for the module
func DefaultGenesisState ¶
func DefaultGenesisState() GenesisState
DefaultGenesisState returns a default genesis state
func ExportGenesis ¶
func ExportGenesis(ctx sdk.Context, keeper Keeper) GenesisState
ExportGenesis exports the genesis state
func NewGenesisState ¶
func NewGenesisState(communities []Community, params Params) GenesisState
NewGenesisState creates a new genesis state.
type Keeper ¶
type Keeper struct {
// contains filtered or unexported fields
}
Keeper data type storing keys to the KVStore
func (Keeper) Communities ¶
Communities gets all communities from the KVStore
func (Keeper) NewCommunity ¶
func (k Keeper) NewCommunity(ctx sdk.Context, id string, name string, description string, creator sdk.AccAddress) (community Community, err sdk.Error)
NewCommunity creates a new community
func (Keeper) RemoveAdmin ¶
RemoveAdmin removes an admin
type MsgAddAdmin ¶
type MsgAddAdmin struct { Admin sdk.AccAddress `json:"admin"` Creator sdk.AccAddress `json:"creator"` }
MsgAddAdmin defines the message to add a new admin
func NewMsgAddAdmin ¶
func NewMsgAddAdmin(admin, creator sdk.AccAddress) MsgAddAdmin
NewMsgAddAdmin returns the messages to add a new admin
func (MsgAddAdmin) GetSignBytes ¶
func (msg MsgAddAdmin) GetSignBytes() []byte
GetSignBytes implements Msg
func (MsgAddAdmin) GetSigners ¶
func (msg MsgAddAdmin) GetSigners() []sdk.AccAddress
GetSigners implements Msg. Returns the creator as the signer.
func (MsgAddAdmin) ValidateBasic ¶
func (msg MsgAddAdmin) ValidateBasic() sdk.Error
ValidateBasic implements Msg
type MsgNewCommunity ¶
type MsgNewCommunity struct { Name string `json:"name"` ID string `json:"id"` Description string `json:"description"` Creator sdk.AccAddress `json:"creator"` }
MsgNewCommunity defines the message to add a new admin
func NewMsgNewCommunity ¶
func NewMsgNewCommunity(id, name, description string, creator sdk.AccAddress) MsgNewCommunity
NewMsgNewCommunity returns the messages to create a new community
func (MsgNewCommunity) GetSignBytes ¶
func (msg MsgNewCommunity) GetSignBytes() []byte
GetSignBytes implements Msg
func (MsgNewCommunity) GetSigners ¶
func (msg MsgNewCommunity) GetSigners() []sdk.AccAddress
GetSigners implements Msg. Returns the creator as the signer.
func (MsgNewCommunity) ValidateBasic ¶
func (msg MsgNewCommunity) ValidateBasic() sdk.Error
ValidateBasic implements Msg
type MsgRemoveAdmin ¶
type MsgRemoveAdmin struct { Admin sdk.AccAddress `json:"admin"` Remover sdk.AccAddress `json:"remover"` }
MsgRemoveAdmin defines the message to remove an admin
func NewMsgRemoveAdmin ¶
func NewMsgRemoveAdmin(admin, remover sdk.AccAddress) MsgRemoveAdmin
NewMsgRemoveAdmin returns the messages to remove an admin
func (MsgRemoveAdmin) GetSignBytes ¶
func (msg MsgRemoveAdmin) GetSignBytes() []byte
GetSignBytes implements Msg
func (MsgRemoveAdmin) GetSigners ¶
func (msg MsgRemoveAdmin) GetSigners() []sdk.AccAddress
GetSigners implements Msg. Returns the remover as the signer.
func (MsgRemoveAdmin) ValidateBasic ¶
func (msg MsgRemoveAdmin) ValidateBasic() sdk.Error
ValidateBasic implements Msg
type MsgUpdateParams ¶
type MsgUpdateParams struct { Updates Params `json:"updates"` UpdatedFields []string `json:"updated_fields"` Updater sdk.AccAddress `json:"updater"` }
MsgUpdateParams defines the message to remove an admin
func NewMsgUpdateParams ¶
func NewMsgUpdateParams(updates Params, updatedFields []string, updater sdk.AccAddress) MsgUpdateParams
NewMsgUpdateParams returns the message to update the params
func (MsgUpdateParams) GetSignBytes ¶
func (msg MsgUpdateParams) GetSignBytes() []byte
GetSignBytes implements Msg
func (MsgUpdateParams) GetSigners ¶
func (msg MsgUpdateParams) GetSigners() []sdk.AccAddress
GetSigners implements Msg. Returns the remover as the signer.
func (MsgUpdateParams) ValidateBasic ¶
func (msg MsgUpdateParams) ValidateBasic() sdk.Error
ValidateBasic implements Msg
type Params ¶
type Params struct { MinIDLength int `json:"min_id_length"` MaxIDLength int `json:"max_id_length"` MinNameLength int `json:"min_name_length"` MaxNameLength int `json:"max_name_length"` MaxDescriptionLength int `json:"max_description_length"` CommunityAdmins []sdk.AccAddress `json:"community_admins"` }
Params holds parameters for a Community
func (*Params) ParamSetPairs ¶
func (p *Params) ParamSetPairs() params.ParamSetPairs
ParamSetPairs implements params.ParamSet
type QueryCommunityParams ¶
type QueryCommunityParams struct {
ID string
}
QueryCommunityParams are params for querying communities by id queries