Documentation ¶
Index ¶
- Constants
- Variables
- func BidIDString(id BidID) string
- func MustMarshalJSON(o interface{}) []byte
- func MustUnmarshalJSON(bz []byte, ptr interface{})
- func OrderIDString(id OrderID) string
- func ParseEvent(ev sdkutil.Event) (interface{}, error)
- func RegisterCodec(cdc *codec.Codec)
- func UnmarshalJSON(bz []byte, ptr interface{}) error
- type Bid
- type BidID
- type BidState
- type EventBidClosed
- type EventBidCreated
- type EventLeaseClosed
- type EventLeaseCreated
- type EventOrderClosed
- type EventOrderCreated
- type Lease
- type LeaseID
- type LeaseState
- type MsgCloseBid
- type MsgCloseOrder
- type MsgCreateBid
- type Order
- type OrderID
- type OrderState
Constants ¶
const ( // ModuleName is the module name constant used in many places ModuleName = "market" // StoreKey is the store key string for market StoreKey = ModuleName // RouterKey is the message route for market RouterKey = ModuleName )
Variables ¶
var ( // ErrInvalidOrder is the error when order id is invalid ErrInvalidOrder = sdkerrors.Register(ModuleName, errCodeInvalidOrder, "invalid: order id") // ErrEmptyProvider is the error when provider is empty ErrEmptyProvider = sdkerrors.Register(ModuleName, errCodeEmptyProvider, "empty provider") // ErrSameAccount is the error when owner and provider are the same account ErrSameAccount = sdkerrors.Register(ModuleName, errCodeSameAccount, "owner and provider are the same account") // ErrInternal is the error for internal error ErrInternal = sdkerrors.Register(ModuleName, errCodeInternal, "internal error") // ErrBidOverOrder is the error when bid price is above max order price ErrBidOverOrder = sdkerrors.Register(ModuleName, errCodeOverOrder, "bid price above max order price") // ErrAttributeMismatch is the error for attribute mismatch ErrAttributeMismatch = sdkerrors.Register(ModuleName, errCodeAttributeMismatch, "attribute mismatch") // ErrUnknownBid is the error for unknown bid ErrUnknownBid = sdkerrors.Register(ModuleName, errCodeUnknownBid, "unknown bid") // ErrUnknownLeaseForBid is the error when lease is unknown for bid ErrUnknownLeaseForBid = sdkerrors.Register(ModuleName, errCodeUnknownLeaseForOrder, "unknown lease for bid") // ErrUnknownOrderForBid is the error when order is unknown for bid ErrUnknownOrderForBid = sdkerrors.Register(ModuleName, errCodeUnknownOrderForBid, "unknown order for bid") // ErrLeaseNotActive is the error when lease is not active ErrLeaseNotActive = sdkerrors.Register(ModuleName, errCodeLeaseNotActive, "lease not active") // ErrBidNotMatched is the error when bid is not matched ErrBidNotMatched = sdkerrors.Register(ModuleName, errCodeBidNotMatched, "bid not matched") // ErrUnknownOrder is the error when order is unknown ErrUnknownOrder = sdkerrors.Register(ModuleName, errCodeUnknownOrder, "unknown order") // ErrNoLeaseForOrder is the error when there is no lease for order ErrNoLeaseForOrder = sdkerrors.Register(ModuleName, errCodeNoLeaseForOrder, "no lease for order") // ErrOrderNotFound order not found ErrOrderNotFound = sdkerrors.Register(ModuleName, errCodeOrderNotFound, "invalid order: order not found") // ErrBidNotFound bid not found ErrBidNotFound = sdkerrors.Register(ModuleName, errCodeBidNotFound, "invalid bid: bid not found") // ErrLeaseNotFound lease not found ErrLeaseNotFound = sdkerrors.Register(ModuleName, errCodeLeaseNotFound, "invalid lease: lease not found") // ErrBidExists bid exists ErrBidExists = sdkerrors.Register(ModuleName, errCodeBidExists, "invalid bid: bid exists from provider") // ErrBidInvalidPrice bid invalid price ErrBidInvalidPrice = sdkerrors.Register(ModuleName, errCodeInvalidPrice, "bid price is invalid") )
var ( ErrOrderMatched = errors.New("order matched") ErrOrderClosed = errors.New("order closed") ErrOrderOpen = errors.New("order open") )
var BidStateMap = map[string]BidState{ "open": BidOpen, "matched": BidMatched, "lost": BidLost, "closed": BidClosed, }
BidStateMap is used to decode bid state flag value
var (
ErrParsingPrice = errors.New("error parsing price")
)
var LeaseStateMap = map[string]LeaseState{ "active": LeaseActive, "insufficient": LeaseInsufficientFunds, "closed": LeaseClosed, }
LeaseStateMap is used to decode lease state flag value
var OrderStateMap = map[string]OrderState{ "open": OrderOpen, "matched": OrderMatched, "closed": OrderClosed, }
OrderStateMap is used to decode order state flag value
Functions ¶
func BidIDString ¶ added in v0.6.5
BidIDString provides consistent conversion to string values for BidID/LeaseIDs.
func MustMarshalJSON ¶
func MustMarshalJSON(o interface{}) []byte
MustMarshalJSON panics if an error occurs. Besides that it behaves exactly like MarshalJSON i.e., encodes json to byte array
func MustUnmarshalJSON ¶
func MustUnmarshalJSON(bz []byte, ptr interface{})
MustUnmarshalJSON panics if an error occurs. Besides that it behaves exactly like UnmarshalJSON.
func OrderIDString ¶ added in v0.7.3
OrderIDString provides consistent conversion to string values for OrderID.
func ParseEvent ¶
ParseEvent parses event and returns details of event and error if occurred
func RegisterCodec ¶
RegisterCodec register concrete types on codec
func UnmarshalJSON ¶
UnmarshalJSON decodes bytes into json
Types ¶
type BidID ¶
type BidID struct { Owner sdk.AccAddress `json:"owner"` DSeq uint64 `json:"dseq"` GSeq uint32 `json:"gseq"` OSeq uint32 `json:"oseq"` Provider sdk.AccAddress `json:"provider"` }
BidID stores owner, provider and all other seq numbers. A successful bid becomes a Lease(ID).
func MakeBidID ¶
func MakeBidID(id OrderID, provider sdk.AccAddress) BidID
MakeBidID returns BidID instance with provided order details and provider
func (BidID) DeploymentID ¶
func (id BidID) DeploymentID() dtypes.DeploymentID
DeploymentID method returns deployment details with specific bid details
type EventBidClosed ¶
EventBidClosed struct
func (EventBidClosed) ToSDKEvent ¶
func (e EventBidClosed) ToSDKEvent() sdk.Event
ToSDKEvent method creates new sdk event for EventBidClosed struct
type EventBidCreated ¶
EventBidCreated struct
func (EventBidCreated) ToSDKEvent ¶
func (e EventBidCreated) ToSDKEvent() sdk.Event
ToSDKEvent method creates new sdk event for EventBidCreated struct
type EventLeaseClosed ¶
EventLeaseClosed struct
func (EventLeaseClosed) ToSDKEvent ¶
func (e EventLeaseClosed) ToSDKEvent() sdk.Event
ToSDKEvent method creates new sdk event for EventLeaseClosed struct
type EventLeaseCreated ¶
EventLeaseCreated struct
func (EventLeaseCreated) ToSDKEvent ¶
func (e EventLeaseCreated) ToSDKEvent() sdk.Event
ToSDKEvent method creates new sdk event for EventLeaseCreated struct
type EventOrderClosed ¶
type EventOrderClosed struct {
ID OrderID
}
EventOrderClosed struct
func (EventOrderClosed) ToSDKEvent ¶
func (e EventOrderClosed) ToSDKEvent() sdk.Event
ToSDKEvent method creates new sdk event for EventOrderClosed struct
type EventOrderCreated ¶
type EventOrderCreated struct {
ID OrderID
}
EventOrderCreated struct
func (EventOrderCreated) ToSDKEvent ¶
func (e EventOrderCreated) ToSDKEvent() sdk.Event
ToSDKEvent method creates new sdk event for EventOrderCreated struct
type Lease ¶
type Lease struct { LeaseID `json:"id"` State LeaseState `json:"state"` Price sdk.Coin `json:"price"` }
Lease stores LeaseID, state of lease and price
type LeaseID ¶
type LeaseID BidID
LeaseID stores bid details of lease
func MakeLeaseID ¶
MakeLeaseID returns LeaseID instance with provided bid details
func (LeaseID) DeploymentID ¶
func (id LeaseID) DeploymentID() dtypes.DeploymentID
DeploymentID method returns deployment details with specific lease details
type LeaseState ¶
type LeaseState uint8
LeaseState defines state of Lease
const ( // LeaseActive is used when state of lease is active LeaseActive LeaseState = iota + 1 // LeaseInsufficientFunds is used when lease has insufficient funds LeaseInsufficientFunds // LeaseClosed is used when state of lease is closed LeaseClosed )
type MsgCloseBid ¶
type MsgCloseBid struct {
BidID `json:"id"`
}
MsgCloseBid defines an SDK message for closing bid
func (MsgCloseBid) GetSignBytes ¶
func (msg MsgCloseBid) GetSignBytes() []byte
GetSignBytes encodes the message for signing
func (MsgCloseBid) GetSigners ¶
func (msg MsgCloseBid) GetSigners() []sdk.AccAddress
GetSigners defines whose signature is required
func (MsgCloseBid) Route ¶
func (msg MsgCloseBid) Route() string
Route implements the sdk.Msg interface
func (MsgCloseBid) Type ¶
func (msg MsgCloseBid) Type() string
Type implements the sdk.Msg interface
func (MsgCloseBid) ValidateBasic ¶
func (msg MsgCloseBid) ValidateBasic() error
ValidateBasic method for MsgCloseBid
type MsgCloseOrder ¶
type MsgCloseOrder struct {
OrderID `json:"id"`
}
MsgCloseOrder defines an SDK message for closing order
func (MsgCloseOrder) GetSignBytes ¶
func (msg MsgCloseOrder) GetSignBytes() []byte
GetSignBytes encodes the message for signing
func (MsgCloseOrder) GetSigners ¶
func (msg MsgCloseOrder) GetSigners() []sdk.AccAddress
GetSigners defines whose signature is required
func (MsgCloseOrder) Route ¶
func (msg MsgCloseOrder) Route() string
Route implements the sdk.Msg interface
func (MsgCloseOrder) Type ¶
func (msg MsgCloseOrder) Type() string
Type implements the sdk.Msg interface
func (MsgCloseOrder) ValidateBasic ¶
func (msg MsgCloseOrder) ValidateBasic() error
ValidateBasic method for MsgCloseOrder
type MsgCreateBid ¶
type MsgCreateBid struct { Order OrderID `json:"order"` Provider sdk.AccAddress `json:"owner"` Price sdk.Coin `json:"price"` }
MsgCreateBid defines an SDK message for creating Bid
func (MsgCreateBid) GetSignBytes ¶
func (msg MsgCreateBid) GetSignBytes() []byte
GetSignBytes encodes the message for signing
func (MsgCreateBid) GetSigners ¶
func (msg MsgCreateBid) GetSigners() []sdk.AccAddress
GetSigners defines whose signature is required
func (MsgCreateBid) Route ¶
func (msg MsgCreateBid) Route() string
Route implements the sdk.Msg interface
func (MsgCreateBid) Type ¶
func (msg MsgCreateBid) Type() string
Type implements the sdk.Msg interface
func (MsgCreateBid) ValidateBasic ¶
func (msg MsgCreateBid) ValidateBasic() error
ValidateBasic does basic validation of provider and order
type Order ¶
type Order struct { OrderID `json:"id"` State OrderState `json:"state"` // block height to start matching StartAt int64 `json:"start-at"` Spec dtypes.GroupSpec `json:"spec"` }
Order stores orderID, state of order and other details
func (Order) MatchAttributes ¶
MatchAttributes method compares provided attributes with specific order attributes
func (Order) ValidateCanBid ¶
ValidateCanBid method validates whether order is open or not and returns error if not
func (Order) ValidateCanMatch ¶
ValidateCanMatch method validates whether to match order for provided height
func (Order) ValidateInactive ¶ added in v0.6.3
ValidateInactive method validates whether order is open or not and returns error if not
type OrderID ¶
type OrderID struct { Owner sdk.AccAddress `json:"owner"` DSeq uint64 `json:"dseq"` GSeq uint32 `json:"gseq"` OSeq uint32 `json:"oseq"` }
OrderID stores owner and all other seq numbers
func MakeOrderID ¶
MakeOrderID returns OrderID instance with provided groupID details and oseq
type OrderState ¶
type OrderState uint8
OrderState defines state of order
const ( // OrderOpen is used when state of order is open OrderOpen OrderState = iota + 1 // OrderMatched is used when state of order is matched OrderMatched // OrderClosed is used when state of order is closed OrderClosed )