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

Commit

Permalink
backing out protocol changes
Browse files Browse the repository at this point in the history
  • Loading branch information
jiyoonie9 committed Jan 18, 2024
1 parent 50ac168 commit 79b71ef
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 78 deletions.
37 changes: 17 additions & 20 deletions packages/protocol/src/dev-tools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -233,27 +233,24 @@ export class DevTools {
}

return {
rfq: {
offeringId : Resource.generateId('offering'),
payinMethod : {
kind : 'DEBIT_CARD',
paymentDetails : {
'cardNumber' : '1234567890123456',
'expiryDate' : '12/22',
'cardHolderName' : 'Ephraim Bartholomew Winthrop',
'cvv' : '123'
}
},
payoutMethod: {
kind : 'BTC_ADDRESS',
paymentDetails : {
btcAddress: '1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa'
}
},
payinAmount : '200.00',
claims : [credential]
offeringId : Resource.generateId('offering'),
payinMethod : {
kind : 'DEBIT_CARD',
paymentDetails : {
'cardNumber' : '1234567890123456',
'expiryDate' : '12/22',
'cardHolderName' : 'Ephraim Bartholomew Winthrop',
'cvv' : '123'
}
},
payoutMethod: {
kind : 'BTC_ADDRESS',
paymentDetails : {
btcAddress: '1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa'
}
},
replyTo: 'https://tbdex.io/alice/callback'
payinAmount : '200.00',
claims : [credential]
}
}

Expand Down
10 changes: 5 additions & 5 deletions packages/protocol/src/message-kinds/rfq.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,27 +155,27 @@ export class Rfq extends Message<'rfq'> {

/** Offering which Alice would like to get a quote for */
get offeringId() {
return this.data.rfq.offeringId
return this.data.offeringId
}

/** Amount of payin currency you want to spend in order to receive payout currency */
get payinAmount() {
return this.data.rfq.payinAmount
return this.data.payinAmount
}

/** Array of claims that satisfy the respective offering's requiredClaims */
get claims() {
return this.data.rfq.claims
return this.data.claims
}

/** Selected payment method that Alice will use to send the listed payin currency to the PFI. */
get payinMethod() {
return this.data.rfq.payinMethod
return this.data.payinMethod
}

/** Selected payment method that the PFI will use to send the listed payout currency to Alice */
get payoutMethod() {
return this.data.rfq.payoutMethod
return this.data.payoutMethod
}

/**
Expand Down
11 changes: 0 additions & 11 deletions packages/protocol/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,17 +179,6 @@ export type MessageKinds = {
* @beta
*/
export type RfqData = {
/** Details of an RFQ (Request For Quote) */
rfq: RfqDetails
/** A string containing a valid URI where new messages from the PFI will be sent */
replyTo?: string
}

/**
* Details of an RFQ (Request For Quote)
* @beta
*/
export type RfqDetails = {
/** Offering which Alice would like to get a quote for */
offeringId: string
/** Amount of _payin_ currency alice wants to spend in order to receive payout currency */
Expand Down
70 changes: 28 additions & 42 deletions packages/protocol/tests/rfq.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,24 +159,20 @@ describe('Rfq', () => {
to : 'did:ex:pfi'
},
data: {
rfq: {
...(await DevTools.createRfqData()).rfq,
offeringId: offering.id
}
...await DevTools.createRfqData(),
offeringId: offering.id
}
}
rfqOptions.metadata.from = did.did
rfqOptions.data.rfq.claims = [signedCredential]
rfqOptions.data.claims = [signedCredential]
})

it('throws an error if offeringId doesn\'t match the provided offering\'s id', async () => {
const rfq = Rfq.create({
...rfqOptions,
data: {
rfq: {
...rfqOptions.data.rfq,
offeringId: 'ABC123456',
}
...rfqOptions.data,
offeringId: 'ABC123456',
}
})
try {
Expand All @@ -193,11 +189,9 @@ describe('Rfq', () => {
const rfq = Rfq.create({
...rfqOptions,
data: {
rfq: {
...rfqOptions.data.rfq,
payinAmount : '99999999999999999.0',
offeringId : offering.id
}
...rfqOptions.data,
payinAmount : '99999999999999999.0',
offeringId : offering.id
}
})
try {
Expand All @@ -212,12 +206,10 @@ describe('Rfq', () => {
const rfq = Rfq.create({
...rfqOptions,
data: {
rfq: {
...rfqOptions.data.rfq,
payinMethod: {
...rfqOptions.data.rfq.payinMethod,
kind: 'POKEMON'
}
...rfqOptions.data,
payinMethod: {
...rfqOptions.data.payinMethod,
kind: 'POKEMON'
}
}
})
Expand All @@ -233,13 +225,11 @@ describe('Rfq', () => {
const rfq = Rfq.create({
...rfqOptions,
data: {
rfq: {
...rfqOptions.data.rfq,
payinMethod: {
...rfqOptions.data.rfq.payinMethod,
paymentDetails: {
beep: 'boop'
}
...rfqOptions.data,
payinMethod: {
...rfqOptions.data.payinMethod,
paymentDetails: {
beep: 'boop'
}
}
}
Expand All @@ -256,12 +246,10 @@ describe('Rfq', () => {
const rfq = Rfq.create({
...rfqOptions,
data: {
rfq: {
...rfqOptions.data.rfq,
payoutMethod: {
...rfqOptions.data.rfq.payoutMethod,
kind: 'POKEMON'
}
...rfqOptions.data,
payoutMethod: {
...rfqOptions.data.payoutMethod,
kind: 'POKEMON'
}
}
})
Expand All @@ -277,13 +265,11 @@ describe('Rfq', () => {
const rfq = Rfq.create({
...rfqOptions,
data: {
rfq: {
...rfqOptions.data.rfq,
payoutMethod: {
...rfqOptions.data.rfq.payoutMethod,
paymentDetails: {
beep: 'boop'
}
...rfqOptions.data,
payoutMethod: {
...rfqOptions.data.payoutMethod,
paymentDetails: {
beep: 'boop'
}
}
}
Expand Down Expand Up @@ -311,7 +297,7 @@ describe('Rfq', () => {
})

const rfqData = await DevTools.createRfqData()
rfqData.rfq.claims = [signedCredential]
rfqData.claims = [signedCredential]

const rfq = Rfq.create({
metadata : { from: did.did, to: 'did:ex:pfi' },
Expand All @@ -334,7 +320,7 @@ describe('Rfq', () => {
})

const rfqData = await DevTools.createRfqData()
rfqData.rfq.claims = [signedCredential]
rfqData.claims = [signedCredential]

const rfq = Rfq.create({
metadata : { from: did.did, to: 'did:ex:pfi' },
Expand Down

0 comments on commit 79b71ef

Please sign in to comment.