Documentation ¶
Index ¶
- Constants
- Variables
- func EndBlocker(ctx sdk.Context, keeper Keeper)
- func ErrAppAccountCreateFailed(address sdk.AccAddress) sdk.Error
- func ErrAppAccountNotFound(address sdk.AccAddress) sdk.Error
- func InitGenesis(ctx sdk.Context, keeper Keeper, data GenesisState)
- func NewHandler(keeper Keeper) sdk.Handler
- func NewQuerier(keeper Keeper) sdk.Querier
- func ParamKeyTable() params.KeyTable
- func RegisterCodec(cdc *codec.Codec)
- func ValidateGenesis(data GenesisState) error
- type AppAccount
- type AppAccounts
- type AppModule
- func (am AppModule) BeginBlock(_ sdk.Context, _ abci.RequestBeginBlock)
- func (am AppModule) EndBlock(ctx 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 BankKeeper
- type GenesisState
- type Keeper
- func (k Keeper) AppAccounts(ctx sdk.Context) (appAccounts []AppAccount)
- func (k Keeper) CreateAppAccount(ctx sdk.Context, address sdk.AccAddress, coins sdk.Coins, pubKey crypto.PubKey) (appAccnt AppAccount, sdkErr sdk.Error)
- func (k Keeper) GetParams(ctx sdk.Context) Params
- func (k Keeper) IncrementSlashCount(ctx sdk.Context, address sdk.AccAddress) (jailed bool, err sdk.Error)
- func (k Keeper) IsJailed(ctx sdk.Context, address sdk.AccAddress) (bool, sdk.Error)
- func (k Keeper) IterateAppAccounts(ctx sdk.Context, cb func(acc AppAccount) (stop bool))
- func (k Keeper) JailUntil(ctx sdk.Context, address sdk.AccAddress, until time.Time) sdk.Error
- func (k Keeper) JailedAccountsBefore(ctx sdk.Context, jailEndTime time.Time) (accounts AppAccounts, err sdk.Error)
- func (k Keeper) Logger(ctx sdk.Context) log.Logger
- func (k Keeper) PrimaryAccount(ctx sdk.Context, addr sdk.AccAddress) (pAcc PrimaryAccount, err sdk.Error)
- func (k Keeper) SetParams(ctx sdk.Context, params Params)
- func (k Keeper) UnJail(ctx sdk.Context, address sdk.AccAddress) sdk.Error
- func (k Keeper) UpdateParams(ctx sdk.Context, updates Params, updatedFields []string) sdk.Error
- type MsgRegisterKey
- type MsgUpdateParams
- type Params
- type PrimaryAccount
- type QueryAppAccountParams
- type QueryAppAccountsParams
- type QueryPrimaryAccountParams
- type QueryPrimaryAccountsParams
Constants ¶
const ( TransactionGift = exported.TransactionGift TransactionBacking = exported.TransactionBacking UserGrowthPoolName = distribution.UserGrowthPoolName )
const ( DefaultCodespace sdk.CodespaceType = ModuleName ErrorCodeAppAccountNotFound sdk.CodeType = 201 ErrorCodeAppAccountCreateFailed sdk.CodeType = 202 )
Auth errors reserve 200 ~ 299.
const ( // TypeMsgRegisterKey represents the type of the message for registering the key TypeMsgRegisterKey = "register_key" // TypeMsgUpdateParams represents the type of TypeMsgUpdateParams = "update_params" )
const ( QueryAppAccount = "account" QueryAppAccounts = "accounts" QueryPrimaryAccount = "primary_account" QueryPrimaryAccounts = "primary_accounts" QueryParams = "params" )
query endpoints supported by the truchain Querier
const ( StoreKey = ModuleName RouterKey = ModuleName QuerierRoute = ModuleName DefaultParamspace = ModuleName EventTypeUnjailedAccount = "unjailed_account" AttributeKeyUser = "user" )
Defines auth module constants
const ModuleName = "account"
ModuleName is the name of this module
Variables ¶
var ( AppAccountKeyPrefix = []byte{0x00} JailEndTimeAccountPrefix = []byte{0x10} )
Keys for account store Items are stored with the following key: values
- 0x00<AccAddress>: AppAccount
- 0x10<jailEndTime_Bytes><AccAddress>: AccAddress
var ( KeyRegistrar = []byte("registrar") KeyMaxSlashCount = []byte("maxSlashCount") KeyJailDuration = []byte("jailTime") KeyUserGrowthAllocation = []byte("userGrowthAllocation") KeyStakeholderAllocation = []byte("stakeholderAllocation") )
Keys for params
var (
FromModuleAccount = exported.FromModuleAccount
)
var ModuleCodec *codec.Codec
ModuleCodec encodes module codec
Functions ¶
func EndBlocker ¶
EndBlocker called every block, process expiring stakes
func ErrAppAccountCreateFailed ¶
func ErrAppAccountCreateFailed(address sdk.AccAddress) sdk.Error
ErrAppAccountCreateFailed throws an error when creating an account fails
func ErrAppAccountNotFound ¶
func ErrAppAccountNotFound(address sdk.AccAddress) sdk.Error
ErrAppAccountNotFound throws an error when the searched AppAccount is not found
func InitGenesis ¶
func InitGenesis(ctx sdk.Context, keeper Keeper, data GenesisState)
InitGenesis initializes account state from genesis file
func NewHandler ¶
NewHandler creates a new handler for auth module
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 AppAccount ¶
type AppAccount struct { Addresses []sdk.AccAddress `json:"addresses"` SlashCount int `json:"slash_count"` IsJailed bool `json:"is_jailed"` JailEndTime time.Time `json:"jail_end_time"` CreatedTime time.Time `json:"created_time"` }
AppAccount is the main account for a TruStory user.
func NewAppAccount ¶
func NewAppAccount(address sdk.AccAddress, createdTime time.Time) AppAccount
func (AppAccount) PrimaryAddress ¶
func (acc AppAccount) PrimaryAddress() sdk.AccAddress
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 (am AppModule) EndBlock(ctx 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 the auth module
func (AppModule) NewHandler ¶
NewHandler creates the handler for the auth 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 BankKeeper ¶
type BankKeeper interface { AddCoin(ctx sdk.Context, addr sdk.AccAddress, amt sdk.Coin, referenceID uint64, txType bankexported.TransactionType, setters ...bankexported.TransactionSetter) (sdk.Coins, sdk.Error) IterateUserTransactions(ctx sdk.Context, creator sdk.AccAddress, reverse bool, cb func(transaction bankexported.Transaction) (stop bool)) }
BankKeeper is the expected bank keeper interface for this module
type GenesisState ¶
type GenesisState struct { AppAccounts []AppAccount `json:"app_accounts"` 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() 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, bankKeeper BankKeeper, accountKeeper auth.AccountKeeper, supplyKeeper supply.Keeper) Keeper
NewKeeper creates a new keeper of the auth Keeper
func (Keeper) AppAccounts ¶
func (k Keeper) AppAccounts(ctx sdk.Context) (appAccounts []AppAccount)
AppAccounts returns all app accounts
func (Keeper) CreateAppAccount ¶
func (k Keeper) CreateAppAccount(ctx sdk.Context, address sdk.AccAddress, coins sdk.Coins, pubKey crypto.PubKey) (appAccnt AppAccount, sdkErr sdk.Error)
CreateAppAccount creates a new account on chain for a user
func (Keeper) IncrementSlashCount ¶
func (k Keeper) IncrementSlashCount(ctx sdk.Context, address sdk.AccAddress) (jailed bool, err sdk.Error)
IncrementSlashCount increments the slash count of the user
func (Keeper) IterateAppAccounts ¶
func (k Keeper) IterateAppAccounts(ctx sdk.Context, cb func(acc AppAccount) (stop bool))
IterateAppAccounts iterates over all the stored app accounts and performs a callback function
func (Keeper) JailedAccountsBefore ¶
func (k Keeper) JailedAccountsBefore(ctx sdk.Context, jailEndTime time.Time) (accounts AppAccounts, err sdk.Error)
JailedAccountsBefore returns all jailed accounts before jailEndTime
func (Keeper) PrimaryAccount ¶
func (k Keeper) PrimaryAccount(ctx sdk.Context, addr sdk.AccAddress) (pAcc PrimaryAccount, err sdk.Error)
PrimaryAccount gets the primary base account
type MsgRegisterKey ¶
type MsgRegisterKey struct { Registrar sdk.AccAddress `json:"registrar"` Address sdk.AccAddress `json:"address"` PubKey crypto.PubKey `json:"public_key"` PubKeyAlgo string `json:"public_key_algo"` Coins sdk.Coins `json:"coins"` }
MsgRegisterKey defines the message to register a new key
func NewMsgRegisterKey ¶
func NewMsgRegisterKey(registrar, address sdk.AccAddress, publicKey crypto.PubKey, publicKeyAlgo string, coins sdk.Coins) MsgRegisterKey
NewMsgRegisterKey returns the messages to register a new key
func (MsgRegisterKey) GetSignBytes ¶
func (msg MsgRegisterKey) GetSignBytes() []byte
GetSignBytes implements Msg
func (MsgRegisterKey) GetSigners ¶
func (msg MsgRegisterKey) GetSigners() []sdk.AccAddress
GetSigners implements Msg. Returns the registrar as the signer.
func (MsgRegisterKey) ValidateBasic ¶
func (msg MsgRegisterKey) 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 { Registrar sdk.AccAddress `json:"registrar"` MaxSlashCount int `json:"max_slash_count"` JailDuration time.Duration `json:"jail_duration"` UserGrowthAllocation sdk.Dec `json:"user_growth_allocation"` StakeholderAllocation sdk.Dec `json:"stakeholder_allocation"` }
Params holds parameters for Auth
func (*Params) ParamSetPairs ¶
func (p *Params) ParamSetPairs() params.ParamSetPairs
ParamSetPairs implements params.ParamSet
type PrimaryAccount ¶
type QueryAppAccountParams ¶
type QueryAppAccountParams struct {
Address sdk.AccAddress `json:"address"`
}
QueryAppAccountParams are params for querying app accounts by address queries
type QueryAppAccountsParams ¶
type QueryAppAccountsParams struct {
Addresses []sdk.AccAddress `json:"addresses"`
}
QueryAppAccountsParams are params for querying app accounts by address queries
type QueryPrimaryAccountParams ¶
type QueryPrimaryAccountParams struct {
Address sdk.AccAddress `json:"address"`
}
QueryPrimaryAccountParams are params for querying app accounts by address queries
type QueryPrimaryAccountsParams ¶
type QueryPrimaryAccountsParams struct {
Addresses []sdk.AccAddress `json:"addresses"`
}
QueryPrimaryAccountParams are params for querying app accounts by address queries