Skip to content

Commit

Permalink
Use Uint64 for BlockInfo Time
Browse files Browse the repository at this point in the history
  • Loading branch information
chipshort committed Nov 15, 2023
1 parent 6daf8e4 commit 3f0224c
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions spec/Specification.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ type Params struct {
type BlockInfo struct {
// block height this transaction is executed
Height uint64 `json:"height"`
// time in nanoseconds since unix epoch. Uses string to ensure JavaScript compatibility.
Time uint64 `json:"time,string"`
// time in nanoseconds since unix epoch. Uses Uint64 to ensure JavaScript compatibility.
Time Uint64 `json:"time"`
ChainID string `json:"chain_id"`
}

Expand Down
4 changes: 2 additions & 2 deletions types/env.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ type Env struct {
type BlockInfo struct {
// block height this transaction is executed
Height uint64 `json:"height"`
// time in nanoseconds since unix epoch. Uses string to ensure JavaScript compatibility.
Time uint64 `json:"time,string"`
// time in nanoseconds since unix epoch. Uses Uint64 to ensure JavaScript compatibility.
Time Uint64 `json:"time"`
ChainID string `json:"chain_id"`
}

Expand Down
2 changes: 1 addition & 1 deletion types/env_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,5 +92,5 @@ func TestBlockInfoDeserialization(t *testing.T) {

// Empty string is not a valid uint64 string
err = json.Unmarshal([]byte(`{"height":0,"time":"","chain_id":""}`), &block)
require.ErrorContains(t, err, "invalid use of ,string struct tag, trying to unmarshal \"\" into uint64")
require.ErrorContains(t, err, "cannot unmarshal \"\" into Uint64, expected string-encoded integer")
}

0 comments on commit 3f0224c

Please sign in to comment.