-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update currency string representation #115
Conversation
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice!
packages/protocol/src/dev-tools.ts
Outdated
@@ -202,8 +202,8 @@ export class DevTools { | |||
btcAddress: '1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa' | |||
} | |||
}, | |||
payinSubunits : '20000', | |||
claims : [signedCredential] | |||
payinAmount : '20000', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
payinAmount : '20000', | |
payinAmount : '200.00', |
@@ -226,9 +226,9 @@ export type QuoteDetails = { | |||
/** ISO 3166 currency code string */ | |||
currencyCode: string | |||
/** The amount of currency expressed in the smallest respective unit */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/** The amount of currency expressed in the smallest respective unit */ | |
/** The amount of currency to two decimal places expressed as a string (ie. '1000.00')*/ |
packages/protocol/tests/rfq.spec.ts
Outdated
@@ -21,8 +21,8 @@ const rfqData: RfqData = { | |||
btcAddress: '1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa' | |||
} | |||
}, | |||
payinSubunits : '20000', | |||
claims : [''] | |||
payinAmount : '20000', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
payinAmount : '20000', | |
payinAmount : '200.00', |
packages/protocol/tests/rfq.spec.ts
Outdated
@@ -190,8 +190,8 @@ describe('Rfq', () => { | |||
btcAddress: '1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa' | |||
} | |||
}, | |||
payinSubunits : '20000', | |||
claims : [signedCredential] | |||
payinAmount : '20000', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
payinAmount : '20000', | |
payinAmount : '200.00', |
packages/protocol/tests/rfq.spec.ts
Outdated
@@ -229,8 +229,8 @@ describe('Rfq', () => { | |||
btcAddress: '1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa' | |||
} | |||
}, | |||
payinSubunits : '20000', | |||
claims : [signedCredential] | |||
payinAmount : '20000', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
payinAmount : '20000', | |
payinAmount : '200.00', |
packages/http-server/src/fakes.ts
Outdated
}, | ||
payoutUnitsPerPayinUnit : '0.000038', | ||
payinMethods : [{ | ||
rate : '0.000038', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why the rename to rate
? We have had issues knowing which direction the rate is hence the explicitness
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was suggested in the issue and I liked it. But I'll revert if it's controversial.
@@ -31,7 +31,9 @@ export class Close extends Message<'close'> { | |||
} | |||
|
|||
const message = { metadata, data: opts.data } | |||
return new Close(message) | |||
const close = new Close(message) | |||
await Message.validate(close) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Message.validate
is not async so I don't think we need to await this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Decided to remove Message.validate
entirely since it's requires signature
to be present even though the message is not signed at this point.
@@ -31,7 +31,9 @@ export class Offering extends Resource<'offering'> { | |||
} | |||
|
|||
const message = { metadata, data: opts.data } | |||
return new Offering(message) | |||
const offering = new Offering(message) | |||
await Resource.validate(offering) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Resource.validate
is not async
@@ -32,7 +33,9 @@ export class OrderStatus extends Message<'orderstatus'> { | |||
} | |||
|
|||
const message = { metadata, data: opts.data } | |||
return new OrderStatus(message) | |||
const orderStatus = new OrderStatus(message) | |||
await Message.validate(order) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto not async
@@ -31,6 +31,8 @@ export class Order extends Message<'order'> { | |||
} | |||
|
|||
const message = { metadata, data: {} } | |||
return new Order(message) | |||
const order = new Order(message) | |||
await Message.validate(order) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto not async
@@ -32,7 +32,9 @@ export class Quote extends Message<'quote'> { | |||
} | |||
|
|||
const message = { metadata, data: opts.data } | |||
return new Quote(message) | |||
const quote = new Quote(message) | |||
await Message.validate(quote) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto not async
@@ -44,7 +44,9 @@ export class Rfq extends Message<'rfq'> { | |||
// TODO: hash `data.payoutMethod.paymentDetails` and set `private` | |||
|
|||
const message = { metadata, data: opts.data } | |||
return new Rfq(message) | |||
const rfq = new Rfq(message) | |||
await Message.validate(rfq) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto not async
Closing this PR because I forgot about (woops) and then reimplemented this change but more thoroughly in #134. |
Update currency amount representation and validation based on this spec change: TBD54566975/tbdex#206
Changes based on the spec
Notes
I added an
await Message.validate(<message-object>
to each#create
method. Since the updated test-vectors in the spec change PR include regex for decimal strings, we can useMessage.validate()
to check that currency strings are in fact valid.