v2

package
v6.4.0 Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2023 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// PermissionNothing represents the permission to do nothing
	PermissionNothing = Permission(0b000000)

	// PermissionWrite identifies users that can create content inside the subspace
	PermissionWrite = Permission(0b000001)

	// PermissionModerateContent allows users to moderate contents of other users (e.g. deleting it)
	PermissionModerateContent = Permission(0b000010)

	// PermissionChangeInfo allows to change the information of the subspace
	PermissionChangeInfo = Permission(0b000100)

	// PermissionManageGroups allows users to manage user groups and members
	PermissionManageGroups = Permission(0b001000)

	// PermissionSetPermissions allows users to set other users' permissions (except PermissionSetPermissions).
	// This includes managing user groups and the associated permissions
	PermissionSetPermissions = Permission(0b010000)

	// PermissionDeleteSubspace allows users to delete the subspace.
	PermissionDeleteSubspace = Permission(0b100000)

	// PermissionEverything allows to do everything.
	// This should usually be reserved only to the owner (which has it by default)
	PermissionEverything = Permission(0b111111)
)

Variables

View Source
var (
	ErrInvalidLengthAuthz        = fmt.Errorf("proto: negative length found during unmarshaling")
	ErrIntOverflowAuthz          = fmt.Errorf("proto: integer overflow")
	ErrUnexpectedEndOfGroupAuthz = fmt.Errorf("proto: unexpected end of group")
)
View Source
var (
	SubspacePrefix             = []byte{0x01}
	GroupIDPrefix              = []byte{0x02}
	GroupsPrefix               = []byte{0x03}
	GroupMembersStorePrefix    = []byte{0x04}
	UserPermissionsStorePrefix = []byte{0x05}
)
View Source
var (
	ErrInvalidLengthModels        = fmt.Errorf("proto: negative length found during unmarshaling")
	ErrIntOverflowModels          = fmt.Errorf("proto: integer overflow")
	ErrUnexpectedEndOfGroupModels = fmt.Errorf("proto: unexpected end of group")
)

Functions

func GetAddressBytes

func GetAddressBytes(user sdk.AccAddress) []byte

func GetAddressFromBytes

func GetAddressFromBytes(bz []byte) sdk.AccAddress

func GetGroupIDBytes

func GetGroupIDBytes(groupID uint32) (groupIDBz []byte)

GetGroupIDBytes returns the byte representation of the groupID

func GetGroupIDFromBytes

func GetGroupIDFromBytes(bz []byte) (subspaceID uint32)

GetGroupIDFromBytes returns groupID in uint32 format from a byte array

func GetSubspaceIDBytes

func GetSubspaceIDBytes(subspaceID uint64) (subspaceIDBz []byte)

GetSubspaceIDBytes returns the byte representation of the subspaceID

func GetSubspaceIDFromBytes

func GetSubspaceIDFromBytes(bz []byte) (subspaceID uint64)

GetSubspaceIDFromBytes returns subspaceID in uint64 format from a byte array

func GroupIDStoreKey

func GroupIDStoreKey(subspaceID uint64) []byte

GroupIDStoreKey returns the store key that is used to store the group id to be used next for the given subspace

func GroupMemberStoreKey

func GroupMemberStoreKey(subspaceID uint64, groupID uint32, user sdk.AccAddress) []byte

GroupMemberStoreKey returns the key used to store the membership of the given user to the specified group inside the provided subspace

func GroupMembersStoreKey

func GroupMembersStoreKey(subspaceID uint64, groupID uint32) []byte

GroupMembersStoreKey returns the key used to store all the members of the given group inside the given subspace

func GroupStoreKey

func GroupStoreKey(subspaceID uint64, groupID uint32) []byte

GroupStoreKey returns the key used to store a group for a subspace

func GroupsStoreKey

func GroupsStoreKey(subspaceID uint64) []byte

GroupsStoreKey returns the key used to store all the groups of a given subspace

func MarshalPermission

func MarshalPermission(permission Permission) (permissionBytes []byte)

MarshalPermission marshals the given permission to a byte array

func MigrateStore

func MigrateStore(ctx sdk.Context, storeKey storetypes.StoreKey, cdc codec.BinaryCodec) error

MigrateStore migrates the store from version 1 to version 2. The migration process will fix all user and group permissions sanitizing their values.

func PermissionsStoreKey

func PermissionsStoreKey(subspaceID uint64) []byte

PermissionsStoreKey returns the key used to store the entire ACL for a given subspace

func RegisterInterfaces

func RegisterInterfaces(registry types.InterfaceRegistry)

RegisterInterfaces registers the interfaces types with the interface registry

func SplitUserPermissionKey

func SplitUserPermissionKey(key []byte) (subspaceID uint64, user sdk.AccAddress)

SplitUserPermissionKey splits the provided UserPermissionStoreKey into the related subspace id and user address

func SubspaceKey

func SubspaceKey(subspaceID uint64) []byte

SubspaceKey returns the key for a specific subspace

func UserPermissionStoreKey

func UserPermissionStoreKey(subspaceID uint64, user sdk.AccAddress) []byte

UserPermissionStoreKey returns the key used to store the permission for the given user inside the given subspace

Types

type GenericSubspaceAuthorization

type GenericSubspaceAuthorization struct {
	// Ids of the subspaces inside which to grant the permission
	SubspacesIDs []uint64 `protobuf:"varint,1,rep,packed,name=subspaces_ids,json=subspacesIds,proto3" json:"subspaces_ids,omitempty"`
	// Msg, identified by it's type URL, to grant unrestricted permissions to
	// execute within the subspace
	Msg string `protobuf:"bytes,2,opt,name=msg,proto3" json:"msg,omitempty"`
}

GenericSubspaceAuthorization defines an authorization to perform any operation only inside a specific subspace.

func NewGenericSubspaceAuthorization

func NewGenericSubspaceAuthorization(subspacesIDs []uint64, msgTypeURL string) *GenericSubspaceAuthorization

NewGenericSubspaceAuthorization creates a new GenericSubspaceAuthorization object.

func (GenericSubspaceAuthorization) Accept

Accept implements Authorization.Accept.

func (*GenericSubspaceAuthorization) Descriptor

func (*GenericSubspaceAuthorization) Descriptor() ([]byte, []int)

func (*GenericSubspaceAuthorization) GetMsg

func (*GenericSubspaceAuthorization) GetSubspacesIDs

func (m *GenericSubspaceAuthorization) GetSubspacesIDs() []uint64

func (*GenericSubspaceAuthorization) Marshal

func (m *GenericSubspaceAuthorization) Marshal() (dAtA []byte, err error)

func (*GenericSubspaceAuthorization) MarshalTo

func (m *GenericSubspaceAuthorization) MarshalTo(dAtA []byte) (int, error)

func (*GenericSubspaceAuthorization) MarshalToSizedBuffer

func (m *GenericSubspaceAuthorization) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (GenericSubspaceAuthorization) MsgTypeURL

func (a GenericSubspaceAuthorization) MsgTypeURL() string

MsgTypeURL implements Authorization.MsgTypeURL.

func (*GenericSubspaceAuthorization) ProtoMessage

func (*GenericSubspaceAuthorization) ProtoMessage()

func (*GenericSubspaceAuthorization) Reset

func (m *GenericSubspaceAuthorization) Reset()

func (*GenericSubspaceAuthorization) Size

func (m *GenericSubspaceAuthorization) Size() (n int)

func (*GenericSubspaceAuthorization) String

func (*GenericSubspaceAuthorization) Unmarshal

func (m *GenericSubspaceAuthorization) Unmarshal(dAtA []byte) error

func (GenericSubspaceAuthorization) ValidateBasic

func (a GenericSubspaceAuthorization) ValidateBasic() error

ValidateBasic implements Authorization.ValidateBasic.

func (*GenericSubspaceAuthorization) XXX_DiscardUnknown

func (m *GenericSubspaceAuthorization) XXX_DiscardUnknown()

func (*GenericSubspaceAuthorization) XXX_Marshal

func (m *GenericSubspaceAuthorization) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*GenericSubspaceAuthorization) XXX_Merge

func (m *GenericSubspaceAuthorization) XXX_Merge(src proto.Message)

func (*GenericSubspaceAuthorization) XXX_Size

func (m *GenericSubspaceAuthorization) XXX_Size() int

func (*GenericSubspaceAuthorization) XXX_Unmarshal

func (m *GenericSubspaceAuthorization) XXX_Unmarshal(b []byte) error

type Permission

type Permission = uint32

Permission represents a permission that can be set to a user or user group

func CombinePermissions

func CombinePermissions(permissions ...Permission) Permission

CombinePermissions combines all the given permissions into a single Permission object using the OR operator

func SanitizePermission

func SanitizePermission(permission Permission) Permission

SanitizePermission sanitizes the given permission to remove any unwanted bits set to 1

func SplitPermissions

func SplitPermissions(permission Permission) []Permission

SplitPermissions splits the given combined permission value into its individual values

func UnmarshalPermission

func UnmarshalPermission(bz []byte) (permission Permission)

UnmarshalPermission reads the given byte array as a Permission object

type PermissionDetail

type PermissionDetail struct {
	// sum is the oneof that specifies whether this represents a user or
	// group permission detail
	//
	// Types that are valid to be assigned to Sum:
	//
	//	*PermissionDetail_User_
	//	*PermissionDetail_Group_
	Sum isPermissionDetail_Sum `protobuf_oneof:"sum"`
}

PermissionDetail contains the details data of a permission

func (*PermissionDetail) Descriptor

func (*PermissionDetail) Descriptor() ([]byte, []int)

func (*PermissionDetail) Equal

func (this *PermissionDetail) Equal(that interface{}) bool

func (*PermissionDetail) GetGroup

func (*PermissionDetail) GetSum

func (m *PermissionDetail) GetSum() isPermissionDetail_Sum

func (*PermissionDetail) GetUser

func (*PermissionDetail) Marshal

func (m *PermissionDetail) Marshal() (dAtA []byte, err error)

func (*PermissionDetail) MarshalTo

func (m *PermissionDetail) MarshalTo(dAtA []byte) (int, error)

func (*PermissionDetail) MarshalToSizedBuffer

func (m *PermissionDetail) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*PermissionDetail) ProtoMessage

func (*PermissionDetail) ProtoMessage()

func (*PermissionDetail) Reset

func (m *PermissionDetail) Reset()

func (*PermissionDetail) Size

func (m *PermissionDetail) Size() (n int)

func (*PermissionDetail) String

func (m *PermissionDetail) String() string

func (*PermissionDetail) Unmarshal

func (m *PermissionDetail) Unmarshal(dAtA []byte) error

func (*PermissionDetail) XXX_DiscardUnknown

func (m *PermissionDetail) XXX_DiscardUnknown()

func (*PermissionDetail) XXX_Marshal

func (m *PermissionDetail) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*PermissionDetail) XXX_Merge

func (m *PermissionDetail) XXX_Merge(src proto.Message)

func (*PermissionDetail) XXX_OneofWrappers

func (*PermissionDetail) XXX_OneofWrappers() []interface{}

XXX_OneofWrappers is for the internal use of the proto package.

func (*PermissionDetail) XXX_Size

func (m *PermissionDetail) XXX_Size() int

func (*PermissionDetail) XXX_Unmarshal

func (m *PermissionDetail) XXX_Unmarshal(b []byte) error

type PermissionDetail_Group

type PermissionDetail_Group struct {
	// Unique id of the group
	GroupID uint32 `protobuf:"varint,1,opt,name=group_id,json=groupId,proto3" json:"group_id,omitempty" yaml:"group_id"`
	// Permission set to the group
	Permission uint32 `protobuf:"varint,2,opt,name=permission,proto3" json:"permission,omitempty"`
}

Group is a permission that has been set to a user group

func (*PermissionDetail_Group) Descriptor

func (*PermissionDetail_Group) Descriptor() ([]byte, []int)

func (*PermissionDetail_Group) Equal

func (this *PermissionDetail_Group) Equal(that interface{}) bool

func (*PermissionDetail_Group) Marshal

func (m *PermissionDetail_Group) Marshal() (dAtA []byte, err error)

func (*PermissionDetail_Group) MarshalTo

func (m *PermissionDetail_Group) MarshalTo(dAtA []byte) (int, error)

func (*PermissionDetail_Group) MarshalToSizedBuffer

func (m *PermissionDetail_Group) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*PermissionDetail_Group) ProtoMessage

func (*PermissionDetail_Group) ProtoMessage()

func (*PermissionDetail_Group) Reset

func (m *PermissionDetail_Group) Reset()

func (*PermissionDetail_Group) Size

func (m *PermissionDetail_Group) Size() (n int)

func (*PermissionDetail_Group) String

func (m *PermissionDetail_Group) String() string

func (*PermissionDetail_Group) Unmarshal

func (m *PermissionDetail_Group) Unmarshal(dAtA []byte) error

func (*PermissionDetail_Group) XXX_DiscardUnknown

func (m *PermissionDetail_Group) XXX_DiscardUnknown()

func (*PermissionDetail_Group) XXX_Marshal

func (m *PermissionDetail_Group) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*PermissionDetail_Group) XXX_Merge

func (m *PermissionDetail_Group) XXX_Merge(src proto.Message)

func (*PermissionDetail_Group) XXX_Size

func (m *PermissionDetail_Group) XXX_Size() int

func (*PermissionDetail_Group) XXX_Unmarshal

func (m *PermissionDetail_Group) XXX_Unmarshal(b []byte) error

type PermissionDetail_Group_

type PermissionDetail_Group_ struct {
	Group *PermissionDetail_Group `protobuf:"bytes,2,opt,name=group,proto3,oneof" json:"group,omitempty"`
}

func (*PermissionDetail_Group_) Equal

func (this *PermissionDetail_Group_) Equal(that interface{}) bool

func (*PermissionDetail_Group_) MarshalTo

func (m *PermissionDetail_Group_) MarshalTo(dAtA []byte) (int, error)

func (*PermissionDetail_Group_) MarshalToSizedBuffer

func (m *PermissionDetail_Group_) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*PermissionDetail_Group_) Size

func (m *PermissionDetail_Group_) Size() (n int)

type PermissionDetail_User

type PermissionDetail_User struct {
	// User for which the permission was set
	User string `protobuf:"bytes,1,opt,name=user,proto3" json:"user,omitempty" yaml:"user"`
	// Permission set to the user
	Permission uint32 `protobuf:"varint,2,opt,name=permission,proto3" json:"permission,omitempty" yaml:"permission"`
}

User is a permission that has been set to a specific user

func (*PermissionDetail_User) Descriptor

func (*PermissionDetail_User) Descriptor() ([]byte, []int)

func (*PermissionDetail_User) Equal

func (this *PermissionDetail_User) Equal(that interface{}) bool

func (*PermissionDetail_User) Marshal

func (m *PermissionDetail_User) Marshal() (dAtA []byte, err error)

func (*PermissionDetail_User) MarshalTo

func (m *PermissionDetail_User) MarshalTo(dAtA []byte) (int, error)

func (*PermissionDetail_User) MarshalToSizedBuffer

func (m *PermissionDetail_User) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*PermissionDetail_User) ProtoMessage

func (*PermissionDetail_User) ProtoMessage()

func (*PermissionDetail_User) Reset

func (m *PermissionDetail_User) Reset()

func (*PermissionDetail_User) Size

func (m *PermissionDetail_User) Size() (n int)

func (*PermissionDetail_User) String

func (m *PermissionDetail_User) String() string

func (*PermissionDetail_User) Unmarshal

func (m *PermissionDetail_User) Unmarshal(dAtA []byte) error

func (*PermissionDetail_User) XXX_DiscardUnknown

func (m *PermissionDetail_User) XXX_DiscardUnknown()

func (*PermissionDetail_User) XXX_Marshal

func (m *PermissionDetail_User) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*PermissionDetail_User) XXX_Merge

func (m *PermissionDetail_User) XXX_Merge(src proto.Message)

func (*PermissionDetail_User) XXX_Size

func (m *PermissionDetail_User) XXX_Size() int

func (*PermissionDetail_User) XXX_Unmarshal

func (m *PermissionDetail_User) XXX_Unmarshal(b []byte) error

type PermissionDetail_User_

type PermissionDetail_User_ struct {
	User *PermissionDetail_User `protobuf:"bytes,1,opt,name=user,proto3,oneof" json:"user,omitempty"`
}

func (*PermissionDetail_User_) Equal

func (this *PermissionDetail_User_) Equal(that interface{}) bool

func (*PermissionDetail_User_) MarshalTo

func (m *PermissionDetail_User_) MarshalTo(dAtA []byte) (int, error)

func (*PermissionDetail_User_) MarshalToSizedBuffer

func (m *PermissionDetail_User_) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*PermissionDetail_User_) Size

func (m *PermissionDetail_User_) Size() (n int)

type Subspace

type Subspace struct {
	// Unique id that identifies the subspace
	ID uint64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty" yaml:"id"`
	// Human-readable name of the subspace
	Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty" yaml:"name"`
	// Optional description of this subspace
	Description string `protobuf:"bytes,3,opt,name=description,proto3" json:"description,omitempty" yaml:"description"`
	// Represents the account that is associated with the subspace and
	// should be used to connect external applications to verify this subspace
	Treasury string `protobuf:"bytes,4,opt,name=treasury,proto3" json:"treasury,omitempty" yaml:"treasury"`
	// Address of the user that owns the subspace
	Owner string `protobuf:"bytes,5,opt,name=owner,proto3" json:"owner,omitempty" yaml:"owner"`
	// Address of the subspace creator
	Creator string `protobuf:"bytes,6,opt,name=creator,proto3" json:"creator,omitempty" yaml:"creator"`
	// the creation time of the subspace
	CreationTime time.Time `protobuf:"bytes,7,opt,name=creation_time,json=creationTime,proto3,stdtime" json:"creation_time" yaml:"creation_time"`
}

Subspace contains all the data of a Desmos subspace

func (*Subspace) Descriptor

func (*Subspace) Descriptor() ([]byte, []int)

func (*Subspace) Equal

func (this *Subspace) Equal(that interface{}) bool

func (*Subspace) GetCreationTime

func (m *Subspace) GetCreationTime() time.Time

func (*Subspace) GetCreator

func (m *Subspace) GetCreator() string

func (*Subspace) GetDescription

func (m *Subspace) GetDescription() string

func (*Subspace) GetID

func (m *Subspace) GetID() uint64

func (*Subspace) GetName

func (m *Subspace) GetName() string

func (*Subspace) GetOwner

func (m *Subspace) GetOwner() string

func (*Subspace) GetTreasury

func (m *Subspace) GetTreasury() string

func (*Subspace) Marshal

func (m *Subspace) Marshal() (dAtA []byte, err error)

func (*Subspace) MarshalTo

func (m *Subspace) MarshalTo(dAtA []byte) (int, error)

func (*Subspace) MarshalToSizedBuffer

func (m *Subspace) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*Subspace) ProtoMessage

func (*Subspace) ProtoMessage()

func (*Subspace) Reset

func (m *Subspace) Reset()

func (*Subspace) Size

func (m *Subspace) Size() (n int)

func (*Subspace) String

func (m *Subspace) String() string

func (*Subspace) Unmarshal

func (m *Subspace) Unmarshal(dAtA []byte) error

func (*Subspace) XXX_DiscardUnknown

func (m *Subspace) XXX_DiscardUnknown()

func (*Subspace) XXX_Marshal

func (m *Subspace) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*Subspace) XXX_Merge

func (m *Subspace) XXX_Merge(src proto.Message)

func (*Subspace) XXX_Size

func (m *Subspace) XXX_Size() int

func (*Subspace) XXX_Unmarshal

func (m *Subspace) XXX_Unmarshal(b []byte) error

type UserGroup

type UserGroup struct {
	// ID of the subspace inside which this group exists
	SubspaceID uint64 `protobuf:"varint,1,opt,name=subspace_id,json=subspaceId,proto3" json:"subspace_id,omitempty" yaml:"subspace_id"`
	// Unique id that identifies the group
	ID uint32 `protobuf:"varint,2,opt,name=id,proto3" json:"id,omitempty" yaml:"id"`
	// Human-readable name of the user group
	Name string `protobuf:"bytes,3,opt,name=name,proto3" json:"name,omitempty" yaml:"name"`
	// Optional description of this group
	Description string `protobuf:"bytes,4,opt,name=description,proto3" json:"description,omitempty" yaml:"description"`
	// Permissions that will be granted to all the users part of this group
	Permissions uint32 `protobuf:"varint,5,opt,name=permissions,proto3" json:"permissions,omitempty" yaml:"permissions"`
}

UserGroup represents a group of users

func NewUserGroup

func NewUserGroup(subspaceID uint64, id uint32, name, description string, permissions Permission) UserGroup

NewUserGroup returns a new UserGroup instance

func (*UserGroup) Descriptor

func (*UserGroup) Descriptor() ([]byte, []int)

func (*UserGroup) Equal

func (this *UserGroup) Equal(that interface{}) bool

func (*UserGroup) GetDescription

func (m *UserGroup) GetDescription() string

func (*UserGroup) GetID

func (m *UserGroup) GetID() uint32

func (*UserGroup) GetName

func (m *UserGroup) GetName() string

func (*UserGroup) GetPermissions

func (m *UserGroup) GetPermissions() uint32

func (*UserGroup) GetSubspaceID

func (m *UserGroup) GetSubspaceID() uint64

func (*UserGroup) Marshal

func (m *UserGroup) Marshal() (dAtA []byte, err error)

func (*UserGroup) MarshalTo

func (m *UserGroup) MarshalTo(dAtA []byte) (int, error)

func (*UserGroup) MarshalToSizedBuffer

func (m *UserGroup) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*UserGroup) ProtoMessage

func (*UserGroup) ProtoMessage()

func (*UserGroup) Reset

func (m *UserGroup) Reset()

func (*UserGroup) Size

func (m *UserGroup) Size() (n int)

func (*UserGroup) String

func (m *UserGroup) String() string

func (*UserGroup) Unmarshal

func (m *UserGroup) Unmarshal(dAtA []byte) error

func (*UserGroup) XXX_DiscardUnknown

func (m *UserGroup) XXX_DiscardUnknown()

func (*UserGroup) XXX_Marshal

func (m *UserGroup) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*UserGroup) XXX_Merge

func (m *UserGroup) XXX_Merge(src proto.Message)

func (*UserGroup) XXX_Size

func (m *UserGroup) XXX_Size() int

func (*UserGroup) XXX_Unmarshal

func (m *UserGroup) XXX_Unmarshal(b []byte) error

Jump to

Keyboard shortcuts

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