cosmos / cosmjs

The Swiss Army knife to power JavaScript based client solutions ranging from Web apps/explorers over browser extensions to server-side clients like faucets/scrapers.
https://cosmos.github.io/cosmjs/
Apache License 2.0
635 stars 328 forks source link

fix: Ensure RFC dates between years 0001 and 0099 are parsed correctly #1516

Closed clockworkgr closed 7 months ago

clockworkgr commented 8 months ago

This fixes an issue where an RFC3339 Date like 0001-01-01T00:00:00Z (which is used as the default/empty/ value in CommitSig.Timestamp when BlockIdFlag is ABSENT) was parsed as 1901-01-01T00:00:00Z due to the way Date.UTC() treats years 0 to 99.

This led to incorrect timestamps being generated.

Unit test has been added.

clockworkgr commented 8 months ago

Related: https://github.com/confio/cosmjs-types/issues/89

clockworkgr commented 8 months ago

This change, combined with the fact we no longer allow empty/unset fields in cosmjs-types means that this:

https://github.com/cosmos/cosmjs/issues/704#issuecomment-797122415

must be addressed by no longer treating the timestamp as optional.

webmaster128 commented 7 months ago

Released in 0.32.1 – thanks a lot!