Documentation ¶
Index ¶
- Constants
- Variables
- func ErrAddressNotAuthorised() sdk.Error
- func ErrCreatorJailed(addr sdk.AccAddress) sdk.Error
- func ErrInvalidBodyTooLong() sdk.Error
- func ErrInvalidBodyTooShort(body string) sdk.Error
- func ErrInvalidCommunityID(id string) sdk.Error
- func ErrInvalidSourceURL(url string) sdk.Error
- func ErrJSONParse(err error) sdk.Error
- func ErrUnknownClaim(id uint64) sdk.Error
- func InitGenesis(ctx sdk.Context, k Keeper, data GenesisState)
- func NewHandler(keeper Keeper) sdk.Handler
- func NewQuerier(keeper Keeper) sdk.Querier
- func ParamKeyTable() params.KeyTable
- func RegisterCodec(c *codec.Codec)
- func ValidateGenesis(data GenesisState) error
- type AccountKeeper
- 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 Claim
- type Claims
- type CodeType
- type GenesisState
- type Keeper
- func (k Keeper) AddAdmin(ctx sdk.Context, admin, creator sdk.AccAddress) (err sdk.Error)
- func (k Keeper) AddBackingStake(ctx sdk.Context, id uint64, stake sdk.Coin) sdk.Error
- func (k Keeper) AddChallengeStake(ctx sdk.Context, id uint64, stake sdk.Coin) sdk.Error
- func (k Keeper) Claim(ctx sdk.Context, id uint64) (claim Claim, ok bool)
- func (k Keeper) Claims(ctx sdk.Context) (claims Claims)
- func (k Keeper) ClaimsAfterTime(ctx sdk.Context, createdTime time.Time) (claims Claims)
- func (k Keeper) ClaimsBeforeTime(ctx sdk.Context, createdTime time.Time) (claims Claims)
- func (k Keeper) ClaimsBetweenIDs(ctx sdk.Context, startClaimID, endClaimID uint64) (claims Claims)
- func (k Keeper) ClaimsBetweenTimes(ctx sdk.Context, startTime time.Time, endTime time.Time) (claims Claims)
- func (k Keeper) CommunityClaims(ctx sdk.Context, communityID string) (claims Claims)
- func (k Keeper) CreatorClaims(ctx sdk.Context, creator sdk.AccAddress) (claims Claims)
- func (k Keeper) EditClaim(ctx sdk.Context, id uint64, body string, editor sdk.AccAddress) (claim Claim, err sdk.Error)
- func (k Keeper) GetParams(ctx sdk.Context) Params
- func (k Keeper) RemoveAdmin(ctx sdk.Context, admin, remover sdk.AccAddress) (err sdk.Error)
- func (k Keeper) SetFirstArgumentTime(ctx sdk.Context, id uint64, firstArgumentTime time.Time) sdk.Error
- func (k Keeper) SetParams(ctx sdk.Context, params Params)
- func (k Keeper) SubmitClaim(ctx sdk.Context, body, communityID string, creator sdk.AccAddress, ...) (claim Claim, err sdk.Error)
- func (k Keeper) SubtractBackingStake(ctx sdk.Context, id uint64, stake sdk.Coin) sdk.Error
- func (k Keeper) SubtractChallengeStake(ctx sdk.Context, id uint64, stake sdk.Coin) sdk.Error
- func (k Keeper) UpdateParams(ctx sdk.Context, updater sdk.AccAddress, updates Params, ...) sdk.Error
- type MsgAddAdmin
- type MsgCreateClaim
- type MsgDeleteClaim
- type MsgEditClaim
- type MsgRemoveAdmin
- type MsgUpdateParams
- type Params
- type QueryClaimParams
- type QueryClaimsIDRangeParams
- type QueryClaimsParams
- type QueryClaimsTimeParams
- type QueryCommunitiesClaimsParams
- type QueryCommunityClaimsParams
- type QueryCreatorClaimsParams
Constants ¶
const ( // TypeMsgCreateClaim represents the type of the message for creating new claim TypeMsgCreateClaim = "create_claim" // 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 ( QueryClaim = "claim" QueryClaims = "claims" QueryClaimsByIDs = "claims_ids" QueryCommunityClaims = "community_claims" QueryCommunitiesClaims = "communities_claims" QueryCreatorClaims = "creator_claims" QueryClaimsIDRange = "claims_id_range" QueryClaimsBeforeTime = "claims_before_time" QueryClaimsAfterTime = "claims_after_time" QueryParams = "params" )
query endpoints
const ( RouterKey = ModuleName QuerierRoute = ModuleName StoreKey = ModuleName DefaultParamspace = ModuleName )
Defines module constants
const ModuleName = "claim"
ModuleName is the name of this module
Variables ¶
var ( ClaimsKeyPrefix = []byte{0x00} ClaimIDKey = []byte{0x01} CommunityClaimsPrefix = []byte{0x10} CreatorClaimsPrefix = []byte{0x11} CreatedTimeClaimsPrefix = []byte{0x12} )
Keys for claim store Items are stored with the following key: values
- 0x00<claimID_Bytes>: Claim_Bytes - 0x01: nextClaimID_Bytes
- 0x10<communityID_Bytes><claimID_Bytes>: claimID_Bytes - 0x11<creator_Bytes><claimID_Bytes>: claimID_Bytes - 0x12<createdTime_Bytes><claimID_Bytes>: claimID_Bytes
var ( KeyMinClaimLength = []byte("minClaimLength") KeyMaxClaimLength = []byte("maxClaimLength") KeyClaimAdmins = []byte("claimAdmins") )
Keys for params
var ModuleCodec *codec.Codec
ModuleCodec encodes module codec
Functions ¶
func ErrAddressNotAuthorised ¶
ErrAddressNotAuthorised throws an error when the address is not admin
func ErrCreatorJailed ¶
func ErrCreatorJailed(addr sdk.AccAddress) sdk.Error
ErrCreatorJailed throws an error on jailed creator
func ErrInvalidBodyTooLong ¶
ErrInvalidBodyTooLong throws an error on invalid claim body
func ErrInvalidBodyTooShort ¶
ErrInvalidBodyTooShort throws an error on invalid claim body
func ErrInvalidCommunityID ¶
ErrInvalidCommunityID throws an error on invalid community id
func ErrInvalidSourceURL ¶
ErrInvalidSourceURL throws an error when a URL in invalid
func ErrJSONParse ¶
ErrJSONParse throws an error on failed JSON parsing
func ErrUnknownClaim ¶
ErrUnknownClaim throws an error on an unknown claim id
func InitGenesis ¶
func InitGenesis(ctx sdk.Context, k Keeper, data GenesisState)
InitGenesis initializes story state from genesis file
func NewQuerier ¶
NewQuerier returns a function that handles queries on the KVStore
func RegisterCodec ¶
RegisterCodec registers all the necessary types and interfaces for the module
func ValidateGenesis ¶
func ValidateGenesis(data GenesisState) error
ValidateGenesis validates the genesis state data
Types ¶
type AccountKeeper ¶
AccountKeeper is the expected account keeper interface for this module
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 supply module.
func (AppModuleBasic) GetTxCmd ¶
func (AppModuleBasic) GetTxCmd(_ *codec.Codec) *cobra.Command
GetTxCmd returns the root tx command for the supply 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 supply module.
func (AppModuleBasic) ValidateGenesis ¶
func (AppModuleBasic) ValidateGenesis(bz json.RawMessage) error
ValidateGenesis validates the genesis state
type Claim ¶
type Claim struct { ID uint64 `json:"id"` CommunityID string `json:"community_id"` Body string `json:"body"` Creator sdk.AccAddress `json:"creator"` Source url.URL `json:"source,omitempty"` TotalStakers uint64 `json:"total_stakers,omitempty"` TotalBacked sdk.Coin `json:"total_backed,omitempty"` TotalChallenged sdk.Coin `json:"total_challenged,omitempty"` CreatedTime time.Time `json:"created_time"` FirstArgumentTime time.Time `json:"first_argument_time"` }
Claim stores data about a claim
type CodeType ¶
CodeType is the error code type for the module
const ( DefaultCodespace sdk.CodespaceType = ModuleName ErrorCodeInvalidBodyTooShort CodeType = 101 ErrorCodeInvalidBodyTooLong CodeType = 102 ErrorCodeInvalidID CodeType = 103 ErrorCodeNotFound CodeType = 104 ErrorCodeInvalidSType CodeType = 105 ErrorCodeClaimsWithCommunityNotFound CodeType = 106 ErrorCodeInvalidSourceURL CodeType = 107 ErrorCodeCreatorJailed CodeType = 108 ErrorCodeAddressNotAuthorised CodeType = 109 ErrorCodeJSONParsing CodeType = 110 )
Claim error types
type GenesisState ¶
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, k Keeper) GenesisState
ExportGenesis exports the genesis state
func NewGenesisState ¶
func NewGenesisState() GenesisState
NewGenesisState creates a new genesis state.
type Keeper ¶
type Keeper struct {
// contains filtered or unexported fields
}
Keeper is the model object for the module
func NewKeeper ¶
func NewKeeper(storeKey sdk.StoreKey, paramStore params.Subspace, codec *codec.Codec, accountKeeper AccountKeeper, communityKeeper community.Keeper) Keeper
NewKeeper creates a new claim keeper
func (Keeper) AddBackingStake ¶
AddBackingStake adds a stake amount to the total backing amount
func (Keeper) AddChallengeStake ¶
AddChallengeStake adds a stake amount to the total challenge amount
func (Keeper) ClaimsAfterTime ¶
ClaimsAfterTime gets all claims after a certain CreatedTime
func (Keeper) ClaimsBeforeTime ¶
ClaimsBeforeTime gets all claims after a certain CreatedTime
func (Keeper) ClaimsBetweenIDs ¶
ClaimsBetweenIDs gets all claims between startClaimID to endClaimID
func (Keeper) ClaimsBetweenTimes ¶
func (k Keeper) ClaimsBetweenTimes(ctx sdk.Context, startTime time.Time, endTime time.Time) (claims Claims)
ClaimsBetweenTimes gets all claims between startTime and endTime
func (Keeper) CommunityClaims ¶
CommunityClaims gets all the claims for a given community
func (Keeper) CreatorClaims ¶
CreatorClaims gets all the claims for a given creator
func (Keeper) EditClaim ¶
func (k Keeper) EditClaim(ctx sdk.Context, id uint64, body string, editor sdk.AccAddress) (claim Claim, err sdk.Error)
EditClaim allows admins to edit the body of a claim
func (Keeper) RemoveAdmin ¶
RemoveAdmin removes an admin
func (Keeper) SetFirstArgumentTime ¶
func (k Keeper) SetFirstArgumentTime(ctx sdk.Context, id uint64, firstArgumentTime time.Time) sdk.Error
SetFirstArgumentTime sets time when first argument was created on a claim
func (Keeper) SubmitClaim ¶
func (k Keeper) SubmitClaim(ctx sdk.Context, body, communityID string, creator sdk.AccAddress, source url.URL) (claim Claim, err sdk.Error)
SubmitClaim creates a new claim in the claim key-value store
func (Keeper) SubtractBackingStake ¶
SubtractBackingStake adds a stake amount to the total backing amount
func (Keeper) SubtractChallengeStake ¶
SubtractChallengeStake adds a stake amount to the total challenge amount
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 MsgCreateClaim ¶
type MsgCreateClaim struct { CommunityID string `json:"community_id"` Body string `json:"body"` Creator sdk.AccAddress `json:"creator"` Source string `json:"source,omitempty"` }
MsgCreateClaim defines a message to submit a story
func NewMsgCreateClaim ¶
func NewMsgCreateClaim(communityID, body string, creator sdk.AccAddress, source string) MsgCreateClaim
NewMsgCreateClaim creates a new message to create a claim
func (MsgCreateClaim) GetSignBytes ¶
func (msg MsgCreateClaim) GetSignBytes() []byte
GetSignBytes gets the bytes for Msg signer to sign on
func (MsgCreateClaim) GetSigners ¶
func (msg MsgCreateClaim) GetSigners() []sdk.AccAddress
GetSigners gets the signs of the Msg
func (MsgCreateClaim) Route ¶
func (msg MsgCreateClaim) Route() string
Route is the name of the route for claim
func (MsgCreateClaim) ValidateBasic ¶
func (msg MsgCreateClaim) ValidateBasic() sdk.Error
ValidateBasic validates basic fields of the Msg
type MsgDeleteClaim ¶
type MsgDeleteClaim struct { ID uint64 `json:"id"` Creator sdk.AccAddress `json:"creator"` }
MsgDeleteClaim defines a message to submit a story
func (MsgDeleteClaim) GetSignBytes ¶
func (msg MsgDeleteClaim) GetSignBytes() []byte
GetSignBytes gets the bytes for Msg signer to sign on
func (MsgDeleteClaim) GetSigners ¶
func (msg MsgDeleteClaim) GetSigners() []sdk.AccAddress
GetSigners gets the signs of the Msg
func (MsgDeleteClaim) Route ¶
func (msg MsgDeleteClaim) Route() string
Route is the name of the route for claim
func (MsgDeleteClaim) ValidateBasic ¶
func (msg MsgDeleteClaim) ValidateBasic() sdk.Error
ValidateBasic validates basic fields of the Msg
type MsgEditClaim ¶
type MsgEditClaim struct { ID uint64 `json:"id"` Body string `json:"body"` Editor sdk.AccAddress `json:"editor"` }
MsgEditClaim defines a message to submit a story
func NewMsgEditClaim ¶
func NewMsgEditClaim(id uint64, body string, editor sdk.AccAddress) MsgEditClaim
NewMsgEditClaim creates a new message to edit a claim
func (MsgEditClaim) GetSignBytes ¶
func (msg MsgEditClaim) GetSignBytes() []byte
GetSignBytes gets the bytes for Msg signer to sign on
func (MsgEditClaim) GetSigners ¶
func (msg MsgEditClaim) GetSigners() []sdk.AccAddress
GetSigners gets the signs of the Msg
func (MsgEditClaim) Route ¶
func (msg MsgEditClaim) Route() string
Route is the name of the route for claim
func (MsgEditClaim) ValidateBasic ¶
func (msg MsgEditClaim) ValidateBasic() sdk.Error
ValidateBasic validates basic fields of the 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 { MinClaimLength int `json:"min_claim_length"` MaxClaimLength int `json:"max_claim_length"` ClaimAdmins []sdk.AccAddress `json:"claim_admins"` }
Params holds parameters for a Claim
func (*Params) ParamSetPairs ¶
func (p *Params) ParamSetPairs() params.ParamSetPairs
ParamSetPairs implements params.ParamSet
type QueryClaimParams ¶
type QueryClaimParams struct {
ID uint64 `json:"id"`
}
QueryClaimParams for a single claim
type QueryClaimsIDRangeParams ¶
type QueryClaimsIDRangeParams struct { StartID uint64 `json:"start_id"` EndID uint64 `json:"end_id"` }
QueryClaimsIDRangeParams for claims by an id range
type QueryClaimsParams ¶
type QueryClaimsParams struct {
IDs []uint64 `json:"ids"`
}
QueryClaimsParams for many claim
type QueryClaimsTimeParams ¶
QueryClaimsTimeParams for claims by time
type QueryCommunitiesClaimsParams ¶
type QueryCommunitiesClaimsParams struct {
CommunityIDs []string `json:"community_ids"`
}
QueryCommunitiesClaimsParams for communities claims
type QueryCommunityClaimsParams ¶
type QueryCommunityClaimsParams struct {
CommunityID string `json:"community_id"`
}
QueryCommunityClaimsParams for community claims
type QueryCreatorClaimsParams ¶
type QueryCreatorClaimsParams struct {
Creator sdk.AccAddress `json:"creator"`
}
QueryCreatorClaimsParams for community claims