shipping

package
v0.22.4 Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2018 License: Apache-2.0, Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CodeDuplicateOrderID sdk.CodeType = iota + 600
	CodeUnknownOrder
	CodeDuplicateAddress
	CodeInvalidAsset
	CodeInvalidInput
	DefaultCodespace sdk.CodespaceType = 10
)

ABCI Response Codes Base SDK reserves 500 - 599.

Variables

View Source
var (
	// Keys for store prefixes
	OrderKey         = []byte{0x06} // prefix for each key to a order
	AccountOrdersKey = []byte{0x01}
)

nolint

Functions

func CodeToDefaultMsg

func CodeToDefaultMsg(code sdk.CodeType) string

CodeToDefaultMsg NOTE: Don't stringer this, we'll put better messages in later.

func ErrDuplicateAddress

func ErrDuplicateAddress() sdk.Error

ErrDuplicateAddress ...

func ErrDuplicateOrder

func ErrDuplicateOrder(orderID string) sdk.Error

ErrDuplicateOrder ...

func ErrInvalidAsset added in v0.2.2

func ErrInvalidAsset() sdk.Error

ErrInvalidAsset ...

func ErrUnknownOrder

func ErrUnknownOrder(orderID string) sdk.Error

ErrUnknownOrder ...

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

func GetOrderKey(uid []byte) []byte

GetOrderKey get the key for the record with address

func NewHandler

func NewHandler(k Keeper) sdk.Handler

NewHandler ...

func NewPubKey added in v0.20.0

func NewPubKey(pk string) (res ed25519.PubKeyEd25519)

func RegisterWire

func RegisterWire(cdc *wire.Codec)

RegisterWire registers concrete types on wire codec

func TestAddr added in v0.20.0

func TestAddr(addr string, bech string) sdk.AccAddress

for incode address generation

func ValidatorByPowerIndexExists added in v0.20.0

func ValidatorByPowerIndexExists(ctx sdk.Context, keeper Keeper, power []byte) bool

does a certain by-power index record exist

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) Type

func (msg CancelOrderMsg) Type() string

nolint ...

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) Type

func (msg CompleteOrderMsg) Type() string

nolint ...

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) Type

func (msg ConfirmOrderMsg) Type() string

nolint ...

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) Type

func (msg CreateOrderMsg) Type() string

nolint ...

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 NewKeeper

func NewKeeper(storeKey sdk.StoreKey, cdc *wire.Codec, assetKeeper asset.Keeper) Keeper

NewKeeper constructs a new keeper

func (Keeper) CancelOrder

func (k Keeper) CancelOrder(ctx sdk.Context, msg CancelOrderMsg) (sdk.Tags, sdk.Error)

CancelOrder vakudates the message and set the status of the target order to Cancelled

Only the issuer can cancel the order

func (Keeper) CompleteOrder

func (k Keeper) CompleteOrder(ctx sdk.Context, msg CompleteOrderMsg) (sdk.Tags, sdk.Error)

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

func (k Keeper) ConfirmOrder(ctx sdk.Context, msg ConfirmOrderMsg) (sdk.Tags, sdk.Error)

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

func (k Keeper) CreateOrder(ctx sdk.Context, msg CreateOrderMsg) (sdk.Tags, sdk.Error)

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

Directories

Path Synopsis
client

Jump to

Keyboard shortcuts

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