types

package
v0.0.0-...-6bfe187 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2020 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EventTypeAppendOrganization    = "append_organization"
	EventTypeRelegateOrganization  = "relegate_organization"
	EventTypeReapproveOrganization = "reapprove_organization"
	EventTypeCreateProduct         = "create_product"
	EventTypeCreateUnit            = "create_unit"
	EventTypeTransferUnit          = "transfer_unit"

	AttributeKeyAuthority           = "authority"
	AttributeKeyOrganizationAddress = "organization_address"
	AttributeKeyOrganizationName    = "organization_name"
	AttributeKeyManufacturer        = "manufacturer"
	AttributeKeyProduct             = "product"
	AttributeKeyReference           = "reference"
	AttributeKeyFrom                = "from"
	AttributeKeyTo                  = "to"

	AttributeValueCategory = ModuleName
)

scx module event types

View Source
const (
	// ModuleName is the name of the module
	ModuleName = "scx"

	// StoreKey to be used when creating the KVStore
	StoreKey = ModuleName

	// RouterKey to be used for routing msgs
	RouterKey = ModuleName

	// QuerierRoute to be used for querier msgs
	QuerierRoute = ModuleName
)
View Source
const (
	QueryOrganizations  = "organizations"
	QueryOrganization   = "organization"
	QueryProduct        = "product"
	QueryProductUnits   = "product-units"
	QueryUnit           = "unit"
	QueryUnitTrace      = "unit-trace"
	QueryUnitComponents = "unit-components"
)

Query endpoints supported by the scx querier

View Source
const (
	// The size of a unit reference (here the 16 first bytes of the unit hash)
	UnitReferenceLength = 32

	// Maximum number of components in a unit
	ComponentsMaxNumber = 50
)
View Source
const AppendOrganizationConst = "AppendOrganization"
View Source
const ChangeOrganizationApprovalConst = "ChangeOrganizationApproval"
View Source
const CreateProductConst = "CreateProduct"
View Source
const CreateUnitConst = "CreateUnit"
View Source
const TransferUnitConst = "TransferUnit"

Variables

View Source
var (
	ErrInvalidOrganization          = sdkerrors.Register(ModuleName, 1, "invalid organization")
	ErrNotAnAuthority               = sdkerrors.Register(ModuleName, 2, "sender is not an authority")
	ErrOrganizationAlreadyExists    = sdkerrors.Register(ModuleName, 3, "organization already exists")
	ErrOrganizationNotFound         = sdkerrors.Register(ModuleName, 4, "organization not found")
	ErrOrganizationAlreadyApproved  = sdkerrors.Register(ModuleName, 5, "organization already approved")
	ErrOrganizationAlreadyRelegated = sdkerrors.Register(ModuleName, 6, "organization already relegated")
	ErrInvalidProduct               = sdkerrors.Register(ModuleName, 7, "invalid product")
	ErrOrganizationNotApproved      = sdkerrors.Register(ModuleName, 8, "the organization is not approved")
	ErrProductAlreadyExist          = sdkerrors.Register(ModuleName, 9, "the product already exist")
	ErrInvalidUnit                  = sdkerrors.Register(ModuleName, 10, "invalid unit")
	ErrInvalidTransfer              = sdkerrors.Register(ModuleName, 11, "invalid transfer")
	ErrUnitNotFound                 = sdkerrors.Register(ModuleName, 12, "unit not found")
	ErrUnitComponentOfAnotherUnit   = sdkerrors.Register(ModuleName, 13, "unit the unit is component of another unit")
	ErrComponentOfNotFound          = sdkerrors.Register(ModuleName, 14, "the component reference has been not found")
	ErrProductNotFound              = sdkerrors.Register(ModuleName, 15, "product not found")
	ErrComponentNotOwned            = sdkerrors.Register(ModuleName, 16, "component is not owned by the manufacturer")
	ErrUnitNotOwned                 = sdkerrors.Register(ModuleName, 17, "unit is not owned by the holder")
)
View Source
var (
	// Prefix for each key to an organization
	OrganizationsKey = []byte{0x21}

	// Products prefix
	ProductsKey = []byte{0x22}

	// Units prefix
	UnitsKey = []byte{0x22}
)
View Source
var ModuleCdc *codec.Codec

ModuleCdc defines the module codec

Functions

func GetOrganizationKey

func GetOrganizationKey(orgAddr sdk.AccAddress) []byte

Get the key for the organization with address

func GetProductKey

func GetProductKey(productName string) []byte

Get the key for the products with the product name

func GetUnitKeyFromProductAndUnitNumber

func GetUnitKeyFromProductAndUnitNumber(productName string, unitNumber uint) []byte

Get the key for the unit from the product name and the unit number

func GetUnitKeyFromReference

func GetUnitKeyFromReference(reference string) []byte

Get the key for the unit from its reference

func GetUnitReferenceFromProductAndUnitNumber

func GetUnitReferenceFromProductAndUnitNumber(productName string, unitNumber uint) (string, error)

Get the unit reference from the product name and its number The reference are the first bytes of the sha 256 hash of the product name associated with the unit number

func MustMarshalOrganization

func MustMarshalOrganization(cdc *codec.Codec, o Organization) []byte

Encoding functions

func MustMarshalProduct

func MustMarshalProduct(cdc *codec.Codec, p Product) []byte

Encoding functions

func MustMarshalUnit

func MustMarshalUnit(cdc *codec.Codec, u Unit) []byte

Encoding functions

func RegisterCodec

func RegisterCodec(cdc *codec.Codec)

RegisterCodec registers concrete types on codec

func ValidateGenesis

func ValidateGenesis(data GenesisState) error

ValidateGenesis validates the scx genesis parameters

Types

type GenesisState

type GenesisState struct {
}

GenesisState - all scx state that must be provided at genesis

func DefaultGenesisState

func DefaultGenesisState() GenesisState

DefaultGenesisState - default GenesisState used by Cosmos Hub

func NewGenesisState

func NewGenesisState() GenesisState

NewGenesisState creates a new GenesisState object

type MsgAppendOrganization

type MsgAppendOrganization struct {
	Organization Organization   `json:"organization"`
	Authority    sdk.ValAddress `json:"authority"`
}

*

  • MsgAppendOrganization

func NewMsgAppendOrganization

func NewMsgAppendOrganization(organization Organization, authority sdk.ValAddress) MsgAppendOrganization

func (MsgAppendOrganization) GetSignBytes

func (msg MsgAppendOrganization) GetSignBytes() []byte

GetSignBytes gets the bytes for the message signer to sign on

func (MsgAppendOrganization) GetSigners

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

func (MsgAppendOrganization) Route

func (msg MsgAppendOrganization) Route() string

nolint

func (MsgAppendOrganization) Type

func (msg MsgAppendOrganization) Type() string

func (MsgAppendOrganization) ValidateBasic

func (msg MsgAppendOrganization) ValidateBasic() error

ValidateBasic validity check for the AnteHandler

type MsgChangeOrganizationApproval

type MsgChangeOrganizationApproval struct {
	Organization sdk.AccAddress `json:"organization"`
	Authority    sdk.ValAddress `json:"authority"`
	Approve      bool           `json:approve"`
}

*

  • MsgChangeOrganizationApproval

func NewMsgChangeOrganizationApproval

func NewMsgChangeOrganizationApproval(organization sdk.AccAddress, authority sdk.ValAddress, approve bool) MsgChangeOrganizationApproval

func (MsgChangeOrganizationApproval) GetSignBytes

func (msg MsgChangeOrganizationApproval) GetSignBytes() []byte

GetSignBytes gets the bytes for the message signer to sign on

func (MsgChangeOrganizationApproval) GetSigners

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

func (MsgChangeOrganizationApproval) Route

nolint

func (MsgChangeOrganizationApproval) Type

func (MsgChangeOrganizationApproval) ValidateBasic

func (msg MsgChangeOrganizationApproval) ValidateBasic() error

ValidateBasic validity check for the AnteHandler

type MsgCreateProduct

type MsgCreateProduct struct {
	Product Product `json:"product"`
}

*

  • MsgCreateProduct

func NewMsgCreateProduct

func NewMsgCreateProduct(product Product) MsgCreateProduct

func (MsgCreateProduct) GetSignBytes

func (msg MsgCreateProduct) GetSignBytes() []byte

GetSignBytes gets the bytes for the message signer to sign on

func (MsgCreateProduct) GetSigners

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

func (MsgCreateProduct) Route

func (msg MsgCreateProduct) Route() string

nolint

func (MsgCreateProduct) Type

func (msg MsgCreateProduct) Type() string

func (MsgCreateProduct) ValidateBasic

func (msg MsgCreateProduct) ValidateBasic() error

ValidateBasic validity check for the AnteHandler

type MsgCreateUnit

type MsgCreateUnit struct {
	ProductName  string         `json:"product_name"`
	Manufacturer sdk.AccAddress `json:"manufacturer"`
	Details      string         `json:"details"`
	Components   []string       `json:"components"`
}

*

  • MsgCreateUnit

func NewMsgCreateUnit

func NewMsgCreateUnit(productName string, manufacturer sdk.AccAddress, details string, components []string) MsgCreateUnit

func (MsgCreateUnit) GetSignBytes

func (msg MsgCreateUnit) GetSignBytes() []byte

GetSignBytes gets the bytes for the message signer to sign on

func (MsgCreateUnit) GetSigners

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

func (MsgCreateUnit) Route

func (msg MsgCreateUnit) Route() string

nolint

func (MsgCreateUnit) Type

func (msg MsgCreateUnit) Type() string

func (MsgCreateUnit) ValidateBasic

func (msg MsgCreateUnit) ValidateBasic() error

ValidateBasic validity check for the AnteHandler

type MsgTransferUnit

type MsgTransferUnit struct {
	UnitReference string         `json:"unit_reference"`
	Holder        sdk.AccAddress `json:"holder"`
	NewHolder     sdk.AccAddress `json:"new_holder"`
}

*

  • MsgTransferUnit

func NewMsgTransferUnit

func NewMsgTransferUnit(unitReference string, currentHolder sdk.AccAddress, newHolder sdk.AccAddress) MsgTransferUnit

func (MsgTransferUnit) GetSignBytes

func (msg MsgTransferUnit) GetSignBytes() []byte

GetSignBytes gets the bytes for the message signer to sign on

func (MsgTransferUnit) GetSigners

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

func (MsgTransferUnit) Route

func (msg MsgTransferUnit) Route() string

nolint

func (MsgTransferUnit) Type

func (msg MsgTransferUnit) Type() string

func (MsgTransferUnit) ValidateBasic

func (msg MsgTransferUnit) ValidateBasic() error

ValidateBasic validity check for the AnteHandler

type Organization

type Organization struct {
	Address     sdk.AccAddress `json:"address"`
	Name        string         `json:"name"`
	Description string         `json:"description"`
	Approved    bool           `json:"approved"`
}

Organizations are the entities that can create new products and units

func MustUnmarshalOrganization

func MustUnmarshalOrganization(cdc *codec.Codec, value []byte) Organization

func NewOrganization

func NewOrganization(address sdk.AccAddress, name, description string) Organization

func UnmarshalOrganization

func UnmarshalOrganization(cdc *codec.Codec, value []byte) (o Organization, err error)

func (*Organization) Approve

func (o *Organization) Approve()

func (Organization) GetAddress

func (o Organization) GetAddress() sdk.AccAddress

func (Organization) GetDescription

func (o Organization) GetDescription() string

func (Organization) GetName

func (o Organization) GetName() string

func (Organization) IsApproved

func (o Organization) IsApproved() bool

func (*Organization) Relegate

func (o *Organization) Relegate()

type PoaKeeper

type PoaKeeper interface {
	GetValidator(ctx sdk.Context, addr sdk.ValAddress) (validator poatypes.Validator, found bool)
}

We use the PoaKeeper to verify if a regulator is a validator in the system

type Product

type Product struct {
	Name         string         `json:"name"`
	Description  string         `json:"description"`
	Manufacturer sdk.AccAddress `json:"manufacturer"`
	UnitCount    uint64         `json:"count"`
}

Describes a product

func MustUnmarshalProduct

func MustUnmarshalProduct(cdc *codec.Codec, value []byte) Product

func NewProduct

func NewProduct(m sdk.AccAddress, name, description string) Product

func UnmarshalProduct

func UnmarshalProduct(cdc *codec.Codec, value []byte) (p Product, err error)

func (Product) GetDescription

func (p Product) GetDescription() string

func (Product) GetManufacturer

func (p Product) GetManufacturer() sdk.AccAddress

func (Product) GetName

func (p Product) GetName() string

func (Product) GetUnitCount

func (p Product) GetUnitCount() uint64

func (*Product) IncreaseUnit

func (p *Product) IncreaseUnit()

func (Product) Validate

func (p Product) Validate() error

type QueryOrganizationParams

type QueryOrganizationParams struct {
	OrganizationAddr sdk.AccAddress
}

Defines the params for the following querie: - 'custom/scx/organization'

func NewQueryOrganizationParams

func NewQueryOrganizationParams(organizationAddr sdk.AccAddress) QueryOrganizationParams

type QueryProductParams

type QueryProductParams struct {
	ProductName string
}

Defines the params for the following querie: - 'custom/scx/product' - 'custom/scx/product-units'

func NewQueryProductParams

func NewQueryProductParams(productName string) QueryProductParams

type QueryUnitParams

type QueryUnitParams struct {
	UnitReference string
}

Defines the params for the following querie: - 'custom/scx/unit' - 'custom/scx/unit-trace' - 'custom/scx/unit-components'

func NewQueryUnitParams

func NewQueryUnitParams(unitReference string) QueryUnitParams

type Unit

type Unit struct {
	Reference     string           `json:"reference"`
	Product       string           `json:"product"`
	Details       string           `json:"details"`
	Components    []string         `json:"components"`
	Holder        sdk.AccAddress   `json:"holder"`
	HolderHistory []sdk.AccAddress `json:"holder_history"`
	ComponentOf   string           `json:"component_of"`
}

Describes the unit of a product

func MustUnmarshalUnit

func MustUnmarshalUnit(cdc *codec.Codec, value []byte) Unit

func NewUnit

func NewUnit(reference string, product Product, details string, components []string) Unit

func UnmarshalUnit

func UnmarshalUnit(cdc *codec.Codec, value []byte) (u Unit, err error)

func (*Unit) ChangeHolder

func (u *Unit) ChangeHolder(newHolder sdk.AccAddress)

Change holder

func (Unit) GetComponentOf

func (u Unit) GetComponentOf() string

func (Unit) GetComponents

func (u Unit) GetComponents() []string

func (Unit) GetCurrentHolder

func (u Unit) GetCurrentHolder() sdk.AccAddress

func (Unit) GetDetails

func (u Unit) GetDetails() string

func (Unit) GetHolderHistrory

func (u Unit) GetHolderHistrory() []sdk.AccAddress

func (Unit) GetProductName

func (u Unit) GetProductName() string

func (Unit) GetReference

func (u Unit) GetReference() string

Accessors

func (Unit) IsComponentOf

func (u Unit) IsComponentOf() bool

func (Unit) Validate

func (u Unit) Validate() error

Check unit structure validity

Jump to

Keyboard shortcuts

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