State-machine for validating the order and metadata of Tbdex messages in an exchange.

This state-machine does not validate the Message.signature or Message.data of messages in the exchange.

Either add messages in order one at a time using Exchange.addNextMessage, or add a list of unsorted messages in an exchange using Exchange.addMessages

Constructors

Properties

cancel: undefined | Cancel

Message sent by Alice to indicate that she does not wish to further propagate the exchange, and get a refund if applicable

close: undefined | Close

Message sent by the PFI to terminate an exchange

order: undefined | Order

Message sent by Alice to the PFI to accept a quote

orderInstructions: undefined | OrderInstructions

Message sent by the PFI to Alice to give payin and payout instructions

orderstatus: OrderStatus[]

Message sent by the PFI to Alice to convey the current status of the order

quote: undefined | Quote

Message sent by the PFI in response to an RFQ

rfq: undefined | Rfq

Message sent by Alice to PFI to request a quote

Accessors

  • get exchangeId(): undefined | string
  • The exchangeId of all messages in the Exchange

    Returns undefined | string

  • get latestMessage(): undefined | Message
  • Latest message in an exchange if there are any messages currently

    Returns undefined | Message

  • get messages(): Message[]
  • A sorted list of messages currently in the exchange.

    Returns Message[]

  • get protocol(): undefined | string
  • The protocol version of all messages in the Exchange

    Returns undefined | string

Methods

  • Add a list of unsorted messages to an exchange.

    Parameters

    • messages: Message[]

      An unsorted array of Tbdex messages in a given exchange

    Returns void

  • Add the next message in the exchange

    Parameters

    • message: Message

      The next allowed message in the exchange

    Returns void

    Throws

    if message's protocol version does not match protocol version of other messages in the exchange

    Throws

    if message is not a valid next message. See Exchange.isValidNext

    Throws

    if message's exchangeId does not match id of the exchange

  • Determines if the message kind is a valid next message in the current exchange

    Parameters

    Returns boolean

    true if the next message in the exchange may have kind messageKind, false otherwise