keeper

package
v0.47.15 Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2024 License: Apache-2.0 Imports: 22 Imported by: 1,289

Documentation

Index

Constants

View Source
const StoreKey = authz.ModuleName

StoreKey is the store key string for authz

Variables

View Source
var (
	GrantKey         = []byte{0x01} // prefix for each key
	GrantQueuePrefix = []byte{0x02}
)

Keys for store prefixes Items are stored with the following key: values

- 0x01<grant_Bytes>: Grant - 0x02<grant_expiration_Bytes>: GrantQueueItem

Functions

func GrantQueueKey added in v0.46.0

func GrantQueueKey(expiration time.Time, granter sdk.AccAddress, grantee sdk.AccAddress) []byte

GrantQueueKey - return grant queue store key. If a given grant doesn't have a defined expiration, then it should not be used in the pruning queue. Key format is:

0x02<expiration><granterAddressLen (1 Byte)><granterAddressBytes><granteeAddressLen (1 Byte)><granteeAddressBytes>: GrantQueueItem

func GrantQueueTimePrefix added in v0.46.0

func GrantQueueTimePrefix(expiration time.Time) []byte

GrantQueueTimePrefix - return grant queue time prefix

Types

type Keeper

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

func NewKeeper

NewKeeper constructs a message authorization Keeper

func (Keeper) DeleteGrant

func (k Keeper) DeleteGrant(ctx sdk.Context, grantee sdk.AccAddress, granter sdk.AccAddress, msgType string) error

DeleteGrant revokes any authorization for the provided message type granted to the grantee by the granter.

func (Keeper) DequeueAndDeleteExpiredGrants added in v0.46.0

func (k Keeper) DequeueAndDeleteExpiredGrants(ctx sdk.Context) error

DequeueAndDeleteExpiredGrants deletes expired grants from the state and grant queue.

func (Keeper) DispatchActions

func (k Keeper) DispatchActions(ctx sdk.Context, grantee sdk.AccAddress, msgs []sdk.Msg) ([][]byte, error)

DispatchActions attempts to execute the provided messages via authorization grants from the message signer to the grantee.

func (Keeper) Exec

func (k Keeper) Exec(goCtx context.Context, msg *authz.MsgExec) (*authz.MsgExecResponse, error)

Exec implements the MsgServer.Exec method.

func (Keeper) ExportGenesis

func (k Keeper) ExportGenesis(ctx sdk.Context) *authz.GenesisState

ExportGenesis returns a GenesisState for a given context.

func (Keeper) GetAuthorization added in v0.46.2

func (k Keeper) GetAuthorization(ctx sdk.Context, grantee sdk.AccAddress, granter sdk.AccAddress, msgType string) (authz.Authorization, *time.Time)

GetAuthorization returns an Authorization and it's expiration time. A nil Authorization is returned under the following circumstances:

  • No grant is found.
  • A grant is found, but it is expired.
  • There was an error getting the authorization from the grant.

func (Keeper) GetAuthorizations

func (k Keeper) GetAuthorizations(ctx sdk.Context, grantee sdk.AccAddress, granter sdk.AccAddress) ([]authz.Authorization, error)

GetAuthorizations Returns list of `Authorizations` granted to the grantee by the granter.

func (Keeper) Grant

func (k Keeper) Grant(goCtx context.Context, msg *authz.MsgGrant) (*authz.MsgGrantResponse, error)

Grant implements the MsgServer.Grant method to create a new grant.

func (Keeper) GranteeGrants added in v0.45.2

GranteeGrants implements the Query/GranteeGrants gRPC method.

func (Keeper) GranterGrants added in v0.45.2

GranterGrants implements the Query/GranterGrants gRPC method.

func (Keeper) Grants

Grants implements the Query/Grants gRPC method. It returns grants for a granter-grantee pair. If msg type URL is set, it returns grants only for that msg type.

func (Keeper) InitGenesis

func (k Keeper) InitGenesis(ctx sdk.Context, data *authz.GenesisState)

InitGenesis new authz genesis

func (Keeper) IterateGrants

func (k Keeper) IterateGrants(ctx sdk.Context,
	handler func(granterAddr sdk.AccAddress, granteeAddr sdk.AccAddress, grant authz.Grant) bool,
)

IterateGrants iterates over all authorization grants This function should be used with caution because it can involve significant IO operations. It should not be used in query or msg services without charging additional gas. The iteration stops when the handler function returns true or the iterator exhaust.

func (Keeper) Logger

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

Logger returns a module-specific logger.

func (Keeper) Revoke

func (k Keeper) Revoke(goCtx context.Context, msg *authz.MsgRevoke) (*authz.MsgRevokeResponse, error)

Revoke implements the MsgServer.Revoke method.

func (Keeper) SaveGrant

func (k Keeper) SaveGrant(ctx sdk.Context, grantee, granter sdk.AccAddress, authorization authz.Authorization, expiration *time.Time) error

SaveGrant method grants the provided authorization to the grantee on the granter's account with the provided expiration time and insert authorization key into the grants queue. If there is an existing authorization grant for the same `sdk.Msg` type, this grant overwrites that.

func (Keeper) SetBankKeeper added in v0.47.11

func (k Keeper) SetBankKeeper(bk authz.BankKeeper) Keeper

Super ugly hack to not be breaking in v0.50 and v0.47 DO NOT USE.

type Migrator added in v0.46.0

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

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

func NewMigrator added in v0.46.0

func NewMigrator(keeper Keeper) Migrator

NewMigrator returns a new Migrator.

func (Migrator) Migrate1to2 added in v0.46.0

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

Migrate1to2 migrates from version 1 to 2.

Jump to

Keyboard shortcuts

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