Documentation ¶
Index ¶
- Constants
- Variables
- func MustMarshalJSON(o interface{}) []byte
- func MustUnmarshalJSON(bz []byte, ptr interface{})
- func ParseEvent(ev sdkutil.Event) (interface{}, error)
- func RegisterCodec(cdc *codec.Codec)
- func UnmarshalJSON(bz []byte, ptr interface{}) error
- type Bid
- type BidFilters
- type BidID
- type BidState
- type EventBidClosed
- type EventBidCreated
- type EventLeaseClosed
- type EventLeaseCreated
- type EventOrderClosed
- type EventOrderCreated
- type Lease
- type LeaseFilters
- type LeaseID
- type LeaseState
- type MsgCloseBid
- type MsgCloseOrder
- type MsgCreateBid
- type Order
- type OrderFilters
- 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, 1, "invalid: order id") // ErrEmptyProvider is the error when provider is empty ErrEmptyProvider = sdkerrors.Register(ModuleName, 2, "empty provider") // ErrSameAccount is the error when owner and provider are the same account ErrSameAccount = sdkerrors.Register(ModuleName, 3, "owner and provider are the same account") // ErrInternal is the error for internal error ErrInternal = sdkerrors.Register(ModuleName, 4, "internal error") // ErrBidOverOrder is the error when bid price is above max order price ErrBidOverOrder = sdkerrors.Register(ModuleName, 5, "bid price above max order price") // ErrAtributeMismatch is the error for attribute mismatch ErrAtributeMismatch = sdkerrors.Register(ModuleName, 6, "atribute mismatch") // ErrUnknownBid is the error for unknown bid ErrUnknownBid = sdkerrors.Register(ModuleName, 7, "unknown bid") // ErrUnknownLeaseForBid is the error when lease is unknown for bid ErrUnknownLeaseForBid = sdkerrors.Register(ModuleName, 8, "unknown lease for bid") // ErrUnknownOrderForBid is the error when order is unknown for bid ErrUnknownOrderForBid = sdkerrors.Register(ModuleName, 9, "unknown order for bid") // ErrLeaseNotActive is the error when lease is not active ErrLeaseNotActive = sdkerrors.Register(ModuleName, 10, "lease not active") // ErrBidNotMatched is the error when bid is not matched ErrBidNotMatched = sdkerrors.Register(ModuleName, 11, "bid not matched") // ErrUnknownOrder is the error when order is unknown ErrUnknownOrder = sdkerrors.Register(ModuleName, 12, "unknown order") // ErrNoLeaseForOrder is the error when there is no lease for order ErrNoLeaseForOrder = sdkerrors.Register(ModuleName, 13, "no lease for order") // ErrOrderNotFound order not found ErrOrderNotFound = sdkerrors.Register(ModuleName, 14, "invalid order: order not found") // ErrBidNotFound bid not found ErrBidNotFound = sdkerrors.Register(ModuleName, 15, "invalid bid: bid not found") // ErrLeaseNotFound lease not found ErrLeaseNotFound = sdkerrors.Register(ModuleName, 16, "invalid lease: lease not found") )
var BidStateMap = map[string]BidState{ "open": BidOpen, "matched": BidMatched, "lost": BidLost, "closed": BidClosed, }
BidStateMap is used to decode bid state flag value
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 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 ParseEvent ¶
ParseEvent parses event and returns details of event and error if occured
func RegisterCodec ¶
RegisterCodec register concrete types on codec
func UnmarshalJSON ¶
UnmarshalJSON decodes bytes into json
Types ¶
type BidFilters ¶
type BidFilters struct { Owner sdk.AccAddress // State flag value given StateFlagVal string // Actual state value decoded from BidStateMap State BidState }
BidFilters defines flags for bid list filter
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
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 BidState ¶
type BidState uint8
BidState defines state of bid
const ( // BidOpen is used when state of bid is opened BidOpen BidState = iota // BidMatched is used when state of bid is matched BidMatched BidState = iota // BidLost is used when state of bid is lost BidLost BidState = iota // BidClosed is used when state of bid is closed BidClosed BidState = iota )
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 LeaseFilters ¶
type LeaseFilters struct { Owner sdk.AccAddress // State flag value given StateFlagVal string // Actual state value decoded from LeaseStateMap State LeaseState }
LeaseFilters defines flags for lease list filter
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 // LeaseInsufficientFunds is used when lease has insufficient funds LeaseInsufficientFunds LeaseState = iota // LeaseClosed is used when state of lease is closed LeaseClosed LeaseState = iota )
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
type OrderFilters ¶
type OrderFilters struct { Owner sdk.AccAddress // State flag value given StateFlagVal string // Actual state value decoded from OrderStateMap State OrderState }
OrderFilters defines flags for order list filter
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 // OrderMatched is used when state of order is matched OrderMatched OrderState = iota // OrderClosed is used when state of order is closed OrderClosed OrderState = iota )