Documentation ¶
Overview ¶
nolint
Index ¶
- Constants
- Variables
- func ErrInsufficientSigs() errors.TMError
- func ErrNoMembers() errors.TMError
- func ErrNoRole() errors.TMError
- func ErrNotEnoughMembers() errors.TMError
- func ErrNotMember() errors.TMError
- func ErrRoleExists() errors.TMError
- func ErrTooManyMembers() errors.TMError
- func IsInsufficientSigsErr(err error) bool
- func IsNoMembersErr(err error) bool
- func IsNoRoleErr(err error) bool
- func IsNotEnoughMembersErr(err error) bool
- func IsNotMemberErr(err error) bool
- func IsRoleExistsErr(err error) bool
- func IsTooManyMembersErr(err error) bool
- func NewAssumeRoleTx(role []byte, tx sdk.Tx) sdk.Tx
- func NewCreateRoleTx(role []byte, minSigs uint32, signers []sdk.Actor) sdk.Tx
- func NewPerm(role []byte) sdk.Actor
- type AssumeRoleTx
- type CreateRoleTx
- type Handler
- type Middleware
- type Role
Constants ¶
const ( //NameRole - name space of the roles module NameRole = "role" // CostCreate is the cost to create a new role CostCreate = uint64(40) // CostAssume is the cost to assume a role as part of a tx CostAssume = uint64(5) )
const ( ByteAssumeRoleTx = 0x23 ByteCreateRoleTx = 0x24 TypeAssumeRoleTx = NameRole + "/assume" // no prefix needed as it is middleware TypeCreateRoleTx = NameRole + "/create" // prefix needed for dispatcher )
nolint
Variables ¶
var ( // MaxMembers it the maximum number of members in a Role. Used to avoid // extremely large roles. // Value is arbitrary, please adjust as needed MaxMembers = 20 )
Functions ¶
func ErrInsufficientSigs ¶
func ErrNoMembers ¶
func ErrNotEnoughMembers ¶
func ErrNotMember ¶
func ErrRoleExists ¶
func ErrTooManyMembers ¶
func IsInsufficientSigsErr ¶
func IsNoMembersErr ¶
func IsNoRoleErr ¶
func IsNotEnoughMembersErr ¶
func IsNotMemberErr ¶
func IsRoleExistsErr ¶
func IsTooManyMembersErr ¶
func NewAssumeRoleTx ¶
NewAssumeRoleTx creates a new wrapper to add a role to a tx execution
func NewCreateRoleTx ¶
NewCreateRoleTx creates a new role, which we can later use
Types ¶
type AssumeRoleTx ¶
AssumeRoleTx is a layered tx that can wrap your normal tx to give it the authority to use a given role.
func (AssumeRoleTx) ValidateBasic ¶
func (tx AssumeRoleTx) ValidateBasic() error
ValidateBasic - validate nothing is empty
type CreateRoleTx ¶
type CreateRoleTx struct { Role data.Bytes `json:"role"` MinSigs uint32 `json:"min_sigs"` Signers []sdk.Actor `json:"signers"` }
CreateRoleTx is used to construct a new role
TODO: add ability to update signers on a role... but that adds a lot more complexity to the permissions
func (CreateRoleTx) ValidateBasic ¶
func (tx CreateRoleTx) ValidateBasic() error
ValidateBasic - validate nothing is empty
type Handler ¶
type Handler struct { sdk.NopInitState sdk.NopInitValidate }
Handler allows us to create new roles
func (Handler) CheckTx ¶
func (h Handler) CheckTx(ctx sdk.Context, store state.SimpleDB, tx sdk.Tx) (res sdk.CheckResult, err error)
CheckTx verifies if the transaction is properly formated
type Middleware ¶
type Middleware struct { stack.PassInitState stack.PassInitValidate }
Middleware allows us to add a requested role as a permission if the tx requests it and has sufficient authority
func NewMiddleware ¶
func NewMiddleware() Middleware
NewMiddleware creates a role-checking middleware
func (Middleware) CheckTx ¶
func (m Middleware) CheckTx(ctx sdk.Context, store state.SimpleDB, tx sdk.Tx, next sdk.Checker) (res sdk.CheckResult, err error)
CheckTx tries to assume the named role if requested. If no role is requested, do nothing. If insufficient authority to assume the role, return error.
func (Middleware) DeliverTx ¶
func (m Middleware) DeliverTx(ctx sdk.Context, store state.SimpleDB, tx sdk.Tx, next sdk.Deliver) (res sdk.DeliverResult, err error)
DeliverTx tries to assume the named role if requested. If no role is requested, do nothing. If insufficient authority to assume the role, return error.