diff --git a/js/package-lock.json b/js/package-lock.json index 379faa8f..03122b9c 100644 --- a/js/package-lock.json +++ b/js/package-lock.json @@ -1,6 +1,6 @@ { "name": "@tbd54566975/tbdex", - "version": "0.0.12", + "version": "0.0.13", "lockfileVersion": 3, "requires": true, "packages": { diff --git a/js/package.json b/js/package.json index e16b88e8..3c855406 100644 --- a/js/package.json +++ b/js/package.json @@ -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", diff --git a/js/src/types.ts b/js/src/types.ts index 177a94f3..d7cd7e96 100644 --- a/js/src/types.ts +++ b/js/src/types.ts @@ -12,27 +12,27 @@ export type ResourceTypes = { export type TbDEXResource = ResourceType -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 = MessageTypes[M] @@ -60,30 +60,31 @@ export type TbDEXMessage = 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 } diff --git a/js/tbdex_types_examples.ts b/js/tbdex_types_examples.ts index e55e90cb..c384bfa8 100644 --- a/js/tbdex_types_examples.ts +++ b/js/tbdex_types_examples.ts @@ -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 = { @@ -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, @@ -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' +} \ No newline at end of file