claim

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: 22 Imported by: 1

Documentation

Index

Constants

View Source
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"
)
View Source
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

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

Defines module constants

View Source
const ModuleName = "claim"

ModuleName is the name of this module

Variables

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

View Source
var (
	KeyMinClaimLength = []byte("minClaimLength")
	KeyMaxClaimLength = []byte("maxClaimLength")
	KeyClaimAdmins    = []byte("claimAdmins")
)

Keys for params

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 ErrCreatorJailed

func ErrCreatorJailed(addr sdk.AccAddress) sdk.Error

ErrCreatorJailed throws an error on jailed creator

func ErrInvalidBodyTooLong

func ErrInvalidBodyTooLong() sdk.Error

ErrInvalidBodyTooLong throws an error on invalid claim body

func ErrInvalidBodyTooShort

func ErrInvalidBodyTooShort(body string) sdk.Error

ErrInvalidBodyTooShort throws an error on invalid claim body

func ErrInvalidCommunityID

func ErrInvalidCommunityID(id string) sdk.Error

ErrInvalidCommunityID throws an error on invalid community id

func ErrInvalidSourceURL

func ErrInvalidSourceURL(url string) sdk.Error

ErrInvalidSourceURL throws an error when a URL in invalid

func ErrJSONParse

func ErrJSONParse(err error) sdk.Error

ErrJSONParse throws an error on failed JSON parsing

func ErrUnknownClaim

func ErrUnknownClaim(id uint64) sdk.Error

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 NewHandler

func NewHandler(keeper Keeper) sdk.Handler

NewHandler creates a new handler

func NewQuerier

func NewQuerier(keeper Keeper) sdk.Querier

NewQuerier returns a function that handles queries on the KVStore

func ParamKeyTable

func ParamKeyTable() params.KeyTable

ParamKeyTable for claim module

func RegisterCodec

func RegisterCodec(c *codec.Codec)

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

type AccountKeeper interface {
	IsJailed(ctx sdk.Context, addr sdk.AccAddress) (bool, sdk.Error)
}

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

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 supply module.

func (AppModuleBasic) GetTxCmd

func (AppModuleBasic) GetTxCmd(_ *codec.Codec) *cobra.Command

GetTxCmd returns the root tx command for the supply 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 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

func NewClaim

func NewClaim(id uint64, communityID string, body string, creator sdk.AccAddress, source url.URL, createdTime time.Time) Claim

NewClaim creates a new claim object

func (Claim) String

func (c Claim) String() string

type Claims

type Claims []Claim

Claims is an array of claims

type CodeType

type CodeType = sdk.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

type GenesisState struct {
	Claims []Claim `json:"claims"`
	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, 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) AddAdmin

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

AddAdmin adds a new admin

func (Keeper) AddBackingStake

func (k Keeper) AddBackingStake(ctx sdk.Context, id uint64, stake sdk.Coin) sdk.Error

AddBackingStake adds a stake amount to the total backing amount

func (Keeper) AddChallengeStake

func (k Keeper) AddChallengeStake(ctx sdk.Context, id uint64, stake sdk.Coin) sdk.Error

AddChallengeStake adds a stake amount to the total challenge amount

func (Keeper) Claim

func (k Keeper) Claim(ctx sdk.Context, id uint64) (claim Claim, ok bool)

Claim gets a single claim by its ID

func (Keeper) Claims

func (k Keeper) Claims(ctx sdk.Context) (claims Claims)

Claims gets all the claims in reverse order

func (Keeper) ClaimsAfterTime

func (k Keeper) ClaimsAfterTime(ctx sdk.Context, createdTime time.Time) (claims Claims)

ClaimsAfterTime gets all claims after a certain CreatedTime

func (Keeper) ClaimsBeforeTime

func (k Keeper) ClaimsBeforeTime(ctx sdk.Context, createdTime time.Time) (claims Claims)

ClaimsBeforeTime gets all claims after a certain CreatedTime

func (Keeper) ClaimsBetweenIDs

func (k Keeper) ClaimsBetweenIDs(ctx sdk.Context, startClaimID, endClaimID uint64) (claims Claims)

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

func (k Keeper) CommunityClaims(ctx sdk.Context, communityID string) (claims Claims)

CommunityClaims gets all the claims for a given community

func (Keeper) CreatorClaims

func (k Keeper) CreatorClaims(ctx sdk.Context, creator sdk.AccAddress) (claims Claims)

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

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

GetParams gets the genesis params for the claim

func (Keeper) RemoveAdmin

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

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

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

SetParams sets the params for the 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

func (k Keeper) SubtractBackingStake(ctx sdk.Context, id uint64, stake sdk.Coin) sdk.Error

SubtractBackingStake adds a stake amount to the total backing amount

func (Keeper) SubtractChallengeStake

func (k Keeper) SubtractChallengeStake(ctx sdk.Context, id uint64, stake sdk.Coin) sdk.Error

SubtractChallengeStake adds a stake amount to the total challenge amount

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

func (msg MsgCreateClaim) Type() string

Type is the name for the Msg

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

func (msg MsgDeleteClaim) Type() string

Type is the name for the Msg

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

func (msg MsgEditClaim) Type() string

Type is the name for the Msg

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) 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 {
	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 DefaultParams

func DefaultParams() Params

DefaultParams is the Claim params for testing

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

type QueryClaimsTimeParams struct {
	CreatedTime time.Time `json:"created_time"`
}

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

Jump to

Keyboard shortcuts

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