Skip to content

Commit

Permalink
team offsite
Browse files Browse the repository at this point in the history
* overhauled offering
* introduced Subunits
* PaymentMethod.kind is now a string
* nuked the base fee
* overhauled quote. looks more like offering now.

Co-Authored-By: Jiyoon Koo <[email protected]>
Co-Authored-By: phoebe-lew <[email protected]>
Co-Authored-By: corcillo <[email protected]>
Co-Authored-By: Ethan Lee <[email protected]>
  • Loading branch information
5 people committed Jul 12, 2023
1 parent fcc3dd4 commit e187b66
Show file tree
Hide file tree
Showing 4 changed files with 103 additions and 70 deletions.
2 changes: 1 addition & 1 deletion js/package-lock.json

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

2 changes: 1 addition & 1 deletion js/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@tbd54566975/tbdex",
"version": "0.0.12",
"version": "0.0.13",
"type": "module",
"description": "Library that includes type definitions for tbdex messages",
"license": "Apache-2.0",
Expand Down
45 changes: 23 additions & 22 deletions js/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,27 +12,27 @@ export type ResourceTypes = {

export type TbDEXResource<R extends keyof ResourceTypes> = ResourceType<R>

export interface Offering {
export type CurrencyDetails = {
currencyCode: string
minSubunit?: string
maxSubunit?: string
}

export type Offering = {
id: string
description: string
baseCurrency: string
quoteCurrency: string
unitPriceDollars: string
baseFeeDollars?: string
minDollars: string
maxDollars: string
quoteUnitsPerBaseUnit: string
baseCurrency: CurrencyDetails
quoteCurrency: CurrencyDetails
kycRequirements: PresentationDefinitionV2
payinMethods: PaymentMethod[]
payoutMethods: PaymentMethod[]
createdTime: string
}

export interface PaymentMethod {
kind: string
requiredPaymentDetails?: JsonSchema
fee?: {
flatFee?: string
}
feeSubunits?: string
}

export type MessageType<M extends keyof MessageTypes> = MessageTypes[M]
Expand Down Expand Up @@ -60,30 +60,31 @@ export type TbDEXMessage<T extends keyof MessageTypes> = MessageMetadata & {

export interface Rfq {
offeringId: string
amountCents: string
quoteAmountSubunits: string
kycProof: string
payinMethod: PaymentMethodResponse
payoutMethod: PaymentMethodResponse
}

export interface PaymentMethodResponse {
kind: PaymentMethodKind
kind: string
paymentDetails?: {
[key: string]: any
}
}

export enum PaymentMethodKind {
BTC_ADDRESS = 'BTC_ADDRESS',
DEBIT_CARD = 'DEBIT_CARD',
APPLE_PAY = 'APPLE_PAY',
CASHAPP_PAY= 'CASHAPP_PAY'
}

export interface Quote {
expiryTime: string
totalFeeCents: string
amountCents: string
base: {
currencyCode: string
amountSubunits: string
feeSubunits?: string
}
quote: {
currencyCode: string
amountSubunits: string
feeSubunits?: string
}
paymentInstructions?: PaymentInstructions
}

Expand Down
124 changes: 78 additions & 46 deletions js/tbdex_types_examples.ts
Original file line number Diff line number Diff line change
@@ -1,32 +1,32 @@
import { PaymentMethodKind, TbDEXResource, MessageMetadata, TbDEXMessage, Status } from './src/types.js'
import { TbDEXResource, MessageMetadata, TbDEXMessage, Status, Quote } from './src/types.js'

const _offering: TbDEXResource<'offering'> = {
id : '123',
description : 'Buy BTC with USD!',
baseCurrency : 'BTC',
quoteCurrency : 'USD',
unitPrice : '27000.00',
baseFee : '1.00',
min : '10.00',
max : '1000.00',
// here's what we want to see in your KYC VC (full name, dob)
// maybe this is a sanctions VC? or maybe this is a silly VC that says 'send me a selfie'
kycRequirements : 'eyJhb...MIDw',
payinMethods : [{
kind : PaymentMethodKind.DEBIT_CARD,
// here's how to present your debit card info
paymentpresentationDefinitionJwt : 'ey...IAbZ',
fee : {
flatFee: '1.00'
}
}],
payoutMethods: [{
kind : PaymentMethodKind.BITCOIN_ADDRESS,
// how to present your BTC address info
paymentpresentationDefinitionJwt : 'ey...EbqW',
}],
createdTime: '2023-06-27T12:34:56Z'
}
// const _offering: TbDEXResource<'offering'> = {
// id : '123',
// description : 'Buy BTC with USD!',
// baseCurrency : 'BTC',
// quoteCurrency : 'USD',
// unitPrice : '27000.00',
// baseFee : '1.00',
// min : '10.00',
// max : '1000.00',
// // here's what we want to see in your KYC VC (full name, dob)
// // maybe this is a sanctions VC? or maybe this is a silly VC that says 'send me a selfie'
// kycRequirements : 'eyJhb...MIDw',
// payinMethods : [{
// kind : PaymentMethodKind.DEBIT_CARD,
// // here's how to present your debit card info
// paymentpresentationDefinitionJwt : 'ey...IAbZ',
// fee : {
// flatFee: '1.00'
// }
// }],
// payoutMethods: [{
// kind : PaymentMethodKind.BITCOIN_ADDRESS,
// // how to present your BTC address info
// paymentpresentationDefinitionJwt : 'ey...EbqW',
// }],
// createdTime: '2023-06-27T12:34:56Z'
// }


const _metadata: MessageMetadata = {
Expand All @@ -39,25 +39,25 @@ const _metadata: MessageMetadata = {
}


const _rfq: TbDEXMessage<'rfq'> = {
..._metadata,
type : 'rfq',
body : {
baseCurrency : 'BTC',
quoteCurrency : 'USD',
amount : '10.00',
kycProof : 'eyJApQf...wqfVkg', // heres my KYC VC
payinMethod : {
kind : PaymentMethodKind.DEBIT_CARD,
paymentVerifiablePresentationJwt : 'fdsafjdla'
},
payoutMethod: {
kind : PaymentMethodKind.BITCOIN_ADDRESS,
paymentVerifiablePresentationJwt : 'rewhiroew'
}
}
// const _rfq: TbDEXMessage<'rfq'> = {
// ..._metadata,
// type : 'rfq',
// body : {
// baseCurrency : 'BTC',
// quoteCurrency : 'USD',
// amount : '10.00',
// kycProof : 'eyJApQf...wqfVkg', // heres my KYC VC
// payinMethod : {
// kind : PaymentMethodKind.DEBIT_CARD,
// paymentVerifiablePresentationJwt : 'fdsafjdla'
// },
// payoutMethod: {
// kind : PaymentMethodKind.BITCOIN_ADDRESS,
// paymentVerifiablePresentationJwt : 'rewhiroew'
// }
// }

}
// }

const _quote: TbDEXMessage<'quote'> = {
..._metadata,
Expand All @@ -82,3 +82,35 @@ const _status: TbDEXMessage<'orderStatus'> = {
orderStatus: Status.PENDING
}
}


const offering1: TbDEXResource<'offering'> = {
'baseCurrency': {
'currencyCode': 'BTC',
},
'quoteCurrency': {
'currencyCode': 'USD'
},
'kycRequirements': {},
'payinMethods': [{
'kind': 'APPLE_PAY',
'feeSubunits': '300'
}],
'payoutMethods': [{
'kind': 'BTC_ADDRESS'
}],
'createdTime': 'happy time',
}

const quote1: Quote = {
'base': {
'currencyCode': 'BTC',
'amountSubunits': '10 MEELYON SATS',
},
'quote': {
'currencyCode': 'USD',
'amountSubunits': '29_000_000_000',
'feeSubunits': '300'
},
'expiryTime': 'sad time'
}

0 comments on commit e187b66

Please sign in to comment.