account

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: 20 Imported by: 3

Documentation

Index

Constants

View Source
const (
	TransactionGift    = exported.TransactionGift
	TransactionBacking = exported.TransactionBacking

	UserGrowthPoolName = distribution.UserGrowthPoolName
)
View Source
const (
	DefaultCodespace sdk.CodespaceType = ModuleName

	ErrorCodeAppAccountNotFound     sdk.CodeType = 201
	ErrorCodeAppAccountCreateFailed sdk.CodeType = 202
)

Auth errors reserve 200 ~ 299.

View Source
const (
	// TypeMsgRegisterKey represents the type of the message for registering the key
	TypeMsgRegisterKey = "register_key"
	// TypeMsgUpdateParams represents the type of
	TypeMsgUpdateParams = "update_params"
)
View Source
const (
	QueryAppAccount      = "account"
	QueryAppAccounts     = "accounts"
	QueryPrimaryAccount  = "primary_account"
	QueryPrimaryAccounts = "primary_accounts"
	QueryParams          = "params"
)

query endpoints supported by the truchain Querier

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

	EventTypeUnjailedAccount = "unjailed_account"
	AttributeKeyUser         = "user"
)

Defines auth module constants

View Source
const ModuleName = "account"

ModuleName is the name of this module

Variables

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

View Source
var (
	KeyRegistrar             = []byte("registrar")
	KeyMaxSlashCount         = []byte("maxSlashCount")
	KeyJailDuration          = []byte("jailTime")
	KeyUserGrowthAllocation  = []byte("userGrowthAllocation")
	KeyStakeholderAllocation = []byte("stakeholderAllocation")
)

Keys for params

View Source
var (
	FromModuleAccount = exported.FromModuleAccount
)
View Source
var ModuleCodec *codec.Codec

ModuleCodec encodes module codec

Functions

func EndBlocker

func EndBlocker(ctx sdk.Context, keeper Keeper)

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

func NewHandler(keeper Keeper) sdk.Handler

NewHandler creates a new handler for auth module

func NewQuerier

func NewQuerier(keeper Keeper) sdk.Querier

NewQuerier creates a new querier

func ParamKeyTable

func ParamKeyTable() params.KeyTable

ParamKeyTable for auth module

func RegisterCodec

func RegisterCodec(cdc *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 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

func (AppAccount) String

func (acc AppAccount) String() string

String implements fmt.Stringer

type AppAccounts

type AppAccounts []AppAccount

AppAccounts is a slice of AppAccounts

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 the auth module

func (AppModule) NewHandler

func (am AppModule) NewHandler() sdk.Handler

NewHandler creates the handler for the auth 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 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) GetParams

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

GetParams gets the genesis params for the auth

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

func (k Keeper) IsJailed(ctx sdk.Context, address sdk.AccAddress) (bool, sdk.Error)

IsJailed tells whether an AppAccount is jailed by its address

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

func (k Keeper) JailUntil(ctx sdk.Context, address sdk.AccAddress, until time.Time) sdk.Error

JailUntil puts an AppAccount in jail until a time

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

func (k Keeper) Logger(ctx sdk.Context) log.Logger

func (Keeper) PrimaryAccount

func (k Keeper) PrimaryAccount(ctx sdk.Context, addr sdk.AccAddress) (pAcc PrimaryAccount, err sdk.Error)

PrimaryAccount gets the primary base account

func (Keeper) SetParams

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

SetParams sets the params for the auth

func (Keeper) UnJail

func (k Keeper) UnJail(ctx sdk.Context, address sdk.AccAddress) sdk.Error

UnJail unjails an AppAccount.

func (Keeper) UpdateParams

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

UpdateParams updates the required params

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

func (msg MsgRegisterKey) Route() string

Route implements Msg

func (MsgRegisterKey) Type

func (msg MsgRegisterKey) Type() string

Type implements Msg

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

func DefaultParams() Params

DefaultParams is the auth params for testing

func (*Params) ParamSetPairs

func (p *Params) ParamSetPairs() params.ParamSetPairs

ParamSetPairs implements params.ParamSet

type PrimaryAccount

type PrimaryAccount struct {
	auth.BaseAccount

	SlashCount  int       `json:"slash_count"`
	IsJailed    bool      `json:"is_jailed"`
	JailEndTime time.Time `json:"jail_end_time"`
	CreatedTime time.Time `json:"created_time"`
}

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

Jump to

Keyboard shortcuts

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