-
Notifications
You must be signed in to change notification settings - Fork 341
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
fix: Ensure RFC dates between years 0001 and 0099 are parsed correctly #1516
Conversation
Related: confio/cosmjs-types#89 |
This change, combined with the fact we no longer allow empty/unset fields in cosmjs-types means that this: must be addressed by no longer treating the timestamp as optional. |
function decodeCommitSignature(data: RpcSignature): CommitSignature { | ||
return { | ||
blockIdFlag: decodeBlockIdFlag(data.block_id_flag), | ||
validatorAddress: data.validator_address ? fromHex(data.validator_address) : undefined, | ||
timestamp: decodeOptionalTime(data.timestamp), | ||
timestamp: data.timestamp ? fromRfc3339WithNanoseconds(data.timestamp) : undefined, |
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.
sweet
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.
wanna run this past @ethanfrey who brought up the original issue that that hacky decodeOptionalTime()
was supposed to solve?
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. Could you add a CHANGELOG entry for this?
Released in 0.32.1 – thanks a lot! |
This fixes an issue where an RFC3339 Date like
0001-01-01T00:00:00Z
(which is used as the default/empty/ value inCommitSig.Timestamp
whenBlockIdFlag
isABSENT
) was parsed as1901-01-01T00:00:00Z
due to the wayDate.UTC()
treats years 0 to 99.This led to incorrect timestamps being generated.
Unit test has been added.