types

package
v0.47.14 Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ModuleName defines the module name
	ModuleName = "capability"

	// StoreKey defines the primary module store key
	StoreKey = ModuleName

	// MemStoreKey defines the in-memory store key
	MemStoreKey = "memory:capability"
)
View Source
const DefaultIndex uint64 = 1

DefaultIndex is the default capability global index

Variables

View Source
var (
	ErrInvalidLengthCapability        = fmt.Errorf("proto: negative length found during unmarshaling")
	ErrIntOverflowCapability          = fmt.Errorf("proto: integer overflow")
	ErrUnexpectedEndOfGroupCapability = fmt.Errorf("proto: unexpected end of group")
)
View Source
var (
	ErrInvalidCapabilityName    = sdkerrors.Register(ModuleName, 2, "capability name not valid")
	ErrNilCapability            = sdkerrors.Register(ModuleName, 3, "provided capability is nil")
	ErrCapabilityTaken          = sdkerrors.Register(ModuleName, 4, "capability name already taken")
	ErrOwnerClaimed             = sdkerrors.Register(ModuleName, 5, "given owner already claimed capability")
	ErrCapabilityNotOwned       = sdkerrors.Register(ModuleName, 6, "capability not owned by module")
	ErrCapabilityNotFound       = sdkerrors.Register(ModuleName, 7, "capability not found")
	ErrCapabilityOwnersNotFound = sdkerrors.Register(ModuleName, 8, "owners not found for capability")
)

x/capability module sentinel errors

View Source
var (
	ErrInvalidLengthGenesis        = fmt.Errorf("proto: negative length found during unmarshaling")
	ErrIntOverflowGenesis          = fmt.Errorf("proto: integer overflow")
	ErrUnexpectedEndOfGroupGenesis = fmt.Errorf("proto: unexpected end of group")
)
View Source
var (
	// KeyIndex defines the key that stores the current globally unique capability
	// index.
	KeyIndex = []byte("index")

	// KeyPrefixIndexCapability defines a key prefix that stores index to capability
	// owners mappings.
	KeyPrefixIndexCapability = []byte("capability_index")

	// KeyMemInitialized defines the key that stores the initialized flag in the memory store
	KeyMemInitialized = []byte("mem_initialized")
)

Functions

func FwdCapabilityKey

func FwdCapabilityKey(module string, cap *Capability) []byte

FwdCapabilityKey returns a forward lookup key for a given module and capability reference.

func IndexFromKey

func IndexFromKey(key []byte) uint64

IndexFromKey returns an index from a call to IndexToKey for a given capability index.

func IndexToKey

func IndexToKey(index uint64) []byte

IndexToKey returns bytes to be used as a key for a given capability index.

func RevCapabilityKey

func RevCapabilityKey(module, name string) []byte

RevCapabilityKey returns a reverse lookup key for a given module and capability name.

Types

type Capability

type Capability struct {
	Index uint64 `protobuf:"varint,1,opt,name=index,proto3" json:"index,omitempty"`
}

Capability defines an implementation of an object capability. The index provided to a Capability must be globally unique.

func NewCapability

func NewCapability(index uint64) *Capability

NewCapability returns a reference to a new Capability to be used as an actual capability.

func (*Capability) Descriptor

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

func (*Capability) GetIndex

func (m *Capability) GetIndex() uint64

func (*Capability) Marshal

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

func (*Capability) MarshalTo

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

func (*Capability) MarshalToSizedBuffer

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

func (*Capability) ProtoMessage

func (*Capability) ProtoMessage()

func (*Capability) Reset

func (m *Capability) Reset()

func (*Capability) Size

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

func (*Capability) String

func (ck *Capability) String() string

String returns the string representation of a Capability. The string contains the Capability's memory reference as the string is to be used in a composite key and to authenticate capabilities.

func (*Capability) Unmarshal

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

func (*Capability) XXX_DiscardUnknown

func (m *Capability) XXX_DiscardUnknown()

func (*Capability) XXX_Marshal

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

func (*Capability) XXX_Merge

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

func (*Capability) XXX_Size

func (m *Capability) XXX_Size() int

func (*Capability) XXX_Unmarshal

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

type CapabilityOwners

type CapabilityOwners struct {
	Owners []Owner `protobuf:"bytes,1,rep,name=owners,proto3" json:"owners"`
}

CapabilityOwners defines a set of owners of a single Capability. The set of owners must be unique.

func NewCapabilityOwners

func NewCapabilityOwners() *CapabilityOwners

func (*CapabilityOwners) Descriptor

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

func (*CapabilityOwners) Get

func (co *CapabilityOwners) Get(owner Owner) (int, bool)

Get returns (i, true) of the provided owner in the CapabilityOwners if the owner exists, where i indicates the owner's index in the set. Otherwise (i, false) where i indicates where in the set the owner should be added.

func (*CapabilityOwners) GetOwners

func (m *CapabilityOwners) GetOwners() []Owner

func (*CapabilityOwners) Marshal

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

func (*CapabilityOwners) MarshalTo

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

func (*CapabilityOwners) MarshalToSizedBuffer

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

func (*CapabilityOwners) ProtoMessage

func (*CapabilityOwners) ProtoMessage()

func (*CapabilityOwners) Remove

func (co *CapabilityOwners) Remove(owner Owner)

Remove removes a provided owner from the CapabilityOwners if it exists. If the owner does not exist, Remove is considered a no-op.

func (*CapabilityOwners) Reset

func (m *CapabilityOwners) Reset()

func (*CapabilityOwners) Set

func (co *CapabilityOwners) Set(owner Owner) error

Set attempts to add a given owner to the CapabilityOwners. If the owner already exists, an error will be returned. Set runs in O(log n) average time and O(n) in the worst case.

func (*CapabilityOwners) Size

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

func (*CapabilityOwners) String

func (m *CapabilityOwners) String() string

func (*CapabilityOwners) Unmarshal

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

func (*CapabilityOwners) XXX_DiscardUnknown

func (m *CapabilityOwners) XXX_DiscardUnknown()

func (*CapabilityOwners) XXX_Marshal

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

func (*CapabilityOwners) XXX_Merge

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

func (*CapabilityOwners) XXX_Size

func (m *CapabilityOwners) XXX_Size() int

func (*CapabilityOwners) XXX_Unmarshal

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

type GenesisOwners

type GenesisOwners struct {
	// index is the index of the capability owner.
	Index uint64 `protobuf:"varint,1,opt,name=index,proto3" json:"index,omitempty"`
	// index_owners are the owners at the given index.
	IndexOwners CapabilityOwners `protobuf:"bytes,2,opt,name=index_owners,json=indexOwners,proto3" json:"index_owners"`
}

GenesisOwners defines the capability owners with their corresponding index.

func (*GenesisOwners) Descriptor added in v0.40.0

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

func (*GenesisOwners) GetIndex added in v0.40.0

func (m *GenesisOwners) GetIndex() uint64

func (*GenesisOwners) GetIndexOwners added in v0.40.0

func (m *GenesisOwners) GetIndexOwners() CapabilityOwners

func (*GenesisOwners) Marshal added in v0.40.0

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

func (*GenesisOwners) MarshalTo added in v0.40.0

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

func (*GenesisOwners) MarshalToSizedBuffer added in v0.40.0

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

func (*GenesisOwners) ProtoMessage added in v0.40.0

func (*GenesisOwners) ProtoMessage()

func (*GenesisOwners) Reset added in v0.40.0

func (m *GenesisOwners) Reset()

func (*GenesisOwners) Size added in v0.40.0

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

func (*GenesisOwners) String added in v0.40.0

func (m *GenesisOwners) String() string

func (*GenesisOwners) Unmarshal added in v0.40.0

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

func (*GenesisOwners) XXX_DiscardUnknown added in v0.40.0

func (m *GenesisOwners) XXX_DiscardUnknown()

func (*GenesisOwners) XXX_Marshal added in v0.40.0

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

func (*GenesisOwners) XXX_Merge added in v0.40.0

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

func (*GenesisOwners) XXX_Size added in v0.40.0

func (m *GenesisOwners) XXX_Size() int

func (*GenesisOwners) XXX_Unmarshal added in v0.40.0

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

type GenesisState

type GenesisState struct {
	// index is the capability global index.
	Index uint64 `protobuf:"varint,1,opt,name=index,proto3" json:"index,omitempty"`
	// owners represents a map from index to owners of the capability index
	// index key is string to allow amino marshalling.
	Owners []GenesisOwners `protobuf:"bytes,2,rep,name=owners,proto3" json:"owners"`
}

GenesisState defines the capability module's genesis state.

func DefaultGenesis

func DefaultGenesis() *GenesisState

DefaultGenesis returns the default Capability genesis state

func (*GenesisState) Descriptor added in v0.40.0

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

func (*GenesisState) GetIndex added in v0.40.0

func (m *GenesisState) GetIndex() uint64

func (*GenesisState) GetOwners added in v0.40.0

func (m *GenesisState) GetOwners() []GenesisOwners

func (*GenesisState) Marshal added in v0.40.0

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

func (*GenesisState) MarshalTo added in v0.40.0

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

func (*GenesisState) MarshalToSizedBuffer added in v0.40.0

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

func (*GenesisState) ProtoMessage added in v0.40.0

func (*GenesisState) ProtoMessage()

func (*GenesisState) Reset added in v0.40.0

func (m *GenesisState) Reset()

func (*GenesisState) Size added in v0.40.0

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

func (*GenesisState) String added in v0.40.0

func (m *GenesisState) String() string

func (*GenesisState) Unmarshal added in v0.40.0

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

func (GenesisState) Validate

func (gs GenesisState) Validate() error

Validate performs basic genesis state validation returning an error upon any failure.

func (*GenesisState) XXX_DiscardUnknown added in v0.40.0

func (m *GenesisState) XXX_DiscardUnknown()

func (*GenesisState) XXX_Marshal added in v0.40.0

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

func (*GenesisState) XXX_Merge added in v0.40.0

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

func (*GenesisState) XXX_Size added in v0.40.0

func (m *GenesisState) XXX_Size() int

func (*GenesisState) XXX_Unmarshal added in v0.40.0

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

type Owner

type Owner struct {
	Module string `protobuf:"bytes,1,opt,name=module,proto3" json:"module,omitempty"`
	Name   string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"`
}

Owner defines a single capability owner. An owner is defined by the name of capability and the module name.

func NewOwner

func NewOwner(module, name string) Owner

func (*Owner) Descriptor

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

func (Owner) Key

func (o Owner) Key() string

Key returns a composite key for an Owner.

func (*Owner) Marshal

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

func (*Owner) MarshalTo

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

func (*Owner) MarshalToSizedBuffer

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

func (*Owner) ProtoMessage

func (*Owner) ProtoMessage()

func (*Owner) Reset

func (m *Owner) Reset()

func (*Owner) Size

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

func (Owner) String

func (o Owner) String() string

func (*Owner) Unmarshal

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

func (*Owner) XXX_DiscardUnknown

func (m *Owner) XXX_DiscardUnknown()

func (*Owner) XXX_Marshal

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

func (*Owner) XXX_Merge

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

func (*Owner) XXX_Size

func (m *Owner) XXX_Size() int

func (*Owner) XXX_Unmarshal

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

Jump to

Keyboard shortcuts

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