Documentation ¶
Index ¶
- Constants
- Variables
- func GetOrganizationKey(orgAddr sdk.AccAddress) []byte
- func GetProductKey(productName string) []byte
- func GetUnitKeyFromProductAndUnitNumber(productName string, unitNumber uint) []byte
- func GetUnitKeyFromReference(reference string) []byte
- func GetUnitReferenceFromProductAndUnitNumber(productName string, unitNumber uint) (string, error)
- func MustMarshalOrganization(cdc *codec.Codec, o Organization) []byte
- func MustMarshalProduct(cdc *codec.Codec, p Product) []byte
- func MustMarshalUnit(cdc *codec.Codec, u Unit) []byte
- func RegisterCodec(cdc *codec.Codec)
- func ValidateGenesis(data GenesisState) error
- type GenesisState
- type MsgAppendOrganization
- type MsgChangeOrganizationApproval
- func (msg MsgChangeOrganizationApproval) GetSignBytes() []byte
- func (msg MsgChangeOrganizationApproval) GetSigners() []sdk.AccAddress
- func (msg MsgChangeOrganizationApproval) Route() string
- func (msg MsgChangeOrganizationApproval) Type() string
- func (msg MsgChangeOrganizationApproval) ValidateBasic() error
- type MsgCreateProduct
- type MsgCreateUnit
- type MsgTransferUnit
- type Organization
- type PoaKeeper
- type Product
- type QueryOrganizationParams
- type QueryProductParams
- type QueryUnitParams
- type Unit
- func (u *Unit) ChangeHolder(newHolder sdk.AccAddress)
- func (u Unit) GetComponentOf() string
- func (u Unit) GetComponents() []string
- func (u Unit) GetCurrentHolder() sdk.AccAddress
- func (u Unit) GetDetails() string
- func (u Unit) GetHolderHistrory() []sdk.AccAddress
- func (u Unit) GetProductName() string
- func (u Unit) GetReference() string
- func (u Unit) IsComponentOf() bool
- func (u Unit) Validate() error
Constants ¶
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
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 )
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
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 )
const AppendOrganizationConst = "AppendOrganization"
const ChangeOrganizationApprovalConst = "ChangeOrganizationApproval"
const CreateProductConst = "CreateProduct"
const CreateUnitConst = "CreateUnit"
const TransferUnitConst = "TransferUnit"
Variables ¶
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") )
var ( // Prefix for each key to an organization OrganizationsKey = []byte{0x21} // Products prefix ProductsKey = []byte{0x22} // Units prefix UnitsKey = []byte{0x22} )
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 ¶
Get the key for the products with the product name
func GetUnitKeyFromProductAndUnitNumber ¶
Get the key for the unit from the product name and the unit number
func GetUnitKeyFromReference ¶
Get the key for the unit from its reference
func GetUnitReferenceFromProductAndUnitNumber ¶
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 ¶
Encoding functions
func RegisterCodec ¶
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) 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 ¶
func (msg MsgChangeOrganizationApproval) Route() string
nolint
func (MsgChangeOrganizationApproval) Type ¶
func (msg MsgChangeOrganizationApproval) Type() string
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) 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) 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) 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 NewProduct ¶
func NewProduct(m sdk.AccAddress, name, description string) Product
func UnmarshalProduct ¶
func (Product) GetDescription ¶
func (Product) GetManufacturer ¶
func (p Product) GetManufacturer() sdk.AccAddress
func (Product) GetUnitCount ¶
func (*Product) IncreaseUnit ¶
func (p *Product) IncreaseUnit()
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 (Unit) GetComponentOf ¶
func (Unit) GetComponents ¶
func (Unit) GetCurrentHolder ¶
func (u Unit) GetCurrentHolder() sdk.AccAddress
func (Unit) GetDetails ¶
func (Unit) GetHolderHistrory ¶
func (u Unit) GetHolderHistrory() []sdk.AccAddress