types

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Feb 11, 2020 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CodeInvalidGenesis                = 101
	CodePurchaseOrderDoesNotExist     = 102
	CodePurchaseOrderAlreadyProcessed = 103
	CodeInvalidDecision               = 104
	CodeInvalidDenomination           = 105
	CodeInvalidStatus                 = 106
	CodePurchaseOrderNotRaised        = 107
	CodeSignerAlreadyMadeDecision     = 108
	CodeMissingData                   = 109
	CodeDataInvalid                   = 110
)
View Source
const (
	// module name
	ModuleName = "enterprise"

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

	DefaultParamspace = ModuleName

	// QuerierRoute is the querier route for the enterprise store.
	QuerierRoute = StoreKey
)
View Source
const (
	RouterKey = ModuleName // defined in keys.go file

	PurchaseAction = "raise_enterprise_purchase_order"
	ProcessAction  = "process_enterprise_purchase_order"
)
View Source
const (
	DefaultDenomination                   = undtypes.DefaultDenomination
	DefaultStartingPurchaseOrderID uint64 = 1 // used in init genesis

	// Valid Purchase Order statuses
	StatusNil       PurchaseOrderStatus = 0x00
	StatusRaised    PurchaseOrderStatus = 0x01
	StatusAccepted  PurchaseOrderStatus = 0x02
	StatusRejected  PurchaseOrderStatus = 0x03
	StatusCompleted PurchaseOrderStatus = 0x04
)

Variables

View Source
var (
	ErrInvalidGenesis                = sdkerrors.Register(ModuleName, CodeInvalidGenesis, "invalid genesis")
	ErrPurchaseOrderDoesNotExist     = sdkerrors.Register(ModuleName, CodePurchaseOrderDoesNotExist, "purchase order does not exist")
	ErrPurchaseOrderAlreadyProcessed = sdkerrors.Register(ModuleName, CodePurchaseOrderAlreadyProcessed, "purchase order already processed")
	ErrInvalidDecision               = sdkerrors.Register(ModuleName, CodeInvalidDecision, "invalid decision")
	ErrInvalidDenomination           = sdkerrors.Register(ModuleName, CodeInvalidDenomination, "invalid denomination")
	ErrInvalidStatus                 = sdkerrors.Register(ModuleName, CodeInvalidStatus, "invalid status")
	ErrPurchaseOrderNotRaised        = sdkerrors.Register(ModuleName, CodePurchaseOrderNotRaised, "purchase order not raised")
	ErrSignerAlreadyMadeDecision     = sdkerrors.Register(ModuleName, CodeSignerAlreadyMadeDecision, "signer already made decision")
	ErrMissingData                   = sdkerrors.Register(ModuleName, CodeMissingData, "missing data")
	ErrInvalidData                   = sdkerrors.Register(ModuleName, CodeDataInvalid, "invalid data")
)
View Source
var (
	EventTypeRaisePurchaseOrder           = "raise_purchase_order"
	EventTypeProcessPurchaseOrderDecision = "process_purchase_order_decision"
	EventTypeAutoRejectStalePurchaseOrder = "auto_reject_stale_purchase_order"
	EventTypeTallyPurchaseOrderDecisions  = "tally_purchase_order_decisions"
	EventTypeUndPurchaseComplete          = "und_purchase_complete"
	EventTypeUndUnlocked                  = "und_unlocked"

	AttributeValueCategory = ModuleName

	AttributeKeyPurchaseOrderID = "id"
	AttributeKeyPurchaser       = "purchaser"
	AttributeKeyAmount          = "amount"
	AttributeKeyDecision        = "decision"
	AttributeKeySigner          = "signer"
	AttributeKeyNumAccepts      = "accepts"
	AttributeKeyNumRejects      = "rejects"
)
View Source
var (

	// key used to store the current highest purchase order ID
	HighestPurchaseOrderIDKey = []byte{0x20}

	// prefix used to store/retrieve an purchase order waiting to be processed from the store
	PurchaseOrderIDKeyPrefix = []byte{0x01}

	// LockedUndAddressKeyPrefix prefix for address keys - used to store locked UND for an account
	LockedUndAddressKeyPrefix = []byte{0x02}

	TotalLockedUndKey = []byte{0x99}
)
View Source
var (
	KeyEntSigners    = []byte("EntSigners")
	KeyDenom         = []byte("Denom")
	KeyMinAccepts    = []byte("MinAccepts")
	KeyDecisionLimit = []byte("DecisionLimit")
)

Parameter store keys

View Source
var ModuleCdc = codec.New()

Functions

func AddressStoreKey

func AddressStoreKey(acc sdk.AccAddress) []byte

AddressStoreKey turn an address to key used for enterprise und/locked data to get it from the store

func GetPurchaseOrderIDBytes

func GetPurchaseOrderIDBytes(purchaseOrderID uint64) (purchaseOrderIDBz []byte)

GetPurchaseOrderIDBytes returns the byte representation of the purchaseOrderID used for getting the highest purchase order ID from the database

func GetPurchaseOrderIDFromBytes

func GetPurchaseOrderIDFromBytes(bz []byte) (purchaseOrderID uint64)

GetPurchaseOrderIDFromBytes returns purchaseOrderID in uint64 format from a byte array used for getting the highest purchase order ID from the database

func ParamKeyTable

func ParamKeyTable() params.KeyTable

ParamTable for enterprise UND module.

func PurchaseOrderKey

func PurchaseOrderKey(purchaseOrderID uint64) []byte

PurchaseOrderKey gets a specific purchase order ID key for use in the store

func RegisterCodec

func RegisterCodec(cdc *codec.Codec)

RegisterCodec registers concrete types on the Amino codec

func ValidPurchaseOrderAcceptRejectStatus

func ValidPurchaseOrderAcceptRejectStatus(status PurchaseOrderStatus) bool

ValidPurchaseOrderAcceptRejectStatus checks the decision - returns true if accept/reject.

func ValidPurchaseOrderStatus

func ValidPurchaseOrderStatus(status PurchaseOrderStatus) bool

ValidPurchaseOrderStatus returns true if the purchase order status is valid and false otherwise.

func ValidateGenesis

func ValidateGenesis(data GenesisState) error

ValidateGenesis validates the provided genesis state to ensure the expected invariants holds.

Types

type EnterpriseUndPurchaseOrder

type EnterpriseUndPurchaseOrder struct {
	PurchaseOrderID uint64                  `json:"id"`
	Purchaser       sdk.AccAddress          `json:"purchaser"`
	Amount          sdk.Coin                `json:"amount"`
	Status          PurchaseOrderStatus     `json:"status"`
	RaisedTime      int64                   `json:"raise_time"`
	Decisions       []PurchaseOrderDecision `json:"decisions"`
	CompletionTime  int64                   `json:"completion_time"`
}

EnterpriseUndPurchaseOrder is a struct that contains information on Enterprise UND purchase orders and their status

func NewEnterpriseUndPurchaseOrder

func NewEnterpriseUndPurchaseOrder() EnterpriseUndPurchaseOrder

NewEnterpriseUndPurchaseOrder returns a new EnterpriseUndPurchaseOrder struct

func (EnterpriseUndPurchaseOrder) String

func (po EnterpriseUndPurchaseOrder) String() string

implement fmt.Stringer

type GenesisState

type GenesisState struct {
	Params                  Params         `json:"params" yaml:"params"`                                         // enterprise params
	StartingPurchaseOrderID uint64         `json:"starting_purchase_order_id" yaml:"starting_purchase_order_id"` // should be 1
	PurchaseOrders          PurchaseOrders `json:"purchase_orders" yaml:"purchase_orders"`
	LockedUnds              LockedUnds     `json:"locked_und" yaml:"locked_und"`
	TotalLocked             sdk.Coin       `json:"total_locked" yaml:"total_locked"`
}

GenesisState - enterprise state

func DefaultGenesisState

func DefaultGenesisState() GenesisState

DefaultGenesisState creates a default GenesisState object

func NewGenesisState

func NewGenesisState(params Params, startingPurchaseOrderID uint64, totalLocked sdk.Coin) GenesisState

NewGenesisState creates a new GenesisState object

func (GenesisState) Equal

func (data GenesisState) Equal(data2 GenesisState) bool

Equal checks whether two enterprise GenesisState structs are equivalent

func (GenesisState) IsEmpty

func (data GenesisState) IsEmpty() bool

IsEmpty returns true if a GenesisState is empty

type LockedUnd

type LockedUnd struct {
	Owner  sdk.AccAddress `json:"owner"`
	Amount sdk.Coin       `json:"amount"`
}

LockedUnd is a struct that is used to track "Locked" Enterprise purchased UND

func NewLockedUnd

func NewLockedUnd(owner sdk.AccAddress, denom string) LockedUnd

func (LockedUnd) String

func (l LockedUnd) String() string

type LockedUnds

type LockedUnds []LockedUnd

LockedUnds is an array of locked UND

func (LockedUnds) String

func (lund LockedUnds) String() string

String implements stringer interface

type MsgProcessUndPurchaseOrder

type MsgProcessUndPurchaseOrder struct {
	PurchaseOrderID uint64              `json:"id"`
	Decision        PurchaseOrderStatus `json:"decision"`
	Signer          sdk.AccAddress      `json:"signer"`
}

MsgProcessUndPurchaseOrder defines a ProcessUndPurchaseOrder message - used to accept/reject a PO

func NewMsgProcessUndPurchaseOrder

func NewMsgProcessUndPurchaseOrder(purchaseOrderID uint64, decision PurchaseOrderStatus, signer sdk.AccAddress) MsgProcessUndPurchaseOrder

NewMsgProcessUndPurchaseOrder is a constructor function for MsgProcessUndPurchaseOrder

func (MsgProcessUndPurchaseOrder) GetSignBytes

func (msg MsgProcessUndPurchaseOrder) GetSignBytes() []byte

GetSignBytes encodes the message for signing

func (MsgProcessUndPurchaseOrder) GetSigners

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

GetSigners defines whose signature is required

func (MsgProcessUndPurchaseOrder) Route

func (msg MsgProcessUndPurchaseOrder) Route() string

Route should return the name of the module

func (MsgProcessUndPurchaseOrder) Type

Type should return the action

func (MsgProcessUndPurchaseOrder) ValidateBasic

func (msg MsgProcessUndPurchaseOrder) ValidateBasic() error

ValidateBasic runs stateless checks on the message

type MsgUndPurchaseOrder

type MsgUndPurchaseOrder struct {
	Purchaser sdk.AccAddress `json:"purchaser"`
	Amount    sdk.Coin       `json:"amount"`
}

MsgUndPurchaseOrder defines a UndPurchaseOrder message

func NewMsgUndPurchaseOrder

func NewMsgUndPurchaseOrder(purchaser sdk.AccAddress, amount sdk.Coin) MsgUndPurchaseOrder

NewMsgUndPurchaseOrder is a constructor function for MsgUndPurchaseOrder

func (MsgUndPurchaseOrder) GetSignBytes

func (msg MsgUndPurchaseOrder) GetSignBytes() []byte

GetSignBytes encodes the message for signing

func (MsgUndPurchaseOrder) GetSigners

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

GetSigners defines whose signature is required

func (MsgUndPurchaseOrder) Route

func (msg MsgUndPurchaseOrder) Route() string

Route should return the name of the module

func (MsgUndPurchaseOrder) Type

func (msg MsgUndPurchaseOrder) Type() string

Type should return the action

func (MsgUndPurchaseOrder) ValidateBasic

func (msg MsgUndPurchaseOrder) ValidateBasic() error

ValidateBasic runs stateless checks on the message

type Params

type Params struct {
	EntSigners    string `json:"ent_signers" yaml:"ent_signers"` // Accounts allowed to sign decisions on UND purchase orders
	Denom         string `json:"denom" yaml:"denom"`
	MinAccepts    uint64 `json:"min_Accepts" yaml:"min_Accepts"`                 // must be <= len(EntSigners)
	DecisionLimit uint64 `json:"decision_time_limit" yaml:"decision_time_limit"` // num seconds elapsed before auto-reject
}

enterprise UND parameters

func DefaultParams

func DefaultParams() Params

default enterprise UND module parameters

func NewParams

func NewParams(denom string, minAccepts uint64, decisionLimit uint64, entSigners string) Params

func (*Params) ParamSetPairs

func (p *Params) ParamSetPairs() params.ParamSetPairs

Implements params.ParamSet

func (Params) String

func (p Params) String() string

func (Params) Validate added in v1.2.0

func (p Params) Validate() error

validate params

type PurchaseOrderDecision

type PurchaseOrderDecision struct {
	Signer       sdk.AccAddress      `json:"signer"`
	Decision     PurchaseOrderStatus `json:"decision"`
	DecisionTime int64               `json:"decision_time"`
}

func NewPurchaseOrderDecision

func NewPurchaseOrderDecision(signer sdk.AccAddress, decision PurchaseOrderStatus) PurchaseOrderDecision

type PurchaseOrderStatus

type PurchaseOrderStatus byte

func PurchaseOrderStatusFromString

func PurchaseOrderStatusFromString(str string) (PurchaseOrderStatus, error)

PurchaseOrderStatusFromString turns a string into a ProposalStatus

func (PurchaseOrderStatus) Format

func (status PurchaseOrderStatus) Format(s fmt.State, verb rune)

Format implements the fmt.Formatter interface. nolint: errcheck

func (PurchaseOrderStatus) Marshal

func (status PurchaseOrderStatus) Marshal() ([]byte, error)

Marshal needed for protobuf compatibility

func (PurchaseOrderStatus) MarshalJSON

func (status PurchaseOrderStatus) MarshalJSON() ([]byte, error)

MarshalJSON Marshals to JSON using string representation of the status

func (PurchaseOrderStatus) String

func (status PurchaseOrderStatus) String() string

String implements the Stringer interface.

func (*PurchaseOrderStatus) Unmarshal

func (status *PurchaseOrderStatus) Unmarshal(data []byte) error

Unmarshal needed for protobuf compatibility

func (*PurchaseOrderStatus) UnmarshalJSON

func (status *PurchaseOrderStatus) UnmarshalJSON(data []byte) error

UnmarshalJSON Unmarshals from JSON assuming Bech32 encoding

type PurchaseOrders

type PurchaseOrders []EnterpriseUndPurchaseOrder

PurchaseOrders is an array of purchase orders

func (PurchaseOrders) String

func (p PurchaseOrders) String() string

String implements stringer interface

type QueryPurchaseOrdersParams

type QueryPurchaseOrdersParams struct {
	Page                int
	Limit               int
	PurchaseOrderStatus PurchaseOrderStatus
	Purchaser           sdk.AccAddress
}

QueryPurchaseOrdersParams Params for query 'custom/enterprise/pos'

func NewQueryPurchaseOrdersParams

func NewQueryPurchaseOrdersParams(page, limit int, status PurchaseOrderStatus, purchaser sdk.AccAddress) QueryPurchaseOrdersParams

NewQueryPurchaseOrdersParams creates a new instance of QueryPurchaseOrdersParams

type QueryResPurchaseOrders

type QueryResPurchaseOrders []EnterpriseUndPurchaseOrder

QueryResPurchaseOrders Queries raised Enterprise UND purchase orders

func (QueryResPurchaseOrders) String

func (po QueryResPurchaseOrders) String() (out string)

implement fmt.Stringer

type SupplyKeeper

type SupplyKeeper interface {
	GetSupply(ctx sdk.Context) supplyexported.SupplyI

	GetModuleAddress(name string) sdk.AccAddress
	GetModuleAccount(ctx sdk.Context, name string) supplyexported.ModuleAccountI

	// TODO remove with genesis 2-phases refactor https://github.com/cosmos/cosmos-sdk/issues/2862
	SetModuleAccount(sdk.Context, supplyexported.ModuleAccountI)

	SendCoinsFromModuleToAccount(ctx sdk.Context, senderModule string, recipientAddr sdk.AccAddress, amt sdk.Coins) error

	UndelegateCoinsFromModuleToAccount(ctx sdk.Context, senderModule string, recipientAddr sdk.AccAddress, amt sdk.Coins) error
	DelegateCoinsFromAccountToModule(ctx sdk.Context, senderAddr sdk.AccAddress, recipientModule string, amt sdk.Coins) error

	MintCoins(ctx sdk.Context, name string, amt sdk.Coins) error
}

supplyKeeper defines the expected supply keeper

type UndSupplies

type UndSupplies []UndSupply

type UndSupply

type UndSupply struct {
	Denom  string `json:"denom"`
	Amount int64  `json:"amount"`
	Locked int64  `json:"locked"`
	Total  int64  `json:"total"`
}

func NewUndSupply

func NewUndSupply(denom string) UndSupply

func (UndSupply) String

func (u UndSupply) String() string

Jump to

Keyboard shortcuts

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