core/types: block timestamp in log should encode as hex

This commit is contained in:
lightclient 2025-07-01 06:53:37 -06:00
parent cc8d58fdc0
commit 49d414e975
No known key found for this signature in database
GPG key ID: 657913021EF45A6A
10 changed files with 17 additions and 16 deletions

View file

@ -22,7 +22,7 @@ func (l Log) MarshalJSON() ([]byte, error) {
TxHash common.Hash `json:"transactionHash" gencodec:"required" rlp:"-"`
TxIndex hexutil.Uint `json:"transactionIndex" rlp:"-"`
BlockHash common.Hash `json:"blockHash" rlp:"-"`
BlockTimestamp uint64 `json:"blockTimestamp" rlp:"-"`
BlockTimestamp hexutil.Uint64 `json:"blockTimestamp" rlp:"-"`
Index hexutil.Uint `json:"logIndex" rlp:"-"`
Removed bool `json:"removed" rlp:"-"`
}
@ -34,7 +34,7 @@ func (l Log) MarshalJSON() ([]byte, error) {
enc.TxHash = l.TxHash
enc.TxIndex = hexutil.Uint(l.TxIndex)
enc.BlockHash = l.BlockHash
enc.BlockTimestamp = l.BlockTimestamp
enc.BlockTimestamp = hexutil.Uint64(l.BlockTimestamp)
enc.Index = hexutil.Uint(l.Index)
enc.Removed = l.Removed
return json.Marshal(&enc)
@ -50,7 +50,7 @@ func (l *Log) UnmarshalJSON(input []byte) error {
TxHash *common.Hash `json:"transactionHash" gencodec:"required" rlp:"-"`
TxIndex *hexutil.Uint `json:"transactionIndex" rlp:"-"`
BlockHash *common.Hash `json:"blockHash" rlp:"-"`
BlockTimestamp *uint64 `json:"blockTimestamp" rlp:"-"`
BlockTimestamp *hexutil.Uint64 `json:"blockTimestamp" rlp:"-"`
Index *hexutil.Uint `json:"logIndex" rlp:"-"`
Removed *bool `json:"removed" rlp:"-"`
}
@ -84,7 +84,7 @@ func (l *Log) UnmarshalJSON(input []byte) error {
l.BlockHash = *dec.BlockHash
}
if dec.BlockTimestamp != nil {
l.BlockTimestamp = *dec.BlockTimestamp
l.BlockTimestamp = uint64(*dec.BlockTimestamp)
}
if dec.Index != nil {
l.Index = uint(*dec.Index)

View file

@ -56,8 +56,9 @@ type Log struct {
}
type logMarshaling struct {
Data hexutil.Bytes
BlockNumber hexutil.Uint64
TxIndex hexutil.Uint
Index hexutil.Uint
Data hexutil.Bytes
BlockNumber hexutil.Uint64
TxIndex hexutil.Uint
BlockTimestamp hexutil.Uint64
Index hexutil.Uint
}

View file

@ -17,4 +17,4 @@
"transactionIndex": "0x0",
"type": "0x3"
}
]
]

View file

@ -15,4 +15,4 @@
"transactionIndex": "0x0",
"type": "0x2"
}
]
]

View file

@ -20,7 +20,7 @@
"transactionHash": "0xeaf3921cbf03ba45bad4e6ab807b196ce3b2a0b5bacc355b6272fa96b11b4287",
"transactionIndex": "0x0",
"blockHash": "0xcc6225bf39327429a3d869af71182d619a354155187d0b5a8ecd6a9309cffcaa",
"blockTimestamp": 30,
"blockTimestamp": "0x1e",
"logIndex": "0x0",
"removed": false
}

View file

@ -17,4 +17,4 @@
"transactionIndex": "0x0",
"type": "0x3"
}
]
]

View file

@ -15,4 +15,4 @@
"transactionHash": "0x80348f994fb5f3b05bd2e5f58bbdc73485e449c028612a2c0680f9ac6ff70add",
"transactionIndex": "0x0",
"type": "0x3"
}
}

View file

@ -13,4 +13,4 @@
"transactionHash": "0x173dffc76966c72542560c376ce512a871e31b86988f9169bf021da0937640f9",
"transactionIndex": "0x0",
"type": "0x1"
}
}

View file

@ -13,4 +13,4 @@
"transactionHash": "0xdcde2574628c9d7dff22b9afa19f235959a924ceec65a9df903a517ae91f5c84",
"transactionIndex": "0x0",
"type": "0x2"
}
}

View file

@ -19,7 +19,7 @@
"transactionHash": "0xeaf3921cbf03ba45bad4e6ab807b196ce3b2a0b5bacc355b6272fa96b11b4287",
"transactionIndex": "0x0",
"blockHash": "0xcc6225bf39327429a3d869af71182d619a354155187d0b5a8ecd6a9309cffcaa",
"blockTimestamp": 30,
"blockTimestamp": "0x1e",
"logIndex": "0x0",
"removed": false
}