Documentation ¶
Index ¶
- Constants
- Variables
- func GrantQueueKey(expiration time.Time, granter, grantee sdk.AccAddress) []byte
- func GrantQueueTimePrefix(expiration time.Time) []byte
- type Keeper
- func (k Keeper) DeleteAllGrants(ctx context.Context, granter sdk.AccAddress) error
- func (k Keeper) DeleteGrant(ctx context.Context, grantee, granter sdk.AccAddress, msgType string) error
- func (k Keeper) DequeueAndDeleteExpiredGrants(ctx context.Context, limit int) error
- func (k Keeper) DispatchActions(ctx context.Context, grantee sdk.AccAddress, msgs []sdk.Msg) ([][]byte, error)
- func (k Keeper) Exec(ctx context.Context, msg *authz.MsgExec) (*authz.MsgExecResponse, error)
- func (k Keeper) ExportGenesis(ctx context.Context) (*authz.GenesisState, error)
- func (k Keeper) GetAuthorization(ctx context.Context, grantee, granter sdk.AccAddress, msgType string) (authz.Authorization, *time.Time)
- func (k Keeper) GetAuthorizations(ctx context.Context, grantee, granter sdk.AccAddress) ([]authz.Authorization, error)
- func (k Keeper) Grant(ctx context.Context, msg *authz.MsgGrant) (*authz.MsgGrantResponse, error)
- func (k Keeper) GranteeGrants(ctx context.Context, req *authz.QueryGranteeGrantsRequest) (*authz.QueryGranteeGrantsResponse, error)
- func (k Keeper) GranterGrants(ctx context.Context, req *authz.QueryGranterGrantsRequest) (*authz.QueryGranterGrantsResponse, error)
- func (k Keeper) Grants(ctx context.Context, req *authz.QueryGrantsRequest) (*authz.QueryGrantsResponse, error)
- func (k Keeper) InitGenesis(ctx context.Context, data *authz.GenesisState) error
- func (k Keeper) IterateGranterGrants(ctx context.Context, granter sdk.AccAddress, ...) error
- func (k Keeper) IterateGrants(ctx context.Context, ...) error
- func (k Keeper) PruneExpiredGrants(ctx context.Context, msg *authz.MsgPruneExpiredGrants) (*authz.MsgPruneExpiredGrantsResponse, error)
- func (k Keeper) Revoke(ctx context.Context, msg *authz.MsgRevoke) (*authz.MsgRevokeResponse, error)
- func (k Keeper) RevokeAll(ctx context.Context, msg *authz.MsgRevokeAll) (*authz.MsgRevokeAllResponse, error)
- func (k Keeper) SaveGrant(ctx context.Context, grantee, granter sdk.AccAddress, ...) error
- type Migrator
Constants ¶
const StoreKey = authz.ModuleName
StoreKey is the store key string for authz
Variables ¶
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 ¶
func GrantQueueKey(expiration time.Time, granter, 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 ¶
GrantQueueTimePrefix - return grant queue time prefix
Types ¶
type Keeper ¶
type Keeper struct { appmodule.Environment // contains filtered or unexported fields }
func (Keeper) DeleteAllGrants ¶
DeleteAllGrants revokes all authorizations granted to the grantee by the granter.
func (Keeper) DeleteGrant ¶
func (k Keeper) DeleteGrant(ctx context.Context, grantee, 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 ¶
DequeueAndDeleteExpiredGrants deletes expired grants from the state and grant queue.
func (Keeper) DispatchActions ¶
func (k Keeper) DispatchActions(ctx context.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) ExportGenesis ¶
ExportGenesis returns a GenesisState for a given context.
func (Keeper) GetAuthorization ¶
func (k Keeper) GetAuthorization(ctx context.Context, grantee, 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 context.Context, grantee, granter sdk.AccAddress) ([]authz.Authorization, error)
GetAuthorizations Returns list of `Authorizations` granted to the grantee by the granter.
func (Keeper) GranteeGrants ¶
func (k Keeper) GranteeGrants(ctx context.Context, req *authz.QueryGranteeGrantsRequest) (*authz.QueryGranteeGrantsResponse, error)
GranteeGrants implements the Query/GranteeGrants gRPC method.
func (Keeper) GranterGrants ¶
func (k Keeper) GranterGrants(ctx context.Context, req *authz.QueryGranterGrantsRequest) (*authz.QueryGranterGrantsResponse, error)
GranterGrants implements the Query/GranterGrants gRPC method.
func (Keeper) Grants ¶
func (k Keeper) Grants(ctx context.Context, req *authz.QueryGrantsRequest) (*authz.QueryGrantsResponse, error)
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 ¶
InitGenesis initializes new authz genesis
func (Keeper) IterateGranterGrants ¶
func (Keeper) IterateGrants ¶
func (k Keeper) IterateGrants(ctx context.Context, handler func(granterAddr, granteeAddr sdk.AccAddress, grant authz.Grant) (bool, error), ) error
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) PruneExpiredGrants ¶
func (k Keeper) PruneExpiredGrants(ctx context.Context, msg *authz.MsgPruneExpiredGrants) (*authz.MsgPruneExpiredGrantsResponse, error)
func (Keeper) RevokeAll ¶
func (k Keeper) RevokeAll(ctx context.Context, msg *authz.MsgRevokeAll) (*authz.MsgRevokeAllResponse, error)
RevokeAll implements the MsgServer.RevokeAll method.
func (Keeper) SaveGrant ¶
func (k Keeper) SaveGrant(ctx context.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.