keeper

package
v0.50.10 Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2024 License: Apache-2.0 Imports: 26 Imported by: 2,779

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewMsgServerImpl added in v0.47.0

func NewMsgServerImpl(ak AccountKeeper) types.MsgServer

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

func NewQueryServer added in v0.50.1

func NewQueryServer(k AccountKeeper) types.QueryServer

Types

type AccountKeeper

type AccountKeeper struct {

	// State
	Schema        collections.Schema
	Params        collections.Item[types.Params]
	AccountNumber collections.Sequence
	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(
	cdc codec.BinaryCodec, storeService store.KVStoreService, proto func() sdk.AccountI,
	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 added in v0.50.1

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 added in v0.46.0

func (ak AccountKeeper) ExportGenesis(ctx sdk.Context) *types.GenesisState

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

func (ak AccountKeeper) GetAllAccounts(ctx context.Context) (accounts []sdk.AccountI)

GetAllAccounts returns all accounts in the accountKeeper.

func (AccountKeeper) GetAuthority added in v0.47.0

func (ak AccountKeeper) GetAuthority() string

GetAuthority returns the x/auth module's authority.

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 added in v0.47.0

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 added in v0.45.0

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

HasAccount implements AccountKeeperI.

func (AccountKeeper) InitGenesis added in v0.46.0

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

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

func (ak AccountKeeper) IterateAccounts(ctx context.Context, cb func(account sdk.AccountI) (stop bool))

IterateAccounts iterates over all the stored accounts and performs a callback function. Stops iteration when callback returns true.

func (AccountKeeper) Logger

func (ak AccountKeeper) Logger(ctx context.Context) log.Logger

Logger returns a module-specific logger.

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 added in v0.47.0

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) 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 added in v0.40.0

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)

	// Iterate over all accounts, calling the provided function. Stop iteration when it returns true.
	IterateAccounts(context.Context, func(sdk.AccountI) bool)

	// 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 added in v0.50.1

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 added in v0.50.1

func NewAccountIndexes(sb *collections.SchemaBuilder) AccountsIndexes

func (AccountsIndexes) IndexesList added in v0.50.1

type Migrator added in v0.43.0

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

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

func NewMigrator added in v0.43.0

func NewMigrator(keeper AccountKeeper, queryServer grpc.Server, ss exported.Subspace) Migrator

NewMigrator returns a new Migrator.

func (Migrator) Migrate1to2 added in v0.43.0

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

Migrate1to2 migrates from version 1 to 2.

func (Migrator) Migrate2to3 added in v0.46.0

func (m Migrator) Migrate2to3(ctx sdk.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 added in v0.47.0

func (m Migrator) Migrate3to4(ctx sdk.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 added in v0.50.1

func (m Migrator) Migrate4To5(ctx sdk.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 added in v0.50.1

func (m Migrator) V45SetAccount(ctx sdk.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