keeper

package
v0.0.0-...-a6871c7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 26, 2024 License: Apache-2.0 Imports: 20 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewMsgServerImpl

func NewMsgServerImpl(ak AccountKeeper) types.MsgServer

NewMsgServerImpl returns an implementation of the x/auth MsgServer interface.

func NewQueryServer

func NewQueryServer(k AccountKeeper) types.QueryServer

Types

type AccountKeeper

type AccountKeeper struct {
	appmodule.Environment

	AccountsModKeeper types.AccountsModKeeper

	// State
	Schema        collections.Schema
	Params        collections.Item[types.Params]
	AccountNumber collections.Sequence
	// Accounts key: AccAddr | value: AccountI | index: AccountsIndex
	Accounts *collections.IndexedMap[sdk.AccAddress, sdk.AccountI, AccountsIndexes]
	// contains filtered or unexported fields
}

AccountKeeper encodes/decodes accounts using the go-amino (binary) encoding/decoding library.

func NewAccountKeeper

func NewAccountKeeper(
	env appmodule.Environment, cdc codec.BinaryCodec, proto func() sdk.AccountI, accountsModKeeper types.AccountsModKeeper,
	maccPerms map[string][]string, ac address.Codec, bech32Prefix, authority string,
) AccountKeeper

NewAccountKeeper returns a new AccountKeeperI that uses go-amino to (binary) encode and decode concrete sdk.Accounts. `maccPerms` is a map that takes accounts' addresses as keys, and their respective permissions as values. This map is used to construct types.PermissionsForAddress and is used in keeper.ValidatePermissions. Permissions are plain strings, and don't have to fit into any predefined structure. This auth module does not use account permissions internally, though other modules may use auth.Keeper to access the accounts permissions map.

func (AccountKeeper) AddressCodec

func (ak AccountKeeper) AddressCodec() address.Codec

AddressCodec returns the x/auth account address codec. x/auth is tied to bech32 encoded user accounts

func (AccountKeeper) ExportGenesis

func (ak AccountKeeper) ExportGenesis(ctx context.Context) (*types.GenesisState, error)

ExportGenesis returns a GenesisState for a given context and keeper

func (AccountKeeper) GetAccount

func (ak AccountKeeper) GetAccount(ctx context.Context, addr sdk.AccAddress) sdk.AccountI

GetAccount implements AccountKeeperI.

func (AccountKeeper) GetAuthority

func (ak AccountKeeper) GetAuthority() string

GetAuthority returns the x/auth module's authority.

func (AccountKeeper) GetEnvironment

func (ak AccountKeeper) GetEnvironment() appmodule.Environment

func (AccountKeeper) GetModuleAccount

func (ak AccountKeeper) GetModuleAccount(ctx context.Context, moduleName string) sdk.ModuleAccountI

GetModuleAccount gets the module account from the auth account store, if the account does not exist in the AccountKeeper, then it is created.

func (AccountKeeper) GetModuleAccountAndPermissions

func (ak AccountKeeper) GetModuleAccountAndPermissions(ctx context.Context, moduleName string) (sdk.ModuleAccountI, []string)

GetModuleAccountAndPermissions gets the module account from the auth account store and its registered permissions

func (AccountKeeper) GetModuleAddress

func (ak AccountKeeper) GetModuleAddress(moduleName string) sdk.AccAddress

GetModuleAddress returns an address based on the module name

func (AccountKeeper) GetModuleAddressAndPermissions

func (ak AccountKeeper) GetModuleAddressAndPermissions(moduleName string) (addr sdk.AccAddress, permissions []string)

GetModuleAddressAndPermissions returns an address and permissions based on the module name

func (AccountKeeper) GetModulePermissions

func (ak AccountKeeper) GetModulePermissions() map[string]types.PermissionsForAddress

GetModulePermissions fetches per-module account permissions.

func (AccountKeeper) GetParams

func (ak AccountKeeper) GetParams(ctx context.Context) (params types.Params)

GetParams gets the auth module's parameters.

func (AccountKeeper) GetPubKey

func (ak AccountKeeper) GetPubKey(ctx context.Context, addr sdk.AccAddress) (cryptotypes.PubKey, error)

GetPubKey Returns the PubKey of the account at address

func (AccountKeeper) GetSequence

func (ak AccountKeeper) GetSequence(ctx context.Context, addr sdk.AccAddress) (uint64, error)

GetSequence Returns the Sequence of the account at address

func (AccountKeeper) HasAccount

func (ak AccountKeeper) HasAccount(ctx context.Context, addr sdk.AccAddress) bool

HasAccount implements AccountKeeperI.

func (AccountKeeper) InitGenesis

func (ak AccountKeeper) InitGenesis(ctx context.Context, data types.GenesisState) error

InitGenesis - Init store state from genesis data

CONTRACT: old coins from the FeeCollectionKeeper need to be transferred through a genesis port script to the new fee collector account

func (AccountKeeper) NewAccount

func (ak AccountKeeper) NewAccount(ctx context.Context, acc sdk.AccountI) sdk.AccountI

NewAccount sets the next account number to a given account interface

func (AccountKeeper) NewAccountWithAddress

func (ak AccountKeeper) NewAccountWithAddress(ctx context.Context, addr sdk.AccAddress) sdk.AccountI

NewAccountWithAddress implements AccountKeeperI.

func (AccountKeeper) NextAccountNumber

func (ak AccountKeeper) NextAccountNumber(ctx context.Context) uint64

NextAccountNumber returns and increments the global account number counter. If the global account number is not set, it initializes it with value 0.

func (AccountKeeper) NonAtomicMsgsExec

func (ak AccountKeeper) NonAtomicMsgsExec(ctx context.Context, signer sdk.AccAddress, msgs []sdk.Msg) ([]*types.NonAtomicExecResult, error)

func (AccountKeeper) RemoveAccount

func (ak AccountKeeper) RemoveAccount(ctx context.Context, acc sdk.AccountI)

RemoveAccount removes an account for the account mapper store. NOTE: this will cause supply invariant violation if called

func (AccountKeeper) SetAccount

func (ak AccountKeeper) SetAccount(ctx context.Context, acc sdk.AccountI)

SetAccount implements AccountKeeperI.

func (AccountKeeper) SetModuleAccount

func (ak AccountKeeper) SetModuleAccount(ctx context.Context, macc sdk.ModuleAccountI)

SetModuleAccount sets the module account to the auth account store

func (AccountKeeper) ValidatePermissions

func (ak AccountKeeper) ValidatePermissions(macc sdk.ModuleAccountI) error

ValidatePermissions validates that the module account has been granted permissions within its set of allowed permissions.

type AccountKeeperI

type AccountKeeperI interface {
	// Return a new account with the next account number and the specified address. Does not save the new account to the store.
	NewAccountWithAddress(context.Context, sdk.AccAddress) sdk.AccountI

	// Return a new account with the next account number. Does not save the new account to the store.
	NewAccount(context.Context, sdk.AccountI) sdk.AccountI

	// Check if an account exists in the store.
	HasAccount(context.Context, sdk.AccAddress) bool

	// Retrieve an account from the store.
	GetAccount(context.Context, sdk.AccAddress) sdk.AccountI

	// Set an account in the store.
	SetAccount(context.Context, sdk.AccountI)

	// Remove an account from the store.
	RemoveAccount(context.Context, sdk.AccountI)

	// Fetch the public key of an account at a specified address
	GetPubKey(context.Context, sdk.AccAddress) (cryptotypes.PubKey, error)

	// Fetch the sequence of an account at a specified address.
	GetSequence(context.Context, sdk.AccAddress) (uint64, error)

	// Fetch the next account number, and increment the internal counter.
	NextAccountNumber(context.Context) uint64

	// GetModulePermissions fetches per-module account permissions
	GetModulePermissions() map[string]types.PermissionsForAddress

	// AddressCodec returns the account address codec.
	AddressCodec() address.Codec
}

AccountKeeperI is the interface contract that x/auth's keeper implements.

type AccountsIndexes

type AccountsIndexes struct {
	// Number is a unique index that indexes accounts by their account number.
	Number *indexes.Unique[uint64, sdk.AccAddress, sdk.AccountI]
}

func NewAccountIndexes

func NewAccountIndexes(sb *collections.SchemaBuilder) AccountsIndexes

func (AccountsIndexes) IndexesList

type Migrator

type Migrator struct {
	// contains filtered or unexported fields
}

Migrator is a struct for handling in-place store migrations.

func NewMigrator

func NewMigrator(keeper AccountKeeper) Migrator

NewMigrator returns a new Migrator.

func (Migrator) Migrate1to2

func (m Migrator) Migrate1to2(ctx context.Context) error

Migrate1to2 migrates from version 1 to 2.

func (Migrator) Migrate2to3

func (m Migrator) Migrate2to3(ctx context.Context) error

Migrate2to3 migrates from consensus version 2 to version 3. Specifically, for each account we index the account's ID to their address.

func (Migrator) Migrate3to4

func (m Migrator) Migrate3to4(ctx context.Context) error

Migrate3to4 migrates the x/auth module state from the consensus version 3 to version 4. Specifically, it takes the parameters that are currently stored and managed by the x/params modules and stores them directly into the x/auth module state.

func (Migrator) Migrate4To5

func (m Migrator) Migrate4To5(ctx context.Context) error

Migrate4To5 migrates the x/auth module state from the consensus version 4 to 5. It migrates the GlobalAccountNumber from being a protobuf defined value to a big-endian encoded uint64, it also migrates it to use a more canonical prefix.

func (Migrator) V45SetAccount

func (m Migrator) V45SetAccount(ctx context.Context, acc sdk.AccountI) error

V45_SetAccount implements V45_SetAccount set the account without map to accAddr to accNumber.

NOTE: This is used for testing purposes only.

Jump to

Keyboard shortcuts

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