Skip to content

Commit

Permalink
Update currency string representation
Browse files Browse the repository at this point in the history
  • Loading branch information
diehuxx committed Dec 14, 2023
1 parent 5631d32 commit a40c636
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 25 deletions.
4 changes: 2 additions & 2 deletions packages/http-server/src/fakes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ const offering = Offering.create({
},
payoutCurrency: {
currencyCode : 'BTC',
maxSubunits : '99952611'
maxAmount : '999526.11'
},
payoutUnitsPerPayinUnit : '0.000038',
rate : '0.000038',
payinMethods : [{
kind : 'DEBIT_CARD',
requiredPaymentDetails : {
Expand Down
4 changes: 2 additions & 2 deletions packages/protocol/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ const rfq = Rfq.create({
btcAddress: '1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa'
}
},
quoteAmountSubunits : '20000',
vcs : ''
amount : '200.00',
vcs : ''
}
})

Expand Down
10 changes: 5 additions & 5 deletions packages/protocol/src/dev-tools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,10 @@ export class DevTools {
},
payoutCurrency: {
currencyCode : 'BTC',
maxSubunits : '99952611'
maxAmount : '999526.11'
},
payoutUnitsPerPayinUnit : '0.00003826',
payinMethods : [{
rate : '0.00003826',
payinMethods : [{
kind : 'DEBIT_CARD',
requiredPaymentDetails : {
$schema : 'http://json-schema.org/draft-07/schema',
Expand Down Expand Up @@ -202,8 +202,8 @@ export class DevTools {
btcAddress: '1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa'
}
},
payinSubunits : '20000',
claims : [signedCredential]
payinAmount : '20000',
claims : [signedCredential]
}

return Rfq.create({
Expand Down
6 changes: 3 additions & 3 deletions packages/protocol/src/message-kinds/rfq.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export class Rfq extends Message<'rfq'> {
throw new Error(`offering id mismatch. (rfq) ${this.offeringId} !== ${offering.metadata.id} (offering)`)
}

// TODO: validate rfq's quoteAmountSubunits against offering's quoteCurrency min/max
// TODO: validate rfq's payinAmount against offering's quoteCurrency min/max

// TODO: validate rfq's payinMethod.kind against offering's payinMethods
// TODO: validate rfq's payinMethod.paymentDetails against offering's respective requiredPaymentDetails json schema
Expand Down Expand Up @@ -91,8 +91,8 @@ export class Rfq extends Message<'rfq'> {
}

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

/** Array of claims that satisfy the respective offering's requiredClaims */
Expand Down
4 changes: 2 additions & 2 deletions packages/protocol/src/resource-kinds/offering.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ export class Offering extends Resource<'offering'> {
}

/** Number of payout currency units for one payin currency unit (i.e 290000 USD for 1 BTC) */
get payoutUnitsPerPayinUnit() {
return this.data.payoutUnitsPerPayinUnit
get rate() {
return this.data.rate
}

/** Details about the currency that the PFI is buying in exchange for payoutCurrency. */
Expand Down
12 changes: 6 additions & 6 deletions packages/protocol/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export type OfferingData = {
/** Brief description of what is being offered. */
description: string
/** Number of _payout_ currency units for one _payin_ currency unit (i.e 290000 USD for 1 BTC) */
payoutUnitsPerPayinUnit: string
rate: string
/** Details about the currency that the PFI is selling. */
payoutCurrency: CurrencyDetails
/** Details about the currency that the PFI is buying in exchange for payout currency. */
Expand All @@ -96,9 +96,9 @@ export type CurrencyDetails = {
/** ISO 3166 currency code string */
currencyCode: string
/** Minimum amount of currency that can be requested */
minSubunits?: string
minAmount?: string
/** Maximum amount of currency that can be requested */
maxSubunits?: string
maxAmount?: string
}

/**
Expand Down Expand Up @@ -182,7 +182,7 @@ export type RfqData = {
/** 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 */
payinSubunits: string
payinAmount: string
/** Selected payment method that Alice will use to send the listed payin currency to the PFI. */
payinMethod: SelectedPaymentMethod
/** Selected payment method that the PFI will use to send the listed base currency to Alice */
Expand Down Expand Up @@ -226,9 +226,9 @@ export type QuoteDetails = {
/** ISO 3166 currency code string */
currencyCode: string
/** The amount of currency expressed in the smallest respective unit */
amountSubunits: string
amount: string
/** the amount paid in fees */
feeSubunits?: string
fee?: string
}

/**
Expand Down
4 changes: 2 additions & 2 deletions packages/protocol/tests/offering.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ const offeringData: OfferingData = {
},
payoutCurrency: {
currencyCode : 'BTC',
maxSubunits : '99952611'
maxAmount : '999526.11'
},
payoutUnitsPerPayinUnit : '0.00003826',
rate : '0.00003826',
payinMethods : [{
kind : 'DEBIT_CARD',
requiredPaymentDetails : {
Expand Down
6 changes: 3 additions & 3 deletions packages/protocol/tests/rfq.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const rfqData: RfqData = {
btcAddress: '1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa'
}
},
payinSubunits : '20000',
payinAmount : '20000',
claims : ['']
}

Expand Down Expand Up @@ -190,7 +190,7 @@ describe('Rfq', () => {
btcAddress: '1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa'
}
},
payinSubunits : '20000',
payinAmount : '20000',
claims : [signedCredential]
}
})
Expand Down Expand Up @@ -229,7 +229,7 @@ describe('Rfq', () => {
btcAddress: '1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa'
}
},
payinSubunits : '20000',
payinAmount : '20000',
claims : [signedCredential]
}
})
Expand Down

0 comments on commit a40c636

Please sign in to comment.