Documentation ¶
Index ¶
- Constants
- Variables
- func AddressStoreKey(acc sdk.AccAddress) []byte
- func ErrInvalidDecision(codespace sdk.CodespaceType, msg string) sdk.Error
- func ErrInvalidDenomination(codespace sdk.CodespaceType, msg string) sdk.Error
- func ErrInvalidGenesis(codespace sdk.CodespaceType, msg string) sdk.Error
- func ErrPurchaseOrderAlreadyProcessed(codespace sdk.CodespaceType, msg string) sdk.Error
- func ErrPurchaseOrderDoesNotExist(codespace sdk.CodespaceType, msg string) sdk.Error
- func ErrPurchaseOrderNotRaised(codespace sdk.CodespaceType, msg string) sdk.Error
- func ErrSignerAlreadyMadeDecision(codespace sdk.CodespaceType, msg string) sdk.Error
- func GetPurchaseOrderIDBytes(purchaseOrderID uint64) (purchaseOrderIDBz []byte)
- func GetPurchaseOrderIDFromBytes(bz []byte) (purchaseOrderID uint64)
- func ParamKeyTable() params.KeyTable
- func PurchaseOrderKey(purchaseOrderID uint64) []byte
- func RegisterCodec(cdc *codec.Codec)
- func ValidPurchaseOrderAcceptRejectStatus(status PurchaseOrderStatus) bool
- func ValidPurchaseOrderStatus(status PurchaseOrderStatus) bool
- func ValidateGenesis(data GenesisState) error
- func ValidateParams(params Params) error
- type EnterpriseUndPurchaseOrder
- type GenesisState
- type LockedUnd
- type LockedUnds
- type MsgProcessUndPurchaseOrder
- type MsgUndPurchaseOrder
- type Params
- type PurchaseOrderDecision
- type PurchaseOrderStatus
- func (status PurchaseOrderStatus) Format(s fmt.State, verb rune)
- func (status PurchaseOrderStatus) Marshal() ([]byte, error)
- func (status PurchaseOrderStatus) MarshalJSON() ([]byte, error)
- func (status PurchaseOrderStatus) String() string
- func (status *PurchaseOrderStatus) Unmarshal(data []byte) error
- func (status *PurchaseOrderStatus) UnmarshalJSON(data []byte) error
- type PurchaseOrders
- type QueryPurchaseOrdersParams
- type QueryResPurchaseOrders
- type SupplyKeeper
- type UndSupplies
- type UndSupply
Constants ¶
const ( DefaultCodespace sdk.CodespaceType = ModuleName CodeInvalidGenesis = 101 CodePurchaseOrderDoesNotExist = 102 CodePurchaseOrderAlreadyProcessed = 103 CodeInvalidDecision = 104 CodeInvalidDenomination = 105 CodeInvalidStatus = 106 CodePurchaseOrderNotRaised = 107 CodeSignerAlreadyMadeDecision = 108 )
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 )
const ( RouterKey = ModuleName // defined in keys.go file PurchaseAction = "purchase" ProcessAction = "process" )
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 ¶
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" )
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} )
var ( KeyEntSigners = []byte("EntSigners") KeyDenom = []byte("Denom") KeyMinAccepts = []byte("MinAccepts") KeyDecisionLimit = []byte("DecisionLimit") )
Parameter store keys
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 ErrInvalidDecision ¶
func ErrInvalidDecision(codespace sdk.CodespaceType, msg string) sdk.Error
func ErrInvalidDenomination ¶
func ErrInvalidDenomination(codespace sdk.CodespaceType, msg string) sdk.Error
func ErrInvalidGenesis ¶
func ErrInvalidGenesis(codespace sdk.CodespaceType, msg string) sdk.Error
ErrInvalidGenesis error for an invalid enterprise GenesisState
func ErrPurchaseOrderAlreadyProcessed ¶
func ErrPurchaseOrderAlreadyProcessed(codespace sdk.CodespaceType, msg string) sdk.Error
func ErrPurchaseOrderDoesNotExist ¶
func ErrPurchaseOrderDoesNotExist(codespace sdk.CodespaceType, msg string) sdk.Error
func ErrPurchaseOrderNotRaised ¶
func ErrPurchaseOrderNotRaised(codespace sdk.CodespaceType, msg string) sdk.Error
func ErrSignerAlreadyMadeDecision ¶
func ErrSignerAlreadyMadeDecision(codespace sdk.CodespaceType, msg string) sdk.Error
func GetPurchaseOrderIDBytes ¶
GetPurchaseOrderIDBytes returns the byte representation of the purchaseOrderID used for getting the highest purchase order ID from the database
func GetPurchaseOrderIDFromBytes ¶
GetPurchaseOrderIDFromBytes returns purchaseOrderID in uint64 format from a byte array used for getting the highest purchase order ID from the database
func PurchaseOrderKey ¶
PurchaseOrderKey gets a specific purchase order ID key for use in the store
func RegisterCodec ¶
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
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 ¶
func (msg MsgProcessUndPurchaseOrder) Type() string
Type should return the action
func (MsgProcessUndPurchaseOrder) ValidateBasic ¶
func (msg MsgProcessUndPurchaseOrder) ValidateBasic() sdk.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() sdk.Error
ValidateBasic runs stateless checks on the message
type Params ¶
type Params struct { EntSigners []sdk.AccAddress `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 (*Params) ParamSetPairs ¶
func (p *Params) ParamSetPairs() params.ParamSetPairs
Implements params.ParamSet
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) sdk.Error UndelegateCoinsFromModuleToAccount(ctx sdk.Context, senderModule string, recipientAddr sdk.AccAddress, amt sdk.Coins) sdk.Error DelegateCoinsFromAccountToModule(ctx sdk.Context, senderAddr sdk.AccAddress, recipientModule string, amt sdk.Coins) sdk.Error MintCoins(ctx sdk.Context, name string, amt sdk.Coins) sdk.Error }
supplyKeeper defines the expected supply keeper
type UndSupplies ¶
type UndSupplies []UndSupply