community

package
v0.3.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 19, 2019 License: Apache-2.0 Imports: 19 Imported by: 1

Documentation

Index

Constants

View Source
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.

View Source
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"
)
View Source
const (
	QueryCommunity   = "community"
	QueryCommunities = "communities"
	QueryParams      = "params"
)

query endpoints supported by the truchain Querier

View Source
const (
	RouterKey    = ModuleName
	QuerierRoute = ModuleName
	StoreKey     = ModuleName
)

Defines module constants

View Source
const ModuleName = "community"

ModuleName is the name of this module

Variables

View Source
var (
	KeyMinIDLength          = []byte("minIDLength")
	KeyMaxIDLength          = []byte("maxIDLength")
	KeyMinNameLength        = []byte("minNameLength")
	KeyMaxNameLength        = []byte("maxNameLength")
	KeyMaxDescriptionLength = []byte("maxDescriptionLength")
	KeyCommunityAdmins      = []byte("communityAdmins")
)

Keys for params

View Source
var (
	CommunityKeyPrefix = []byte{0x00}
)

Keys for community store Items are stored with the following key: values

- 0x00<communityID_Bytes>: Community{} bytes

View Source
var ModuleCodec *codec.Codec

ModuleCodec encodes module codec

Functions

func ErrAddressNotAuthorised

func ErrAddressNotAuthorised() sdk.Error

ErrAddressNotAuthorised throws an error when the address is not admin

func ErrCommunityNotFound

func ErrCommunityNotFound(id string) sdk.Error

ErrCommunityNotFound throws an error when the searched category is not found

func ErrInvalidCommunityMsg

func ErrInvalidCommunityMsg(message string) sdk.Error

ErrInvalidCommunityMsg throws an error when the searched category is not found

func ErrJSONParse

func ErrJSONParse(err error) sdk.Error

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

func NewHandler(k Keeper) sdk.Handler

NewHandler creates a new handler for all community messages

func NewQuerier

func NewQuerier(k Keeper) sdk.Querier

NewQuerier returns a function that handles queries on the KVStore

func ParamKeyTable

func ParamKeyTable() params.KeyTable

ParamKeyTable for community module

func RegisterCodec

func RegisterCodec(c *codec.Codec)

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

func NewAppModule(keeper Keeper) AppModule

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

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

func (am AppModule) NewHandler() sdk.Handler

NewHandler creates the handler for the module

func (AppModule) NewQuerierHandler

func (am AppModule) NewQuerierHandler() sdk.Querier

NewQuerierHandler creates a new querier handler

func (AppModule) QuerierRoute

func (AppModule) QuerierRoute() string

QuerierRoute defines the querier route

func (AppModule) RegisterInvariants

func (am AppModule) RegisterInvariants(ir sdk.InvariantRegistry)

RegisterInvariants enforces registering of invariants

func (AppModule) Route

func (AppModule) Route() string

Route defines the key for the route

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) Name

func (AppModuleBasic) Name() string

Name define the name of the 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 Communities

type Communities []Community

Communities is a slice of communites

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

func NewCommunity(id, name, description string, createdTime time.Time) Community

NewCommunity creates a new Community

func (Community) String

func (c Community) String() string

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 NewKeeper

func NewKeeper(storeKey sdk.StoreKey, paramStore params.Subspace, codec *codec.Codec) Keeper

NewKeeper creates a new keeper of the community Keeper

func (Keeper) AddAdmin

func (k Keeper) AddAdmin(ctx sdk.Context, admin, creator sdk.AccAddress) (err sdk.Error)

AddAdmin adds a new admin

func (Keeper) Communities

func (k Keeper) Communities(ctx sdk.Context) (communities []Community)

Communities gets all communities from the KVStore

func (Keeper) Community

func (k Keeper) Community(ctx sdk.Context, id string) (community Community, err sdk.Error)

Community returns a community by its ID

func (Keeper) GetParams

func (k Keeper) GetParams(ctx sdk.Context) Params

GetParams gets the genesis params for the community

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

func (k Keeper) RemoveAdmin(ctx sdk.Context, admin, remover sdk.AccAddress) (err sdk.Error)

RemoveAdmin removes an admin

func (Keeper) SetParams

func (k Keeper) SetParams(ctx sdk.Context, params Params)

SetParams sets the params for the community

func (Keeper) UpdateParams

func (k Keeper) UpdateParams(ctx sdk.Context, updater sdk.AccAddress, updates Params, updatedFields []string) sdk.Error

UpdateParams updates the required params

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) Route

func (msg MsgAddAdmin) Route() string

Route implements Msg

func (MsgAddAdmin) Type

func (msg MsgAddAdmin) Type() string

Type implements Msg

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) Route

func (msg MsgNewCommunity) Route() string

Route implements Msg

func (MsgNewCommunity) Type

func (msg MsgNewCommunity) Type() string

Type implements Msg

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) Route

func (msg MsgRemoveAdmin) Route() string

Route implements Msg

func (MsgRemoveAdmin) Type

func (msg MsgRemoveAdmin) Type() string

Type implements Msg

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) Route

func (msg MsgUpdateParams) Route() string

Route implements Msg

func (MsgUpdateParams) Type

func (msg MsgUpdateParams) Type() string

Type implements Msg

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 DefaultParams

func DefaultParams() Params

DefaultParams is the Community params for testing

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL