Documentation ¶
Index ¶
- Constants
- Variables
- func CodeToDefaultMsg(code sdk.CodeType) string
- func ErrDuplicateAddress() sdk.Error
- func ErrDuplicateOrder(orderID string) sdk.Error
- func ErrInvalidAsset() sdk.Error
- func ErrUnknownOrder(orderID string) sdk.Error
- func GetAccountOrderKey(addr sdk.AccAddress, claimID string) []byte
- func GetAccountOrdersKey(addr sdk.AccAddress) []byte
- func GetOrderKey(uid []byte) []byte
- func NewHandler(k Keeper) sdk.Handler
- func NewPubKey(pk string) (res ed25519.PubKeyEd25519)
- func RegisterWire(cdc *wire.Codec)
- func TestAddr(addr string, bech string) sdk.AccAddress
- func ValidatorByPowerIndexExists(ctx sdk.Context, keeper Keeper, power []byte) bool
- type CancelOrderMsg
- type CompleteOrderMsg
- func (msg CompleteOrderMsg) Get(key interface{}) (value interface{})
- func (msg CompleteOrderMsg) GetSignBytes() []byte
- func (msg CompleteOrderMsg) GetSigners() []sdk.AccAddress
- func (msg CompleteOrderMsg) String() string
- func (msg CompleteOrderMsg) Type() string
- func (msg CompleteOrderMsg) ValidateBasic() sdk.Error
- type ConfirmOrderMsg
- type CreateOrderMsg
- func (msg CreateOrderMsg) Get(key interface{}) (value interface{})
- func (msg CreateOrderMsg) GetSignBytes() []byte
- func (msg CreateOrderMsg) GetSigners() []sdk.AccAddress
- func (msg CreateOrderMsg) String() string
- func (msg CreateOrderMsg) Type() string
- func (msg CreateOrderMsg) ValidateBasic() sdk.Error
- type Keeper
- func (k Keeper) CancelOrder(ctx sdk.Context, msg CancelOrderMsg) (sdk.Tags, sdk.Error)
- func (k Keeper) CompleteOrder(ctx sdk.Context, msg CompleteOrderMsg) (sdk.Tags, sdk.Error)
- func (k Keeper) ConfirmOrder(ctx sdk.Context, msg ConfirmOrderMsg) (sdk.Tags, sdk.Error)
- func (k Keeper) CreateOrder(ctx sdk.Context, msg CreateOrderMsg) (sdk.Tags, sdk.Error)
- type Order
- type OrderStatus
- type TransportedAsset
Constants ¶
const ( CodeDuplicateOrderID sdk.CodeType = iota + 600 CodeUnknownOrder CodeDuplicateAddress CodeInvalidAsset CodeInvalidInput DefaultCodespace sdk.CodespaceType = 10 )
ABCI Response Codes Base SDK reserves 500 - 599.
Variables ¶
var ( // Keys for store prefixes OrderKey = []byte{0x06} // prefix for each key to a order AccountOrdersKey = []byte{0x01} )
nolint
Functions ¶
func CodeToDefaultMsg ¶
CodeToDefaultMsg NOTE: Don't stringer this, we'll put better messages in later.
func GetAccountOrderKey ¶ added in v0.9.0
func GetAccountOrderKey(addr sdk.AccAddress, claimID string) []byte
GetAccountOrderKey get the key for an account for a order
func GetAccountOrdersKey ¶ added in v0.9.0
func GetAccountOrdersKey(addr sdk.AccAddress) []byte
GetAccountOrdersKey get the key for an account for all orders
func GetOrderKey ¶
GetOrderKey get the key for the record with address
func NewPubKey ¶ added in v0.20.0
func NewPubKey(pk string) (res ed25519.PubKeyEd25519)
func RegisterWire ¶
RegisterWire registers concrete types on wire codec
Types ¶
type CancelOrderMsg ¶
type CancelOrderMsg struct { OrderID string `json:"order_id"` // ID of the order to be cancelled Issuer sdk.AccAddress `json:"issuer_id"` // the issuer }
CompleteOrderMsg is sent by the receiver to confirm that the receiver has received the asset from the carrier
func (CancelOrderMsg) Get ¶
func (msg CancelOrderMsg) Get(key interface{}) (value interface{})
func (CancelOrderMsg) GetSignBytes ¶
func (msg CancelOrderMsg) GetSignBytes() []byte
GetSignBytes ...
func (CancelOrderMsg) GetSigners ¶
func (msg CancelOrderMsg) GetSigners() []sdk.AccAddress
func (CancelOrderMsg) ValidateBasic ¶
func (msg CancelOrderMsg) ValidateBasic() sdk.Error
ValidateBasic ...
type CompleteOrderMsg ¶
type CompleteOrderMsg struct { OrderID string `json:"order_id"` // ID of the order completed Receiver sdk.AccAddress `json:"receiver_id"` // the receiver, who confirm the completion of the order }
CompleteOrderMsg is sent by the receiver to confirm that the receiver has received the asset from the carrier
func (CompleteOrderMsg) Get ¶
func (msg CompleteOrderMsg) Get(key interface{}) (value interface{})
func (CompleteOrderMsg) GetSignBytes ¶
func (msg CompleteOrderMsg) GetSignBytes() []byte
GetSignBytes ...
func (CompleteOrderMsg) GetSigners ¶
func (msg CompleteOrderMsg) GetSigners() []sdk.AccAddress
func (CompleteOrderMsg) String ¶
func (msg CompleteOrderMsg) String() string
func (CompleteOrderMsg) ValidateBasic ¶
func (msg CompleteOrderMsg) ValidateBasic() sdk.Error
ValidateBasic ...
type ConfirmOrderMsg ¶
type ConfirmOrderMsg struct { OrderID string `json:"order_id"` // ID of the order received Carrier sdk.AccAddress `json:"carrier_id"` // the carrier, who confirms the order }
ReceiveOrderMsg is sent by the carrier to confirm that the carrier has received the asset from the issuer
func (ConfirmOrderMsg) GetSignBytes ¶
func (msg ConfirmOrderMsg) GetSignBytes() []byte
GetSignBytes ...
func (ConfirmOrderMsg) GetSigners ¶
func (msg ConfirmOrderMsg) GetSigners() []sdk.AccAddress
func (ConfirmOrderMsg) ValidateBasic ¶
func (msg ConfirmOrderMsg) ValidateBasic() sdk.Error
ValidateBasic ...
type CreateOrderMsg ¶
type CreateOrderMsg struct { ID string `json:"id"` // ID of the order, provided by the client TransportedAssets []TransportedAsset `json:"transported_assets"` // The assets to be transported Issuer sdk.AccAddress `json:"issuer"` // The issuer of the order, must also be the owner of the asset (coin) Carrier sdk.AccAddress `json:"carrier"` // The carrier Receiver sdk.AccAddress `json:"receiver"` // The receiver, often a buyer }
CreateOrderMsg is sent by the issuer to construct a new order, all fields are required
func (CreateOrderMsg) Get ¶
func (msg CreateOrderMsg) Get(key interface{}) (value interface{})
func (CreateOrderMsg) GetSignBytes ¶
func (msg CreateOrderMsg) GetSignBytes() []byte
GetSignBytes ...
func (CreateOrderMsg) GetSigners ¶
func (msg CreateOrderMsg) GetSigners() []sdk.AccAddress
func (CreateOrderMsg) String ¶
func (msg CreateOrderMsg) String() string
func (CreateOrderMsg) ValidateBasic ¶
func (msg CreateOrderMsg) ValidateBasic() sdk.Error
ValidateBasic ...
type Keeper ¶
type Keeper struct {
// contains filtered or unexported fields
}
Keeper manages shipping orders
func (Keeper) CancelOrder ¶
CancelOrder vakudates the message and set the status of the target order to Cancelled
Only the issuer can cancel the order
func (Keeper) CompleteOrder ¶
CompleteOrder vakudates the message and set the status of the target order to Completed
Only the receiver can complete the order, and only when the order is confirmed
func (Keeper) ConfirmOrder ¶
ConfirmOrder validate the message and set the status of the target order to Completed
Only the carrier can confirm the order, and only when the order is pending
func (Keeper) CreateOrder ¶
CreateOrder validates and creates a new order
type Order ¶
type Order struct { ID string `json:"id"` // ID of the order, provided by the client TransportedAssets []TransportedAsset `json:"transported_assets"` // The assets to be transported Issuer sdk.AccAddress `json:"issuer"` // The issuer of the order, must also be the owner of the asset (coin) Carrier sdk.AccAddress `json:"carrier"` // The carrier Receiver sdk.AccAddress `json:"receiver"` // The receiver, often a buyer Status OrderStatus `json:"status"` // The status of the order }
Order is a shipping order
type OrderStatus ¶
type OrderStatus int
OrderStatus represents the order's status
const ( OrderStatusPending OrderStatus = iota // Order has been created OrderStatusConfirmed // The carrier received the asset from the issuer OrderStatusCompleted // The receiver received the asset from the carrier OrderStatusCancelled // Order is cancelled )
Valid status of an order
type TransportedAsset ¶
type TransportedAsset struct {
ID string `json:"id"` // ID of the asset (coin) to be transported
}
TransportedAsset contains the id of the asset and the quantity to be transported