Skip to content
This repository has been archived by the owner on Dec 12, 2024. It is now read-only.

Commit

Permalink
Fixes (#151)
Browse files Browse the repository at this point in the history
* fix `Order` class

* make RFQ returned by `DevTools.createRfq` realistic

* refactor so its easier to call methods specific to an individual message kind (e.g. rfq)

* add npm script to auto generate API reference docs

* fix typo

* include request token when making request to get an exchange

* add placeholders for `Rfq.private`

* make `Resource` and abstract class

* implement Rfq method that checks vc's against an offering's `vcRequirements`

* bump version

* remove unused dependency hardlock dependency versions
  • Loading branch information
mistermoe authored Sep 4, 2023
1 parent 8caf774 commit 94fc7b8
Show file tree
Hide file tree
Showing 22 changed files with 1,482 additions and 428 deletions.
73 changes: 72 additions & 1 deletion js/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
# tbDEX Protocol <!-- omit in toc -->

Library that can be used to:
* create, parse, verify, and validate the tbDEX Messages and Resources defined in the [protocol specification](../README.md)
* send requests to PFIs
# Table of Contents <!-- omit in toc -->
- [Installation](#installation)
- [Usage](#usage)
- [Message Creation](#message-creation)
- [Message Parsing](#message-parsing)
- [Message Validation](#message-validation)
- [Integrity Check](#integrity-check)
- [Sending Requests](#sending-requests)
- [Development](#development)
- [Prerequisites](#prerequisites)
- [`node` and `npm`](#node-and-npm)
Expand All @@ -17,8 +26,70 @@ npm install @tbd54566975/tbdex
```

# Usage
TODO: Fill out

## Message Creation
There's a concrete class for each [Message Kind](../README.md#message-kinds). These classes can be used to create messages. e.g.
```typescript
import { DevTools, Rfq } from '@tbd54566975/tbdex'

const rfq = Rfq.create({
metadata : { from: alice.did, to: 'did:ex:pfi' },
data : {
offeringId : 'abcd123',
payinMethod : {
kind : 'DEBIT_CARD',
paymentDetails : {
'cardNumber' : '1234567890123456',
'expiryDate' : '12/22',
'cardHolderName' : 'Ephraim Bartholomew Winthrop',
'cvv' : '123'
}
},
payoutMethod: {
kind : 'BTC_ADDRESS',
paymentDetails : {
btcAddress: '1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa'
}
},
quoteAmountSubunits : '20000',
vcs : ''
}
})

await rfq.sign(alice)

console.log(JSON.stringify(rfq, null, 2))
```

## Message Parsing
All messages can be parsed from json into an instance of the Message Kind's class using the `Message.parse` method. e.g.

```typescript
import { Message } from '@tbd54566975/tbdex'

const jsonMessage = "<SERIALIZED_MESSAGE>"
const message = await Message.parse(jsonMessage)

if (message.isRfq()) {
// rfq specific logic
}
```

Parsing a message includes format validation and integrity checking

## Message Validation
> [!NOTE]
>
> TODO: Fill Out
## Integrity Check
> [!NOTE]
>
> TODO: Fill Out
## Sending Requests
> [!NOTE]
>
> TODO: Fill Out
# Development

Expand Down
Loading

0 comments on commit 94fc7b8

Please sign in to comment.