Back to

Package genaccounts

Latest Go to latest

The highest tagged major version is .

Published: Aug 13, 2020 | License: Apache-2.0 | Module:


Package genaccounts contains specialized functionality for initializing accounts from genesis including:

- genesis account validation,
- initchain processing of genesis accounts,
- export processing (to genesis) of accounts,
- server command for adding accounts to the genesis file.



const ModuleName = "accounts"

ModuleName accounts module name

func InitGenesis

func InitGenesis(ctx sdk.Context, _ *codec.Codec, accountKeeper AccountKeeper, genesisState GenesisState)

InitGenesis initializes accounts and deliver genesis transactions

func NewAppModule

func NewAppModule(accountKeeper AccountKeeper) module.AppModule

NewAppModule creates a new AppModule object

func SetGenesisStateInAppState

func SetGenesisStateInAppState(cdc *codec.Codec,
	appState map[string]json.RawMessage, genesisState GenesisState) map[string]json.RawMessage

SetGenesisStateInAppState sets the genesis state within the expected app state

func ValidateGenesis

func ValidateGenesis(genesisState GenesisState) error

ValidateGenesis performs validation of genesis accounts. It ensures that there are no duplicate accounts in the genesis state and any provided vesting accounts are valid.

type AccountKeeper

type AccountKeeper interface {
	NewAccount(sdk.Context, exported.Account) exported.Account
	SetAccount(sdk.Context, exported.Account)
	IterateAccounts(ctx sdk.Context, process func(exported.Account) (stop bool))

AccountKeeper defines expected account keeper

type AppModule

type AppModule struct {
	// contains filtered or unexported fields

AppModule implements an application module for the genaccounts module.

func (AppModule) ExportGenesis

func (am AppModule) ExportGenesis(ctx sdk.Context) json.RawMessage

ExportGenesis returns the exported genesis state as raw bytes for the genaccounts module.

func (AppModule) InitGenesis

func (am AppModule) InitGenesis(ctx sdk.Context, data json.RawMessage) []abci.ValidatorUpdate

InitGenesis performs genesis initialization for the genaccounts module.

type AppModuleBasic

type AppModuleBasic struct{}

AppModuleBasic defines the basic application module used by the genaccounts module.

func (AppModuleBasic) DefaultGenesis

func (AppModuleBasic) DefaultGenesis() json.RawMessage

DefaultGenesis returns default genesis state as raw bytes for the genaccounts module.

func (AppModuleBasic) GetQueryCmd

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

GetQueryCmd returns the root query command for the genaccounts module.

func (AppModuleBasic) GetTxCmd

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

GetTxCmd returns the root tx command for the genaccounts module.

func (AppModuleBasic) IterateGenesisAccounts

func (AppModuleBasic) IterateGenesisAccounts(cdc *codec.Codec, appGenesis map[string]json.RawMessage,
	iterateFn func(auth.Account) (stop bool))

IterateGenesisAccounts is extra function from sdk.AppModuleBasic iterate the genesis accounts and perform an operation at each of them - to used by other modules

func (AppModuleBasic) Name

func (AppModuleBasic) Name() string

Name returns the genaccounts module's name

func (AppModuleBasic) RegisterCodec

func (AppModuleBasic) RegisterCodec(cdc *codec.Codec)

RegisterCodec registers the genaccounts module's types for the given codec.

func (AppModuleBasic) RegisterRESTRoutes

func (AppModuleBasic) RegisterRESTRoutes(_ context.CLIContext, _ *mux.Router)

RegisterRESTRoutes registers the REST routes for the genaccounts module.

func (AppModuleBasic) ValidateGenesis

func (AppModuleBasic) ValidateGenesis(bz json.RawMessage) error

ValidateGenesis performs genesis state validation for the genaccounts module.

type GenesisAccount

type GenesisAccount struct {
	Address       sdk.AccAddress `json:"address" yaml:"address"`
	Coins         sdk.Coins      `json:"coins" yaml:"coins"`
	Sequence      uint64         `json:"sequence_number" yaml:"sequence_number"`
	AccountNumber uint64         `json:"account_number" yaml:"account_number"`

	// vesting account fields
	OriginalVesting  sdk.Coins `json:"original_vesting" yaml:"original_vesting"`   // total vesting coins upon initialization
	DelegatedFree    sdk.Coins `json:"delegated_free" yaml:"delegated_free"`       // delegated vested coins at time of delegation
	DelegatedVesting sdk.Coins `json:"delegated_vesting" yaml:"delegated_vesting"` // delegated vesting coins at time of delegation
	StartTime        int64     `json:"start_time" yaml:"start_time"`               // vesting start time (UNIX Epoch time)
	EndTime          int64     `json:"end_time" yaml:"end_time"`                   // vesting end time (UNIX Epoch time)

	// for lazy vesting account
	VestingSchedules []auth.VestingSchedule `json:"vesting_schedules" yaml:"vesting_schedules"` // lazy vesting schedules

	// module account fields
	ModuleName        string   `json:"module_name" yaml:"module_name"`               // name of the module account
	ModulePermissions []string `json:"module_permissions" yaml:"module_permissions"` // permissions of module account

GenesisAccount is a struct for account initialization used exclusively during genesis

func NewGenesisAccount

func NewGenesisAccount(acc *auth.BaseAccount) GenesisAccount

NewGenesisAccount creates a GenesisAccount instance from a BaseAccount.

func NewGenesisAccountI

func NewGenesisAccountI(acc auth.Account) (GenesisAccount, error)

NewGenesisAccountI creates a GenesisAccount instance from an Account interface.

func NewGenesisAccountRaw

func NewGenesisAccountRaw(address sdk.AccAddress, coins,
	vestingAmount sdk.Coins, vestingStartTime, vestingEndTime int64,
	lazyVestingSchedules []auth.VestingSchedule, module string, permissions ...string) GenesisAccount

NewGenesisAccountRaw creates a new GenesisAccount object

func (*GenesisAccount) ToAccount

func (ga *GenesisAccount) ToAccount() auth.Account

ToAccount converts a GenesisAccount to an Account interface

func (GenesisAccount) Validate

func (ga GenesisAccount) Validate() error

Validate checks for errors on the vesting and module account parameters

type GenesisAccounts

type GenesisAccounts []GenesisAccount

GenesisAccounts is genesis account array

func (GenesisAccounts) Contains

func (gaccs GenesisAccounts) Contains(acc sdk.AccAddress) bool

Contains check whether genesis accounts contain an address

type GenesisState

type GenesisState GenesisAccounts

State to Unmarshal

func ExportGenesis

func ExportGenesis(ctx sdk.Context, accountKeeper AccountKeeper) GenesisState

ExportGenesis exports genesis for all accounts

func GetGenesisStateFromAppState

func GetGenesisStateFromAppState(cdc *codec.Codec, appState map[string]json.RawMessage) GenesisState

GetGenesisStateFromAppState returns the genesis state from the expected app state

func (GenesisState) Sanitize

func (gs GenesisState) Sanitize()

Sanitize sorts accounts and coin sets.

Package Files

Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to identifier