Skip to content
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

Amend the Node.js bindings Ledger API values representation #338

Merged
merged 1 commit into from
Apr 10, 2019

Conversation

stefanobaghino-da
Copy link
Contributor

Finishes the work started in #324:

  • drops deprecated name in identifiers, adopting moduleName and entityName
  • use string to represent timestamps to avoid a loss of precision
  • use string for dates too for consistency and future-proofness

The work unconvered a quite serious bug caused by the lack of coverage
on the validation of timestamps: the model was expecting timestamps to
be of type timestamp, whereas in Ledger API values they are represented
by numbers.

Pull Request Checklist

Finishes the work started in #324:

- drops deprecated `name` in identifiers, adopting `moduleName` and `entityName`
- use string to represent `timestamp`s to avoid a loss of precision
- use string for `date`s too for consistency and future-proofness

The work unconvered a quite serious bug caused by the lack of coverage
on the validation of timestamps: the model was expecting timestamps to
be of type timestamp, whereas in Ledger API values they are represented
by numbers.
@@ -44,7 +44,7 @@ message Value {
// epoch is greater than that. Range: 0001-01-01T00:00:00Z to
// 9999-12-31T23:59:59.999999Z, so that we can convert to/from
// https://www.ietf.org/rfc/rfc3339.txt
sfixed64 timestamp = 9;
sfixed64 timestamp = 9 [jstype = JS_STRING];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not use the [jstype = JS_STRING] annotation for int32 date = 14; below as well? Dates seem to be converted to strings manually in mapping/value.ts, whereas timestamps are converted to strings using the annotation.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[jstype = JS_STRING] only works on 64-bit numeric types.

@stefanobaghino-da stefanobaghino-da merged commit e775b49 into master Apr 10, 2019
@stefanobaghino-da stefanobaghino-da deleted the amend-nodejs-bindings-model branch April 10, 2019 08:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants