Documentation ¶
Index ¶
- Constants
- type AccountPermissions
- type BasePermissions
- func (bp BasePermissions) Compose(bpFallthrough BasePermissions) BasePermissions
- func (bp BasePermissions) Get(ty PermFlag) (bool, error)
- func (bp BasePermissions) IsSet(ty PermFlag) bool
- func (bp BasePermissions) ResultantPerms() PermFlag
- func (bp *BasePermissions) Set(ty PermFlag, value bool) error
- func (bp BasePermissions) String() string
- func (bp *BasePermissions) Unset(ty PermFlag) error
- type ErrInvalidPermission
- type ErrValueNotSet
- type PermFlag
Constants ¶
const ( // Chain permissions. // These permissions grant the ability for accounts to perform certain transition within the execution package // Root is a reserved permission currently unused that may be used in the future to grant super-user privileges // for instance to a governance contract Root PermFlag = 1 << iota // 1 // Send permits an account to issue a SendTx to transfer value from one account to another. Note that value can // still be transferred with a CallTx by specifying an Amount in the InputTx. Funding an account is the basic // prerequisite for an account to act in the system so is often used as a surrogate for 'account creation' when // sending to a unknown account - in order for this to be permitted the input account needs the CreateAccount // permission in addition. Send // 2 // Call permits and account to issue a CallTx, which can be used to call (run) the code of an existing // account/contract (these are synonymous in Burrow/EVM). A CallTx can be used to create an account if it points to // a nil address - in order for an account to be permitted to do this the input (calling) account needs the // CreateContract permission in addition. Call // 4 // CreateContract permits the input account of a CallTx to create a new contract/account when CallTx.Address is nil // and permits an executing contract in the EVM to create a new contract programmatically. CreateContract // 8 // CreateAccount permits an input account of a SendTx to add value to non-existing (unfunded) accounts CreateAccount // 16 // Bond is a reserved permission for making changes to the validator set - currently unused Bond // 32 // Name permits manipulation of the name registry by allowing an account to issue a NameTx Name // 64 // Moderator permissions. // These permissions concern the alteration of the chain permissions listed above. Each permission relates to a // particular canonical permission mutation or query function. When an account is granted a moderation permission // it is permitted to call that function. See snative.go for a marked-up description of what each function does. HasBase SetBase UnsetBase SetGlobal HasRole AddRole RemoveRole NumPermissions uint = 14 // NOTE Adjust this too. We can support upto 64 TopPermFlag PermFlag = 1 << (NumPermissions - 1) AllPermFlags PermFlag = TopPermFlag | (TopPermFlag - 1) DefaultPermFlags PermFlag = Send | Call | CreateContract | CreateAccount | Bond | Name | HasBase | HasRole // Chain permissions strings RootString string = "root" SendString = "send" CallString = "call" CreateContractString = "createContract" CreateAccountString = "createAccount" BondString = "bond" NameString = "name" // Moderator permissions strings HasBaseString = "hasBase" SetBaseString = "setBase" UnsetBaseString = "unsetBase" SetGlobalString = "setGlobal" HasRoleString = "hasRole" AddRoleString = "addRole" RemoveRoleString = "removeRole" UnknownString = "#-UNKNOWN-#" AllString = "all" )
Base permission references are like unix (the index is already bit shifted)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AccountPermissions ¶
type AccountPermissions struct { Base BasePermissions Roles []string }
func (*AccountPermissions) AddRole ¶
func (ap *AccountPermissions) AddRole(role string) bool
Returns true if the role is added, and false if it already exists
func (*AccountPermissions) Clone ¶ added in v0.16.0
func (ap *AccountPermissions) Clone() AccountPermissions
Clone clones the account permissions
func (AccountPermissions) HasRole ¶
func (ap AccountPermissions) HasRole(role string) bool
Returns true if the role is found
func (*AccountPermissions) RmRole ¶
func (ap *AccountPermissions) RmRole(role string) bool
Returns true if the role is removed, and false if it is not found
type BasePermissions ¶
type BasePermissions struct { // bit array with "has"/"doesn't have" for each permission Perms PermFlag // bit array with "set"/"not set" for each permission (not-set should fall back to global) SetBit PermFlag }
Base chain permissions struct
func (BasePermissions) Compose ¶ added in v0.18.0
func (bp BasePermissions) Compose(bpFallthrough BasePermissions) BasePermissions
Returns a BasePermission that matches any permissions set on this BasePermission and falls through to any permissions set on the bpFallthrough
func (BasePermissions) Get ¶
func (bp BasePermissions) Get(ty PermFlag) (bool, error)
Gets the permission value. ErrValueNotSet is returned if the permission's set bits are not all on, and should be caught by caller so the global permission can be fetched
func (BasePermissions) IsSet ¶
func (bp BasePermissions) IsSet(ty PermFlag) bool
Check if the permission is set
func (BasePermissions) ResultantPerms ¶ added in v0.16.0
func (bp BasePermissions) ResultantPerms() PermFlag
Returns the Perms PermFlag masked with SetBit bit field to give the resultant permissions enabled by this BasePermissions
func (*BasePermissions) Set ¶
func (bp *BasePermissions) Set(ty PermFlag, value bool) error
Set a permission bit. Will set the permission's set bit to true.
func (BasePermissions) String ¶
func (bp BasePermissions) String() string
func (*BasePermissions) Unset ¶
func (bp *BasePermissions) Unset(ty PermFlag) error
Set the permission's set bits to false
type ErrInvalidPermission ¶
type ErrInvalidPermission PermFlag
func (ErrInvalidPermission) Error ¶
func (e ErrInvalidPermission) Error() string
type ErrValueNotSet ¶
type ErrValueNotSet PermFlag
set=false. This error should be caught and the global value fetched for the permission by the caller
func (ErrValueNotSet) Error ¶
func (e ErrValueNotSet) Error() string
type PermFlag ¶
type PermFlag uint64
A particular permission
func PermStringToFlag ¶
PermStringToFlag maps camel- and snake case strings to the the corresponding permission flag.