order

package
v0.13.0 Latest Latest
Warning

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

Go to latest
Published: May 7, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const Kind = "order"

Kind is the value used within a message's metadata.kind

Variables

This section is empty.

Functions

func ValidNext added in v0.11.0

func ValidNext() []string

ValidNext returns the valid message kinds that can follow an order.

Types

type CreateOption

type CreateOption func(*createOptions)

CreateOption defines a type for functions that can modify the createOptions struct.

func CreatedAt

func CreatedAt(t time.Time) CreateOption

CreatedAt can be passed to Create to provide a custom created at time.

func ExternalID

func ExternalID(externalID string) CreateOption

ExternalID can be passed to Create to provide a external id.

func ID

func ID(id string) CreateOption

ID can be passed to Create to provide a custom id.

type Data

type Data struct{}

Data represents the data field of an order message. Note that this is intentionally left empty as per the spec

type Order

type Order struct {
	Metadata  message.Metadata `json:"metadata,omitempty"`
	Data      Data             `json:"data,omitempty"`
	Signature string           `json:"signature,omitempty"`
}

Order represents a tbdex order message.

func Create

func Create(fromDID did.BearerDID, to, exchangeID string, opts ...CreateOption) (Order, error)

Create creates a new order message. The following are generated by default unless custom values are provided:

  • created at time is set to the current time
  • protocol is set to "1.0"
  • id is autogenerated

func Parse

func Parse(data []byte) (Order, error)

Parse unmarshals the provided input into an Order and then verifies the signature.

func (Order) Digest

func (o Order) Digest() ([]byte, error)

Digest computes a hash of the order

func (Order) GetKind added in v0.13.0

func (o Order) GetKind() string

GetKind returns the kind of message

func (Order) GetMetadata added in v0.13.0

func (o Order) GetMetadata() message.Metadata

GetMetadata returns the metadata of the message

func (Order) GetValidNext added in v0.13.0

func (o Order) GetValidNext() []string

GetValidNext returns the valid message kinds that can follow an order.

func (*Order) UnmarshalJSON

func (o *Order) UnmarshalJSON(data []byte) error

UnmarshalJSON validates and unmarshals the input data into an Order.

func (*Order) Verify

func (o *Order) Verify() error

Verify verifies the order's signature.

Jump to

Keyboard shortcuts

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