types

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2020 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EventGrantAuthorization   = "grant_authorization"
	EventRevokeAuthorization  = "revoke_authorization"
	EventExecuteAuthorization = "execute_authorization"

	AttributeKeyGrantType      = "grant_type"
	AttributeKeyGranteeAddress = "grantee"
	AttributeKeyGranterAddress = "granter"

	AttributeValueCategory = ModuleName
)

msgauth module events

View Source
const (
	// ModuleName is the module name constant used in many places
	ModuleName = "msgauth"

	// StoreKey is the store key string for msgauth
	StoreKey = ModuleName

	// RouterKey is the message route for msgauth
	RouterKey = ModuleName

	// QuerierRoute is the querier route for msgauth
	QuerierRoute = ModuleName
)
View Source
const (
	QueryGrant  = "grant"
	QueryGrants = "grants"
)

Defines the prefix of each query path

Variables

View Source
var (
	ErrInvalidPeriod  = sdkerrors.Register(ModuleName, 3, "period of authorization should be positive time duration")
	ErrInvalidMsgType = sdkerrors.Register(ModuleName, 4, "given msg type is not grantable")
)

x/gov module sentinel errors

View Source
var (
	// Keys for store prefixes
	GrantKey      = []byte{0x01} // prefix for each key to a prevote
	GrantQueueKey = []byte{0x02} // prefix for the timestamps in grants queue
)

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

- 0x01<accAddress_Bytes><accAddress_Bytes><msgType_Bytes>: Grant - 0x02<timestamp_Bytes>: []GGMPair

View Source
var ModuleCdc = codec.New()

ModuleCdc defines internal Module Codec

Functions

func ExtractAddressesFromGrantKey

func ExtractAddressesFromGrantKey(key []byte) (granterAddr, granteeAddr sdk.AccAddress)

ExtractAddressesFromGrantKey - split granter & grantee address from the authorization key

func GetGrantKey

func GetGrantKey(granterAddr sdk.AccAddress, granteeAddr sdk.AccAddress, msgType string) []byte

GetGrantKey - return grant store key

func GetGrantTimeKey

func GetGrantTimeKey(timestamp time.Time) []byte

GetGrantTimeKey - return grant queue store key

func RegisterCodec

func RegisterCodec(cdc *codec.Codec)

RegisterCodec concretes types on codec codec

func RegisterMsgAuthTypeCodec

func RegisterMsgAuthTypeCodec(o interface{}, name string)

RegisterMsgAuthTypeCodec registers an external msg type defined in another module for the internal ModuleCdc. This allows the MsgExecAuthorized to be correctly Amino encoded and decoded.

func ValidateGenesis

func ValidateGenesis(data GenesisState) error

ValidateGenesis check the given genesis state has no integrity issues

Types

type Authorization

type Authorization interface {
	MsgType() string
	Accept(msg sdk.Msg, block abci.Header) (allow bool, updated Authorization, delete bool)
}

Authorization represents the interface of various Authorization instances

type AuthorizationEntry

type AuthorizationEntry struct {
	Granter       sdk.AccAddress `json:"granter" yaml:"granter"`
	Grantee       sdk.AccAddress `json:"grantee" yaml:"grantee"`
	Authorization Authorization  `json:"authorization" yaml:"authorization"`
	Expiration    time.Time      `json:"expiration" yaml:"expiration"`
}

AuthorizationEntry hold each authorization information

type AuthorizationGrant

type AuthorizationGrant struct {
	Authorization Authorization `json:"authorization"`

	Expiration time.Time `json:"expiration"`
}

AuthorizationGrant represent the stored grant instance in the keeper store

func NewAuthorizationGrant

func NewAuthorizationGrant(authorization Authorization, expiration time.Time) AuthorizationGrant

NewAuthorizationGrant returns new AuthroizationGrant instance

type GGMPair

type GGMPair struct {
	GranterAddress sdk.AccAddress
	GranteeAddress sdk.AccAddress
	MsgType        string
}

GGMPair is struct that just has a granter-grantee-msgtype pair with no other data. It is intended to be used as a marshalable pointer. For example, a GGPair can be used to construct the key to getting an Grant from state.

type GenericAuthorization

type GenericAuthorization struct {
	// GrantMsgType is the type of Msg this capability grant allows
	GrantMsgType string `json:"grant_msg_type"`
}

GenericAuthorization grants the permission to execute any transaction of the provided msg type without restrictions

func NewGenericAuthorization

func NewGenericAuthorization(msgType string) GenericAuthorization

NewGenericAuthorization returns new GenericAuthorization instantce

func (GenericAuthorization) Accept

func (ga GenericAuthorization) Accept(msg sdk.Msg, block abci.Header) (allow bool, updated Authorization, delete bool)

Accept implement Authorization

func (GenericAuthorization) MsgType

func (ga GenericAuthorization) MsgType() string

MsgType implement Authorization

type GenesisState

type GenesisState struct {
	AuthorizationEntries []AuthorizationEntry `json:"authorization_entries" yaml:"authorization_entries"`
}

GenesisState is the struct representation of the export genesis

func DefaultGenesisState

func DefaultGenesisState() GenesisState

DefaultGenesisState gets raw genesis raw message for testing

func NewGenesisState

func NewGenesisState(entries []AuthorizationEntry) GenesisState

NewGenesisState creates a new GenesisState object

func (GenesisState) Equal

func (data GenesisState) Equal(data2 GenesisState) bool

Equal checks whether 2 GenesisState structs are equivalent.

func (GenesisState) IsEmpty

func (data GenesisState) IsEmpty() bool

IsEmpty returns if a GenesisState is empty or has data in it

type MsgExecAuthorized

type MsgExecAuthorized struct {
	Grantee sdk.AccAddress `json:"grantee"`
	Msgs    []sdk.Msg      `json:"msgs"`
}

MsgExecAuthorized attempts to execute the provided messages using authorizations granted to the grantee. Each message should have only one signer corresponding to the granter of the authorization.

func NewMsgExecAuthorized

func NewMsgExecAuthorized(grantee sdk.AccAddress, msg []sdk.Msg) MsgExecAuthorized

func (MsgExecAuthorized) GetSignBytes

func (msg MsgExecAuthorized) GetSignBytes() []byte

func (MsgExecAuthorized) GetSigners

func (msg MsgExecAuthorized) GetSigners() []sdk.AccAddress

func (MsgExecAuthorized) Route

func (msg MsgExecAuthorized) Route() string

func (MsgExecAuthorized) Type

func (msg MsgExecAuthorized) Type() string

func (MsgExecAuthorized) ValidateBasic

func (msg MsgExecAuthorized) ValidateBasic() error

type MsgGrantAuthorization

type MsgGrantAuthorization struct {
	Granter       sdk.AccAddress `json:"granter"`
	Grantee       sdk.AccAddress `json:"grantee"`
	Authorization Authorization  `json:"authorization"`
	Period        time.Duration  `json:"period"`
}

MsgGrantAuthorization grants the provided authorization to the grantee on the granter's account during the provided period time.

func NewMsgGrantAuthorization

func NewMsgGrantAuthorization(granter sdk.AccAddress, grantee sdk.AccAddress, authorization Authorization, period time.Duration) MsgGrantAuthorization

NewMsgGrantAuthorization returns new MsgGrantAuthorization instance

func (MsgGrantAuthorization) GetSignBytes

func (msg MsgGrantAuthorization) GetSignBytes() []byte

func (MsgGrantAuthorization) GetSigners

func (msg MsgGrantAuthorization) GetSigners() []sdk.AccAddress

func (MsgGrantAuthorization) Route

func (msg MsgGrantAuthorization) Route() string

func (MsgGrantAuthorization) Type

func (msg MsgGrantAuthorization) Type() string

func (MsgGrantAuthorization) ValidateBasic

func (msg MsgGrantAuthorization) ValidateBasic() error

type MsgRevokeAuthorization

type MsgRevokeAuthorization struct {
	Granter sdk.AccAddress `json:"granter"`
	Grantee sdk.AccAddress `json:"grantee"`
	// AuthorizationMsgType is the type of sdk.Msg that the revoked Authorization refers to.
	// i.e. this is what `Authorization.MsgType()` returns
	AuthorizationMsgType string `json:"authorization_msg_type"`
}

MsgRevokeAuthorization revokes any authorization with the provided sdk.Msg type on the granter's account with that has been granted to the grantee.

func NewMsgRevokeAuthorization

func NewMsgRevokeAuthorization(granter sdk.AccAddress, grantee sdk.AccAddress, authorizationMsgType string) MsgRevokeAuthorization

func (MsgRevokeAuthorization) GetSignBytes

func (msg MsgRevokeAuthorization) GetSignBytes() []byte

func (MsgRevokeAuthorization) GetSigners

func (msg MsgRevokeAuthorization) GetSigners() []sdk.AccAddress

func (MsgRevokeAuthorization) Route

func (msg MsgRevokeAuthorization) Route() string

func (MsgRevokeAuthorization) Type

func (msg MsgRevokeAuthorization) Type() string

func (MsgRevokeAuthorization) ValidateBasic

func (msg MsgRevokeAuthorization) ValidateBasic() error

type QueryGrantParams

type QueryGrantParams struct {
	Granter sdk.AccAddress `json:"granter"`
	Grantee sdk.AccAddress `json:"grantee"`
	MsgType string         `json:"msg_type"`
}

QueryGrantParams defines the params for the following queries: - 'custom/msgauth/grant'

func NewQueryGrantParams

func NewQueryGrantParams(granter sdk.AccAddress, grantee sdk.AccAddress, msgType string) QueryGrantParams

NewQueryGrantParams returns params for grant query

type QueryGrantsParams

type QueryGrantsParams struct {
	Granter sdk.AccAddress `json:"granter"`
	Grantee sdk.AccAddress `json:"grantee"`
}

QueryGrantsParams defines the params for the following queries: - 'custom/msgauth/grants'

func NewQueryGrantsParams

func NewQueryGrantsParams(granter sdk.AccAddress, grantee sdk.AccAddress) QueryGrantsParams

NewQueryGrantsParams returns params for grant query

type SendAuthorization

type SendAuthorization struct {
	// SpendLimit specifies the maximum amount of tokens that can be spent
	// by this authorization and will be updated as tokens are spent. If it is
	// empty, there is no spend limit and any amount of coins can be spent.
	SpendLimit sdk.Coins `json:"spend_limit"`
}

func NewSendAuthorization

func NewSendAuthorization(spendLimit sdk.Coins) SendAuthorization

NewSendAuthorization return new SendAhtorization instance

func (SendAuthorization) Accept

func (authorization SendAuthorization) Accept(msg sdk.Msg, block abci.Header) (allow bool, updated Authorization, delete bool)

func (SendAuthorization) MsgType

func (authorization SendAuthorization) MsgType() string

Jump to

Keyboard shortcuts

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