Skip to content

Commit

Permalink
blehhhhh (#109)
Browse files Browse the repository at this point in the history
* Rename presentationRequest to presentationDefinition
* Yeet the protocol folder
* Yeet the implementations folder
* `Close` message type (#110)
---------

Co-authored-by: Moe Jangda <[email protected]>
  • Loading branch information
phoebe-lew and mistermoe authored Jul 6, 2023
1 parent 8698e2d commit 82b61d8
Show file tree
Hide file tree
Showing 45 changed files with 397 additions and 310 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release-npm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
publish-npm:
defaults:
run:
working-directory: protocol/implementations/js
working-directory: js
shell: bash
name: NPM Publish
runs-on: ubuntu-latest
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
security-audit:
defaults:
run:
working-directory: protocol/implementations/js
working-directory: js
shell: bash
runs-on: ubuntu-latest
steps:
Expand All @@ -33,7 +33,7 @@ jobs:
test-with-node:
defaults:
run:
working-directory: protocol/implementations/js
working-directory: js
shell: bash
runs-on: ubuntu-latest
steps:
Expand Down Expand Up @@ -62,7 +62,7 @@ jobs:
# Run browser tests using macOS so that WebKit tests don't fail under a Linux environment
defaults:
run:
working-directory: protocol/implementations/js
working-directory: js
shell: bash
runs-on: macos-latest
steps:
Expand Down
2 changes: 1 addition & 1 deletion CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
# The format is described: https://github.blog/2017-07-06-introducing-code-owners/

# These owners will be the default owners for everything in the repo.
* @michaelneale @mistermoe @jiyoontbd @phoebe-lew
* @michaelneale @mistermoe @jiyoontbd @phoebe-lew @KendallWeihe


# -----------------------------------------------
Expand Down
106 changes: 70 additions & 36 deletions README.md

Large diffs are not rendered by default.

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import tbdexMessage from '../../json-schemas/message.schema.json' assert { type:
import offering from '../../json-schemas/offering.schema.json' assert { type: 'json' }
import rfq from '../../json-schemas/rfq.schema.json' assert { type: 'json' }
import quote from '../../json-schemas/quote.schema.json' assert { type: 'json' }
import close from '../../json-schemas/close.schema.json' assert { type: 'json' }
import order from '../../json-schemas/order.schema.json' assert { type: 'json' }
import orderStatus from '../../json-schemas/order-status.schema.json' assert { type: 'json' }

Expand All @@ -30,6 +31,7 @@ const schemas = {
tbdexMessage,
offering,
rfq,
close,
quote,
order,
orderStatus
Expand Down
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@tbd54566975/tbdex",
"version": "0.0.10",
"version": "0.0.11",
"type": "module",
"description": "Library that includes type definitions for tbdex messages",
"license": "Apache-2.0",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,6 @@
import { MessageType, MessageTypes, TbDEXMessage } from './types.js'
import { MessageType, MessageTypes, TbDEXMessage, XOR } from './types.js'
import { createTbdexId } from './id.js'

/**
* Get the keys of T without any keys of U.
*/
type Without<T, U> = { [P in Exclude<keyof T, keyof U>]?: never }

/**
* Restrict using either only the keys of T or only the keys of U.
*/
type XOR<T, U> = (T | U) extends object ? (Without<T, U> & U) | (Without<U, T> & T) : T | U

type NewThreadOpts = {
from: string,
to: string,
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
const CloseRules = {
$actions: [
{
who : 'recipient',
of : 'RFQ',
can : 'write'
},
{
who : 'author',
of : 'RFQ',
can : 'write'
},
],
}

export const aliceProtocolDefinition = {
protocol : 'https://tbd.website/protocols/tbdex',
types : {
Expand All @@ -13,6 +28,12 @@ export const aliceProtocolDefinition = {
'application/json'
]
},
Close: {
schema : 'https://tbd.website/protocols/tbdex/Close',
dataFormats : [
'application/json'
]
},
OrderStatus: {
schema : 'https://tbd.website/protocols/tbdex/OrderStatus',
dataFormats : [
Expand All @@ -32,7 +53,9 @@ export const aliceProtocolDefinition = {
can : 'write'
}
],
// OrderStatus can be written to Alice's DWN by someone who wrote RFQ/Quote (i.e. PFI)
// Alice _or_ the PFI can Close/End the thread here.
Close: CloseRules,
// OrderStatus can be written to Alice's DWN by someone who wrote RFQ/QuoteResponse (i.e. PFI)
OrderStatus: {
$actions: [
{
Expand All @@ -42,7 +65,9 @@ export const aliceProtocolDefinition = {
}
]
}
}
},
// Alice _or_ the PFI can Close/End the thread here.
Close: CloseRules
}
}
}
Expand All @@ -63,6 +88,12 @@ export const pfiProtocolDefinition = {
'application/json'
]
},
Close: {
schema : 'https://tbd.website/protocols/tbdex/Close',
dataFormats : [
'application/json'
]
},
OrderStatus: {
schema : 'https://tbd.website/protocols/tbdex/OrderStatus',
dataFormats : [
Expand All @@ -80,11 +111,15 @@ export const pfiProtocolDefinition = {
can : 'write'
}
],
// PFI is sending OUT quotes. no one should be writing Quotes to PFIs.
// Alice _or_ the PFI can Close/End the thread here.
Close: CloseRules,
// PFI is sending OUT quote responses. no one should be writing QuoteResponse to PFIs.
Quote: {
// PFI is sending OUT OrderStatus. no one should be writing OrderStatus to PFIs.
OrderStatus: { }
OrderStatus: { },
// Alice _or_ the PFI can Close/End the thread here.
Close: CloseRules
}
}
}
}
}
33 changes: 24 additions & 9 deletions protocol/implementations/js/src/types.ts → js/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ export interface Offering {
description: string
baseCurrency: string
quoteCurrency: string
unitPrice: string
baseFee?: string
min: string
max: string
unitPriceDollars: string
baseFeeDollars?: string
minDollars: string
maxDollars: string
kycRequirements: string
payinMethods: PaymentMethod[]
payoutMethods: PaymentMethod[]
Expand All @@ -23,7 +23,7 @@ export interface Offering {

export interface PaymentMethod {
kind: string
paymentPresentationRequestJwt?: string
paymentPresentationDefinitionJwt?: string
fee?: {
flatFee?: string
}
Expand All @@ -34,6 +34,7 @@ export type MessageType<M extends keyof MessageTypes> = MessageTypes[M]
export type MessageTypes = {
rfq: Rfq
quote: Quote
close: Close
orderStatus: OrderStatus
}

Expand All @@ -52,8 +53,8 @@ export type TbDEXMessage<T extends keyof MessageTypes> = MessageMetadata & {
}

export interface Rfq {
offeringId: string,
amount: string
offeringId: string
amountCents: string
kycProof: string
payinMethod: PaymentMethodResponse
payoutMethod: PaymentMethodResponse
Expand All @@ -66,11 +67,15 @@ export interface PaymentMethodResponse {

export interface Quote {
expiryTime: string
totalFee: string
amount: string
totalFeeCents: string
amountCents: string
paymentInstructions?: PaymentInstructions
}

export interface Close {
reason?: string
}

export interface PaymentInstructions {
payin?: PaymentInstruction
payout?: PaymentInstruction
Expand All @@ -89,3 +94,13 @@ export enum Status {
COMPLETED,
FAILED
}

/**
* Get the keys of T without any keys of U.
*/
export type Without<T, U> = { [P in Exclude<keyof T, keyof U>]?: never }

/**
* Restrict using either only the keys of T or only the keys of U.
*/
export type XOR<T, U> = (T | U) extends object ? (Without<T, U> & U) | (Without<U, T> & T) : T | U
File renamed without changes.
50 changes: 50 additions & 0 deletions js/tbdex_schema_examples.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
let offering = {
'description': 'Buy BTC with USD!',
'pair': 'BTC_USD',
'unitPrice': '27000.00',
'baseFee': '1.00',
'min': '10.00',
'max': '1000.00',
'presentationDefinitionJwt': 'eyJhb...MIDw',
'payinInstruments': [{
'kind': 'DEBIT_CARD',
'fee': {
'flatFee': '1.00'
}
}],
'payoutInstruments': [{
'kind': 'BTC_ADDRESS'
}]
}

let rfq = {
'pair': 'BTC_USD',
'amount': '10.00',
'verifiablePresentationJwt': '...',
'payinInstrument': {
'kind': 'DEBIT_CARD'
},
'payoutInstrument': {
'kind': 'BTC_ADDRESS'
}
}

let quote = {
'expiryTime': '2023-04-14T12:12:12Z',
'totalFee': '2.00',
'amount': '0.000383',
'paymentpresentationDefinitionJwt': 'eyJhbGc...EWfNnAw',
'paymentInstructions': {
'payin': {
'link': 'stripe.com?for=alice'
}
}
}

let order = {
'paymentVerifiablePresentationJwt': '...'
}

let orderStatus = {
'orderStatus': 'PENDING'
}
Loading

0 comments on commit 82b61d8

Please sign in to comment.